コード例 #1
0
        /// <summary>
        /// 根据ID获取工单类型领域模型。
        /// </summary>
        /// <param name="typeId"></param>
        /// <param name="clear"></param>
        /// <returns></returns>
        public WorkOrderTypeDomainModel GetTypeDomainModelById(string typeId, bool clear)
        {
            if (string.IsNullOrEmpty(typeId) || typeId == "All")
            {
                return(null);
            }

            string cacheKey = CacheKey.WORKORDER_TYPE_DOMAINMODEL.GetKeyDefine(typeId);

            WorkOrderTypeDomainModel model = CacheUtil.Get <WorkOrderTypeDomainModel>(cacheKey);

            if (model == null || clear)
            {
                model = GetWorkOrderTypeDomainModelFromDatabase(typeId);
                if (model != null)
                {
                    CacheUtil.Set(cacheKey, model);
                }
                //else
                //{
                //    CacheUtil.Remove(cacheKey);
                //}
            }

            return(model);
        }
コード例 #2
0
        public bool DeleteTypeResultInfo(string typeId, string resultId, out string message)
        {
            bool result = false;

            message = "操作失败,请与管理员联系";

            try
            {
                BeginTransaction();

                if (WorkorderResultInfoService.Instance.Delete(resultId) > 0)
                {
                    WorkOrderTypeDomainModel dataInfo = GetTypeDomainModelById(typeId, true);
                    string sql             = @"UPDATE workorder_result_info SET sort_order = $sort_order$ WHERE workorder_result_id = $workorder_result_id$";
                    ParameterCollection pc = new ParameterCollection();

                    int index = 1;
                    foreach (WorkorderResultInfoModel item in dataInfo.ResultList.Values)
                    {
                        item.SortOrder = index;
                        index++;

                        pc.Clear();
                        pc.Add("workorder_result_id", item.WorkorderResultId);
                        pc.Add("sort_order", item.SortOrder);

                        if (ExecuteNonQuery(sql, pc) != 1)
                        {
                            RollbackTransaction();
                            return(false);
                        }

                        // TASK:检查是否有该工单类型状态值引用
                    }

                    CommitTransaction();
                    message = "成功删除指定工单类型处理结果值";
                    GetTypeDomainModelById(typeId, true);
                    result = true;
                }

                RollbackTransaction();
            }
            catch (Exception ex)
            {
                RollbackTransaction();
                LogUtil.Error("删除工单类型处理结果值异常", ex);
                throw ex;
            }

            return(result);
        }
コード例 #3
0
        /// <summary>
        /// 修改工单处理结果值。
        /// </summary>
        /// <param name="resultInfo"></param>
        /// <returns></returns>
        public bool UpdateTypeResultInfo(WorkorderResultInfoModel resultInfo)
        {
            bool result = false;
            WorkOrderTypeDomainModel domain = GetTypeDomainModelById(resultInfo.WorkorderTypeId, false);

            if (domain == null)
            {
                return(false);
            }



            if (WorkorderResultInfoService.Instance.Update(resultInfo) > 0)
            {
                result = true;
                GetTypeDomainModelById(resultInfo.WorkorderTypeId, true);
            }

            return(result);
        }
コード例 #4
0
        /// <summary>
        /// 新建工单处理结果值。
        /// </summary>
        /// <param name="resultInfo"></param>
        /// <returns></returns>
        public bool CreateTypeResultInfo(WorkorderResultInfoModel resultInfo)
        {
            bool result = false;
            WorkOrderTypeDomainModel domain = GetTypeDomainModelById(resultInfo.WorkorderTypeId, false);

            if (domain == null)
            {
                return(false);
            }

            resultInfo.SortOrder = domain.ResultList.Count + 1;

            if (WorkorderResultInfoService.Instance.Create(resultInfo) > 0)
            {
                result = true;
                GetTypeDomainModelById(resultInfo.WorkorderTypeId, true);
            }

            return(result);
        }
コード例 #5
0
        /// <summary>
        /// 获取工单结果名称字典。
        /// </summary>
        /// <param name="clear"></param>
        /// <returns></returns>
        public Dictionary <string, string> GetWorkorderResultNameList(bool clear)
        {
            string cacheKey = CacheKey.WORKORDER_RESULTNAME_DICT;
            Dictionary <string, string> dict = CacheUtil.Get <Dictionary <string, string> >(cacheKey);

            if (dict == null || clear)
            {
                dict = new Dictionary <string, string>();
                Dictionary <string, WorkorderTypeInfoModel> typeList = WorkorderTypeInfoService.Instance.GetWorkOrderDictionary(false);
                foreach (WorkorderTypeInfoModel typeItem in typeList.Values)
                {
                    WorkOrderTypeDomainModel typeDomainModel = GetTypeDomainModelById(typeItem.WorkorderTypeId, false);
                    foreach (WorkorderResultInfoModel resultModel in typeDomainModel.ResultList.Values)
                    {
                        dict[resultModel.WorkorderResultId] = resultModel.ResultName;
                    }
                }
            }

            return(dict);
        }
