public void OnStart() { isConnecting = true; var t1 = Task.Run(() => { while (isConnecting) { if (Interlocked.Exchange(ref inTimer, 1) == 0) { MQHandler queue = new MQHandler(); string rcvd; do { rcvd = queue.ReceiveMessage(IntData.QUEUE_NAME, IntData.QUEUE_NAME + " Message");//Dequeue the query if (rcvd != "") { ThreadHandler.ThreadLocker();//Pause the program when thread is locked ExecuteSQL(rcvd); } } while (rcvd != ""); Interlocked.Exchange(ref inTimer, 0); } Thread.Sleep(1000); } }); }
static void Main(string[] args) { MQHandler <PersonenBeschreibung> handler = new MQHandler <PersonenBeschreibung>("entriesDelete"); Provider prov = new Provider(); while (true) { prov.deleteById(handler.Read().Id.ToString()); } }
static void Main(string[] args) { MQHandler <XItem> mq = new MQHandler <XItem>("sycoexample2"); while (true) { var temp = GetRandomItem(); mq.Send(temp); Console.WriteLine("New Item sent: " + temp.Description + ", " + temp.Price + ", " + temp.Amount + ", " + temp.Category); Thread.Sleep(5000); } }
static void Main(string[] args) { //Namen der MessageQueue beim Constructor mitgeben (sollte einzigartiger Name sein) MQHandler <PersonenBeschreibung> handler = new MQHandler <PersonenBeschreibung>("entries"); //Kommt aus der DataLayer Klasse Provider prov = new Provider(); while (true) { //Methode der DataLayerklasse die auf Datenbank zugreift prov.Insert(handler.Read()); } }
static void Main(string[] args) { MQHandler <XItem> mq = new MQHandler <XItem>("sycoexample2"); DataHandler dh = new DataHandler(); while (true) { var temp = mq.Receive(); dh.AddItem(temp); Console.WriteLine("New Item received and added to DB: " + temp.Description + ", " + temp.Price + ", " + temp.Amount + ", " + temp.Category); } }
public VMPerson() { handler = new MQHandler <PersonenBeschreibung>("entries"); handlerDelete = new MQHandler <PersonenBeschreibung>("entriesDelete"); handlerUpdate = new MQHandler <PersonenBeschreibung>("entriesUpdate"); client = new ServiceReference1.MeinTollerServiceClient(); clientFileWriter = new FileWriterService.FileWriteServiceClient(); this.Personen = client.getPersonenBeschreibung(); BtnWrite = new MVVMCommand((param) => { WriteToQueue(); }, (param) => { return(true); }); BtnUpdate = new MVVMCommand((param) => { updatePersonen(); }, (param) => { return(true); }); BtnDeleteById = new MVVMCommand((param) => { deleteById(param); }, (param) => { return(true); }); BtnUpdateById = new MVVMCommand((param) => { updateById(param); }, (param) => { return(true); }); }
public void Execute(Boolean ReplaceAndExecute, string tagevent, TagHandler Tags) { string finalWhere; string value; string cmdSend; Logging log = new Logging("[" + tagevent + "]" + Command + ":" + ColumnName + " "); SQLHandler sqlGenerator = new SQLHandler(); string cmd = Command.ToLower(); if (cmd.Substring(0, 6) == "insert" || cmd.Substring(0, 6) == "update" || cmd.Substring(0, 6) == "select") { if (Where != "") { finalWhere = Tags.SolveWhere(Where); } else { finalWhere = Where; } sqlGenerator.InitCommand(cmd.ToString(), ColumnName.ToString(), finalWhere); if (Columns != null) { for (int index = 0; index < Columns.Count; index++) { ColumnsCommand column = Columns[index]; log.Command += column.TagAddress + column.name + column.KeepInTag + "=" + column.Formula + "\t"; if (column.Enabled) { if (ReplaceAndExecute) { string tmpExp = column.Formula; value = Tags.SolveFormula(tmpExp); if (column.Format != "") { value = String.Format(column.Formula, column.Format); } } else { value = column.Formula; } column.Value = value.ToString().Trim(); sqlGenerator.SetColumn(column.name, value); if (column.KeepInTag != "") { Tags.UpdateTagsValue(column.KeepInTag, Convert.ToInt32(value)); IntData.SaveRecordsetFlag = true; } } Columns[index] = column; } if (ReplaceAndExecute) { cmdSend = sqlGenerator.Command; if (Command.ToString().ToUpper() == "UPDATE") { if (AutoInsert(ColumnName.ToString())) { cmdSend += IntData.AUTO_INSERT_STR; } } if (Command.ToString().ToUpper() != "SELECT" && ColumnName.ToString() != "" && ColumnName.IndexOf("_Internal") == -1) { MQHandler queue = new MQHandler(); queue.SendMsg(cmdSend); } if (Command.ToString().ToUpper() == "SELECT") { WriteOPC(cmdSend, Tags); } } } } log.Success(); }
public async void Onstart() { isConnecting = true; MQHandler queue = new MQHandler(); queue.CreateQueue(); Tags.Init(); Events.Init(); var t = Task.Run(() => { while (isConnecting) { Task.Run(() => { if (Interlocked.Exchange(ref eventTimer, 1) == 0) { Events.Refresh(Tags); Interlocked.Exchange(ref eventTimer, 0); } }); Thread.Sleep(1000); } }); var t1 = Task.Run(() => { try { Log.Enqueue("Application starting..."); if (Log.Count > 20) { Log.Dequeue(); } while (isConnecting) { for (Logging info = log.FetchInformation(); info != null; info = log.FetchInformation()) { Log.Enqueue(info.Function + ": CMD" + StrLenLimit(info.Command, 100) + "\t MSG:" + info.Information); if (Log.Count > 20) { Log.Dequeue(); } } for (Logging warn = log.FetchWarning(); warn != null; warn = log.FetchWarning()) { Log.Enqueue(warn.Function + ": CMD" + StrLenLimit(warn.Command, 100) + "\t MSG:" + warn.Warning); if (Log.Count > 20) { Log.Dequeue(); } } for (Logging fatl = log.FetchWarning(); fatl != null; fatl = log.FetchFatal()) { Log.Enqueue(fatl.Function + ": CMD" + StrLenLimit(fatl.Command, 100) + "\t MSG:" + fatl.Exception.Message); if (Log.Count > 20) { Log.Dequeue(); } } } Thread.Sleep(100); Log.Enqueue("The application is stoped."); } catch (Exception ex) { Log.Enqueue(ex.Message + "The application failed to start."); if (Log.Count > 20) { Log.Dequeue(); } } }); await t; Events.Dispose(); Tags.Dispose(); }