/// <summary> /// Tries to kill the hosted process. /// </summary> public void TryKill() { var id = _hostedProcessId; if (id != null) { lock (_syncRoot) { if (_process != null) { _process.Exited -= ProcessOnExited; _process.OutputDataReceived -= ProcessOnOutputDataReceived; } _hostedProcessState = HostState.Dead; _remotePort = null; _hasProcessFailed = true; _hasProcessExited = true; _hostedProcessId = null; } ProcessExtensions.TryKill(id.Value); } _process = null; }
private void DisConnectGM01Func() { //btn_H1_Start.Text = "Start"; GM01_HostState = HostState.Unknow; txt_H1_IP.Enabled = true; txt_H1_Port.Enabled = true; txt_H1_LUNO.Enabled = true; isGM01Start = false; if (GM01_ListenThread != null && GM01_ListenThread.ThreadState == System.Threading.ThreadState.Running) { GM01_ListenThread.Suspend(); } GM01_ListenThread = null; if (GM01_StartThread.ThreadState == System.Threading.ThreadState.Running) { GM01_StartThread.Suspend(); } GM01_StartThread = null; if (socket_GM01.Connected) { socket_GM01.Disconnect(false); } socket_GM01 = null; //if (isGM01Start) //{ // btn_H1_Start.PerformClick(); //} }
//一键重启 private void btnrestart_Click(object sender, EventArgs e) { if (MessageBox.Show("您确定要重启中间件服务器吗?", "询问窗", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { try { //MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Red, "正在准备重启中间件服务,请等待..."); efwplusBaseManager.StopBase(); efwplusRouteManager.StopRoute(); efwplusWebAPIManager.StopAPI(); MongodbManager.StopDB(); NginxManager.StopWeb(); RunState = HostState.NoOpen; efwplusBaseManager.StartBase(); efwplusRouteManager.StartRoute(); efwplusWebAPIManager.StartAPI(); MongodbManager.StartDB(); NginxManager.StartWeb(); RunState = HostState.Opened; } catch { } } }
public void InitializeRuntimeBehaviors2() { HostState st = new HostState(); var ep = NetworkHelpers.LocalEphemeralEndPoint().ToString(); ServiceHost h = new ServiceHost(typeof(SpecificAction), new Uri("http://" + ep)); h.AddServiceEndpoint(typeof(Action1Interface), new BasicHttpBinding(), "temp"); h.AddServiceEndpoint(typeof(Action2Interface), new BasicHttpBinding(), "temp2"); h.Description.Behaviors.Add(new MyServiceBehavior(st, h)); h.Description.Endpoints [0].Behaviors.Add(new MyEndpointBehavior(st, h)); h.Description.Endpoints [0].Contract.Behaviors.Add(new MyContractBehavior(st, h)); h.Description.Endpoints [0].Contract.Operations [0].Behaviors.Add(new MyOperationBehavior(st, h)); h.Description.Endpoints [1].Behaviors.Add(new MyEndpointBehavior(st, h)); h.Description.Endpoints [1].Contract.Behaviors.Add(new MyContractBehavior(st, h)); h.Description.Endpoints [1].Contract.Operations [0].Behaviors.Add(new MyOperationBehavior(st, h)); h.Open(); h.Close(); string expected = "Start, IServiceBehavior.Validate, IContractBehavior.Validate, IEndpointBehavior.Validate, IOperationBehavior.ApplyDispatchBehavior, IContractBehavior.Validate, IEndpointBehavior.Validate, IOperationBehavior.ApplyDispatchBehavior, IServiceBehavior.AddBindingParameters, IContractBehavior.AddBindingParameters, IEndpointBehavior.AddBindingParameters, IOperationBehavior.AddBindingParameters, IServiceBehavior.AddBindingParameters, IContractBehavior.AddBindingParameters, IEndpointBehavior.AddBindingParameters, IOperationBehavior.AddBindingParameters, IServiceBehavior.ApplyDispatchBehavior, IContractBehavior.ApplyDispatchBehavior, IEndpointBehavior.ApplyDispatchBehavior, IOperationBehavior.ApplyDispatchBehavior, IContractBehavior.ApplyDispatchBehavior, IEndpointBehavior.ApplyDispatchBehavior, IOperationBehavior.ApplyDispatchBehavior"; Assert.AreEqual(expected, st.CurrentStage); }
//启动 private void btnStart_Click(object sender, EventArgs e) { ExecCmd("quitall", null); ExecCmd("startall", null); RunState = HostState.Opened; }
private void TransitionState(EventType evtType) { if (evtType == EventType.MessageReceivedFromBank) { if (_lastReceivedMessageFromBank is NetworkManagementModel) { var model = (_lastReceivedMessageFromBank as NetworkManagementModel); if (model.Mti == "0800" && model.NetMgtInfoCode == "001") { _log.Debug("Receieved Logon Request from Partner MTI: " + model.Mti); ChangeInternalState(HostWorkflowState.ReceivedSignOnRequest); } else if (model.Mti == "0810" && model.NetMgtInfoCode == "001") { _log.Debug("Receieved Logon Response from Partner MTI: " + model.Mti); ChangeInternalState(HostWorkflowState.ReceivedSignOnReply); this.FinaliseLogon(); } else if (model.Mti == "0820" && model.NetMgtInfoCode == "101") { _log.Debug("Receieved Key Exchange Request from Partner MTI: " + model.Mti); ChangeInternalState(HostWorkflowState.RecievedKeyExchangeRequest); } else if (model.Mti == "0830" && model.NetMgtInfoCode == "101") { _log.Debug("Receieved Key Exchange Response from Partner MTI: " + model.Mti); ChangeInternalState(HostWorkflowState.ReceivedKeyExchangeReply); _log.Debug("Finalizing Key Exchange..."); if (this.FinaliseKeyExchange()) { CurrentState = HostState.SignedOn; _log.Info("Host is now Signed ON"); } } } } else if (evtType == EventType.ResponseSentToBank) { if (_workFlowState == HostWorkflowState.ReceivedSignOnRequest) { ChangeInternalState(HostWorkflowState.SendSignOnRequest); } else if (_workFlowState == HostWorkflowState.SendSignOnRequest) { ChangeInternalState(HostWorkflowState.WaitForSignOnReply); } else if (_workFlowState == HostWorkflowState.RecievedKeyExchangeRequest) { ChangeInternalState(HostWorkflowState.SendKeyExchangeRequest); } else if (_workFlowState == HostWorkflowState.SendKeyExchangeRequest) { ChangeInternalState(HostWorkflowState.WaitForKeyExchangeReply); } else if (_workFlowState == HostWorkflowState.ReceivedKeyExchangeReply) { ChangeInternalState(HostWorkflowState.Ready); } } }
internal Runspace GetRunspace() { if (_Runspace == null) { var state = HostState.CreateSessionState(); state.LanguageMode = _LanguageMode == LanguageMode.FullLanguage ? PSLanguageMode.FullLanguage : PSLanguageMode.ConstrainedLanguage; _Runspace = RunspaceFactory.CreateRunspace(state); if (Runspace.DefaultRunspace == null) { Runspace.DefaultRunspace = _Runspace; } _Runspace.Open(); _Runspace.SessionStateProxy.PSVariable.Set(new PSRuleVariable()); _Runspace.SessionStateProxy.PSVariable.Set(new RuleVariable()); _Runspace.SessionStateProxy.PSVariable.Set(new LocalizedDataVariable()); _Runspace.SessionStateProxy.PSVariable.Set(new AssertVariable()); _Runspace.SessionStateProxy.PSVariable.Set(new TargetObjectVariable()); _Runspace.SessionStateProxy.PSVariable.Set(new ConfigurationVariable()); _Runspace.SessionStateProxy.PSVariable.Set(ErrorPreference, ActionPreference.Continue); _Runspace.SessionStateProxy.PSVariable.Set(WarningPreference, ActionPreference.Continue); _Runspace.SessionStateProxy.PSVariable.Set(VerbosePreference, ActionPreference.Continue); _Runspace.SessionStateProxy.PSVariable.Set(DebugPreference, ActionPreference.Continue); _Runspace.SessionStateProxy.Path.SetLocation(PSRuleOption.GetWorkingPath()); } return(_Runspace); }
private static void GM01_ListenClientConnect() { while (true && socket_GM01 != null && socket_GM01.Connected) { int receiveLength = socket_GM01.Receive(result_GM01); XDCMessage msgContent = XDCUnity.MessageFormat.Format(result_GM01, receiveLength, TcpHead.L2L1); string msg = msgContent.MsgASCIIString; if (!string.IsNullOrEmpty(msg.TrimEnd('\0'))) { while (true) { if (myClientSocket != null) { if (msgContent.MsgCommandType == MessageCommandType.GoInService && GM01_HostState != HostState.InService) { //这条1消息代表GM01要进入服务了,但是此时不能进入,要等GM02就位了才能进入。 GM01_HostState = HostState.WaitForReadyToInservice; } SendMsgToeCATEvent(myClientSocket, msgContent); break; } else { ReceiveMsg_Unknow("GM01-Connectting to eCAT..."); Thread.Sleep(1000); } } } } }
private void DisConnectGM02Func() { //btn_H2_Start.Text = "Start"; GM01_HostState = HostState.Unknow; txt_H2_IP.Enabled = true; txt_H2_Port.Enabled = true; txt_H2_LUNO.Enabled = true; isGM02Start = false; if (GM02Thread != null && GM02Thread.ThreadState == System.Threading.ThreadState.Running) { GM02Thread.Suspend(); } GM02Thread = null; if (GM02_StartThread != null && GM02_StartThread.ThreadState == System.Threading.ThreadState.Running) { GM02_StartThread.Suspend(); } GM02_StartThread = null; if (socket_GM02.Connected) { socket_GM02.Disconnect(false); } socket_GM02 = null; }
/// <summary> /// Initializes the UI and Interop and binds events to the AddIn. /// </summary> /// <param name="application">Excel Application</param> /// <param name="dispatcher">Excel UI Dispatcher</param> /// <param name="RibbonMacros">A serialized list of ribbon accessible macros</param> public static MacroUI CreateApplicationInstance(IMacroEngine engine) { MacroUI ui = new MacroUI(engine); string[] workspaces = new string[] { Path.GetFullPath(Files.AssemblyDirectory + "/Macros/") }; HostState state = new HostState(workspaces, Properties.Settings.Default.ActiveDocument, Properties.Settings.Default.IncludedLibraries); engine.Instantiate(state); ui.Instantiate(state); ui.MainWindow = new MainWindow() { DataContext = new MainWindowViewModel() }; ((MainWindowViewModel)ui.MainWindow.DataContext).SetTheme(Macro_Editor.Properties.Settings.Default.Theme); if (ui.m_IsRibbonLoaded) { Events.InvokeEvent("LoadRibbonMacros"); } ui.m_IsLoaded = true; return(ui); }
private void combxHostName_SelectedIndexChanged(object sender, EventArgs e) { hsResult = HostState.CANNNOT; lbQureyResult.Text = "查询结果:"; btnRevoke.Enabled = false; btnGrant.Enabled = false; }
/// <summary> /// Initializes a new instance of this ProcessWatchdog with the specified options. /// The given host process will only be started once <see cref="Start()" /> is called. /// </summary> /// <param name="process"></param> /// <param name="options"></param> /// <param name="postMortemSettings">The settings for the post mortem debugger of the host process, if none are specified then no post mortem debugging is performed</param> /// <param name="processReadyTimeout">The amount of time the host process has to report being ready before it is assumed to be dead</param> /// <exception cref="ArgumentNullException"> /// When <paramref name="process" /> is null /// </exception> /// <exception cref="ArgumentException"> /// When <paramref name="process" /> is contains only whitespace /// </exception> public ProcessWatchdog( string process = SharpRemoteHost, ProcessOptions options = ProcessOptions.HideConsole, PostMortemSettings postMortemSettings = null, TimeSpan?processReadyTimeout = null ) { if (process == null) { throw new ArgumentNullException(nameof(process)); } if (string.IsNullOrWhiteSpace(process)) { throw new ArgumentException("process"); } if (postMortemSettings != null && !postMortemSettings.IsValid) { throw new ArgumentException("postMortemSettings"); } if (postMortemSettings != null) { _postMortemSettings = postMortemSettings.Clone(); if (_postMortemSettings.MinidumpFolder != null) { _postMortemSettings.MinidumpFolder = _postMortemSettings.MinidumpFolder.Replace('/', '\\'); if (!_postMortemSettings.MinidumpFolder.EndsWith("\\")) { _postMortemSettings.MinidumpFolder += '\\'; } } } _processReadyTimeout = processReadyTimeout ?? new FailureSettings().ProcessReadyTimeout; _waitHandle = new ManualResetEvent(false); _hostedProcessState = HostState.BootPending; _syncRoot = new object(); _parentPid = Process.GetCurrentProcess().Id; _startInfo = new ProcessStartInfo(process) { Arguments = FormatArguments(_parentPid, _postMortemSettings), RedirectStandardOutput = true, UseShellExecute = false }; switch (options) { case ProcessOptions.HideConsole: _startInfo.CreateNoWindow = true; break; case ProcessOptions.ShowConsole: _startInfo.CreateNoWindow = false; break; } _hasProcessExited = true; }
static public void ProcessStream(byte[] dataStream, byte streamType) { if (dataStream[3] == HOST_STREAM_RESP_OK) { if (streamType == HOST_STREAM_CONNECT_REQ) { hostState = HostState.CONNECTED; } else if (streamType == HOST_STREAM_SPEED_REQ) { Robot.motorCurrentSpeedPPS[Robot.MOTOR_LEFT] = StreamBuilder.GetInt(dataStream, 4, StreamBuilder.BuilderType.INT32_BYTE); Robot.motorTargetSpeedPPS[Robot.MOTOR_LEFT] = StreamBuilder.GetInt(dataStream, 8, StreamBuilder.BuilderType.INT32_BYTE); Robot.motorCurrentSpeedPPS[Robot.MOTOR_RIGHT] = StreamBuilder.GetInt(dataStream, 12, StreamBuilder.BuilderType.INT32_BYTE); Robot.motorTargetSpeedPPS[Robot.MOTOR_RIGHT] = StreamBuilder.GetInt(dataStream, 16, StreamBuilder.BuilderType.INT32_BYTE); Robot.displacementX = StreamBuilder.GetFloat(dataStream, 20, StreamBuilder.BuilderType.FLOAT_BYTE_Q8); Robot.displacementY = StreamBuilder.GetFloat(dataStream, 24, StreamBuilder.BuilderType.FLOAT_BYTE_Q8); Robot.displacementYaw = StreamBuilder.GetFloat(dataStream, 28, StreamBuilder.BuilderType.FLOAT_BYTE_Q8); } else if (streamType == HOST_STREAM_SERVO_REQ) { for (UInt16 i = 0; i < Robot.SERVO_NUMBER; i++) { Robot.servoData[i] = (int)StreamBuilder.GetUnsignedInt(dataStream, (UInt16)(i + 4), StreamBuilder.BuilderType.BYTE); } } else if (streamType == HOST_STREAM_BATTERY_REQ) { Robot.batteryState = (int)StreamBuilder.GetUnsignedInt(dataStream, 4, StreamBuilder.BuilderType.BYTE); Robot.batteryVoltage = StreamBuilder.GetUnsignedFloat(dataStream, 5, StreamBuilder.BuilderType.FLOAT_BYTE_Q16); Robot.batteryPercent = (int)StreamBuilder.GetUnsignedInt(dataStream, 9, StreamBuilder.BuilderType.BYTE); } else if (streamType == HOST_STREAM_SLAMCORE_STATE_REQ) { Robot.slamcoreState = (int)StreamBuilder.GetUnsignedInt(dataStream, 4, StreamBuilder.BuilderType.BYTE); } else if (streamType == HOST_STREAM_SONAR_REQ) { for (int i = 0; i < Robot.SONAR_NUMBER; i++) { Robot.sonarData[i] = (int)StreamBuilder.GetUnsignedInt(dataStream, (UInt16)(i * 4 + 4), StreamBuilder.BuilderType.INT32_BYTE); } } DataUpdateEvent?.Invoke(); } }
static GangState <HostState> GetState() { var state = new HostState( users: new[] { new User(USER_ID) } ); return(GangState.Create(state)); }
private void StopAllHost() { MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Red, "正在准备关闭中间件服务,请等待..."); WcfGlobal.Exit(); WebApiGlobal.Exit(); RunState = HostState.NoOpen; }
static GangState <HostState> GetState( params User[] users) { var state = new HostState( users: users ); return(GangState.Create(state)); }
static public void Event() { if (SerialManager.serialPort.IsOpen && portConnected) { if (eventState == EventState.WAITCONNECT) { eventContext = HOST_STREAM_CONNECT_REQ; int _length = BuildStream(streamBuffer, eventContext); streamRecieved = false; streamBufferPos = 0; streamState = StreamState.WAITFORHEAD; SerialManager.SetISRLength(1); SerialManager.SendStream(streamBuffer, _length); eventState = EventState.WAITRESP; } else if (eventState == EventState.SEND) { int _length = BuildStream(streamBuffer, eventContext); streamRecieved = false; streamBufferPos = 0; streamState = StreamState.WAITFORHEAD; SerialManager.SetISRLength(1); SerialManager.SendStream(streamBuffer, _length); eventState = EventState.WAITRESP; } else if (eventState == EventState.WAITRESP) { if (streamRecieved) { if (hostState == HostState.CONNECTED || eventContext == HOST_STREAM_CONNECT_REQ) { ProcessStream(streamBuffer, eventContext); if (eventContext == HOST_STREAM_CONNECT_REQ && hostState == HostState.CONNECTED) { eventContext = HOST_STREAM_SPEED_REQ; eventState = EventState.SEND; } else if (eventContext != HOST_STREAM_CONNECT_REQ) { eventContext = GetNextContext(eventContext); eventState = EventState.SEND; } } } } } else { hostState = HostState.DISCONNECTED; eventState = EventState.WAITCONNECT; eventContext = HOST_STREAM_CONNECT_REQ; streamRecieved = false; streamBufferPos = 0; streamState = StreamState.WAITFORHEAD; SerialManager.SetISRLength(1); } }
//停止 private void btnStop_Click(object sender, EventArgs e) { if (MessageBox.Show("您确定要停止服务吗?", "询问窗", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { ExecCmd("quitall", null); RunState = HostState.NoOpen; } }
static void IncreaseScore(HostState hostState) { lock (hostState) { if (hostState.Score < ScoreCeil) { hostState.Score++; } } }
private void btnStop_Click(object sender, EventArgs e) { if (MessageBox.Show("您确定要停止服务吗?", "询问窗", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { try { if (mAppHost != null) { WcfServerManage.StopWCFHost(); WcfServerManage.UnCreateSuperClient(); mAppHost.Close(); AddMsg(Color.Blue, DateTime.Now, "基础服务已关闭"); } if (mRouterHost != null && mFileRouterHost != null) { mRouterHost.Close(); mFileRouterHost.Close(); RouterServerManage.Stop(); AddMsg(Color.Blue, DateTime.Now, "路由服务已关闭"); } if (mFileHost != null) { mFileHost.Close(); AddMsg(Color.Blue, DateTime.Now, "文件传输服务已关闭"); } if (webapiHost != null) { webapiHost.StopHost(); AddMsg(Color.Blue, DateTime.Now, "WebAPI服务已关闭"); } } catch { if (mAppHost != null) { mAppHost.Abort(); } if (mRouterHost != null) { mRouterHost.Abort(); } if (mFileHost != null) { mFileHost.Abort(); } if (webapiHost != null) { webapiHost = null; } } RunState = HostState.NoOpen; } }
public override void LoadScene(HostScene scene, object initState = null) { this.newHostSceneRequest = new NewHostSceneRequest() { Scene = scene, InitState = initState }; Thread.MemoryBarrier(); this.state = HostState.LoadingScene; }
public Message(HostState hostState, BoincRpc.Message rpcMessage) { HostId = hostState.Id; HostName = hostState.Name; Project = rpcMessage.Project; Date = rpcMessage.Timestamp.ToLocalTime().ToString("g"); MessageBody = rpcMessage.Body; Priority = rpcMessage.Priority.ToString(); }
private void ProcessOnExited(object sender, EventArgs args) { var s = (Process)sender; ProcessFailureReason reason; int?pid; lock (_syncRoot) { // We have to make sure that we ignore events from previously spawned processes! if (sender != _process) { return; } if (_isDisposed || _isDisposing) { return; } if (_processFailureReason != null) { return; } _hostedProcessState = HostState.Dead; _processFailureReason = reason = Hosting.ProcessFailureReason.HostProcessExitedUnexpectedly; pid = _hostedProcessId; _remotePort = null; _hasProcessExited = true; _hasProcessFailed = true; } if (reason == Hosting.ProcessFailureReason.HostProcessExitedUnexpectedly) { Log.ErrorFormat("Host '{0}' (PID: {1}) exited unexpectedly with error code {2} at {3}!", _startInfo.FileName, pid, _process.TryGetExitCode(), _process.TryGetExitTime()); } else { _process.TryKill(); } try { var fn = OnFaultDetected; fn?.Invoke(s.Id, reason); } catch (Exception e) { Log.WarnFormat("OnFaultDetected threw an exception - ignoring it: {0}", e); } }
private void FrmHosting_Load(object sender, EventArgs e) { this.Text = "efwplusServer 云医院中间件【" + HostSettingConfig.GetValue("hostname") + "】"; this.notifyIcon1.Visible = true; this.notifyIcon1.Icon = this.Icon; this.notifyIcon1.Text = this.Text; RunState = HostState.NoOpen; lsServerUrl.Text = ReadConfig.GetWcfServerUrl(); btnStart_Click(null, null);//打开服务主机后自动启动服务 }
/// <summary> /// Adds a server to the database. If a cache of virtual machines is given, /// then we insert the virtual machines into the Master Tree. If not, then we /// obtain a list of virtual machines and then insert it into the Master Tree. /// This function is cache safe. /// </summary> /// <param name="dbHost">The computer object to insert into the database.</param> /// <param name="cache">An optional cache parameter.</param> public void AddServer(DbHostComputer dbHost, HostState state, List <VirtualMachine> cache = null) { Insert(dbHost, x => x.HostName); if (cache == null) { cache = HyperV.GetVm(dbHost.HostName); } var root = this.GetRootTreeNode(dbHost, state, cache); Directory.Add(dbHost.HostName, root); }
public void Instantiate(HostState state) { Events.SubscribeEvent("OnFocused", (Action)FocusWindow); Events.SubscribeEvent("OnShown", (Action)ShowWindow); Events.SubscribeEvent("OnHidden", (Action)HideWindow); Messages.DisplayOkMessageEvent += DisplayOkMessage; Messages.DisplayYesNoMessageReturnEvent += DisplayYesNoMessageReturn; Messages.DisplayInputMessageReturnEvent += DisplayInputMessageReturn; }
public override void Run(Client client, int scene, object initState = null) { this.client = client; this.newHostSceneRequest = new NewHostSceneRequest() { SceneName = scene, InitState = initState }; this.state = HostState.LoadingScene; this.Run(); }
public Project(HostState hostState, BoincRpc.Project project) { HostId = hostState.Id; HostName = hostState.Name; Name = project.ProjectName; Username = project.UserName; Team = project.TeamName; Credit = project.UserTotalCredit.ToString("N2"); AverageCredit = project.UserAverageCredit.ToString("N2"); Status = Statuses.GetProjectStatus(project); }
private void OnStateChanged(HostState state) { Logger.Info($">>>> Perpetuum Server State : [{_state}]"); try { StateChanged?.Invoke(this, state); } catch (Exception ex) { Logger.Exception(ex); } }
private void GetState() { this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Getting Host Instance: {0} state on: {1}", this.HostName, this.MachineName)); if (!this.GetHostInstanceByHostName()) { return; } HostState s = (HostState)Convert.ToInt32(this.hostInstance["ServiceState"], CultureInfo.InvariantCulture); this.State = s.ToString(); }
static void DecreaseScore(HostState hostState) { lock (hostState) { hostState.FailStamp = Tools.Generic.GetCurrentUtcDateTime; hostState.Score--; } }
private void btnRevoke_Click(object sender, EventArgs e) { string strHostName = combxHostName.Text; int nAffectRowCnt = 0; if (hsResult == HostState.GRANTED) { string strSql = string.Format("Update {0} set userid = '{1}' where userid = '{2}'", TableName, "@" + strHostName, strHostName); nAffectRowCnt = ExcuteNodeQurey(strSql, Conn_1285); hsResult = HostState.REVOCKED; } else if (hsResult == HostState.NOTEXISTS && strHostName.Trim().Length == 0) { string strSql = string.Format("Update {0} set userid = '@' + userid where userid not like '@%'"); nAffectRowCnt = ExcuteNodeQurey(strSql, Conn_1285); hsResult = HostState.ALLREVOCKED; } UpdateButtonsSatate(); }
private bool QureyHostNameState(string strHostName, ref HostState hostState) { if (IsHostNameExists(TableName, "userid", strHostName, Conn_1285)) { hostState = HostState.GRANTED; } else if (IsHostNameExists(TableName, "userid", "@" + strHostName, Conn_1285)) { hostState = HostState.REVOCKED; } else if (IsHostNameExists(TableName, "userid", strHostName, Conn_rtm)) { hostState = HostState.NOTEXISTS; } else { strsNameLike = GetHostNamesAlike(TableName, "userid", strHostName, Conn_rtm); hostState = HostState.CANNNOT; } return true; }
private void btnGrant_Click(object sender, EventArgs e) { string strHostName = combxHostName.Text; int nAffectRowCnt = 0; if (hsResult == HostState.REVOCKED) { string strSql = string.Format("Update {0} set userid = '{1}' where userid = '{2}'", TableName, strHostName, "@" + strHostName); nAffectRowCnt = ExcuteNodeQurey(strSql, Conn_1285); hsResult = HostState.GRANTED; } else if (hsResult == HostState.NOTEXISTS) { string strSql = string.Format("select * from {0} where userid = '{1}'", TableName, strHostName); DataRow drNew = GetDataRow(strSql, Conn_rtm); if (drNew != null) { InsertDataRow(drNew, TableName, Conn_1285); hsResult = HostState.GRANTED; } } UpdateButtonsSatate(); }
void ConfirmHostValidity(HostState state) { if (state.Score <= -_scoreLimit) throw new HostListExhausted(); }
static void IncreaseScore(HostState hostState) { lock (hostState) { if (hostState.Score < ScoreCeil) hostState.Score++; } }