Exemplo n.º 1
0
        /// <summary>
        /// Evals the static method.
        /// </summary>
        /// <param name="dateRule">The date rule.</param>
        /// <param name="assemblyName">Name of the assembly.</param>
        /// <param name="nameSpace">The name space.</param>
        /// <param name="className">Name of the class.</param>
        /// <param name="staticMethodName">Name of the static method.</param>
        /// <param name="parameterObject">The parameter object.</param>
        /// <returns></returns>
        internal static SignificantDay[] EvalStaticMethod(DateRule dateRule, string assemblyName, string nameSpace, string className, string staticMethodName, object[] parameterObject)
        {
            SignificantDay[] sds;
            Assembly         assembly = Assembly.Load(assemblyName);
            Type             myClass  = assembly.GetType($"{nameSpace}.{className}");
            object           dteval   = myClass.InvokeMember(staticMethodName, BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.FlattenHierarchy, null, null, parameterObject);
            var sd = new SignificantDay();

            if (dteval is DateTime)
            {
                sd.Date = (DateTime)dteval;
                sds     = new[] { sd };
            }
            else
            {
                if (dteval is SignificantDay day)
                {
                    sds = new[] { day };
                }
                else
                {
                    sds = (SignificantDay[])dteval;
                }
            }
            return(sds);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Determines whether [is rule effective] [the specified dr].
        /// </summary>
        /// <param name="dr">The dr.</param>
        /// <param name="dtCheckDate">The dt check date.</param>
        /// <returns>
        ///     <c>true</c> if [is rule effective] [the specified dr]; otherwise, <c>false</c>.
        /// </returns>
        internal static bool IsRuleEffective(DateRule dr, DateTime dtCheckDate)
        {
            DateTime dtStart            = dr.startDate;
            DateTime dtEnd              = dr.endDate;
            bool     bIsValidRulePeriod = true;

            if (dtStart > DateTime.MinValue && dtEnd > DateTime.MinValue)
            {
                if (dtCheckDate.Year < dtStart.Year || dtCheckDate.Year > dtEnd.Year)
                {
                    bIsValidRulePeriod = false;
                }
            }
            else if (dtStart > DateTime.MinValue)
            {
                if (dtCheckDate.Year < dtStart.Year)
                {
                    bIsValidRulePeriod = false;
                }
            }
            else if (dtEnd > DateTime.MinValue)
            {
                if (dtCheckDate.Year > dtEnd.Year)
                {
                    bIsValidRulePeriod = false;
                }
            }

            return(bIsValidRulePeriod);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Applies the date rule roll convention.
        /// </summary>
        /// <param name="dr">The dr.</param>
        /// <param name="dtBase">The dt base.</param>
        /// <returns></returns>
        internal static DateTime ApplyDateRuleRollConvention(DateRule dr, DateTime dtBase)
        {
            DateTime dtRolledDate = dtBase;

            if ((dr.applyRollSpecified) && (dr.applyRoll))
            {
                dtRolledDate = RollWeekendDateFwdToMonday(dtBase);
            }
            // Here we roll to before the weekend (i.e Friday)
            else if ((dr.applyRollPriorSpecified) && (dr.applyRollPrior))
            {
                dtRolledDate = RollWeekendDateBackToFriday(dtBase);
            }
            // Here we would roll fwd to monday if a Sunday and rollback to Friday if a Saturday
            else if ((dr.rollBeforeAfterWeekendSpecified) && (dr.rollBeforeAfterWeekend))
            {
                dtRolledDate = RollWeekendDateBeforeAfterWeekend(dtBase);
            }
            // Here we roll to before the weekend (i.e Friday) ONLY if its a Saturday
            else if ((dr.RollPriorIfSaturdaySpecified) && (dr.RollPriorIfSaturday))
            {
                dtRolledDate = RollBeforeWeekendIfSaturday(dtBase);
            }
            return(dtRolledDate);
        }
        public override void EditRule(IDataRule aRule)
        {
            base.EditRule(aRule);
            chkConvertToString.Checked = aRule.ConvertToString;
            rbRandomDateTime.Checked   = aRule.IsRandom;
            rbDateTimeInc.Checked      = !aRule.IsRandom;
            string inc = String.Empty;
            int    idx = -1;

            if (aRule.RuleType == FieldTypes.Time)
            {
                TimeRule tRule = (TimeRule)aRule;
                startDatePicker.Value = tRule.Start;
                endDatePicker.Value   = tRule.End;
                idx = cboRate.Items.IndexOf(tRule.RateType.ToString());
                inc = tRule.Increment.ToString();
            }
            else
            {
                DateRule dRule = (DateRule)aRule;
                startDatePicker.Value = dRule.Start;
                endDatePicker.Value   = dRule.End;
                idx = cboRate.Items.IndexOf(dRule.RateType.ToString());
                inc = dRule.Increment.ToString();
            }
            cboRate.SelectedIndex     = idx;
            txtTimeDateIncrement.Text = inc;
        }
Exemplo n.º 5
0
        private static DateRule RangeRule(int startYear, int endYear, DateRule rule)
        {
            if (startYear == 0 && endYear == 0)
            {
                return(rule);
            }

            RangeDateRule rangeRule = new RangeDateRule();

            if (startYear != 0)
            {
                Calendar start = new GregorianCalendar(startYear, IBM.ICU.Util.Calendar.JANUARY,
                                                       1);
                rangeRule.Add(start.GetTime(), rule);
            }
            else
            {
                rangeRule.Add(rule);
            }
            if (endYear != 0)
            {
                DateTime end = new GregorianCalendar(endYear, IBM.ICU.Util.Calendar.DECEMBER, 31)
                               .GetTime();
                rangeRule.Add(end, null);
            }

            return(rangeRule);
        }
Exemplo n.º 6
0
        public PagedList <MpUserDTO> GetForOutAuthUserList(int pageIndex, int pageSize)
        {
            int      currentMonth = DateTime.Now.Month;
            int      year         = DateTime.Now.Year;
            DateRule dateRule     = DateRuleList.DateRules.Where(d => d.Months.Where(m => m == currentMonth).Count() > 0).First();
            string   sql          = "select u.* from Funongbao f inner join MpUser u on f.MpUserId=u.Id where u.IsSubscribe=1 order by u.CreateDate desc ";

            return(this.GetPageList <MpUserDTO>(sql, pageIndex, pageSize));
        }
Exemplo n.º 7
0
        public PagedList <FunongbaoApply> GetForTaskUserList(int pageIndex, int pageSize)
        {
            int      currentMonth = DateTime.Now.Month;
            int      year         = DateTime.Now.Year;
            DateRule dateRule     = DateRuleList.DateRules.Where(d => d.Months.Where(m => m == currentMonth).Count() > 0).First();
            string   sql          = "select fa.* from FunongbaoApply fa inner join Funongbao f on fa.FunongbaoId=f.Id inner join MpUser u on f.MpUserId=u.Id where u.IsSubscribe=1 and fa.NoticeStatus=0 and fa.CreateDate>='" + (new DateTime(year, dateRule.ApplyMonth, DateRule.ApplyStartDay)) + "' and datediff(hour,u.lastvisitdate,getdate())<48 order by CreateDate desc ";

            return(this.GetPageList(sql, pageIndex, pageSize));
        }
Exemplo n.º 8
0
        public PagedList <ScoreConsumeInfo> GetConsumeScoreList(Guid gid, int pageIndex, int pageSize)
        {
            int      currentMonth = DateTime.Now.Month;
            int      year         = DateTime.Now.Year;
            DateRule dateRule     = DateRuleList.DateRules.Where(d => d.Months.Where(m => m == currentMonth).Count() > 0).First();
            string   sql          = "select * from ScoreConsumeInfo where MpUserId = '" + gid + "' order by CreateDate desc ";

            return(this.GetPageList <ScoreConsumeInfo>(sql, pageIndex, pageSize));
        }
Exemplo n.º 9
0
        public FunongbaoApply ExistGroupApply(string groupNO)
        {
            int      currentMonth = DateTime.Now.Month;
            int      year         = DateTime.Now.Year;
            DateRule dateRule     = DateRuleList.DateRules.Where(d => d.Months.Where(m => m == currentMonth).Count() > 0).First();
            DateTime startDate    = new DateTime(year, dateRule.ApplyMonth, 1);
            DateTime endDate      = new DateTime(year, dateRule.ApplyMonth, DateTime.DaysInMonth(year, dateRule.ApplyMonth), 23, 59, 59);

            return(GetUnique(f => f.RFunongbao.GroupNO == groupNO && f.ApplyDate > new DateTime(1900, 1, 1) && (f.ApplyStatus == -1 || f.ApplyStatus == 0) && (f.CreateDate >= startDate && f.CreateDate <= endDate)));//f.CreateDate >= new DateTime(year, dateRule.ApplyMonth, DateRule.ApplyStartDay)
        }
Exemplo n.º 10
0
        /// <summary>
        /// Processes the observed significant day date.
        /// </summary>
        /// <param name="dr">The dr.</param>
        /// <param name="noOfDaysAfter">The no of days after.</param>
        /// <param name="baseDate">The base date.</param>
        /// <returns></returns>
        internal static DateTime ProcessObservedSignificantDayDate(DateRule dr, int noOfDaysAfter, DateTime baseDate)
        {
            DateTime dtDependentObsHoliday = baseDate.AddDays(noOfDaysAfter);

            if (IsWeekend(dtDependentObsHoliday))
            {
                dtDependentObsHoliday = ApplyDateRuleRollConvention(dr, dtDependentObsHoliday);
            }
            return(dtDependentObsHoliday);
        }
Exemplo n.º 11
0
        public IList <FunongbaoApply> GetByFunongbaoIds(Guid[] funongbaoIds)
        {
            int      currentMonth = DateTime.Now.Month;
            int      year         = DateTime.Now.Year;
            DateRule dateRule     = DateRuleList.DateRules.Where(d => d.Months.Where(m => m == currentMonth).Count() > 0).First();
            DateTime startDate    = new DateTime(year, dateRule.ApplyMonth, 1);
            DateTime endDate      = new DateTime(year, dateRule.ApplyMonth, DateTime.DaysInMonth(year, dateRule.ApplyMonth), 23, 59, 59);

            return(this.GetALL(f => funongbaoIds.Contains(f.FunongbaoId) && f.CreateDate >= startDate && f.CreateDate <= endDate));//f.CreateDate >= new DateTime(year, dateRule.ApplyMonth, DateRule.ApplyStartDay)
        }
Exemplo n.º 12
0
        public FunongbaoApply GetByFunongbaoId(Guid funongbaoId)
        {
            int      currentMonth = DateTime.Now.Month;
            int      year         = DateTime.Now.Year;
            DateRule dateRule     = DateRuleList.DateRules.Where(d => d.Months.Where(m => m == currentMonth).Count() > 0).First();
            DateTime startDate    = new DateTime(year, dateRule.ApplyMonth, 1);
            DateTime endDate      = new DateTime(year, dateRule.ApplyMonth, DateTime.DaysInMonth(year, dateRule.ApplyMonth), 23, 59, 59);

            return(GetUnique(f => f.FunongbaoId == funongbaoId && f.CreateDate >= startDate && f.CreateDate <= endDate));//
        }
Exemplo n.º 13
0
        public ActionResult Index()
        {
            if (!base.HasPermission("VehicleLicense", PermissionOperate.manager))
            {
                return(base.ShowNotPermissionTip(""));
            }

            IList <SelectListItem> importQuarterList = new List <SelectListItem>();
            int      startQuarter = 1;
            int      endQuarter   = 4;
            DateRule dateR        = DateRuleList.DateRules.Where(d => d.Months.Where(m => m == DateTime.Now.Month).Count() > 0).First();
            int      x            = 0;

            for (int i = (DateTime.Now.Year - DateRule.StartYear); i >= 0; i--)
            {
                if ((i + DateRule.StartYear) == DateRule.StartYear)
                {
                    startQuarter = DateRule.StartQuarter;
                }
                else
                {
                    startQuarter = 1;
                }
                if (i == (DateTime.Now.Year - DateRule.StartYear))
                {
                    endQuarter = dateR.Quarterly;
                }
                else
                {
                    endQuarter = 4;
                }
                for (int j = endQuarter; j >= startQuarter; j--)
                {
                    if (x == 0)
                    {
                        importQuarterList.Add(new SelectListItem()
                        {
                            Text = (i + DateRule.StartYear).ToString() + "年第" + StringHelper.GetQuarter(j) + "季度", Value = StringHelper.GetQuarter(DateRule.StartYear + i, j), Selected = true
                        });
                        x++;
                    }
                    else
                    {
                        importQuarterList.Add(new SelectListItem()
                        {
                            Text = (i + DateRule.StartYear).ToString() + "年第" + StringHelper.GetQuarter(j) + "季度", Value = StringHelper.GetQuarter(DateRule.StartYear + i, j)
                        });
                    }
                }
            }
            ViewBag.ImportQuarterList = importQuarterList;
            return(View());
        }
Exemplo n.º 14
0
        public void AddDateRule()
        {
            var dateRule = new DateRule()
            {
                Name = nameof(DateRule)
            };

            _model.Rules.Add(dateRule);
            var ruleViewModel = _rulesFactory.Create(dateRule, this);

            _rules.Add(ruleViewModel);
            ruleViewModel.Focus();
        }
Exemplo n.º 15
0
        private void StartReminderTrigger()
        {
            var firstHour  = (int)FirstHourSwitch.SelectedRowInComponent(0);
            var secondHour = (int)SecondHourSwitch.SelectedRowInComponent(0);

            var goingToWork   = DateRule.HourBetween(firstHour, secondHour);
            var insideCarRule = ProximityRule.InRangeOfNearableType(NearableType.Car);
            var noBagRule     = ProximityRule.OutsideRangeOfNearableType(NearableType.Bag);

            var forgotBagTrigger = new Trigger(new Rule[] { goingToWork, insideCarRule, noBagRule }, TriggerId);

            if (triggerManager == null)
            {
                triggerManager = new TriggerManager();
            }

            triggerManager.StartMonitoringForTrigger(forgotBagTrigger);
        }
Exemplo n.º 16
0
        public async void testDateRule(DateTimeOffset?expiryDate, bool expected)
        {
            Enrollee enrollee = TestUtils.EnrolleeFaker.Generate();

            enrollee.AccessTerms = new[]
            {
                new AccessTerm
                {
                    ExpiryDate = expiryDate
                }
            };

            var  rule   = new DateRule();
            bool result = await rule.ProcessRule(enrollee);

            Assert.Equal(expected, result);
            AssertNoReasons(enrollee);
        }
Exemplo n.º 17
0
        public FunongbaoApply GetByFunongbaoIdAndDate(Guid funongbaoId)
        {
            int            currentMonth = DateTime.Now.Month;
            int            year         = DateTime.Now.Year;
            DateRule       dateRule     = DateRuleList.DateRules.Where(d => d.Months.Where(m => m == currentMonth).Count() > 0).First();
            DateTime       startDate    = new DateTime(year, dateRule.ApplyMonth, 1);
            DateTime       endDate      = new DateTime(year, dateRule.ApplyMonth, DateTime.DaysInMonth(year, dateRule.ApplyMonth), 23, 59, 59);
            FunongbaoApply apply        = GetUnique(f => f.FunongbaoId == funongbaoId && f.CreateDate >= startDate && f.CreateDate <= endDate);//f.CreateDate >= new DateTime(year, dateRule.ApplyMonth, DateRule.ApplyStartDay)

            //FunongbaoApply apply = GetUnique(" where FunongbaoId='"+funongbaoId.ToString()+"'");//(f => f.FunongbaoId == funongbaoId);
            if (apply != null)
            {
                //DateRule dateRuleApply = DateRuleList.DateRules.Where(d => d.Months.Where(m => m == apply.CreateDate.Month).Count() > 0).First();
                //if (dateRule.ApplyMonth == dateRuleApply.ApplyMonth)
                //{
                return(apply);
                //}
            }
            return(null);
        }
Exemplo n.º 18
0
 /// <summary>
 /// Applies the day in month rule.
 /// </summary>
 /// <param name="dr">The dr.</param>
 /// <param name="dim">The dim.</param>
 /// <param name="dtCheckDate">The dt check date.</param>
 /// <param name="dtBase">The dt base.</param>
 /// <param name="observedDayDate">The dt observed day date.</param>
 internal static void ApplyDayInMonthRule(DateRule dr, DayInMonth dim, DateTime dtCheckDate, ref DateTime dtBase, ref DateTime observedDayDate)
 {
     // if we have a base holiday where the month and day have been specified
     if (dim.Month > 0 && dim.Day > 0)
     {
         dtBase = new DateTime(dtCheckDate.Year, dim.Month, dim.Day);
         ////Those that occur on a specified date but only on certain years
         //// NOTE**:These attributes don't yet exist but can easily be added to the XSD
         //if (hr.EveryXYearsSpecified)
         //{
         //    if (((dt.Year - hr.StartYear) % hr.EveryXYears) == 0)
         //    {
         //        h.Date = dt;
         //    }
         //}
     }
     // Derive and set business holiday (not necessarily the same as the holiday particularly if we are rolling
     // if the date falls on a weekend.
     // Here we would roll fwd to monday
     observedDayDate = ApplyDateRuleRollConvention(dr, dtBase);
 }
Exemplo n.º 19
0
        public static void Buildrule(DateRule aRule, DateTime start, DateTime end, String increment, String rateType)
        {
            try
            {
                aRule.Start = start;
                aRule.End   = end;
                double result = Double.NegativeInfinity;
                if (double.TryParse(increment, out result))
                {
                    aRule.Increment = result;
                }
                else
                {
                    throw new Exception();
                }

                aRule.RateType = EnumPlus.ConvertString(typeof(DateTimeRateTypes), rateType);
            }
            catch (Exception e)
            {
                throw new Exception("Build date rule failed");
            }
        }
Exemplo n.º 20
0
        public int CancelApply(Guid id)
        {
            FunongbaoApply apply = this.GetById(id);

            if (apply != null)
            {
                int      currentMonth = apply.ApplyDate.Month;
                int      year         = apply.ApplyDate.Year;
                DateRule dateRule     = DateRuleList.DateRules.Where(d => d.Months.Where(m => m == currentMonth).Count() > 0).First();
                this.ExcuteSql("update Funongbao set GroupLimit=" + apply.PreGroupLimit.ToString() + ",CurrentLimit=" + apply.PreLimit.ToString() + ",CurrentRates=" + apply.PreRates.ToString() + " where Id in (select Id from Funongbao where GroupNO in(select GroupNO from Funongbao where id='" + apply.FunongbaoId.ToString() + "'))");
                apply.ApplyLimit       = 0.00M;
                apply.ApplyRates       = 0.00M;
                apply.ChangedRates     = 0.00M;
                apply.ChangedLimit     = 0.00M;
                apply.ApplyStatus      = 0;
                apply.ProcessStatus    = 0;
                apply.ApplyDate        = new DateTime(1900, 1, 1);
                apply.FinishDate       = new DateTime(1900, 1, 1);
                apply.GroupApplyStatus = 0;
                this.Update(apply);
                return(this.ExcuteSql("update FunongbaoApply set ApplyLimit=0.00,ApplyRates=0.00,ChangedLimit=0.00,ApplyType=0,ChangedRates=0.00,ApplyStatus=0,ProcessStatus=0,ApplyDate='1900-01-01',FinishDate='1900-01-01',GroupApplyStatus=0 where FunongbaoId in(select Id from Funongbao where GroupNO in(select GroupNO from Funongbao where id='" + apply.FunongbaoId.ToString() + "')) and charindex(convert(varchar(7),CreateDate,120),'" + StringHelper.GetQuarter(year, dateRule.Quarterly) + "')>0"));
            }
            return(0);
        }
Exemplo n.º 21
0
        //***************************疑问********************************
        //还有一个疑问:当同组的有一个提交了超额的申请,另外一个人如果提交不同的申请,需不需要提示?
        //如果已经提交了超额的申请,进去的提示直接提交时的提示一样吗?
        //***************************疑问********************************
        public ActionResult ApplyOld()
        {
            //if (CurrentFunongbao.IsSignAgreement == 1 || (!string.IsNullOrEmpty(RQuery["c"]) && RQuery["c"]=="go"))//判断是否签订协议
            //{
            FunongbaoApply apply = _funongbaoApplyService.GetByFunongbaoId(CurrentFunongbao.Id);

            if (apply != null && apply.ApplyDate > new DateTime(1900, 1, 1))    //判断当季度是否已申请
            {
                int      applyMonth = apply.ApplyDate.Month;
                int      applyDay   = apply.ApplyDate.Day;
                DateRule dateRule   = DateRuleList.DateRules.Where(d => d.Months.Where(m => m == applyMonth).Count() > 0).First();
                if (apply.ApplyDate > new DateTime(apply.ApplyDate.Year, apply.ApplyDate.Month, DateRule.ApplyMiddleDay))     //判断当月或者次月
                {
                    ViewBag.ApplyMonth = applyMonth + 1;
                }
                else
                {
                    ViewBag.ApplyMonth = applyMonth;
                }
                ViewBag.ChangeDay = DateRule.ChangeDay;
                if (apply.ApplyStatus <= 0)
                {
                    IList <Funongbao>      funongbaoGroup      = _funongbaoService.GetGroupByNo(CurrentFunongbao.GroupNO);
                    Guid[]                 funongbaoIds        = funongbaoGroup.Select(f => f.Id).ToArray();
                    IList <FunongbaoApply> funongbaoApplyGroup = _funongbaoApplyService.GetByFunongbaoIds(funongbaoIds);

                    ViewBag.RelationNames = GetNoticeApplyNames(funongbaoGroup, apply, funongbaoApplyGroup);
                    if (ViewBag.RelationNames == "-1")
                    {
                        ViewBag.ApplyStatus = -1;
                    }
                }
                return(View("Applied", apply));
            }
            else
            {
                IList <LimitProgrammeDTO> limitList = null;
                if (apply != null)
                {
                    limitList = _funongbaoApplyService.GetLimitProgramme(apply.LimitProgramme);
                    if (limitList != null && limitList.Count == 1)
                    {
                        ViewBag.LimitProgrammeList = limitList;
                    }
                    else
                    {
                        FunongbaoApply groupApply = _funongbaoApplyService.ExistGroupApply(apply.RFunongbao.GroupNO);
                        if (groupApply != null && limitList != null)
                        {
                            IEnumerable <LimitProgrammeDTO> groupLimits = limitList.Where(l => l.ApplyLimit == groupApply.ApplyLimit / 10000 && l.ApplyRates == groupApply.ApplyRates);
                            if (groupLimits.Count() > 0)
                            {
                                ViewBag.LimitProgrammeList = groupLimits.ToList();
                            }
                            else
                            {
                                ViewBag.LimitProgrammeList = null;
                            }
                        }
                        else
                        {
                            ViewBag.LimitProgrammeList = limitList;
                        }
                    }
                }
                if (WebHelper.IsPost())
                {
                    return(ApplyPost(apply, limitList));
                }

                return(View("LimitProgramme", apply));
            }
            //}
            //else
            //{
            //    return View("WeixinAgreement");
            //}
        }
Exemplo n.º 22
0
 public DateRuleViewModel(DateRule rule)
     : base(rule)
 {
     _rule = rule;
     RefreshName();
 }
Exemplo n.º 23
0
        public ActionResult ImportPosExcel(HttpPostedFileBase posExcel)
        {
            ViewBag.Method  = "post";
            ViewBag.Success = true;
            int countPos       = 0;
            int countPosUpdate = 0;

            if (posExcel != null)
            {
                DataTable dt = null;
                if (posExcel.FileName.ToLower().EndsWith(".xlsx"))
                {
                    dt = NPOIHelper.ExcelToTableForXLSX(posExcel.InputStream, "序号");
                }
                else
                {
                    dt = NPOIHelper.ExcelToTableForXLS(posExcel.InputStream, "序号", string.Empty);
                }
                var columns = dt.Columns;

                DateRule rule  = DateRuleList.DateRules.Where(d => d.Months.Where(m => m == DateTime.Now.Month).Count() > 0).First();
                int      month = rule.ApplyMonth;
                int      year  = DateTime.Now.Year;
                try
                {
                    for (int i = 0; i <= dt.Rows.Count - 1; i++)
                    {
                        Pos pos = new Pos();
                        pos.CreateDate     = DateTime.Now;
                        pos.VendorName     = dt.Rows[i]["商户名称"].ToString();
                        pos.VendorNO       = dt.Rows[i]["商户号"].ToString();
                        pos.TerminalNO     = dt.Rows[i]["终端号"].ToString();
                        pos.InstallAddress = dt.Rows[i]["装机地址"].ToString();
                        pos.DeductRate     = dt.Rows[i]["扣率"].ToString();
                        pos.BankNO         = dt.Rows[i]["银行卡号"].ToString();
                        Pos oldPos;
                        int exits = _posService.ExistPos(pos, out oldPos, false);
                        if (exits == 1)//已存在的POS
                        {
                            countPosUpdate++;
                            oldPos.CreateDate     = DateTime.Now;
                            oldPos.VendorName     = pos.VendorName;
                            oldPos.InstallAddress = pos.InstallAddress;
                            oldPos.DeductRate     = pos.DeductRate;
                            _posService.Update(oldPos);
                        }
                        else
                        {
                            countPos++;
                            _posService.Insert(pos);
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw new OceanException("导入失败,具体原因,请查看日志!", ex);
                }
                ViewBag.countPos       = countPos;
                ViewBag.countPosUpdate = countPosUpdate;
            }
            else
            {
                ViewBag.Success = false;
                ViewBag.Message = "请选择导入文件";
            }
            return(View());
        }
Exemplo n.º 24
0
        private void Initialize()
        {
            var mapper = BsonMapper.Global;

            mapper.Entity <RuleInfo>()
            .Id(x => x.Id);

            mapper.RegisterType <CompositeRule>(rule =>
            {
                var bson = new BsonDocument
                {
                    ["Type"] = new BsonValue(rule.GetType().Name),
                    [nameof(rule.SelectedType)] = new BsonValue(rule.SelectedType.ToString()),
                    [nameof(rule.IsEnabled)]    = new BsonValue(rule.IsEnabled),
                    [nameof(rule.Name)]         = new BsonValue(rule.Name)
                };
                bson.Add(nameof(rule.Rules), new BsonArray(rule.Rules.Select(r => mapper.ToDocument(r))));
                return(bson);
            }, value =>
            {
                var rule          = new CompositeRule();
                rule.IsEnabled    = value.AsDocument[nameof(rule.IsEnabled)].AsBoolean;
                rule.Name         = value.AsDocument[nameof(rule.Name)].AsString;
                rule.SelectedType =
                    (RuleGroupType)
                    Enum.Parse(typeof(RuleGroupType), value.AsDocument[nameof(rule.SelectedType)].AsString);
                rule.Rules = value.AsDocument[nameof(rule.Rules)].AsArray.Select(v =>
                {
                    var type =
                        typeof(RuleBase).Assembly.GetType(
                            $"{typeof(RuleBase).Namespace}.{v.AsDocument["Type"].AsString}", true);
                    return(mapper.ToObject(type, v.AsDocument) as IRule);
                }).ToList();

                return(rule);
            });
            mapper.RegisterType <TextRule>(
                serialize: rule =>
            {
                var bson = new BsonDocument
                {
                    ["Type"]                       = new BsonValue(rule.GetType().Name),
                    [nameof(rule.Name)]            = new BsonValue(rule.Name),
                    [nameof(rule.IsEnabled)]       = new BsonValue(rule.IsEnabled),
                    [nameof(rule.SelectedAction)]  = new BsonValue(rule.SelectedAction.ToString()),
                    [nameof(rule.Text)]            = new BsonValue(rule.Text),
                    [nameof(rule.IsCaseSensitive)] = new BsonValue(rule.IsCaseSensitive)
                };
                return(bson);
            },
                deserialize: bson =>
            {
                var rule             = new TextRule();
                rule.Name            = bson.AsDocument[nameof(rule.Name)].AsString;
                rule.IsEnabled       = bson.AsDocument[nameof(rule.IsEnabled)].AsBoolean;
                rule.IsCaseSensitive = bson.AsDocument[nameof(rule.IsCaseSensitive)].AsBoolean;
                rule.SelectedAction  =
                    (TextRuleAction)
                    Enum.Parse(typeof(TextRuleAction), bson.AsDocument[nameof(rule.SelectedAction)].AsString);
                rule.Text = bson.AsDocument[nameof(rule.Text)].AsString;


                return(rule);
            });

            mapper.RegisterType <DateRule>(
                serialize: rule =>
            {
                var bson = new BsonDocument
                {
                    ["Type"]                      = new BsonValue(rule.GetType().Name),
                    [nameof(rule.Name)]           = new BsonValue(rule.Name),
                    [nameof(rule.IsEnabled)]      = new BsonValue(rule.IsEnabled),
                    [nameof(rule.SelectedAction)] = new BsonValue(rule.SelectedAction.ToString()),
                    [nameof(rule.Date)]           = !rule.Date.HasValue ? BsonValue.Null : new BsonValue(rule.Date)
                };
                return(bson);
            },
                deserialize: bson =>
            {
                var rule            = new DateRule();
                rule.Name           = bson.AsDocument[nameof(rule.Name)].AsString;
                rule.IsEnabled      = bson.AsDocument[nameof(rule.IsEnabled)].AsBoolean;
                rule.SelectedAction = (DateRuleAction)Enum.Parse(typeof(DateRuleAction), bson.AsDocument[nameof(rule.SelectedAction)].AsString);
                rule.Date           = bson.AsDocument[nameof(rule.Date)].IsNull
                        ? new DateTime?()
                        : bson.AsDocument[nameof(rule.Date)].AsDateTime;

                return(rule);
            });

            mapper.RegisterType <RegexRule>(
                serialize: rule =>
            {
                var bson = new BsonDocument
                {
                    ["Type"]                      = new BsonValue(rule.GetType().Name),
                    [nameof(rule.Name)]           = new BsonValue(rule.Name),
                    [nameof(rule.IsEnabled)]      = new BsonValue(rule.IsEnabled),
                    [nameof(rule.SelectedAction)] = new BsonValue(rule.SelectedAction.ToString()),
                    [nameof(rule.Pattern)]        = new BsonValue(rule.Pattern)
                };
                return(bson);
            },
                deserialize: bson =>
            {
                var rule            = new RegexRule();
                rule.Name           = bson.AsDocument[nameof(rule.Name)].AsString;
                rule.IsEnabled      = bson.AsDocument[nameof(rule.IsEnabled)].AsBoolean;
                rule.SelectedAction = (RegexRuleAction)
                                      Enum.Parse(typeof(RegexRuleAction), bson.AsDocument[nameof(rule.SelectedAction)].AsString);
                rule.Pattern = bson.AsDocument[nameof(rule.Pattern)].AsString;
                return(rule);
            });

            mapper.RegisterType <IRule>(
                serialize: rule => mapper.ToDocument(rule.GetType(), rule),
                deserialize: value =>
            {
                var type =
                    typeof(RuleBase).Assembly.GetType(
                        $"{typeof(RuleBase).Namespace}.{value.AsDocument["Type"].AsString}", true);
                return(mapper.ToObject(type, value.AsDocument) as IRule);
            }
                );
        }
Exemplo n.º 25
0
 private static Unit WriteDateRule(JsonTextWriter writer, DateRule dateRule)
 => dateRule is DateSimpleRule simple?nameof(Type).WriteValueProperty(nameof(DateSimpleRule)).Then(nameof(DateRule).WriteObjectProperty(simple, WriteDateSimpleRule))(writer)
Exemplo n.º 26
0
        public static IDataRule InitializeBase(FieldTypes generalType, bool isRandom, String fieldName, String fieldDataType, bool convertToString)
        {
            IDataRule result = null;

            switch (generalType)
            {
            case FieldTypes.Date:
                result = new DateRule();
                break;

            case FieldTypes.Time:
                result = new TimeRule();
                break;

            case FieldTypes.GUID:
                result = new GuidRule();
                break;

            case FieldTypes.Imported:
                //result = new
                break;

            case FieldTypes.MultiColumn:
                result = new MultiFieldDataSourceRule();
                break;

            case FieldTypes.SingleColumn:
                result = new SingleFieldDataSourceRule();
                break;

            case FieldTypes.Number:
                result = new NumberRule();
                break;

            case FieldTypes.String:
                result = new StringRule();
                break;

            case FieldTypes.Bool:
                result = new BoolRule();
                break;

            case FieldTypes.Dynamic:
            case FieldTypes.Type:
                result = new TRule();
                break;

            case FieldTypes.Enumerator:
                result = new EnumeratorRule();
                break;

            case FieldTypes.MappedSource:
                result = new MappedSourceRule();
                break;

            case FieldTypes.Collection:
                result = new CollectionRule();
                break;

            case FieldTypes.Tuple:
                result = new TupleRule();
                break;
            }

            result.ConvertToString = convertToString;
            result.FieldDataType   = fieldDataType;
            result.FieldName       = fieldName;
            result.IsRandom        = isRandom;
            result.RuleType        = generalType;
            return(result);
        }
Exemplo n.º 27
0
 /// <summary>
 /// Construct a new Holiday object. This is for use by subclasses only. This
 /// constructs a new holiday with the given name and date rules.
 /// </summary>
 ///
 /// <param name="name">The name of this holiday. The getDisplayName method uses thisstring as a key to look up the holiday's name a resourcebundle object named HolidayBundle.</param>
 /// <param name="rule">The date rules used for determining when this holiday falls.Holiday's implementation of the DateRule inteface simplydelegates to this DateRule object.</param>
 /// @draft ICU 2.8
 /// @provisional This API might change or be removed in a future release.
 protected internal Holiday(String name, DateRule rule)
 {
     this.name = name;
     this.rule = rule;
 }
Exemplo n.º 28
0
        public ActionResult Apply()
        {
            FunongbaoApply apply = _funongbaoApplyService.GetByFunongbaoId(CurrentFunongbao.Id);

            if (apply != null && apply.ApplyDate > new DateTime(1900, 1, 1))//判断当季度是否已申请
            {
                int      applyMonth = apply.ApplyDate.Month;
                int      applyDay   = apply.ApplyDate.Day;
                DateRule dateRule   = DateRuleList.DateRules.Where(d => d.Months.Where(m => m == applyMonth).Count() > 0).First();
                if (apply.ApplyDate > new DateTime(apply.ApplyDate.Year, apply.ApplyDate.Month, DateRule.ApplyMiddleDay)) //判断当月或者次月
                {
                    ViewBag.ApplyMonth = applyMonth + 1;
                }
                else
                {
                    ViewBag.ApplyMonth = applyMonth;
                }
                if (apply.ApplyType > 0)
                {
                    ViewBag.ApplyStatus = 1;
                }
                else
                {
                    ViewBag.ApplyStatus = 2;
                }
                ViewBag.ChangeDay = DateRule.ChangeDay;
                ViewBag.ApplyType = apply.ApplyType;
                return(View("Applied", apply));
            }
            else
            {
                IList <LimitProgrammeDTO> limitList = null;
                if (apply != null)
                {
                    limitList = _funongbaoApplyService.GetLimitProgramme(apply.LimitProgramme);
                    if (limitList != null && limitList.Count == 1)
                    {
                        ViewBag.LimitProgrammeList = limitList;
                    }
                    else
                    {
                        //FunongbaoApply groupApply = _funongbaoApplyService.ExistGroupApply(apply.RFunongbao.GroupNO);
                        //if (groupApply != null && limitList != null)
                        //{
                        //    IEnumerable<LimitProgrammeDTO> groupLimits = limitList.Where(l => l.ApplyLimit == groupApply.ApplyLimit / 10000 && l.ApplyRates == groupApply.ApplyRates);
                        //    if (groupLimits.Count() > 0)
                        //    {
                        //        ViewBag.LimitProgrammeList = groupLimits.ToList();
                        //    }
                        //    else
                        //    {
                        //        ViewBag.LimitProgrammeList = null;
                        //    }
                        //}
                        //else
                        //{
                        ViewBag.LimitProgrammeList = limitList;
                        //}
                    }
                }
                if (WebHelper.IsPost())
                {
                    return(ApplyPost(apply, limitList));
                }

                return(View("LimitProgramme", apply));
            }
        }
Exemplo n.º 29
0
 /// @draft ICU 2.8
 /// @provisional This API might change or be removed in a future release.
 public void SetRule(DateRule rule)
 {
     this.rule = rule;
 }
Exemplo n.º 30
0
        public void Save()
        {
            (String name, String category) Holiday(String name) => (name, "Holiday");

            var isWeekend  = ("Weekend", "Weekend").Is(Day.IsSunday.Or(Day.IsSaturday));
            var isNewYears = Holiday("New Year's Day").Is(Month.Is(1).And(Day.Is(1), Day.IsNotSunday, Day.IsNotSaturday))
                             .Or(Holiday("New Year's Day (observed)").IsEither(Month.Is(1).And(Day.Is(2), Day.IsMonday),
                                                                               Month.Is(12).And(Day.Is(31), Day.IsFriday)));

            var isThirdMonday = Month.Third(DayOfWeek.Monday);
            var isLastMonday  = Month.Last(DayOfWeek.Monday);

            var isMLK        = Holiday("Martin Luther King Day").Is(Month.Is(1).And(isThirdMonday));
            var isPresidents = Holiday("President's Day").Is(Month.Is(2).And(isThirdMonday));
            var isMemorial   = Holiday("Memorial Day").Is(Month.Is(5).And(isLastMonday));

            var isIndependence = Holiday("Independence Day").Is(Month.Is(7).And(Day.Is(4), Day.IsNotSunday, Day.IsNotSaturday))
                                 .Or(Holiday("Independence Day (observed)").Is(Month.Is(7).AndEither(Day.Is(3).And(Day.IsFriday),
                                                                                                     Day.Is(5).And(Day.IsMonday))));

            var isLabor    = Holiday("Labor Day").Is(Month.Is(9).And(Month.First(DayOfWeek.Monday)));
            var isColumbus = Holiday("Columbus Day").Is(Month.Is(10).And(Month.Second(DayOfWeek.Monday)));

            var isVeterans = Holiday("Veteran's Day").Is(Month.Is(11).And(Day.Is(11), Day.IsNotSunday, Day.IsNotSaturday))
                             .Or(Holiday("Veteran's Day (observed)").Is(Month.Is(11).AndEither(Day.Is(10).And(Day.IsFriday),
                                                                                               Day.Is(12).And(Day.IsMonday))));

            var isThanksTerm  = Month.Is(11).And(Month.Fourth(DayOfWeek.Thursday));
            var isThanks      = Holiday("Thanksgiving Day").Is(isThanksTerm);
            var isAfterThanks = Holiday("Day After Thanksgiving").Is(Month.Is(11).And(Day.PriorIs(isThanksTerm)));

            var isChristmas = Holiday("Christmas Day").Is(Month.Is(12).And(Day.Is(25).And(Day.IsNotSunday, Day.IsNotSaturday)))
                              .Or(Holiday("Christmas Day (observed)").Is(Month.Is(12).AndEither(Day.Is(26).And(Day.IsMonday),
                                                                                                Day.Is(24).And(Day.IsFriday))));

            var rules = new DateRule[] { isWeekend, isNewYears, isMLK, isPresidents, isMemorial, isIndependence, isLabor, isColumbus, isVeterans, isThanks, isAfterThanks, isChristmas };

            File.WriteAllText("HolidayRules.json", rules.ToJson());

            var rulesClone = File.ReadAllText("HolidayRules.json").ToDateRules();

            var currDate = new DateTime(2010, 1, 1);
            var endDate  = new DateTime(2020, 12, 31);

            var logic      = rules.ToLogic();
            var logicClone = rulesClone.ToLogic();

            var monthNum  = 0;
            var mondayNum = 0;

            Boolean IsWeekDay(DateTime date) => (Int32)date.DayOfWeek >= 1 && (Int32)date.DayOfWeek <= 5;

            while (currDate <= endDate)
            {
                var logicResult      = logic(currDate);
                var logicCloneResult = logicClone(currDate);

                if (mondayNum != currDate.Month)
                {
                    mondayNum = currDate.Month;
                    mondayNum = 0;
                }

                if (currDate.DayOfWeek == DayOfWeek.Monday)
                {
                    mondayNum++;
                }

                Assert.True(logicResult.Select(s => logicCloneResult.Select(sc => s.Name.Equals(sc.Name, StringComparison.OrdinalIgnoreCase), () => false),
                                               () => logicCloneResult.Select(sc => false, () => true)));

                if (currDate.Month == 1 && currDate.Day == 1 && IsWeekDay(currDate))
                {
                    Assert.True(logicResult.Select(s => s.Name.Equals("New Year's Day"), () => false));
                }
                if (currDate.Month == 1 && mondayNum == 3)
                {
                    Assert.True(logicResult.Select(s => s.Name.Equals("Martin Luther King Day"), () => false));
                }
                if (currDate.Month == 2 && mondayNum == 3)
                {
                    Assert.True(logicResult.Select(s => s.Name.Equals("President's Day"), () => false));
                }

                currDate = currDate.AddDays(1);
            }
        }