public OM_B1InfomationDTO UpdateSalesOrderStatusByToSAP(string cipher, string orderGuid)
 {
     OM_B1InfomationDTO b1Information = orderManger.UpdateSalesOrderStatusByToSAP(orderGuid);
     if (b1Information.GSCode == 200 && b1Information.JFZCode == 200)
     {
         var user = userManager.GetUser(s => s.Guid == cipher);
         var order = orderManger.GetSalesOrder(s => s.Guid == orderGuid);
         var log = new OM_Log
         {
             CreateDatetime = DateTime.Now,
             Doc_View = "Order/UpdateStatus",
             Guid = Guid.NewGuid().ToString(),
             Operation = "对接订单到SAP",
             User_Guid = user.Guid,
             Message = string.Format("用户[{0}] : '{1}' 对接订单【{2}】到SAP.", user.Name, DateTime.Now, order.DocEntry)
         };
         logManager.WriteLog(log);
         return b1Information;
     }
     return b1Information;
 }
        public void UpdatePassword(string cipher, string userGuid, string oldPwd, string newPwd)
        {
            var result = userManager.UpdatePassword(userGuid, oldPwd, newPwd);
            if (result == false)
                throw new GenericException("更新用户密码失败");

            var user = userManager.GetUser(s => s.Guid == userGuid);
            var log = new OM_Log
            {
                CreateDatetime = DateTime.Now,
                Doc_View = "User/Login",
                Guid = Guid.NewGuid().ToString(),
                Operation = "修改密码",
                User_Guid = cipher,
                Message = string.Format("用户[{0}] : '{1}' 修改了密码.", user.Name, DateTime.Now)
            };
            logManager.WriteLog(log);
        }
        public void UpdateSalesOrderStatusByCommit(string cipher, string orderGuid)
        {
            orderManger.UpdateSalesOrderStatusByCommit(orderGuid);

            var user = userManager.GetUser(s => s.Guid == cipher);
            var order = orderManger.GetSalesOrder(s => s.Guid == orderGuid);
            var log = new OM_Log
            {
                CreateDatetime = DateTime.Now,
                Doc_View = "Order/UpdateStatus",
                Guid = Guid.NewGuid().ToString(),
                Operation = "提交订单",
                User_Guid = user.Guid,
                Message = string.Format("用户[{0}] : '{1}' 提交订单【{2}】.", user.Name, DateTime.Now, order.DocEntry)
            };
            logManager.WriteLog(log);
        }
 public bool SaveMessageBoard(string cipher, OM_MessageBoard msgBoard)
 {
     var result = userManager.SaveMessageBoard(msgBoard);
     if (result)
     {
         var user = userManager.GetUser(s => s.Guid == cipher);
         var log = new OM_Log
         {
             CreateDatetime = DateTime.Now,
             Doc_View = "Log/MessageBoard",
             Guid = Guid.NewGuid().ToString(),
             Operation = "留言",
             User_Guid = cipher,
             Message = string.Format("用户[{0}] : '{1}' 留了一条信息.", user.Name, DateTime.Now)
         };
         logManager.WriteLog(log);
     }
     return result;
 }
        public string SaveSalesOrder(string cipher, OM_SalesOrderDataObject obj)
        {
            var result = orderManger.SaveSalesOrder(obj);
            if (!result)
                throw new GenericException("保存草稿失败。");

            var user = userManager.GetUser(s => s.Guid == cipher);
            var order = orderManger.GetSalesOrder(s => s.Guid == obj.Guid);
            var log = new OM_Log
            {
                CreateDatetime = DateTime.Now,
                Doc_View = "Order/UpdateStatus",
                Guid = Guid.NewGuid().ToString(),
                Operation = "保存草稿",
                User_Guid = user.Guid,
                Message = string.Format("用户[{0}] : '{1}' 保存草稿【{2}】.", user.Name, DateTime.Now, order.DocEntry)
            };
            logManager.WriteLog(log);
            return order.DocEntry.ToString();
        }
        public void ResetPassword(string cipher, string userGuid, string newPwd)
        {
            var result = userManager.ResetPassword(userGuid, newPwd);
            if (result == false)
                throw new GenericException("重设用户密码失败");

            var user = userManager.GetUser(s => s.Guid == userGuid);
            var log = new OM_Log
            {
                CreateDatetime = DateTime.Now,
                Doc_View = "User/ResetPassword",
                Guid = Guid.NewGuid().ToString(),
                Operation = "重设用户密码",
                User_Guid = cipher,
                Message = string.Format("'{0}' 重设用户 [{1}] 密码.", DateTime.Now, user.Name)
            };
            logManager.WriteLog(log);
        }
        public OM_UserDetail Login(string userAccount, string password)
        {
            var result = userManager.Login(userAccount, password);
            if (result == false)
                throw new GenericException("账户或密码错误,请再次检查输入", OM_ExceptionCodeEnum.LOGIN.ToString());

            var user = userManager.GetUser(f => f.Account == userAccount && f.Pwd == password);

            user.UpdateDatetime = DateTime.Now;
            user.Key = Encryptor.MD5Encrypt(user.ID + user.Account + user.Pwd + user.CreateDatetime + user.Area_Guid + user.UpdateDatetime);
            userManager.UpdateUer(user);

            var re = userManager.GetUserDetail(user.Guid);

            var log = new OM_Log
            {
                CreateDatetime = DateTime.Now,
                Doc_View = "User/Login",
                Guid = Guid.NewGuid().ToString(),
                Operation = "登陆",
                User_Guid = user.Guid,
                Message = string.Format("用户[{0}] : '{1}' 登陆了系统.", user.Name, DateTime.Now)
            };
            logManager.WriteLog(log);

            return re;
        }
 public bool WriteLog(OM_Log log)
 {
     var result= DbRepository.Add<OM_Log>(log);
        return result > 0;
 }
 public bool UpdateLog(OM_Log log)
 {
     if (DbRepository.Update(log) > 0)
     {
         return true;
     }
     return false;
 }
 public bool SaveLog(OM_Log log)
 {
     if (DbRepository.Add(log) > 0)
     {
         return true;
     }
     return false;
 }