Пример #1
0
        public JsonResult Transfer()
        {
            MSGReturnModel result = new MSGReturnModel();

            try
            {
                #region 抓Excel檔案 轉成 model

                // Excel 檔案位置
                DateTime startTime   = DateTime.Now;
                string   projectFile = Server.MapPath("~/" + SetFile.FileUploads);
                string   fileName    = string.Empty;
                if (Cache.IsSet(CacheList.A59ExcelName))
                {
                    fileName = (string)Cache.Get(CacheList.A59ExcelName);  //從Cache 抓資料
                }
                if (fileName.IsNullOrWhiteSpace())
                {
                    result.RETURN_FLAG = false;
                    result.DESCRIPTION = Message_Type.time_Out.GetDescription();
                }

                string     path   = Path.Combine(projectFile, fileName);
                FileStream stream = System.IO.File.Open(path, FileMode.Open, FileAccess.Read);

                string pathType = path.Split('.')[1]; //抓副檔名
                List <A59ViewModel> dataModel = A5Repository.getA59Excel(pathType, stream);
                #endregion 抓Excel檔案 轉成 model

                #region txtlog 檔案名稱

                string txtpath = SetFile.A59TransferTxtLog; //預設txt名稱

                #endregion txtlog 檔案名稱

                #region save 資料

                #region save A59(A59=>A57=>A58)

                MSGReturnModel resultA59 = A5Repository.saveA59(dataModel);                                                                //save to DB
                bool           A59Log    = CommonFunction.saveLog(Table_Type.A59, fileName, SetFile.ProgramName,
                                                                  resultA59.RETURN_FLAG, Debt_Type.B.ToString(), startTime, DateTime.Now); //寫sql Log
                TxtLog.txtLog(Table_Type.A59, resultA59.RETURN_FLAG, startTime, txtLocation(txtpath));                                     //寫txt Log

                #endregion save A59(A59=>A57=>A58)
                result = resultA59;

                #endregion save 資料
            }
            catch (Exception ex)
            {
                result.RETURN_FLAG = false;
                result.DESCRIPTION = Message_Type.save_Fail
                                     .GetDescription(null, ex.Message);
            }
            return(Json(result));
        }
