示例#1
0
        private static Boolean ResponseToStation(ScriptBuffer ThisBuffer)
        {
            Boolean IsSend = false;

            if (ScriptDBBuffer.Count > 0)
            {
                List <ScriptTB> WaitingScriptList = ScriptDBBuffer.Values.Where(Item => Item.ScriptState == "CREATED" || Item.ScriptState == "WAITINGSERVER" && Item.ExecutionNumber == 1).ToList();

                if (WaitingScriptList.Count > 0)
                {
                    while (WaitingScriptList.Count > 0)
                    {
                        String Message = "";

                        Boolean IsAllScriptRecived = IsBlockComplete(WaitingScriptList[0], out Message);
                        if (IsAllScriptRecived)
                        {
                            if (!VerifyTotalExecutionTime(WaitingScriptList[0]))
                            {
                                if (ThisBuffer != null)
                                {
                                    WebSockets.ReturnScriptResult(ThisBuffer.WSConnection, ThisBuffer.Script.BlockName, ThisBuffer.Script.BlockID, ThisBuffer.Script.ExecutionNumber.ToString(), ThisBuffer.Script.CommandName.ToString(), "All script is sending to client.", "Script_Success");
                                }

                                List <ScriptTB> InValidScript = ScriptDBBuffer.Values.Where(Item => Item.BlockID == WaitingScriptList[0].BlockID).ToList();

                                foreach (ScriptTB ThisScript in InValidScript)
                                {
                                    ScriptTB TempScript = null;
                                    ScriptDBBuffer.TryRemove(ThisScript.BlockID + ThisScript.ExecutionNumber, out TempScript);
                                    DatabaseSynchronization.DeleteScript(TempScript);

                                    RemoveScriptToMonitoring(TempScript);
                                }
                                return(false);
                            }

                            SendScriptToStation(WaitingScriptList[0]);
                            WaitingScriptList.RemoveAll(Item => Item.BlockID == WaitingScriptList[0].BlockID);
                            IsSend = true;
                        }
                        else
                        {
                            WaitingScriptList.RemoveAt(0);
                        }
                    }
                }
            }

            return(IsSend);
        }
示例#2
0
 private static void ResponseToClient(ScriptBuffer ThisBuffer)
 {
     if (ThisBuffer != null)
     {
         String  Message            = "";
         Boolean IsAllScriptRecived = IsBlockComplete(ThisBuffer.Script, out Message);
         if (IsAllScriptRecived)
         {
             WebSockets.ReturnScriptResult(ThisBuffer.WSConnection, ThisBuffer.Script.BlockName, ThisBuffer.Script.BlockID, ThisBuffer.Script.ExecutionNumber.ToString(), ThisBuffer.Script.CommandName.ToString(), "All script is sending to client.", "Script_Success");
         }
         else
         {
             WebSockets.ReturnScriptResult(ThisBuffer.WSConnection, ThisBuffer.Script.BlockName, ThisBuffer.Script.BlockID, ThisBuffer.Script.ExecutionNumber.ToString(), ThisBuffer.Script.CommandName.ToString(), Message, "Script_OK");
         }
     }
 }