Ejemplo n.º 1
0
        public static void NewLogInformation(STATIONNAME StationName, DateTime LogDate, String Message, LogType LogCategory, long?UserID)
        {
            InformationLogs NewLog = new InformationLogs();

            NewLog.LogID       = (long)(DateTime.UtcNow - DateTime.MinValue).TotalMilliseconds;
            NewLog.UserID      = UserID;
            NewLog.LogName     = "Log from " + StationName.ToString();
            NewLog.LogDate     = LogDate;
            NewLog.LogValue    = null;
            NewLog.LogMessage  = Message;
            NewLog.LogCategory = LogCategory;
            NewLog.StationName = StationName;

            TTCSLogInformation.Add(NewLog);
            TTCSTempLogInformation.Add(NewLog);

            if (!TTCSLog.IsSearchByAllStation)
            {
                AddLogToGrid(StationName, LogDate, Message, LogCategory, null, UserID);
            }
            else if (TTCSLog.IsSearchByAllStation && LogDate >= StartDate && LogDate <= EndDate)
            {
                AddLogToGrid(StationName, LogDate, Message, LogCategory, null, UserID);
            }
        }
Ejemplo n.º 2
0
        public static void NewLogInformation(STATIONNAME StationName, DateTime LogDate, String LogName, Object[] Value, String Message, LogType LogCategory, long?UserID)
        {
            InformationLogs NewLog = new InformationLogs();

            NewLog.LogID    = (long)(DateTime.UtcNow - DateTime.MinValue).TotalMilliseconds;
            NewLog.UserID   = UserID;
            NewLog.LogName  = LogName;
            NewLog.LogDate  = LogDate;
            NewLog.LogValue = Value != null?String.Join(", ", Value) : null;

            NewLog.LogMessage  = Message;
            NewLog.LogCategory = LogCategory;
            NewLog.StationName = StationName;

            if (DateTime.UtcNow.Hour == 1)
            {
                TTCSTempLogInformation.Clear();
            }

            TTCSLogInformation.Add(NewLog);
            TTCSTempLogInformation.Add(NewLog);

            if (!TTCSLog.IsSearchByAllStation)
            {
                AddLogToGrid(StationName, LogDate, Message, LogCategory, NewLog.LogValue, UserID);
            }
            else if (TTCSLog.IsSearchByAllStation && LogDate >= StartDate && LogDate <= EndDate)
            {
                AddLogToGrid(StationName, LogDate, Message, LogCategory, NewLog.LogValue, UserID);
            }
        }
Ejemplo n.º 3
0
        public static void GetLogBySearchInformarion(STATIONNAME StationName, DateTime StartDate, DateTime EndDate, Boolean IsSearchByAllStation)
        {
            List <InformationLogs> TTCSLogBySearch = TTCSLogInformation;

            TTCSLog.StartDate            = StartDate;
            TTCSLog.EndDate              = EndDate;
            TTCSLog.IsSearchByAllStation = IsSearchByAllStation;

            if (IsSearchByAllStation)
            {
                if (StationName == STATIONNAME.NULL)
                {
                    TTCSLogBySearch = TTCSLogInformation.Where(Item => Item.LogDate.Date >= StartDate.Date && Item.LogDate.Date <= EndDate.Date).ToList();
                }
                else
                {
                    TTCSLogBySearch = TTCSLogInformation.Where(Item => Item.StationName == StationName && Item.LogDate.Date >= StartDate.Date && Item.LogDate.Date <= EndDate.Date).ToList();
                }
            }

            TTCSLogGrid.Rows.Clear();
            if (TTCSLogBySearch != null)
            {
                for (int i = 0; i < TTCSLogBySearch.Count; i++)
                {
                    AddLogToGrid(TTCSLogBySearch[i].StationName, TTCSLogBySearch[i].LogDate, TTCSLogBySearch[i].LogMessage, TTCSLogBySearch[i].LogCategory, TTCSLogBySearch[i].LogValue, TTCSLogBySearch[i].UserID);
                }
            }
        }