Пример #2
0
        public JsonResult Transfer()
        {
            MSGReturnModel result = new MSGReturnModel();

            try
            {
                #region 抓Excel檔案 轉成 model

                // Excel 檔案位置
                DateTime startTime   = DateTime.Now;
                string   projectFile = Server.MapPath("~/" + SetFile.FileUploads);

                string fileName = string.Empty;
                if (Cache.IsSet(CacheList.A71ExcelName))
                {
                    fileName = (string)Cache.Get(CacheList.A71ExcelName);  //從Cache 抓資料
                }
                if (fileName.IsNullOrWhiteSpace())
                {
                    result.RETURN_FLAG = false;
                    result.DESCRIPTION = Message_Type.time_Out.GetDescription();
                }

                string     path   = Path.Combine(projectFile, fileName);
                FileStream stream = System.IO.File.Open(path, FileMode.Open, FileAccess.Read);

                string pathType = path.Split('.')[1];                                      //抓副檔名
                List <Exhibit29Model> dataModel = A7Repository.getExcel(pathType, stream); //Excel轉成 Exhibit29Model

                #endregion 抓Excel檔案 轉成 model

                #region txtlog 檔案名稱

                string txtpath       = SetFile.A71TransferTxtLog; //預設txt名稱
                string configTxtName = ConfigurationManager.AppSettings["txtLogA7Name"];
                if (!string.IsNullOrWhiteSpace(configTxtName))
                {
                    txtpath = configTxtName; //有設定webConfig且不為空就取代
                }
                #endregion txtlog 檔案名稱

                #region save 資料

                #region save Moody_Tm_YYYY(A71)

                MSGReturnModel resultA71 = A7Repository.saveA71(dataModel);                                                                //save to DB
                bool           A71Log    = CommonFunction.saveLog(Table_Type.A71, fileName, SetFile.ProgramName,
                                                                  resultA71.RETURN_FLAG, Debt_Type.B.ToString(), startTime, DateTime.Now); //寫sql Log
                TxtLog.txtLog(Table_Type.A71, resultA71.RETURN_FLAG, startTime, txtLocation(txtpath));                                     //寫txt Log

                #endregion save Moody_Tm_YYYY(A71)

                #region save Tm_Adjust_YYYY(A72)

                MSGReturnModel resultA72 = A7Repository.saveA72();                                                                         //save to DB
                bool           A72Log    = CommonFunction.saveLog(Table_Type.A72, fileName, SetFile.ProgramName,
                                                                  resultA72.RETURN_FLAG, Debt_Type.B.ToString(), startTime, DateTime.Now); //寫sql Log
                TxtLog.txtLog(Table_Type.A72, resultA72.RETURN_FLAG, startTime, txtLocation(txtpath));                                     //寫txt Log

                #endregion save Tm_Adjust_YYYY(A72)

                #region save GM_YYYY(A73)

                MSGReturnModel resultA73 = A7Repository.saveA73();                                                                         //save to DB
                bool           A73Log    = CommonFunction.saveLog(Table_Type.A73, fileName, SetFile.ProgramName,
                                                                  resultA73.RETURN_FLAG, Debt_Type.B.ToString(), startTime, DateTime.Now); //寫sql Log
                TxtLog.txtLog(Table_Type.A73, resultA73.RETURN_FLAG, startTime, txtLocation(txtpath));                                     //寫txt Log

                #endregion save GM_YYYY(A73)

                #region save Grade_Moody_Info(A51)

                MSGReturnModel resultA51 = A7Repository.saveA51();                                                                         //save to DB
                bool           A51Log    = CommonFunction.saveLog(Table_Type.A51, fileName, SetFile.ProgramName,
                                                                  resultA51.RETURN_FLAG, Debt_Type.B.ToString(), startTime, DateTime.Now); //寫sql Log
                TxtLog.txtLog(Table_Type.A51, resultA51.RETURN_FLAG, startTime, txtLocation(txtpath));                                     //寫txt Log

                #endregion save Grade_Moody_Info(A51)

                result.RETURN_FLAG = resultA71.RETURN_FLAG &&
                                     resultA72.RETURN_FLAG &&
                                     resultA73.RETURN_FLAG &&
                                     resultA51.RETURN_FLAG;

                result.DESCRIPTION = Message_Type.save_Success.GetDescription(
                    string.Format("{0},{1},{2},{3}",
                                  Table_Type.A71.ToString(),
                                  Table_Type.A72.ToString(),
                                  Table_Type.A73.ToString(),
                                  Table_Type.A51.ToString()
                                  ));

                if (!result.RETURN_FLAG)
                {
                    List <string> errs = new List <string>();
                    if (!resultA71.RETURN_FLAG)
                    {
                        errs.Add(resultA71.DESCRIPTION);
                    }
                    if (!resultA72.RETURN_FLAG)
                    {
                        errs.Add(resultA72.DESCRIPTION);
                    }
                    if (!resultA73.RETURN_FLAG)
                    {
                        errs.Add(resultA73.DESCRIPTION);
                    }
                    if (!resultA51.RETURN_FLAG)
                    {
                        errs.Add(resultA51.DESCRIPTION);
                    }

                    result.DESCRIPTION = Message_Type.save_Fail
                                         .GetDescription(null, string.Join("\n", errs));
                }

                #endregion save 資料
            }
            catch (Exception ex)
            {
                result.RETURN_FLAG = false;
                result.DESCRIPTION = Message_Type.save_Fail
                                     .GetDescription(null, ex.Message);
            }
            return(Json(result));
        }
        public JsonResult Transfer()
        {
            MSGReturnModel result = new MSGReturnModel();

            try
            {
                #region 抓Excel檔案 轉成 model

                // Excel 檔案位置
                DateTime startTime   = DateTime.Now;
                string   projectFile = Server.MapPath("~/" + SetFile.FileUploads);
                string   fileName    = string.Empty;
                if (Cache.IsSet(CacheList.A62ExcelName))
                {
                    fileName = (string)Cache.Get(CacheList.A62ExcelName);  //從Cache 抓資料
                }
                if (fileName.IsNullOrWhiteSpace())
                {
                    result.RETURN_FLAG = false;
                    result.DESCRIPTION = Message_Type.time_Out.GetDescription();
                }

                string     path   = Path.Combine(projectFile, fileName);
                FileStream stream = System.IO.File.Open(path, FileMode.Open, FileAccess.Read);

                string pathType = path.Split('.')[1];                                     //抓副檔名
                List <Exhibit7Model> dataModel = A6Repository.getExcel(pathType, stream); //Excel轉成 Exhibit7Model

                #endregion 抓Excel檔案 轉成 model

                #region txtlog 檔案名稱

                string txtpath       = SetFile.A62TransferTxtLog; //預設txt名稱
                string configTxtName = ConfigurationManager.AppSettings["txtLogA6Name"];
                if (!string.IsNullOrWhiteSpace(configTxtName))
                {
                    txtpath = configTxtName; //有設定webConfig且不為空就取代
                }
                #endregion txtlog 檔案名稱

                #region save 資料

                #region save Tm_Adjust_YYYY(A62)

                MSGReturnModel resultA62 = A6Repository.saveA62(dataModel);                                                                //save to DB
                bool           A62Log    = CommonFunction.saveLog(Table_Type.A62, fileName, SetFile.ProgramName,
                                                                  resultA62.RETURN_FLAG, Debt_Type.B.ToString(), startTime, DateTime.Now); //寫sql Log
                TxtLog.txtLog(Table_Type.A62, resultA62.RETURN_FLAG, startTime, txtLocation(txtpath));                                     //寫txt Log

                #endregion save Tm_Adjust_YYYY(A62)

                result = resultA62;

                #endregion save 資料
            }
            catch (Exception ex)
            {
                result.RETURN_FLAG = false;
                result.DESCRIPTION = Message_Type.save_Fail
                                     .GetDescription(null, ex.Message);
            }
            return(Json(result));
        }
        public JsonResult Transfer(string reportDate, string version)
        {
            MSGReturnModel result = new MSGReturnModel();

            try
            {
                #region 抓Excel檔案 轉成 model

                // Excel 檔案位置
                DateTime startTime   = DateTime.Now;
                string   projectFile = Server.MapPath("~/" + SetFile.FileUploads);

                string fileName = string.Empty;
                if (Cache.IsSet(CacheList.A41ExcelName))
                {
                    fileName = (string)Cache.Get(CacheList.A41ExcelName);  //從Cache 抓資料
                }
                if (fileName.IsNullOrWhiteSpace())
                {
                    result.RETURN_FLAG = false;
                    result.DESCRIPTION = Message_Type.time_Out.GetDescription();
                }

                string     path   = Path.Combine(projectFile, fileName);
                FileStream stream = System.IO.File.Open(path, FileMode.Open, FileAccess.Read);

                string pathType = path.Split('.')[1];                                    //抓副檔名
                List <A41ViewModel> dataModel = A4Repository.getExcel(pathType, stream); //Excel轉成 Exhibit10Model

                #endregion 抓Excel檔案 轉成 model

                #region txtlog 檔案名稱

                string txtpath       = SetFile.A41TransferTxtLog; //預設txt名稱
                string configTxtName = ConfigurationManager.AppSettings["txtLogA4Name"];
                if (!string.IsNullOrWhiteSpace(configTxtName))
                {
                    txtpath = configTxtName; //有設定webConfig且不為空就取代
                }
                #endregion txtlog 檔案名稱

                #region save Bond_Account_Info(A41)

                MSGReturnModel resultA41 = A4Repository.saveA41(dataModel, reportDate, version); //save to DB
                bool           A41Log    = CommonFunction.saveLog(Table_Type.A41,
                                                                  fileName, SetFile.ProgramName, resultA41.RETURN_FLAG,
                                                                  Debt_Type.B.ToString(), startTime, DateTime.Now); //寫sql Log
                TxtLog.txtLog(Table_Type.A41, resultA41.RETURN_FLAG, startTime, txtLocation(txtpath));              //寫txt Log

                #endregion save Bond_Account_Info(A41)

                result.RETURN_FLAG = resultA41.RETURN_FLAG;
                result.DESCRIPTION = Message_Type.save_Success.GetDescription(Table_Type.A41.ToString());

                if (!result.RETURN_FLAG)
                {
                    result.DESCRIPTION = Message_Type.save_Fail
                                         .GetDescription(Table_Type.A41.ToString(), resultA41.DESCRIPTION);
                }
            }
            catch (Exception ex)
            {
                result.RETURN_FLAG = false;
                result.DESCRIPTION = ex.Message;
            }
            return(Json(result));
        }
