Events, EventViewer, Common prjs, UI.EventLogs, UI.Calendar, EventTriggers, GetCalendarEvents() in WT/I.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
///
|
||||
/// Copyright (c) 2020 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.Output.EventTriggers.Iperl
|
||||
{
|
||||
public class Factory : IComponentFactory
|
||||
{
|
||||
public string ClassName { get { return this.GetType().Namespace.Substring(17); } }
|
||||
|
||||
public void ResetStaticProperties() { Trigger.ResetStaticProperties(); }
|
||||
|
||||
public IComponent DummyComponent() { return new Trigger(); }
|
||||
|
||||
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Trigger(cfg); }
|
||||
|
||||
public IComponentCfg DefaultConfig() { return new TriggerCfg(this.GetType().Namespace.Substring(24), this); }
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
|
||||
{
|
||||
return ComponentCfgBase.CreateFromDbEntity(TriggerCfg.Serializer, component, this);;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
///
|
||||
/// Copyright (c) 2020 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using log4net;
|
||||
|
||||
namespace TBF.BenchControl.Output.EventTriggers.Iperl
|
||||
{
|
||||
public class Trigger : ComponentBase, IOperation, GenericDevices.IEventTrigger
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(Trigger));
|
||||
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(1)); }
|
||||
|
||||
readonly TriggerCfg triggerCfg;
|
||||
|
||||
Results.Entities.Batch batch;
|
||||
|
||||
|
||||
public Trigger() {}
|
||||
|
||||
public Trigger(Generic.IComponentCfg cfg)
|
||||
: base(cfg)
|
||||
{
|
||||
triggerCfg = cfg as TriggerCfg;
|
||||
ApplyConfig();
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
|
||||
void ApplyConfig()
|
||||
{
|
||||
}
|
||||
|
||||
#region Configuration Change Handling
|
||||
|
||||
public static void OnCfgChange(object sender, CfgChangeArgs args)
|
||||
{
|
||||
if (CfgChangeHandler == null) return;
|
||||
try { CfgChangeHandler(sender, args); }
|
||||
catch (Exception e) { log.Error("CfgChangeHandler(...) failed", e); }
|
||||
}
|
||||
|
||||
public static event EventHandler<CfgChangeArgs> CfgChangeHandler;
|
||||
|
||||
public override void StartChangeHandler()
|
||||
{
|
||||
CfgChangeHandler += delegate(object sender, CfgChangeArgs args)
|
||||
{
|
||||
TriggerCfg newCfg = args.Cfg as TriggerCfg;
|
||||
if (newCfg != null && newCfg.Name.Equals(Name))
|
||||
{
|
||||
if (args.Command == CfgChangeCmd.CfgChange)
|
||||
{
|
||||
triggerCfg.EventSource = newCfg.EventSource;
|
||||
triggerCfg.Culture = newCfg.Culture;
|
||||
triggerCfg.EliminateSpaces = newCfg.EliminateSpaces;
|
||||
triggerCfg.PrintCaption = newCfg.PrintCaption;
|
||||
|
||||
ApplyConfig();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endregion Configuration Change Handling
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Writes the test cycle results into a file
|
||||
/// Events:
|
||||
/// Event.ResultsWritten
|
||||
/// Event.Busy
|
||||
/// </summary>
|
||||
/// <param name="batch">Results to write into a file</param>
|
||||
/// <returns>Reference to the operation</returns>
|
||||
public IOperation ProcessResultsOp(Results.Entities.Batch batch)
|
||||
{
|
||||
this.batch = batch;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
Process(batch);
|
||||
}
|
||||
|
||||
/// <summary>Run this operation</summary>
|
||||
/// <returns>Event.ResultsProcessed</returns>
|
||||
public Event Run()
|
||||
{
|
||||
return Event.ResultsProcessed;
|
||||
}
|
||||
|
||||
/// <summary>Stop this operation</summary>
|
||||
public void Stop()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void Process(Results.Entities.Batch batch)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
///
|
||||
/// Copyright (c) 2020 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Xml.Serialization;
|
||||
using Config.Entities;
|
||||
using TBF.BenchControl.Generic;
|
||||
using TBF.Resources;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TBF.BenchControl.Output.EventTriggers.Iperl
|
||||
{
|
||||
/// <summary>
|
||||
/// Serializable configuration of Output.EventTriggers.Standard component.
|
||||
/// </summary>
|
||||
public class TriggerCfg : ComponentCfgBase, Generic.IComponentCfg, Config.Entities.IParamsProvider
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TriggerCfg) })[0];
|
||||
public override XmlSerializer GetSerializer() { return Serializer; }
|
||||
|
||||
public IComponentCfgCtrl GetControl() { return new Configs.ParamsProvider.ComponentCfgCtrl(this, null); }
|
||||
|
||||
///
|
||||
/// Serialized parameters
|
||||
///
|
||||
public string EventSource;
|
||||
public Culture Culture;
|
||||
public bool EliminateSpaces;
|
||||
public bool PrintCaption;
|
||||
|
||||
/// Private parameterless constructor invoked by all other (public) constructors
|
||||
TriggerCfg() {}
|
||||
|
||||
public TriggerCfg(string name, IComponentFactory factory)
|
||||
: this()
|
||||
{
|
||||
Name = name;
|
||||
Factory = factory;
|
||||
ParentName = string.Empty;
|
||||
InitializeAll();
|
||||
}
|
||||
|
||||
public string ComponentName { get { return Name; } }
|
||||
|
||||
public void InitializeAll()
|
||||
{
|
||||
EventSource = "Výsledky iPERL";
|
||||
Culture = Culture.EN;
|
||||
EliminateSpaces = false;
|
||||
PrintCaption = false;
|
||||
}
|
||||
|
||||
string[] paramNames = new string[]
|
||||
{
|
||||
"Event source",
|
||||
"Culture",
|
||||
"Eliminate spaces",
|
||||
"Print caption",
|
||||
};
|
||||
public string ParamName(int i) { return paramNames[i]; }
|
||||
public int ParamsCount() { return paramNames.Length; }
|
||||
|
||||
public IList<string> ParamValues(int i)
|
||||
{
|
||||
IList<string> listOfValues = new List<string>();
|
||||
if (i == 1)
|
||||
{
|
||||
for (Culture cu = 0; cu < Culture.Count; cu++) listOfValues.Add(cu.ToString());
|
||||
return listOfValues;
|
||||
}
|
||||
else if (i == 2)
|
||||
{
|
||||
listOfValues.Add(Strings.yes);
|
||||
listOfValues.Add(Strings.no);
|
||||
return listOfValues;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case -1: return string.Format("Name={0}, FNameFmt={1}, NoSpaces={2}", Name, EventSource, EliminateSpaces);
|
||||
case 0: return EventSource;
|
||||
case 1: return Culture.ToString();
|
||||
case 2: return EliminateSpaces ? Strings.yes : Strings.no;
|
||||
case 3: return PrintCaption ? Strings.yes : Strings.no;
|
||||
default: return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public CfgUpdateFlags UpdateParam(int i, string strValue)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0: EventSource = strValue; return CfgUpdateFlags.RestartRqrd;
|
||||
case 1:
|
||||
for (Culture cu = 0; cu < Culture.Count; cu++)
|
||||
{
|
||||
if (strValue == cu.ToString())
|
||||
{
|
||||
if (Culture != cu)
|
||||
{
|
||||
Culture = cu;
|
||||
return CfgUpdateFlags.RestartRqrd;
|
||||
}
|
||||
else
|
||||
{
|
||||
return CfgUpdateFlags.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
return CfgUpdateFlags.Error;
|
||||
case 2: EliminateSpaces = (strValue == Strings.yes); return CfgUpdateFlags.RestartRqrd;
|
||||
case 3: PrintCaption = (strValue == Strings.yes); return CfgUpdateFlags.RestartRqrd;
|
||||
default: return CfgUpdateFlags.None;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ValidateParam(int i, string strValue, out string message)
|
||||
{
|
||||
message = string.Empty;
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0: return true;
|
||||
case 1:
|
||||
for (Culture cu = 0; cu < Culture.Count; cu++)
|
||||
{
|
||||
if (strValue == cu.ToString()) return true;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
if (strValue == Strings.yes || strValue == Strings.no) return true;
|
||||
break;
|
||||
default:
|
||||
message = "Invalid index";
|
||||
return false;
|
||||
}
|
||||
|
||||
message = ParamName(i) + " is invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
void CopyContentTo(TriggerCfg prms)
|
||||
{
|
||||
prms.EventSource = this.EventSource;
|
||||
prms.Culture = this.Culture;
|
||||
prms.EliminateSpaces = this.EliminateSpaces;
|
||||
prms.PrintCaption = this.PrintCaption;
|
||||
}
|
||||
|
||||
public Config.Entities.IParamsProvider Clone()
|
||||
{
|
||||
TriggerCfg pars = new TriggerCfg();
|
||||
CopyContentTo(pars);
|
||||
return pars;
|
||||
}
|
||||
|
||||
public bool UpdateEmbeddedDbEntity()
|
||||
{
|
||||
return true; /// =OK, do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user