Exemplo n.º 1
0
        protected Schedule(ScheduleActivity view) : base(view)
        {
            intent  = view.Intent;
            Periods = new Periods(View, this);

            view.ImageFavorites.Click += ClickImageFavorites;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the next report number for this foundry
        /// </summary>
        /// <param name="ctx">Context under which to give the report number</param>
        /// <returns></returns>
        public String getNextReportNumber(RadiographyContext ctx)
        {
            //period logic - first check whether which is the current period or we need to create a new period
            if (NextResetDate < DateTime.Now)
            {
                //end date the current period, and create a new period
                if (CurrentPeriod != null)
                {
                    CurrentPeriod.EndDate = NextResetDate;
                }
                var newPeriod = new Period
                {
                    StartDate = NextResetDate,
                    Foundry   = this,
                    FoundryID = ID,
                };
                Periods.Add(newPeriod);

                //set the next reset date to one year hence
                NextResetDate = NextResetDate.AddYears(1);
                //for ctx to get these changes
                ctx.Foundries.AttachAsModified(this, ctx);
                ctx.Periods.Add(newPeriod);
                ctx.SaveChanges();
            }

            //fetch immediately from the database, otherwise convert.toint32 will fail
            var reports    = ctx.RGReports.Where(p => p.ReportNo.StartsWith(this.ReportNumberPrefix) && p.ReportDate > CurrentPeriod.StartDate).ToList();
            var lastNumber = !reports.Any() ? 0 : reports.Max(p => Convert.ToInt32(p.ReportNo.Replace(ReportNumberPrefix, "")));

            return(String.Concat(ReportNumberPrefix, Convert.ToString(lastNumber + 1)));
        }
Exemplo n.º 3
0
            }             // Add

            public override string ToString()
            {
                var os = new StringBuilder();

                os.AppendFormat(
                    "\n\n\tBusiness ID: {0}\n" +
                    "\tCurrency code: {1}\n" +
                    "\t{2}\n\n" +
                    "\t*** Quarters:\n" +
                    "\t{3}\n\n" +
                    "\t*** Box totals:\n" +
                    "\t\t{4}\n\n" +
                    "\t*** Annualized data:\n{5}\n",
                    BusinessID,
                    CurrencyCode,
                    string.Join("\n\t", Periods.Select(pair => pair.Value.ToString("\t\t"))),
                    string.Join("\n\t", Quarters.Select(x => x.ToString("\t\t"))),
                    string.Join("\n\t\t", BoxTotals.Select(pair => string.Format("{0}: {1}", pair.Key, pair.Value))),
                    Annualized.ToString("\t\t")
                    );

                ToString(os, "\t");

                return(os.ToString());
            }             // ToString
Exemplo n.º 4
0
        /// <summary>
        /// Evaluates this event to determine the dates and times for which the event occurs.
        /// This method only evaluates events which occur between <paramref name="FromDate"/>
        /// and <paramref name="ToDate"/>; therefore, if you require a list of events which
        /// occur outside of this range, you must specify a <paramref name="FromDate"/> and
        /// <paramref name="ToDate"/> which encapsulate the date(s) of interest.
        /// <note type="caution">
        ///     For events with very complex recurrence rules, this method may be a bottleneck
        ///     during processing time, especially when this method in called for a large number
        ///     of events, in sequence, or for a very large time span.
        /// </summary>
        /// <param name="FromDate">The beginning date of the range to evaluate.</param>
        /// <param name="ToDate">The end date of the range to evaluate.</param>
        /// <returns></returns>
        public override List <Period> Evaluate(Date_Time FromDate, Date_Time ToDate)
        {
            // Add the event itself, before recurrence rules are evaluated
            // NOTE: this fixes a bug where (if evaluated multiple times)
            // a period can be added to the Periods collection multiple times.
            Period period = new Period(DTStart, Duration);

            if (!Periods.Contains(period))
            {
                Periods.Add(period);
            }

            // Evaluate recurrences normally
            base.Evaluate(FromDate, ToDate);

            // Ensure each period has a duration
            foreach (Period p in Periods)
            {
                if (p.EndTime == null)
                {
                    p.Duration = Duration;
                    p.EndTime  = p.StartTime + Duration;
                }
            }

            return(Periods);
        }
