private void button_Click(object sender, RoutedEventArgs e)
 {
     //StartTime = DateTime.Parse(DatePicker1.Text + " " + textBox.Text + ":" + textBox1.Text + ":00");
     if (DatePicker1.SelectedDate == null || DatePicker2.SelectedDate == null)
     {
         MessageBox.Show("请选择日期!");
         return;
     }
     StartTime = DatePicker1.SelectedDate.Value.AddHours(int.Parse(textBox.Text)).AddMinutes(int.Parse(textBox1.Text));
     //EndTime = DateTime.Parse(DatePicker2.Text + " " + textBox_Copy.Text + ":" + textBox1_Copy.Text + ":00");
     EndTime = DatePicker2.SelectedDate.Value.AddHours(int.Parse(textBox_Copy.Text)).AddMinutes(int.Parse(textBox1_Copy.Text));
     if (StartTime >= EndTime)
     {
         MessageBox.Show("截止时间不能早于出发时间!");
     }
     else if (StartTime.AddDays(30) < EndTime)
     {
         MessageBox.Show("查询时间跨度不能大于30天!");
     }
     else
     {
         QueryStartTime = StartTime;
         QueryEndTime   = EndTime;
         Close();
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the time at a certain index
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public DateTime GetTime(int index)
        {
            switch (TimeStepSize)
            {
            case TimeStepUnit.Year:
                return(StartTime.AddYears(TimeStepMultiplier * index));

            case TimeStepUnit.Month:
                return(StartTime.AddMonths(TimeStepMultiplier * index));

            case TimeStepUnit.Day:
                return(StartTime.AddDays(TimeStepMultiplier * index));

            case TimeStepUnit.Hour:
                return(StartTime.AddHours(TimeStepMultiplier * index));

            case TimeStepUnit.Minute:
                return(StartTime.AddMinutes(TimeStepMultiplier * index));

            case TimeStepUnit.Second:
                return(StartTime.AddSeconds(TimeStepMultiplier * index));

            case TimeStepUnit.None:
            default:
                return(DateTime.MinValue);
            }
        }
Exemplo n.º 3
0
 private Mute(string ip, string reason, int durationDays, string muter)
 {
     Ip        = ip;
     StartTime = DateTime.UtcNow;
     Reason    = reason;
     EndTime   = StartTime.AddDays(durationDays);
     Muter     = muter;
 }
Exemplo n.º 4
0
 private Ban(string ip, string reason, int durationDays, string banner)
 {
     Ip        = ip;
     StartTime = DateTime.UtcNow;
     Reason    = reason;
     EndTime   = StartTime.AddDays(durationDays);
     Banner    = banner;
 }
Exemplo n.º 5
0
        public void SetProgram(IProgram program)
        {
            IProgramRecordingStatus recordingStatus = program as IProgramRecordingStatus;

            if (recordingStatus != null)
            {
                UpdateState(recordingStatus.RecordingStatus);
            }
            try
            {
                IChannel             channel;
                IChannelAndGroupInfo channelAndGroupInfo = ServiceRegistration.Get <ITvHandler>().ChannelAndGroupInfo;
                if (program != null && channelAndGroupInfo != null && channelAndGroupInfo.GetChannel(program.ChannelId, out channel))
                {
                    ChannelName = channel.Name;
                }

                _settingProgram = true;
                IProgramSeries series = program as IProgramSeries;
                if (series != null)
                {
                    SeasonNumber  = series.SeasonNumber;
                    EpisodeNumber = series.EpisodeNumber;
                    EpisodeTitle  = series.EpisodeTitle;
                    Series        = BuildSeriesText(this);
                }
                else
                {
                    SeasonNumber  = string.Empty;
                    EpisodeNumber = string.Empty;
                    EpisodeTitle  = string.Empty;
                    Series        = string.Empty;
                }
                if (program != null)
                {
                    ProgramId   = program.ProgramId;
                    Title       = program.Title;
                    Description = program.Description;
                    StartTime   = program.StartTime;
                    EndTime     = program.EndTime;
                    Genre       = program.Genre;
                }
                else
                {
                    ProgramId   = 0;
                    Title       = string.Empty;
                    Description = string.Empty;
                    StartTime   = DateTime.Now.GetDay();
                    EndTime     = StartTime.AddDays(1);
                    Genre       = string.Empty;
                }
                UpdateDuration();
            }
            finally
            {
                _settingProgram = false;
            }
        }
 /// <summary>
 /// Gets an estimated end time for the match or tournament based on the start time and a typical duration
 /// </summary>
 /// <returns></returns>
 public DateTimeOffset EstimatedEndTime()
 {
     if (StartTimeIsKnown)
     {
         return((MatchType == null) ? StartTime.AddHours(7) : StartTime.AddMinutes(90));
     }
     else
     {
         return(StartTime.AddDays(1));
     }
 }
Exemplo n.º 7
0
        public void SetProgram(IProgram program)
        {
            IProgramRecordingStatus recordingStatus = program as IProgramRecordingStatus;

            if (recordingStatus != null)
            {
                UpdateState(recordingStatus.RecordingStatus);
            }
            try
            {
                _settingProgram = true;
                IProgramSeries series = program as IProgramSeries;
                if (series != null)
                {
                    SeasonNumber  = series.SeasonNumber;
                    EpisodeNumber = series.EpisodeNumber;
                    EpisodeTitle  = series.EpisodeTitle;
                    Series        = BuildSeriesText(this);
                }
                else
                {
                    SeasonNumber  = string.Empty;
                    EpisodeNumber = string.Empty;
                    EpisodeTitle  = string.Empty;
                    Series        = string.Empty;
                }
                if (program != null)
                {
                    ProgramId   = program.ProgramId;
                    Title       = program.Title;
                    Description = program.Description;
                    StartTime   = program.StartTime;
                    EndTime     = program.EndTime;
                    Genre       = program.Genre;
                }
                else
                {
                    ProgramId   = 0;
                    Title       = string.Empty;
                    Description = string.Empty;
                    StartTime   = DateTime.Now.GetDay();
                    EndTime     = StartTime.AddDays(1);
                    Genre       = string.Empty;
                }
                UpdateDuration();
            }
            finally
            {
                _settingProgram = false;
            }
        }
Exemplo n.º 8
0
        private void _timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            _timer.Enabled = false;
            while (DateTime.Now > EndTime)
            {
                StartTime = StartTime.AddDays(1);
                EndTime   = EndTime.AddDays(1);
            }
            bool triggerNow = ((DateTime.Now >= StartTime) && (DateTime.Now <= EndTime) && (DaysToRun.Contains(DateTime.Today.Day)) && (MonthsToRun.Contains(DateTime.Today.Month)));

            if (triggerNow && (TimesToRun.Count > 0))
            {
                triggerNow = false;
                DateTime[] timesToRun = TimesToRun.ToArray();
                foreach (DateTime dateTime in timesToRun)
                {
                    if (dateTime < DateTime.Now)
                    {
                        triggerNow = true;
                        DateTime nextExecTime = dateTime.AddDays(1);
                        while (nextExecTime < DateTime.Now)
                        {
                            nextExecTime = nextExecTime.AddDays(1);
                        }
                        TimesToRun.Remove(dateTime);
                        TimesToRun.Add(nextExecTime);
                    }
                }
            }

            if (triggerNow)
            {
                triggerNow = WeekDaysToRun.HasFlag((ListenerDaysOfWeek)Enum.Parse(typeof(ListenerDaysOfWeek), DateTime.Today.DayOfWeek.ToString()));
            }

            if (triggerNow)
            {
                TriggerEvent();
            }
            _timer.Enabled = true;
        }
Exemplo n.º 9
0
        public void Roll()
        {
            //获取这天的配送类型
            GetDeliveryType();

            //获取备货周期
            if (PrepareSections == null)
            {
                GetPrepareSections();
            }

            //隔日配送
            if (IntervalDays > 0)
            {
                DateTime newDate = StartTime.AddDays(IntervalDays);
                int      presc   = PrepareSections.HasValue ? PrepareSections.Value : 0;//?
                //重置属性
                ReSetProperty(newDate, 0, presc);
                //递归
                Roll();
            }
            else
            {
                int secs = PrepareSections.Value - Sections;

                if (secs > 0)
                {
                    ReSetProperty(StartTime.AddDays(1), 0, secs);
                    //递归
                    Roll();
                }
                else
                {
                    LatestDate   = StartTime.Date;
                    FinalSection = DeliveryType == 2 ? PrepareSections.Value : 0;
                }
            }
        }
Exemplo n.º 10
0
        public void SetProgram(IProgram program)
        {
            IProgramRecordingStatus recordingStatus = program as IProgramRecordingStatus;

            if (recordingStatus != null)
            {
                IsScheduled = recordingStatus.RecordingStatus != RecordingStatus.None;
            }
            try
            {
                _settingProgram = true;
                if (program != null)
                {
                    ProgramId   = program.ProgramId;
                    Title       = program.Title;
                    Description = program.Description;
                    StartTime   = program.StartTime;
                    EndTime     = program.EndTime;
                    Genre       = program.Genre;
                }
                else
                {
                    ProgramId   = 0;
                    Title       = string.Empty;
                    Description = string.Empty;
                    StartTime   = FormatHelper.GetDay(DateTime.Now);
                    EndTime     = StartTime.AddDays(1);
                    Genre       = string.Empty;
                }
                UpdateDuration();
            }
            finally
            {
                _settingProgram = false;
            }
        }
 public FindMeetingTimesModel()
 {
     StartTime = DateTime.Now;
     EndTime   = StartTime.AddDays(7);
 }
Exemplo n.º 12
0
        private void GetConclusion()
        {
            string subconclusion = string.Empty;
            bool   hasconclusion = false;

            //1
            foreach (var device in DevicesView)
            {
                subconclusion += device.DeviceTreeItemViewModel.Name + "、";
            }
            if (subconclusion != string.Empty)
            {
                subconclusion = subconclusion.Substring(0, subconclusion.Length - 1);
            }
            this.DeviceRunAnalyze.ConclusionDevices = subconclusion;

            //2
            this.DeviceRunAnalyze.ConclusionHeader = "在" + StartTime.ToString("yyyy-MM-dd HH:mm:ss") + "至" + StartTime.AddDays(SelectedDay).ToString("yyyy-MM-dd HH:mm:ss") + "期间设备运行状态如下:";

            //3
            subconclusion = null;
            foreach (var device in DevicesView)
            {
                if (device.AlarmGrade == AlarmGrade.HighPreAlarm || device.AlarmGrade == AlarmGrade.LowPreAlarm ||
                    device.AlarmGrade == AlarmGrade.HighAlarm || device.AlarmGrade == AlarmGrade.LowAlarm ||
                    device.AlarmGrade == AlarmGrade.HighDanger || device.AlarmGrade == AlarmGrade.LowDanger)
                {
                    if (subconclusion == null)
                    {
                        subconclusion = "需要关注的设备有:";
                    }
                    subconclusion += device.DeviceTreeItemViewModel.Name + "(" + device.MaxResult.ToString("f3") + device.Unit + ")" + "、";
                    hasconclusion  = true;
                }
            }
            if (subconclusion != null)
            {
                subconclusion = subconclusion.Substring(0, subconclusion.Length - 1);
            }
            this.DeviceRunAnalyze.ConclusionAlarm = subconclusion;

            //4
            subconclusion = null;
            foreach (var device in DevicesView)
            {
                if (device.DiagnosticAdvice != null && device.DiagnosticInfo != null)
                {
                    if (subconclusion == null)
                    {
                        subconclusion = "需要重点关注的设备有:\r\n";
                    }
                    subconclusion += device.DeviceTreeItemViewModel.Name + "(" + device.DiagnosticInfo + ")\r\n" + device.DiagnosticAdvice + "\r\n";
                    hasconclusion  = true;
                }
            }
            if (subconclusion != null)
            {
                subconclusion = subconclusion.Substring(0, subconclusion.Length - 2);
            }
            this.DeviceRunAnalyze.ConclusionDanger = subconclusion;

            //5
            if (hasconclusion == true)
            {
                this.DeviceRunAnalyze.ConclusionEnd = "其它设备正常运行";
            }
            else
            {
                this.DeviceRunAnalyze.ConclusionEnd += "所有设备正常运行";
            }
        }
Exemplo n.º 13
0
    protected void btnAdd_Click(object sender, System.EventArgs e)
    {
        string Isuse = "";

        try
        {
            Isuse = Shove._Web.Utility.FilteSqlInfusion(tbIsuse.Text.Trim());
        }
        catch { }

        if (Isuse == "")
        {
            Shove._Web.JavaScript.Alert(this.Page, "期号不能为空!");

            return;
        }

        DataTable dt = new DAL.Tables.T_Isuses().Open("[ID]", "[Name] = '" + Isuse + "' and LotteryID = " + Shove._Web.Utility.FilteSqlInfusion(tbLotteryID.Text), "");

        if (dt == null)
        {
            PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", this.GetType().FullName);

            return;
        }

        if (dt.Rows.Count > 0)
        {
            Shove._Web.JavaScript.Alert(this.Page, "期号已经存在,请不要输入重名期号!");

            return;
        }

        System.DateTime StartTime, EndTime;

        object time = PF.ValidLotteryTime(tbStartTime.Text);

        if (time == null)
        {
            Shove._Web.JavaScript.Alert(this.Page, "开始时间格式输入错误!");
            return;
        }

        StartTime = (DateTime)time;

        time = PF.ValidLotteryTime(tbEndTime.Text);

        if (time == null)
        {
            Shove._Web.JavaScript.Alert(this.Page, "截止时间格式输入错误!");
            return;
        }

        EndTime = (DateTime)time;

        if (EndTime <= StartTime)
        {
            Shove._Web.JavaScript.Alert(this.Page, "截止时间应该在开始时间之后!");

            return;
        }

        string AdditionasXml = "";

        if ((tbLotteryID.Text == SZJS.Lottery.SFC.sID || tbLotteryID.Text == SZJS.Lottery.ZCSFC.sID || tbLotteryID.Text == SZJS.Lottery.ZCRJC.sID) && (BuildAdditionasXmlForSFC(ref AdditionasXml) < 0))
        {
            return;
        }

        if ((tbLotteryID.Text == SZJS.Lottery.JQC.sID) && (BuildAdditionasXmlForJQC(ref AdditionasXml) < 0))
        {
            return;
        }

        if ((tbLotteryID.Text == SZJS.Lottery.LCBQC.sID) && (BuildAdditionasXmlForLCBQC(ref AdditionasXml) < 0))
        {
            return;
        }

        if ((tbLotteryID.Text == SZJS.Lottery.LCDC.sID) && (BuildAdditionasXmlForLCDC(ref AdditionasXml) < 0))
        {
            return;
        }

        if ((tbLotteryID.Text == SZJS.Lottery.ZCDC.sID) && (BuildAdditionasXmlForZCDC(ref AdditionasXml) < 0))
        {
            return;
        }

        int LotteryID = int.Parse(tbLotteryID.Text);

        long   NewIsuseID        = -1;
        string ReturnDescription = "";

        int Result = DAL.Procedures.P_IsuseAdd(LotteryID, Isuse, StartTime, EndTime, AdditionasXml, ref NewIsuseID, ref ReturnDescription);

        if (Result < 0)
        {
            PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", this.GetType().FullName);

            return;
        }

        if (NewIsuseID < 0)
        {
            PF.GoError(ErrorNumber.Unknow, ReturnDescription, this.GetType().FullName);

            return;
        }

        if (cbAutoNext10Isuse.Visible && cbAutoNext10Isuse.Checked && (AdditionasXml == ""))
        {
            string IsuseYear = Isuse.Substring(0, Isuse.Length - 3);
            int    IsuseNum  = Shove._Convert.StrToInt(Isuse.Substring(Isuse.Length - 3, 3), 0);

            for (int i = 1; i <= 9; i++)
            {
                IsuseNum++;
                string NextIsuse = IsuseYear + IsuseNum.ToString().PadLeft(3, '0');
                StartTime = StartTime.AddDays(1);
                EndTime   = EndTime.AddDays(1);
                int Results = -1;
                Results = DAL.Procedures.P_IsuseAdd(LotteryID, NextIsuse, StartTime, EndTime, "", ref NewIsuseID, ref ReturnDescription);
                if (Results < 0)
                {
                    break;
                }

                if (NewIsuseID < 0)
                {
                    continue;
                }
            }
        }

        this.Response.Redirect("Isuse2.aspx?LotteryID=" + tbLotteryID.Text, true);
    }
Exemplo n.º 14
0
        public override IDataProvider GetData(string Code, int Count)
        {
            try
            {
                CommonDataProvider cdp = new CommonDataProvider(this);
                cdp.DateMergeType = MergeCycleType.OPEN;
                DbParam[] dps = new DbParam[] {
                    new DbParam("@Symbol", DbType.String, Code),
                    new DbParam("@Q1", DbType.DateTime, StartTime.AddDays(-5)),
                    new DbParam("@Q2", DbType.DateTime, EndTime),
                };
                BaseDb bd = DB.Open(false);
                try
                {
                    DataTable dt    = bd.GetDataTable("select Price,Volume,QuoteTime from Intraday where Symbol=? and QuoteTime>=? and QuoteTime<=? order by QuoteTime", dps);
                    double    LastV = -1;
                    foreach (DataRow dr in dt.Rows)
                    {
                        double NowV = (double)dr["Volume"];
                        if (LastV >= 0)
                        {
                            if (NowV > LastV)
                            {
                                dr["Volume"] = NowV - LastV;
                            }
                            else
                            {
                                dr["Volume"] = (double)0;
                            }
                        }
                        LastV = NowV;
                    }

                    dps[2].Value = StartTime;
                    dps[1].Value = StartTime.AddDays(-30);
                    DataRow drr = bd.GetFirstRow("select Price from Intraday where Symbol=? and QuoteTime>=? and QuoteTime<? order by QuoteTime desc", dps);

                    if (dt.Rows.Count > 0)
                    {
                        cdp.SetStringData("LastTradeTime", ((DateTime)dt.Rows[dt.Rows.Count - 1]["QuoteTime"]).ToString("yyyy-MM-dd HH:mm:ss", DateTimeFormatInfo.InvariantInfo));
                    }
                    if (drr != null)
                    {
                        cdp.SetStringData("LastPrice", drr[0].ToString());
                    }
                    SetStrings(cdp, Code);

                    if (dt.Rows.Count == 0)
                    {
                        dt.Rows.Add(new object[] { double.NaN, 0, StartTime });
                    }
                    double[] CLOSE  = new double[dt.Rows.Count];
                    double[] VOLUME = new double[dt.Rows.Count];
                    double[] DATE   = new double[dt.Rows.Count];

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        CLOSE[i]  = ToAutoDouble(dt.Rows[i]["Price"]);
                        VOLUME[i] = ToAutoDouble(dt.Rows[i]["Volume"]);
                        DATE[i]   = ((DateTime)dt.Rows[i]["QuoteTime"]).ToOADate();
                    }
                    cdp.LoadBinary("CLOSE", CLOSE);
                    cdp.LoadBinary("DATE", DATE);
                    cdp.LoadBinary("VOLUME", VOLUME);
                }
                finally
                {
                    bd.Close();
                }
                return(cdp);
            }
            catch (Exception e)
            {
                Tools.Log("IntraDataManager:" + e.Message);
            }
            return(base.GetData(Code, Count));
        }
