void IJob.Execute(IJobExecutionContext context)
 {
     try
     {
         bool   isScuccess     = false;
         object val_MeasTask   = context.Scheduler.Context["val_MeasTask"];
         object SensorIDS      = context.Scheduler.Context["val_SensorIds"];
         object val_ActionType = context.Scheduler.Context["val_ActionType"];
         object val_isOnline   = context.Scheduler.Context["val_isOnline"];
         if ((val_MeasTask != null) && (SensorIDS != null) && (val_ActionType != null) && (val_isOnline != null))
         {
             Task tsk = new Task(() =>
             {
                 isScuccess = WorkFlowProcessManageTasks.Process_Multy_Meas((MeasTask)val_MeasTask, (List <int>)SensorIDS, (string)val_ActionType, (bool)val_isOnline);
             }).ContinueWith(x =>
             {
                 if (isScuccess)
                 {
                     DisposeSheduler();
                 }
             });
             System.GC.Collect();
         }
         CoreICSM.Logs.CLogs.WriteInfo(CoreICSM.Logs.ELogsWhat.Unknown, "Sheduler_Send_MeasSdr ");
     }
     catch (Exception ex) {
         CoreICSM.Logs.CLogs.WriteError(CoreICSM.Logs.ELogsWhat.Unknown, "Sheduler_Send_MeasSdr " + ex.Message);
     }
 }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="options"></param>
        /// <param name="operationContext"></param>
        /// <returns></returns>
        public override CommonOperationResult Handle(StopMeasTaskAppOperationOptions options, IAppOperationContext operationContext)
        {
            CommonOperationResult res = new CommonOperationResult();
            Task ge = new Task(() =>
            {
                try
                {
                    if (options.TaskId != null)
                    {
                        MeasTask mt = GlobalInit.LIST_MEAS_TASK.Find(z => z.Id.Value == options.TaskId.Value);
                        if (mt != null)
                        {
                            WorkFlowProcessManageTasks tasks = new WorkFlowProcessManageTasks();
                            //int ID = tasks.Create_New_Meas_Task(mt, "Stop");
                            List <int> SensorIds = new List <int>();
                            foreach (MeasSubTask item in mt.MeasSubTasks)
                            {
                                foreach (MeasSubTaskStation u in item.MeasSubTaskStations)
                                {
                                    SensorIds.Add(u.StationId.Value);
                                }
                            }

                            foreach (MeasStation item in mt.Stations)
                            {
                                SensorIds.Add(item.StationId.Value);
                            }

                            var mt_edit = new MeasTask()
                            {
                                CreatedBy = mt.CreatedBy, DateCreated = mt.DateCreated, ExecutionMode = mt.ExecutionMode, Id = mt.Id, MaxTimeBs = mt.MaxTimeBs, MeasDtParam = mt.MeasDtParam, MeasFreqParam = mt.MeasFreqParam, MeasLocParams = mt.MeasLocParams, MeasOther = mt.MeasOther, MeasSubTasks = mt.MeasSubTasks, MeasTimeParamList = mt.MeasTimeParamList, Name = mt.Name, OrderId = mt.OrderId, Prio = mt.Prio, ResultType = mt.ResultType, Stations = mt.Stations, Status = mt.Status, Task = mt.Task, Type = mt.Type
                            };
                            if (SensorIds.Count > 0)
                            {
                                bool isOnline = false;
                                WorkFlowProcessManageTasks.Process_Multy_Meas(mt_edit, SensorIds, "Stop", isOnline);
                                res.State = CommonOperationState.Success;
                            }
                        }
                    }

                    Logger.Trace(this, options, operationContext);
                }
                catch (Exception ex)
                {
                    Logger.Trace("StopMeasTask:" + ex.Message);
                    res.State      = CommonOperationState.Fault;
                    res.FaultCause = ex.Message;
                }
            });

            ge.RunSynchronously();
            return(res);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="options"></param>
        /// <param name="operationContext"></param>
        /// <returns></returns>
        public override MeasTaskIdentifier Handle(CreateMeasTaskAppOperationOptions options, IAppOperationContext operationContext)
        {
            MeasTaskIdentifier md = new MeasTaskIdentifier();

            System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.Highest;
            MeasTask mt = options.Task;

            if (mt.Id == null)
            {
                mt.Id = new MeasTaskIdentifier();
            }
            if (mt.Status == null)
            {
                mt.Status = "N";
            }
            WorkFlowProcessManageTasks tasks = new WorkFlowProcessManageTasks();

            System.Console.WriteLine("Start Create_New_Meas_Task ");
            int ID = tasks.Create_New_Meas_Task(mt, "New");

            md.Value = ID;
            Logger.Trace(this, options, operationContext);
            Task tsg = new Task(() => {
                try {
                    List <int> SensorIds = new List <int>();
                    if (mt.Stations != null)
                    {
                        foreach (MeasStation ts in mt.Stations)
                        {
                            if (ts.StationId != null)
                            {
                                if (ts.StationId != null)
                                {
                                    if (!SensorIds.Contains(ts.StationId.Value))
                                    {
                                        SensorIds.Add(ts.StationId.Value);
                                    }
                                }
                            }
                        }
                    }
                    WorkFlowProcessManageTasks.Process_Multy_Meas(mt, SensorIds, "New", false);
                }
                catch (Exception ex)
                {
                    System.Console.WriteLine("CreateMeasTaskAppOperationHandler " + ex.Message);
                }
            });

            tsg.Start();
            //tsg.Wait();
            return(md);
        }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="options"></param>
        /// <param name="operationContext"></param>
        /// <returns></returns>
        public override CommonOperationResult Handle(DeleteMeasTaskAppOperationOptions options, IAppOperationContext operationContext)
        {
            CommonOperationResult res = new CommonOperationResult();

            //bool isSuccessSendTOSDR = false;
            try {
                if (options.TaskId != null)
                {
                    MeasTask mt = GlobalInit.LIST_MEAS_TASK.Find(z => z.Id.Value == options.TaskId.Value);
                    if (mt != null)
                    {
                        WorkFlowProcessManageTasks tasks = new WorkFlowProcessManageTasks();
                        List <int> SensorIds             = new List <int>();
                        foreach (MeasSubTask item in mt.MeasSubTasks)
                        {
                            foreach (MeasSubTaskStation u in item.MeasSubTaskStations)
                            {
                                SensorIds.Add(u.StationId.Value);
                            }
                        }

                        foreach (MeasStation item in mt.Stations)
                        {
                            SensorIds.Add(item.StationId.Value);
                        }

                        var mt_edit = new MeasTask()
                        {
                            CreatedBy = mt.CreatedBy, DateCreated = mt.DateCreated, ExecutionMode = mt.ExecutionMode, Id = mt.Id, MaxTimeBs = mt.MaxTimeBs, MeasDtParam = mt.MeasDtParam, MeasFreqParam = mt.MeasFreqParam, MeasLocParams = mt.MeasLocParams, MeasOther = mt.MeasOther, MeasSubTasks = mt.MeasSubTasks, MeasTimeParamList = mt.MeasTimeParamList, Name = mt.Name, OrderId = mt.OrderId, Prio = mt.Prio, ResultType = mt.ResultType, Stations = mt.Stations, Status = mt.Status, Task = mt.Task, Type = mt.Type
                        };
                        if (SensorIds.Count > 0)
                        {
                            WorkFlowProcessManageTasks.Process_Multy_Meas(mt_edit, SensorIds, "Stop", false);
                            WorkFlowProcessManageTasks.Process_Multy_Meas(mt_edit, SensorIds, "Del", false);
                            GlobalInit.LST_MeasurementResults.RemoveAll(t => t.Id.MeasTaskId.Value == options.TaskId.Value);
                            res.State = CommonOperationState.Success;
                        }
                    }
                }
                Logger.Trace(this, options, operationContext);
            }
            catch (Exception ex) {
                res.State      = CommonOperationState.Fault;
                res.FaultCause = ex.Message;
            }
            return(res);
        }