コード例 #6
0
        /// <summary>
        /// 下移工单类型状态值。
        /// </summary>
        /// <param name="typeStatusId"></param>
        /// <returns></returns>
        public bool MoveDownTypeStatusSortOrder(string typeId, string typeStatusId, out string message)
        {
            bool result = false;

            message = "操作失败,请与管理员联系";

            WorkOrderTypeDomainModel typeInfo = GetTypeDomainModelById(typeId, false);

            if (typeInfo == null)
            {
                message = "操作失败,该工单类型不存在";
                return(false);
            }

            if (typeInfo.StatusList == null || typeInfo.StatusList.ContainsKey(typeStatusId) == false)
            {
                message = "操作失败,该工单类型状态值不存在";
                return(false);
            }
            WorkorderStatusInfoModel statusInfo = typeInfo.StatusList[typeStatusId];

            if (statusInfo.SortOrder == typeInfo.StatusList.Count)
            {
                message = "操作失败,该工单类型状态值已为最下序列号";
                return(false);
            }

            WorkorderStatusInfoModel downValueInfo = null;

            foreach (WorkorderStatusInfoModel item in typeInfo.StatusList.Values)
            {
                if (item.SortOrder == statusInfo.SortOrder + 1)
                {
                    downValueInfo = item;
                }
            }

            if (downValueInfo != null)
            {
                string sql = @"UPDATE workorder_status_info SET sort_order = $sort_order$ WHERE workorder_status_id = $workorder_status_id$";

                try
                {
                    BeginTransaction();
                    ParameterCollection pc = new ParameterCollection();
                    pc.Add("workorder_status_id", statusInfo.WorkorderStatusId);
                    pc.Add("sort_order", statusInfo.SortOrder + 1);

                    if (ExecuteNonQuery(sql, pc) > 0)
                    {
                        pc.Clear();
                        pc.Add("workorder_status_id", downValueInfo.WorkorderStatusId);
                        pc.Add("sort_order", downValueInfo.SortOrder - 1);

                        if (ExecuteNonQuery(sql, pc) > 0)
                        {
                            CommitTransaction();
                            GetTypeDomainModelById(typeId, true);
                            message = "成功下移该工单类型状态值";
                            return(true);
                        }
                    }

                    RollbackTransaction();
                }
                catch (Exception ex)
                {
                    RollbackTransaction();
                    LogUtil.Error("下移工单类型状态值排序索引异常", ex);
                    throw ex;
                }
            }

            return(result);
        }
コード例 #7
0
        /// <summary>
        /// 根据ID从数据库获取工单类型领域模型。
        /// </summary>
        /// <param name="typeId"></param>
        /// <returns></returns>
        public WorkOrderTypeDomainModel GetWorkOrderTypeDomainModelFromDatabase(string typeId)
        {
            WorkOrderTypeDomainModel result = null;

            WorkorderTypeInfoModel typeInfo = Retrieve(typeId);

            if (typeInfo != null)
            {
                result            = new WorkOrderTypeDomainModel();
                result.StatusList = new Dictionary <string, WorkorderStatusInfoModel>();
                result.ResultList = new Dictionary <string, WorkorderResultInfoModel>();

                result.TypeInfo = typeInfo;

                ParameterCollection pc = new ParameterCollection();
                pc.Add("workorder_type_id", typeId);

                List <WorkorderStatusInfoModel> statusList = WorkorderStatusInfoService.Instance.RetrieveMultiple(pc, OrderByCollection.Create("sort_order", "asc"));
                if (statusList != null && statusList.Count > 0)
                {
                    foreach (WorkorderStatusInfoModel status in statusList)
                    {
                        if (status.StatusTag == 0)
                        {
                            result.BeginStatusInfo = status;
                        }
                        if (status.StatusTag == 2)
                        {
                            result.EndStatusInfo = status;
                        }

                        if (status.CustomStatus == "待审批")
                        {
                            result.ApprovalStatusInfo = status;
                        }

                        if (status.CustomStatus == "待质检")
                        {
                            result.QuilityCheckedStatusInfo = status;
                        }

                        result.StatusList.Add(status.WorkorderStatusId, status);
                    }
                }

                List <WorkorderResultInfoModel> resultList = WorkorderResultInfoService.Instance.RetrieveMultiple(pc, OrderByCollection.Create("sort_order", "asc"));
                if (resultList != null && resultList.Count > 0)
                {
                    foreach (WorkorderResultInfoModel resultItem in resultList)
                    {
                        if (resultItem.IsBegin == 0)
                        {
                            result.BeginResultInfo = resultItem;
                        }

                        result.ResultList.Add(resultItem.WorkorderResultId, resultItem);
                    }
                }
            }

            return(result);
        }