Ejemplo n.º 4
0
        public static List <TTCSCommandDisplay> GetListCommandName(STATIONNAME StationName, DEVICECATEGORY DeviceCategory)
        {
            List <TCSCommandStructure> ListOfCommands       = CommandList.Where(Item => Item.StationOwner.Exists(Item2 => Item2 == StationName) && Item.DeviceCategory == DeviceCategory).ToList();
            List <TTCSCommandDisplay>  ListOfDisplayCommand = new List <TTCSCommandDisplay>();

            foreach (TCSCommandStructure ThisCommand in ListOfCommands)
            {
                TTCSCommandDisplay NewReturnCommand = new TTCSCommandDisplay();
                NewReturnCommand.CommandName = ThisCommand.Command.ToString();

                String ParameterStr = "";
                if (ThisCommand.Parameter != null)
                {
                    ParameterStr = String.Join(", ", ThisCommand.Parameter);
                }

                ParameterStr = ParameterStr.Replace("System.", "");
                NewReturnCommand.Parameter = ParameterStr;

                String ParaDesc = "";
                if (ThisCommand.ParameterDescription != null)
                {
                    ParaDesc = String.Join("<br>", ThisCommand.ParameterDescription);
                }

                NewReturnCommand.ParameterDescription = ParaDesc;

                ListOfDisplayCommand.Add(NewReturnCommand);
            }

            return(ListOfDisplayCommand);
        }
Ejemplo n.º 5
0
        public static void SendScriptToStation(ScriptTB CompletedScript)
        {
            STATIONNAME     DestinationStation = STATIONNAME.NULL;
            List <ScriptTB> ScriptArr          = ScriptDBBuffer.Values.Where(Item => Item.BlockID == CompletedScript.BlockID).ToList();

            ScriptStructure[] StructureArr = ConvertScriptTBToScriptStructure(ScriptArr);

            foreach (ScriptTB ThisScript in ScriptArr)
            {
                DestinationStation     = TTCSHelper.StationStrConveter(ThisScript.StationName);
                ThisScript.ScriptState = SCRIPTSTATE.WAITINGSERVER.ToString();

                UpdateScriptToMonitoring(ThisScript);
            }

            StationHandler ThisStation = AstroData.GetStationObject(DestinationStation);

            if (ThisStation.IsStationConnected)
            {
                StructureArr.OrderBy(Item => Item.ExecutionNumber);
                AstroData.ScriptHandler(DestinationStation, StructureArr);

                foreach (ScriptTB ThisScript in ScriptArr)
                {
                    ThisScript.ScriptState = SCRIPTSTATE.SENDINGTOSTATION.ToString();
                    UpdateScriptToMonitoring(ThisScript);
                }
            }
        }
Ejemplo n.º 6
0
        private void AllStationEnableSearch_CheckedChanged(object sender, EventArgs e)
        {
            if (SearchStationStartDate.Value.Date > SearchStationEndDate.Value.Date)
            {
                MessageBox.Show("Invalid search information. Please check.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                if (StationEnableSearch.Checked)
                {
                    SearchStationName.Enabled      = true;
                    SearchStationStartDate.Enabled = true;
                    SearchStationEndDate.Enabled   = true;
                }
                else
                {
                    SearchStationName.Enabled      = false;
                    SearchStationStartDate.Enabled = false;
                    SearchStationEndDate.Enabled   = false;
                }

                STATIONNAME StationName = GetStationNameForSearch(SearchStationName.Text);
                TTCSLog.GetLogBySearchInformarion(StationName, SearchStationStartDate.Value, SearchStationEndDate.Value, StationEnableSearch.Checked);
            }
        }
Ejemplo n.º 7
0
        public static void DisplayToUI(STATIONNAME StationName, DEVICENAME DeviceNameStr, INFORMATIONSTRUCT ThisInformation)
        {
            if (ActiveStation == StationName && ActiveDeviceNameStr == DeviceNameStr.ToString())
            {
                Boolean IsFound = false;
                ThreadTextHandler(StationStatus, "Online");
                ThreadTextHandler(StationLastestTimeUpdate, ThisInformation.UpdateTime.Value.ToString("MM/dd/yyyy HH:mm:ss.fff"));

                for (int i = 0; i < DeviceGrid.RowCount; i++)
                {
                    if (DeviceGrid[1, i].Value.ToString() == ThisInformation.FieldName.ToString())
                    {
                        DeviceGrid[2, i].Value = ThisInformation.Value.ToString().Length > 30 ? "Too large information to display." : ThisInformation.Value;
                        DeviceGrid[3, i].Value = ThisInformation.UpdateTime;

                        IsFound = true;
                        ThreadTextHandler(DeviceStatus, "Online");
                        break;
                    }
                }

                if (!IsFound)
                {
                    ThreadAddDataGridHandler(ThisInformation.FieldName.ToString(), ThisInformation.Value.ToString(), ThisInformation.UpdateTime.ToString());
                }
            }
            else if (ActiveStation == StationName && DeviceCombo.Items.Count == 0)
            {
                SetDeviceList();
            }
        }
Ejemplo n.º 8
0
        public static void RefreshScript(STATIONNAME StationName)
        {
            StationScript stationScript = GetStationScript(StationName);

            if (stationScript != null)
            {
                stationScript.RemoveAllScript();
            }
            else
            {
                stationScript = new StationScript(StationName);
                ScriptStation.Add(stationScript);
            }

            String LastestScript = GetLastestFile("\\\\192.168.2.110\\ftp\\Script\\" + StationName);

            if (ExtractScriptData(LastestScript, StationName, scriptConfigure, false))
            {
                SendScriptToStation(StationName);
            }
            else
            {
                DisplayScript("", StationName);
            }
        }
Ejemplo n.º 9
0
        //public Boolean DelayScheduleEvented(ScriptStructureNew[] Scripts)
        //{
        //    foreach (ScriptStructureNew Script in Scripts)
        //    {
        //        DBScheduleEngine.UpdateSchedule(Script);
        //    }

        //    return true;
        //}


        public void GetNextScriptPart(STATIONNAME StationName)
        {
            String         Output      = "";
            StationHandler ThisStation = AstroData.GetStationObject(StationName);

            ThisStation.NextScriptInformation(out Output);
        }
Ejemplo n.º 10
0
        public ReturnKnowType AstroCreateStation(STATIONNAME StationName, Double Version = 0)
        {
            try
            {
                if (Version != RequirePackageVersion)
                {
                    return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "(#Co003) Failed to create " + StationName + ". Your client version is " + Version + " (Require version " + RequirePackageVersion + ")."));
                }
                else
                {
                    OperationContext context      = OperationContext.Current;
                    ServerCallBack   SiteCallBack = OperationContext.Current.GetCallbackChannel <ServerCallBack>();
                    CallBackHandler.AddSiteConnection(StationName, context.SessionId, SiteCallBack);

                    OperationContext.Current.Channel.Closed  += StationChannel_Closed;
                    OperationContext.Current.Channel.Faulted += StationChannel_Closed;

                    ReturnKnowType CreateSiteResult = AstroData.CreateStation(StationName, context.SessionId, SiteCallBack);
                    return(CreateSiteResult);
                }
            }
            catch (Exception e)
            {
                return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "(#Co001) Failed to create site at TTCSCreateSite see. (" + e.Message + ")"));
            }
        }
