示例#1
0
        void INovaAlertService.UpdateTask(int unitId, Task task, long?duration, eTaskType taskType)
        {
            var unit = _resources.UnitPhones.FirstOrDefault(u => u.Id == unitId);

            if (unit != null)
            {
                unit.Task.TaskObj = task;

                NovaAlertCommon.UpdateTask(unit.UnitPhone, duration, taskType);

                // Cap nhat bang den
                if (GlobalSetting.Instance.UseSwitchPortForLP)
                {
                    SerialComm.SendAllResultBySwitchComm(unit.UnitPhone.PhoneNumberId);
                }
                else
                {
                    SerialComm.LPComm.SendAllResults(unit.UnitPhone.PhoneNumberId);
                }

                foreach (var c in _resources.GetActiveClients())
                {
                    try
                    {
                        c.Callback.OnTaskChanged(new TaskChangedEventArgs(unitId, task));
                    }
                    catch (CommunicationObjectAbortedException ex)
                    {
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
        }
示例#2
0
        List <UnitPhone> INovaAlertService.GetUnitPhones(int?groupId, eTaskType taskType, bool includeTask)
        {
            if (groupId.HasValue)
            {
                List <UnitPhone> list = new List <UnitPhone>();
                var ids = NovaAlertCommon.GetUnitsInGroup(groupId.Value);
                foreach (var u in _resources.UnitPhones)
                {
                    var g = ids.FirstOrDefault(gu => gu.UnitId == u.Id);
                    if (g != null)
                    {
                        var up = new UnitPhone(u.Id, u.Name)
                        {
                            PhoneNumberId = u.PhoneNumberId,
                            AreaCode      = u.AreaCode,
                            Number        = u.Number,
                            Password      = u.Password,
                            ListOrder     = g.ListOrder,
                        };

                        if (includeTask)
                        {
                            up.Task = NovaAlertCommon.GetLastestTask(u.PhoneNumberId, taskType);
                        }

                        list.Add(up);
                    }
                }
                return(list);
            }
            else
            {
                return(_resources.UnitPhones.Select(vm => vm.Phone).OfType <UnitPhone>().ToList());
            }
        }
示例#3
0
        public AlertControlViewModel(AlertController controller, eTaskType taskType)
        {
            this.TaskType       = taskType;
            this.Controller     = controller;
            this.ConnectCommand = new RelayCommand(p => this.Controller.OnConnect(), p => this.Controller.CanConnect());

            this.IssueCommand = new RelayCommand(p => this.Controller.OnIssue(), p => this.Controller.CanIssue());

            this.ReceiveCommand = new RelayCommand(p => this.Controller.OnReceive(), p => this.Controller.CanReceive());

            this.ChangeStatusCommand = new RelayCommand(p => this.Controller.OnChangeStatus(), p => this.Controller.CanChangeStatus());

            this.ResultCommand = new RelayCommand(p => OnViewResult());

            this.GroupSelectCommand = new RelayCommand(p => OnGroupSelect(), p => CanChangeGroup());

            if (this.TaskType == eTaskType.CTT)
            {
                this.FinishButtonCaption = "ĐÃ CTT";
            }
            else
            {
                this.FinishButtonCaption = "ĐÃ CC";
            }
        }
示例#4
0
 public static void SendAllResults(IPresentation pre, eTaskType taskType = eTaskType.CTT, int phoneNumberId = 0)
 {
     for (byte i = 0; i <= NovaAlert.Service.LPComm.MaxPanelId; i++)
     {
         SendResults(pre, (byte)(i + 1), eTaskType.CTT, phoneNumberId);
     }
 }
        /// <summary>
        /// 解析任务结果文件,获取结果信息
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="tasktype"></param>
        /// <param name="refundtaskinfo"></param>
        /// <param name="disassemblytaskinfo"></param>
        /// <returns></returns>
        public static Boolean ParseTaskReslutFile(String filename, ref eTaskType tasktype,
                                                  ref RefundTaskResultInfo refundtaskinfo, ref MeterDisassemblyTaskResultInfo disassemblytaskinfo)
        {
            //首先,初始化解密任务文件的密钥
            InitKey(EncryptKey_ResultFile);

            //取出全部的文件内容
            String  encryptstr = String.Empty;
            Boolean bl         = FileProcessor.ReadFileString(filename, out encryptstr, false);

            if (!bl || String.IsNullOrEmpty(encryptstr))
            {
                return(false);
            }

            //解析
            String filestr = DencryptTaskFileInfo(encryptstr);

            if (String.IsNullOrEmpty(filestr))
            {
                return(false);
            }

            //获取任务类型
            bl = GetTaskType(filestr, ref tasktype);
            if (!bl)
            {
                return(false);
            }

            //根据不同的任务类型获取任务信息类数据
            bl = GetTaskResultInfo(tasktype, ref refundtaskinfo, ref disassemblytaskinfo);
            return(bl);
        }
        /// <summary>
        ///  创建任务结果文件
        /// </summary>
        /// <param name="tasktype"></param>
        /// <param name="refundtaskinfo"></param>
        /// <param name="resultinfo"></param>
        /// <param name="filenamestr"></param>
        /// <returns></returns>
        public static Boolean BuildTaskReslutFile(eTaskType tasktype,
                                                  RefundTaskResultInfo refundtaskinfo, MeterDisassemblyTaskResultInfo resultinfo, ref String filenamestr)
        {
            //首先,初始化解密任务文件的密钥
            InitKey(EncryptKey_ResultFile);

            //先获取结果文件名
            String filename = GetFileName(tasktype, refundtaskinfo, resultinfo);

            if (String.IsNullOrEmpty(filename))
            {
                return(false);
            }
            filename    = ResultFileFolderPath + filename;
            filenamestr = filename;

            //构建文件具体的内容
            String filecontentstr = GetResultFileContent(tasktype, refundtaskinfo, resultinfo);

            if (String.IsNullOrEmpty(filecontentstr))
            {
                return(false);
            }

            //加密文件内容
            String encryptresfilestr = EncryptInfo(filecontentstr);

            //创建文件
            Boolean bl = FileProcessor.WriteFileString(filename, encryptresfilestr, false);

            return(true);
        }
        /// <summary>
        /// 获取退购的任务结果信息
        /// </summary>
        /// <param name="type"></param>
        /// <param name="refundtaskinfo"></param>
        /// <returns></returns>
        private static Boolean GetTaskResultInfo_Refund(eTaskType type, ref RefundTaskResultInfo refundtaskinfo)
        {
            if (m_dicFileCon == null)
            {
                return(false);
            }
            //判断任务类型,获取弹出的处理界面
            refundtaskinfo = new RefundTaskResultInfo {
            };
            //TaskID
            if (!m_dicFileCon.Keys.Contains(Const_TaskID))
            {
                return(false);
            }
            refundtaskinfo.TaskID = Convert.ToInt32(m_dicFileCon[Const_TaskID]);

            //RefundTradeID
            if (!m_dicFileCon.Keys.Contains(Const_RefundTradeID))
            {
                return(false);
            }
            refundtaskinfo.RefundTradeID = Convert.ToInt32(m_dicFileCon[Const_RefundTradeID]);

            //TechnicianID
            if (!m_dicFileCon.Keys.Contains(Const_TechnicianID))
            {
                return(false);
            }
            refundtaskinfo.TechnicianID = Convert.ToInt32(m_dicFileCon[Const_TechnicianID]);

            //MeterAddress
            if (!m_dicFileCon.Keys.Contains(Const_MeterAddress))
            {
                return(false);
            }
            refundtaskinfo.MeterAddress = m_dicFileCon[Const_MeterAddress];

            //TaskFinished
            if (!m_dicFileCon.Keys.Contains(Const_TaskFinished))
            {
                return(false);
            }
            refundtaskinfo.TaskFinished = (m_dicFileCon[Const_TaskFinished] == "1") ? true : false;

            //AllowRefund
            if (!m_dicFileCon.Keys.Contains(Const_AllowRefund))
            {
                return(false);
            }
            refundtaskinfo.EnableRefund = (m_dicFileCon[Const_AllowRefund] == "1") ? true : false;

            //TaskProcess
            if (!m_dicFileCon.Keys.Contains(Const_TaskProcess))
            {
                return(false);
            }
            refundtaskinfo.TaskProcess = m_dicFileCon[Const_TaskProcess];
            return(true);
        }
示例#8
0
 public void SetTaskTypeAndParam(eTaskType tasktype, eInvitePageType pageType, eTaskTabType tasktab)
 {
     hasInit           = false;
     this.tasktype     = tasktype;
     this.pageType     = pageType;
     this.tasktab      = tasktab;
     mDL.DefaultDataID = taskdataid;
 }
示例#9
0
    Task MakeTask(eTaskType actionType)
    {
        switch (actionType)
        {
        case eTaskType.WaitTask:
        {
            return(new WaitTask());
        }

        case eTaskType.PropTask:
        {
            return(new PropTask());
        }

        case eTaskType.Light:
        {
            return(new LightTask());
        }

        case eTaskType.Actor:
        {
            return(new ActorTask());
        }

        case eTaskType.ActorTalk:
        {
            return(new ActorTalkTask());
        }

        case eTaskType.Curtain:
        {
            return(new CurtainTask());
        }

        case eTaskType.MoveSet:
        {
            return(new MoveSetTask());
        }

        case eTaskType.AudioTrigger:
        {
            return(new AudioTriggerTask());
        }

        case eTaskType.AudienceIntent:
        {
            return(new AudienceIntentTask());
        }

        default:
        {
            return(new Task());
        }
        }
    }
        /// <summary>
        /// 获取文件名
        /// 根据任务类型和对应的参数
        /// </summary>
        /// <param name="type"></param>
        /// <param name="refundtaskinfo"></param>
        /// <param name="resultinfo"></param>
        /// <param name="isResultFile">true-结果文件名,false-任务文件名</param>
        /// <returns></returns>
        private static String GetFileName(eTaskType type,
                                          RefundTask refundtaskinfo, MeterDisassemblyTaskBase resultinfo, Boolean isResultFile = true)
        {
            List <String> namelist = new List <string> {
            };

            String str = String.Empty;

            //先根据任务类型
            switch (type)
            {
            case eTaskType.CloseCustomer:
                str = (isResultFile) ? Const_TaskFileResultName_CancelAccountResult : Const_TaskFileName_CancelAccountTask;
                break;

            case eTaskType.Refund:
                str = (isResultFile) ? Const_TaskFileResultName_RefundResult : Const_TaskFileName_RefundTask;
                break;

            case eTaskType.ReplaceMeter:
                str = (isResultFile) ? Const_TaskFileResultName_ReplaceMeterResult : Const_TaskFileName_ReplaceMeterTask;
                break;

            default:
                return(null);
            }
            namelist.Add(str);

            if (type == eTaskType.Refund)
            {
                if (refundtaskinfo == null)
                {
                    return(null);
                }
                //获取 TechnicianID
                namelist.Add(refundtaskinfo.TechnicianID.ToString());
                //获取 TaskID
                namelist.Add(refundtaskinfo.TaskID.ToString());
            }
            else
            {
                if (resultinfo == null)
                {
                    return(null);
                }
                //获取 TechnicianID
                namelist.Add(resultinfo.TechnicianID.ToString());
                //获取 TaskID
                namelist.Add(resultinfo.TaskID.ToString());
            }
            String reslutfilename = DataFormatProcessor.ListToString(namelist, "_");

            reslutfilename = reslutfilename + ".bin";
            return(reslutfilename);
        }
        /// <summary>
        /// 获取任务类型
        /// </summary>
        /// <param name="filestr"></param>
        /// <param name="tasktype"></param>
        /// <returns></returns>
        private static Boolean GetTaskType(String filestr, ref eTaskType tasktype)
        {
            if (String.IsNullOrEmpty(filestr))
            {
                return(false);
            }
            //分割内容
            List <String> filelist = new List <string> {
            };
            Boolean bl             = DataFormatProcessor.StringToList(filestr, Environment.NewLine, ref filelist);

            if (!bl || filelist.Count < 1)
            {
                return(false);
            }

            //构建dic<key-String, value-String>,key是等号左边,value是等号右边数据
            m_dicFileCon = new Dictionary <string, string> {
            };
            foreach (String str in filelist)
            {
                List <String> list = new List <string> {
                };
                bl = DataFormatProcessor.StringToList(str, "=", ref list, false, true);
                if (!bl)
                {
                    return(false);
                }
                if (list.Count == 1)
                {
                    list.Add("");
                }
                if (m_dicFileCon.Keys.Contains(list[0]))
                {
                    m_dicFileCon[list[0]] = list[1];
                }
                else
                {
                    m_dicFileCon.Add(list[0], list[1]);
                }
            }

            //获取任务类型
            if (!m_dicFileCon.ContainsKey(Const_TaskType))
            {
                return(false);
            }
            String typestr = m_dicFileCon[Const_TaskType];

            tasktype = (eTaskType)Convert.ToInt32(typestr);
            return(true);
        }
示例#12
0
 private Mission(eTaskType taskType, string missionName, string dllLocation, string className, string launchMethod,
     string shutDownMethod, int launchInterval, int _errorTryInterval, eMissionStatus missionStatus)
 {
     _TaskType = taskType;
     _MissionName = missionName;
     _DllLocation = string.Format(@"{0}{1}", System.AppDomain.CurrentDomain.BaseDirectory, dllLocation); ;
     _ClassName = className;
     _LaunchMethod = launchMethod;
     _ShutDownMethod = shutDownMethod;
     _LaunchInterval = launchInterval;
     _ErrorTryInterval = _errorTryInterval;
     _MissionStatus = missionStatus;
     _MissionOwnerStatus = ThreadState.Unstarted;
 }
示例#13
0
 List <ResultData> INovaAlertService.GetResults(eTaskType taskType)
 {
     try
     {
         if (CheckConnection() == false)
         {
             throw new ServiceException();
         }
         return(_realProxy.GetResults(taskType));
     }
     catch (Exception ex)
     {
         OnException(ex);
         throw new ServiceException();
     }
 }
示例#14
0
 UnitPhone INovaAlertService.GetUnitPhone(int id, eTaskType taskType)
 {
     try
     {
         if (CheckConnection() == false)
         {
             throw new ServiceException();
         }
         return(_realProxy.GetUnitPhone(id, taskType));
     }
     catch (Exception ex)
     {
         OnException(ex);
         throw new ServiceException();
     }
 }
示例#15
0
 public List <ResultData> GetSubResults(int phoneNumberId, eTaskType type)
 {
     try
     {
         if (CheckConnection() == false)
         {
             throw new ServiceException();
         }
         return(_realProxy.GetSubResults(phoneNumberId, type));
     }
     catch (Exception ex)
     {
         OnException(ex);
         throw new ServiceException();
     }
 }
        /// <summary>
        /// 组合成任务结果文件内容
        /// </summary>
        /// <param name="resultinfo"></param>
        /// <returns></returns>
        private static String GetResultFileContent(eTaskType type, RefundTaskResultInfo refundtaskinfo, MeterDisassemblyTaskResultInfo resultinfo)
        {
            //根据任务类型
            switch (type)
            {
            case eTaskType.CloseCustomer:
            case eTaskType.ReplaceMeter:
                return(GetResultFileContent_Replase(resultinfo));

            case eTaskType.Refund:
                return(GetResultFileContent_Refund(refundtaskinfo));

            default:
                return(null);
            }
        }
示例#17
0
 List <Entities.UnitPhone> INovaAlertService.GetUnitPhones(int?groupId, eTaskType taskType, bool includeTask)
 {
     try
     {
         if (CheckConnection() == false)
         {
             throw new ServiceException();
         }
         return(_realProxy.GetUnitPhones(groupId, taskType, includeTask));
     }
     catch (Exception ex)
     {
         OnException(ex);
         throw new ServiceException();
     }
 }
        /// <summary>
        /// 根据任务类型,获取任务信息
        /// </summary>
        /// <param name="type"></param>
        /// <param name="refundtaskinfo"></param>
        /// <param name="disassemblytaskinfo"></param>
        /// <returns></returns>
        private static Boolean GetTaskInfo(eTaskType type, ref RefundTaskInfo refundtaskinfo, ref MeterDisassemblyTaskInfo disassemblytaskinfo)
        {
            refundtaskinfo      = null;
            disassemblytaskinfo = null;
            switch (type)
            {
            case eTaskType.Refund:
                return(GetTaskInfo_Refund(type, ref refundtaskinfo));

            case eTaskType.CloseCustomer:
            case eTaskType.ReplaceMeter:
                return(GetTaskInfo_Replace(type, ref disassemblytaskinfo));

            default:
                return(false);
            }
        }
示例#19
0
        public static void RequestBuddyLevelUpFinish()
        {
            bool shouldSend = false;

            IDictionary tasks = null;

            DataLookupsCache.Instance.SearchDataByID <IDictionary>("tasks", out tasks);
            if (tasks == null)
            {
                return;
            }
            string task_state = "";
            int    task_id    = 0;
            var    iter       = tasks.GetEnumerator();

            while (iter.MoveNext())
            {
                IDictionary task = iter.Value as IDictionary;
                eTaskType   type = (eTaskType)System.Enum.Parse(typeof(eTaskType), task["task_type"].ToString());
                if (eTaskType.Normal != type && eTaskType.Week != type && eTaskType.ComeBack != type)
                {
                    continue;
                }

                task_state = EB.Dot.String("state", iter.Value, "");
                if (task_state != "running")
                {
                    continue;
                }

                task_id = int.Parse(iter.Key.ToString());
                var tpl = Hotfix_LT.Data.TaskTemplateManager.Instance.GetTask(task_id);
                if (tpl == null || tpl.target_parameter_1 != "29")
                {
                    continue;
                }

                shouldSend = true;
                break;
            }

            if (shouldSend)
            {
                LTHotfixManager.GetManager <TaskManager>().RequestUplevelTaskFinish(task_id, null);
            }
        }
示例#20
0
        //public static void GetLastestTask(UnitPhone unit, eTaskType taskType = eTaskType.CTT)
        //{
        //    using (var ctx = new NovaAlertContext())
        //    {
        //        var dt = ctx.GroupUnitTasks.Where(t => t.PhoneNumberId == unit.PhoneNumberId && t.TaskType == (byte)taskType)
        //            .OrderByDescending(t => t.Id).FirstOrDefault();
        //        if (dt != null)
        //        {
        //            unit.Task = new Task()
        //            {
        //                CurrentTask = (eTask)dt.Task,
        //                Level = (eTaskLevel)dt.Level,
        //                Result = (eTaskResult)dt.Result,
        //                CreatedDate = dt.CreatedDate
        //            };
        //        }
        //    }
        //}

        public static Task GetLastestTask(int phoneNumberId, eTaskType taskType)
        {
            using (var ctx = new NovaAlertContext())
            {
                var task = new Task();

                var dt = ctx.GroupUnitTasks.Where(t => t.PhoneNumberId == phoneNumberId && t.TaskType == (byte)taskType)
                         .OrderByDescending(t => t.Id).FirstOrDefault();
                if (dt != null)
                {
                    task.CurrentTask = (eTask)dt.Task;
                    task.Level       = (eTaskLevel)dt.Level;
                    task.Result      = (eTaskResult)dt.Result;
                    task.CreatedDate = dt.CreatedDate;
                }

                return(task);
            }
        }
示例#21
0
        public static void SendResults(IPresentation pre, byte address, eTaskType taskType, int phoneNumberId = 0)
        {
            lock (_staticSyncObj)
            {
                var dbResults = NovaAlertCommon.GetResults(taskType, phoneNumberId);

                for (int i = 0; i < dbResults.Count; i++)
                {
                    var item = dbResults[i];
                    var msg  = new LP_ResultMessage()
                    {
                        TypeDest = eDevice.LedPanel,
                        Address  = address,
                        Id       = (byte)item.DisplayId,
                        Alert    = (byte)item.Task,
                        Level    = (byte)item.Level
                    };

                    if (item.TimeReceive.HasValue && item.TimeChange.HasValue)
                    {
                        msg.Result = 3;
                    }
                    else
                    {
                        if (item.TimeChange.HasValue)
                        {
                            msg.Result = 2;
                        }
                        else
                        {
                            if (item.TimeReceive.HasValue)
                            {
                                msg.Result = 1;
                            }
                        }
                    }

                    pre.SendData(msg);
                    System.Threading.Thread.Sleep(51);
                }
            }
        }
示例#22
0
        UnitPhone INovaAlertService.GetUnitPhone(int id, eTaskType taskType)
        {
            var item = _resources.UnitPhones.FirstOrDefault(u => u.Id == id);

            if (item != null)
            {
                var unit = item.UnitPhone;
                return(new UnitPhone(unit.Id, unit.Name)
                {
                    PhoneNumberId = unit.PhoneNumberId,
                    AreaCode = unit.AreaCode,
                    Number = unit.Number,
                    Password = unit.Password,
                    ListOrder = unit.ListOrder,
                    Task = NovaAlertCommon.GetLastestTask(unit.PhoneNumberId, taskType)
                });
            }

            return(null);
        }
示例#23
0
        private static Image GetImage(eTaskType inType)
        {
            switch (inType)
            {
            case eTaskType.Input: return(global::Sardauscan.Properties.Resources.Microscope);

            case eTaskType.IO: return(global::Sardauscan.Properties.Resources.Floppy);

            case eTaskType.MeshBuild: return(global::Sardauscan.Properties.Resources.Meshes);

            case eTaskType.Smooth: return(global::Sardauscan.Properties.Resources.Mesh);

            case eTaskType.Filter: return(global::Sardauscan.Properties.Resources.Rescue);

            case eTaskType.Transform: return(global::Sardauscan.Properties.Resources.Rescue);

            case eTaskType.Color: return(global::Sardauscan.Properties.Resources.Paint);
            }
            return(global::Sardauscan.Properties.Resources.Gear);
        }
示例#24
0
        public static void ShowResults(List <ResultData> results, eTaskType taskType, string hostName)
        {
            UserControl view;

            if (taskType == eTaskType.CTT)
            {
                view = new NovaAlert.Config.Views.ResultDataListView()
                {
                    DataContext = results
                };
                ModalDialog.ShowControl(view, string.Format("{0} - Kết quả CTT", hostName), false, true);
            }
            else
            {
                view = new NovaAlert.Config.Views.ResultDataListView_CCPK()
                {
                    DataContext = results
                };
                ModalDialog.ShowControl(view, string.Format("{0} - Kết quả chuyển cấp", hostName), false, true);
            }
        }
示例#25
0
        /// <summary>
        /// 读取xml节点,输出ConfItem
        /// </summary>
        /// <param name="node"></param>
        /// <param name="missionName"></param>
        /// <returns></returns>
        private Mission(XmlNode node, string missionName)
        {
            string location = XMLHelper.GetXmlNodeAttributes(node, "location", true);
            string className = XMLHelper.GetXmlNodeAttributes(node, "classname", true);
            string launchMethod = XMLHelper.GetXmlNodeAttributes(node, "launchmethod", true);
            string shutDownMethod = XMLHelper.GetXmlNodeAttributes(node, "shutdownmethod", true);
            int launchInterval = XMLHelper.GetXmlNodeAttributesToInt(node, "launchinterval", true);
            int errorTryInterval = XMLHelper.GetXmlNodeAttributesToInt(node, "errortryinterval", true);
            string missiondstatus = XMLHelper.GetXmlNodeAttributes(node, "missionstatus", false);

            _TaskType = eTaskType.Normal;
            _MissionName = missionName;
            _DllLocation = string.Format(@"{0}{1}", System.AppDomain.CurrentDomain.BaseDirectory, location);
            _ClassName = className;
            _LaunchMethod = launchMethod;
            _ShutDownMethod = shutDownMethod;
            _LaunchInterval = launchInterval * 1000;
            _ErrorTryInterval = errorTryInterval * 1000;
            _MissionStatus = (eMissionStatus)Enum.Parse(typeof(eMissionStatus), missiondstatus, false);
            _MissionOwnerStatus = ThreadState.Unstarted;
        }
示例#26
0
        public static void UpdateTask(UnitPhone unit, long?duration, eTaskType taskType)
        {
            Entities.Task task = NovaAlert.Dal.NovaAlertCommon.GetLastestTask(unit.Id, Entities.eTaskType.CTT);
            using (var ctx = new NovaAlertContext())
            {
                var dt = new GroupUnitTask()
                {
                    GroupId       = 0, //unit.GroupId,
                    TaskType      = (byte)taskType,
                    PhoneNumberId = unit.PhoneNumberId,
                    Task          = (byte)unit.Task.CurrentTask,
                    Level         = (byte)unit.Task.Level,
                    Result        = (byte)unit.Task.Result,
                    CreatedDate   = DateTime.Now,
                    Duration      = duration
                };

                ctx.GroupUnitTasks.Add(dt);
                ctx.SaveChanges();
            }
        }
示例#27
0
        public static void RequestChatTaskFinish(ChatRule.CHAT_CHANNEL _eChannel)
        {
            if (_eChannel == ChatRule.CHAT_CHANNEL.CHAT_CHANNEL_WORLD)
            {
                IDictionary tasks = null;
                DataLookupsCache.Instance.SearchDataByID <IDictionary>("tasks", out tasks);
                if (tasks == null)
                {
                    return;
                }
                string task_state = "";
                int    task_id    = 0;
                var    iter       = tasks.GetEnumerator();
                while (iter.MoveNext())
                {
                    IDictionary task = iter.Value as IDictionary;
                    eTaskType   type = (eTaskType)System.Enum.Parse(typeof(eTaskType), task["task_type"].ToString());
                    if (eTaskType.Normal != type && eTaskType.Week != type)
                    {
                        continue;
                    }

                    task_state = EB.Dot.String("state", iter.Value, "");
                    if (task_state != "running")
                    {
                        continue;
                    }

                    task_id = int.Parse(iter.Key.ToString());
                    var tpl = Hotfix_LT.Data.TaskTemplateManager.Instance.GetTask(task_id);
                    if (tpl == null || tpl.target_parameter_1 != "4")
                    {
                        continue;
                    }

                    LTHotfixManager.GetManager <TaskManager>().RequestChatTaskFinish(task_id, null);
                    break;
                }
            }
        }
示例#28
0
        public static List <ResultData> GetSubResults(int phoneNumberId, eTaskType type)
        {
            using (var ctx = new NovaAlertContext())
            {
                var sql        = string.Format("EXEC GetSubResult {0}, {1}", phoneNumberId, (byte)type);
                var subResults = ctx.Database.SqlQuery <SubResult>(sql).ToList();

                var list = new List <ResultData>();
                foreach (var item in subResults)
                {
                    var r = new ResultData()
                    {
                        DisplayId     = item.DisplayId,
                        PhoneNumberId = item.PhoneNumberId,
                        UnitName      = item.UnitName,
                        TaskType      = (eTaskType)item.TaskType,
                        Task          = (eTask)item.Task,
                        Level         = (eTaskLevel)item.Level,
                        Result        = (eTaskResult)item.Result,
                        TimeReceive   = item.TimeReceive,
                        TimeChange    = item.TimeChange
                    };

                    if (item.IntervalReceive.HasValue)
                    {
                        r.IntervalReceive = TimeSpan.FromSeconds(item.IntervalReceive.Value);
                    }
                    if (item.IntervalChange.HasValue)
                    {
                        r.IntervalChange = TimeSpan.FromSeconds(item.IntervalChange.Value);
                    }

                    list.Add(r);
                }

                return(list);
            }
        }
 List <ResultData> INovaAlertConfigService.GetSubResults(int phoneNumberId, eTaskType type)
 {
     return(NovaAlertCommon.GetSubResults(phoneNumberId, type));
 }
 List <ResultData> INovaAlertConfigService.GetResults(eTaskType taskType)
 {
     return(NovaAlertCommon.GetResults(taskType));
 }
示例#31
0
 private static Image GetImage(eTaskType inType)
 {
     switch (inType)
     {
         case eTaskType.Input: return global::Sardauscan.Properties.Resources.Microscope;
         case eTaskType.IO: return global::Sardauscan.Properties.Resources.Floppy;
         case eTaskType.MeshBuild: return global::Sardauscan.Properties.Resources.Meshes;
         case eTaskType.Smooth: return global::Sardauscan.Properties.Resources.Mesh;
         case eTaskType.Filter: return global::Sardauscan.Properties.Resources.Rescue;
         case eTaskType.Transform: return global::Sardauscan.Properties.Resources.Rescue;
         case eTaskType.Color: return global::Sardauscan.Properties.Resources.Paint;
     }
     return global::Sardauscan.Properties.Resources.Gear;
 }
示例#32
0
        public static List <ResultData> GetResults(eTaskType taskType, int phoneNumberId = 0)
        {
            var results = new List <ResultData>();

            using (var ctx = new NovaAlertContext())
            {
                //var list = ctx.ViewResults.Where(r => r.TaskType == (byte)taskType && r.PhoneNumberId != null).OrderBy(r => r.Id).ToList();

                var list = new List <ViewResult>();
                if (phoneNumberId == 0)
                {
                    list = ctx.ViewResults.Where(r => r.TaskType == (byte)taskType && r.PhoneNumberId != null).OrderBy(r => r.Id).ToList();
                }
                else
                {
                    list = ctx.ViewResults.Where(r => r.TaskType == (byte)taskType && r.PhoneNumberId == phoneNumberId).OrderBy(r => r.Id).ToList();
                }

                foreach (var item in list)
                {
                    var re = new ResultData()
                    {
                        DisplayId     = item.Id,
                        PhoneNumberId = item.PhoneNumberId.Value,
                        UnitName      = item.UnitName,
                        Task          = (eTask)(item.Task ?? 0),
                        Level         = (eTaskLevel)(item.Level ?? 0),
                        Result        = (eTaskResult)(item.Result ?? 0),
                        TaskType      = (eTaskType)item.TaskType
                    };

                    if (re.Result == eTaskResult.NL)
                    {
                        if (item.Duration.HasValue)
                        {
                            re.TimeReceive     = item.CreatedDate;
                            re.IntervalReceive = TimeSpan.FromSeconds(item.Duration.Value);
                        }
                    }
                    else if (re.Result == eTaskResult.CTT)
                    {
                        if (item.Duration.HasValue)
                        {
                            re.TimeChange     = item.CreatedDate;
                            re.IntervalChange = TimeSpan.FromSeconds(item.Duration.Value);
                        }

                        var temp = ctx.GroupUnitTasks.Where(r => r.Result == (byte)eTaskResult.NL && r.PhoneNumberId == item.PhoneNumberId &&
                                                            r.TaskType == (byte)eTaskType.CTT).OrderByDescending(r => r.Id).FirstOrDefault();
                        if (temp != null)
                        {
                            if (temp.Duration.HasValue)
                            {
                                re.TimeReceive     = temp.CreatedDate;
                                re.IntervalReceive = TimeSpan.FromSeconds(temp.Duration.Value);
                            }
                        }
                    }

                    results.Add(re);
                }
            }

            return(results);
        }
示例#33
0
 void INovaAlertService.UpdateTask(int unitId, Entities.Task task, long?duration, eTaskType taskType)
 {
     try
     {
         if (CheckConnection() == false)
         {
             throw new ServiceException();
         }
         _realProxy.UpdateTask(unitId, task, duration, taskType);
     }
     catch (Exception ex)
     {
         OnException(ex);
     }
 }