Esempio n. 1
0
 /// <summary>
 /// Bond_Rating_Summary 組成 A58ViewModel
 /// </summary>
 /// <param name="item">DataRow</param>
 /// <returns>A58ViewModel</returns>
 private A58ViewModel getA58ViewModel(Bond_Rating_Summary item)
 {
     return(new A58ViewModel()
     {
         Reference_Nbr = item.Reference_Nbr,
         Report_Date = TypeTransfer.dateTimeNToString(item.Report_Date),
         Bond_Number = item.Bond_Number,
         Lots = item.Lots,
         Origination_Date = TypeTransfer.dateTimeNToString(item.Origination_Date),
         Parm_ID = item.Parm_ID,
         Bond_Type = item.Bond_Type,
         Rating_Type = item.Rating_Type == "1" ? Rating_Type.A.GetDescription() : Rating_Type.B.GetDescription(),
         Rating_Object = item.Rating_Object,
         Rating_Org_Area = item.Rating_Org_Area,
         Rating_Selection = item.Rating_Selection == "1" ? "孰高" : "孰低",
         Grade_Adjust = TypeTransfer.intNToString(item.Grade_Adjust),
         Rating_Priority = TypeTransfer.intNToString(item.Rating_Priority),
         Processing_Date = TypeTransfer.dateTimeNToString(item.Processing_Date),
         Version = TypeTransfer.intNToString(item.Version),
         Portfolio_Name = item.Portfolio_Name,
         SMF = item.SMF,
         Issuer = item.ISSUER,
         Security_Ticker = getSecurityTicker(item.SMF, item.Bond_Number),
         RATING_AS_OF_DATE_OVERRIDE = item.Rating_Type == "1" ?
                                      TypeTransfer.dateTimeNToString(item.Origination_Date, 8) :
                                      TypeTransfer.dateTimeNToString(item.Report_Date, 8)
     });
 }
 /// <summary>
 /// Db 組成 D05ViewModel
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 private D05ViewModel DbToD05ViewModel(Group_Product_Code_Mapping data)
 {
     return(new D05ViewModel()
     {
         Group_Product_Code = data.Group_Product_Code,
         Group_Product = data.Group_Product.Group_Product_Name,
         Product_Code = data.Product_Code,
         Processing_Date = TypeTransfer.dateTimeNToString(data.Processing_Date)
     });
 }
 /// <summary>
 /// Db 組成 D01ViewModel
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 private D01ViewModel DbToD01ViewModel(Flow_Info data)
 {
     return(new D01ViewModel()
     {
         PRJID = data.PRJID,
         FLOWID = data.FLOWID,
         Group_Product_Code = data.Group_Product_Code,
         Publish_Date = TypeTransfer.dateTimeNToString(data.Publish_Date),
         Apply_On_Date = TypeTransfer.dateTimeNToString(data.Apply_On_Date),
         Apply_Off_Date = TypeTransfer.dateTimeNToString(data.Apply_Off_Date),
         Issuer = data.Issuer,
         Memo = data.Memo
     });
 }
Esempio n. 4
0
        private A62ViewModel DbToA62ViewModel(Moody_LGD_Info data)
        {
            string statusName  = "";
            string auditorName = "";

            StatusList          statusList         = new StatusList();
            List <SelectOption> selectOptionStatus = statusList.statusOption;

            for (int i = 0; i < selectOptionStatus.Count; i++)
            {
                if (data.Status.IsNullOrWhiteSpace() && selectOptionStatus[i].Value.IsNullOrWhiteSpace())
                {
                    statusName = selectOptionStatus[i].Text;
                    break;
                }
                else
                {
                    if (selectOptionStatus[i].Value == data.Status)
                    {
                        statusName = selectOptionStatus[i].Text;
                        break;
                    }
                }
            }

            using (IFRS9DBEntities db = new IFRS9DBEntities())
            {
                var UserData = db.IFRS9_User.Where(x => x.User_Account == data.Auditor).FirstOrDefault();
                if (UserData != null)
                {
                    auditorName = UserData.User_Name;
                }
            }

            return(new A62ViewModel()
            {
                Data_Year = data.Data_Year,
                Lien_Position = data.Lien_Position,
                Recovery_Rate = data.Recovery_Rate.ToString(),
                LGD = data.LGD.ToString(),
                Status = data.Status,
                Status_Name = statusName,
                Auditor_Reply = data.Auditor_Reply,
                Auditor = data.Auditor,
                Auditor_Name = auditorName,
                Audit_date = TypeTransfer.dateTimeNToString(data.Audit_date)
            });
        }
