Пример #1
0
        public MSGReturnModel saveA94(string actionType, A94ViewModel dataModel)
        {
            MSGReturnModel result = new MSGReturnModel();

            using (IFRS9DBEntities db = new IFRS9DBEntities())
            {
                try
                {
                    Gov_Info_Ticker editData = new Gov_Info_Ticker();

                    if (actionType == "Add")
                    {
                        if (db.Gov_Info_Ticker.AsNoTracking()
                            .Where(x => x.Country == dataModel.Country)
                            .FirstOrDefault() != null)
                        {
                            result.RETURN_FLAG = false;
                            result.DESCRIPTION = "資料重複:您輸入的 國家 已存在";
                            return(result);
                        }

                        editData.Country = dataModel.Country;
                    }
                    else if (actionType == "Modify")
                    {
                        editData = db.Gov_Info_Ticker
                                   .Where(x => x.Country == dataModel.Country)
                                   .FirstOrDefault();
                    }

                    editData.IGS_Index_Map        = dataModel.IGS_Index_Map;
                    editData.Short_term_Debt_Map  = dataModel.Short_term_Debt_Map;
                    editData.Foreign_Exchange_Map = dataModel.Foreign_Exchange_Map;
                    editData.GDP_Yearly_Map       = dataModel.GDP_Yearly_Map;

                    if (actionType == "Add")
                    {
                        db.Gov_Info_Ticker.Add(editData);
                    }

                    db.SaveChanges(); //Save

                    result.RETURN_FLAG = true;
                }
                catch (Exception ex)
                {
                    result.RETURN_FLAG = false;
                    result.DESCRIPTION = ex.Message;
                }
            }

            return(result);
        }
Пример #2
0
        public MSGReturnModel saveIssuerTicker(string actionType, IssuerTickerViewModel dataModel)
        {
            MSGReturnModel result = new MSGReturnModel();

            using (IFRS9DBEntities db = new IFRS9DBEntities())
            {
                try
                {
                    if (actionType == "Add")
                    {
                        if (db.Issuer_Ticker.AsNoTracking()
                            .Where(x => x.Issuer == dataModel.Issuer)
                            .Count() > 0)
                        {
                            result.RETURN_FLAG = false;
                            result.DESCRIPTION = string.Format("資料重複:{0} 已存在", dataModel.Issuer);
                            return(result);
                        }

                        Issuer_Ticker addData = new Issuer_Ticker();

                        addData.Issuer = dataModel.Issuer;
                        addData.ISSUER_EQUITY_TICKER = dataModel.ISSUER_EQUITY_TICKER;
                        addData.Create_User          = _UserInfo._user;
                        addData.Create_Time          = _UserInfo._time;
                        addData.Create_Date          = _UserInfo._date;
                        db.Issuer_Ticker.Add(addData);
                    }
                    else if (actionType == "Modify")
                    {
                        Issuer_Ticker oldData = db.Issuer_Ticker
                                                .Where(x => x.Issuer == dataModel.Issuer)
                                                .FirstOrDefault();

                        oldData.ISSUER_EQUITY_TICKER = dataModel.ISSUER_EQUITY_TICKER;
                        oldData.LastUpdate_User      = _UserInfo._user;
                        oldData.LastUpdate_Date      = _UserInfo._date;
                        oldData.LastUpdate_Time      = _UserInfo._time;
                    }

                    db.SaveChanges();

                    result.RETURN_FLAG = true;
                }
                catch (DbUpdateException ex)
                {
                    result.RETURN_FLAG = false;
                    result.DESCRIPTION = ex.Message;
                }
            }

            return(result);
        }