Ejemplo n.º 11
0
        public void SubscribeInformation(STATIONNAME StationName, DEVICENAME DeviceName, dynamic FieldName)
        {
            ServerCallBack   ClientCallBack = OperationContext.Current.GetCallbackChannel <ServerCallBack>();
            OperationContext Context        = OperationContext.Current;

            AstroData.SubscribeInformation(StationName, DeviceName, FieldName, Context.SessionId, ClientCallBack);
        }
Ejemplo n.º 12
0
 public void AddASTROSERVER(STATIONNAME StationName, DEVICENAME DeviceName, ASTROSERVER[] FieldName, Object[] Value, DateTime[] DateTime)
 {
     for (int i = 0; i < FieldName.Count(); i++)
     {
         AstroData.NewASTROSERVERInformation(StationName, DeviceName, FieldName[i], Value[i], DateTime[i]);
     }
 }
Ejemplo n.º 13
0
        //--------------------------------------------------------------------------------------Queue----------------------------------------------------------------------------------

        public void AstroQueueUpdate(String jSon)
        {
            jSon = StringCompression.DecompressString(jSon);
            JObject obj = JObject.Parse(jSon);

            STATIONNAME stationName = TTCSHelper.StationStrConveter(obj["StationName"].ToString());
            String      Id          = obj["Id"].ToString();
            String      Event       = obj["Event"].ToString();
            DateTime    TimeStamp   = DateTime.Parse(obj["TimeStamp"].ToString());

            Console.WriteLine("[AstroQueueUpdate] " + obj["StationName"] + " : " + obj["Event"] + " --> " + Id);

            AstroQueueImpl astroQueue = DBQueueEngine.FindById(stationName, Id);

            if (Event == "RECEIVED")
            {
                QueueStatus queueStatus = new QueueStatus(QUEUE_STATUS.WAITINGSTATION, SENDING_STATUS.COMPLETED, TimeStamp);

                astroQueue.QueueStatus.Add(queueStatus);
                astroQueue.Save();
            }

            Task task = Task.Run(async() =>
            {
                await Task.Delay(100);

                StationHandler StationCommunication = AstroData.GetStationObject(stationName);
                StationCommunication.AckTarget(astroQueue, QUEUE_STATUS.WAITINGSTATION, SENDING_STATUS.COMPLETED);
            });
        }