Пример #5
0
        public JsonResult TransferC10(string reportDate)
        {
            MSGReturnModel result = new MSGReturnModel();

            try
            {
                #region 抓Excel檔案 轉成 model

                // Excel 檔案位置

                string projectFile = Server.MapPath("~/" + SetFile.FileUploads);

                string fileName = string.Empty;
                if (Cache.IsSet(CacheList.C10ExcelName))
                {
                    fileName = (string)Cache.Get(CacheList.C10ExcelName);  //從Cache 抓資料Name
                }
                if (fileName.IsNullOrWhiteSpace())
                {
                    result.RETURN_FLAG = false;
                    result.DESCRIPTION = Message_Type.time_Out.GetDescription();
                    return(Json(result));
                }

                string path = Path.Combine(projectFile, fileName);

                List <C10ViewModel> dataModel = new List <C10ViewModel>();

                DateTime dt = DateTime.MinValue;
                DateTime.TryParse(reportDate, out dt);

                string errorMessage = string.Empty;

                using (FileStream stream = System.IO.File.Open(path, FileMode.Open, FileAccess.Read))
                {
                    string pathType = path.Split('.')[1]; //抓副檔名
                    var    data     = C0Repository.getExcel(pathType, stream, dt);
                    dataModel    = data.Item2;
                    errorMessage = data.Item1;
                }
                if (!errorMessage.IsNullOrWhiteSpace())
                {
                    result.RETURN_FLAG = false;
                    result.DESCRIPTION = errorMessage;
                    return(Json(result));
                }
                #endregion 抓Excel檔案 轉成 model

                #region txtlog 檔案名稱


                string txtpath       = SetFile.C10TransferTxtLog; //預設txt名稱
                string configTxtName = ConfigurationManager.AppSettings["txtLogC0Name"];
                if (!string.IsNullOrWhiteSpace(configTxtName))
                {
                    txtpath = configTxtName; //有設定webConfig且不為空就取代
                }
                #endregion txtlog 檔案名稱

                #region save C10



                MSGReturnModel resultC10 = C0Repository.saveC10(dataModel, reportDate); //save to DB

                int v = 0;                                                              ///上傳檔案,版本皆為0

                bool C10Log = CommonFunction.saveLog(Table_Type.C10,
                                                     fileName, SetFile.ProgramName, resultC10.RETURN_FLAG,
                                                     Debt_Type.B.ToString(), startTime, DateTime.Now, AccountController.CurrentUserInfo.Name, v, dt); //寫sql Log
                TxtLog.txtLog(Table_Type.C10, resultC10.RETURN_FLAG, startTime, txtLocation(txtpath));                                                //寫txt Log

                #endregion save C10

                result.RETURN_FLAG = resultC10.RETURN_FLAG;
                result.DESCRIPTION = Message_Type.save_Success.GetDescription(Table_Type.C10.ToString());

                if (!result.RETURN_FLAG)
                {
                    result.DESCRIPTION = Message_Type.save_Fail
                                         .GetDescription(Table_Type.C10.ToString(), resultC10.DESCRIPTION);
                }
            }
            catch (Exception ex)
            {
                result.RETURN_FLAG = false;
                result.DESCRIPTION = ex.Message;
            }
            return(Json(result));
        }