Exemplo n.º 5
0
        public PeriodsResponse Post(Periods request)
        {
            if (request.Period.Id > 0)
              {
            Bm2s.Data.Common.BLL.Parameter.Period item = Datas.Instance.DataStorage.Periods[request.Period.Id];
            item.Code = request.Period.Code;
            item.EndingDate = request.Period.EndingDate;
            item.Interval = request.Period.Interval;
            item.Name = request.Period.Name;
            item.StartingDate = request.Period.StartingDate;
            item.UnitId = request.Period.Unit.Id;
            Datas.Instance.DataStorage.Periods[request.Period.Id] = item;
              }
              else
              {
            Bm2s.Data.Common.BLL.Parameter.Period item = new Data.Common.BLL.Parameter.Period()
            {
              Code = request.Period.Code,
              EndingDate = request.Period.EndingDate,
              Interval = request.Period.Interval,
              Name = request.Period.Name,
              StartingDate = request.Period.StartingDate,
              UnitId = request.Period.Unit.Id
            };

            Datas.Instance.DataStorage.Periods.Add(item);
            request.Period.Id = item.Id;
              }

              PeriodsResponse response = new PeriodsResponse();
              response.Periods.Add(request.Period);
              return response;
        }
        /// <summary>
        /// Calculates forecast object value column's values.
        /// </summary>
        /// <param name="parameters">Parameters.</param>
        /// <returns>
        /// Parameters with calculated cells.
        /// </returns>
        public ForecastCalcParams Calculate(ForecastCalcParams parameters)
        {
            InitData(parameters);
            var         objectValueColumns = GetObjectValueColumns();
            List <Cell> cells = new List <Cell>();

            if (objectValueColumns.IsNotEmpty())
            {
                CellRepository.DeleteCells(ForecastSheet, Periods, objectValueColumns);
            }
            _log.Info($"Forecast object value calculation. " +
                      $"Columns to count: {objectValueColumns.Count()}");
            foreach (ForecastColumn column in objectValueColumns)
            {
                var settings = ColumnSettingsMapper.GetForecastColumnSettingsData(UserConnection, column);
                if (settings == null)
                {
                    _log.Info($"Settings for forecast {ForecastSheet.Name} - {ForecastSheet.Id} " +
                              $"column {column.Name} - {column.Id} does not exists");
                    continue;
                }
                _log.Info($"Forecast object value calculation. " +
                          $"Periods to count: {Periods.Count()}");
                foreach (Period period in Periods)
                {
                    var esq = new EntitySchemaQuery(UserConnection.EntitySchemaManager, settings.SourceEntityName);
                    esq.IgnoreDisplayValues = true;
                    string columnPath      = GetEntityInCellColumnPath(settings);
                    var    refColumnName   = esq.AddColumn(settings.ReferenceColumnName);
                    var    rowIdColumnName = esq.AddColumn($"{columnPath}.Row");
                    var    valueColumn     = esq.AddColumn(esq.CreateAggregationFunction(
                                                               GetCalcFunction(settings.FuncCode), settings.FuncColumnName));
                    AddSettingsFilter(settings, esq);
                    AddPeriodFilter(period, settings.PeriodColumnName, esq);
                    AddEntitiesFilter(columnPath, esq);
                    List <Cell> periodCells = new List <Cell>();
                    Select      select      = esq.GetSelectQuery(UserConnection);
                    select.ExecuteReader((reader) => {
                        decimal value = reader.GetColumnValue <decimal>(valueColumn.ValueQueryAlias);
                        value         = CalcValue(settings, value);
                        periodCells.Add(new Cell {
                            Value    = value,
                            ColumnId = column.Id,
                            EntityId = reader.GetColumnValue <Guid>(refColumnName.ValueQueryAlias),
                            RowId    = reader.GetColumnValue <Guid>(rowIdColumnName.ValueQueryAlias),
                            PeriodId = period.Id
                        });
                    });
                    if (periodCells.Any())
                    {
                        cells.AddRange(periodCells);
                        _log.Info($"Forecast object value calculation. " +
                                  $"Has {periodCells.Count()} cells data for period {period.Name}");
                    }
                }
            }
            SaveCells(cells);
            parameters.Cells.AddRange(cells);
            return(parameters);
        }
Exemplo n.º 7
0
        public async void testSetPeriods()
        {
            Console.WriteLine("------testSetPeriods");
            try
            {
                int id = await ApiClass.CreatePromotion();

                //id = -1;
                Assert.False(id == -1, Messages.msg_object_not_created);
                Console.WriteLine(Messages.msg_object_created);

                NewPeriods etalon   = TestHelper.BasePeriods();
                string     Response = await ApiClass.SetPeriods(id, etalon);

                if (Response != "")
                {
                    Console.WriteLine(Response);
                }
                Assert.IsNullOrEmpty(Response, Messages.msg_object_not_created);
                Console.WriteLine(Messages.msg_object_created);

                Periods ResSub = await ApiClass.GetPeriodsPromotion(id);

                NewPeriods actual = ResSub as NewPeriods;
                Assert.AreEqual(etalon, actual, Messages.msg_objects_not_equal);
                Console.WriteLine(Messages.msg_objects_equal);
                Console.WriteLine(Messages.msg_test_pass);
            }
            catch (Exception e)
            {
                Console.WriteLine(Messages.msg_test_fail);
            }
        }
Exemplo n.º 8
0
        public void GetClosingPeriodDataPeriods()
        {
            var period1 = new Periods
            {
                InvestmentProgramId = investmentProgram.Id,
                Id     = Guid.NewGuid(),
                Number = 1,
                Status = PeriodStatus.Closed
            };
            var period2 = new Periods
            {
                InvestmentProgramId = investmentProgram.Id,
                Id     = Guid.NewGuid(),
                Number = 2,
                Status = PeriodStatus.InProccess
            };

            context.AddRange(new[] { period1, period2 });
            context.SaveChanges();

            var result = trustManagementService.GetClosingPeriodData(investmentProgram.Id);

            Assert.IsTrue(result.IsSuccess);
            Assert.IsNotNull(result.Data.CurrentPeriod);
            Assert.AreEqual(result.Data.CurrentPeriod.Id, context.Periods.First(x => x.Number == 2 && x.InvestmentProgramId == investmentProgram.Id).Id);
            //Assert.IsNull(result.Data.NextPeriod);

            context.Periods.RemoveRange(context.Periods.Where(x => x.Id == period1.Id || x.Id == period2.Id));
            context.SaveChanges();
        }