Exemplo n.º 15
0
        public void SetProgram(IProgram program, IChannel channel = null)
        {
            IProgramRecordingStatus recordingStatus = program as IProgramRecordingStatus;

            if (recordingStatus != null)
            {
                UpdateState(recordingStatus.RecordingStatus);
            }
            try
            {
                if (channel == null && program != null)
                {
                    IChannelAndGroupInfoAsync channelAndGroupInfo = ServiceRegistration.Get <ITvHandler>().ChannelAndGroupInfo;
                    if (channelAndGroupInfo != null)
                    {
                        var result = channelAndGroupInfo.GetChannelAsync(program.ChannelId).Result;
                        if (result.Success)
                        {
                            channel = result.Result;
                        }
                    }
                }

                ChannelName     = channel?.Name ?? "";
                ChannelNumber   = channel?.ChannelNumber ?? 0;
                ChannelLogoType = channel.GetFanArtMediaType();
                _settingProgram = true;
                IProgramSeries series = program as IProgramSeries;
                if (series != null)
                {
                    SeasonNumber  = series.SeasonNumber;
                    EpisodeNumber = series.EpisodeNumber;
                    EpisodeTitle  = series.EpisodeTitle;
                    Series        = BuildSeriesText(this);
                }
                else
                {
                    SeasonNumber  = string.Empty;
                    EpisodeNumber = string.Empty;
                    EpisodeTitle  = string.Empty;
                    Series        = string.Empty;
                }
                if (program != null)
                {
                    ProgramId     = program.ProgramId;
                    Title         = program.Title;
                    Description   = program.Description;
                    StartTime     = program.StartTime;
                    EndTime       = program.EndTime;
                    Genre         = program.Genre;
                    EpgGenreId    = program.EpgGenreId;
                    EpgGenreColor = program.EpgGenreColor;
                }
                else
                {
                    ProgramId     = -1;
                    Title         = string.Empty;
                    Description   = string.Empty;
                    StartTime     = DateTime.Now.GetDay();
                    EndTime       = StartTime.AddDays(1);
                    Genre         = string.Empty;
                    EpgGenreId    = 0;
                    EpgGenreColor = string.Empty;
                }

                NoProgramData = ProgramId == -1;
                UpdateDuration();
            }
            finally
            {
                _settingProgram = false;
            }
        }
