public void AddResult(string i_Name, eOperationType i_OperationType, TimeSpan i_Elapsed, bool i_Done, string i_Exception = "") { InnerResults.Add(new Result() { Name = i_Name, OperationType = i_OperationType, Elapsed = i_Elapsed, Done = i_Done, Exception = i_Exception }); }
public void TakeAction(string i_MachineName, string i_IP, string i_ServiceName,string i_DisplayName, eOperationType i_OperationType) { Stopwatch sw = new Stopwatch(); sw.Start(); LogManager.Instance.WriteInfo("Action " + Enum.GetName(typeof(eOperationType), i_OperationType) + "on all agents started "); m_AgentsManager.TakeAction(i_MachineName, i_IP, i_ServiceName, i_DisplayName, i_OperationType); sw.Stop(); LogManager.Instance.WriteInfo("Action " + Enum.GetName(typeof(eOperationType), i_OperationType) + "on all agents ended, took: "+sw.ToString()); }
bool isMainOperationDone(Result i_Result, eOperationType i_MostImportantAction) { bool mainOperationDone = false; Result LastOperationInProdecureResult = i_Result.InnerResults.Find(x => x.OperationType == i_MostImportantAction); if (LastOperationInProdecureResult != null) { mainOperationDone = LastOperationInProdecureResult.Done; } return(mainOperationDone); }
protected void AddItem(eOperationType type, Object3d obj, double x, double y, double z) { if (obj == null) return; while (m_undopointer < m_undoItemList.Count) { m_undoItemList.RemoveAt(m_undopointer); } UndoItem item = new UndoItem(); item.opType = type; item.obj = obj; item.x = x; item.y = y; item.z = z; item.linkedToPrev = false; m_undoItemList.Add(item); m_undopointer++; UpdateButtons(); }
private void ZThrowFailure(eOperationType pType) { if (MessageHandle.Expunged) { throw new cMessageExpungedException(MessageHandle); } switch (pType) { case eOperationType.fetch: throw new cRequestedDataNotReturnedException(); case eOperationType.store: throw new cSingleMessageStoreException(); default: throw new cInternalErrorException(); } }
protected void AddItem(eOperationType type, Object3d obj, double x, double y, double z) { if (obj == null) { return; } while (m_undopointer < m_undoItemList.Count) { m_undoItemList.RemoveAt(m_undopointer); } UndoItem item = new UndoItem(); item.opType = type; item.obj = obj; item.x = x; item.y = y; item.z = z; item.linkedToPrev = false; m_undoItemList.Add(item); m_undopointer++; UpdateButtons(); }
public void TakeActionOnAllAgents(eOperationType i_OperationType) { Stopwatch sw = new Stopwatch(); sw.Start(); ThreadPool.SetMaxThreads(5, 5); LogManager.Instance.WriteInfo(Enum.GetName(i_OperationType.GetType(),i_OperationType)+" action on all agents started."); AgentInstance agent = null; bool finalResult = false; int numOfOperations = 0; int faultedOperations = 0; Task task = null; List<Task> tasks = new List<Task>(); foreach (var keyvalueAgent in m_Agents) { task = new Task(() => { AgentInstance agente = keyvalueAgent.Value; foreach (var service in agente.Services) { numOfOperations++; finalResult = TakeAction(agente.ComputerName, agente.IP, service.Value, service.Key, i_OperationType); if (!finalResult) { faultedOperations++; } } }); task.Start(); tasks.Add(task); } Task.WaitAll(tasks.ToArray()); LogManager.Instance.WriteInfo(Enum.GetName(i_OperationType.GetType(),i_OperationType)+" action on all agents ended, elapsed: " + sw.Elapsed); LogManager.Instance.WriteInfo("Results : " + faultedOperations + " out of " + numOfOperations + " operations failed"); }
public Result TakeAction(string i_ServiceName, eOperationType i_OperationType) { Stopwatch stopWatch = new Stopwatch(); string exception = string.Empty; bool operationDone = true; Result result = new Result(); result.OperationType = i_OperationType; stopWatch.Start(); LogManager.Instance.WriteInfo(i_ServiceName + " => " + Enum.GetName(typeof(eOperationType), i_OperationType) + ", action started"); try { switch (i_OperationType) { case eOperationType.StartService: if (!ServiceUtils.isServiceRunning(i_ServiceName)) { Thread.Sleep(TimeSpan.FromSeconds(m_Configurations.WaitTimeBetweenActions)); ServiceUtils.StartService(i_ServiceName, m_Configurations.ServiceChangeStateWaitTime); } break; case eOperationType.StopService: if (ServiceUtils.isServiceRunning(i_ServiceName)) { ServiceUtils.StopService(i_ServiceName, m_Configurations.ServiceChangeStateWaitTime); Thread.Sleep(TimeSpan.FromSeconds(m_Configurations.WaitTimeBetweenActions)); } break; case eOperationType.RestartService: try { result.AddResult(TakeAction(i_ServiceName, eOperationType.StopService)); result.AddResult(TakeAction(i_ServiceName, eOperationType.StartService)); if (isMainOperationDone(result, eOperationType.StartService)) { operationDone = true; } else { if (ServiceUtils.isServiceRunning(i_ServiceName)) { operationDone = true; } else { operationDone = false; } } } catch (Exception ex) { exception = ex.Message; operationDone = false; } break; } } catch (Exception ex) { operationDone = false; exception = ex.Message; LogManager.Instance.WriteError(i_ServiceName + " => " + Enum.GetName(typeof(eOperationType), i_OperationType) + " faulted! with exception: " + ex.Message); } LogManager.Instance.WriteInfo(i_ServiceName + " => " + Enum.GetName(typeof(eOperationType), i_OperationType) + ", action ended ,took: " + stopWatch.Elapsed.ToString()); stopWatch.Stop(); result.Elapsed = stopWatch.Elapsed; result.Exception = exception; result.Done = operationDone; return(result); }
bool isMainOperationDone(Result i_Result, eOperationType i_MostImportantAction) { bool mainOperationDone = false; Result LastOperationInProdecureResult = i_Result.InnerResults.Find(x => x.OperationType == i_MostImportantAction); if(LastOperationInProdecureResult != null) { mainOperationDone= LastOperationInProdecureResult.Done; } return mainOperationDone; }
public Result TakeAction(string i_ServiceName, eOperationType i_OperationType) { Stopwatch stopWatch = new Stopwatch(); string exception = string.Empty; bool operationDone = true; Result result = new Result(); result.OperationType = i_OperationType; stopWatch.Start(); LogManager.Instance.WriteInfo(i_ServiceName + " => " + Enum.GetName(typeof(eOperationType), i_OperationType) + ", action started"); try { switch (i_OperationType) { case eOperationType.StartService: if (!ServiceUtils.isServiceRunning(i_ServiceName)) { Thread.Sleep(TimeSpan.FromSeconds(m_Configurations.WaitTimeBetweenActions)); ServiceUtils.StartService(i_ServiceName, m_Configurations.ServiceChangeStateWaitTime); } break; case eOperationType.StopService: if (ServiceUtils.isServiceRunning(i_ServiceName)) { ServiceUtils.StopService(i_ServiceName, m_Configurations.ServiceChangeStateWaitTime); Thread.Sleep(TimeSpan.FromSeconds(m_Configurations.WaitTimeBetweenActions)); } break; case eOperationType.RestartService: try { result.AddResult(TakeAction(i_ServiceName, eOperationType.StopService)); result.AddResult(TakeAction(i_ServiceName, eOperationType.StartService)); if (isMainOperationDone(result, eOperationType.StartService)) { operationDone = true; } else { if (ServiceUtils.isServiceRunning(i_ServiceName)) { operationDone = true; } else { operationDone = false; } } } catch (Exception ex) { exception = ex.Message; operationDone = false; } break; } } catch (Exception ex) { operationDone = false; exception = ex.Message; LogManager.Instance.WriteError(i_ServiceName + " => " + Enum.GetName(typeof(eOperationType), i_OperationType) + " faulted! with exception: " + ex.Message); } LogManager.Instance.WriteInfo(i_ServiceName + " => " + Enum.GetName(typeof(eOperationType), i_OperationType) + ", action ended ,took: " + stopWatch.Elapsed.ToString()); stopWatch.Stop(); result.Elapsed = stopWatch.Elapsed; result.Exception = exception; result.Done = operationDone; return result; }
/* * 0-引擎 * 1-主炮 * 2-观测 * 3-通讯 */ public void OnSwitchOperation(eOperationType eOper) { MainPanel.SetActive (true); txtMainCanon.GetComponent<Text>().color = Color.gray; txtEngine.GetComponent<Text>().color = Color.gray; txtScout.GetComponent<Text>().color = Color.gray; txtCommunication.GetComponent<Text>().color = Color.gray; bool fMainCanon = false; bool fEngine = false; bool fScout = false; bool fCommunication = false; switch (eOper) { case eOperationType.MainCanon: Ship ship = GameObject.Find("This ship").GetComponent<Ship>(); txtMainCanon.GetComponent<Text>().color = Color.white; fMainCanon = true; break; case eOperationType.Engine: txtEngine.GetComponent<Text>().color = Color.white; fEngine = true; break; case eOperationType.Scout: txtScout.GetComponent<Text>().color = Color.white; fScout = true; break; case eOperationType.Communication: txtCommunication.GetComponent<Text>().color = Color.white; fCommunication = true; break; } uigMainCanon.SetActive(fMainCanon); uigEngine.SetActive(fEngine); // btnScout.SetActive(fScout); uigCommunication.SetActive(fCommunication); }
public bool TakeAction(string i_MachineName, string i_IP, string i_ServiceName, string i_DisplayName, eOperationType i_OperationType) { string ServiceID = Guid.NewGuid().ToString(); LogManager.Instance.WriteInfo("["+ServiceID+"][Action]: " + Enum.GetName(typeof(eOperationType), i_OperationType) + " , [MachineName]: " + i_MachineName + " [IP]: " + i_IP + " [ServiceName]: " + i_ServiceName + " [DisplayName]: " + i_DisplayName + " => Started"); AgentInstance agentInstance; bool finalResult = false; try { agentInstance = m_Agents[i_IP]; Result result = agentInstance.RestartServiceContract.RestartService(i_ServiceName); finalResult = result.Done; if (result.Done == true) { SystemLogManager.Instance.Log(eLogType.Info, agentInstance, i_DisplayName, "Success", result.Elapsed.ToString()); LogManager.Instance.WriteInfo("[" + ServiceID + "][Action]: " + Enum.GetName(typeof(eOperationType), i_OperationType) + " , [MachineName]: " + i_MachineName + " [IP]: " + i_IP + " [ServiceName]: " + i_ServiceName + " [DisplayName]: " + i_DisplayName + " => Done, [Result]: Success" + " [Elapsed]: " + result.Elapsed.ToString()); } else { LogManager.Instance.WriteError("[" + ServiceID + "][Action]: " + Enum.GetName(typeof(eOperationType), i_OperationType) + " , [MachineName]: " + i_MachineName + " [IP]: " + i_IP + " [ServiceName]: " + i_ServiceName + " [DisplayName]: " + i_DisplayName + " => Done, [Result]: Failed"); foreach (Result res in result.InnerResults) { LogManager.Instance.WriteError("[" + ServiceID + "][Service]: " + res.Name + " [Action]: " + Enum.GetName(typeof(eOperationType), res.OperationType) + " [Done]: " + res.Done + " [Exception]: " + res.Exception + " [Elapsed]: " + res.Elapsed.ToString()); } SystemLogManager.Instance.Log(eLogType.Error, agentInstance, i_DisplayName, "Failed", result.Elapsed.ToString()); } } catch (Exception ex) { LogManager.Instance.WriteInfo("[" + ServiceID + "][Action]: " + Enum.GetName(typeof(eOperationType), i_OperationType) + " , [MachineName]: " + i_MachineName + " [IP]: " + i_IP + " [ServiceName]: " + i_ServiceName + " [DisplayName]: " + i_DisplayName + " [Error]: " + ex.Message); } return finalResult; }
public void AddResult(string i_Name, eOperationType i_OperationType, TimeSpan i_Elapsed, bool i_Done, string i_Exception = "") { InnerResults.Add(new Result() { Name = i_Name, OperationType = i_OperationType, Elapsed = i_Elapsed, Done = i_Done, Exception = i_Exception }); }
public void TakeAction(string i_MachineName, string i_IP, string i_ServiceName, string i_DisplayName, eOperationType i_OperationType) { Stopwatch sw = new Stopwatch(); sw.Start(); LogManager.Instance.WriteInfo("Action " + Enum.GetName(typeof(eOperationType), i_OperationType) + "on all agents started "); m_AgentsManager.TakeAction(i_MachineName, i_IP, i_ServiceName, i_DisplayName, i_OperationType); sw.Stop(); LogManager.Instance.WriteInfo("Action " + Enum.GetName(typeof(eOperationType), i_OperationType) + "on all agents ended, took: " + sw.ToString()); }