public void ReadData() { Logger.info(String.Format("Чтение данных за {0} по объекту ", DateStart.ToString("dd.MM.yyyy"))); foreach (KeyValuePair <string, string> de in Names) { try { SqlConnection con = getConnection(); con.Open(); string comSTR = ""; comSTR = String.Format("SELECT DATA_DATE,VALUE0, SEASON FROM DATA WHERE OBJECT={0} AND OBJTYPE={1} AND ITEM={2} AND PARNUMBER=12 AND DATA_DATE>'{3}' AND DATA_DATE<='{4}'", Data[de.Key].Source.Obj, Data[de.Key].Source.ObjType, Data[de.Key].Source.Item, DateStart.ToString(DateFormat), DateEnd.ToString(DateFormat)); SqlCommand command = new SqlCommand(comSTR, con); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { //Object dt= DateTime date = reader.GetDateTime(0); double val = reader.GetDouble(1); int season = reader.GetInt32(2); if (season >= CurrentSeason) { CurrentSeason = season; } try { Data[de.Key].Values[date] = String.Format("{0:0.##}", val).Replace(",", "."); } catch { } } reader.Close(); con.Close(); } catch (Exception e) { Logger.info("Ошибка при данных" + e.ToString()); } } }
private void UpdateDates() { layoutControlItemDateStart.Text = String.Format("<color=\"Gray\">Start: {0}</color>", DateStart?.ToString("M/d/yy") ?? String.Empty); layoutControlItemDateEnd.Text = String.Format("<color=\"Gray\">End: {0}</color>", DateEnd?.ToString("M/d/yy") ?? String.Empty); }
public void sendDKData() { try { string header = "<tr><th>Дата<br/>получения</th><th>Время<br/>команды</th><th>ГОУ</th><th>Команда</th><th>Время<br/>начала</th><th>Время</br>окончания</th>"; string table = ""; foreach (SDPMDKRecord rec in DKDataFull.Values) { string s = ""; s += String.Format("<td>{0}{1}</td>", rec.DKTrigger.ToString("dd.MM HH:mm:ss"), (rec.AutoDK?"":"<br/>Экспресс")); s += String.Format("<td>{0}</td>", rec.DKTime.ToString("dd.MM HH:mm")); s += String.Format("<td>{0}</td>", rec.GOU); s += String.Format("<td>{0}</td>", rec.DK); s += String.Format("<td>{0}</td>", rec.DKStartTime.ToString("dd.MM HH:mm")); s += String.Format("<td>{0}</td>", rec.DKEndTime.ToString("dd.MM HH:mm")); s = string.Format("<tr>{0}</tr>", s); table += s; } table = string.Format("<table border='1'>{0}{1}</table></html>", header, table); //FileInfo file = new FileInfo("c:/int/ftpfolder/"+fn); System.Net.Mail.MailMessage mess = new System.Net.Mail.MailMessage(); mess.From = new MailAddress(Settings.Single.SMTPFrom); mess.Subject = String.Format("Диспетчерские команды {0} - {1}", DateStart.ToString("dd.MM.yyyy"), DateEnd.ToString("dd.MM.yyyy")); mess.Body = String.Format("<html><h1>{0}</h1>{1}</html>", mess.Subject, table); string[] mails = Settings.Single.DKMail.Split(';'); foreach (string mail in mails) { mess.To.Add(mail); } //mess.Attachments.Add(new Attachment(fn)); mess.SubjectEncoding = System.Text.Encoding.UTF8; mess.BodyEncoding = System.Text.Encoding.UTF8; mess.IsBodyHtml = true; System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(Settings.Single.SMTPServer, Settings.Single.SMTPPort); client.EnableSsl = false; if (string.IsNullOrEmpty(Settings.Single.SMTPUser)) { client.UseDefaultCredentials = true; } else { client.Credentials = new System.Net.NetworkCredential(Settings.Single.SMTPUser, Settings.Single.SMTPPassword, Settings.Single.SMTPDomain); } // Отправляем письмо client.Send(mess); Logger.Info("Данные в автооператор отправлены успешно"); } catch (Exception e) { Logger.Error(String.Format("Ошибка при отправке почты: {0}", e.ToString()), Logger.LoggerSource.server); Logger.Info("Данные в автооператор не отправлены"); } }
public string exportAsICS() { //create a new stringbuilder instance StringBuilder sb = new StringBuilder(); //start the calendar item sb.AppendLine("BEGIN:VCALENDAR"); sb.AppendLine("VERSION:2.0"); sb.AppendLine("PRODID:BilleterieEPITA"); //add the event sb.AppendLine("BEGIN:VEVENT"); //DTSTART: Date de début de l'événement sb.AppendLine("DTSTART;TZID=Europe/Paris:" + DateStart.ToString("yyyyMMddTHHmm00")); //sb.AppendLine("DTSTART:" + DateStart.ToString("yyyyMMddTHHmm00")); //DTEND: Date de fin de l'événement sb.AppendLine("DTEND;TZID=Europe/Paris:" + DateEnd.ToString("yyyyMMddTHHmm00")); //sb.AppendLine("DTEND:" + DateEnd.ToString("yyyyMMddTHHmm00")); sb.AppendLine("ORGANIZER:CN=" + Organizer + ":MAILTO:" + OrganizerEmail); //SUMMARY: Titre de l'événement sb.AppendLine("SUMMARY:" + Summary + ""); //LOCATION: Lieu de l'événement sb.AppendLine("LOCATION:" + Location + ""); //DESCRIPTION: Description de l'événement sb.AppendLine("DESCRIPTION:" + Description + ""); //CATEGORIES: Catégorie de l'événement (ex: Conférence, Fête...) //STATUS: Statut de l'événement (TENTATIVE, CONFIRMED, CANCELLED) //TRANSP: Définit si la ressource affectée à l'événement est rendu indisponible (OPAQUE, TRANSPARENT) //SEQUENCE: Nombre de mises à jour, la première mise à jour est à 1 sb.AppendLine("PRIORITY:" + Priority.ToString()); sb.AppendLine("END:VEVENT"); //end calendar item sb.AppendLine("END:VCALENDAR"); //create a string from the stringbuilder string CalendarItem = sb.ToString(); return(CalendarItem); //send the calendar item to the browser /* * Response.ClearHeaders(); * Response.Clear(); * Response.Buffer = true; * Response.ContentType = "text/calendar"; * Response.AddHeader("content-length", CalendarItem.Length.ToString()); * Response.AddHeader("content-disposition", "attachment; filename=\"" + FileName + ".ics\""); * Response.Write(CalendarItem); * Response.Flush(); * HttpContext.Current.ApplicationInstance.CompleteRequest(); */ }
} // DueCurrencyCode public override string ToString() { return(string.Format("{0} - {1}: {2} {3}, {4} {5}", DateStart.ToString("MMM d yyyy", CultureInfo.InvariantCulture), DateEnd.ToString("MMM d yyyy", CultureInfo.InvariantCulture), PaidAmount, PaidCurrencyCode, DueAmount, DueCurrencyCode )); } // ToString
public void ReadNames() { Logger.info(String.Format("Чтение наименований за {0} по объекту [{1}-{2}]", DateStart.ToString("dd.MM.yyyy"), Source.Obj, Source.ObjType)); Names = new Dictionary<string, string>(); Data = new Dictionary<string, DataRecord>(); /*for (int i = 0; i <= 50; i++) { string name = "Parametr" + i.ToString(); string codeStr = String.Format("{0}_{1}_{2}", Source.Obj, Source.ObjType, i); Names.Add(codeStr, name); DataRecord rec = new DataRecord(); rec.Key = codeStr; rec.Name = name; rec.Source = SourceInfo.getFullInfo(codeStr); rec.Values = new Dictionary<DateTime, string>(); foreach (DateTime date in Dates) { rec.Values.Add(date, "---"); } Data.Add(codeStr, rec); } return;*/ try { SqlConnection con = getConnection(); con.Open(); string comSTR = ""; if (Source.ObjType == 0) { int stationID = Source.Obj == 8737 ? 2 : Source.Obj == 8738 ? 1 : Source.Obj == 8739 ? 3 : Source.Obj == 8740 ? 4 : -1; comSTR = String.Format("SELECT NAME,CODE FROM SENSORS WHERE STATIONID={0} order by code", stationID); } else { comSTR = String.Format("SELECT NAME,CODE FROM CLIENTS order by code"); } SqlCommand command = new SqlCommand(comSTR, con); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { string name = reader.GetString(0); int code = reader.GetInt32(1); name = String.Format("{0}: {1}", code, name); string codeStr = String.Format("{0}_{1}_{2}", Source.Obj, Source.ObjType, code); Names.Add(codeStr, name); DataRecord rec = new DataRecord(); rec.Key = codeStr; rec.Name = name; rec.Source = SourceInfo.getFullInfo(codeStr); rec.Values = new Dictionary<DateTime, string>(); foreach (DateTime date in Dates) { rec.Values.Add(date, "---"); } Data.Add(codeStr, rec); } reader.Close(); con.Close(); } catch (Exception e) { Logger.info("Ошибка при чтении наименований источника " + e.ToString()); } }
public bool ReadData(String type, int nasosCount, string typeCalcRun = "GG_UST") { NasosType = type; DataGG = new Dictionary <string, List <PuskStopData> >(); DataGG.Add("GG_RUN", new List <PuskStopData>()); DataGG.Add("GG_STOP", new List <PuskStopData>()); DataGG.Add("GG_UST", new List <PuskStopData>()); DataNasos = new Dictionary <string, List <PuskStopData> >(); Date = DateStart.ToString("dd.MM"); for (int nasos = 1; nasos <= nasosCount; nasos++) { DataNasos.Add(String.Format("{0}_{1}", type, nasos), new List <PuskStopData>()); } FullGGData = createPuskStopData("GG", DataGG); FullNasosData = createPuskStopData(type, DataNasos); CreateComments(); timeGGRun = 0; timeGGStop = 0; OneTimeWorkInfo = new SortedList <DateTime, PuskStopData>(); IEnumerable <PuskStopData> req = from gg in DataGG[typeCalcRun] where gg.TimeOn <= DateEnd && gg.TimeOff >= DateStart select gg; foreach (PuskStopData rec in req) { DateTime start = rec.TimeOn > DateStart ? rec.TimeOn : DateStart; DateTime end = rec.TimeOff < DateEnd ? rec.TimeOff : DateEnd; timeGGRun += (end - start).TotalSeconds; } req = from gg in DataGG["GG_STOP"] where gg.TimeOn <= DateEnd && gg.TimeOff >= DateStart select gg; foreach (PuskStopData rec in req) { DateTime start = rec.TimeOn > DateStart ? rec.TimeOn : DateStart; DateTime end = rec.TimeOff < DateEnd ? rec.TimeOff : DateEnd; timeGGStop += (end - start).TotalSeconds; } NasosRunGG = processNasosData(typeCalcRun); NasosStopGG = processNasosData("GG_STOP"); NasosGG = processNasosData(""); /*NasosRunGG.cntPuskRel = NasosRunGG.cntPusk / timeGGRun; * NasosStopGG.cntPuskRel = NasosStopGG.cntPusk / (timeGGStop);*/ return(true); }
private void BtnAddCalculatedMetrics_Click(object sender, EventArgs e) { string DeviceID, MetricValue; //int MetricID; DateTime DateStart, DateEnd; DeviceID = MetricValue = default; // MetricID = default; DateStart = DateEnd = default; if (String.IsNullOrEmpty(textBox3.Text)) { MessageBox.Show("Gngn vraies valeurs svp"); return; //Arrete tout si jamais c'est le cas } else { MetricValue = textBox3.Text; //On est dans le cas ou c'est good } //if (MetricID == default) //{ // MetricID = ""; //} if (DeviceID == default) { //DeviceID = GetRandomMacAddress(); var random = new Random(); DeviceID = (1 + random.Next(100)).ToString(); } else if (MetricValue == default) { var random = new Random(); MetricValue = (1 + random.Next()).ToString(); } else if (DateStart == default) { DateStart = DateTime.Now; string formatForMySql = DateStart.ToString("yyyy-MM-dd HH:mm:ss"); } else if (DateEnd == default) { DateEnd = DateTime.Now; string formatForMySql = DateEnd.ToString("yyyy-MM-dd HH:mm:ss"); } if (DeviceID == default && MetricValue == default) { } DAL.PostCalculatedMetrics(DeviceID, MetricValue, DateStart, DateEnd, 0); }
public TaskBox(Task task) { InitializeComponent(); DateStart = task.StartDate; DateFinish = task.Deadline; TaskName = task.Name; taskName.Text = TaskName; dateFinish.Text = DateFinish.ToString(); dateStart.Text = DateStart.ToString(); BackColor = SystemColors.ActiveCaption; Dock = DockStyle.Top; //Location = new Point(0, 60); Name = $"taskBoxItem{task.Id}"; Size = new Size(477, 36); }
public string exportAsICS(Models.Event ev) { DateStart = ev.Begin; DateEnd = ev.End; Organizer = ev.Assoc; Summary = ev.Name; Description = ev.Description; Location = "FIXME"; try { object email = Database.Database.database.RequestObject("f_email", ev.Owner); OrganizerEmail = (string)email; } catch (Exception) { } //create a new stringbuilder instance StringBuilder sb = new StringBuilder(); //start the calendar item sb.AppendLine("BEGIN:VCALENDAR"); sb.AppendLine("VERSION:2.0"); sb.AppendLine("PRODID:BilleterieEPITA"); sb.AppendLine("BEGIN:VEVENT"); sb.AppendLine("DTSTART;TZID=Europe/Paris:" + DateStart.ToString("yyyyMMddTHHmm00")); sb.AppendLine("DTEND;TZID=Europe/Paris:" + DateEnd.ToString("yyyyMMddTHHmm00")); sb.AppendLine("ORGANIZER:CN=" + Organizer + ":MAILTO:" + OrganizerEmail); sb.AppendLine("SUMMARY:" + Summary); sb.AppendLine("LOCATION:" + Location); sb.AppendLine("DESCRIPTION:" + Description); //CATEGORIES: Catégorie de l'événement (ex: Conférence, Fête...) //STATUS: Statut de l'événement (TENTATIVE, CONFIRMED, CANCELLED) //TRANSP: Définit si la ressource affectée à l'événement est rendu indisponible (OPAQUE, TRANSPARENT) //SEQUENCE: Nombre de mises à jour, la première mise à jour est à 1 sb.AppendLine("PRIORITY:" + Priority.ToString()); sb.AppendLine("END:VEVENT"); sb.AppendLine("END:VCALENDAR"); //create a string from the stringbuilder string CalendarItem = sb.ToString(); return(CalendarItem); }
public override string ToString() { string drome = ""; foreach (var item in SelectedAutodromes) { drome += item.CodeName + "\n"; } if (SelectedAutodromes.Count < 1) { drome = "Все"; } return($"Дата начала {DateStart.ToString("dd.MM")}\nДата конца {DateEnd.ToString("dd.MM")}\n" + $"Время старта занятия больше чем {string.Format("{0:00}:{1:00}:{2:00}",TimeStart.Hours,TimeStart.Minutes,TimeStart.Seconds)}\nВыбранные площадки \"{drome}\"\n" + $"Искомая фамилия учителя \"{TeacherLast}\""); }
public DateTime CheckWorkingDaysInFuture(int NumberOfDays) { if (NumberOfDays <= 0) { throw new Exceptions.InvalidSettingsConfigurationException("The number of days in the future must be above 0."); } Reader = new WorkingDaysReader(); BankHolidaysList = Reader.ReadWorkingDaysFile(); WorkingDays = 0; CalendarDays = 0; DateToday = DateTime.UtcNow.Date; DateStart = DateToday; // Check if today is a bank holiday or falls on a weekend if (DateToday.DayOfWeek == DayOfWeek.Saturday || DateToday.DayOfWeek == DayOfWeek.Sunday || BankHolidaysList.Contains(DateStart.Date.ToString("yyyy-MM-dd"))) { int i = 0; while (DateToday.DayOfWeek != DayOfWeek.Saturday && DateToday.DayOfWeek != DayOfWeek.Sunday || BankHolidaysList.Contains(DateStart.ToString("yyyy-MM-dd"))) { i++; DateStart = DateToday.AddDays(i); } } while (WorkingDays <= (NumberOfDays - 1)) { WorkingDate = DateStart.AddDays(CalendarDays); if (WorkingDate.DayOfWeek != DayOfWeek.Saturday && WorkingDate.DayOfWeek != DayOfWeek.Sunday && !BankHolidaysList.Contains(WorkingDate.ToString("yyyy-MM-dd"))) { WorkingDays++; } CalendarDays++; } FinalDate = DateStart.AddDays(CalendarDays); while (FinalDate.DayOfWeek == DayOfWeek.Saturday || FinalDate.DayOfWeek == DayOfWeek.Sunday || BankHolidaysList.Contains(FinalDate.ToString("yyyy-MM-dd"))) { FinalDate = FinalDate.AddDays(1); CalendarDays++; } return(FinalDate); }
GetHashCode() { return((DateStart.ToString() + DateEnd.ToString() + Salary.ToString()).GetHashCode()); }
public override string ToString() { return($"{DateStart.ToString("dd MMM yyyy")} - {DateEnd.ToString("dd MMM yyyy")}. {Comment}"); }