Esempio n. 5
0
        /// <summary>
        /// 查詢資料
        /// </summary>
        /// <param name="searchModel">查詢ViwModel</param>
        /// <returns></returns>
        public IEnumerable <ITinItem> GetSearchData(ITinItem searchModel)
        {
            var searchData = (TreasuryMailTimeSearchViewModel)searchModel;
            List <TreasuryMailTimeViewModel> result = new List <TreasuryMailTimeViewModel>();

            using (TreasuryDBEntities db = new TreasuryDBEntities())
            {
                var emps = GetEmps();

                var _Is_Disabled = db.SYS_CODE.AsNoTracking()
                                   .Where(x => x.CODE_TYPE == "IS_DISABLED").ToList();
                var _DATA_STATUS = db.SYS_CODE.AsNoTracking()
                                   .Where(x => x.CODE_TYPE == "DATA_STATUS").ToList();

                var his = db.MAIL_TIME_HIS.AsNoTracking()
                          .Where(x => x.APPR_DATE == null).ToList();

                result.AddRange(db.MAIL_TIME.AsNoTracking()
                                .AsEnumerable()
                                .Select((x) => new TreasuryMailTimeViewModel()
                {
                    vSEND_TIME            = x.SEND_TIME,
                    vFUNC_ID              = x.FUNC_ID,
                    vINTERVAL_MIN         = x.INTERVAL_MIN?.ToString(),
                    vMAIL_CONTENT_ID      = x.MAIL_CONTENT_ID,
                    vEXEC_TIME_B          = x.EXEC_TIME_B,
                    vEXEC_TIME_E          = x.EXEC_TIME_E,
                    vDATA_STATUS          = x.DATA_STATUS,
                    vDATA_STATUS_NAME     = _DATA_STATUS.FirstOrDefault(y => y.CODE == x.DATA_STATUS)?.CODE_VALUE,
                    vAplyNo               = x.DATA_STATUS != "1" ? his.FirstOrDefault(y => y.MAIL_TIME_ID == x.MAIL_TIME_ID)?.APLY_NO : "",
                    vMEMO                 = x.MEMO,
                    vIS_DISABLED          = x.IS_DISABLED,
                    vIS_DISABLED_NAME     = _Is_Disabled.FirstOrDefault(y => y.CODE == x.IS_DISABLED)?.CODE_VALUE,
                    vTREA_OPEN_TIME       = x.TREA_OPEN_TIME,
                    vFREEZE_UID_Name      = emps.FirstOrDefault(y => y.USR_ID != null && y.USR_ID == x.FREEZE_UID)?.EMP_NAME?.Trim(),
                    vLAST_UPDATE_UID_Name = emps.FirstOrDefault(y => y.USR_ID == x.LAST_UPDATE_UID)?.EMP_NAME?.Trim(),
                    vLAST_UPDATE_DT_Show  = TypeTransfer.dateTimeNToString(x.LAST_UPDATE_DT),
                    vMAIL_TIME_ID         = x.MAIL_TIME_ID,
                    vLAST_UPDATE_DT       = x.LAST_UPDATE_DT,
                }).OrderBy(x => x.vMAIL_CONTENT_ID).ToList());
            }
            return(result);
        }
