protected override void OnMouseWheel(MouseWheelEventArgs e) { base.OnMouseWheel(e); var time = TimeEnd - TimeStart; if (e.Delta < 0) { if (time.Days > 182) { return; } TimeStart = TimeStart.AddDays(-1); TimeEnd = TimeEnd.AddDays(1); } else { if (time.Days < 7) { return; } TimeStart = TimeStart.AddDays(1); TimeEnd = TimeEnd.AddDays(-1); } isDirty = true; InvalidateVisual(); }
public override int GetHashCode() { int hash = 1; if (MsgCmd != 0) { hash ^= MsgCmd.GetHashCode(); } if (Uuid.Length != 0) { hash ^= Uuid.GetHashCode(); } if (TimeStart.Length != 0) { hash ^= TimeStart.GetHashCode(); } if (TimeEnd.Length != 0) { hash ^= TimeEnd.GetHashCode(); } if (ImageBase64.Length != 0) { hash ^= ImageBase64.GetHashCode(); } if (Processed != 0) { hash ^= Processed.GetHashCode(); } hash ^= targetFeatureList_.GetHashCode(); hash ^= targetResultList_.GetHashCode(); return(hash); }
/// <summary> /// 清空数据 /// </summary> private void FrmClear() { VehicleHead.SetVehicleText(""); TxtHphm.Text = null; TxtClxh.Text = null; TxtCjh.Text = null; TxtFdjh.Text = null; TxtHdkl.Text = null; TxtSjxm.Text = null; TxtLxdh.Text = null; TxtSjhm.Text = null; TxtClzt.Text = null; TxtClpp.Text = null; TxtHjhm.Text = null; uiDepartment1.DepertId = "";//.Reset(); CmbHpzl.Value = null; CmbHpzl.Value = null; CmbGPS.Value = null; CmbClzl.Value = null; DateField1.Text = null; TxtRyzk.Text = null; TimeStart.Clear(); TimeEnd.Clear(); TxtKkid.Clear(); }
/// <summary> /// Based on the day of the school, decide the start and stop times /// </summary> public void SetSchoolTime() { switch (DayStart) { case SchoolCalendarDismissalEnum.Early: TimeStart = Backend.DataSourceBackend.Instance.SchoolDismissalSettingsBackend.GetDefault().StartEarly; break; case SchoolCalendarDismissalEnum.Late: TimeStart = Backend.DataSourceBackend.Instance.SchoolDismissalSettingsBackend.GetDefault().StartLate; break; case SchoolCalendarDismissalEnum.Normal: TimeStart = Backend.DataSourceBackend.Instance.SchoolDismissalSettingsBackend.GetDefault().StartNormal; break; } switch (DayEnd) { case SchoolCalendarDismissalEnum.Early: TimeEnd = Backend.DataSourceBackend.Instance.SchoolDismissalSettingsBackend.GetDefault().EndEarly; break; case SchoolCalendarDismissalEnum.Late: TimeEnd = Backend.DataSourceBackend.Instance.SchoolDismissalSettingsBackend.GetDefault().EndLate; break; case SchoolCalendarDismissalEnum.Normal: TimeEnd = Backend.DataSourceBackend.Instance.SchoolDismissalSettingsBackend.GetDefault().EndNormal; break; } TimeDuration = TimeEnd.Subtract(TimeStart); }
public void WriteToParcel(Parcel dest, ParcelableWriteFlags flags) { dest.WriteString(Subject); dest.WriteString(Exercise); dest.WriteString(Lesson); dest.WriteString(TimeEnd.ToString("d")); dest.WriteInt(TimeLimited); }
/// <summary> /// 停止计时 /// </summary> public void Stop() { if (_timer == null) { return; } _timer.Stop(); TimeEnd?.Invoke(this, null); }
public void Change(float value) { time += value; if (time <= 0) { time = 0; TimeEnd?.Invoke(); } TimeChangeEvent?.Invoke(time); }
public TimeEnd UpdateTimeEnd(TimeEnd timeEnd) { if (validator.Validate(timeEnd)) { return(_teRepo.UpdateTimeEnd(timeEnd)); } else { throw new InvalidDataException("Invalid Data, follow the format HH:mm (ex 09:45)"); } }
public ActionResult <TimeEnd> Put(int id, [FromBody] TimeEnd timeEnd) { try { return(Ok(_teService.UpdateTimeEnd(timeEnd))); } catch (Exception e) { return(BadRequest(e.Message)); } }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); var pos = e.GetPosition(this); var rHeader = new Rect(0, 0, ActualWidth, rowMonthAndDay); if (rHeader.Contains(pos)) { Cursor = Cursors.Hand; } else { Cursor = Cursors.Arrow; } if (isDown) { switch (mode) { #region Move case DragMode.Move: { if (mouseStartMoveX - pos.X > 20) { TimeStart = TimeStart.AddDays(1); TimeEnd = TimeEnd.AddDays(1); mouseStartMoveX = pos.X; isDirty = true; } else if (mouseStartMoveX - pos.X < -20) { TimeStart = TimeStart.AddDays(-1); TimeEnd = TimeEnd.AddDays(-1); mouseStartMoveX = pos.X; isDirty = true; } break; } #endregion } } InvalidateVisual(); }
public bool Validate(TimeEnd timeEnd) { if (timeEnd == null) { throw new InvalidDataException("TimeEnd can't be null"); } if (string.IsNullOrEmpty(timeEnd.timeEnd)) { throw new InvalidDataException("TimeEnd can't be empty"); } if (timeEnd.timeEnd.Length != 5) { throw new InvalidDataException("TimeEnd string is too long/short, follow format HH:mm"); } int hours; if (!int.TryParse(timeEnd.timeEnd.Substring(0, 2), out hours)) { throw new InvalidDataException("TimeEnd string has to be numbers"); } int minutes; if (!int.TryParse(timeEnd.timeEnd.Substring(3, 2), out minutes)) { throw new InvalidDataException("TimeEnd string has to be numbers"); } if (!timeEnd.timeEnd.Substring(2, 1).Equals(":")) { throw new InvalidDataException("TimeEnd string has to be in format of HH:mm (ex 09:45)"); } minutes = int.Parse(timeEnd.timeEnd.Substring(3, 2)); if (minutes > 59 || minutes < 0) { throw new InvalidDataException("TimeEnd string minutes has to be 00-59"); } hours = int.Parse(timeEnd.timeEnd.Substring(0, 2)); if (hours > 23 || hours < 0) { throw new InvalidDataException("TimeEnd string hours has to be 00-23"); } return(true); }
public void CreateTimeEndNotNumbersThrowException() { var teRepo = new Mock <ITimeEndRepo>(); var teService = new TimeEndService(teRepo.Object); var timeEnd = new TimeEnd() { id = 1, timeEnd = "hh:mm" }; Exception ex = Assert.Throws <InvalidDataException>(() => teService.CreateTimeEnd(timeEnd)); Assert.Equal("TimeEnd string has to be numbers", ex.Message); }
public void CreateTimeEndWithEmptyTimeThrowsException() { var teRepo = new Mock <ITimeEndRepo>(); var teService = new TimeEndService(teRepo.Object); var timeEnd = new TimeEnd() { id = 1, timeEnd = "" }; Exception ex = Assert.Throws <InvalidDataException>(() => teService.CreateTimeEnd(timeEnd)); Assert.Equal("TimeEnd can't be empty", ex.Message); }
public void CreateTimeEndIncorrectFormatThrowException() { var teRepo = new Mock <ITimeEndRepo>(); var teService = new TimeEndService(teRepo.Object); var timeEnd = new TimeEnd() { id = 1, timeEnd = "24355" }; Exception ex = Assert.Throws <InvalidDataException>(() => teService.CreateTimeEnd(timeEnd)); Assert.Equal("TimeEnd string has to be in format of HH:mm (ex 09:45)", ex.Message); }
public void CreateTimeEndIncorrectLengthTooShortThrowException() { var teRepo = new Mock <ITimeEndRepo>(); var teService = new TimeEndService(teRepo.Object); var timeEnd = new TimeEnd() { id = 1, timeEnd = "4444" }; Exception ex = Assert.Throws <InvalidDataException>(() => teService.CreateTimeEnd(timeEnd)); Assert.Equal("TimeEnd string is too long/short, follow format HH:mm", ex.Message); }
public void CreateTimeEndWithIncorrectHoursOutsideLowerBoundThrowException() { var teRepo = new Mock <ITimeEndRepo>(); var teService = new TimeEndService(teRepo.Object); var timeEnd = new TimeEnd() { id = 1, timeEnd = "-1:45" }; Exception ex = Assert.Throws <InvalidDataException>(() => teService.CreateTimeEnd(timeEnd)); Assert.Equal("TimeEnd string hours has to be 00-23", ex.Message); }
public CondTimeRange(string name, int range) { Name = name; TimeEnd = DateTime.Now.Date; TimeStart = TimeEnd.AddDays(-range); }
public DummyData() { CreatePasswordHash(password, out passwordHashUserOne, out passwordSaltUserOne); CreatePasswordHash(password, out passwordHashUserTwo, out passwordSaltUserTwo); var SSA = new Group() { Type = "SSA", QualificationNumber = 3, }; var SSH = new Group() { Type = "SSH", QualificationNumber = 2 }; var UDD = new Group() { Type = "UDD", QualificationNumber = 1 }; userNormal = new User() { IsAdmin = false, Name = "Christian", PasswordSalt = passwordSaltUserOne, PasswordHash = passwordHashUserOne, Email = "*****@*****.**", Group = SSA, ProfilePicture = "https://scontent-ams4-1.xx.fbcdn.net/v/t1.0-9/68397042_2373050946108579_1355476049231609856_n.jpg?_nc_cat=111&_nc_ohc=L-VxFCgmIOEAQkExKADS7GkFanYn-wlS1DtritGMIDMaz-F2F47jDBqdg&_nc_ht=scontent-ams4-1.xx&oh=d64bb5c81845f4af32142583c4d47f87&oe=5E89A221" }; userNormal2 = new User() { IsAdmin = false, Name = "Richart", Email = "*****@*****.**", ProfilePicture = "https://scontent-ams4-1.xx.fbcdn.net/v/t1.0-9/13906839_10206396239896911_6785032534256698008_n.jpg?_nc_cat=100&_nc_ohc=NWUTbJTLB7oAQkf5171xXvT0S_v4pdlAB1wHR_kbXfXiZXd0kzXCiLjuA&_nc_ht=scontent-ams4-1.xx&oh=d38d30e968f89eff9eb1fe39ee3287c3&oe=5E68167D", PasswordSalt = passwordSaltUserOne, PasswordHash = passwordHashUserOne, Group = UDD }; userNormal3 = new User() { IsAdmin = false, Name = "Casper", Email = "*****@*****.**", ProfilePicture = "https://scontent-ams4-1.xx.fbcdn.net/v/t1.0-9/12524001_1549641258661056_8462488784370177517_n.png?_nc_cat=109&_nc_ohc=_uulefV7bhEAQmqusa2XXfvuZdh72xF92JjafAdGC2NjGXJZ0RGgy2z2w&_nc_ht=scontent-ams4-1.xx&oh=1c4928765d11ea4940a2a00321425a65&oe=5E6815A3" , PasswordSalt = passwordSaltUserOne, PasswordHash = passwordHashUserOne, Group = SSA }; userAdmin = new User() { IsAdmin = true, Name = "Simon", Email = "*****@*****.**", ProfilePicture = "https://imgix.bustle.com/elite-daily/2017/07/28103007/joffrey-game-of-thrones-choking.jpg?w=1020&h=574&fit=crop&crop=faces&auto=format&q=70", PasswordSalt = passwordSaltUserTwo, PasswordHash = passwordHashUserTwo, Group = SSH }; var route1 = new Route() { Name = "MA01", }; var route2 = new Route() { Name = "MA02", }; var ar = new ActiveRoute() { Name = "MA01" }; var ar2 = new ActiveRoute() { Name = "MA02" }; var ar3 = new ActiveRoute() { Name = "MA03" }; var ar4 = new ActiveRoute() { Name = "MA10" }; var ts = new TimeStart() { timeStart = "15:00" }; var ts2 = new TimeStart() { timeStart = "15:30" }; var ts3 = new TimeStart() { timeStart = "16:00" }; var ts4 = new TimeStart() { timeStart = "16:30" }; var te = new TimeEnd() { timeEnd = "23:00" }; var shift = new Shift() { ActiveRoute = true, ShiftQualificationNumber = 3, TimeStart = new DateTime(2021, 1, 1, 10, 0, 0), TimeEnd = new DateTime(2021, 1, 1, 18, 0, 0) }; var shift2 = new Shift() { ActiveRoute = true, ShiftQualificationNumber = 2, TimeStart = new DateTime(2021, 1, 2, 10, 0, 0), TimeEnd = new DateTime(2021, 1, 2, 18, 0, 0) }; var shift3 = new Shift() { ActiveRoute = true, ShiftQualificationNumber = 1, TimeStart = new DateTime(2021, 1, 3, 10, 0, 0), TimeEnd = new DateTime(2021, 1, 3, 18, 0, 0) }; pShift1 = new PendingShift() { Shift = shift }; userNormal.Shifts = new List <Shift> { shift2, shift3 }; }
public void Polling(int ThreadId) { ShowPollingStatus(); if (DataMeasuringState == DataMeasuringState.Start) { _LocalIntervalCount = 0; ShowPollingStatus(); WriteThreadId?.Invoke(ThreadId); TimeStart?.Invoke(); //количество интервалов измерений int countInt = 0; foreach (var interval in Experiment.Intervals.Where(p => p.isActive)) { countInt += interval.CenterFrequencys.Count; } pBarMax?.Invoke(countInt); int Value = 0; //StateButtunChart?.Invoke(false); //деактивация кнопок График foreach (Interval currentInterval in Experiment.Intervals) { if (currentInterval.isActive) { ShowPollingStatus(); ShowIntervalMessage(currentInterval.IntervalSettings); if (DataMeasuringType == DataMeasuringType.Signal) { currentInterval.SignalClear(); } else { currentInterval.NoiseClear(); } currentInterval.Frequencys.Clear(); //количество центральных частот в текущем интервале(>1, точек измерения получается больше, чем может отобразить прибор) _LocalIntervalFrequencys = currentInterval.CenterFrequencys.Count; _LocalPointCount = 0; if (currentInterval.CenterFrequencys.Count == 0) { MessageBox.Show("Не возможно выполнить измерения." + Environment.NewLine + "Вероятно Вы забыли нажать кнопку 'РАССЧИТАТЬ'"); DataMeasuringState = DataMeasuringState.Clear; return; } StateButtunChart?.Invoke(false, (ParametersCtrl)currentInterval.IntervalSettings.LinkToVisualControl); //деактивация кнопок График //pBarMax?.Invoke(Experiment.Intervals.Where(p => p.isActive).Count() * currentInterval.CenterFrequencys.Count); foreach (long currentFrequency in currentInterval.CenterFrequencys) { ShowPollingStatus(); while (DataMeasuringState == DataMeasuringState.Pause) { if (DataMeasuringState == DataMeasuringState.Interrupted) { if (DataMeasuringType == DataMeasuringType.Signal) { currentInterval.SignalClear(); } else { currentInterval.NoiseClear(); } ShowPollingStatus(); return; } ShowPollingStatus(); Thread.Sleep(100); } if (DataMeasuringState == DataMeasuringState.Interrupted) { if (DataMeasuringType == DataMeasuringType.Signal) { currentInterval.SignalClear(); } else { currentInterval.NoiseClear(); } ShowPollingStatus(); return; } bool dataReady = false; if (DataMeasuringType == DataMeasuringType.Signal) { dataReady = ReadSignal(currentFrequency, currentInterval.IntervalSettings.BandWidth, currentInterval.IntervalSettings.Span, currentInterval.IntervalSettings.Band, currentInterval.IntervalSettings.isManuaSWPTime, currentInterval.IntervalSettings.ManuaSWPTime); if (dataReady) { if (currentInterval.Frequencys.Count != 0) { double[] tmpX = new double[ResultsX.Length - 1]; Array.Copy(ResultsX, 1, tmpX, 0, ResultsX.Length - 1); double[] tmpY = new double[ResultsY.Length - 1]; Array.Copy(ResultsY, 1, tmpY, 0, ResultsY.Length - 1); currentInterval.Frequencys.AddRange(tmpX); currentInterval.OriginalSignal.AddRange(tmpY); } else { currentInterval.Frequencys.AddRange(ResultsX); currentInterval.OriginalSignal.AddRange(ResultsY); } } } else { dataReady = ReadNoise(currentFrequency, currentInterval.IntervalSettings.BandWidth, currentInterval.IntervalSettings.Span, currentInterval.IntervalSettings.Band, currentInterval.IntervalSettings.isManuaSWPTime, currentInterval.IntervalSettings.ManuaSWPTime); if (dataReady) { if (currentInterval.Frequencys.Count != 0) { double[] tmpX = new double[ResultsX.Length - 1]; Array.Copy(ResultsX, 1, tmpX, 0, ResultsX.Length - 1); double[] tmpY = new double[ResultsY.Length - 1]; Array.Copy(ResultsY, 1, tmpY, 0, ResultsY.Length - 1); currentInterval.Frequencys.AddRange(tmpX); currentInterval.OriginalNoise.AddRange(tmpY); } else { currentInterval.Frequencys.AddRange(ResultsX); currentInterval.OriginalNoise.AddRange(ResultsY); } } } _LocalPointCount++; Value++; pBarValue?.Invoke(Value); } if (currentInterval.IntervalSettings.isAuto) //только для СС { currentInterval.Computer(); //обработка полученных сигналов измерения } else { currentInterval.Restore(); //для СС. Копирование ориг. значений без обработки } //сигнал, меньший шума, подтянем до уровня шума if (currentInterval.Signal.Count != 0 && currentInterval.Noise.Count != 0) { for (int i = 0; i < currentInterval.Frequencys.Count; i++) { if (currentInterval.Signal[i] < currentInterval.Noise[i]) { currentInterval.Signal[i] = currentInterval.Noise[i]; } } } _LocalIntervalCount++; StateButtunChart?.Invoke(true, (ParametersCtrl)currentInterval.IntervalSettings.LinkToVisualControl); } } TimeEnd?.Invoke(); DataMeasuringState = DataMeasuringState.Finish; ShowPollingStatus(); if (DataMeasuringType == DataMeasuringType.Signal) { SignalReadyIntervalEvent?.Invoke(); MessageBox.Show(Experiment.ExperimentSettings.HardwareSettings.HardwareType + "- -СЪЕМ СИГНАЛА ЗАВЕРШЕН" + Environment.NewLine + "Поток - " + ThreadId.ToString()); } if (DataMeasuringType == DataMeasuringType.Noise) { MessageBox.Show(Experiment.ExperimentSettings.HardwareSettings.HardwareType + " - СЪЕМ ШУМА ЗАВЕРШЕН" + Environment.NewLine + "Поток - " + ThreadId.ToString()); NoiseReadyIntervalEvent?.Invoke(); } pBarValue?.Invoke(0); pBarMax?.Invoke(0); // StateButtunChart?.Invoke(true); //активация кнопок График } }
private void FillElectronicNotificatorForm() { var list = ElectricNotificators.Split(new[] { '\r', '\n' }); string ECHZone = ""; int IndexOf; var tmp = ""; string TimeRange = DateTime.Today.ToString(); DateTime DateInaccssibility = DateTime.Today.AddDays(1); bool DateIsChange = false; DateTime TimeStart; DateTime TimeEnd; List <string> Stations = new List <string>(); foreach (string tmpstr in list) { if (tmpstr != "") { /// Удаляю пунктуацию в конце строки Regex regex = new Regex(@"\W"); tmp = tmpstr; for (int i = tmp.Length - 1; i >= 0; i--) { if (!(regex.Match(tmp[i].ToString()).Success)) { tmp = tmp.Substring(0, i + 1).ToString(); i = -1; } } /// Дата начала простоя regex = new Regex(@"\d\d\.\d\d\.\d\d"); if (regex.Match(tmp).Success) { DateInaccssibility = Convert.ToDateTime((tmp.Split(' ').AsEnumerable().Where(obj => regex.Match(obj).Success)).First()); DateIsChange = true; } if (tmpstr == list[list.Length - 1] && !DateIsChange) { MessageBox.Show("Отсутсвтует дата простоя: " + Environment.NewLine + "Будет -> " + DateInaccssibility.ToString("dd.MM.yy")); } DateTime DateInaccssibilityEnd = DateInaccssibility.AddDays(1); textBox_StartActive.Text = DateInaccssibility.ToString("dd'/'MM'/'yy HH:mm:ss"); textBox_EndActive.Text = DateInaccssibility.AddDays(1).ToString("dd'/'MM'/'yy HH:mm:ss"); /// ЭЧ зона if (tmp.Contains("ЭЧ-")) { IndexOf = tmp.IndexOf("ЭЧ-"); ECHZone = tmp.Substring(IndexOf, 4); } regex = new Regex(@"\A-"); if (regex.Match(tmp.Replace(" ", "").Replace("\t", "")).Success) { if (tmp.Contains("ё")) { tmp = tmp.Replace("ё", "е"); } regex = new Regex(@"\sдо\s"); if (regex.Match(tmp).Success) { IndexOf = tmp.IndexOf(" до "); tmp = tmp.Substring(0, IndexOf) + "-" + tmp.Substring(IndexOf + 4, tmp.Length - IndexOf - 4); } try { string line; StreamReader sr = new StreamReader(".\\Glossary.txt", Encoding.Default); while ((line = sr.ReadLine()) != null) { var Glossary = line.Replace("-", " "); if (tmp.Contains(Glossary)) { //MessageBox.Show(tmp); regex = new Regex(@"\d:\d\d-\d"); if (regex.Match(tmp).Success) { TimeRange = (tmp.Split(' ', '.', ',').AsEnumerable().Where(obj => regex.Match(obj).Success)).Last(); TimeStart = DateInaccssibility + TimeSpan.Parse(TimeRange.Split('-')[0]) + TimeSpan.Parse("04:00"); TimeEnd = DateInaccssibility + TimeSpan.Parse(TimeRange.Split('-')[TimeRange.Split('-').Length - 1]) + TimeSpan.Parse("04:00"); } else { TimeStart = DateInaccssibility + TimeSpan.Parse("08:00"); TimeEnd = DateInaccssibility + TimeSpan.Parse("17:00"); } if (TimeStart > TimeEnd) { TimeEnd = TimeEnd.AddDays(1); } if (Convert.ToDateTime(textBox_EndActive.Text) < TimeEnd) { textBox_EndActive.Text = TimeEnd.ToString("dd'/'MM'/'yy HH:mm:ss"); } dataGridView_Inaccessibility.Rows.Add(TimeStart.ToString("dd'/'MM'/'yy HH:mm:ss"), TimeEnd.ToString("dd'/'MM'/'yy HH:mm:ss"), "*" + Glossary.Replace(" ", "") + "*КРАСН"); Stations.Add(Glossary); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } } } textBox_Description.Text = "Плановые работы " + ECHZone + " cо снятием напряжения на " + DateInaccssibility.ToString("dd.MM.yy") + ":" + Environment.NewLine; if (Stations.Count > 0) { var result = from obj in Stations.AsEnumerable() group obj by obj into grp select new { FilterObject = grp.Key, MemberCount = grp.Count() }; foreach (var item in result) { textBox_Description.Text += item.FilterObject + ", "; } } }
public TimeEnd UpdateTimeEnd(TimeEnd timeEnd) { _context.TimeEnds.Attach(timeEnd).State = EntityState.Modified; _context.SaveChanges(); return(timeEnd); }
public TimeEnd CreateTimeEnd(TimeEnd timeEnd) { _context.TimeEnds.Attach(timeEnd).State = EntityState.Added; _context.SaveChanges(); return(timeEnd); }