Exemplo n.º 16
0
        public QuickDeployment(ConnectionManagerBase connectionManager, IResultObject collectionObject)
            : this()
        {
            this.connectionManager = connectionManager;
            Collection             = collectionObject;

            Match match = Regex.Match(collectionObject["Name"].StringValue, @"(?<=\[)([ANSIR]*)\s?(.*)(?=\])");

            IsPhased = match.Success ? true : false;

            if (match.Groups[1].Success)
            {
                string key = match.Groups[1].Value;

                if (Regex.IsMatch(key, @"[A]"))
                {
                    IsRequired = false;
                }
                if (Regex.IsMatch(key, @"[N]"))
                {
                    UserUIExperience = true;
                    NotifyUser       = false;
                }
                if (Regex.IsMatch(key, @"[I]"))
                {
                    OverrideServiceWindows = true;
                }
                if (Regex.IsMatch(key, @"[R]"))
                {
                    RebootOutsideOfServiceWindows = true;
                }
                if (Regex.IsMatch(key, @"[S]"))
                {
                    SuppressReboot = 3;
                }
            }

            if (match.Groups[2].Success)
            {
                string[] values = match.Groups[2].Value.Split(new char[0], StringSplitOptions.RemoveEmptyEntries);

                if (0 < values.Length && Regex.IsMatch(values[0], @"(\+[0-9]+)"))
                {
                    StartTime    = StartTime.AddDays(Convert.ToDouble(values[0].TrimStart('+')));
                    DeadLineTime = DeadLineTime.AddDays(Convert.ToDouble(values[0].TrimStart('+')));
                }

                if (1 < values.Length && Regex.IsMatch(values[1], @"(([01]\d|2[0-3]):?[0-5]\d)"))
                {
                    string[] time = values[1].Split(':');
                    StartTime    = StartTime.ChangeTime(Convert.ToInt16(time[0]), Convert.ToInt16(time[1]), 0, 0);
                    DeadLineTime = DeadLineTime.ChangeTime(Convert.ToInt16(time[0]), Convert.ToInt16(time[1]), 0, 0);
                }

                if (2 < values.Length && Regex.IsMatch(values[2], @"(\+[0-9]+)"))
                {
                    DeadLineTime = DeadLineTime.AddDays(Convert.ToDouble(values[2].TrimStart('+')));
                }

                if (3 < values.Length && Regex.IsMatch(values[3], @"(([01]\d|2[0-3]):?[0-5]\d)"))
                {
                    string[] time = values[3].Split(':');
                    DeadLineTime = DeadLineTime.ChangeTime(Convert.ToInt16(time[0]), Convert.ToInt16(time[1]), 0, 0);
                }
            }
        }