Esempio n. 6
0
        /// <summary>
        /// 查詢申請單紀錄資料by單號
        /// </summary>
        /// <param name="aplyNo"></param>
        /// <returns></returns>
        public TreasuryAccessViewModel GetByAplyNo(string aplyNo)
        {
            var result = new TreasuryAccessViewModel();
            var depts  = new List <VW_OA_DEPT>();
            var emps   = new List <V_EMPLY2>();

            using (DB_INTRAEntities dbINTRA = new DB_INTRAEntities())
            {
                depts = dbINTRA.VW_OA_DEPT.AsNoTracking().ToList();
                emps  = dbINTRA.V_EMPLY2.AsNoTracking().ToList();
            }
            using (TreasuryDBEntities db = new TreasuryDBEntities())
            {
                var formStatus    = db.SYS_CODE.AsNoTracking().Where(x => x.CODE_TYPE == "FORM_STATUS").ToList();
                var treaItemTypes = db.TREA_ITEM.AsNoTracking().Where(x => x.IS_DISABLED == "N" && x.ITEM_OP_TYPE == "3").ToList();
                var data          = db.TREA_APLY_REC.AsNoTracking().FirstOrDefault(x => x.APLY_NO == aplyNo);
                if (data != null)
                {
                    result.vAplyNo             = data.APLY_NO;
                    result.vItem               = treaItemTypes.FirstOrDefault(x => x.ITEM_ID == data.ITEM_ID)?.ITEM_DESC;
                    result.vAplyUnitNmae       = depts.FirstOrDefault(y => y.DPT_CD.Trim() == data.APLY_UNIT)?.DPT_NAME; //1904112 Bianco 改為顯示名子
                    result.vAplyUidName        = emps.FirstOrDefault(x => x.USR_ID == data.APLY_UID)?.EMP_NAME;          //1904112 Bianco 改為顯示名子
                    result.vAplyUnit           = data.APLY_UNIT;
                    result.vAplyUid            = data.APLY_UID;
                    result.vChargeUnit         = depts.FirstOrDefault(y => y.DPT_CD.Trim() == data.APLY_UNIT)?.DPT_NAME;
                    result.vAccessType         = data.ACCESS_TYPE == "P" ? "存入" : data.ACCESS_TYPE == "G" ? "取出" : ""; //存入(P) or 取出(G)
                    result.vExpectedAccessDate = TypeTransfer.dateTimeNToString(data.EXPECTED_ACCESS_DATE);
                    result.vCreateDt           = TypeTransfer.dateTimeNToString(data.CREATE_DT);
                    var _createEmp = emps.FirstOrDefault(x => x.USR_ID == data.CREATE_UID);
                    result.vCreateUnit     = depts.FirstOrDefault(y => y.DPT_CD.Trim() == _createEmp?.DPT_CD?.Trim())?.DPT_NAME;
                    result.vCreateUid      = _createEmp?.EMP_NAME;
                    result.vCreateUnit_Id  = data.CREATE_UNIT;
                    result.vCreateUid_Id   = data.CREATE_UID;
                    result.vAccessReason   = data.ACCESS_REASON;
                    result.vLastUpdateTime = data.LAST_UPDATE_DT;
                }
            }
            return(result);
        }
