Esempio n. 1
0
        public static void LogNew(int siteId, int channelId, int contentID, string realName, string toDepartmentName)
        {
            var logInfo = new LogInfo(0, siteId, channelId, contentID, 0, string.Empty, ELogTypeUtils.GetValue(ELogType.New), Utils.GetIpAddress(), DateTime.Now,
                                      $"前台{realName}提交办件{toDepartmentName}");

            LogDao.Insert(logInfo);
        }
Esempio n. 2
0
        /**
         * 異動角色檔
         **/
        public void updateRole(RoleMgrModel roleMgrModel, CODE_ROLE codeRoleO, SqlConnection conn, SqlTransaction transaction)
        {
            try
            {
                CodeRoleDao codeRoleDao = new CodeRoleDao();

                //新增LOG
                Log log = new Log();
                log.CFUNCTION = "角色管理-修改";
                log.CACTION   = "U";
                log.CCONTENT  = codeRoleDao.roleLogContent(codeRoleO);
                LogDao.Insert(log, Session["UserID"].ToString());

                //異動角色檔
                codeRoleO.DATA_STATUS     = "2";
                codeRoleO.LAST_UPDATE_UID = Session["UserID"].ToString();
                codeRoleO.LAST_UPDATE_DT  = DateTime.Now;
                codeRoleO.FREEZE_UID      = Session["UserID"].ToString();
                codeRoleO.FREEZE_DT       = DateTime.Now;

                int cnt = codeRoleDao.Update(codeRoleO, conn, transaction);
            }
            catch (Exception e)
            {
                logger.Error("[updateRole]其它錯誤:" + e.ToString());
                throw e;
                //新增角色檔失敗
                // return Json(new { success = false, errors = e.ToString() }, JsonRequestBehavior.AllowGet);
            }
        }
Esempio n. 3
0
        public static void LogSwitchTo(int siteId, int channelId, int contentID, string switchToDepartmentName, string administratorName, int departmentId)
        {
            var logInfo = new LogInfo(0, siteId, channelId, contentID, departmentId, administratorName, ELogTypeUtils.GetValue(ELogType.SwitchTo), Utils.GetIpAddress(), DateTime.Now,
                                      $"{DepartmentManager.GetDepartmentName(departmentId)}({administratorName})转办办件至{switchToDepartmentName} ");

            LogDao.Insert(logInfo);
        }
Esempio n. 4
0
        public static void LogTranslate(int siteId, int channelId, int contentID, string nodeName, string administratorName, int departmentId)
        {
            var logInfo = new LogInfo(0, siteId, channelId, contentID, departmentId, administratorName, ELogTypeUtils.GetValue(ELogType.Translate), Utils.GetIpAddress(), DateTime.Now,
                                      $"{DepartmentManager.GetDepartmentName(departmentId)}({administratorName})从分类“{nodeName}”转移办件至此 ");

            LogDao.Insert(logInfo);
        }
Esempio n. 5
0
        public static void Log(int siteId, int channelId, int contentID, string logType, string administratorName, int departmentId)
        {
            var logInfo = new LogInfo(0, siteId, channelId, contentID, departmentId, administratorName, logType, Utils.GetIpAddress(), DateTime.Now, string.Empty);

            var departmentName = DepartmentManager.GetDepartmentName(departmentId);

            ELogType eLogType = ELogTypeUtils.GetEnumType(logType);

            if (eLogType == ELogType.Accept)
            {
                logInfo.Summary = $"{departmentName}({administratorName})受理办件";
            }
            else if (eLogType == ELogType.Deny)
            {
                logInfo.Summary = $"{departmentName}({administratorName})拒绝受理办件";
            }
            else if (eLogType == ELogType.Reply)
            {
                logInfo.Summary = $"{departmentName}({administratorName})回复办件";
            }
            else if (eLogType == ELogType.Comment)
            {
                logInfo.Summary = $"{departmentName}({administratorName})批示办件";
            }
            else if (eLogType == ELogType.Redo)
            {
                logInfo.Summary = $"{departmentName}({administratorName})要求返工";
            }
            else if (eLogType == ELogType.Check)
            {
                logInfo.Summary = $"{departmentName}({administratorName})审核通过";
            }
            LogDao.Insert(logInfo);
        }
Esempio n. 6
0
        /// <summary>
        /// 處理角色存取項目異動
        /// </summary>
        /// <param name="roleId"></param>
        /// <param name="aplyNO"></param>
        /// <param name="conn"></param>
        /// <param name="transaction"></param>
        private void procRoleItemHis(string roleId, string aplyNo, SqlConnection conn, SqlTransaction transaction)
        {
            CodeRoleItemHisDao       codeRoleItemHisDao = new CodeRoleItemHisDao();
            List <CodeRoleItemModel> cRoleItemList      = codeRoleItemHisDao.qryByAplyNo(aplyNo, "");

            if (cRoleItemList != null)
            {
                if (cRoleItemList.Count > 0)
                {
                    CodeRoleItemDao codeRoleItemDao = new CodeRoleItemDao();

                    foreach (CodeRoleItemModel d in cRoleItemList)
                    {
                        CODE_ROLE_ITEM dItem = new CODE_ROLE_ITEM();
                        Log            log   = new Log();

                        switch (d.execAction)
                        {
                        case "A":
                            dItem.ROLE_ID         = roleId;
                            dItem.ITEM_ID         = d.itemId;
                            dItem.AUTH_TYPE       = d.authType;
                            dItem.LAST_UPDATE_UID = Session["UserID"].ToString();
                            dItem.LAST_UPDATE_DT  = DateTime.Now;


                            //新增資料
                            codeRoleItemDao.Insert(dItem, conn, transaction);


                            //新增LOG
                            log.CFUNCTION = "角色管理(存取項目)-新增";
                            log.CACTION   = "A";
                            log.CCONTENT  = codeRoleItemDao.logContent(dItem);
                            LogDao.Insert(log, Session["UserID"].ToString());

                            break;

                        case "D":
                            dItem = codeRoleItemDao.getRoleItemByKey(roleId, d.itemId, d.authType);

                            //新增LOG
                            log.CFUNCTION = "角色管理(存取項目)-刪除";
                            log.CACTION   = "D";
                            log.CCONTENT  = codeRoleItemDao.logContent(dItem);
                            LogDao.Insert(log, Session["UserID"].ToString());

                            //刪除資料
                            codeRoleItemDao.Delete(dItem, conn, transaction);

                            break;

                        default:
                            break;
                        }
                    }
                }
            }
        }
Esempio n. 7
0
        public IHttpActionResult Submit()
        {
            try
            {
                var request  = Context.GetCurrentRequest();
                var formInfo = FormManager.GetFormInfoByPost(request);
                if (formInfo == null)
                {
                    return(NotFound());
                }
                if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.PluginId))
                {
                    return(Unauthorized());
                }

                var logId = request.GetPostInt("logId");

                var logInfo = logId > 0
                    ? LogDao.GetLogInfo(logId)
                    : new LogInfo
                {
                    FormId  = formInfo.Id,
                    AddDate = DateTime.Now
                };
                var fieldInfoList = FieldManager.GetFieldInfoList(formInfo.Id);
                foreach (var fieldInfo in fieldInfoList)
                {
                    if (request.IsPostExists(fieldInfo.Title))
                    {
                        var value = request.GetPostString(fieldInfo.Title);
                        if (fieldInfo.FieldType == InputType.Date.Value || fieldInfo.FieldType == InputType.DateTime.Value)
                        {
                            var dt = FormUtils.ToDateTime(request.GetPostString(fieldInfo.Title));
                            logInfo.Set(fieldInfo.Title, dt.ToLocalTime());
                        }

                        else
                        {
                            logInfo.Set(fieldInfo.Title, value);
                        }
                    }
                }

                if (logId == 0)
                {
                    LogDao.Insert(formInfo, logInfo);
                }
                else
                {
                    LogDao.Update(logInfo);
                }

                return(Ok(new{}));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Esempio n. 8