Пример #6
0
        public JsonResult TransferA96()
        {
            MSGReturnModel result = new MSGReturnModel();

            try
            {
                #region 抓Excel檔案 轉成 model

                // Excel 檔案位置

                string projectFile = Server.MapPath("~/" + SetFile.FileUploads);

                string fileName = string.Empty;
                if (Cache.IsSet(CacheList.A96ExcelName))
                {
                    fileName = (string)Cache.Get(CacheList.A96ExcelName);  //從Cache 抓資料
                }
                if (fileName.IsNullOrWhiteSpace())
                {
                    result.RETURN_FLAG = false;
                    result.DESCRIPTION = Message_Type.time_Out.GetDescription();
                    return(Json(result));
                }

                string path = Path.Combine(projectFile, fileName);

                List <A96ViewModel> dataModel = new List <A96ViewModel>();

                string errorMessage = string.Empty;

                using (FileStream stream = System.IO.File.Open(path, FileMode.Open, FileAccess.Read))
                {
                    //Excel轉成 Exhibit10Model
                    string pathType = path.Split('.')[1]; //抓副檔名
                    var    data     = A9Repository.getA96Excel(pathType, stream);
                    dataModel    = data.Item2;
                    errorMessage = data.Item1;
                }
                if (!errorMessage.IsNullOrWhiteSpace())
                {
                    result.RETURN_FLAG = false;
                    result.DESCRIPTION = errorMessage;
                    return(Json(result));
                }
                #endregion 抓Excel檔案 轉成 model

                #region txtlog 檔案名稱

                string txtpath = SetFile.A96TransferTxtLog; //預設txt名稱

                #endregion txtlog 檔案名稱

                #region save Bond_Spread_Info(A96)

                MSGReturnModel resultA96 = A9Repository.saveA96(dataModel); //save to DB
                CommonFunction.saveLog(Table_Type.A96,
                                       fileName, SetFile.ProgramName, resultA96.RETURN_FLAG,
                                       Debt_Type.B.ToString(), startTime, DateTime.Now, AccountController.CurrentUserInfo.Name); //寫sql Log
                TxtLog.txtLog(Table_Type.A96, resultA96.RETURN_FLAG, startTime, txtLocation(txtpath));                           //寫txt Log

                #endregion save Bond_Spread_Info(A96)

                result.RETURN_FLAG = resultA96.RETURN_FLAG;
                result.DESCRIPTION = Message_Type.save_Success.GetDescription(Table_Type.A96.ToString());

                if (!result.RETURN_FLAG)
                {
                    result.DESCRIPTION = Message_Type.save_Fail
                                         .GetDescription(Table_Type.A96.ToString(), resultA96.DESCRIPTION);
                }
            }
            catch (Exception ex)
            {
                result.RETURN_FLAG = false;
                result.DESCRIPTION = ex.exceptionMessage();
            }
            return(Json(result));
        }