Exemplo n.º 17
0
 public bool CanBook(DateTime bookTime)
 {
     return(IsOpen && StartTime.AddDays(-30) > bookTime && Vacancies > 0);
 }
Exemplo n.º 18
0
        private List <Object> FormatRecurringEvents(IQueryable <MessageItem> mEvents, DateTimeOffset startDate)
        {
            List <object> fmEvents = new List <object>();

            foreach (var eitem in mEvents)
            {
                var backgroundColor = System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.CornflowerBlue);
                var StartTime       = eitem.ScheduleStart;

                if (eitem.ScheduleInterval == ScheduleIntervalType.Daily)
                {
                    if (startDate.Month > eitem.ScheduleStart.Month)
                    {
                        StartTime = new DateTimeOffset(eitem.ScheduleStart.Year, startDate.Month, startDate.Day, eitem.ScheduleStart.Hour, eitem.ScheduleStart.Minute, eitem.ScheduleStart.Second, eitem.ScheduleStart.Offset);
                    }

                    backgroundColor = System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.Purple);

                    for (var day = StartTime.DayOfYear; day <= new DateTime(startDate.Year, startDate.Month, DateTime.DaysInMonth(startDate.Year, startDate.Month)).DayOfYear; day++)
                    {
                        if (eitem.Expiration.DayOfYear < day)
                        {
                            break;
                        }

                        fmEvents.Add(new
                        {
                            id    = eitem.MessageItemId,
                            title = eitem.MessageTitle,
                            start = StartTime.AddDays(day - StartTime.DayOfYear),
                            //start = new DateTimeOffset(StartTime.Year, StartTime.Month, day, StartTime.Hour, StartTime.Minute, StartTime.Second, StartTime.Offset),
                            end    = eitem.duration,
                            color  = backgroundColor,
                            allDay = false
                        });
                    }
                }

                if (eitem.ScheduleInterval == ScheduleIntervalType.Weekly)
                {
                    if (startDate.DayOfYear >= (eitem.ScheduleStart.DayOfYear + 7))
                    {
                        StartTime = startDate.StartOfWeek(eitem.ScheduleStart.DayOfWeek);
                    }
                    backgroundColor = System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.Orange);

                    for (var day = StartTime.DayOfYear; day <= new DateTime(startDate.Year, startDate.Month, DateTime.DaysInMonth(startDate.Year, startDate.Month)).DayOfYear; day += 7)
                    {
                        if (eitem.Expiration.DayOfYear < day)
                        {
                            break;
                        }

                        fmEvents.Add(new
                        {
                            id    = eitem.MessageItemId,
                            title = eitem.MessageTitle,
                            start = StartTime.AddDays(day - StartTime.DayOfYear),
                            //start = new DateTimeOffset(StartTime.Year, StartTime.Month, new DateTime().AddDays(day - 1).Day, StartTime.Hour, StartTime.Minute, StartTime.Second, StartTime.Offset),
                            end    = eitem.duration,
                            color  = backgroundColor,
                            allDay = false
                        });
                    }
                }

                if (eitem.ScheduleInterval == ScheduleIntervalType.Monthly)
                {
                    backgroundColor = System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.Maroon);

                    if (startDate.Month > eitem.ScheduleStart.Month)
                    {
                        StartTime = new DateTimeOffset(startDate.Year, startDate.Month, eitem.ScheduleStart.Day, eitem.ScheduleStart.Hour, eitem.ScheduleStart.Minute, eitem.ScheduleStart.Second, eitem.ScheduleStart.Offset);
                    }

                    if (eitem.Expiration < StartTime)
                    {
                        continue;
                    }

                    fmEvents.Add(new
                    {
                        id     = eitem.MessageItemId,
                        title  = eitem.MessageTitle,
                        start  = StartTime,
                        end    = eitem.duration,
                        color  = backgroundColor,
                        allDay = false
                    });
                }

                if (eitem.ScheduleInterval == ScheduleIntervalType.Hourly)
                {
                    backgroundColor = System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.Lime);

                    for (var day = eitem.ScheduleStart.Day; day <= DateTime.DaysInMonth(startDate.Year, startDate.Month); day++)
                    {
                        fmEvents.Add(new
                        {
                            id     = eitem.MessageItemId,
                            title  = eitem.MessageTitle,
                            start  = new DateTimeOffset(eitem.ScheduleStart.Year, eitem.ScheduleStart.Month, day, eitem.ScheduleStart.Hour, eitem.ScheduleStart.Minute, eitem.ScheduleStart.Second, eitem.ScheduleStart.Offset),
                            end    = eitem.duration,
                            color  = backgroundColor,
                            allDay = false
                        });
                    }
                }

                if (eitem.ScheduleInterval == ScheduleIntervalType.Never)
                {
                    fmEvents.Add(new
                    {
                        id     = eitem.MessageItemId,
                        title  = eitem.MessageTitle,
                        start  = eitem.ScheduleStart,
                        end    = eitem.duration,
                        color  = backgroundColor,
                        allDay = false
                    });
                }
            }

            return(fmEvents);
        }