Пример #3
0
 /// <summary>
 /// get Moody_Predit_PD_Info(A83)
 /// </summary>
 /// <returns></returns>
 public Tuple <bool, List <Moody_Predit_PD_Info> > GetA83()
 {
     using (IFRS9DBEntities db = new IFRS9DBEntities())
     {
         if (db.Moody_Predit_PD_Info.Any())
         {
             return(new Tuple <bool, List <Moody_Predit_PD_Info> >
                        (true, db.Moody_Predit_PD_Info.AsNoTracking().ToList()));
         }
     }
     return(new Tuple <bool, List <Moody_Predit_PD_Info> >(false, new List <Moody_Predit_PD_Info>()));
 }
Пример #4
0
        /// <summary>
        /// get A96 最後交易日 資料
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        public List <A96TradeViewModel> getA96Trade(DateTime?dt)
        {
            List <A96TradeViewModel> result = new List <A96TradeViewModel>();

            using (IFRS9DBEntities db = new IFRS9DBEntities())
            {
                result = common.getViewModel(db.Bond_Spread_Trade_Info.AsNoTracking()
                                             .Where(x => x.Report_Date == dt, dt != null).AsEnumerable(),
                                             Table_Type.A96_Trade).OfType <A96TradeViewModel>().ToList();
            }
            return(result);
        }
Пример #5
0
        /// <summary>
        /// save A95_1 (產業別對應Ticker補登檔)
        /// </summary>
        /// <param name="data"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public MSGReturnModel saveA95_1(A95_1ViewModel data, Action_Type type)
        {
            MSGReturnModel result = new MSGReturnModel();

            result.RETURN_FLAG = false;
            var _tableName = Table_Type.A95_1.tableNameGetDescription();

            if (data == null || data.Bond_Number.IsNullOrWhiteSpace())
            {
                result.DESCRIPTION = Message_Type.parameter_Error.GetDescription(_tableName);
                return(result);
            }
            using (IFRS9DBEntities db = new IFRS9DBEntities())
            {
                if ((type & Action_Type.Edit) == Action_Type.Edit)
                {
                    var _edit = db.Assessment_Sub_Kind_Ticker.FirstOrDefault(x => x.Bond_Number == data.Bond_Number);
                    if (_edit == null)
                    {
                        result.DESCRIPTION = Message_Type.already_Change.GetDescription(_tableName);
                        return(result);
                    }
                    _edit.Bloomberg_Ticker = data.Bloomberg_Ticker;
                    _edit.Security_Des     = data.Security_Des;
                    _edit.LastUpdate_User  = _UserInfo._user;
                    _edit.LastUpdate_Date  = _UserInfo._date;
                    _edit.LastUpdate_Time  = _UserInfo._time;
                    result.DESCRIPTION     = Message_Type.update_Success.GetDescription(_tableName);
                }
                else if ((type & Action_Type.Dele) == Action_Type.Dele)
                {
                    var _dele = db.Assessment_Sub_Kind_Ticker.FirstOrDefault(x => x.Bond_Number == data.Bond_Number);
                    if (_dele == null)
                    {
                        result.DESCRIPTION = Message_Type.already_Change.GetDescription(_tableName);
                        return(result);
                    }
                    db.Assessment_Sub_Kind_Ticker.Remove(_dele);
                    result.DESCRIPTION = Message_Type.delete_Success.GetDescription(_tableName);
                }
                try
                {
                    db.SaveChanges();
                    result.RETURN_FLAG = true;
                }
                catch (DbUpdateException ex)
                {
                    result.DESCRIPTION = ex.exceptionMessage();
                }
            }
            return(result);
        }
Пример #6
0
        /// <summary>
        /// get A96 資料
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="version"></param>
        /// <returns></returns>
        public List <A96ViewModel> getA96(DateTime dt, int version)
        {
            List <A96ViewModel> result = new List <A96ViewModel>();

            using (IFRS9DBEntities db = new IFRS9DBEntities())
            {
                result = common.getViewModel(db.Bond_Spread_Info.AsNoTracking()
                                             .Where(x => x.Report_Date == dt &&
                                                    x.Version == version)
                                             .AsEnumerable(), Table_Type.A96).OfType <A96ViewModel>().ToList();
            }
            return(result);
        }
