public override TaskStatus Run() { Info("Start Comparator task"); bool success = false; bool IsIndata = false; try { if (indata == "file") { foreach (FileInf fi in SelectFiles()) { SrezTableLight stl = new SrezTableLight(); sa.FileName = fi.Path; sa.Fill(stl); int id = int.Parse(fi.FileName.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries)[1]); stls.AddSrez(id, stl.SrezList.Values[0]); } IsIndata = true; } if (indata == "mem") { foreach (RSServer srv in srvs.GetRSServers()) { stls.AddSrez(srv.Id, srv.GetCurrSrez()); } IsIndata = true; } if (IsIndata) { foreach (Cnl cnl in Cnls) { Argument cArg = new Argument(cnl.ToString(), stls.GetCnlData(cnl.ID, cnl.Num)); CalcArgs.Add(cArg); } CalcArgs.AddRange(xArgs); foreach (Argument arg in CalcArgs) { Info(arg.getArgumentName() + " " + arg.getArgumentValue().ToString()); } Expression expr = new Expression(condition, CalcArgs.ToArray()); double pvExpr = expr.calculate(); if (pvExpr == 0) { success = false; } else if (pvExpr == 1) { success = true; } if (success) { foreach (Argument arg in odts) { arg.addDefinitions(CalcArgs.ToArray()); } } InfoFormat("Condition: {0}", condition); InfoFormat("Result calculate: {0}", expr.calculate()); InfoFormat("Success value: {0}", success); } else { Info("Not set parametr indata"); } CalcArgs.Clear(); stls.ClearSrez(); } catch (ThreadAbortException) { throw; } catch (Exception ex) { ErrorFormat("Ann error calc comparator. Error: {0}", ex.Message); } Info("Task RSComparator finished."); return(new TaskStatus(Status.Success, success)); }
public override TaskStatus Run () { Info("Start RSSendValues task"); bool IsIndata = false; try { if(indata=="file") { foreach(FileInf fi in SelectFiles()) { SrezTableLight stl = new SrezTableLight (); sa.FileName = fi.Path; sa.Fill(stl); int id = int.Parse (fi.FileName.Split (new char[]{'.'},StringSplitOptions.RemoveEmptyEntries)[1]); stls.AddSrez(id,stl.SrezList.Values[0]); } IsIndata = true; } if (indata == "mem") { foreach(RSServer srv in srvs.GetRSServers()) { stls.AddSrez(srv.Id,srv.GetCurrSrez()); } IsIndata = true; } if(IsIndata) { foreach(Cnl cnl in Cnls) { Argument cArg = new Argument(cnl.ToString(),stls.GetCnlData(cnl.ID,cnl.Num)); CalcArgs.Add(cArg); } CalcArgs.AddRange(xArgs); List<Cnl> cnls = new List<Cnl>(); foreach(Argument arg in SendVals) { PrimitiveElement[] pes = CalcArgs.ToArray(); arg.addDefinitions(pes); Cnl cnl = new Cnl(arg.getArgumentName(),arg.getArgumentValue(),1); cnls.Add(cnl); arg.removeDefinitions(CalcArgs.ToArray()); } srvs.SendCurrSrez(cnls); } else{ Info("No set parametr indata"); } CalcArgs.Clear(); stls.ClearSrez(); } catch (ThreadAbortException) { throw; } catch (Exception ex) { InfoFormat ("An error RSSendValues: {0}", ex.Message); } Info("Task RSSendValues finished"); return new TaskStatus (Status.Success, false); }