Exemple #1
0
        public static void SaveSummaryPayFeeMonthly()
        {
            decimal totalSlowFee, totalDebtFee;
            using (var db = new RentBikeEntities())
            {
                try
                {
                    var stores = db.Stores.Where(c => c.ACTIVE == true).ToList();
                    foreach (var store in stores)
                    {
                        if (db.SummaryPayFeeMonthlies.Any(c => c.SUMMURY_DATE == DateTime.Today
                                && c.STORE_ID == store.ID))
                            continue;

                        GetSummuryFeeMonthly(out totalSlowFee, out totalDebtFee, store.ID);

                        SummaryPayFeeMonthly sum1 = new SummaryPayFeeMonthly();
                        sum1.STORE_ID = store.ID;
                        sum1.STORE_NAME = store.NAME;
                        sum1.SUMMURY_FEE = totalSlowFee;
                        sum1.SUMMURY_FEE_TYPE = (int)SUMMURY_FEE_TYPE.SLOW_FEE;
                        sum1.SUMMURY_DATE = DateTime.Today;
                        sum1.NOTE = Constants.SUMMURY_SLOW_FEE;
                        sum1.CREATED_DATE = DateTime.Now;
                        sum1.CREATED_BY = Constants.DUMMY_USER;
                        sum1.UPDATED_DATE = DateTime.Now;
                        sum1.UPDATED_BY = Constants.DUMMY_USER;
                        db.SummaryPayFeeMonthlies.Add(sum1);

                        SummaryPayFeeMonthly sum2 = new SummaryPayFeeMonthly();
                        sum2.STORE_ID = store.ID;
                        sum2.STORE_NAME = store.NAME;
                        sum2.SUMMURY_FEE = totalDebtFee;
                        sum2.SUMMURY_FEE_TYPE = (int)SUMMURY_FEE_TYPE.DEBT_FEE;
                        sum2.SUMMURY_DATE = DateTime.Today;
                        sum2.NOTE = Constants.SUMMURY_DEBT_FEE;
                        sum2.CREATED_DATE = DateTime.Now;
                        sum2.CREATED_BY = Constants.DUMMY_USER;
                        sum2.UPDATED_DATE = DateTime.Now;
                        sum2.UPDATED_BY = Constants.DUMMY_USER;
                        db.SummaryPayFeeMonthlies.Add(sum2);

                    }
                    db.SaveChanges();
                }
                catch (System.Data.Entity.Validation.DbEntityValidationException e)
                {
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Logger.Log(string.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                            eve.Entry.Entity.GetType().Name, eve.Entry.State));
                        foreach (var ve in eve.ValidationErrors)
                        {
                            Logger.Log(string.Format("- Property: \"{0}\", Error: \"{1}\"",
                                 ve.PropertyName, ve.ErrorMessage));
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log(ex.Message + Environment.NewLine + ex.StackTrace);
                }
            }
        }
Exemple #2
0
        public static void SaveSummaryPayFeeMonthly()
        {
            decimal totalSlowFee, totalDebtFee;

            using (var db = new RentBikeEntities())
            {
                try
                {
                    var stores = db.Stores.Where(c => c.ACTIVE == true).ToList();
                    foreach (var store in stores)
                    {
                        if (db.SummaryPayFeeMonthlies.Any(c => c.SUMMURY_DATE == DateTime.Today &&
                                                          c.STORE_ID == store.ID))
                        {
                            continue;
                        }

                        GetSummuryFeeMonthly(out totalSlowFee, out totalDebtFee, store.ID);

                        SummaryPayFeeMonthly sum1 = new SummaryPayFeeMonthly();
                        sum1.STORE_ID         = store.ID;
                        sum1.STORE_NAME       = store.NAME;
                        sum1.SUMMURY_FEE      = totalSlowFee;
                        sum1.SUMMURY_FEE_TYPE = (int)SUMMURY_FEE_TYPE.SLOW_FEE;
                        sum1.SUMMURY_DATE     = DateTime.Today;
                        sum1.NOTE             = Constants.SUMMURY_SLOW_FEE;
                        sum1.CREATED_DATE     = DateTime.Now;
                        sum1.CREATED_BY       = Constants.DUMMY_USER;
                        sum1.UPDATED_DATE     = DateTime.Now;
                        sum1.UPDATED_BY       = Constants.DUMMY_USER;
                        db.SummaryPayFeeMonthlies.Add(sum1);

                        SummaryPayFeeMonthly sum2 = new SummaryPayFeeMonthly();
                        sum2.STORE_ID         = store.ID;
                        sum2.STORE_NAME       = store.NAME;
                        sum2.SUMMURY_FEE      = totalDebtFee;
                        sum2.SUMMURY_FEE_TYPE = (int)SUMMURY_FEE_TYPE.DEBT_FEE;
                        sum2.SUMMURY_DATE     = DateTime.Today;
                        sum2.NOTE             = Constants.SUMMURY_DEBT_FEE;
                        sum2.CREATED_DATE     = DateTime.Now;
                        sum2.CREATED_BY       = Constants.DUMMY_USER;
                        sum2.UPDATED_DATE     = DateTime.Now;
                        sum2.UPDATED_BY       = Constants.DUMMY_USER;
                        db.SummaryPayFeeMonthlies.Add(sum2);
                    }
                    db.SaveChanges();
                }
                catch (System.Data.Entity.Validation.DbEntityValidationException e)
                {
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Logger.Log(string.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                                 eve.Entry.Entity.GetType().Name, eve.Entry.State));
                        foreach (var ve in eve.ValidationErrors)
                        {
                            Logger.Log(string.Format("- Property: \"{0}\", Error: \"{1}\"",
                                                     ve.PropertyName, ve.ErrorMessage));
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log(ex.Message + Environment.NewLine + ex.StackTrace);
                }
            }
        }