Пример #7
0
 public void saveD04(Flow_Apply_Status data)
 {
     using (IFRS9DBEntities db = new IFRS9DBEntities())
     {
         db.Flow_Apply_Status.Add(data);
         try
         {
             db.SaveChanges();
         }
         catch (Exception ex) {
         }
     }
 }
Пример #8
0
        /// <summary>
        /// get user debt
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public string getUserDebt(string account)
        {
            var result = string.Empty;

            using (IFRS9DBEntities db = new IFRS9DBEntities())
            {
                var _user = db.IFRS9_User.AsNoTracking().FirstOrDefault(x => x.User_Account == account);
                if (_user != null)
                {
                    result = _user.DebtType;
                }
            }
            return(result);
        }
Пример #9
0
 public Tuple <string, string> getProductInfo(string productCode)
 {
     using (IFRS9DBEntities db = new IFRS9DBEntities())
     {
         var data = db.Flow_Info.AsNoTracking().Where(x =>
                                                      x.Group_Product_Code == productCode &&
                                                      x.Apply_Off_Date == null).OrderByDescending(x => x.Apply_Off_Date)
                    .FirstOrDefault();
         if (data != null)
         {
             return(new Tuple <string, string>(data.PRJID, data.FLOWID));
         }
     }
     return(new Tuple <string, string>("", ""));
 }
Пример #10
0
 /// <summary>
 /// 轉檔紀錄存到Sql(Transfer_CheckTable)
 /// </summary>
 /// <param name="fileName">檔案名稱 A41,A42...</param>
 /// <param name="flag">成功失敗</param>
 /// <param name="reportDate">基準日</param>
 /// <param name="version">版本</param>
 /// <param name="start">轉檔開始時間</param>
 /// <param name="end">轉檔結束時間</param>
 /// <returns></returns>
 public bool saveTransferCheck(
     string fileName,
     bool flag,
     DateTime reportDate,
     int version,
     DateTime start,
     DateTime end,
     string Msg = null)
 {
     using (IFRS9DBEntities db = new IFRS9DBEntities())
     {
         if (flag && db.Transfer_CheckTable.Any(x =>
                                                x.ReportDate == reportDate &&
                                                x.Version == version &&
                                                x.File_Name == fileName &&
                                                x.TransferType == "Y"))
         {
             return(false);
         }
         if (EnumUtil.GetValues <Transfer_Table_Type>()
             .Select(x => x.ToString()).ToList().Contains(fileName))
         {
             db.Transfer_CheckTable.Add(new Transfer_CheckTable()
             {
                 File_Name    = fileName,
                 ReportDate   = reportDate,
                 Version      = version,
                 TransferType = flag ? "Y" : "N",
                 Create_date  = start.ToString("yyyyMMdd"),
                 Create_time  = start.ToString("HH:mm:ss"),
                 End_date     = end.ToString("yyyyMMdd"),
                 End_time     = end.ToString("HH:mm:ss"),
                 Process      = "Web",
                 Error_Msg    = Msg
             });
             try
             {
                 db.SaveChanges();
                 return(true);
             }
             catch
             {
                 return(false);
             }
         }
         return(false);
     }
 }
Пример #11
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)
            });
        }
Пример #12
0
        public Tuple <bool, List <A94ViewModel> > getA94(A94ViewModel dataModel)
        {
            using (IFRS9DBEntities db = new IFRS9DBEntities())
            {
                if (db.Gov_Info_Ticker.Any())
                {
                    var query = db.Gov_Info_Ticker.AsNoTracking()
                                .Where(x => x.Country == dataModel.Country, dataModel.Country.IsNullOrWhiteSpace() == false);

                    return(new Tuple <bool, List <A94ViewModel> >(query.Any(),
                                                                  query.AsEnumerable().Select(x => { return DbToA94Model(x); }).ToList()));
                }
            }

            return(new Tuple <bool, List <A94ViewModel> >(false, new List <A94ViewModel>()));
        }