Ejemplo n.º 14
0
        public void AstroQueueUpdateExposure(String jSon)
        {
            jSon = StringCompression.DecompressString(jSon);
            JObject obj = JObject.Parse(jSon);

            STATIONNAME    stationName        = TTCSHelper.StationStrConveter(obj["StationName"].ToString());
            String         Id                 = obj["Id"].ToString();
            String         AstroQueueId       = obj["AstroQueueId"].ToString();
            ExposedHistory exposedHistoryRecv = (ExposedHistory)JsonConvert.DeserializeObject(obj["ExposedHistory"].ToString(), typeof(ExposedHistory));

            Console.WriteLine("[AstroQueueUpdateExposure] " + obj["StationName"] + " : " + exposedHistoryRecv.filterName + " --> " + Id);

            AstroQueueImpl astroQueue     = DBQueueEngine.FindById(stationName, AstroQueueId);
            ExposedHistory exposedHistory = astroQueue.Target.exposedHistory.Find(Item => Item.filterName == exposedHistoryRecv.filterName && Item.executedStatus == EXECUTESTATUS.WAIT);

            if (exposedHistory != null)
            {
                exposedHistory.executedStatus = exposedHistoryRecv.executedStatus;
                exposedHistory.executedDate   = exposedHistoryRecv.executedDate;

                astroQueue.Save();

                Task task = Task.Run(async() =>
                {
                    await Task.Delay(100);

                    StationHandler StationCommunication = AstroData.GetStationObject(stationName);
                    StationCommunication.AckExposure(Id, SENDING_STATUS.COMPLETED);
                });
            }
        }
Ejemplo n.º 15
0
 public void AddWEATHERSTATION(STATIONNAME StationName, DEVICENAME DeviceName, WEATHERSTATION[] FieldName, Object[] Value, DateTime[] DateTime)
 {
     for (int i = 0; i < FieldName.Count(); i++)
     {
         AstroData.NewWEATHERSTATIONInformation(StationName, DeviceName, FieldName[i], Value[i], DateTime[i]);
     }
 }
Ejemplo n.º 16
0
 public void AddLANOUTLET(STATIONNAME StationName, DEVICENAME DeviceName, LANOUTLET[] FieldName, Object[] Value, DateTime[] DateTime)
 {
     for (int i = 0; i < FieldName.Count(); i++)
     {
         AstroData.NewLANOUTLETInformation(StationName, DeviceName, FieldName[i], Value[i], DateTime[i]);
     }
 }
Ejemplo n.º 17
0
 public static StationHandler GetStationObject(STATIONNAME StationName)
 {
     if (KeeperData != null)
     {
         return(KeeperData.FirstOrDefault(Item => Item.StationName == StationName));
     }
     return(null);
 }
Ejemplo n.º 18
0
        public static void CreateStation(STATIONNAME StationName, List <DEVICEMAPPER> AvaliableDevices)
        {
            StationHandler NewStation = new StationHandler();

            NewStation.CreateEngine(StationName, AvaliableDevices);

            KeeperData.Add(NewStation);
        }
Ejemplo n.º 19
0
        public static STATIONNAME StationStrConveter(String Name)
        {
            String             ThisName       = Name.Trim();
            List <STATIONNAME> AllStationName = Enum.GetValues(typeof(STATIONNAME)).Cast <STATIONNAME>().ToList();
            STATIONNAME        StationName    = AllStationName.FirstOrDefault(Item => Item.ToString() == ThisName);

            return(StationName);
        }
Ejemplo n.º 20
0
        private static void DisplayAllField(STATIONNAME StationName, String DeviceNameStr, dynamic FieldName, INFORMATIONSTRUCT ThisInformation)
        {
            String FieldNameStr = FieldName.ToString();

            if (ActiveStation == StationName && FieldNameStr != "NULL")
            {
                ThreadAddDataGridHandler(FieldNameStr, ThisInformation.Value == null ? "-" : ThisInformation.Value.ToString(), ThisInformation.UpdateTime == null ? "-" : ThisInformation.UpdateTime.ToString());
            }
        }
Ejemplo n.º 21
0
        public static void SubscribeInformation(STATIONNAME StationName, DEVICENAME DeviceName, dynamic FieldName, String SessionID, Object CallBackObject)
        {
            StationHandler SiteInformation = KeeperData.FirstOrDefault(Item => Item.StationName == StationName);

            if (SiteInformation != null)
            {
                SiteInformation.SubscribeInformation(DeviceName, FieldName, SessionID, CallBackObject);
            }
        }