Esempio n. 7
0
        /// <summary>
        /// 查詢
        /// </summary>
        /// <param name="data">金庫物品存取主畫面查詢ViewModel</param>
        /// <returns></returns>
        public List <TreasuryAccessSearchDetailViewModel> GetSearchDetail(TreasuryAccessSearchViewModel data)
        {
            List <TreasuryAccessSearchDetailViewModel> result = new List <TreasuryAccessSearchDetailViewModel>();

            if (data.vItem == null || data.vAplyUnit == null || !data.vItem.Any() || !data.vAplyUnit.Any()) //無查詢項目 or 申請單位 表示沒有權限查詢
            {
                return(result);
            }
            var depts = GetDepts();
            var emps  = GetEmps();

            using (TreasuryDBEntities db = new TreasuryDBEntities())
            {
                DateTime?_vAPLY_DT_S          = TypeTransfer.stringToDateTimeN(data.vAPLY_DT_S);
                DateTime?_vAPLY_DT_E          = TypeTransfer.stringToDateTimeN(data.vAPLY_DT_E).DateToLatestTime();
                DateTime?_vActualAccessDate_S = TypeTransfer.stringToDateTimeN(data.vActualAccessDate_S);
                DateTime?_vActualAccessDate_E = TypeTransfer.stringToDateTimeN(data.vActualAccessDate_E).DateToLatestTime();
                var      formStatus           = db.SYS_CODE.AsNoTracking().Where(x => x.CODE_TYPE == "FORM_STATUS").ToList();
                var      treaItems            = db.TREA_ITEM.AsNoTracking().Where(x => x.ITEM_OP_TYPE == "3").ToList();

                var _data = db.TREA_APLY_REC.AsNoTracking()
                            .Where(x => data.vItem.Contains(x.ITEM_ID))                                                              //項目
                            .Where(x => data.vAplyUnit.Contains(x.APLY_UNIT), data.vCustodianFlag && data.vAplyUnit.Count == 1)      //保管科還是要單獨查詢申請單位
                            .Where(x => data.vAplyUnit.Contains(x.APLY_UNIT), !data.vCustodianFlag)                                  //非保管科要加入申請單位條件 (20181105調整)
                            .Where(x => x.APLY_DT >= _vAPLY_DT_S, _vAPLY_DT_S != null)                                               //申請日期(起)
                            .Where(x => x.APLY_DT <= _vAPLY_DT_E, _vAPLY_DT_E != null)                                               //申請日期(迄)
                            .Where(x => x.APLY_NO == data.vAPLY_NO, !data.vAPLY_NO.IsNullOrWhiteSpace())                             //申請單號
                            .Where(x => x.TREA_REGISTER_ID == data.vTREA_REGISTER_ID, !data.vTREA_REGISTER_ID.IsNullOrWhiteSpace()); //金庫登記簿單號

                if (_vActualAccessDate_S != null || _vActualAccessDate_E != null)                                                    //實際存取
                {
                    var status = new List <string>()
                    {
                        Ref.AccessProjectFormStatus.D03.ToString(),
                        Ref.AccessProjectFormStatus.E01.ToString()
                    };                                               //狀態須符合這兩個
                    _data = _data.Where(x => status.Contains(x.APLY_STATUS))
                            .Join(db.TREA_OPEN_REC.AsNoTracking()
                                  .Where(x => x.REGI_APPR_DT >= _vActualAccessDate_S, _vActualAccessDate_S != null)
                                  .Where(x => x.REGI_APPR_DT <= _vActualAccessDate_E, _vActualAccessDate_E != null),
                                  x => x.TREA_REGISTER_ID,
                                  y => y.TREA_REGISTER_ID,
                                  (x, y) => x);
                }
                var dataTAR = _data.ToList();
                var TRIDs   = dataTAR.Where(x => x.TREA_REGISTER_ID != null).Select(x => x.TREA_REGISTER_ID).ToList();
                var dataTOR = db.TREA_OPEN_REC.AsNoTracking().Where(x => TRIDs.Contains(x.TREA_REGISTER_ID)).ToList();
                result.AddRange(
                    from TAR in dataTAR
                    join TOR in dataTOR
                    on TAR.TREA_REGISTER_ID equals TOR.TREA_REGISTER_ID into temp
                    from TOR in temp.DefaultIfEmpty()
                    select new TreasuryAccessSearchDetailViewModel
                {
                    vACCESS_REASON = TAR.ACCESS_REASON,
                    vAPLY_DT       = TypeTransfer.dateTimeNToString(TAR.APLY_DT),
                    vREGI_APPR_DT  = TypeTransfer.dateTimeNToString(TOR?.REGI_APPR_DT),
                    vAPLY_NO       = TAR.APLY_NO,
                    vAPLY_STATUS   = TAR.APLY_STATUS,
                    vAPLY_STATUS_D = formStatus.FirstOrDefault(x => x.CODE == TAR.APLY_STATUS)?.CODE_VALUE,
                    vAPLY_UNIT     = depts.FirstOrDefault(y => y.DPT_CD.Trim() == TAR.APLY_UNIT)?.DPT_NAME,
                    vAPLY_UID      = TAR.APLY_UID,
                    vAPLY_UID_NAME = emps.FirstOrDefault(x => x.USR_ID == TAR.APLY_UID)?.EMP_NAME,
                    vCancleFlag    = TAR.APLY_STATUS == Ref.AccessProjectFormStatus.A01.ToString() && TAR.CREATE_UID == data.vCreateUid ? "Y" : "N",
                    vInvalidFlag   = invalidStatus.Contains(TAR.APLY_STATUS) &&
                                     TAR.CREATE_UID == data.vCreateUid ? "Y" : "N",
                    vPrintFlag        = printsStatus.Contains(TAR.APLY_STATUS) ? "Y" : "N",
                    vItem             = TAR.ITEM_ID,
                    vItemDec          = treaItems.FirstOrDefault(x => x.ITEM_ID == TAR.ITEM_ID)?.ITEM_DESC,
                    vDESC             = !TAR.APLY_APPR_DESC.IsNullOrWhiteSpace() ? TAR.APLY_APPR_DESC : TAR.CUSTODY_APPR_DESC,
                    vACCESS_TYPE      = TAR.ACCESS_TYPE,
                    vLast_Update_Time = TAR.LAST_UPDATE_DT
                });
            }
            return(result);
        }