Пример #13
0
 /// <summary>
 /// get Moody_LGD_Info(A62)
 /// </summary>
 /// <returns></returns>
 public Tuple <bool, List <A62ViewModel> > GetA62(string dataYear)
 {
     using (IFRS9DBEntities db = new IFRS9DBEntities())
     {
         if (db.Moody_LGD_Info.Any())
         {
             var query = from q in db.Moody_LGD_Info.AsNoTracking()
                         .Where(x => x.Data_Year == dataYear, dataYear != "All")
                         select q;
             return(new Tuple <bool,
                               List <A62ViewModel> >(query.Any(),
                                                     query.AsEnumerable().Select(x => { return DbToA62ViewModel(x); }).ToList()));
         }
     }
     return(new Tuple <bool, List <A62ViewModel> >(false, new List <A62ViewModel>()));
 }
Пример #14
0
 /// <summary>
 /// 判斷轉檔紀錄是否有存在
 /// </summary>
 /// <param name="fileNames">目前檔案名稱</param>
 /// <param name="checkName">要檢查的檔案名稱</param>
 /// <param name="reportDate">基準日</param>
 /// <param name="version">版本</param>
 /// <returns></returns>
 public bool checkTransferCheck(
     string fileName,
     string checkName,
     DateTime reportDate,
     int version)
 {
     if (fileName.IsNullOrWhiteSpace() || checkName.IsNullOrWhiteSpace())
     {
         return(false);
     }
     using (IFRS9DBEntities db = new IFRS9DBEntities())
     {
         var checkTable  = db.Transfer_CheckTable.AsNoTracking();
         var _A53Version = 0;
         if (checkName == "A53")
         {
             var _vers = checkTable.Where(x =>
                                          x.File_Name == "A53" &&
                                          x.TransferType != "R" &&
                                          x.ReportDate == reportDate).ToList();
             if (_vers.Any())
             {
                 _A53Version = _vers.Max(x => x.Version);
             }
         }
         //須符合有一筆"Y"(上一動作完成) 自己沒有"Y"(重複做) 才算符合
         if (//當 fileName,checkName 都為 A41 不用檢查(為最先動作)
             ((fileName == Table_Type.A41.ToString() &&
               checkName == Table_Type.A41.ToString()) ||
              //檢查上一動作有無成功(A53 只有一版),前置動作檢查檔案為A53版本為A53最大版
              checkTable.Any(x => x.ReportDate == reportDate &&
                             ((checkName == "A53" &&
                               x.Version == _A53Version) ||
                              (x.File_Name == checkName &&
                               x.Version == version)) &&
                             x.TransferType == "Y")) &&
             //檢查本身有無重複執行(有成功就要下一版)
             !checkTable.Any(x => x.File_Name == fileName &&
                             x.ReportDate == reportDate &&
                             x.Version == version &&
                             x.TransferType == "Y"))
         {
             return(true);
         }
     }
     return(false);
 }
Пример #15
0
        /// <summary>
        /// get Debt SelectOption
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public List <SelectOption> getDebtSelectOption(string account)
        {
            List <SelectOption> result = new List <SelectOption>()
            {
                new SelectOption()
                {
                    Text = " ", Value = " "
                }
            };

            using (IFRS9DBEntities db = new IFRS9DBEntities())
            {
                result.AddRange(getDebt("A")
                                .Select(x => debtSelectOption(x)));
            }
            return(result);
        }