Exemplo n.º 9
0
        public static DateTime AddPeriodToDate(DateTime utcDate, Periods period)
        {
            switch(period)
            {
                case Periods.FiveYears:
                    return utcDate.AddYears(5);
                case Periods.Forever:
                    return DateTime.MaxValue;
                case Periods.OneMonth:
                    return utcDate.AddMonths(1);
                case Periods.OneTime:
                    return utcDate;
                case Periods.OneWeek:
                    return utcDate.AddDays(7);
                case Periods.OneYear:
                    return utcDate.AddYears(1);
                case Periods.SixMonths:
                    return utcDate.AddMonths(6);
                case Periods.ThirtyDays:
                    return utcDate.AddDays(30);
                case Periods.ThreeMonths:
                    return utcDate.AddMonths(3);
                case Periods.TwoWeeks:
                    return utcDate.AddDays(14);
                case Periods.TwoYears:
                    return utcDate.AddYears(2);
                case Periods.Unknown:
                    return utcDate;
            }

            return utcDate;
        }
Exemplo n.º 10
0
        /// <summary>
        /// <see cref="Periods"/>들의 Gap 부분들만을 기간 컬렉션으로 반환합니다.
        /// </summary>
        /// <returns>Gap 기간들의 컬렉션</returns>
        public ITimePeriodCollection CalcuateGaps()
        {
            if (IsDebugEnabled)
            {
                log.Debug("ITimePeriod 사이의 Gap들을 계산하여 ITimePeriod 컬렉션으로 반환합니다...");
            }

            // exclude periods
            //
            var gapPeriods = new TimePeriodCollection();

            foreach (var period in Periods.Where(p => Limits.IntersectsWith(p)))
            {
                gapPeriods.Add(new TimeRange(period));
            }

            var timeLineMoments = GetTimeLineMoments(gapPeriods);

            if (timeLineMoments.Count == 0)
            {
                return new TimePeriodCollection {
                           Limits
                }
            }
            ;

            var range = ActivatorTool.CreateInstance <T>();

            range.Setup(MapPeriodStart(Limits.Start), MapPeriodEnd(Limits.End));

            return(timeLineMoments.CalculateGaps <T>(range));
        }
