private async Task UpdateStatusObj() { StatusObj.Icon = Status ? "\uea10" : "\uea0f"; StatusObj.Message = Status ? "Export Successful" : "Export Failed"; StatusObj.FgColor = Brushes.White; StatusObj.BgColor = Status ? Brushes.Green : Brushes.Red; await StatusObj.Show(4); }
public IActionResult HealthCheck() { var res = new StatusObj() { status = "success" }; return(Ok(JsonConvert.SerializeObject(res))); }
private void PostTopic() { while (dtTableUp.Rows.Count > 0) { if (isAbort == false) { if (isLock == false) { if (dtTableUp.Rows.Count > 0) { try { isLock = true; string strErr = ""; long id = long.Parse(dtTableUp.Rows[0]["ID"].ToString()); dtTableUp.Rows.RemoveAt(0); WebLink weblink = WebLink.Get(id); isLock = false; StatusObj statusObj = new StatusObj(); if (weblink != null) { strErr = "Up page " + weblink.Url + " [ " + weblink.Topic + " ] " + "...................."; DataRow dtRow = dtLogEntries.NewRow(); dtRow["ID"] = id; dtRow["LogEntries"] = strErr; dtRow["DateTime"] = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"); dtLogEntries.Rows.Add(dtRow); try { WebBrowser webBrowser = (WebBrowser)panelControl1.Controls[id.ToString()]; AutoUpEx post = new AutoUpEx(webBrowser, weblink); statusObj = post.UpTopic(); strErr = strErr + statusObj.Message; try { webBrowser.Dispose(); } catch { } try { panelControl1.Controls.Remove(webBrowser); } catch { } } catch { strErr = strErr + " Error."; } dtRow["LogEntries"] = strErr; dtRow["LinkUp"] = statusObj.Value; dtRow["Status"] = statusObj.Status; } } catch { isLock = false; } } } } } }
public void init(bool initMonitorPingInfos) { _pingParams = new PingParams(); _pingParams.BufferLength = _config.GetValue <int>("PingPacketSize"); _pingParams.TimeOut = _config.GetValue <int>("PingTimeOut"); _pingParams.PingBurstDelay = _config.GetValue <int>("PingBurstDelay"); _pingParams.PingBurstNumber = _config.GetValue <int>("PingBurstNumber"); _pingParams.Schedule = _config.GetValue <string>("PingSchedule"); _pingParams.SaveSchedule = _config.GetValue <string>("SaveSchedule"); _pingParams.AlertSchedule = _config.GetValue <string>("AlertSchedule"); _pingParams.AlertThreshold = _config.GetValue <int>("PingAlertThreshold"); _pingParams.DisableNetStatService = _config.GetValue <bool>("DisableNetStatService"); _pingParams.LogStatsThreshold = _config.GetValue <int>("LogNetworkStatsThreshold"); _pingParams.NetStatsDeviceID = _config.GetValue <int>("NetStatsDeviceID"); if (initMonitorPingInfos) { // init fully on first run. _monitorPingInfos = new List <MonitorPingInfo>(); _monitorIPs = _config.GetSection("MonitorIps").GetChildren().ToArray().Select(c => c.Value).ToArray(); MonitorPingInfo monitorPingInfo; for (int i = 0; i < _monitorIPs.Length; i++) { monitorPingInfo = new MonitorPingInfo(); monitorPingInfo.ID = i + 1; monitorPingInfo.IPAddress = _monitorIPs[i]; _monitorPingInfos.Add(monitorPingInfo); } } else { List <MonitorPingInfo> newMonPingInfos = new List <MonitorPingInfo>(); MonitorPingInfo newMonPingInfo; StatusObj status; int i = 0; // Copy Alert status before init. foreach (MonitorPingInfo monPingInfo in _monitorPingInfos) { status = new StatusObj(); status.AlertFlag = monPingInfo.MonitorStatus.AlertFlag; status.AlertSent = monPingInfo.MonitorStatus.AlertSent; status.DownCount = monPingInfo.MonitorStatus.DownCount; status.IsUp = monPingInfo.MonitorStatus.IsUp; newMonPingInfo = new MonitorPingInfo(); newMonPingInfo.ID = i + 1; newMonPingInfo.IPAddress = _monitorIPs[i]; newMonPingInfo.MonitorStatus = status; newMonPingInfos.Add(newMonPingInfo); i++; } _monitorPingInfos = new List <MonitorPingInfo>(newMonPingInfos); } }
private void PostTopic() { while (dtTable.Rows.Count > 0) { if (isAbort == false) { if (isLock == false) { if (dtTable.Rows.Count > 0) { try { isLock = true; string strErr = ""; long id = long.Parse(dtTable.Rows[0]["ID"].ToString()); dtTable.Rows.RemoveAt(0); WebLink weblink = WebLink.Get(id); isLock = false; StatusObj statusObj = new StatusObj(); if (weblink != null) { strErr = "Up to " + weblink.Url + " [ " + weblink.Topic + " ] " + "...................."; DataRow dtRow = dtLogEntries.NewRow(); dtRow["ID"] = id; dtRow["LogEntries"] = strErr; dtRow["DateTime"] = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"); dtLogEntries.Rows.Add(dtRow); try { } catch { strErr = strErr + " Error."; } dtRow["LogEntries"] = strErr; dtRow["LinkUp"] = statusObj.Value; dtRow["Status"] = statusObj.Status; } } catch { isLock = false; } } } } } }
/// <summary> /// This updates the trade. This is called at an interval of a /// default of 800ms, not including the execution time of the /// method itself. /// </summary> /// <returns><c>true</c> if the other trade partner performed an action; otherwise <c>false</c>.</returns> public bool Poll() { bool otherDidSomething = false; if (!TradeStarted) { tradeStarted = true; // since there is no feedback to let us know that the trade // is fully initialized we assume that it is when we start polling. if (OnAfterInit != null) { OnAfterInit(); } } StatusObj status = GetStatus(); if (status == null) { throw new TradeException("The web command to get the trade status failed."); } // I've noticed this when the trade is cancelled. if (status.trade_status == 3) { if (OnError != null) { OnError("Trade was cancelled by other user."); } OtherUserCancelled = true; return(otherDidSomething); } if (status.events != null && numEvents != status.events.Length) { int numLoops = status.events.Length - numEvents; numEvents = status.events.Length; for (int i = numLoops; i > 0; i--) { int EventID; if (numLoops == 1) { EventID = numEvents - 1; } else { EventID = numEvents - i; } bool isBot = status.events [EventID].steamid == MySteamId.ConvertToUInt64().ToString(); /* * * Trade Action ID's * * 0 = Add item (itemid = "assetid") * 1 = remove item (itemid = "assetid") * 2 = Toggle ready * 3 = Toggle not ready * 4 * 5 * 6 * 7 = Chat (message = "text") * */ ulong itemID; switch (status.events [EventID].action) { case 0: itemID = (ulong)status.events [EventID].assetid; if (isBot) { steamMyOfferedItems.Add(itemID); ValidateSteamItemChanged(itemID, true); } else { OtherOfferedItems.Add(itemID); Inventory.Item item = OtherInventory.GetItem(itemID); Schema.Item schemaItem = CurrentSchema.GetItem(item.Defindex); OnUserAddItem(schemaItem, item); } break; case 1: itemID = (ulong)status.events [EventID].assetid; if (isBot) { steamMyOfferedItems.Remove(itemID); ValidateSteamItemChanged(itemID, false); } else { OtherOfferedItems.Remove(itemID); Inventory.Item item = OtherInventory.GetItem(itemID); Schema.Item schemaItem = CurrentSchema.GetItem(item.Defindex); OnUserRemoveItem(schemaItem, item); } break; case 2: if (!isBot) { otherIsReady = true; OnUserSetReady(true); } break; case 3: if (!isBot) { otherIsReady = false; OnUserSetReady(false); } break; case 4: if (!isBot) { OnUserAccept(); } break; case 7: if (!isBot) { OnMessage(status.events [EventID].text); } break; default: // Todo: add an OnWarning or similar event if (OnError != null) { OnError("Unkown Event ID: " + status.events [EventID].action); } break; } if (!isBot) { otherDidSomething = true; } } } // Update Local Variables if (status.them != null) { otherIsReady = status.them.ready == 1 ? true : false; meIsReady = status.me.ready == 1 ? true : false; } // Update version if (status.newversion) { Version = status.version; } if (status.logpos != 0) { LogPos = status.logpos; } return(otherDidSomething); }
private void PostTopic() { while (dtTable.Rows.Count > 0) { if (isAbort == false) { if (isLock == false) { if (dtTable.Rows.Count > 0) { try { isLock = true; string strErr = ""; long id = long.Parse(dtTable.Rows[0]["ID"].ToString()); dtTable.Rows.RemoveAt(0); hashTable.Add(id, false); WebLink weblink = WebLink.Get(id); isLock = false; StatusObj statusObj = new StatusObj(); if (weblink != null) { DataRow dtRow = dtLogEntries.NewRow(); dtRow["ID"] = id; dtRow["DateTime"] = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"); dtLogEntries.Rows.Add(dtRow); if (_Type == NumCode.POS) { strErr = "Post to " + weblink.Url + " ...................."; dtRow["LogEntries"] = strErr; try { WebBrowser webBrowser = (WebBrowser)panelControl1.Controls[id.ToString()]; AutoPost post = new AutoPost(webBrowser, multiforum, weblink, Subject, Content, Tag); statusObj = post.PostTopic(); strErr = strErr + statusObj.Message; } catch { strErr = strErr + "Error."; } } else { strErr = "Up to " + weblink.Url + " [ " + weblink.Topic + " ] " + "...................."; dtRow["LogEntries"] = strErr; try { WebBrowser webBrowser = (WebBrowser)panelControl1.Controls[id.ToString()]; AutoPost post = new AutoPost(webBrowser, multiforum, weblink, Subject, Content, Tag); statusObj = post.UpTopic(); strErr = strErr + statusObj.Message; } catch { strErr = strErr + "Error."; } } dtRow["LogEntries"] = strErr; dtRow["LinkUp"] = statusObj.Value; dtRow["Status"] = statusObj.Status; if (statusObj.Status == "Successful") { haveSuccessful = true; } hashTable[id] = true; } } catch { isLock = false; } } } } } try { if (Thread.CurrentThread.IsAlive) { Thread.CurrentThread.Abort(); } } catch { } }
/// <summary> /// This updates the trade. This is called at an interval of a /// default of 800ms, not including the execution time of the /// method itself. /// </summary> /// <returns><c>true</c> if the other trade partner performed an action; otherwise <c>false</c>.</returns> public bool Poll() { bool otherDidSomething = false; if (!TradeStarted) { tradeStarted = true; // since there is no feedback to let us know that the trade // is fully initialized we assume that it is when we start polling. if (OnAfterInit != null) { OnAfterInit(); } } StatusObj status = GetStatus(); if (status == null) { throw new TradeException("The web command to get the trade status failed."); } // I've noticed this when the trade is cancelled. if (status.trade_status == 3) { if (OnError != null) { OnError("Trade was cancelled by other user."); } OtherUserCancelled = true; return(otherDidSomething); } if (status.events != null) { foreach (TradeEvent trdEvent in status.events) { if (!eventList.Contains(trdEvent)) { eventList.Add(trdEvent);//add event to processed list, as we are taking care of this event now bool isBot = trdEvent.steamid == MySteamId.ConvertToUInt64().ToString(); /* * * Trade Action ID's * * 0 = Add item (itemid = "assetid") * 1 = remove item (itemid = "assetid") * 2 = Toggle ready * 3 = Toggle not ready * 4 * 5 * 6 * 7 = Chat (message = "text") * */ ulong itemID; switch ((TradeEventType)trdEvent.action) { case TradeEventType.ItemAdded: itemID = (ulong)trdEvent.assetid; if (isBot) { steamMyOfferedItems.Add(itemID); ValidateSteamItemChanged(itemID, true); Inventory.Item item = MyInventory.GetItem(itemID); Schema.Item schemaItem = CurrentSchema.GetItem(item.Defindex); } else { OtherOfferedItems.Add(itemID); Inventory.Item item = OtherInventory.GetItem(itemID); Schema.Item schemaItem = CurrentSchema.GetItem(item.Defindex); OnUserAddItem(schemaItem, item); } break; case TradeEventType.ItemRemoved: itemID = (ulong)trdEvent.assetid; if (isBot) { steamMyOfferedItems.Remove(itemID); ValidateSteamItemChanged(itemID, false); Inventory.Item item = MyInventory.GetItem(itemID); Schema.Item schemaItem = CurrentSchema.GetItem(item.Defindex); } else { OtherOfferedItems.Remove(itemID); Inventory.Item item = OtherInventory.GetItem(itemID); Schema.Item schemaItem = CurrentSchema.GetItem(item.Defindex); OnUserRemoveItem(schemaItem, item); } break; case TradeEventType.UserSetReady: if (!isBot) { otherIsReady = true; OnUserSetReady(true); } break; case TradeEventType.UserSetUnReady: if (!isBot) { otherIsReady = false; OnUserSetReady(false); } break; case TradeEventType.UserAccept: if (!isBot) { OnUserAccept(); } break; case TradeEventType.UserChat: if (!isBot) { OnMessage(trdEvent.text); } break; default: // Todo: add an OnWarning or similar event if (OnError != null) { OnError("Unknown Event ID: " + trdEvent.action); } break; } if (!isBot) { otherDidSomething = true; } } //if (!eventList.Contains(trdEvent)) } // foreach (TradeEvent trdEvent in status.events) } //if (status.events != null) // Update Local Variables if (status.them != null) { otherIsReady = status.them.ready == 1 ? true : false; meIsReady = status.me.ready == 1 ? true : false; } // Update version if (status.newversion) { Version = status.version; } if (status.logpos != 0) { LogPos = status.logpos; } return(otherDidSomething); }
/// <summary> /// This updates the trade. This is called at an interval of a /// default of 800ms, not including the execution time of the /// method itself. /// </summary> public void Poll() { if (!TradeStarted) { tradeStarted = true; tradeStartTime = DateTime.Now; lastOtherActionTime = DateTime.Now; } StatusObj status = GetStatus(); if (status == null) { throw new TradeException("The web command to get the trade status failed."); } // I've noticed this when the trade is cancelled. if (status.trade_status == 3) { if (OnError != null) { OnError("Trade was cancelled by other user."); } OtherUserCancelled = true; return; } if (status.events != null && numEvents != status.events.Length) { int numLoops = status.events.Length - numEvents; numEvents = status.events.Length; for (int i = numLoops; i > 0; i--) { int EventID; if (numLoops == 1) { EventID = numEvents - 1; } else { EventID = numEvents - i; } bool isBot = status.events [EventID].steamid == MySteamId.ConvertToUInt64().ToString(); /* * * Trade Action ID's * * 0 = Add item (itemid = "assetid") * 1 = remove item (itemid = "assetid") * 2 = Toggle ready * 3 = Toggle not ready * 4 * 5 * 6 * 7 = Chat (message = "text") * */ ulong itemID; switch (status.events [EventID].action) { case 0: itemID = (ulong)status.events [EventID].assetid; if (isBot) { steamMyOfferedItems.Add(itemID); ValidateSteamItemChanged(itemID, true); } else { OtherOfferedItems.Add(itemID); Inventory.Item item = OtherInventory.GetItem(itemID); Schema.Item schemaItem = CurrentSchema.GetItem(item.Defindex); OnUserAddItem(schemaItem, item); } break; case 1: itemID = (ulong)status.events [EventID].assetid; if (isBot) { steamMyOfferedItems.Remove(itemID); ValidateSteamItemChanged(itemID, false); } else { OtherOfferedItems.Remove(itemID); Inventory.Item item = OtherInventory.GetItem(itemID); Schema.Item schemaItem = CurrentSchema.GetItem(item.Defindex); OnUserRemoveItem(schemaItem, item); } break; case 2: if (!isBot) { otherIsReady = true; OnUserSetReady(true); } break; case 3: if (!isBot) { otherIsReady = false; OnUserSetReady(false); } break; case 4: if (!isBot) { OnUserAccept(); } break; case 7: if (!isBot) { OnMessage(status.events [EventID].text); } break; default: // Todo: add an OnWarning or similar event if (OnError != null) { OnError("Unkown Event ID: " + status.events [EventID].action); } break; } if (!isBot) { lastOtherActionTime = DateTime.Now; } } } else { // check if the user is AFK var now = DateTime.Now; DateTime actionTimeout = lastOtherActionTime.AddSeconds(MaximumActionGap); int untilActionTimeout = (int)Math.Round((actionTimeout - now).TotalSeconds); DateTime tradeTimeout = TradeStartTime.AddSeconds(MaximumTradeTime); int untilTradeTimeout = (int)Math.Round((tradeTimeout - now).TotalSeconds); if (untilActionTimeout <= 0 || untilTradeTimeout <= 0) { if (OnTimeout != null) { OnTimeout(); } CancelTrade(); } else if (untilActionTimeout <= 15 && untilActionTimeout % 5 == 0) { SendMessageWebCmd("Are You AFK? The trade will be canceled in " + untilActionTimeout + " seconds if you don't do something."); } } // Update Local Variables if (status.them != null) { otherIsReady = status.them.ready == 1 ? true : false; meIsReady = status.me.ready == 1 ? true : false; } // Update version if (status.newversion) { Version = status.version; } if (status.logpos != 0) { LogPos = status.logpos; } }
public void AsyncStartStop() { if (GlobVar.Status == StatusApp.Waiting) { if (_Status == StatusObj.Waiting) { Status = StatusObj.Working; _objToConvert.Progress += _objToConvert_Progress; _objToConvert.Done += _objToConvert_Done; _objToConvert.AsyncConvert(); } else if (_Status == StatusObj.Working) { Status = StatusObj.Stopping; _objToConvert.AsyncStop(); } else MessageBox.Show("La conversione è già stata eseguita"); } else { MessageBox.Show("completare l'operazione in corso e riprovare"); } }
private void _objToConvert_Done(StatusConvert sc,String msg="") { if (sc == StatusConvert.Complete) Status = StatusObj.Complete; else if (sc == StatusConvert.Error) { Status = StatusObj.Error; SetErrMsg(msg); } else if (sc == StatusConvert.Aborted) Status = StatusObj.Waiting; }
private void ChangeStatus(StatusObj s) { if (this.InvokeRequired) { this.Invoke((MethodInvoker)delegate { ChangeStatus(s); }); } else { _Status = s; if (_Status == StatusObj.Complete) { progressBar1.Value = 100; this.BackColor = Color.FromArgb(128, 255, 128); button1.Visible = false; button1.Enabled = false; } else if (_Status == StatusObj.Error) { progressBar1.Value = 0; this.BackColor = Color.FromArgb(255, 108, 108); button1.Visible = false; button1.Enabled = false; } else if (_Status == StatusObj.Waiting) { this.BackColor = SystemColors.Control; button1.Text = TextConvert; button1.Enabled = true; button2.Enabled = true; button1.Visible = true; } else if (_Status == StatusObj.Working) { this.BackColor = SystemColors.Control; button1.Text = TextStop; button1.Visible = true; button1.Enabled = GlobVar.Status != StatusApp.OnConvertMultiple; button2.Enabled = false; } } }
public void Convert(bool silent=false) { if (_Status == StatusObj.Waiting) { Status = StatusObj.Working; _objToConvert.Progress += _objToConvert_Progress; _objToConvert.Done += _objToConvert_Done; _objToConvert.Convert(); } else if( !silent) MessageBox.Show("La conversione è già stata eseguita"); }