Пример #7
0
        public JsonResult autoTransfer(string datepicker, string version)
        {
            string         sType               = "原始投資信評";
            string         portfolio           = "All";
            string         search              = "Miss";
            string         from                = "";
            string         to                  = "";
            string         bondNumber          = "";
            MSGReturnModel result_searchA58    = new MSGReturnModel();
            MSGReturnModel result_getA59       = new MSGReturnModel();
            MSGReturnModel result_saveA59Excel = new MSGReturnModel();
            MSGReturnModel result_autoTransfer = new MSGReturnModel();

            result_searchA58.RETURN_FLAG    = false;
            result_getA59.RETURN_FLAG       = false;
            result_autoTransfer.RETURN_FLAG = false;
            #region 找A58缺漏
            var A58Data = A5Repository.GetA58(datepicker, sType, from, to, bondNumber, version, search, portfolio);
            result_searchA58.RETURN_FLAG = A58Data.Item1;
            #endregion
            #region 轉入寶碩信評資料
            if (!A58Data.Item1)
            {
                result_searchA58.DESCRIPTION = Message_Type.not_Find_Any.GetDescription();
                return(Json(result_searchA58));
            }
            var A59Data = A5Repository.getA59(A58Data.Item2, datepicker);
            if (!A59Data.Item1)
            {
                result_getA59.DESCRIPTION = Message_Type.not_Find_CounterPartyCreditRating.GetDescription();
                GetCheckDataToCache();
                return(Json(result_getA59));
            }

            #region 產excel出來
            var A59Filled = Excel_DownloadName.A59Filled.ToString();
            var fileName  = string.Format("{0}.{1}", Excel_DownloadName.A59Filled.GetDescription(), "xlsx"); //固定轉成此名稱

            //檢查資料夾是否存在
            string projectFile = Server.MapPath("~/" + SetFile.FileUploads); //專案資料夾
            string path        = Path.Combine(projectFile, fileName);
            FileRelated.createFile(projectFile);                             //檢查是否有FileUploads資料夾,如果沒有就新增

            result_saveA59Excel = A5Repository.SaveA59Excel(A59Filled, path, A59Data.Item2);
            //儲存excel失敗不用中止,只要記錄就好
            DateTime startTime  = DateTime.Now;
            DateTime reportdate = DateTime.MinValue;
            DateTime.TryParse(datepicker, out reportdate);
            bool A59Log = CommonFunction.saveLog(Table_Type.A59, fileName, SetFile.ProgramName,
                                                 result_saveA59Excel.RETURN_FLAG, Debt_Type.B.ToString(), startTime, DateTime.Now, AccountController.CurrentUserInfo.Name, Convert.ToInt32(version), reportdate); //寫sql Log

            #endregion 測試產excel出來看

            #endregion

            #region 更新A57、A58
            #region txtlog 檔案名稱

            string txtpath = SetFile.A59TransferTxtLog; //預設txt名稱

            #endregion txtlog 檔案名稱

            #region save A59(A59=>A57=>A58)
            DateTime st_saveA59 = DateTime.Now;
            result_autoTransfer = A5Repository.saveA59(A59Data.Item2);
            A5Repository.SaveA59TransLog(result_autoTransfer, datepicker, st_saveA59, Convert.ToInt32(version));
            TxtLog.txtLog(Table_Type.A59Trans, result_autoTransfer.RETURN_FLAG, st_saveA59, txtLocation(txtpath)); //寫txt Log

            #endregion save A59(A59=>A57=>A58)
            #endregion 更新A57、A58
            #region 執行檢核
            A5Repository.GetA58TransferCheck(reportdate, Convert.ToInt32(version));
            GetCheckDataToCache();
            #endregion 執行檢核

            return(Json(result_autoTransfer));
        }