Ejemplo n.º 22
0
        public static void NewASTROSERVERInformation(STATIONNAME StationName, DEVICENAME DeviceName, ASTROSERVER FieldName, Object Value, DateTime DataTimestamp)
        {
            StationHandler ExistingStation = KeeperData.FirstOrDefault(Item => Item.StationName == StationName);

            if (ExistingStation != null)
            {
                ExistingStation.NewASTROSERVERInformation(DeviceName, FieldName, Value, DataTimestamp);
            }
        }
Ejemplo n.º 23
0
        public static void NewGPSInformation(String DataGroupID, STATIONNAME StationName, DEVICENAME DeviceName, GPS FieldName, Object Value, DateTime DataTimestamp, Boolean IsHistory)
        {
            StationHandler ExistingStation = KeeperData.FirstOrDefault(Item => Item.StationName == StationName);

            if (ExistingStation != null)
            {
                ExistingStation.NewGPSInformation(DataGroupID, DeviceName, FieldName, Value, DataTimestamp, IsHistory);
            }
        }
Ejemplo n.º 24
0
        public Boolean AddASTROCLIENT(STATIONNAME StationName, DEVICENAME DeviceName, ASTROCLIENT[] FieldName, Object[] Value, DateTime[] DateTime)
        {
            for (int i = 0; i < FieldName.Count(); i++)
            {
                AstroData.NewASTROCLIENTInformation(StationName, DeviceName, FieldName[i], Value[i], DateTime[i]);
            }

            return(true);
        }
Ejemplo n.º 25
0
        public static void ReturnSubscribe(STATIONNAME _StationName, DEVICECATEGORY _DeviceName, String _CommandName, Object _Value, DateTime _UpdateTime)
        {
            SubscribeStructure ThisSubscribe = SubscribeList.FirstOrDefault(Item => Item.StationName == _StationName && Item.DeviceName == _DeviceName && Item.CommandName == _CommandName);

            for (int i = 0; i < SubscribeList.Count; i++)
            {
                //if(SubscribeList[i].StationName == _StationName && SubscribeList[i].DeviceName == DeviceName.NULL && SubscribeList[i].CommandName == null)
            }
        }
Ejemplo n.º 26
0
        public static void UnsubscribeByFieldName(String SessionID, STATIONNAME StationName, DEVICENAME DeviceName, dynamic FieldName)
        {
            StationHandler ThisSite = KeeperData.FirstOrDefault(Item => Item.StationName == StationName);

            if (ThisSite != null)
            {
                ThisSite.UnsubscribeByFieldName(SessionID, DeviceName, FieldName);
            }
        }
Ejemplo n.º 27
0
        public void AddGPS(String DataGroupID, STATIONNAME StationName, DEVICENAME DeviceName, GPS[] FieldName, Object[] Value, DateTime[] DateTime, Boolean IsHistory)
        {
            for (int i = 0; i < FieldName.Count(); i++)
            {
                AstroData.NewGPSInformation(DataGroupID, StationName, DeviceName, FieldName[i], Value[i], DateTime[i], IsHistory);
            }

            AstroData.ReturnAckState(DataGroupID, StationName, DeviceName);
        }
Ejemplo n.º 28
0
        public static List <OUTPUTSTRUCT> GetInformation(STATIONNAME StationName)
        {
            StationHandler SiteInformation = KeeperData.FirstOrDefault(Item => Item.StationName == StationName);

            if (SiteInformation != null)
            {
                return(SiteInformation.GetInformation());
            }
            return(null);
        }
Ejemplo n.º 29
0
        public static INFORMATIONSTRUCT GetInformationObject(STATIONNAME StationName, DEVICENAME DeviceName, dynamic FieldName)
        {
            StationHandler SiteInformation = KeeperData.FirstOrDefault(Item => Item.StationName == StationName);

            if (SiteInformation != null)
            {
                return(SiteInformation.GetInformationObject(DeviceName, FieldName));
            }
            return(null);
        }
Ejemplo n.º 30
0
        public static void AddSiteConnection(STATIONNAME StationName, String SiteSessionID, ServerCallBack SiteCallBack)
        {
            SiteConnection NewSiteConnection = new SiteConnection();

            NewSiteConnection.StationName   = StationName;
            NewSiteConnection.SiteSessionID = SiteSessionID;
            NewSiteConnection.SiteCallBack  = SiteCallBack;

            SiteConnectionList.Add(NewSiteConnection);
        }