Пример #16
0
        public bool checkC07(DateTime reportDate, string PRJID, string FLOWID)
        {
            bool result = false;

            using (IFRS9DBEntities db = new IFRS9DBEntities())
            {
                var _reportDate = reportDate.ToString(C07reportDateFormate);
                var _Loan_1     = Product_Code.M.GetDescription();
                result = db.EL_Data_Out.AsNoTracking()
                         .Where(x => x.Report_Date == _reportDate &&
                                x.Version == 1 &&
                                x.Product_Code == _Loan_1 &&
                                x.PRJID == PRJID &&
                                x.FLOWID == FLOWID).Any();
            }
            return(result);
        }
Пример #17
0
        public void backC07(List <EL_Data_Out> datas)
        {
            using (IFRS9DBEntities db = new IFRS9DBEntities())
            {
                StringBuilder sb = new StringBuilder();
                datas.ForEach(
                    x => {
                    sb.Append(
                        $@"
INSERT INTO [EL_Data_Out]
           ([Report_Date]
           ,[Processing_Date]
           ,[Product_Code]
           ,[Reference_Nbr]
           ,[PD]
           ,[Lifetime_EL]
           ,[Y1_EL]
           ,[EL]
           ,[Impairment_Stage]
           ,[Version]
           ,[PRJID]
           ,[FLOWID])
     VALUES
           ('{x.Report_Date}'
           ,'{x.Processing_Date}'
           ,'{x.Product_Code}'
           ,'{x.Reference_Nbr}'
           ,{x.PD}
           ,{x.Lifetime_EL}
           ,{x.Y1_EL}
           ,{x.EL}
           ,'{x.Impairment_Stage}'
           ,{x.Version}
           ,'{x.PRJID}'
           ,'{x.FLOWID}') ; ");
                });
                try
                {
                    if (sb.Length > 0)
                    {
                        db.Database.ExecuteSqlCommand(sb.ToString());
                    }
                }
                catch { }
            }
        }
Пример #18
0
        public static IFRS9DBEntities UpdateToContext <T>(IFRS9DBEntities context,
                                                          T entity, int count, int commitCount, bool recreateContext) where T : class
        {
            if (count % commitCount == 0)
            {
                context.SaveChanges();
                if (recreateContext)
                {
                    context.Dispose();
                    context = new IFRS9DBEntities();
                    context.Configuration.AutoDetectChangesEnabled = false;
                    context.Configuration.ValidateOnSaveEnabled    = false;
                }
            }

            return(context);
        }
Пример #19
0
        /// <summary>
        /// get User Name
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public string GetUserName(string data)
        {
            List <string> result = new List <string>();

            using (IFRS9DBEntities db = new IFRS9DBEntities())
            {
                result = db.IFRS9_User
                         .AsNoTracking()
                         .Where(x => x.User_Account == data)
                         .Select(x => x.User_Name)
                         .Distinct()
                         .OrderBy(x => x)
                         .ToList();
            }

            return(string.Join(",", result));
        }
Пример #20
0
        //在執行 Action 之前執行
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            _controllerName = (string)filterContext.RouteData.Values["controller"];
            _actionName     = (string)filterContext.RouteData.Values["action"];
            var loginTime = AccountController.CurrentUserInfo.Ticket.UserData;
            var dt        = DateTime.Now.Date;

            db = new IFRS9DBEntities();
            var result = db.IFRS9_Browse_Log.AsNoTracking().Where(x =>
                                                                  x.User_Account == AccountController.CurrentUserInfo.Name &&
                                                                  System.Data.Entity.DbFunctions.TruncateTime(x.Login_Time).Value == dt)
                         .AsEnumerable()
                         .Where(x => x.Login_Time.ToString("yyyy/MM/dd HH:mm:ss") == loginTime)
                         .OrderByDescending(x => x.Browse_Time)
                         .FirstOrDefault();

            if (result != null)
            {
                var _Event_Name_Length = 200;
                var _Event_Name        = formatEventName(filterContext, _eventName);
                if (!_Event_Name.IsNullOrWhiteSpace())
                {
                    _Event_Name = _Event_Name.Substring(0, _Event_Name.Length >= _Event_Name_Length ? _Event_Name_Length : _Event_Name.Length);
                }
                _eventLog = new IFRS9_Event_Log()
                {
                    Menu_Id      = result.Menu_Id,
                    User_Account = result.User_Account,
                    Login_Time   = result.Login_Time,
                    Browse_Time  = result.Browse_Time,
                    Action_Name  = _actionName,
                    Event_Name   = _Event_Name,
                    Event_Begin  = DateTime.Now
                };
                db.IFRS9_Event_Log.Add(_eventLog);
                try
                {
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    ex.exceptionMessage();
                }
            }
        }