Esempio n. 8
0
        /// <summary>
        /// 異動紀錄查詢資料
        /// </summary>
        /// <param name="searchModel">查詢ViwModel</param>
        /// <param name="aply_No">申請單號</param>
        /// <returns></returns>
        public IEnumerable <ITinItem> GetChangeRecordSearchData(ITinItem searchModel, string aply_No = null)
        {
            var searchData = (TreasuryMailTimeSearchViewModel)searchModel;
            List <TreasuryMailTimeHistoryViewModel> result = new List <TreasuryMailTimeHistoryViewModel>();

            //if (searchData == null)
            //    return result;

            using (TreasuryDBEntities db = new TreasuryDBEntities())
            {
                var emps = GetEmps();

                var _CODE_FUNC = db.CODE_FUNC.AsNoTracking().ToList();

                var _sysCodes = db.SYS_CODE.AsNoTracking().ToList();

                var _EXEC_ACTION = db.SYS_CODE.AsNoTracking()
                                   .Where(x => x.CODE_TYPE == "EXEC_ACTION").ToList();
                var _Appr_Status = _sysCodes
                                   .Where(x => x.CODE_TYPE == "APPR_STATUS").ToList();
                var _Is_Disabled = db.SYS_CODE.AsNoTracking()
                                   .Where(x => x.CODE_TYPE == "IS_DISABLED").ToList();

                result = db.MAIL_TIME_HIS.AsNoTracking()
                         .Where(x => x.FUNC_ID == searchData.vFunc_ID ||
                                x.FUNC_ID_B == searchData.vFunc_ID, searchData != null &&
                                !searchData.vFunc_ID.IsNullOrWhiteSpace())
                         .Where(x => x.MAIL_TIME_ID == searchData.vMAIL_TIME_ID,
                                searchData != null &&
                                !searchData.vMAIL_TIME_ID.IsNullOrWhiteSpace())
                         .Where(x => x.APPR_STATUS == searchData.vAPPR_STATUS,
                                searchData != null &&
                                !searchData.vAPPR_STATUS.IsNullOrWhiteSpace() &&
                                searchData.vAPPR_STATUS != "All")
                         .Where(x => x.APLY_NO == aply_No, !aply_No.IsNullOrWhiteSpace())
                         .AsEnumerable()
                         .Select(x => new TreasuryMailTimeHistoryViewModel()
                {
                    vAPLY_DATE         = TypeTransfer.dateTimeNToString(x.APLY_DATE),
                    vAPLY_NO           = x.APLY_NO,
                    vAPLY_UID_Name     = emps.FirstOrDefault(y => y.USR_ID == x.APLY_UID)?.EMP_NAME?.Trim(),
                    Act                = _EXEC_ACTION.FirstOrDefault(y => y.CODE == x.EXEC_ACTION)?.CODE_VALUE,
                    vSEND_TIME         = x.SEND_TIME,
                    vSEND_TIME_B       = x.SEND_TIME_B,
                    vFUNC_ID           = x.FUNC_ID,
                    vFUNC_ID_B         = x.FUNC_ID_B,
                    vINTERVAL_MIN      = x.INTERVAL_MIN?.ToString(),
                    vINTERVAL_MIN_B    = x.INTERVAL_MIN_B?.ToString(),
                    vEXEC_TIME_B       = x.EXEC_TIME_B,
                    vEXEC_TIME_B_B     = x.EXEC_TIME_B_B,
                    vEXEC_TIME_E       = x.EXEC_TIME_E,
                    vEXEC_TIME_E_B     = x.EXEC_TIME_E_B,
                    vTREA_OPEN_TIME    = x.TREA_OPEN_TIME,
                    vTREA_OPEN_TIME_B  = x.TREA_OPEN_TIME_B,
                    vMAIL_CONTENT_ID   = x.MAIL_CONTENT_ID,
                    vMAIL_CONTENT_ID_B = x.MAIL_CONTENT_ID_B,
                    vMEMO              = x.MEMO,
                    vMEMO_B            = x.MEMO_B,
                    vIS_DISABLED       = _Is_Disabled.FirstOrDefault(y => y.CODE == x.IS_DISABLED)?.CODE_VALUE,
                    vIS_DISABLED_B     = _Is_Disabled.FirstOrDefault(y => y.CODE == x.IS_DISABLED_B)?.CODE_VALUE,
                    vAPPR_STATUS       = _Appr_Status.FirstOrDefault(y => y.CODE == x.APPR_STATUS)?.CODE_VALUE,
                    vAPPR_DESC         = x.APPR_DESC
                }).ToList();
            }

            return(result);
        }
