Ejemplo n.º 1
0
        /// <summary>
        /// 更新案件材料
        /// </summary>
        /// <param name="Sn"></param>
        /// <param name="Seq"></param>
        /// <returns></returns>
        public Boolean Update(Tvupart part)
        {
            using (TransactionScope scope = new TransactionScope())
            {
                #region 更新案件材料

                var con = new Conditions <DataBase.TVUPART>();


                con.And(x => x.Sn == part.Sn &&
                        x.Seq == part.Seq);

                con.Allow(x => x.Part_No);
                con.Allow(x => x.Qty);
                //con.Allow(x => x.Use_Date);
                con.Allow(x => x.Price);


                _tpartRepo.Update(con, part);

                #endregion

                decimal price = GetTotalPrice(part.Sn);

                RefillPrice(part.CompCd, part.Sn, price);


                scope.Complete();
            }
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 紀錄推播訊息
        /// </summary>
        /// <param name="Sn"></param>
        /// <param name="Content"></param>
        private void Record(string CompCd, string Sn, string Account, string Content)
        {
            var con = new Conditions <DataBase.TCallLogRecord>();

            con.And(x => x.SN == Sn &&
                    x.Account == Account);

            con.Allow(x => x.RecordRemark);
            con.Allow(x => x.RecordDatetime);

            TcallogRecord record = new TcallogRecord()
            {
                Comp_Cd        = CompCd,
                SN             = Sn,
                Account        = Account,
                RecordDatetime = DateTime.Now,
                RecordRemark   = Content,
            };

            _pushRecordRepo.Insert(con, record);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// [client]技師登出
        /// </summary>
        /// <param name="Account"></param>
        /// <param name="Password"></param>
        /// <returns></returns>
        public Boolean VendorLogout(string Account, string Password)
        {
            _logger.Info($"APP登出-帳號:{Account},密碼:{Password}");

            #region 取得技師資訊

            var con = new Conditions <DataBase.TVenderTechnician>();

            con.And(x => x.Account == Account);
            con.And(x => x.Password == Password);

            //con.Include(x => x.TVENDER.TCMPDAT);

            TvenderTechnician result = _technicianRepo.Get(con);

            if (result == null)
            {
                throw new NullReferenceException($"[ERROR]=> 廠商登入時,帳號或密碼不存在");
            }

            #endregion 檢核技師相關欄位

            #region 清空相關欄位

            _logger.Info($"APP登出-準備更新資訊");

            result.DeviceID       = "";
            result.RegistrationID = "";

            con.Allow(x => x.DeviceID);
            con.Allow(x => x.RegistrationID);

            _technicianRepo.Update(con, result);

            #endregion

            return(true);
        }
Ejemplo n.º 4
0
        public HttpResponseMessage ClearUUID(string Account, string Password)
        {
            try
            {
                if (MethodHelper.IsNullOrEmpty(Account, Password))
                {
                    throw new ArgumentNullException($"[ERROR]=> 清除時,沒有輸入帳號密碼");
                }

                var con = new Conditions <DataBase.TVenderTechnician>();

                //取得MD5資訊
                var md5Password = Identity.ClearPassword.GetMd5Hash(Password).ToUpper();

                con.And(x => x.Account == Account &&
                        x.Password == md5Password);

                con.Allow(x => x.DeviceID);

                Boolean isSuccess = _technicianRepo.Update(con, new TvenderTechnician()
                {
                    DeviceID = "",
                    Account  = Account,
                    Password = md5Password
                });

                if (!isSuccess)
                {
                    throw new Exception("清空設備識別值發生錯誤");
                }

                return(Request.CreateResponse(
                           HttpStatusCode.OK,
                           new JsonResult <Boolean>(true, "清空設備識別值成功", 1, true)));
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);
                return(Request.CreateResponse(
                           HttpStatusCode.OK,
                           new JsonResult <TechnicianResultApiViewModel>(null, $"{ ex.GetType().Name}:Message:{ex.Message}", 1, false)));
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 更新技師
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public Boolean UpdateTechnician(TvenderTechnician data)
        {
            _logger.Info($"更新技師-技師帳號:{data.Account}");

            #region 找到技師相關訊息
            var con = new Conditions <DataBase.TVenderTechnician>();

            con.And(x => x.Comp_Cd == data.CompCd);
            con.And(x => x.Vender_Cd == data.VenderCd);
            con.And(x => x.Account == data.Account);

            TvenderTechnician meta = _technicianRepo.Get(con);

            if (meta == null)
            {
                throw new NullReferenceException($"[ERROR]=> 更新技師訊息時,找不到技師相關訊息");
            }

            #endregion

            using (TransactionScope scope = new TransactionScope())
            {
                _logger.Info($"更新技師-準備更新資料");

                #region 更新技師訊息


                con.Allow(x => x.Enable,     //帳號啟用
                          x => x.Name,       //名字
                          x => x.IsVendor,   //角色
                          x => x.Password);  //密碼

                _technicianRepo.Update(con, data);


                #endregion

                scope.Complete();
            }

            return(true);
        }
Ejemplo n.º 6
0
        public HttpResponseMessage UpdateRegID(string RegId)
        {
            try
            {
                if (this.User == null)
                {
                    throw new ArgumentNullException($"[ERROR]=> 廠商刷新推播碼時,沒有輸入對應資訊");
                }

                var user = ((PtcIdentity)this.User.Identity).currentUser;


                var con = new Conditions <DataBase.TVenderTechnician>();

                //取得MD5資訊
                var md5Password = Identity.ClearPassword.GetMd5Hash(user.Password).ToUpper();

                con.And(x => x.Account == user.UserId &&
                        x.Password == md5Password);

                con.Allow(x => x.RegistrationID);

                Boolean isSuccess = _technicianRepo.Update(con, new TvenderTechnician()
                {
                    Account        = user.UserId,
                    Password       = md5Password,
                    RegistrationID = RegId,
                });

                return(Request.CreateResponse(
                           HttpStatusCode.OK,
                           new JsonResult <Boolean>(true, "刷新推播碼成功", 1, true)));
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest,
                                                   $"{ ex.GetType().Name}:Message:{ex.Message}"));
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 廠商銷案案件
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public Boolean VendorConfirm(Tcallog input)
        {
            _logger.Info($"案件銷案-公司別:{input.CompCd},案件編號:{input.Sn}");

            string SapAssetKind = _ImgRepo.GetSpcAssetKind(input.CompCd, input.AssetCd);


            var con = new Conditions <DataBase.TCALLOG>();

            con.And(g => g.Sn == input.Sn);
            con.And(g => g.Comp_Cd == input.CompCd);
            con.Allow(g => g.Arrive_Date);
            con.Allow(g => g.Fc_Date);
            con.Allow(g => g.TimePoint);
            con.Allow(g => g.Work_Id);
            con.Allow(g => g.Finish_Id);
            con.Allow(g => g.Damage_Proc_No);
            if (SapAssetKind == "1")
            {
                con.Allow(g => g.Coffee_Cup);
            }
            con.Allow(g => g.Close_Sts);
            con.Allow(g => g.Work_Desc);
            con.Allow(g => g.VndEng_Id);
            con.Allow(g => g.AppClose_Date);
            con.Allow(g => g.Update_User);
            con.Allow(g => g.Update_Date);

            List <TCallLogDateRecord> AddCDR = new List <TCallLogDateRecord>();

            if (input.TcallLogDateRecords != null)
            {
                AddCDR = input.TcallLogDateRecords.Where(x => x.Seq == 0).ToList();
            }

            //檢查是否已有既有紀錄,若有則進行更新就好
            TCALINV sqlCALINV = GetTCALINV(input.CompCd, input.Sn);
            var     conINV    = new Conditions <DataBase.TCALINV>();

            conINV.And(g => g.Comp_Cd == input.CompCd);
            conINV.And(g => g.Sn == input.Sn);
            if (sqlCALINV != null)
            {
                conINV.Allow(g => g.Work_Id);
                conINV.Allow(g => g.Pre_Amt);
                conINV.Allow(g => g.Update_User);
                conINV.Allow(g => g.Update_Date);
            }

            using (TransactionScope scope = new TransactionScope())
            {
                _logger.Info($"案件銷案-準備更新資料");

                #region 儲存資料

                _callogRepo.Update(con, input);

                if (input.TCALINV != null)
                {
                    if (sqlCALINV == null)
                    {
                        _CALINVRepo.Add(conINV, input.TCALINV);
                    }
                    else
                    {
                        _CALINVRepo.Update(conINV, input.TCALINV);
                    }
                }

                if (AddCDR != null)
                {
                    _callogFactory.AddDateRecords(AddCDR);
                }

                #endregion

                _logger.Info($"案件銷案-準備儲存照片");

                #region 儲存照片

                _ImgRepo.AddImg(input);

                #endregion

                scope.Complete();
            }

            return(true);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// [client]技師登入
        /// </summary>
        /// <param name="Account"></param>
        /// <param name="Password"></param>
        /// <returns></returns>
        public TvenderTechnician VendorLogin(string Account, string Password, string UUID)
        {
            _logger.Info($"APP登入-帳號:{Account},密碼:{Password},UUID:{UUID}");

            #region 取得技師資訊

            var con = new Conditions <DataBase.TVenderTechnician>();

            con.And(x => x.Account == Account);
            con.And(x => x.Password == Password);
            con.Include(x => x.TVENDER);
            con.And(x => x.TVENDER.Comp_Cd == "711");
            TvenderTechnician result = _technicianRepo.Get(con);

            #endregion 檢核技師相關欄位

            #region 相關驗證

            if (result == null)
            {
                _logger.Info("帳號或密碼不存在");
                throw new NullReferenceException($"登入失敗");
            }


            if (!result.Enable)
            {
                _logger.Info("帳號尚未啟用");
                throw new InvalidProgramException($"帳號尚未啟用");
            }

            var ConTusrven = new Conditions <DataBase.TUSRVENRELATION>();
            ConTusrven.And(x => x.Comp_Cd == result.CompCd);
            ConTusrven.And(x => x.Vender_Cd == result.VenderCd);
            var Tusrven = _tusrvenrelationRepo.Get(ConTusrven);

            if (Tusrven == null)
            {
                _logger.Info("廠商未服務711");
                throw new InvalidProgramException($"廠商未服務711");
            }

            //2018/06/19因為廠商輸入密碼錯誤6次會造成帳號被關閉且技師無法登入APP,經與玉萍討論,在決定檢核廠商的規則前,暫時不進行檢核 by 天生
            //if (_venderFactory.CheckVender(result.CompCd, Tusrven.User_Id) == false)
            //{
            //    _logger.Info("廠商已被關閉");
            //    throw new InvalidProgramException($"廠商已被關閉");
            //}

            if (!string.IsNullOrEmpty(result.DeviceID) && result.DeviceID != UUID)
            {
                _logger.Info("UUID重複");
                throw new ArgumentOutOfRangeException($"已經有其他設備登入過,是否強制登入?");
            }


            #endregion

            #region 寫入相關資訊

            _logger.Info($"APP登入-準備更新資訊");

            con.Allow(x => x.LastLoginTime);
            con.Allow(x => x.DeviceID);

            if (!_technicianRepo.Update(con, new TvenderTechnician()
            {
                Account = Account,
                Password = Password,
                DeviceID = UUID,
                LastLoginTime = DateTime.Now
            }))
            {
                throw new Exception("登入失敗");
            }

            #endregion

            return(result);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// [server 更新使用者資訊]
        /// </summary>
        /// <param name="user"></param>
        /// <param name="role"></param>
        /// <returns></returns>
        public bool Update(UserBase User, RoleAuth Role)
        {
            #region 找到對應的使用者

            var uCon = new Conditions <DataBase.TUSRMST>();

            uCon.And(x => x.Comp_Cd == User.CompCd &&
                     x.User_Id == User.UserId);


            //uCon.Include(x => x.TSYSROL);

            Tusrmst user = _userRepo.Get(uCon);


            if (user == null)
            {
                throw new NullReferenceException($"[ERROR]=>找不到對應的使用者資訊,公司代號:{User.CompCd},使用者ID:{User.UserId}");
            }


            #endregion

            #region 找到對應權限

            var rCon = new Conditions <DataBase.TSYSROL>();

            rCon.And(x => x.Comp_Cd == Role.CompCd &&
                     x.Role_Id == Role.RoleId);

            RoleAuth role = _aspRoleRepo.Get(rCon);

            if (role == null)
            {
                throw new NullReferenceException($"[ERROR]=>找不到對應的權限資訊,公司代號:{User.CompCd},權限ID:{User.RoleId}");
            }


            #endregion

            #region 組合物件

            List <AuthItem> pageAuth = CulcPageAuth(role.PageAuth, User.PageAuth);

            user.RoleId = role.RoleId;

            user.PageAuth = pageAuth != null?JsonConvert.SerializeObject(pageAuth) : string.Empty;


            #endregion

            #region 更新資料

            uCon.Allow(x => x.Role_Id,
                       x => x.PageAuth);


            if (!_userRepo.Update(uCon, user))
            {
                throw new Exception("[ERROR]=>更新使用者資訊失敗");
            }

            #endregion

            return(true);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 更新群組信息
        /// </summary>
        /// <param name="Data"></param>
        /// <param name="Accounts"></param>
        /// <returns></returns>
        public Boolean UpdateTechnicianGroup(TtechnicianGroup Data, String[] Accounts)
        {
            //_logger.Info($"更新群組-群組名稱:{Data.GroupName}");

            #region 檢核群組信息是否存在

            var con = new Conditions <DataBase.TTechnicianGroup>();
            con.And(x => x.Seq == Data.Seq &&
                    x.CompCd == Data.CompCd &&
                    x.VendorCd == Data.VendorCd);
            con.Allow(x => x.GroupName);
            con.Allow(x => x.Responsible_Do);
            con.Allow(x => x.Responsible_Zo);
            var group = _technicianGroupRepo.Get(con);

            if (group == null)
            {
                throw new IndexOutOfRangeException("[ERROR]=>修改群組數據時,檢核没有該群組數據存在");
            }

            var groupname = group.GroupName;

            #endregion

            #region 檢核群組信息是否重复

            var query = new Conditions <DataBase.TTechnicianGroup>();

            query.And(x => x.CompCd == Data.CompCd &&
                      x.VendorCd == Data.VendorCd &&
                      x.GroupName == Data.GroupName);

            var count = _technicianGroupRepo.GetList(query).Count();
            if (count > 1)
            {
                throw new IndexOutOfRangeException("[ERROR]=>修改群組數據時,檢核已經有該群組存在");
            }
            else
            {
                var gp       = _technicianGroupRepo.Get(query);
                var groupseq = 0;
                if (gp != null)
                {
                    groupseq = gp.Seq;
                }
                if (count == 1 && groupseq != Data.Seq)
                {
                    throw new IndexOutOfRangeException("[ERROR]=>修改群組數據時,檢核已經有該群組存在");
                }
            }



            #endregion

            using (TransactionScope scope = new TransactionScope())
            {
                _logger.Info($"更新群組-準備更新資料");

                #region 修改群組
                _technicianGroupRepo.Update(con, Data);
                #endregion

                #region 修改技師至群組
                var cond = new Conditions <DataBase.TTechnicianGroupClaims>();
                cond.And(x => x.Seq == Data.Seq &&
                         x.CompCd == Data.CompCd &&
                         x.VendorCd == Data.VendorCd);
                if (_technicianGroupClaimsRepo.GetList(cond).Any())
                {
                    _technicianGroupClaimsRepo.Remove(cond);
                }

                if (Accounts != null)
                {
                    foreach (String account in Accounts)
                    {
                        TtechnicianGroupClaims technicianGroupClaims = new TtechnicianGroupClaims()
                        {
                            Seq      = Data.Seq,
                            CompCd   = Data.CompCd,
                            VendorCd = Data.VendorCd,
                            Account  = account
                        };

                        var condition = new Conditions <DataBase.TTechnicianGroupClaims>();
                        condition.And(x => x.Seq == Data.Seq &&
                                      x.CompCd == Data.CompCd &&
                                      x.VendorCd == Data.VendorCd &&
                                      x.Account == account);

                        if (!_technicianGroupClaimsRepo.Add(condition, technicianGroupClaims))
                        {
                            throw new Exception("[ERROR]=>修改技師至群組時,新增失敗");
                        }
                    }
                }
                #endregion

                scope.Complete();
            }
            return(true);
        }
        public ActionResult ModifyMasterAuth(RoleAuthViewModel model)
        {
            Boolean isSuccess = false;

            try
            {
                var con = new Conditions <DataBase.TSYSROL>();

                var compcd = model?.Compcd ?? string.Empty;

                con.And(x => x.Comp_Cd == compcd &&
                        x.Role_Id == model.RoleId);

                RoleAuth roleAuth = _tsysrolRepo.Get(con);

                if (roleAuth == null)
                {
                    throw new NullReferenceException($"no find data");
                }

                List <AuthItem> pageAuth = model.PageAuth == null ? new List <AuthItem>() :
                                           model.PageAuth.Select(x => new AuthItem()
                {
                    GroupName = x.id, AuthType = x.AuthType
                }).ToList();
                Tsysrol updaterole = new Tsysrol()
                {
                    RoleId   = model.RoleId,
                    RoleName = model.RoleName,
                    CompCd   = model.Compcd,
                    PageAuth = pageAuth != null?JsonConvert.SerializeObject(pageAuth) : string.Empty,
                                   UpdateDate = DateTime.Now,
                                   UpdateUser = User.Identity.Name,
                };

                con.Allow(y => y.Role_Name,
                          y => y.PageAuth,
                          y => y.Update_Date,
                          y => y.Update_User);

                isSuccess = _uptsysrolRepo.Update(con, updaterole);

                MvcSiteMapProvider.SiteMaps.ReleaseSiteMap();

                return(Json(new JsonResult()
                {
                    Data = new
                    {
                        IsSuccess = isSuccess,
                        Message = $"修改權限:{(isSuccess ? "成功" : "失敗")}"
                    }
                }));
            }
            catch (Exception ex)
            {
                return(Json(new JsonResult()
                {
                    Data = new
                    {
                        IsSuccess = isSuccess,
                        Message = $"修改權限:{(isSuccess ? "成功" : "失敗")}"
                    }
                }));
            }
        }