Exemplo n.º 19
0
        private async void Search()
        {
            var sw = Stopwatch.StartNew();

            try
            {
                int number = 0;
                Status = ViewModelStatus.Querying;

                DevicesView.Clear();
                resultDevices.Clear();
                DeviceHourlySelectedResult.Clear();

                for (int i = 0; i < SelectedDay; i++)
                {
                    DeviceHourlySelectedResult.Add(new DeviceHourlySelectedResult()
                    {
                        DateTime = StartTime.AddDays(i), IsChecked = true
                    });
                }


                var deviceTrees = _cardProcess.GetDevices(selectedOrganization);
                if (deviceTrees == null)
                {
                    return;
                }

                foreach (var deviceTree in deviceTrees)
                {
                    WaitInfo = "数据统计: " + number.ToString();
                    List <DeviceHourlyDataInfo> devices = new List <DeviceHourlyDataInfo>();

                    DateTime start = StartTime;
                    for (int day = SelectedDay; day > 0;)
                    {
                        int dayRange = day > 30 ? 30 : day;
                        devices.AddRange(await GetDeviceHourlyData(deviceTree, start, dayRange));
                        day   = day - dayRange;
                        start = start.AddDays(dayRange);
                    }
                    if (devices == null)
                    {
                        continue;
                    }
                    devices.ForEach(p => p.DeviceTreeItemViewModel = deviceTree);
                    resultDevices.Add(devices);
                    DeviceHourlyDataInfo device = devices.FirstOrDefault();

                    number++;

                    DevicesView.Add(device);
                }
            }
            catch (Exception ex)
            {
                _eventAggregator.GetEvent <ThrowExceptionEvent>().Publish(Tuple.Create <string, Exception>("设备数据-运行状态查询", ex));
            }
            finally
            {
                Console.WriteLine("消耗时间" + sw.Elapsed.ToString());
                Status = ViewModelStatus.None;
            }
        }