Пример #21
0
        public ActionResult Menu()
        {
            bool hasuser         = System.Web.HttpContext.Current.User != null;
            bool isAuthenticated = hasuser && System.Web.HttpContext.Current.User.Identity.IsAuthenticated;

            if (isAuthenticated)
            {
                List <IFRS9_Menu_Sub>  subs  = new List <IFRS9_Menu_Sub>();
                List <IFRS9_Menu_Main> mains = new List <IFRS9_Menu_Main>();
                using (IFRS9DBEntities db = new IFRS9DBEntities())
                {
                    var _user = db.IFRS9_User.Where(x => x.User_Account == AccountController.CurrentUserInfo.Name && x.Effective).ToList();

                    if (_user.Any(x => x.AdminFlag))
                    {
                        subs  = db.IFRS9_Menu_Sub.AsNoTracking().Where(x => x.Menu == "System").OrderBy(x => x.Menu_Id).ToList();
                        mains = db.IFRS9_Menu_Main.AsNoTracking().Where(x => x.Menu == "System").ToList();
                    }
                    else if (_user.Any())
                    {
                        var _DebtType = _user.First().DebtType;
                        subs = db.IFRS9_Menu_Set.AsNoTracking()
                               .Where(x => x.User_Account == AccountController.CurrentUserInfo.Name && x.Effective == "Y")
                               .Select(x => x.IFRS9_Menu_Sub)
                               .Where(x => x.DebtType == "A" || x.DebtType == _DebtType, _DebtType != "A")
                               .OrderBy(x => x.Menu_Id).ToList();
                        var Menus = subs.Select(x => x.Menu).Distinct();
                        mains = db.IFRS9_Menu_Main.AsNoTracking()
                                .Where(x => Menus.Contains(x.Menu))
                                .OrderBy(x => x.Menu).ToList();
                    }
                }
                MenuModel menus = new MenuModel()
                {
                    menu_Main = mains,
                    menu_Sub  = subs
                };

                return(PartialView(menus));
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }
        }
Пример #22
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public List <string> GetA62SearchYear(string Status = "All")
        {
            List <string> result = new List <string>();

            using (IFRS9DBEntities db = new IFRS9DBEntities())
            {
                if (db.Moody_LGD_Info.Any())
                {
                    result.Add("All(全部)");
                    result.AddRange(db.Moody_LGD_Info.AsNoTracking()
                                    .Where(x => x.Status == Status, Status != "All")
                                    .GroupBy(x => new { x.Data_Year, x.Status })
                                    .AsEnumerable()
                                    .Select(x => $"{x.Key.Data_Year}({A52Status(x.Key.Status)})").OrderByDescending(x => x));
                }
            }
            return(result);
        }
Пример #23
0
 /// <summary>
 /// Get C01 Version
 /// </summary>
 /// <param name="product"></param>
 /// <param name="date"></param>
 /// <returns></returns>
 public List <string> GetC01Version(string product, DateTime date)
 {
     using (IFRS9DBEntities db = new IFRS9DBEntities())
     {
         List <string> result       = new List <string>();
         var           product_Code = db.Group_Product_Code_Mapping.AsNoTracking()
                                      .Where(x => x.Group_Product_Code == product).Select(x => x.Product_Code).AsEnumerable();
         if (!product_Code.Any())
         {
             return(result);
         }
         var version = db.EL_Data_In.AsNoTracking()
                       .Where(x => x.Report_Date == date && product_Code.Contains(x.Product_Code))
                       .Select(x => x.Version).Distinct().OrderBy(x => x)
                       .AsEnumerable().Select(x => x.ToString()).ToList();
         return(version);
     }
 }