Esempio n. 9
0
        protected void SetDetail(string aply_No)
        {
            var depts = new List <VW_OA_DEPT>();
            var emps  = new List <V_EMPLY2>();

            _REC = new REC();
            //var sys
            using (DB_INTRAEntities dbINTRA = new DB_INTRAEntities())
            {
                depts = dbINTRA.VW_OA_DEPT.AsNoTracking().Where(x => x.DPT_CD != null).ToList();
                emps  = dbINTRA.V_EMPLY2.AsNoTracking().ToList();
            }
            using (TreasuryDBEntities db = new TreasuryDBEntities())
            {
                var treaItems = db.TREA_ITEM.AsNoTracking().Where(x => x.ITEM_OP_TYPE == "3").ToList();
                var data      = db.TREA_APLY_REC.AsNoTracking().FirstOrDefault(x => x.APLY_NO == aply_No);
                ////////////Bianco////////////
                var status = db.SYS_CODE.AsNoTracking().Where(x => x.CODE_TYPE == "FORM_STATUS");

                var _dept = new INTRA().getDept(data.APLY_UNIT);
                if (_dept != null)
                {
                    if (_dept.Dpt_type != null)
                    {
                        switch (_dept.Dpt_type.Trim())
                        {
                        case "04":     //科
                            _REC.APLY_DEPT = _dept.UP_DPT_CD?.Trim();
                            _REC.APLY_SECT = _dept.DPT_CD?.Trim();
                            break;

                        case "03":     //部
                        case "02":     //營管
                            _REC.APLY_DEPT = _dept.DPT_CD?.Trim();
                            break;
                        }
                    }
                }
                _REC.APLY_NO              = data.APLY_NO;                                                         //申請單號
                _REC.ACCESS_TYPE          = data.ACCESS_TYPE == "P" ? "存入" : data.ACCESS_TYPE == "G" ? "取出" : ""; //動作 存入/取出
                _REC.APLY_DT              = TypeTransfer.dateTimeNToString(data.CREATE_DT);                       //申請日期
                _REC.ITEM_ID              = treaItems.FirstOrDefault(x => x.ITEM_ID == data.ITEM_ID)?.ITEM_DESC;  //作業項目
                _REC.APLY_UNIT            = getEmpName(depts, data.APLY_UNIT);                                    //權責部門
                _REC.ACCESS_REASON        = data.ACCESS_REASON;                                                   //申請原因
                _REC.EXPECTED_ACCESS_DATE = TypeTransfer.dateTimeNToString(data.EXPECTED_ACCESS_DATE);            //預計存取日期
                //申請單位
                var APLY_APPR = getDeptName(emps, data.APLY_APPR_UID);                                            //覆核人員資料
                _REC.APLY_APPR_UID_UNIT = APLY_APPR.Item1;                                                        //覆核人員單位
                _REC.APLY_APPR_UID      = APLY_APPR.Item2;                                                        //覆核人員名稱
                var APLY = getDeptName(emps, data.APLY_UID);                                                      //申請人員資料
                _REC.APLY_UID_UNIT = APLY.Item1;                                                                  //申請人員單位
                _REC.APLY_UID      = APLY.Item2;                                                                  //申請人員名稱
                //保管單位
                var CUSTODY_APPR = getDeptName(emps, data.CUSTODY_APPR_UID);                                      //覆核人員資料
                _REC.CUSTODY_APPR_UID_UNIT = CUSTODY_APPR.Item1;                                                  //覆核人員單位
                _REC.CUSTODY_APPR_UID      = CUSTODY_APPR.Item2;                                                  //覆核人員名稱
                var CUSTODY = getDeptName(emps, data.CUSTODY_UID);                                                //承辦人員資料
                _REC.CUSTODY_UID_UNIT = CUSTODY.Item1;                                                            //承辦人員單位
                _REC.CUSTODY_UID      = CUSTODY.Item2;                                                            //承辦人員名稱
                _REC.APLY_STATUS      = getStatue(data.APLY_STATUS);                                              //申請狀態
            }
        }