Exemplo n.º 11
0
        private HashSet <IPeriod> FindDateOverlaps(HashSet <IPeriod> dates)
        {
            var datesWithoutTimes = new HashSet <DateTime>(dates.Where(d => d.StartTime.Value.TimeOfDay == TimeSpan.Zero).Select(d => d.StartTime.Value));
            var overlaps          = new HashSet <IPeriod>(Periods.Where(p => datesWithoutTimes.Contains(p.StartTime.Value.Date)));

            return(overlaps);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Evalates the RDate component, and adds each specified DateTime or
        /// Period to the <see cref="Periods"/> collection.
        /// </summary>
        /// <param name="FromDate">The beginning date of the range to evaluate.</param>
        /// <param name="ToDate">The end date of the range to evaluate.</param>
        virtual protected void EvaluateRDate(Date_Time FromDate, Date_Time ToDate)
        {
            // Handle RDATEs
            if (RDate != null)
            {
                foreach (RDate rdate in RDate)
                {
                    ArrayList Items = rdate.Evaluate(DTStart, FromDate, ToDate);
                    foreach (object obj in Items)
                    {
                        Period p = null;
                        if (obj is Period)
                        {
                            p = (Period)obj;
                        }
                        else if (obj is Date_Time)
                        {
                            p = new Period((Date_Time)obj);
                        }

                        if (p != null && !Periods.Contains(p))
                        {
                            Periods.Add(p);
                        }
                    }
                }
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Evalates the ExDate component, and excludes each specified DateTime or
        /// Period from the <see cref="Periods"/> collection.
        /// </summary>
        /// <param name="periodStart">The beginning date of the range to evaluate.</param>
        /// <param name="periodEnd">The end date of the range to evaluate.</param>
        virtual protected void EvaluateExDate(IDateTime referenceDate, DateTime periodStart, DateTime periodEnd)
        {
            // Handle EXDATEs
            if (Recurrable.ExceptionDates != null)
            {
                foreach (IPeriodList exdate in Recurrable.ExceptionDates)
                {
                    IEvaluator evaluator = exdate.GetService(typeof(IEvaluator)) as IEvaluator;
                    if (evaluator != null)
                    {
                        IList <IPeriod> periods = evaluator.Evaluate(referenceDate, periodStart, periodEnd, false);
                        foreach (IPeriod p in periods)
                        {
                            // If no time was provided for the ExDate, then it excludes the entire day
                            if (!p.StartTime.HasTime || (p.EndTime != null && !p.EndTime.HasTime))
                            {
                                p.MatchesDateOnly = true;
                            }

                            while (Periods.Contains(p))
                            {
                                Periods.Remove(p);
                            }
                        }
                    }
                }
            }
        }
        private async Task LoadDate(IOutcomeReportServiceProvider provider)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            using (var service = provider.GetService())
            {
                var response = await service.GetAllPeriodsAsync(new ApplicationService.GetAllPeriodsRequest());

                if (ReferenceEquals(response.Exception, null))
                {
                    foreach (var vm in response.PeriodViewModels)
                    {
                        Periods.Add(vm);
                    }
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine(response.Exception);
                }
            }

            IsBusy = false;
        }
        public override int GetHashCode()
        {
            int hashCode = 718353637;

            if (Uid != null)
            {
                hashCode += Uid.GetHashCode();
            }

            if (Cadence != null)
            {
                hashCode += Cadence.GetHashCode();
            }

            if (Periods != null)
            {
                hashCode += Periods.GetHashCode();
            }

            if (RecurringPriceMoney != null)
            {
                hashCode += RecurringPriceMoney.GetHashCode();
            }

            if (Ordinal != null)
            {
                hashCode += Ordinal.GetHashCode();
            }

            return(hashCode);
        }
Exemplo n.º 16
0
        public JsonResult TimingsPeriods(Sections section, Periods period)
        {
            var timingsByPeriod = _timingStats.Extend(section, period);
            var sectionTimes    = timingsByPeriod.ToDictionary(x => x.Key.Label, y => y.Value.Select(z => TimeSpan.FromMilliseconds(z.Value).TotalMinutes));

            return(Json(sectionTimes));
        }
Exemplo n.º 17
0
        /// <summary>
        /// Evalates the ExDate component, and excludes each specified DateTime or
        /// Period from the <see cref="Periods"/> collection.
        /// </summary>
        /// <param name="FromDate">The beginning date of the range to evaluate.</param>
        /// <param name="ToDate">The end date of the range to evaluate.</param>
        virtual protected void EvaluateExDate(iCalDateTime FromDate, iCalDateTime ToDate)
        {
            // Handle EXDATEs
            if (ExDate != null)
            {
                foreach (RecurrenceDates exdate in ExDate)
                {
                    List <Period> periods = exdate.Evaluate(DTStart, FromDate, ToDate);
                    foreach (Period p in periods)
                    {
                        // If no time was provided for the ExDate, then it excludes the entire day
                        if (!p.StartTime.HasTime || (p.EndTime != null && !p.EndTime.HasTime))
                        {
                            p.MatchesDateOnly = true;
                        }

                        if (p != null)
                        {
                            while (Periods.Contains(p))
                            {
                                Periods.Remove(p);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 18
0
        public List <Periods> IspisSati()
        {
            SqlConnection con = new SqlConnection("Server=dev1.mev.hr;Database=piis2017_e3_podaci1;User Id=piis2017_e3_user; Password=rhNGj5KEVS;MultipleActiveResultSets=true");
            SqlCommand    cmd = new SqlCommand("select * from Periods", con);

            con.Open();

            List <Periods> listaSati = null;

            SqlDataReader reader = cmd.ExecuteReader();

            if (reader.HasRows)
            {
                listaSati = new List <Periods>();
                while (reader.Read())
                {
                    Periods periods = new Periods();

                    periods.period    = Convert.ToInt16(reader["period"]);
                    periods.starttime = Convert.ToString(reader["starttime"]);
                    periods.endtime   = Convert.ToString(reader["endtime"]);

                    listaSati.Add(periods);
                }
                listaSati.TrimExcess();
            }
            return(listaSati);
        }
Exemplo n.º 19
0
 /// <summary>
 /// Check that data is valid.
 /// </summary>
 public override void CheckData()
 {
     base.CheckData();
     if (Factors.IsNotEmpty())
     {
         foreach (WebFactor factor in Factors)
         {
             factor.CheckData();
         }
     }
     if (IndividualCategories.IsNotEmpty())
     {
         foreach (WebIndividualCategory individualCategory in IndividualCategories)
         {
             individualCategory.CheckData();
         }
     }
     if (SpeciesFactFieldConditions.IsNotEmpty())
     {
         foreach (WebSpeciesFactFieldCondition speciesFactFieldCondition in SpeciesFactFieldConditions)
         {
             speciesFactFieldCondition.CheckData();
         }
     }
     if (Periods.IsNotEmpty())
     {
         foreach (WebPeriod period in Periods)
         {
             period.CheckData();
         }
     }
 }
Exemplo n.º 20
0
        /// <summary>
        /// Evaluates this event to determine the dates and times for which the event occurs.
        /// This method only evaluates events which occur between <paramref name="FromDate"/>
        /// and <paramref name="ToDate"/>; therefore, if you require a list of events which
        /// occur outside of this range, you must specify a <paramref name="FromDate"/> and
        /// <paramref name="ToDate"/> which encapsulate the date(s) of interest.
        /// <note type="caution">
        ///     For events with very complex recurrence rules, this method may be a bottleneck
        ///     during processing time, especially when this method in called for a large number
        ///     of events, in sequence, or for a very large time span.
        /// </note>
        /// </summary>
        /// <param name="FromDate">The beginning date of the range to evaluate.</param>
        /// <param name="ToDate">The end date of the range to evaluate.</param>
        /// <returns></returns>                
        internal override List<Period> Evaluate(iCalDateTime FromDate, iCalDateTime ToDate)
        {
            // Add the event itself, before recurrence rules are evaluated
            // NOTE: this fixes a bug where (if evaluated multiple times)
            // a period can be added to the Periods collection multiple times.
            Period period = new Period(DTStart, Duration);
            // Ensure the period does not already exist in our collection
            if (!Periods.Contains(period))
                Periods.Add(period);
            
            // Evaluate recurrences normally
            base.Evaluate(FromDate, ToDate);

            // Ensure each period has a duration
            foreach(Period p in Periods)
            {
                if (p.EndTime == null)
                {
                    p.Duration = Duration;
                    if (p.Duration != null)
                        p.EndTime = p.StartTime + Duration;
                    else p.EndTime = p.StartTime;
                }
                // Ensure the Kind of time is consistent with DTStart
                p.EndTime.IsUniversalTime = DTStart.IsUniversalTime;
            }

            return Periods;
        }
Exemplo n.º 21
0
        public ActionResult AddOrUpdate(PeriodModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var isCreated = model.Id == Guid.Empty;
            var period    = new Periods();

            if (!isCreated)
            {
                period = PeriodRepository.GetById(model.Id);
            }

            period.Begin = model.Begin;
            period.End   = model.End;
            period.Years = YearRepository.GetById(model.YearId);

            if (isCreated)
            {
                PeriodRepository.Add(period);
            }
            PeriodRepository.Save();

            return(Redirect(Url.Action("Get", "Period", new { id = period.Id })));
        }
Exemplo n.º 22
0
        public async void LoadGpnAsync()
        {
            if (string.IsNullOrEmpty(GpnFile))
            {
                return;
            }

            try
            {
                GpnLoadDateTime = null;
                IsBusy          = true;
                Periods.Clear();

                BusyText = "Untis Datei laden...";
                Result   = await UntisExporter.ParseFileAsync(GpnFile);

                foreach (var period in Result.Periods)
                {
                    Periods.Add(period);
                }

                GpnLoadDateTime = DateTime.Now;
            }
            catch (Exception e)
            {
                await dialogCoordinator.ShowMessageAsync(this, "Fehler beim Laden der Untis-Datei", e.Message, MessageDialogStyle.Affirmative);

                Result = null;
            }
            finally
            {
                IsBusy   = false;
                BusyText = "";
            }
        }
Exemplo n.º 23
0
        async Task ExecuteLoadPeriodCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Periods.Clear();
                var periods = await DataStoreP.GetPeriodsAsync(true);

                foreach (var period in periods)
                {
                    Periods.Add(period);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 24
0
        public static DateTime?StartDate(this Enum e, DateTime?to)
        {
            if (to == null)
            {
                return(null);
            }

            Periods period = (Box.CMS.Models.Periods)e;

            switch (period)
            {
            case Periods.LastHour:
                return(to.Value.AddDays(-1));

            case Periods.LastDay:
                return(to.Value.AddDays(-1));

            case Periods.Last5Days:
                return(to.Value.AddDays(-5));

            case Periods.Last30Days:
                return(to.Value.AddDays(-30));

            case Periods.Last150Days:
                return(to.Value.AddDays(-150));

            case Periods.Last360Days:
                return(to.Value.AddDays(-360));
            }
            return(null);
        }
Exemplo n.º 25
0
        /// <summary>
        /// 图片文件的显示:相册
        /// </summary>
        /// <param name="serviceWorks"></param>
        /// <param name="worksId"></param>
        /// <returns></returns>
        private void ShowImages(IServiceWorks serviceWorks, long worksId)
        {
            StringBuilder htmlContent = new StringBuilder();
            List <VAWcfService.WorksFile> imagesList = serviceWorks.GetWorksFile(worksId.ToString(), "2");

            if (imagesList.Count > 0)
            {
                VAWcfService.Works works    = serviceWorks.GetWorksSubmitById(worksId.ToString());
                string             periodId = works.PeriodID.ToString();
                Periods            period   = serviceWorks.GetPeriodsById(periodId).FirstOrDefault();
                string             courseId = period.CourseID.ToString();
                Course             course   = serviceWorks.GetCourseById(courseId).FirstOrDefault();
                string             siteUrl  = "http://va.neu.edu.cn";

                if (course != null)
                {
                    siteUrl += course.Url;
                }
                htmlContent.AppendLine("<fieldset><legend>作品图片</legend>");
                htmlContent.AppendLine("<div class='box'>");
                htmlContent.AppendLine("<div id ='imgs' class='imgs'>");
                foreach (var file in imagesList)
                {
                    htmlContent.AppendLine("<img src='" + siteUrl + file.FilePath + "' onClick='$(this).ImgZoomIn();' height='200'>");
                }
                htmlContent.AppendLine("</div>");
                htmlContent.AppendLine("</div>");
                htmlContent.AppendLine("</fieldset>");
                ImagesDiv.InnerHtml = htmlContent.ToString();
            }
            else
            {
                ImagesDiv.Visible = false;
            }
        }
Exemplo n.º 26
0
        public static void GetBetweenDate(this DateTime date, Periods period, out DateTime startOfPeriod, out DateTime endOfPeriod)
        {
            startOfPeriod = date;
            endOfPeriod   = date;
            switch (period)
            {
            case Periods.Day:
                startOfPeriod = startOfPeriod.StartOfDay();
                endOfPeriod   = endOfPeriod.EndOfDay();
                break;

            case Periods.Week:
                startOfPeriod = startOfPeriod.StartOfWeek();
                endOfPeriod   = endOfPeriod.EndOfWeek();
                break;

            case Periods.Month:
                startOfPeriod = startOfPeriod.StartOfMonth();
                endOfPeriod   = endOfPeriod.EndOfMonth();
                break;

            case Periods.Year:
                startOfPeriod = startOfPeriod.StartOfYear();
                endOfPeriod   = endOfPeriod.EndOfYear();
                break;
            }
        }
Exemplo n.º 27
0
 /// <summary>
 /// Evaulates the RRule component, and adds each specified Period
 /// to the <see cref="Periods"/> collection.
 /// </summary>
 /// <param name="periodStart">The beginning date of the range to evaluate.</param>
 /// <param name="periodEnd">The end date of the range to evaluate.</param>
 virtual protected void EvaluateRRule(IDateTime referenceDate, DateTime periodStart, DateTime periodEnd, bool includeReferenceDateInResults)
 {
     // Handle RRULEs
     if (Recurrable.RecurrenceRules != null &&
         Recurrable.RecurrenceRules.Count > 0)
     {
         foreach (IRecurrencePattern rrule in Recurrable.RecurrenceRules)
         {
             IEvaluator evaluator = rrule.GetService(typeof(IEvaluator)) as IEvaluator;
             if (evaluator != null)
             {
                 IList <IPeriod> periods = evaluator.Evaluate(referenceDate, periodStart, periodEnd, includeReferenceDateInResults);
                 foreach (IPeriod p in periods)
                 {
                     if (!Periods.Contains(p))
                     {
                         Periods.Add(p);
                     }
                 }
             }
         }
     }
     else if (includeReferenceDateInResults)
     {
         // If no RRULEs were found, then we still need to add
         // the initial reference date to the results.
         IPeriod p = new Period(referenceDate.Copy <IDateTime>());
         if (!Periods.Contains(p))
         {
             Periods.Add(p);
         }
     }
 }
Exemplo n.º 28
0
        /// <summary>
        /// Evaluates this event to determine the dates and times for which the event occurs.
        /// This method only evaluates events which occur between <paramref name="FromDate"/>
        /// and <paramref name="ToDate"/>; therefore, if you require a list of events which
        /// occur outside of this range, you must specify a <paramref name="FromDate"/> and
        /// <paramref name="ToDate"/> which encapsulate the date(s) of interest.
        /// <note type="caution">
        ///     For events with very complex recurrence rules, this method may be a bottleneck
        ///     during processing time, especially when this method in called for a large number
        ///     of events, in sequence, or for a very large time span.
        /// </summary>
        /// <param name="FromDate">The beginning date of the range to evaluate.</param>
        /// <param name="ToDate">The end date of the range to evaluate.</param>
        /// <returns></returns>
        public override List <Period> Evaluate(Date_Time FromDate, Date_Time ToDate)
        {
            // Add the event itself, before recurrence rules are evaluated
            // NOTE: this fixes a bug where (if evaluated multiple times)
            // a period can be added to the Periods collection multiple times.
            Period period = new Period(DTStart, Duration);

            // Ensure the period does not already exist in our collection
            if (!Periods.Contains(period))
            {
                Periods.Add(period);
            }

            // Evaluate recurrences normally
            base.Evaluate(FromDate, ToDate);

            // Ensure each period has a duration
            foreach (Period p in Periods)
            {
                if (p.EndTime == null)
                {
                    p.Duration = Duration;
                    p.EndTime  = p.StartTime + Duration;
                }
                // Ensure the Kind of time is consistent with DTStart
                else if (p.EndTime.Kind != DTStart.Kind)
                {
                    p.EndTime.Value = DateTime.SpecifyKind(p.EndTime.Value, DTStart.Kind);;
                }
            }

            return(Periods);
        }
Exemplo n.º 29
0
        public override IList <IPeriod> Evaluate(IDateTime referenceDate, DateTime periodStart, DateTime periodEnd, bool includeReferenceDateInResults)
        {
            // Create a recurrence pattern suitable for use during evaluation.
            IRecurrencePattern pattern = ProcessRecurrencePattern(referenceDate);

            // Enforce evaluation restrictions on the pattern.
            EnforceEvaluationRestrictions(pattern);

            Periods.Clear();
            foreach (DateTime dt in GetDates(referenceDate, periodStart, periodEnd, -1, pattern, includeReferenceDateInResults))
            {
                // Turn each resulting date/time into an IDateTime and associate it
                // with the reference date.
                IDateTime newDt = new iCalDateTime(dt, referenceDate.TZID);

                // NOTE: fixes bug #2938007 - hasTime missing
                newDt.HasTime = referenceDate.HasTime;

                newDt.AssociateWith(referenceDate);

                // Create a period from the new date/time.
                IPeriod p = new Period(newDt);

                if (!Periods.Contains(p))
                {
                    Periods.Add(p);
                }
            }

            return(Periods);
        }
Exemplo n.º 30
0
        public override HashSet <Period> Evaluate(IDateTime referenceDate, DateTime periodStart, DateTime periodEnd, bool includeReferenceDateInResults)
        {
            // TODO items can only recur if a start date is specified
            if (Todo.Start == null)
            {
                return(new HashSet <Period>());
            }

            base.Evaluate(referenceDate, periodStart, periodEnd, includeReferenceDateInResults);

            // Ensure each period has a duration
            foreach (var period in Periods.Where(period => period.EndTime == null))
            {
                period.Duration = Todo.Duration;
                if (period.Duration != null)
                {
                    period.EndTime = period.StartTime.Add(Todo.Duration);
                }
                else
                {
                    period.Duration = Todo.Duration;
                }
            }
            return(Periods);
        }
        public override HashSet <IPeriod> Evaluate(IDateTime referenceDate, DateTime periodStart, DateTime periodEnd, bool includeReferenceDateInResults)
        {
            // Create a recurrence pattern suitable for use during evaluation.
            IRecurrencePattern pattern = ProcessRecurrencePattern(referenceDate);

            // Enforce evaluation restrictions on the pattern.
            EnforceEvaluationRestrictions(pattern);

            HashSet <IPeriod> periods = new HashSet <IPeriod>();

            foreach (DateTime dt in GetDates(referenceDate, periodStart, periodEnd, -1, pattern, includeReferenceDateInResults))
            {
                // Create a period from the date/time.
                IPeriod p = CreatePeriod(dt, referenceDate);

                if (!periods.Contains(p))
                {
                    periods.Add(p);
                }
            }


            Periods.Clear();

            Periods.UnionWith(periods);

            return(Periods);
        }
Exemplo n.º 32
0
        /// <summary>
        /// Evaluates this event to determine the dates and times for which the event occurs.
        /// This method only evaluates events which occur between <paramref name="periodStart"/>
        /// and <paramref name="periodEnd"/>; therefore, if you require a list of events which
        /// occur outside of this range, you must specify a <paramref name="periodStart"/> and
        /// <paramref name="periodEnd"/> which encapsulate the date(s) of interest.
        /// <note type="caution">
        ///     For events with very complex recurrence rules, this method may be a bottleneck
        ///     during processing time, especially when this method in called for a large number
        ///     of events, in sequence, or for a very large time span.
        /// </note>
        /// </summary>
        /// <param name="referenceTime"></param>
        /// <param name="periodStart">The beginning date of the range to evaluate.</param>
        /// <param name="periodEnd">The end date of the range to evaluate.</param>
        /// <param name="includeReferenceDateInResults"></param>
        /// <returns></returns>
        public override HashSet <IPeriod> Evaluate(IDateTime referenceTime, DateTime periodStart, DateTime periodEnd, bool includeReferenceDateInResults)
        {
            // Evaluate recurrences normally
            base.Evaluate(referenceTime, periodStart, periodEnd, includeReferenceDateInResults);

            foreach (var period in Periods.Where(period => period.EndTime == null))
            {
                period.Duration = Event.Duration;
                period.EndTime  = period.Duration == null
                    ? period.StartTime
                    : period.StartTime.Add(Event.Duration);
            }

            // Ensure each period has a duration
            //for (var i = 0; i < Periods.Count; i++)
            //{
            //    var p = Periods[i];
            //    if (p.EndTime == null)
            //    {
            //        p.Duration = Event.Duration;
            //        if (p.Duration != null)
            //            p.EndTime = p.StartTime.Add(Event.Duration);
            //        else p.EndTime = p.StartTime;
            //    }
            //}

            return(Periods);
        }
Exemplo n.º 33
0
        public PeriodsResponse Delete(Periods request)
        {
            Bm2s.Data.Common.BLL.Parameter.Period item = Datas.Instance.DataStorage.Periods[request.Period.Id];
              item.EndingDate = DateTime.Now;
              Datas.Instance.DataStorage.Periods[item.Id] = item;

              PeriodsResponse response = new PeriodsResponse();
              response.Periods.Add(request.Period);
              return response;
        }
Exemplo n.º 34
0
        public PeriodsResponse Get(Periods request)
        {
            PeriodsResponse response = new PeriodsResponse();
              List<Bm2s.Data.Common.BLL.Parameter.Period> items = new List<Data.Common.BLL.Parameter.Period>();
              if (!request.Ids.Any())
              {
            items.AddRange(Datas.Instance.DataStorage.Periods.Where(item =>
              (string.IsNullOrWhiteSpace(request.Code) || item.Code.ToLower().Contains(request.Code.ToLower())) &&
              (string.IsNullOrWhiteSpace(request.Name) || item.Name.ToLower().Contains(request.Name.ToLower())) &&
              (request.UnitId == 0 || item.UnitId == request.UnitId) &&
              (!request.Date.HasValue || (request.Date >= item.StartingDate && (!item.EndingDate.HasValue || request.Date < item.EndingDate.Value)))
              ));
              }
              else
              {
            items.AddRange(Datas.Instance.DataStorage.Periods.Where(item => request.Ids.Contains(item.Id)));
              }

              var collection = (from item in items
                        select new Bm2s.Poco.Common.Parameter.Period()
                        {
                          Code = item.Code,
                          EndingDate = item.EndingDate,
                          Id = item.Id,
                          Interval = item.Interval,
                          Name = item.Name,
                          StartingDate = item.StartingDate,
                          Unit = new UnitsService().Get(new Units() { Ids = new List<int>() { item.UnitId } }).Units.FirstOrDefault()
                        }).AsQueryable().OrderBy(request.Order, !request.DescendingOrder);

              response.ItemsCount = collection.Count();
              if (request.PageSize > 0)
              {
            response.Periods.AddRange(collection.Skip((request.CurrentPage - 1) * request.PageSize).Take(request.PageSize));
              }
              else
              {
            response.Periods.AddRange(collection);
              }

              try
              {
            response.PagesCount = collection.Count() / response.Periods.Count + (collection.Count() % response.Periods.Count > 0 ? 1 : 0);
              }
              catch
              {
            response.PagesCount = 1;
              }

              return response;
        }
Exemplo n.º 35
0
 public PWM(Cpu.Pin pin, Periods period)
     : this(pin, (uint)period)
 {
 }
Exemplo n.º 36
0
        public static DateTime SubtractPeriodFromDate(DateTime utcDate, Periods period)
        {
            switch (period)
            {
                case Periods.FiveYears:
                    return utcDate.AddYears(-5);
                case Periods.Forever:
                    return DateTime.MinValue;
                case Periods.OneMonth:
                    return utcDate.AddMonths(-1);
                case Periods.OneTime:
                    return utcDate;
                case Periods.OneWeek:
                    return utcDate.AddDays(-7);
                case Periods.OneYear:
                    return utcDate.AddYears(-1);
                case Periods.SixMonths:
                    return utcDate.AddMonths(-6);
                case Periods.ThirtyDays:
                    return utcDate.AddDays(-30);
                case Periods.ThreeMonths:
                    return utcDate.AddMonths(-3);
                case Periods.TwoWeeks:
                    return utcDate.AddDays(-14);
                case Periods.TwoYears:
                    return utcDate.AddYears(-2);
                case Periods.Unknown:
                    return utcDate;
            }

            return utcDate;
        }
Exemplo n.º 37
0
        public static IHtmlString Contents(string[] kinds = null, Func<ContentHead, HelperResult> itemTemplate = null, string order = "Date", Periods period = Periods.AnyTime, DateTime? createdFrom = null, DateTime? createdTo = null, bool parseContent = false, int top = 0, string navigationId = null, string location = null, string filter = null, IHtmlString noItemMessage = null, System.Linq.Expressions.Expression<Func<ContentHead, bool>> queryFilter = null)
        {
            if (itemTemplate == null)
                itemTemplate = (head) => { return new HelperResult(w => w.Write("<li>" + ContentLink(head) + "</li>")); };
            string str = "";

            int skip = 0;
            if (navigationId != null)
            {
                top = BoxLib.GetListPageSize(navigationId);
                skip = BoxLib.GetPageSkipForList(navigationId) * top;
            }

            SiteService site = new SiteService();

            DateTime? startDate = createdFrom;
            if (period != Periods.AnyTime)
            {
                DateTime? lastPublished = DateTime.Now;
                lastPublished = site.GetLastPublishDate(location, kinds);
                startDate = period.StartDate(lastPublished);
            }

            var contents = BoxLib.GetContents(location, order, kinds, startDate, createdTo, parseContent, skip, top + 1, filter, queryFilter);
            int i = 0;
            foreach (ContentHead head in contents) {
                if (i < top) {
                    head.OrderIndex = i;
                    str = str + itemTemplate(head).ToString();
                    i++;
                }
            }

            if (navigationId != null) {

                bool hasMorePage = contents.Count() == top + 1;
                int realCount = contents.Count();
                if (realCount > top)
                    realCount = top;

                BoxLib.SetListIsOver(navigationId, !hasMorePage);
                BoxLib.SetListCount(navigationId, realCount);
            }

            if (contents.Count() == 0)
            {
                if (noItemMessage != null)
                    return noItemMessage;
                else
                    return new HtmlString("<li>No items.</li>");
            }

            return new HtmlString(str);
        }
Exemplo n.º 38
0
        public static IHtmlString ContentsRelatedWithHotestThread(Func<ContentHead, HelperResult> itemTemplate = null, string location = null, string[] kinds = null, ContentRanks rankBy = ContentRanks.PageViews, Periods period = Periods.LastDay, int top = 5, string navigationId = null)
        {
            SiteService site = new SiteService();

            DateTime? lastPublished = DateTime.Now;
            if (period != Periods.AnyTime)
                lastPublished = site.GetLastPublishDate(location, kinds);

            ContentHead hotContent = site.GetHotestContent(kinds, location, rankBy, period.StartDate(lastPublished), null);
            if (hotContent == null)
                return new HtmlString("");
            return ContentsRelated(hotContent.TagsToArray(), itemTemplate, null, null, null, false, top, navigationId);
        }
Exemplo n.º 39
0
 protected PWM(Periods period)
 {
     _period = (uint)period;
 }