Пример #24
0
 public void getBondC07CheckData(DateTime dt, int version)
 {
     using (IFRS9DBEntities db = new IFRS9DBEntities())
     {
         var _dt           = dt.ToString("yyyy-MM-dd");
         var Product_Codes = new List <string>()
         {
             Product_Code.B_A.GetDescription(),
             Product_Code.B_B.GetDescription(),
             Product_Code.B_P.GetDescription()
         };
         var C07s = db.EL_Data_Out.AsNoTracking().
                    Where(x => x.Report_Date == _dt &&
                          x.Version == version &&
                          Product_Codes.Contains(x.Product_Code));
         new BondsCheckRepository <EL_Data_Out>(C07s, Check_Table_Type.Bonds_C07_Transfer_Check);
     }
 }
Пример #25
0
        public Tuple <bool, List <C13ViewModel> > getC13(C13ViewModel dataModel)
        {
            using (IFRS9DBEntities db = new IFRS9DBEntities())
            {
                if (db.Econ_D_Var.Any())
                {
                    var query = db.Econ_D_Var.AsNoTracking()
                                .Where(x => x.Year_Quartly.Contains(dataModel.Year_Quartly), dataModel.Year_Quartly.IsNullOrWhiteSpace() == false)
                                .Where(x => x.Consumer_Price_Index_Pre_Ind == dataModel.Consumer_Price_Index_Pre_Ind, dataModel.Consumer_Price_Index_Pre_Ind.IsNullOrWhiteSpace() == false)
                                .Where(x => x.Unemployment_Rate_Pre_Ind == dataModel.Unemployment_Rate_Pre_Ind, dataModel.Unemployment_Rate_Pre_Ind.IsNullOrWhiteSpace() == false);

                    return(new Tuple <bool, List <C13ViewModel> >(query.Any(), query.AsEnumerable()
                                                                  .Select(x => { return DbToC13Model(x); }).ToList()));
                }
            }

            return(new Tuple <bool, List <C13ViewModel> >(false, new List <C13ViewModel>()));
        }
Пример #26
0
        /// <summary>
        /// Log資料存到Sql(IFRS9_Log)
        /// </summary>
        /// <param name="tableType">table簡寫</param>
        /// <param name="tableName">table名</param>
        /// <param name="fileName">檔案名</param>
        /// <param name="programName">專案名</param>
        /// <param name="falg">成功失敗</param>
        /// <param name="deptType">B:債券 M:房貸 (共用同一table時做區分)</param>
        /// <param name="start">開始時間</param>
        /// <param name="end">結束時間</param>
        /// <param name="userAccount">執行帳號</param>
        /// <param name="version">版本</param>
        /// <param name="reportDate">基準日</param>
        /// <returns>回傳成功或失敗</returns>
        public bool saveLog(
            Table_Type table,
            string fileName,
            string programName,
            bool falg,
            string deptType,
            DateTime start,
            DateTime end,
            string userAccount,
            int version = 1,
            Nullable <DateTime> date = null)
        {
            bool flag = true;

            try
            {
                using (IFRS9DBEntities db = new IFRS9DBEntities())
                {
                    var tableName = table.GetDescription();
                    db.IFRS9_Log.Add(new IFRS9_Log() //寫入DB
                    {
                        Table_type   = table.ToString(),
                        Table_name   = tableName.Substring(0, (tableName.Length > 40 ? 40 : tableName.Length)),
                        File_name    = fileName,
                        Program_name = programName,
                        Version      = version,
                        Create_date  = start.ToString("yyyyMMdd"),
                        Create_time  = start.ToString("HH:mm:ss"),
                        End_date     = end.ToString("yyyyMMdd"),
                        End_time     = end.ToString("HH:mm:ss"),
                        TYPE         = falg ? "Y" : "N",
                        Debt_Type    = deptType,
                        User_Account = userAccount,
                        Report_Date  = date
                    });
                    db.SaveChanges(); //DB SAVE
                }
            }
            catch
            {
                flag = false;
            }
            return(flag);
        }