Esempio n. 10
0
        public JsonResult Estate_Upload()
        {
            MSGReturnModel <JsonResult> result = new MSGReturnModel <JsonResult>();

            try
            {
                #region 前端無傳送檔案進來


                if (!Request.Files.AllKeys.Any())
                {
                    result.RETURN_FLAG = false;
                    result.DESCRIPTION = Ref.MessageType.upload_Not_Find.GetDescription();
                    return(Json(result));
                }

                var FileModel = Request.Files["UploadedFile"];
                //string type = Request.Form["type"];

                #endregion 前端無傳送檔案進來

                #region 前端檔案大小不符或不為Excel檔案(驗證)

                //ModelState
                if (!ModelState.IsValid)
                {
                    result.RETURN_FLAG = false;
                    result.DESCRIPTION = Ref.MessageType.excel_Validate.GetDescription();
                    return(Json(result));
                }

                #endregion 前端檔案大小不符或不為Excel檔案(驗證)

                #region  傳檔案

                string pathType = Path.GetExtension(FileModel.FileName)
                                  .Substring(1);      //上傳的檔案類型

                var fileName = string.Format("{0}.{1}",
                                             Ref.ExcelName.Estate.GetDescription(),
                                             pathType); //固定轉成此名稱

                //Cache.Invalidate(CacheList.A59ExcelName); //清除 Cache
                //Cache.Set(CacheList.A59ExcelName, fileName); //把資料存到 Cache

                #region 檢查是否有FileUploads資料夾,如果沒有就新增 並加入 excel 檔案

                string projectFile = Server.MapPath("~/" + SetFile.FileUploads); //專案資料夾
                string path        = Path.Combine(projectFile, fileName);

                FileRelated.createFile(projectFile); //檢查是否有FileUploads資料夾,如果沒有就新增

                //呼叫上傳檔案 function
                result = FileRelated.FileUpLoadinPath <JsonResult>(path, FileModel);
                if (!result.RETURN_FLAG)
                {
                    return(Json(result));
                }

                #endregion 檢查是否有FileUploads資料夾,如果沒有就新增 並加入 excel 檔案

                #region 讀取Excel資料 使用ExcelDataReader 並且組成 json

                var stream = FileModel.InputStream;
                List <FileEstateModel> dataModel = new List <FileEstateModel>();
                var Estateresult = new FileService().getExcel(pathType, path, Ref.ExcelName.Estate);
                if (Estateresult.Item1.IsNullOrWhiteSpace())
                {
                    dataModel = Estateresult.Item2.Cast <FileEstateModel>().ToList();
                }
                else
                {
                    result.RETURN_FLAG = false;
                    result.DESCRIPTION = Estateresult.Item1;
                    return(Json(result));
                }
                if (dataModel.Count > 0)
                {
                    if (Cache.IsSet(CacheList.ESTATEData))
                    {
                        var tempData = (List <EstateDetailViewModel>)Cache.Get(CacheList.ESTATEData);
                        dataModel.ForEach(x =>
                        {
                            tempData.Add(new EstateDetailViewModel()
                            {
                                vItemId            = Guid.NewGuid().ToString(),
                                vEstate_From_No    = x.ESTATE_FORM_NO,
                                vEstate_Date       = TypeTransfer.dateTimeNToString(TypeTransfer.stringToADDateTimeN(x.ESTATE_DATE)),
                                vEstate_Seq        = x.ESTATE_SEQ,
                                vHouse_No          = x.HOUSE_NO,
                                vLand_Building_No  = x.LAND_BUILDING_NO,
                                vMemo              = x.MEMO,
                                vOwnership_Cert_No = x.OWNERSHIP_CERT_NO,
                                vStatus            = Ref.AccessInventoryType._3.GetDescription()
                            });
                        });
                        Cache.Invalidate(CacheList.ESTATEData);
                        Cache.Set(CacheList.ESTATEData, tempData);
                        List <string> sames = new List <string>();
                        tempData.ForEach(y =>
                        {
                            var tempData2 = tempData.Where(x => x.vItemId != y.vItemId).ToList();
                            bool sameFlag = //位(字號;地/建號;門牌號;流水號/編號等欄位)建置相同值時,系統提醒建相同資料的訊息(但不影響資料的建置)
                                            ((!y.vOwnership_Cert_No.IsNullOrWhiteSpace()) && tempData2.Where(x => x.vOwnership_Cert_No != null).Where(x => x.vOwnership_Cert_No?.Trim() == y.vOwnership_Cert_No?.Trim()).Any()) ||
                                            ((!y.vLand_Building_No.IsNullOrWhiteSpace()) && tempData2.Where(x => x.vLand_Building_No != null).Where(x => x.vLand_Building_No?.Trim() == y.vLand_Building_No?.Trim()).Any()) ||
                                            ((!y.vHouse_No.IsNullOrWhiteSpace()) && tempData2.Where(x => x.vHouse_No != null).Where(x => x.vHouse_No?.Trim() == y.vHouse_No?.Trim()).Any()) ||
                                            ((!y.vEstate_Seq.IsNullOrWhiteSpace()) && tempData2.Where(x => x.vEstate_Seq != null).Where(x => x.vEstate_Seq?.Trim() == y.vEstate_Seq?.Trim()).Any());
                            if (sameFlag)
                            {
                                sames.Add($@"字號:{y.vOwnership_Cert_No},地/建號:{y.vLand_Building_No},門牌號:{y.vHouse_No},流水號/編號:{y.vEstate_Seq}");
                            }
                        });
                        result.RETURN_FLAG = true;
                        result.DESCRIPTION = Ref.MessageType.upload_Success.GetDescription();
                        if (sames.Any())
                        {
                            result.DESCRIPTION = Ref.MessageType.upload_Success.GetDescription(null, "<br/>以下資料欄位驗證有重複<br/>" + string.Join("<br/>", sames));
                        }
                    }
                }
                else
                {
                    result.RETURN_FLAG = false;
                    result.DESCRIPTION = Ref.MessageType.data_Not_Compare.GetDescription();
                }

                #endregion 讀取Excel資料 使用ExcelDataReader 並且組成 json

                #endregion  傳檔案
            }
            catch (Exception ex)
            {
                result.RETURN_FLAG = false;
                result.DESCRIPTION = ex.Message;
            }
            return(Json(result));
        }