0
        /// <summary>
        /// 處理使用者角色異動
        /// </summary>
        /// <param name="roleId"></param>
        /// <param name="aplyNO"></param>
        /// <param name="conn"></param>
        /// <param name="transaction"></param>
        private void procUserRoleHis(CODE_USER cODEUSERO, string aplyNo, SqlConnection conn, SqlTransaction transaction)
        {
            CodeUserRoleHisDao       codeUserRoleHisDao = new CodeUserRoleHisDao();
            List <CodeUserRoleModel> cRoleList          = codeUserRoleHisDao.qryByAplyNo(aplyNo);

            if (cRoleList != null)
            {
                if (cRoleList.Count > 0)
                {
                    CodeUserRoleDao codeUserRoleDao = new CodeUserRoleDao();

                    foreach (CodeUserRoleModel d in cRoleList)
                    {
                        CODE_USER_ROLE dRole = new CODE_USER_ROLE();
                        Log            log   = new Log();

                        switch (d.execAction)
                        {
                        case "A":
                            dRole.USER_ID    = cODEUSERO.USER_ID;
                            dRole.ROLE_ID    = d.roleId;
                            dRole.CREATE_UID = cODEUSERO.LAST_UPDATE_UID;
                            dRole.CREATE_DT  = cODEUSERO.LAST_UPDATE_DT;


                            //新增資料
                            codeUserRoleDao.insert(dRole, conn, transaction);


                            //新增LOG
                            log.CFUNCTION = "使用者管理(角色授權)-新增";
                            log.CACTION   = "A";
                            log.CCONTENT  = codeUserRoleDao.logContent(dRole);
                            LogDao.Insert(log, Session["UserID"].ToString());

                            break;

                        case "D":
                            dRole = codeUserRoleDao.qryByKey(cODEUSERO.USER_ID, d.roleId);

                            //新增LOG

                            log.CFUNCTION = "使用者管理(角色授權)-刪除";
                            log.CACTION   = "D";
                            log.CCONTENT  = codeUserRoleDao.logContent(dRole);
                            LogDao.Insert(log, Session["UserID"].ToString());

                            //刪除資料
                            codeUserRoleDao.delete(dRole, conn, transaction);
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
        }
Esempio n. 9
0
        /// <summary>
        /// 處理角色功能異動
        /// </summary>
        /// <param name="roleId"></param>
        /// <param name="aplyNO"></param>
        /// <param name="conn"></param>
        /// <param name="transaction"></param>
        private void procRoleFuncHis(string roleId, string aplyNo, SqlConnection conn, SqlTransaction transaction)
        {
            CodeRoleFuncHisDao      codeRoleFuncHisDao = new CodeRoleFuncHisDao();
            List <RoleFuncHisModel> cRoleFuncList      = codeRoleFuncHisDao.qryByAplyNo(aplyNo);

            if (cRoleFuncList != null)
            {
                if (cRoleFuncList.Count > 0)
                {
                    CodeRoleFunctionDao roleFuncDao = new CodeRoleFunctionDao();

                    foreach (RoleFuncHisModel d in cRoleFuncList)
                    {
                        CODE_ROLE_FUNC dFunc = new CODE_ROLE_FUNC();
                        Log            log   = new Log();
                        switch (d.execAction)
                        {
                        case "A":
                            dFunc.ROLE_ID         = roleId;
                            dFunc.SYS_CD          = "TREASURY";
                            dFunc.FUNC_ID         = d.cFunctionID;
                            dFunc.LAST_UPDATE_UID = Session["UserID"].ToString();
                            dFunc.LAST_UPDATE_DT  = DateTime.Now;


                            //新增資料
                            roleFuncDao.Insert(dFunc, conn, transaction);


                            //新增LOG
                            log.CFUNCTION = "角色管理(功能授權)-新增";
                            log.CACTION   = "A";
                            log.CCONTENT  = roleFuncDao.logContent(dFunc);
                            LogDao.Insert(log, Session["UserID"].ToString());

                            break;

                        case "D":
                            dFunc = roleFuncDao.getFuncRoleByKey(roleId, d.cFunctionID);

                            //新增LOG
                            log.CFUNCTION = "角色管理(功能授權)-刪除";
                            log.CACTION   = "D";
                            log.CCONTENT  = roleFuncDao.logContent(dFunc);
                            LogDao.Insert(log, Session["UserID"].ToString());

                            //刪除資料
                            roleFuncDao.Delete(dFunc, conn, transaction);
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
        }
Esempio n. 10
0
        public JsonResult execInsert(String cParentFunctionID, String cFunctionName, int iSortBy, String cFlag, String vFunctionUrl, String vFunctionMemo)
        {
            CodeFuncDao codeFuncDao = new CodeFuncDao();

            if (codeFuncDao.chkFuncName("", cFunctionName) != null)
            {
                var jsonData = new { success = false, err = "功能名稱:”功能名稱”已存在,請重新輸入!" };
                return(Json(jsonData, JsonRequestBehavior.AllowGet));
            }

            CODE_FUNC func = new CODE_FUNC();

            func.SYS_CD         = "TREASURY";
            func.PARENT_FUNC_ID = cParentFunctionID;
            func.FUNC_NAME      = cFunctionName;
            func.FUNC_LEVEL     = 2;
            func.FUNC_MEMO      = vFunctionMemo;
            func.FUNC_URL       = vFunctionUrl;
            func.FUNC_ORDER     = iSortBy;
            func.IS_DISABLED    = cFlag;
            func.CREATE_UID     = Session["UserID"].ToString();

            string strConn = DbUtil.GetDBTreasuryConnStr();

            using (SqlConnection conn = new SqlConnection(strConn))
            {
                conn.Open();

                SqlTransaction transaction = conn.BeginTransaction("Transaction");

                try
                {
                    func = codeFuncDao.insert(func, conn, transaction);

                    Log log = new Log();
                    log.CFUNCTION = "功能維護作業-新增";
                    log.CACTION   = "A";
                    log.CCONTENT  = codeFuncDao.funcLogContent(func);
                    LogDao.Insert(log, Session["UserID"].ToString());

                    transaction.Commit();

                    var jsonData = new { success = true, id = func.FUNC_ID.Trim() };
                    return(Json(jsonData, JsonRequestBehavior.AllowGet));
                }
                catch (Exception e)
                {
                    transaction.Rollback();
                    logger.Error("[execInsert]其它錯誤:" + e.ToString());
                    var jsonData = new { success = false, err = "其它錯誤,請洽系統管理員!!" };
                    return(Json(jsonData, JsonRequestBehavior.AllowGet));
                }
            }
        }
Esempio n. 11
0
 public static void NewApplication(DataInfo dataInfo)
 {
     LogDao.Insert(new LogInfo
     {
         Id      = 0,
         SiteId  = dataInfo.SiteId,
         DataId  = dataInfo.Id,
         UserId  = 0,
         AddDate = DateTime.Now,
         Summary =
             $"{(dataInfo.IsOrganization ? dataInfo.OrgName : dataInfo.CivicName)}({(dataInfo.IsOrganization ? "公民" : "法人/其他组织")})提交申请"
     });
 }
Esempio n. 12
0
        /// <summary>
        /// 新增申請覆核
        /// </summary>
        /// <param name="data"></param>
        /// <param name="currentUserId">目前使用者ID</param>
        /// <returns></returns>
        public MSGReturnModel <List <SpecifiedTimeTreasurySearchDetailViewModel> > InsertApplyData(SpecifiedTimeTreasuryApplyViewModel data, string currentUserId, SpecifiedTimeTreasurySearchViewModel searchData)
        {
            var result = new MSGReturnModel <List <SpecifiedTimeTreasurySearchDetailViewModel> >();

            result.RETURN_FLAG = false;
            result.DESCRIPTION = Ref.MessageType.Apply_Audit_Fail.GetDescription();
            string logStr = string.Empty; //log

            using (TreasuryDBEntities db = new TreasuryDBEntities())
            {
                var _data = db.TREA_OPEN_REC
                            .Add(MappingTableForInsert(data, currentUserId));

                logStr += _data.modelToString(logStr);

                var validateMessage = db.GetValidationErrors().getValidateString();
                if (validateMessage.Any())
                {
                    result.DESCRIPTION = validateMessage;
                }
                else
                {
                    try
                    {
                        db.SaveChanges();
                        #region LOG
                        //新增LOG
                        Log log = new Log();
                        log.CFUNCTION = "申請覆核";
                        log.CACTION   = "C";
                        log.CCONTENT  = logStr;
                        LogDao.Insert(log, currentUserId);
                        #endregion
                        result.RETURN_FLAG = true;
                        result.DESCRIPTION = Ref.MessageType.Apply_Audit_Success.GetDescription();;
                    }
                    catch (DbUpdateException ex)
                    {
                        result.DESCRIPTION = ex.exceptionMessage();
                    }
                }

                if (result.RETURN_FLAG)
                {
                    result.Datas = GetSearchDetail(searchData);
                }
            }
            return(result);
        }
Esempio n. 13
0
        public static void Check(int siteId, int dataId, int userId)
        {
            var adminInfo = Context.AdminApi.GetAdminInfoByUserId(userId);
            var summary   = adminInfo.DisplayName == adminInfo.UserName
                ? $"{adminInfo.UserName}审核通过"
                : $"{adminInfo.DisplayName}({adminInfo.UserName})审核通过";

            LogDao.Insert(new LogInfo
            {
                Id      = 0,
                SiteId  = siteId,
                DataId  = dataId,
                UserId  = adminInfo.Id,
                AddDate = DateTime.Now,
                Summary = summary
            });
        }
Esempio n. 14
0
        public static void Translate(int siteId, int dataId, int userId, int departmentId)
        {
            var adminInfo = Context.AdminApi.GetAdminInfoByUserId(userId);
            var summary   = adminInfo.DisplayName == adminInfo.UserName
                ? $"{adminInfo.UserName}转办申请至{DepartmentManager.GetDepartmentName(siteId, departmentId)}"
                : $"{adminInfo.DisplayName}({adminInfo.UserName})转办申请至{DepartmentManager.GetDepartmentName(siteId, departmentId)}";

            LogDao.Insert(new LogInfo
            {
                Id      = 0,
                SiteId  = siteId,
                DataId  = dataId,
                UserId  = adminInfo.Id,
                AddDate = DateTime.Now,
                Summary = summary
            });
        }
Esempio n. 15
0
        public static void Redo(int siteId, int dataId, int userId, string instruction)
        {
            var adminInfo = Context.AdminApi.GetAdminInfoByUserId(userId);
            var summary   = adminInfo.DisplayName == adminInfo.UserName
                ? $"{adminInfo.UserName}要求返工:{instruction}"
                : $"{adminInfo.DisplayName}({adminInfo.UserName})要求返工:{instruction}";

            LogDao.Insert(new LogInfo
            {
                Id      = 0,
                SiteId  = siteId,
                DataId  = dataId,
                UserId  = adminInfo.Id,
                AddDate = DateTime.Now,
                Summary = summary
            });
        }
Esempio n. 16
0
        public static void Accept(int siteId, int dataId, int userId, int departmentId)
        {
            var adminInfo = Context.AdminApi.GetAdminInfoByUserId(userId);
            var summary   = adminInfo.DisplayName == adminInfo.UserName
                ? $"{adminInfo.UserName}受理申请"
                : $"{adminInfo.DisplayName}({adminInfo.UserName})受理申请";

            if (departmentId > 0)
            {
                summary += $",转办至 {DepartmentManager.GetDepartmentName(siteId, departmentId)}";
            }
            LogDao.Insert(new LogInfo
            {
                Id      = 0,
                SiteId  = siteId,
                DataId  = dataId,
                UserId  = adminInfo.Id,
                AddDate = DateTime.Now,
                Summary = summary
            });
        }
Esempio n. 17
0
        public ActionResult qryEquip(string cRoleID)
        {
            CodeRoleTreaItemDao codeRoleTreaItemDao = new CodeRoleTreaItemDao();

            try
            {
                List <CodeRoleEquipModel> roleEquipList = codeRoleTreaItemDao.qryForRoleMgr(cRoleID);

                Log log = new Log();
                log.CFUNCTION = "角色維護-金庫設備查詢";
                log.CACTION   = "Q";
                log.CCONTENT  = "cRoleID:" + cRoleID + "|totCnt:" + roleEquipList.Count;
                LogDao.Insert(log, Session["UserID"].ToString());

                return(Json(new { success = true, roleEquipList = roleEquipList }));
            }
            catch (Exception e)
            {
                logger.Error("[qryEquip]:" + e.ToString());
                return(Json(new { success = false, err = "其它錯誤,請洽系統管理員!!" }));
            }
        }
Esempio n. 18
0
        /// <summary>
        /// 覆核畫面駁回
        /// </summary>
        /// <param name="searchData">金庫物品覆核畫面查詢ViewModel</param>
        /// <param name="viewModels">覆核表單查詢顯示區塊ViewModel</param>
        /// <param name="apprDesc">駁回意見</param>
        /// <returns></returns>
        public MSGReturnModel <List <TreasuryAccessApprSearchDetailViewModel> > Reject(TreasuryAccessApprSearchViewModel searchData, List <TreasuryAccessApprSearchDetailViewModel> viewModels, string apprDesc)
        {
            var result = new MSGReturnModel <List <TreasuryAccessApprSearchDetailViewModel> >();

            result.RETURN_FLAG = false;
            result.DESCRIPTION = Ref.MessageType.not_Find_Any.GetDescription();

            DateTime dt     = DateTime.Now;
            string   logStr = string.Empty;

            using (TreasuryDBEntities db = new TreasuryDBEntities())
            {
                var aplynos = new List <string>();
                foreach (var item in viewModels.Where(x => x.vCheckFlag))
                {
                    var _TREA_APLY_REC = db.TREA_APLY_REC
                                         .FirstOrDefault(x => x.APLY_NO == item.vAPLY_NO);
                    if (_TREA_APLY_REC == null) //找不到該筆單號
                    {
                        result.DESCRIPTION = Ref.MessageType.not_Find_Any.GetDescription(null, $"單號:{item.vAPLY_NO}");
                        return(result);
                    }
                    if (_TREA_APLY_REC.LAST_UPDATE_DT > item.vLast_Update_Time) //資料已經被更新
                    {
                        result.DESCRIPTION = Ref.MessageType.already_Change.GetDescription(null, $"單號:{item.vAPLY_NO}");
                        return(result);
                    }
                    aplynos.Add(item.vAPLY_NO);

                    //填寫單位 == 保管科單位 狀態 => 申請單位覆核駁回
                    var aplyStatus = Ref.AccessProjectFormStatus.A02.ToString(); // 狀態 => 申請單位覆核駁回

                    if (Properties.Settings.Default["CustodianFlag"]?.ToString() == _TREA_APLY_REC.APLY_UNIT)
                    //保管科=申請單位 狀態 => 保管科覆核駁回
                    {
                        aplyStatus = Ref.AccessProjectFormStatus.A06.ToString();
                    }

                    _TREA_APLY_REC.LAST_UPDATE_DT = dt;
                    _TREA_APLY_REC.APLY_STATUS    = aplyStatus;
                    //_TREA_APLY_REC.LAST_UPDATE_UID = searchData.vCreateUid;
                    // 保管科單位
                    if (aplyStatus == Ref.AccessProjectFormStatus.A06.ToString())
                    {
                        _TREA_APLY_REC.CUSTODY_APPR_DESC = apprDesc;
                        _TREA_APLY_REC.CUSTODY_APPR_DT   = dt;
                        _TREA_APLY_REC.CUSTODY_APPR_UID  = searchData.vCreateUid;
                    }
                    // 申請單位
                    else
                    {
                        _TREA_APLY_REC.APLY_APPR_DESC = apprDesc;
                        _TREA_APLY_REC.APLY_APPR_DT   = dt;
                        _TREA_APLY_REC.APLY_APPR_UID  = searchData.vCreateUid;
                    }
                    logStr += _TREA_APLY_REC.modelToString(logStr);

                    #region 申請單歷程檔
                    var ARH = new APLY_REC_HIS()
                    {
                        APLY_NO     = _TREA_APLY_REC.APLY_NO,
                        APLY_STATUS = aplyStatus,
                        PROC_UID    = searchData.vCreateUid,
                        PROC_DT     = dt
                    };
                    logStr += ARH.modelToString(logStr);

                    db.APLY_REC_HIS.Add(ARH);

                    #endregion
                }
                var validateMessage = db.GetValidationErrors().getValidateString();
                if (validateMessage.Any())
                {
                    result.DESCRIPTION = validateMessage;
                }
                else
                {
                    try
                    {
                        db.SaveChanges();

                        #region LOG
                        //新增LOG
                        Log log = new Log();
                        log.CFUNCTION = "駁回-金庫物品存取覆核作業";
                        log.CACTION   = "U";
                        log.CCONTENT  = logStr;
                        LogDao.Insert(log, searchData.vCreateUid);
                        #endregion

                        result.RETURN_FLAG = true;
                        result.DESCRIPTION = $"申請單號 : {string.Join(",", aplynos)} 已駁回!";
                        result.Datas       = GetApprSearchDetail(searchData);
                    }
                    catch (DbUpdateException ex)
                    {
                        result.DESCRIPTION = ex.exceptionMessage();
                    }
                }
            }

            return(result);
        }
Esempio n. 19
0
        /// <summary>
        /// 作廢 (保留資料)
        /// </summary>
        /// <param name="searchData">金庫物品存取主畫面查詢ViewModel</param>
        /// <param name="data">申請表單查詢顯示區塊ViewModel</param>
        /// <returns></returns>
        public MSGReturnModel <List <TreasuryAccessSearchDetailViewModel> > Invalidate(TreasuryAccessSearchViewModel searchData, TreasuryAccessSearchDetailViewModel data)
        {
            var result = new MSGReturnModel <List <TreasuryAccessSearchDetailViewModel> >();

            result.RETURN_FLAG = false;
            result.DESCRIPTION = Ref.MessageType.already_Change.GetDescription();
            DateTime dt     = DateTime.Now;
            string   logStr = string.Empty;
            //取得流水號
            var _status = Ref.AccessProjectFormStatus.E02.ToString();

            using (TreasuryDBEntities db = new TreasuryDBEntities())
            {
                var _TREA_APLY_REC = db.TREA_APLY_REC.FirstOrDefault(x => x.APLY_NO == data.vAPLY_NO);
                if (_TREA_APLY_REC != null)
                {
                    if (_TREA_APLY_REC.LAST_UPDATE_DT > data.vLast_Update_Time)
                    {
                        return(result);
                    }
                    _TREA_APLY_REC.LAST_UPDATE_UID = AccountController.CurrentUserId;
                    _TREA_APLY_REC.LAST_UPDATE_DT  = dt;
                    _TREA_APLY_REC.APLY_STATUS     = _status;
                    logStr += _TREA_APLY_REC.modelToString(logStr);

                    #region 作廢
                    var sampleFactory = new SampleFactory();
                    var getAgenct     = sampleFactory.GetAgenct(EnumUtil.GetValues <Ref.TreaItemType>().First(x => x.ToString() == _TREA_APLY_REC.ITEM_ID));
                    if (getAgenct != null)
                    {
                        var _recover = getAgenct.ObSolete(db, _TREA_APLY_REC.APLY_NO, _TREA_APLY_REC.ACCESS_TYPE, logStr, dt);
                        if (!_recover.Item1) //失敗
                        {
                            return(result);
                        }
                        logStr += _recover.Item2;
                    }
                    else
                    {
                        return(result);
                    }
                    #endregion

                    #region 申請單歷程檔
                    //「取消申請」:新增「E02」申請人刪除的狀態資料。
                    var ARH = new APLY_REC_HIS()
                    {
                        APLY_NO     = _TREA_APLY_REC.APLY_NO,
                        APLY_STATUS = _status,
                        PROC_UID    = searchData.vCreateUid,
                        PROC_DT     = dt
                    };
                    logStr += ARH.modelToString(logStr);

                    db.APLY_REC_HIS.Add(ARH);

                    #endregion

                    var validateMessage = db.GetValidationErrors().getValidateString();
                    if (validateMessage.Any())
                    {
                        result.DESCRIPTION = validateMessage;
                    }
                    else
                    {
                        try
                        {
                            db.SaveChanges();

                            #region LOG
                            //新增LOG
                            Log log = new Log();
                            log.CFUNCTION = "作廢-金庫物品存取申請作業";
                            log.CACTION   = "U";
                            log.CCONTENT  = logStr;
                            LogDao.Insert(log, searchData.vCreateUid);
                            #endregion

                            result.RETURN_FLAG = true;
                            result.DESCRIPTION = $@"單號{data.vAPLY_NO} 已作廢!";
                        }
                        catch (DbUpdateException ex)
                        {
                            result.DESCRIPTION = ex.exceptionMessage();
                        }
                    }
                }
                if (result.RETURN_FLAG)
                {
                    result.Datas = GetSearchDetail(searchData);
                }
            }
            return(result);
        }
Esempio n. 20
0
        /// <summary>
        /// 刪除申請 (刪除資料)
        /// </summary>
        /// <param name="searchData">金庫物品存取主畫面查詢ViewModel</param>
        /// <param name="data">申請表單查詢顯示區塊ViewModel</param>
        /// <returns></returns>
        public MSGReturnModel <List <TreasuryAccessSearchDetailViewModel> > Cancel(TreasuryAccessSearchViewModel searchData, TreasuryAccessSearchDetailViewModel data)
        {
            var result = new MSGReturnModel <List <TreasuryAccessSearchDetailViewModel> >();

            result.RETURN_FLAG = false;
            result.DESCRIPTION = Ref.MessageType.already_Change.GetDescription();
            DateTime dt     = DateTime.Now;
            string   logStr = string.Empty;
            //取得流水號
            SysSeqDao sysSeqDao = new SysSeqDao();
            String    qPreCode  = DateUtil.getCurChtDateTime().Split(' ')[0];

            using (TreasuryDBEntities db = new TreasuryDBEntities())
            {
                var _TREA_APLY_REC = db.TREA_APLY_REC.FirstOrDefault(x => x.APLY_NO == data.vAPLY_NO);
                if (_TREA_APLY_REC != null)
                {
                    if (_TREA_APLY_REC.LAST_UPDATE_DT > data.vLast_Update_Time)
                    {
                        return(result);
                    }
                    logStr += _TREA_APLY_REC.modelToString();


                    #region 刪除申請
                    var sampleFactory = new SampleFactory();
                    var getAgenct     = sampleFactory.GetAgenct(EnumUtil.GetValues <Ref.TreaItemType>().First(x => x.ToString() == _TREA_APLY_REC.ITEM_ID));
                    if (getAgenct != null)
                    {
                        var _recover = getAgenct.CancelApply(db, _TREA_APLY_REC.APLY_NO, _TREA_APLY_REC.ACCESS_TYPE, logStr, dt);
                        if (!_recover.Item1) //失敗
                        {
                            return(result);
                        }
                        logStr = _recover.Item2;
                    }
                    else
                    {
                        return(result);
                    }
                    #endregion

                    #region 刪除 申請單歷程檔
                    db.APLY_REC_HIS.RemoveRange(db.APLY_REC_HIS.Where(x => x.APLY_NO == _TREA_APLY_REC.APLY_NO));
                    #endregion

                    #region 刪除 申請單紀錄檔
                    db.TREA_APLY_REC.Remove(_TREA_APLY_REC);
                    #endregion

                    var validateMessage = db.GetValidationErrors().getValidateString();
                    if (validateMessage.Any())
                    {
                        result.DESCRIPTION = validateMessage;
                    }
                    else
                    {
                        try
                        {
                            db.SaveChanges();

                            #region LOG
                            //新增LOG
                            Log log = new Log();
                            log.CFUNCTION = "刪除申請-金庫物品存取申請作業";
                            log.CACTION   = "D";
                            log.CCONTENT  = logStr;
                            LogDao.Insert(log, searchData.vCreateUid);
                            #endregion

                            result.RETURN_FLAG = true;
                            result.DESCRIPTION = $@"單號{data.vAPLY_NO} 已刪除!";
                        }
                        catch (DbUpdateException ex)
                        {
                            result.DESCRIPTION = ex.exceptionMessage();
                        }
                    }
                }
                if (result.RETURN_FLAG)
                {
                    result.Datas = GetSearchDetail(searchData);
                }
            }
            return(result);
        }
Esempio n. 21
0
        /// <summary>
        /// 駁回
        /// </summary>
        /// <param name="RegisterNo"></param>
        /// <param name="RejectReason"></param>
        /// <param name="ViewModel"></param>
        /// <param name="SearchData"></param>
        /// <returns></returns>
        public MSGReturnModel <List <SpecifiedTimeTreasuryApprSearchDetailViewModel> > RejectData(List <string> RegisterNo, string RejectReason, List <SpecifiedTimeTreasuryApprSearchDetailViewModel> ViewModel, SpecifiedTimeTreasuryApprSearchViewModel SearchData)
        {
            var result = new MSGReturnModel <List <SpecifiedTimeTreasuryApprSearchDetailViewModel> >();

            result.RETURN_FLAG = false;
            result.DESCRIPTION = Ref.MessageType.not_Find_Any.GetDescription();

            DateTime dt      = DateTime.Now;
            string   logStrC = string.Empty; //combin Log

            using (TreasuryDBEntities db = new TreasuryDBEntities())
            {
                foreach (var item in ViewModel.Where(x => RegisterNo.Contains(x.vTREA_REGISTER_ID)))
                {
                    var _TREA_OPEN_REC = db.TREA_OPEN_REC.FirstOrDefault(x => x.TREA_REGISTER_ID == item.vTREA_REGISTER_ID);
                    if (_TREA_OPEN_REC == null) //找不到該單號
                    {
                        result.DESCRIPTION = Ref.MessageType.not_Find_Any.GetDescription(null, $"單號:{item.vTREA_REGISTER_ID}");
                        return(result);
                    }
                    if (_TREA_OPEN_REC.LAST_UPDATE_DT > item.vLAST_UPDATE_DT) //資料已被更新
                    {
                        result.DESCRIPTION = Ref.MessageType.already_Change.GetDescription(null, $"單號:{item.vTREA_REGISTER_ID}");
                        return(result);
                    }
                    var    applyStatus = ((int)Ref.ApplyStatus._3).ToString(); // 狀態: 退回
                    string logStrB     = string.Empty;                         //修改前 Log
                    string logStrA     = string.Empty;                         //修改後 Log

                    logStrB += _TREA_OPEN_REC.modelToString(logStrB);

                    _TREA_OPEN_REC.APPR_STATUS     = applyStatus;
                    _TREA_OPEN_REC.LAST_UPDATE_UID = SearchData.vCreateUid;
                    _TREA_OPEN_REC.LAST_UPDATE_DT  = dt;
                    _TREA_OPEN_REC.APPR_DESC       = RejectReason;
                    _TREA_OPEN_REC.APPR_UID        = SearchData.vCreateUid;
                    _TREA_OPEN_REC.APPR_DT         = dt;

                    logStrA += _TREA_OPEN_REC.modelToString(logStrA);
                    logStrC += string.Format("修改前{0}^^修改後{1}", logStrB, logStrA);
                }
                //檢核欄位
                var validateMessage = db.GetValidationErrors().getValidateString();
                if (validateMessage.Any())
                {
                    result.DESCRIPTION = validateMessage;
                }
                else
                {
                    try
                    {
                        db.SaveChanges();

                        #region LOG
                        //新增LOG
                        Log log = new Log();
                        log.CFUNCTION = "駁回-指定開庫覆核作業";
                        log.CACTION   = "U";
                        log.CCONTENT  = logStrC;
                        LogDao.Insert(log, SearchData.vCreateUid);
                        #endregion

                        result.RETURN_FLAG = true;
                        result.DESCRIPTION = $"申請單號 : {string.Join(",", RegisterNo)} 已駁回";
                        result.Datas       = GetApprSearchData(SearchData);
                    }
                    catch (DbUpdateException ex)
                    {
                        result.DESCRIPTION = ex.exceptionMessage();
                    }
                }
            }
            return(result);
        }
Esempio n. 22
0
        /// <summary>
        /// 覆核
        /// </summary>
        /// <param name="RegisterNo"></param>
        /// <param name="ViewModel"></param>
        /// <param name="SearchData"></param>
        /// <returns></returns>
        public MSGReturnModel <List <SpecifiedTimeTreasuryApprSearchDetailViewModel> > ApproveData(List <string> RegisterNo, List <SpecifiedTimeTreasuryApprSearchDetailViewModel> ViewModel, SpecifiedTimeTreasuryApprSearchViewModel SearchData)
        {
            var result = new MSGReturnModel <List <SpecifiedTimeTreasuryApprSearchDetailViewModel> >();

            result.RETURN_FLAG = false;
            result.DESCRIPTION = Ref.MessageType.not_Find_Any.GetDescription();

            if (!ViewModel.Any())
            {
                return(result);
            }

            DateTime dt      = DateTime.Now;
            string   logStrC = string.Empty; //combin Log

            List <TREA_OPEN_REC> TORs = new List <TREA_OPEN_REC>();

            using (TreasuryDBEntities db = new TreasuryDBEntities())
            {
                var _TREA_ITEM = db.TREA_ITEM.Where(x => x.ITEM_OP_TYPE == "3").Select(x => x.ITEM_ID).ToList();

                foreach (var item in ViewModel.Where(x => RegisterNo.Contains(x.vTREA_REGISTER_ID)))
                {
                    var _TREA_OPEN_REC = db.TREA_OPEN_REC.FirstOrDefault(x => x.TREA_REGISTER_ID == item.vTREA_REGISTER_ID);
                    if (_TREA_OPEN_REC == null) //找不到該單號
                    {
                        result.DESCRIPTION = Ref.MessageType.not_Find_Any.GetDescription(null, $"單號:{item.vTREA_REGISTER_ID}");
                        return(result);
                    }
                    if (_TREA_OPEN_REC.LAST_UPDATE_DT > item.vLAST_UPDATE_DT) //資料已備更新
                    {
                        result.DESCRIPTION = Ref.MessageType.already_Change.GetDescription(null, $"單號:{item.vTREA_REGISTER_ID}");
                        return(result);
                    }
                    TORs.Add(_TREA_OPEN_REC);
                    var    applyStatus = ((int)Ref.ApplyStatus._2).ToString(); // 狀態: 覆核完成
                    string logStrB     = string.Empty;                         //修改前 Log
                    string logStrA     = string.Empty;                         //修改後 Log

                    logStrB += _TREA_OPEN_REC.modelToString(logStrB);

                    _TREA_OPEN_REC.APPR_STATUS     = applyStatus;
                    _TREA_OPEN_REC.LAST_UPDATE_UID = SearchData.vCreateUid;
                    _TREA_OPEN_REC.LAST_UPDATE_DT  = dt;
                    _TREA_OPEN_REC.APPR_UID        = SearchData.vCreateUid;
                    _TREA_OPEN_REC.APPR_DT         = dt;

                    logStrA += _TREA_OPEN_REC.modelToString(logStrA);

                    //#region 申請單紀錄檔
                    ////取得流水號
                    //List<string> workList = _TREA_OPEN_REC.OPEN_TREA_REASON.Split(';').ToList();
                    //foreach (var workItem in workList)
                    //{
                    //    if (!_TREA_ITEM.Contains(workItem))
                    //    {
                    //        SysSeqDao sysSeqDao = new SysSeqDao();
                    //        string qPreCode = DateUtil.getCurChtDateTime().Split(' ')[0];
                    //        var cId = sysSeqDao.qrySeqNo("G6", qPreCode).ToString().PadLeft(3, '0');

                    //        var _TREA_APLY_REC = db.TREA_APLY_REC
                    //            .Add(new TREA_APLY_REC()
                    //            {
                    //                APLY_NO = $@"G6{qPreCode}{cId}", ////申請單號 G6+系統日期YYYMMDD(民國年)+3碼流水號
                    //                APLY_FROM = "S",
                    //                TREA_REGISTER_ID = item.vTREA_REGISTER_ID,
                    //                ITEM_ID = workItem,
                    //                APLY_STATUS = "C01",
                    //                EXPECTED_ACCESS_DATE = _TREA_OPEN_REC.OPEN_TREA_DATE,
                    //                APLY_UNIT = _TREA_OPEN_REC.CREATE_UNIT,
                    //                APLY_UID = _TREA_OPEN_REC.CREATE_UID,
                    //                APLY_DT = _TREA_OPEN_REC.CREATE_DT,
                    //                APLY_APPR_UID = SearchData.vCreateUid,
                    //                APLY_APPR_DT = dt,
                    //                CREATE_UID = SearchData.vCreateUid,
                    //                CREATE_DT = dt,
                    //                LAST_UPDATE_UID = SearchData.vCreateUid,
                    //                LAST_UPDATE_DT = dt,
                    //                CREATE_UNIT = SearchData.vCreateUnit
                    //            });
                    //        logStrA += _TREA_APLY_REC.modelToString(logStrA);
                    //    }
                    //}
                    //#endregion

                    #region 申請單暫存檔
                    //取得流水號
                    List <string> workList = _TREA_OPEN_REC.OPEN_TREA_REASON.Split(';').ToList();
                    if (workList.Count != 0)
                    {
                        var data = (from n in db.TREA_APLY_TEMP select n);
                        db.TREA_APLY_TEMP.RemoveRange(data);
                    }
                    foreach (var workItem in workList)
                    {
                        if (!_TREA_ITEM.Contains(workItem))
                        {
                            var _TREA_APLY_TEMP = db.TREA_APLY_TEMP
                                                  .Add(new TREA_APLY_TEMP()
                            {
                                ITEM_ID = workItem,
                            });
                        }
                    }
                    #endregion

                    logStrC += string.Format("修改前{0}^^修改後{1}", logStrB, logStrA);
                }
                var validateMessage = db.GetValidationErrors().getValidateString();
                if (validateMessage.Any())
                {
                    result.DESCRIPTION = validateMessage;
                }
                else
                {
                    try
                    {
                        db.SaveChanges();

                        #region 寄信
                        //List<Tuple<string, string>> _mailTo = new List<Tuple<string, string>>() { new Tuple<string, string>("*****@*****.**", "測試帳號-glsisys") };
                        List <Tuple <string, string> > _mailTo = new List <Tuple <string, string> >();
                        List <Tuple <string, string> > _ccTo   = new List <Tuple <string, string> >();
                        var emps            = GetEmps();
                        var _MAIL_CONTENT   = db.MAIL_CONTENT.AsNoTracking().FirstOrDefault(x => x.MAIL_CONTENT_ID == "01" && x.IS_DISABLED == "N");
                        var _MAIL_RECEIVE   = db.MAIL_RECEIVE.AsNoTracking();
                        var _CODE_ROLE_FUNC = db.CODE_ROLE_FUNC.AsNoTracking();
                        var _CODE_USER_ROLE = db.CODE_USER_ROLE.AsEnumerable();
                        var _CODE_USER      = db.CODE_USER.AsNoTracking();
                        foreach (var TOR in TORs)
                        {
                            if (_MAIL_CONTENT != null)
                            {
                                string _content = _MAIL_CONTENT.MAIL_CONTENT1;
                                _content = _content.Replace("@_TREA_OPEN_TIME_", TOR.OPEN_TREA_TIME);
                                _content = _content.Replace("@_EXEC_TIME_E_", TOR.EXEC_TIME_E);
                                StringBuilder sb = new StringBuilder();
                                sb.AppendLine(_content);
                                //                            sb.AppendLine(
                                //        $@"您好,
                                //通知今日金庫開關庫時間為:{TOR.OPEN_TREA_TIME},請準時至金庫門口集合。
                                //為配合金庫大門之啟閉,請有權人在:{TOR.EXEC_TIME_E} 前進入「金庫進出管理系統」完成入庫確認作業,謝謝。
                                //");
                                var           _FuncId     = _MAIL_RECEIVE.Where(x => x.MAIL_CONTENT_ID == _MAIL_CONTENT.MAIL_CONTENT_ID).Select(x => x.FUNC_ID);
                                var           _RoleId     = _CODE_ROLE_FUNC.Where(x => _FuncId.Contains(x.FUNC_ID)).Select(x => x.ROLE_ID);
                                var           _UserId     = _CODE_USER_ROLE.Where(x => _RoleId.Contains(x.ROLE_ID)).Select(x => x.USER_ID).Distinct();
                                List <string> _userIdList = new List <string>();

                                _userIdList.AddRange(_CODE_USER.Where(x => _UserId.Contains(x.USER_ID) && x.IS_MAIL == "Y").Select(x => x.USER_ID).ToList());
                                if (_userIdList.Any())
                                {
                                    //人名 EMAIl
                                    var _EMP = emps.Where(x => _userIdList.Contains(x.USR_ID)).ToList();
                                    if (_EMP.Any())
                                    {
                                        _EMP.ForEach(x => {
                                            _mailTo.Add(new Tuple <string, string>(x.EMAIL, x.EMP_NAME));
                                        });
                                    }
                                }

                                try
                                {
                                    var sms = new SendMail.SendMailSelf();
                                    sms.smtpPort    = 25;
                                    sms.smtpServer  = Properties.Settings.Default["smtpServer"]?.ToString();
                                    sms.mailAccount = Properties.Settings.Default["mailAccount"]?.ToString();
                                    sms.mailPwd     = Properties.Settings.Default["mailPwd"]?.ToString();
                                    sms.Mail_Send(
                                        new Tuple <string, string>(sms.mailAccount, "金庫管理系統"),
                                        _mailTo,
                                        _ccTo,
                                        _MAIL_CONTENT?.MAIL_SUBJECT ?? "入庫人員確認作業通知",
                                        sb.ToString()
                                        );
                                }
                                catch (Exception ex)
                                {
                                    result.DESCRIPTION = $"Email 發送失敗請人工通知。";
                                }
                            }
                        }
                        #endregion

                        #region LOG
                        //新增LOG
                        Log log = new Log();
                        log.CFUNCTION = "覆核-指定開庫覆核作業";
                        log.CACTION   = "U";
                        log.CCONTENT  = logStrC;
                        LogDao.Insert(log, SearchData.vCreateUid);
                        #endregion

                        result.RETURN_FLAG = true;
                        result.DESCRIPTION = $"申請單號 : {string.Join(",", RegisterNo)} 覆核成功";
                        result.Datas       = GetApprSearchData(SearchData);
                    }
                    catch (Exception ex)
                    {
                        result.DESCRIPTION = ex.exceptionMessage();
                    }
                }
            }
            return(result);
        }
Esempio n. 23
0
        public MSGReturnModel <List <SpecifiedTimeTreasurySearchDetailViewModel> > CancelApplyData(SpecifiedTimeTreasuryCancelViewModel data, string currentUserId, SpecifiedTimeTreasurySearchViewModel searchData)
        {
            var result = new MSGReturnModel <List <SpecifiedTimeTreasurySearchDetailViewModel> >();

            result.RETURN_FLAG = false;
            result.DESCRIPTION = Ref.MessageType.update_Fail.GetDescription();
            string logStr = string.Empty; //log

            //bool 登入者與申請者為同一人
            if (data.vCREATE_UID == currentUserId)
            {
                if (data.vAPLY_STATUS_ID == ((int)Ref.ApplyStatus._1).ToString() || data.vAPLY_STATUS_ID == ((int)Ref.ApplyStatus._3).ToString())
                {
                    using (TreasuryDBEntities db = new TreasuryDBEntities())
                    {
                        var _data = db.TREA_OPEN_REC.FirstOrDefault(x => x.TREA_REGISTER_ID == data.vTREA_REGISTER_ID);
                        //統一取系統時間
                        DateTime dt = DateTime.Now;
                        if (_data != null)
                        {
                            if (_data.APPR_UID == null)
                            {
                                db.TREA_OPEN_REC.Remove(_data);
                            }
                            else
                            {
                                _data.APPR_STATUS     = "4";
                                _data.LAST_UPDATE_UID = currentUserId;
                                _data.LAST_UPDATE_DT  = dt;
                            }

                            logStr += _data.modelToString(logStr);

                            var validateMessage = db.GetValidationErrors().getValidateString();
                            if (validateMessage.Any())
                            {
                                result.DESCRIPTION = validateMessage;
                            }
                            else
                            {
                                try
                                {
                                    db.SaveChanges();

                                    if (data.vAPPR_UID == null)
                                    {
                                        result.DESCRIPTION = Ref.MessageType.delete_Success.GetDescription();
                                        #region LOG
                                        //新增LOG
                                        Log log = new Log();
                                        log.CFUNCTION = "取消覆核(作廢)";
                                        log.CACTION   = "D";
                                        log.CCONTENT  = logStr;
                                        LogDao.Insert(log, currentUserId);
                                        #endregion
                                    }
                                    else
                                    {
                                        result.DESCRIPTION = Ref.MessageType.update_Success.GetDescription();;
                                        #region LOG
                                        //新增LOG
                                        Log log = new Log();
                                        log.CFUNCTION = "取消覆核";
                                        log.CACTION   = "U";
                                        log.CCONTENT  = logStr;
                                        LogDao.Insert(log, currentUserId);
                                        #endregion
                                    }

                                    result.RETURN_FLAG = true;
                                }
                                catch (DbUpdateException ex)
                                {
                                    result.DESCRIPTION = ex.exceptionMessage();
                                }
                            }
                        }
                        else
                        {
                            result.DESCRIPTION = Ref.MessageType.not_Find_Audit_Data.GetDescription();
                        }
                    }
                }
                else
                {
                    result.DESCRIPTION = Ref.MessageType.parameter_Error.GetDescription();
                }
            }
            if (result.RETURN_FLAG)
            {
                result.Datas = GetSearchDetail(searchData);
            }
            return(result);
        }
Esempio n. 24
0
        /// <summary>
        /// 修改申請覆核
        /// </summary>
        /// <param name="data"></param>
        /// <param name="currntUserId">目前使用者ID</param>
        /// <param name="searchData"></param>
        /// <returns></returns>
        public MSGReturnModel <List <SpecifiedTimeTreasurySearchDetailViewModel> > UpdateApplyData(SpecifiedTimeTreasuryUpdateViewModel data, string currentUserId, SpecifiedTimeTreasurySearchViewModel searchData)
        {
            var result = new MSGReturnModel <List <SpecifiedTimeTreasurySearchDetailViewModel> >();

            result.RETURN_FLAG = false;
            result.DESCRIPTION = Ref.MessageType.update_Fail.GetDescription();
            string logStr = string.Empty; //log

            //bool 登入者與申請者為同一人
            if (data.vCREATE_UID == currentUserId)
            {
                using (TreasuryDBEntities db = new TreasuryDBEntities())
                {
                    var _data = db.TREA_OPEN_REC.FirstOrDefault(x => x.TREA_REGISTER_ID == data.vTREA_REGISTER_ID);
                    //統一取系統時間
                    DateTime dt = DateTime.Now;
                    if (_data != null)
                    {
                        _data.EXEC_TIME_B      = data.vEXEC_TIME_B;
                        _data.EXEC_TIME_E      = data.vEXEC_TIME_E;
                        _data.OPEN_TREA_TIME   = data.vOPEN_TREA_TIME;
                        _data.MEMO             = data.vMEMO;
                        _data.OPEN_TREA_REASON = string.Join(";", data.vOPEN_TREA_REASON_ID.ToArray());
                        _data.APPR_STATUS      = "1";
                        _data.LAST_UPDATE_UID  = currentUserId;
                        _data.LAST_UPDATE_DT   = dt;

                        logStr += _data.modelToString(logStr);

                        var validateMessage = db.GetValidationErrors().getValidateString();
                        if (validateMessage.Any())
                        {
                            result.DESCRIPTION = validateMessage;
                        }
                        else
                        {
                            try
                            {
                                db.SaveChanges();

                                #region LOG
                                //新增LOG
                                Log log = new Log();
                                log.CFUNCTION = "修改申請";
                                log.CACTION   = "U";
                                log.CCONTENT  = logStr;
                                LogDao.Insert(log, currentUserId);
                                #endregion

                                result.RETURN_FLAG = true;
                                result.DESCRIPTION = Ref.MessageType.update_Success.GetDescription();
                            }
                            catch (DbUpdateException ex)
                            {
                                result.DESCRIPTION = ex.exceptionMessage();
                            }
                        }
                    }
                    else
                    {
                        result.DESCRIPTION = Ref.MessageType.not_Find_Audit_Data.GetDescription();
                    }
                }
            }
            if (result.RETURN_FLAG)
            {
                result.Datas = GetSearchDetail(searchData);
            }
            return(result);
        }
Esempio n. 25
0
        /// <summary>
        /// 金庫進出管理作業-申請覆核
        /// </summary>
        /// <param name="saveData">申請覆核的資料</param>
        /// <param name="searchModel">查詢ViwModel</param>
        /// <returns></returns>
        public MSGReturnModel <IEnumerable <ITinItem> > TinApplyAudit(IEnumerable <ITinItem> saveData, ITinItem searchModel)
        {
            var searchData = (TreasuryMailTimeSearchViewModel)searchModel;
            var result     = new MSGReturnModel <IEnumerable <ITinItem> >();

            result.RETURN_FLAG = false;
            DateTime dt = DateTime.Now;

            try
            {
                if (saveData != null)
                {
                    var datas = (List <TreasuryMailTimeViewModel>)saveData;
                    if (datas.Any(x => x.updateFlag))
                    {
                        using (TreasuryDBEntities db = new TreasuryDBEntities())
                        {
                            string logStr = string.Empty; //log

                            //取得流水號
                            SysSeqDao sysSeqDao = new SysSeqDao();
                            String    qPreCode  = DateUtil.getCurChtDateTime().Split(' ')[0];
                            string    _Aply_No  = $@"G3{qPreCode}{sysSeqDao.qrySeqNo("G3", qPreCode).ToString().PadLeft(3, '0')}"; //申請單號 G3+系統日期YYYMMDD(民國年)+3碼流水號

                            foreach (var data in datas.Where(x => x.updateFlag))
                            {
                                var _MT = db.MAIL_TIME.First(x => x.MAIL_TIME_ID == data.vMAIL_TIME_ID);

                                if (_MT.DATA_STATUS != "1")
                                {
                                    result.DESCRIPTION = Ref.MessageType.already_Change.GetDescription();
                                    return(result);
                                }
                                _MT.DATA_STATUS     = "2"; //凍結中
                                _MT.LAST_UPDATE_UID = searchData.userId;
                                _MT.LAST_UPDATE_DT  = dt;
                                _MT.FREEZE_DT       = dt;
                                _MT.FREEZE_UID      = searchData.userId;

                                var MTH = new MAIL_TIME_HIS()
                                {
                                    APLY_NO           = _Aply_No,
                                    MAIL_TIME_ID      = _MT.MAIL_TIME_ID,
                                    EXEC_ACTION       = "U", //只有修改
                                    FUNC_ID           = data.vFUNC_ID,
                                    FUNC_ID_B         = _MT.FUNC_ID,
                                    SEND_TIME         = data.vSEND_TIME,
                                    SEND_TIME_B       = _MT.SEND_TIME,
                                    INTERVAL_MIN      = TypeTransfer.stringToIntN(data.vINTERVAL_MIN),
                                    INTERVAL_MIN_B    = _MT.INTERVAL_MIN,
                                    TREA_OPEN_TIME    = data.vTREA_OPEN_TIME,
                                    TREA_OPEN_TIME_B  = _MT.TREA_OPEN_TIME,
                                    EXEC_TIME_B       = data.vEXEC_TIME_B,
                                    EXEC_TIME_B_B     = _MT.EXEC_TIME_B,
                                    EXEC_TIME_E       = data.vEXEC_TIME_E,
                                    EXEC_TIME_E_B     = _MT.EXEC_TIME_E,
                                    MAIL_CONTENT_ID   = data.vMAIL_CONTENT_ID,
                                    MAIL_CONTENT_ID_B = _MT.MAIL_CONTENT_ID,
                                    MEMO          = data.vMEMO,
                                    MEMO_B        = _MT.MEMO,
                                    IS_DISABLED   = data.vIS_DISABLED,
                                    IS_DISABLED_B = _MT.IS_DISABLED,
                                    APLY_UID      = searchData.userId,
                                    APLY_DATE     = dt,
                                    APPR_STATUS   = "1", //表單申請
                                };

                                logStr += MTH.modelToString(logStr);
                                db.MAIL_TIME_HIS.Add(MTH);
                            }

                            #region Save Db
                            var validateMessage = db.GetValidationErrors().getValidateString();
                            if (validateMessage.Any())
                            {
                                result.DESCRIPTION = validateMessage;
                            }
                            else
                            {
                                try
                                {
                                    db.SaveChanges();

                                    #region LOG
                                    //新增LOG
                                    Log log = new Log();
                                    log.CFUNCTION = "申請覆核-mail發送內文設定檔";
                                    log.CACTION   = "A";
                                    log.CCONTENT  = logStr;
                                    LogDao.Insert(log, searchData.userId);
                                    #endregion

                                    result.RETURN_FLAG = true;
                                    result.DESCRIPTION = Ref.MessageType.Apply_Audit_Success.GetDescription(null, $@"單號為{_Aply_No}");
                                }
                                catch (DbUpdateException ex)
                                {
                                    result.DESCRIPTION = ex.exceptionMessage();
                                }
                            }
                            #endregion
                        }
                    }
                    else
                    {
                        result.DESCRIPTION = Ref.MessageType.not_Find_Audit_Data.GetDescription();
                    }
                }
                else
                {
                    result.DESCRIPTION = Ref.MessageType.not_Find_Audit_Data.GetDescription();
                }
            }
            catch (Exception ex)
            {
                result.DESCRIPTION = ex.exceptionMessage();
            }

            return(result);
        }
Esempio n. 26
0
        /// <summary>
        /// 保管單位承辦作業-覆核
        /// </summary>
        /// <param name="searchData"></param>
        /// <param name="viewModels"></param>
        /// <returns></returns>
        public MSGReturnModel <List <TreasuryAccessApprSearchDetailViewModel> > CustodyApproved(TreasuryAccessApprSearchViewModel searchData, List <TreasuryAccessApprSearchDetailViewModel> viewModels)
        {
            MSGReturnModel <List <TreasuryAccessApprSearchDetailViewModel> > result = new MSGReturnModel <List <TreasuryAccessApprSearchDetailViewModel> >();

            result.RETURN_FLAG = false;
            result.DESCRIPTION = MessageType.parameter_Error.GetDescription();

            if (!viewModels.Any())
            {
                return(result);
            }

            DateTime dt     = DateTime.Now;
            string   logStr = string.Empty;

            using (TreasuryDBEntities db = new TreasuryDBEntities())
            {
                var aplynos = new List <string>();

                List <string> checks = new List <string>()
                {
                    TreaItemType.D1016.ToString(), TreaItemType.D1017.ToString()
                };

                foreach (var item in viewModels.Where(x => x.vCheckFlag))
                {
                    var _TREA_APLY_REC = db.TREA_APLY_REC.FirstOrDefault(x => x.APLY_NO == item.vAPLY_NO);
                    if (_TREA_APLY_REC == null) //找不到該筆單號
                    {
                        result.DESCRIPTION = Ref.MessageType.not_Find_Any.GetDescription(null, $"單號:{item.vAPLY_NO}");
                        return(result);
                    }
                    if (_TREA_APLY_REC.LAST_UPDATE_DT > item.vLast_Update_Time) //資料已經被更新
                    {
                        result.DESCRIPTION = Ref.MessageType.already_Change.GetDescription(null, $"單號:{item.vAPLY_NO}");
                        return(result);
                    }
                    if (_TREA_APLY_REC.ITEM_ID == TreaItemType.D1016.ToString())
                    {
                        var ids   = db.OTHER_ITEM_APLY.AsNoTracking().Where(x => x.APLY_NO == _TREA_APLY_REC.APLY_NO).Select(x => x.ITEM_ID).Distinct().ToList();
                        var items = db.ITEM_REFUNDABLE_DEP.AsNoTracking()
                                    .Where(x => ids.Contains(x.ITEM_ID)).AsEnumerable()
                                    .Where(x => x.BOOK_NO.IsNullOrWhiteSpace())
                                    .Select(x => x.ITEM_ID).ToList();
                        if (items.Any())
                        {
                            result.DESCRIPTION = MessageType.book_No_Error.GetDescription($@"存出保證金 歸檔編號:{string.Join(",", items)} , 冊號 不得為空值");
                            return(result);
                        }
                    }
                    else if (_TREA_APLY_REC.ITEM_ID == TreaItemType.D1017.ToString())
                    {
                        var ids   = db.OTHER_ITEM_APLY.AsNoTracking().Where(x => x.APLY_NO == _TREA_APLY_REC.APLY_NO).Select(x => x.ITEM_ID).Distinct().ToList();
                        var items = db.ITEM_DEP_RECEIVED.AsNoTracking()
                                    .Where(x => ids.Contains(x.ITEM_ID)).AsEnumerable()
                                    .Where(x => x.BOOK_NO.IsNullOrWhiteSpace())
                                    .Select(x => x.ITEM_ID).ToList();
                        if (items.Any())
                        {
                            result.DESCRIPTION = MessageType.book_No_Error.GetDescription($@"存入保證金 歸檔編號:{string.Join(",", items)} , 冊號 不得為空值");
                            return(result);
                        }
                    }
                    aplynos.Add(item.vAPLY_NO);
                    var aplyStatus = Ref.AccessProjectFormStatus.B02.ToString(); // 狀態 => 保管科覆核中
                    _TREA_APLY_REC.APLY_STATUS     = aplyStatus;
                    _TREA_APLY_REC.CUSTODY_UID     = searchData.vCreateUid;
                    _TREA_APLY_REC.LAST_UPDATE_UID = searchData.vCreateUid;
                    _TREA_APLY_REC.LAST_UPDATE_DT  = dt;

                    logStr += _TREA_APLY_REC.modelToString(logStr);

                    #region 申請單歷程檔
                    var ARH = new APLY_REC_HIS()
                    {
                        APLY_NO     = _TREA_APLY_REC.APLY_NO,
                        APLY_STATUS = aplyStatus,
                        PROC_UID    = searchData.vCreateUid,
                        PROC_DT     = dt
                    };
                    logStr += ARH.modelToString(logStr);

                    db.APLY_REC_HIS.Add(ARH);
                    #endregion
                }
                var validateMessage = db.GetValidationErrors().getValidateString();
                if (validateMessage.Any())
                {
                    result.DESCRIPTION = validateMessage;
                }
                else
                {
                    try
                    {
                        db.SaveChanges();

                        #region LOG
                        //新增LOG
                        Log log = new Log();
                        log.CFUNCTION = "覆核-保管單位承辦作業";
                        log.CACTION   = "U";
                        log.CCONTENT  = logStr;
                        LogDao.Insert(log, searchData.vCreateUid);
                        #endregion

                        result.RETURN_FLAG = true;
                        result.DESCRIPTION = $"申請單號 : {string.Join(",", aplynos)} 覆核成功!";
                        result.Datas       = GetCustodySearchDetail(searchData);
                    }
                    catch (DbUpdateException ex)
                    {
                        result.DESCRIPTION = ex.exceptionMessage();
                    }
                }
            }



            return(result);
        }
Esempio n. 27
0
        /// <summary>
        /// 金庫進出管理作業-申請覆核
        /// </summary>
        /// <param name="saveData">申請覆核的資料</param>
        /// <param name="searchModel">查詢ViwModel</param>
        /// <returns></returns>
        public MSGReturnModel <IEnumerable <ITinItem> > TinApplyAudit(IEnumerable <ITinItem> saveData, ITinItem searchModel)
        {
            var searchData = (TreasuryMailContentSearchViewModel)searchModel;
            var result     = new MSGReturnModel <IEnumerable <ITinItem> >();

            result.RETURN_FLAG = false;
            DateTime dt = DateTime.Now;

            try
            {
                if (saveData != null)
                {
                    var data = ((List <TreasuryMailContentUpdateViewModel>)saveData).FirstOrDefault();
                    if (data != null)
                    {
                        using (TreasuryDBEntities db = new TreasuryDBEntities())
                        {
                            //取得流水號
                            SysSeqDao sysSeqDao = new SysSeqDao();
                            String    qPreCode  = DateUtil.getCurChtDateTime().Split(' ')[0];

                            string logStr = string.Empty; //log

                            var          _MAIL_CONTENT_ID = string.Empty;
                            MAIL_CONTENT _MC = null;
                            if (!data.vMAIL_CONTENT_ID.IsNullOrWhiteSpace()) //現有資料修改
                            {
                                _MAIL_CONTENT_ID = data.vMAIL_CONTENT_ID;
                                _MC = db.MAIL_CONTENT.First(x => x.MAIL_CONTENT_ID == _MAIL_CONTENT_ID);
                                if (_MC.DATA_STATUS != "1")
                                {
                                    result.DESCRIPTION = Ref.MessageType.already_Change.GetDescription();
                                    return(result);
                                }
                                _MC.DATA_STATUS     = "2"; //凍結中
                                _MC.LAST_UPDATE_UID = data.UserID;
                                _MC.LAST_UPDATE_DT  = dt;
                                _MC.FREEZE_DT       = dt;
                                _MC.FREEZE_UID      = data.UserID;
                            }
                            else
                            {
                                //目前只加入異動檔
                            }

                            string _Aply_No = $@"G4{qPreCode}{sysSeqDao.qrySeqNo("G4", qPreCode).ToString().PadLeft(3, '0')}";  //申請單號 G4+系統日期YYYMMDD(民國年)+3碼流水號

                            var MCH = new MAIL_CONTENT_HIS()
                            {
                                APLY_NO         = _Aply_No,
                                MAIL_CONTENT_ID = _MAIL_CONTENT_ID,
                                IS_DISABLED     = data.vIS_DISABLED,
                                IS_DISABLED_B   = _MC?.IS_DISABLED,
                                MAIL_SUBJECT    = data.vMAIL_SUBJECT,
                                MAIL_SUBJECT_B  = _MC?.MAIL_SUBJECT,
                                MAIL_CONTENT    = data.vMAIL_CONTENT,
                                MAIL_CONTENT_B  = _MC?.MAIL_CONTENT1,
                                APLY_UID        = data.UserID,
                                APLY_DATE       = dt,
                                APPR_STATUS     = "1", //表單申請
                                EXEC_ACTION     = (data.vMAIL_CONTENT_ID != null) ? "U" : "A"
                            };

                            logStr += MCH.modelToString(logStr);
                            db.MAIL_CONTENT_HIS.Add(MCH);

                            foreach (var item in data.subData)
                            {
                                var _MRH = new MAIL_RECEIVE_HIS()
                                {
                                    APLY_NO         = _Aply_No,
                                    MAIL_CONTENT_ID = _MAIL_CONTENT_ID,
                                    FUNC_ID         = item.FUNC_ID,
                                    EXEC_ACTION     = item.vStatus
                                };
                                logStr += _MRH.modelToString(logStr);
                                db.MAIL_RECEIVE_HIS.Add(_MRH);
                            }
                            #region Save Db
                            var validateMessage = db.GetValidationErrors().getValidateString();
                            if (validateMessage.Any())
                            {
                                result.DESCRIPTION = validateMessage;
                            }
                            else
                            {
                                try
                                {
                                    db.SaveChanges();

                                    #region LOG
                                    //新增LOG
                                    Log log = new Log();
                                    log.CFUNCTION = "申請覆核-mail發送內文設定檔";
                                    log.CACTION   = "A";
                                    log.CCONTENT  = logStr;
                                    LogDao.Insert(log, data.UserID);
                                    #endregion
                                    result.Datas       = GetSearchData(searchModel);
                                    result.RETURN_FLAG = true;
                                    result.DESCRIPTION = Ref.MessageType.Apply_Audit_Success.GetDescription(null, $@"單號為{_Aply_No}");
                                }
                                catch (DbUpdateException ex)
                                {
                                    result.DESCRIPTION = ex.exceptionMessage();
                                }
                            }
                            #endregion
                        }
                    }
                    else
                    {
                        result.DESCRIPTION = Ref.MessageType.not_Find_Audit_Data.GetDescription();
                    }
                }
                else
                {
                    result.DESCRIPTION = Ref.MessageType.not_Find_Audit_Data.GetDescription();
                }
            }
            catch (Exception ex)
            {
                result.DESCRIPTION = ex.exceptionMessage();
            }

            return(result);
        }
Esempio n. 28
0
        /// <summary>
        /// 產生工作底稿
        /// </summary>
        /// <param name="currentUserId">目前使用者ID</param>
        /// <param name="Trea_Register_Id">金庫開庫單號</param>
        /// <returns></returns>
        public MSGReturnModel <IEnumerable <ITreaItem> > DraftData(string currentUserId, string Trea_Register_Id)
        {
            var result = new MSGReturnModel <IEnumerable <ITreaItem> >();

            result.RETURN_FLAG = false;
            DateTime dt          = DateTime.Now;
            var      Regi_Status = Ref.AccessProjectFormStatus.C02.ToString();
            var      OTD         = DateTime.Now.ToString("yyyy-MM-dd");

            try
            {
                using (TreasuryDBEntities db = new TreasuryDBEntities())
                {
                    string logStr = string.Empty; //log

                    //查詢【開庫紀錄檔】,是否有尚待執行開庫的申請資料
                    var _TOR_List = db.TREA_OPEN_REC.FirstOrDefault(x => x.TREA_REGISTER_ID == Trea_Register_Id);

                    var Update_Regi_Status = Ref.AccessProjectFormStatus.D01.ToString();

                    #region 開庫紀錄檔
                    if (_TOR_List != null)
                    {
                        //異動【開庫紀錄檔】
                        _TOR_List.REGI_STATUS = Update_Regi_Status;
                        //開庫類型=1
                        if (_TOR_List.OPEN_TREA_TYPE == "1")
                        {
                            _TOR_List.CREATE_UID = currentUserId;
                        }
                        _TOR_List.LAST_UPDATE_UID = currentUserId;
                        _TOR_List.LAST_UPDATE_DT  = dt;

                        logStr += "|";
                        logStr += _TOR_List.modelToString();

                        //畫面上「已入庫確認資料」
                        var _TAR_List = db.TREA_APLY_REC
                                        .Where(x => x.CONFIRM_UID != null)
                                        .Where(x => x.APLY_STATUS == Regi_Status)
                                        .Where(x => x.TREA_REGISTER_ID == _TOR_List.TREA_REGISTER_ID)
                                        .ToList();


                        foreach (var item in _TAR_List)
                        {
                            #region 申請單紀錄檔
                            item.APLY_STATUS     = Update_Regi_Status;
                            item.LAST_UPDATE_UID = currentUserId;
                            item.LAST_UPDATE_DT  = dt;

                            logStr += "|";
                            logStr += item.modelToString();
                            #endregion

                            #region 申請單歷程檔
                            db.APLY_REC_HIS.Add(
                                new APLY_REC_HIS()
                            {
                                APLY_NO     = item.APLY_NO,
                                APLY_STATUS = Update_Regi_Status,
                                PROC_UID    = currentUserId,
                                PROC_DT     = dt
                            });
                            #endregion
                        }


                        #region Save Db
                        var validateMessage = db.GetValidationErrors().getValidateString();
                        if (validateMessage.Any())
                        {
                            result.DESCRIPTION = validateMessage;
                        }
                        else
                        {
                            try
                            {
                                db.SaveChanges();

                                #region LOG
                                //新增LOG
                                Log log = new Log();
                                log.CFUNCTION = "金庫登記簿執行作業(開庫前)";
                                log.CACTION   = "A";
                                log.CCONTENT  = logStr;
                                LogDao.Insert(log, currentUserId);
                                #endregion

                                result.RETURN_FLAG = true;
                                result.DESCRIPTION = "金庫登記簿執行作業(開庫前),執行成功";
                            }
                            catch (DbUpdateException ex)
                            {
                                result.DESCRIPTION = ex.exceptionMessage();
                            }
                        }
                        #endregion
                    }
                    else
                    {
                        result.DESCRIPTION = "無可供開庫作業的申請資料,若需開庫,請執行指定時間開庫申請!!";
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                result.DESCRIPTION = ex.exceptionMessage();
            }

            return(result);
        }
Esempio n. 29
0
        public JsonResult execReviewU(string aplyNo, string userId, string apprStatus)
        {
            string strConn = DbUtil.GetDBTreasuryConnStr();

            using (SqlConnection conn = new SqlConnection(strConn))
            {
                conn.Open();
                SqlTransaction transaction = conn.BeginTransaction("Transaction");

                try
                {
                    AuthApprDao AuthApprDao = new AuthApprDao();
                    AUTH_APPR   authAppr    = AuthApprDao.qryByKey(aplyNo);

                    if (StringUtil.toString(authAppr.CREATE_UID).Equals(Session["UserID"].ToString()))
                    {
                        return(Json(new { success = false, errors = "覆核人員與申請人員相同,不可執行覆核作業!!" }, JsonRequestBehavior.AllowGet));
                    }


                    //異動使用者資料檔
                    string         cExecType      = "";
                    CodeUserHisDao codeUserHisDao = new CodeUserHisDao();
                    CodeUserDao    codeUserDao    = new CodeUserDao();
                    CODE_USER      cODEUSERO      = new CODE_USER();

                    CODE_USER_HIS codeUserHis = codeUserHisDao.qryByAplyNo(aplyNo);
                    string        execAction  = "";
                    if (codeUserHis != null)
                    {
                        execAction = StringUtil.toString(codeUserHis.EXEC_ACTION);
                    }

                    if ("A".Equals(execAction))  //新增使用者
                    {
                    }
                    else
                    {  //異動角色
                        cODEUSERO = codeUserDao.qryUserByKey(userId);
                    }



                    if ("A".Equals(execAction))
                    {
                        if ("2".Equals(apprStatus))
                        {
                            cODEUSERO.USER_ID         = StringUtil.toString(codeUserHis.USER_ID);
                            cODEUSERO.IS_DISABLED     = codeUserHis.IS_DISABLED;
                            cODEUSERO.IS_MAIL         = codeUserHis.IS_MAIL;
                            cODEUSERO.MEMO            = codeUserHis.MEMO;
                            cODEUSERO.DATA_STATUS     = "1";
                            cODEUSERO.CREATE_UID      = authAppr.CREATE_UID;
                            cODEUSERO.CREATE_DT       = authAppr.CREATE_DT;
                            cODEUSERO.LAST_UPDATE_UID = StringUtil.toString(authAppr.CREATE_UID);
                            cODEUSERO.LAST_UPDATE_DT  = authAppr.CREATE_DT;
                            cODEUSERO.APPR_UID        = Session["UserID"].ToString();
                            cODEUSERO.APPR_DT         = DateTime.Now;

                            int cnt = codeUserDao.Create(cODEUSERO, conn, transaction);

                            //新增LOG
                            Log log = new Log();
                            log.CFUNCTION = "使用者管理-新增";
                            log.CACTION   = "A";
                            log.CCONTENT  = codeUserDao.userLogContent(cODEUSERO);
                            LogDao.Insert(log, Session["UserID"].ToString());

                            //新增稽核軌跡
                            procTrackLog("A", codeUserDao, cODEUSERO, conn, transaction);
                        }
                    }
                    else
                    {
                        //新增LOG
                        Log log = new Log();
                        log.CFUNCTION = "使用者管理-修改";
                        log.CACTION   = "U";
                        log.CCONTENT  = codeUserDao.userLogContent(cODEUSERO);
                        LogDao.Insert(log, Session["UserID"].ToString());

                        cODEUSERO.DATA_STATUS     = "1";
                        cODEUSERO.LAST_UPDATE_UID = StringUtil.toString(authAppr.CREATE_UID);
                        cODEUSERO.LAST_UPDATE_DT  = authAppr.CREATE_DT;
                        cODEUSERO.APPR_UID        = Session["UserID"].ToString();
                        cODEUSERO.APPR_DT         = DateTime.Now;
                        cODEUSERO.FREEZE_DT       = null;
                        cODEUSERO.FREEZE_UID      = "";

                        if ("U".Equals(execAction) && "2".Equals(apprStatus))
                        {
                            cODEUSERO.IS_DISABLED = codeUserHis.IS_DISABLED;
                            cODEUSERO.IS_MAIL     = StringUtil.toString(codeUserHis.IS_MAIL);
                            cODEUSERO.MEMO        = StringUtil.toString(codeUserHis.MEMO);
                        }


                        int cnt = codeUserDao.Update(cODEUSERO, conn, transaction);

                        //20190418 201904160117-00 Bianco 修改稽核軌跡
                        procTrackLog("E", codeUserDao, cODEUSERO, conn, transaction);
                    }


                    //覆核狀態=核可時
                    if ("2".Equals(apprStatus))
                    {
                        procUserRoleHis(cODEUSERO, aplyNo, conn, transaction); //異動使用者角色
                    }
                    //異動覆核資料檔
                    procAuthAppr(aplyNo, apprStatus, conn, transaction);

                    transaction.Commit();
                    return(Json(new { success = true }));
                }
                catch (Exception e)
                {
                    transaction.Rollback();
                    logger.Error("[execReviewR]其它錯誤:" + e.ToString());

                    return(Json(new { success = false, errors = "其它錯誤,請洽系統管理員!!" }, JsonRequestBehavior.AllowGet));
                }
            }
        }
Esempio n. 30
0
        //public List<SelectOption> GetTreaItem()
        //{
        //    List<SelectOption> treaItem = new List<SelectOption>();

        //    using (TreasuryDBEntities db = new TreasuryDBEntities())
        //    {
        //        treaItem = db.TREA_ITEM.AsNoTracking()
        //    }
        //}

        /// <summary>
        /// 金庫進出管理作業-申請覆核
        /// </summary>
        /// <param name="saveData">申請覆核的資料</param>
        /// <param name="searchModel">查詢ViwModel</param>
        /// <returns></returns>
        public MSGReturnModel <IEnumerable <ITinItem> > TinApplyAudit(IEnumerable <ITinItem> saveData, ITinItem searchModel)
        {
            var searchData = (ItemMaintainSearchViewModel)searchModel;
            var result     = new MSGReturnModel <IEnumerable <ITinItem> >();

            result.RETURN_FLAG = false;
            DateTime dt = DateTime.Now;

            try
            {
                if (saveData != null)
                {
                    var datas = (List <ItemMaintainSearchDetailViewModel>)saveData;
                    if (datas.Any())
                    {
                        using (TreasuryDBEntities db = new TreasuryDBEntities())
                        {
                            //取得流水號
                            SysSeqDao sysSeqDao = new SysSeqDao();
                            String    qPreCode  = DateUtil.getCurChtDateTime().Split(' ')[0];
                            var       cId       = sysSeqDao.qrySeqNo("G1", qPreCode).ToString().PadLeft(3, '0');
                            string    _Aply_No  = string.Empty;
                            _Aply_No = $@"G1{qPreCode}{cId}"; //申請單號 G1+系統日期YYYMMDD(民國年)+3碼流水號
                            string logStr = string.Empty;     //log

                            foreach (var item in datas)
                            {
                                var _Trea_Item_Id = string.Empty;
                                var _TI           = new TREA_ITEM();
                                # region 金庫存取作業設定檔
                                //判斷執行功能
                                switch (item.vEXEC_ACTION)
                                {
                                case "A":    //新增
                                    _Trea_Item_Id = "";
                                    //_Trea_Item_Id = sysSeqDao.qrySeqNo("D1", string.Empty).ToString().PadLeft(3, '0');
                                    //_Trea_Item_Id = $@"D1{_Trea_Item_Id}";
                                    //_TI = new TREA_ITEM()
                                    //{
                                    //    ITEM_ID = _Trea_Item_Id,
                                    //    ITEM_DESC = item.vITEM_DESC,
                                    //    IS_TREA_ITEM = item.vIS_TREA_ITEM,
                                    //    TREA_ITEM_NAME = item.vTREA_ITEM_NAME,
                                    //    TREA_ITEM_TYPE = item.vTREA_ITEM_TYPE,
                                    //    ITEM_OP_TYPE = item.vITEM_OP_TYPE,
                                    //    DAILY_FLAG = item.vISDO_PERDAY,
                                    //    IS_DISABLED = item.vIS_DISABLED,
                                    //    MEMO = item.vMEMO,
                                    //    DATA_STATUS = "2",//凍結中
                                    //    CREATE_DT = dt,
                                    //    CREATE_UID = searchData.vCUSER_ID,
                                    //    LAST_UPDATE_DT =dt,
                                    //    LAST_UPDATE_UID = searchData.vCUSER_ID,
                                    //    FREEZE_UID = searchData.vCUSER_ID,
                                    //    FREEZE_DT = dt
                                    //};
                                    //db.TREA_ITEM.Add(_TI);
                                    //logStr += "|";
                                    //logStr += _TI.modelToString();
                                    break;

                                case "U":    //修改
                                    _TI = db.TREA_ITEM.FirstOrDefault(x => x.ITEM_ID == item.vITEM_ID);
                                    if (_TI.LAST_UPDATE_DT != null && _TI.LAST_UPDATE_DT > item.vLAST_UPDATE_DT)
                                    {
                                        result.DESCRIPTION = Ref.MessageType.already_Change.GetDescription();
                                        return(result);
                                    }
                                    _Trea_Item_Id       = item.vITEM_ID;
                                    _TI.DATA_STATUS     = "2";//凍結中
                                    _TI.LAST_UPDATE_UID = searchData.vCUSER_ID;
                                    _TI.LAST_UPDATE_DT  = dt;
                                    _TI.FREEZE_UID      = searchData.vCUSER_ID;
                                    _TI.FREEZE_DT       = dt;
                                    logStr += "|";
                                    logStr += _TI.modelToString();
                                    break;

                                case "D":    //刪除
                                    _TI = db.TREA_ITEM.FirstOrDefault(x => x.ITEM_ID == item.vITEM_ID);
                                    if (_TI.LAST_UPDATE_DT != null && _TI.LAST_UPDATE_DT > item.vLAST_UPDATE_DT)
                                    {
                                        result.DESCRIPTION = Ref.MessageType.already_Change.GetDescription();
                                        return(result);
                                    }
                                    _Trea_Item_Id       = item.vITEM_ID;
                                    _TI.DATA_STATUS     = "2";//凍結中
                                    _TI.LAST_UPDATE_UID = searchData.vCUSER_ID;
                                    _TI.LAST_UPDATE_DT  = dt;
                                    _TI.FREEZE_UID      = searchData.vCUSER_ID;
                                    _TI.FREEZE_DT       = dt;
                                    logStr += "|";
                                    logStr += _TI.modelToString();
                                    break;

                                default:
                                    break;
                                }
                                #endregion
                                #region 金庫存取作業異動檔
                                var _TI_Data = db.TREA_ITEM.FirstOrDefault(x => x.ITEM_ID == item.vITEM_ID);
                                if (_TI_Data == null)
                                {
                                    var _TIH = new TREA_ITEM_HIS()
                                    {
                                        APLY_NO        = _Aply_No,
                                        ITEM_ID        = _Trea_Item_Id,
                                        EXEC_ACTION    = item.vEXEC_ACTION,
                                        ITEM_DESC      = item.vITEM_DESC,
                                        IS_TREA_ITEM   = item.vIS_TREA_ITEM,
                                        TREA_ITEM_NAME = item.vTREA_ITEM_NAME,
                                        TREA_ITEM_TYPE = item.vTREA_ITEM_TYPE,
                                        ITEM_OP_TYPE   = item.vITEM_OP_TYPE,
                                        DAILY_FLAG     = item.vISDO_PERDAY,
                                        IS_DISABLED    = item.vIS_DISABLED,
                                        MEMO           = item.vMEMO,
                                        APLY_DATE      = dt,
                                        APLY_UID       = searchData.vCUSER_ID,
                                        APPR_STATUS    = "1" //表單申請
                                    };
                                    db.TREA_ITEM_HIS.Add(_TIH);
                                    logStr += "|";
                                    logStr += _TIH.modelToString();
                                }
                                else
                                {
                                    var _TIH = new TREA_ITEM_HIS()
                                    {
                                        APLY_NO          = _Aply_No,
                                        ITEM_ID          = _Trea_Item_Id,
                                        EXEC_ACTION      = item.vEXEC_ACTION,
                                        ITEM_DESC        = item.vITEM_DESC,
                                        IS_TREA_ITEM     = item.vIS_TREA_ITEM,
                                        TREA_ITEM_NAME   = item.vTREA_ITEM_NAME,
                                        TREA_ITEM_TYPE   = item.vTREA_ITEM_TYPE,
                                        ITEM_OP_TYPE     = item.vITEM_OP_TYPE,
                                        DAILY_FLAG       = item.vISDO_PERDAY,
                                        IS_DISABLED      = item.vIS_DISABLED,
                                        MEMO             = item.vMEMO,
                                        APLY_DATE        = dt,
                                        APLY_UID         = searchData.vCUSER_ID,
                                        APPR_STATUS      = "1", //表單申請
                                        DAILY_FLAG_B     = _TI_Data.DAILY_FLAG,
                                        IS_DISABLED_B    = _TI_Data.IS_DISABLED,
                                        IS_TREA_ITEM_B   = _TI_Data.IS_TREA_ITEM,
                                        TREA_ITEM_TYPE_B = _TI_Data.TREA_ITEM_TYPE,
                                        TREA_ITEM_NAME_B = _TI_Data.TREA_ITEM_NAME,
                                        MEMO_B           = _TI_Data.MEMO
                                    };
                                    db.TREA_ITEM_HIS.Add(_TIH);
                                    logStr += "|";
                                    logStr += _TIH.modelToString();
                                }
                                #endregion
                            }
                            var validateMessage = db.GetValidationErrors().getValidateString();
                            if (validateMessage.Any())
                            {
                                result.DESCRIPTION = validateMessage;
                            }
                            else
                            {
                                try
                                {
                                    db.SaveChanges();

                                    #region LOG
                                    //新增LOG
                                    Log log = new Log();
                                    log.CFUNCTION = "申請覆核-金庫存取項目作業";
                                    log.CACTION   = "A";
                                    log.CCONTENT  = logStr;
                                    LogDao.Insert(log, searchData.vCUSER_ID);
                                    #endregion

                                    result.RETURN_FLAG = true;
                                    result.DESCRIPTION = Ref.MessageType.Apply_Audit_Success.GetDescription(null, $@"單號為{_Aply_No}");
                                }
                                catch (DbUpdateException ex)
                                {
                                    result.DESCRIPTION = ex.exceptionMessage();
                                }
                            }
                        }
                    }
                    else
                    {
                        result.DESCRIPTION = Ref.MessageType.not_Find_Audit_Data.GetDescription();
                    }
                }
                else
                {
                    result.DESCRIPTION = Ref.MessageType.not_Find_Audit_Data.GetDescription();
                }
            }