Пример #27
0
        public MSGReturnModel saveC13(string actionType, C13ViewModel dataModel)
        {
            MSGReturnModel result = new MSGReturnModel();

            using (IFRS9DBEntities db = new IFRS9DBEntities())
            {
                try
                {
                    Econ_D_Var dataEdit = new Econ_D_Var();

                    if (actionType == "Add")
                    {
                        dataEdit.Year_Quartly = dataModel.Year_Quartly;
                    }
                    else if (actionType == "Modify")
                    {
                        dataEdit = db.Econ_D_Var
                                   .Where(x => x.Year_Quartly == dataModel.Year_Quartly)
                                   .FirstOrDefault();
                    }

                    dataEdit.Consumer_Price_Index         = double.Parse(dataModel.Consumer_Price_Index);
                    dataEdit.Consumer_Price_Index_Pre_Ind = dataModel.Consumer_Price_Index_Pre_Ind;
                    dataEdit.Unemployment_Rate            = double.Parse(dataModel.Unemployment_Rate);
                    dataEdit.Unemployment_Rate_Pre_Ind    = dataModel.Unemployment_Rate_Pre_Ind;

                    if (actionType == "Add")
                    {
                        db.Econ_D_Var.Add(dataEdit);
                    }

                    db.SaveChanges();

                    result.RETURN_FLAG = true;
                }
                catch (Exception ex)
                {
                    result.RETURN_FLAG = false;
                    result.DESCRIPTION = ex.Message;
                }
            }

            return(result);
        }
Пример #28
0
        public List <string> getB06PRJID(string productCode)
        {
            using (IFRS9DBEntities db = new IFRS9DBEntities())
            {
                if (db.IFRS9_Foward_Looking_Parm.Any())
                {
                    var query = from q in db.IFRS9_Foward_Looking_Parm.AsNoTracking()
                                .Where(x => x.Product_Code == productCode)
                                select q;

                    List <string> data = query.AsEnumerable().OrderBy(x => x.PRJID)
                                         .Select(x => x.PRJID).Distinct()
                                         .ToList();
                    return(data);
                }
            }

            return(new List <string>());
        }
Пример #29
0
        public Tuple <bool, List <C13ViewModel> > getC13All()
        {
            using (IFRS9DBEntities db = new IFRS9DBEntities())
            {
                if (db.Econ_D_Var.Any())
                {
                    return(new Tuple <bool, List <C13ViewModel> >
                           (
                               true,
                               (
                                   from q in db.Econ_D_Var.AsNoTracking().AsEnumerable()
                                   select DbToC13Model(q)
                               ).ToList()
                           ));
                }
            }

            return(new Tuple <bool, List <C13ViewModel> >(true, new List <C13ViewModel>()));
        }
Пример #30
0
        public Tuple <bool, List <A94ViewModel> > getA94All()
        {
            using (IFRS9DBEntities db = new IFRS9DBEntities())
            {
                if (db.Gov_Info_Ticker.Any())
                {
                    return(new Tuple <bool, List <A94ViewModel> >
                           (
                               true,
                               (
                                   from q in db.Gov_Info_Ticker.AsNoTracking()
                                   .AsEnumerable()
                                   select DbToA94Model(q)
                               ).ToList()
                           ));
                }
            }

            return(new Tuple <bool, List <A94ViewModel> >(true, new List <A94ViewModel>()));
        }