Beispiel #1
0
 /// <summary>
 /// 作者:Vincen
 /// 时间:2014-01-21
 /// 描述:设置区域中心缓存
 /// </summary>
 /// <param name="branch"></param>
 public static void SetBranchCache(Branch branch)
 {
     if (null == branch) return;
     if (!Icache.IsSet(string.Format("{0}{1}", Kword, branch.Id)))
     {
         Icache.Set(string.Format("{0}{1}", Kword, branch.Id), branch, 180 * 24 * 60);
     }
 }
Beispiel #2
0
 /// <summary>
 /// 作者:Vincen
 /// 时间:2014.01.21
 /// 描述:更新区域中心缓存
 /// </summary>
 /// <param name="branch"></param>
 public static void UpdateBranchCache(Branch branch)
 {
     if (branch != null)
     {
         Icache.Set(string.Format("{0}{1}", Kword, branch.Id), branch, 180 * 24 * 60);
     }
 }
Beispiel #3
0
        /// <summary>
        /// 作者:Ark
        /// 时间:2014-08-23
        /// 描述:同步EHR部门
        /// 更新:Ark 2014-08-27 修改时不修改父
        /// </summary>
        /// <param name="dept">部门</param>
        /// <returns></returns>
        public static ESBResult EditBranch(DeptModel dept)
        {
            var result = new ESBResult { Code = "000000", Message = "成功" };
            var editUserId = -111;

            try
            {
                using (var edb = new EmeEntities())
                {
                    var remark = dept.DeptId.ToString();
                    // EHR的部门Id对应Branch的Remark

                    // 是否新增
                    bool isAdd = false;
                    var branch = edb.Branch.FirstOrDefault(b => b.Remark == remark);

                    if (null == branch)
                    {
                        isAdd = true;
                        branch = new Branch();
                    }
                    branch.DataCenterId = dept.DeptId;
                    //branch.BranchType = ESBConvert.ToBranchType(dept.NodeType, dept.NodeCode, dept.CName);
                    branch.BranchType = ESBConvert.ToBranchType(dept.NodeType);         //sap接口,只根据nodetype判断
                    branch.CName = dept.CName;
                    branch.EName = dept.EName;
                    branch.Description = dept.EName;
                    branch.Status = dept.Status;
                    branch.Remark = remark;

                    if (1 < dept.DeptId)
                    {
                        var pDeptId = dept.ParentId.ToString();

                        if (!string.IsNullOrWhiteSpace(pDeptId) && branch.BranchType != ConvertEnum.BranchTypeForHeadquarters)
                        {
                            // 查询上级部门是否存在
                            int parentId = edb.Branch.Where(b => b.Remark == pDeptId).Select(b => b.Id).FirstOrDefault();

                            if (parentId == 0)
                            {
                                result.Code = "EME0101";
                                result.Message = "请先同步上级部门!";
                                return result;
                            }

                            branch.ParentId = parentId;
                        }
                    }
                    // 不存在新增,存在修改
                    if (isAdd)
                    {
                        branch.CreateBy = editUserId;
                        branch.CreateTime = DateTime.Now;
                        edb.Branch.Add(branch);
                    }
                    else
                    {
                        branch.UpdateBy = editUserId;
                        branch.UpdateTime = DateTime.Now;
                    }

                    edb.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                // 异常日志消息队列
                QueueManager.AddExceptionLog(new ExceptionLogs()
                {
                    ExceptionType = CommonHelper.To<int>(ExceptionType.Function),
                    Message = string.Format("BranchBLL-EditBranch:{0};{1};{2}", ex.Message, ex.InnerException.Message, ex.HelpLink),
                    IsTreat = false,
                    CreateBy = -1,
                    CreateTime = DateTime.Now
                });

                result.Code = "EME0102";
                result.Message = "数据库操作异常,请联系管理员!Cause:" + ex.Message;
            }

            return result;
        }