Exemplo n.º 20
0
 partial void EndTime_Compute(ref DateTime result)
 {
     // Set result to the desired field value
     result = StartTime.AddDays(2.5);
 }
Exemplo n.º 21
0
 private void btnPlus1Day_Click(object sender, EventArgs e)
 {
     StartTime = StartTime.AddDays(ONE_DAY);
     Redraw();
 }
Exemplo n.º 22
0
        //public IList<ActivityEntity> ActivityEntities { get; set; }

        public async Task <IActionResult> OnGetAsync()
        {
            PopulateTimeFrameDropDownList(_context, "");
            StartTime = DateTimeOffset.UtcNow.ToLocalTime();

            //remove hours, minutes, seconds, milliseconds
            StartTime = StartTime.AddMilliseconds(-StartTime.Millisecond).AddSeconds(-StartTime.Second).AddMinutes(-StartTime.Minute).AddHours(-StartTime.Hour);

            //get current day of week
            var dayOfWeek = StartTime.DayOfWeek;

            //if Sunday subtract 6 to get the previous Monday, otherwise subtract the day of week index plus one
            var daysToSubtract = (dayOfWeek) == DayOfWeek.Sunday ? -6 : -(int)dayOfWeek + 1;

            StartTime = StartTime.AddDays(daysToSubtract);
            EndTime   = StartTime.AddDays(6).AddHours(23).AddMinutes(59).AddSeconds(59).AddMilliseconds(999);

            Rate = 37.5M;

            var p = new object[]
            {
                new SqlParameter("@p0", SqlDbType.DateTimeOffset, 7)
                {
                    Value = StartTime
                },
                new SqlParameter("@p1", SqlDbType.DateTimeOffset, 7)
                {
                    Value = EndTime
                },
                new SqlParameter("@p2", SqlDbType.Money, 4)
                {
                    Value = Rate
                },
                new SqlParameter("@p3", SqlDbType.Bit, 1)
                {
                    Value = true
                }
            };

            Clients = await _context.Clients.ToListAsync();

            Projects = await _context.Projects.ToListAsync();

            ActivityTypes = await _context.ActivityTypes.ToListAsync();

            Report = await _context
                     .Report
                     .FromSqlRaw("EXEC sp_Report @p0, @p1, @p2, @p3", p)
                     .TagWith("my statement")
                     .ToListAsync();

            ReportDetails = await _context.ReportDetails
                            .FromSqlRaw("EXEC sp_ReportDetails @p0, @p1, @p2, @p3", p)
                            .TagWith("my second statement")
                            .ToListAsync();

            ReportDetailsByDay = await _context.ReportDetailsByDay
                                 .FromSqlRaw("EXEC sp_ReportDetailsByDay @p0, @p1, @p2, @p3", p)
                                 .TagWith("my third statement")
                                 .ToListAsync();

            //ActivityEntities = await PopulateActivityEntities(StartTime, EndTime);
            return(Page());
        }
Exemplo n.º 23
0
 public void AddDay()
 {
     StartTime = StartTime.AddDays(1);
 }