public void Send(string UserName) { SmsService smsDB = new SmsService(); DateMode dateMode = Configuration.GetInstance().App.DateMode; string messageText = this.Message; while (messageText.Length > 0) { string messagePart; if (messageText.Length > 160) { messagePart = messageText.Substring(0, 160); messageText = messageText.Substring(160); } else { messagePart = messageText; messageText = String.Empty; } string MessageID = smsDB.InsertMessage(dateMode, this.PhoneNo, messagePart, this.Template, this.EntityType, this.EntityID, this.SMSUserName, this.SMSPassword, this.SMSChannelID, UserName); } }
/// <summary> /// 把每行表达式转换为 DateTime /// </summary> /// <param name="expr">接收一个字符串表达式,格式为“mm/dd/yyyy”</param> /// <param name="dateMode"></param> /// <returns></returns> /// <remarks> /// 注意,ParseExpressToDateTime 的设计存在缺陷,DateTime 字符串的格式会随着不同地区文化的差异 /// 而有所不同,最终会导致在部分地区下的客户端中出现解析错误,请更正该设计! /// </remarks> internal static DateTime ParseExpressToDateTime(string expr, DateMode dateMode = DateMode.DateWithWhiteSpace) { string[] tokens = null; switch (dateMode) { case DateMode.DateWithWhiteSpace: tokens = GetToken(expr, ' '); break; case DateMode.DateWithSlash: tokens = GetToken(expr, '/'); break; default: break; } if (tokens.Length == 3) { ushort monthValue = StringToUInt16(tokens[0]); ushort dayValue = Convert.ToUInt16(tokens[1]); ushort yearValue = Convert.ToUInt16(tokens[2]); return(new DateTime(yearValue, monthValue, dayValue)); } else { throw new ArgumentOutOfRangeException($"Date time format error: {tokens}"); } }
/// <summary> /// Set display date mode (datetime or time, 12 hour or 24 hour) /// </summary> /// <param name="mode"></param> /// <returns></returns> public async Task <bool> SetDisplayDate(DateMode mode) { byte[] date = null; switch (mode) { case DateMode.DATEFORMAT_TIME: date = new byte[] { 6, 10, 0, 0 }; break; case DateMode.DATEFORMAT_DATETIME: date = new byte[] { 6, 10, 0, 3 }; break; case DateMode.DATEFORMAT_12_HOURS: date = new byte[] { 6, 2, 0, 0 }; break; case DateMode.DATEFORMAT_24_HOURS: date = new byte[] { 6, 2, 0, 1 }; break; } Debug.WriteLine("Set display time"); var characteristic = await Gatt.GetCharacteristicByServiceUuid(MI_BAND_SERVICE, DISPLAY_DATE_CHARACTERISTIC); var gattWriteResult = await characteristic.WriteValueAsync(date.AsBuffer()); return(gattWriteResult == GattCommunicationStatus.Success); }
/// <summary> /// Calculates the values. /// </summary> private void CalculateValues() { dateMode = dateLineGraph.DateMode; startDate = GetMinimumDate(); endDate = GetMaximumDate(); timeSpan = GetTimeSpan(); totalDays = timeSpan.Days; // totalHours = timeSpan.Hours; }
/// <summary> /// 该构造器接收一个字符串序列,把它转换成StatistTotalByDateTime链表,同时接收一个 DateMode 指示日期字符串的分割方式 /// </summary> /// <param name="lines">文本序列</param> /// <param name="dateMode">指示日期字符串的分割方式</param> public StatistTotalByDateTimeModel(IEnumerable <string> lines, DateMode dateMode) { foreach (var line in lines) { if (line != "" && line != "\r") // 忽略空行 { StatistTotalByDateTime statist = DatetimeParser.ParseExpressToStatistTotalByDateTime(line, dateMode); this.Add(statist); } } }
/// <summary> /// Initializes a new instance of the <see cref="DateLineGraph"/> class. /// </summary> /// <param name="dateMode">The date mode.</param> public DateLineGraph(DateMode dateMode) : base() { this.dateMode = dateMode; dateLineCollection = new DateLineCollection(); dateXAxisTextCollection = new DateXAxisTextCollection(); datePhaseLines = new DateXAxisTextCollection(); trendLine = new DateLine(); trendLine.Width = 2.0F; MarginForTextOnAxis = 15; }
public override void Execute(System.Data.Common.DbTransaction tran, string WorkflowCode, string FromWorkflowStepCode, string ToWorkflowStepCode, string EntityID, string Comment, string UserName) { SmsService smsDB = new SmsService(); Workflow workflow = Workflow.GetWorkflowByCode(WorkflowCode); //select template Template contentTemplate = GetTemplate(tran, WorkflowCode, FromWorkflowStepCode, ToWorkflowStepCode, EntityID, Comment, UserName); DateMode dateMode = Configuration.GetInstance().App.DateMode; if (contentTemplate != null) { List <PhoneNumber> numbers = GetPhoneNumbers(tran, WorkflowCode, FromWorkflowStepCode, ToWorkflowStepCode, EntityID, Comment, UserName); Hashtable contentItems = GetContentItems(tran, contentTemplate, WorkflowCode, FromWorkflowStepCode, ToWorkflowStepCode, EntityID, Comment, UserName); //individual emails for each tos foreach (PhoneNumber phoneNo in numbers) { string messageText = GetMessageText(phoneNo, contentTemplate, contentItems); //create as many messages as needed in 160 chunks while (messageText.Length > 0) { string messagePart; if (messageText.Length > 160) { messagePart = messageText.Substring(0, 160); messageText = messageText.Substring(160); } else { messagePart = messageText; messageText = String.Empty; } string MessageID = smsDB.InsertMessage(dateMode, phoneNo.Phone, messagePart, contentTemplate.Name, workflow.EntityName, EntityID, null, null, null, UserName); } } } else { throw new ApplicationException("No SMS Template found"); } }
public void initData(bool enableAssoc, DateTime dateTime, int productID, DateMode dateMode, double price, NewWDS.Demo_applications.ShelfLabelDemo.Currency currency, DisplayMode displayMode) { this.chbEnableAssociation.Checked = enableAssoc; this.dtpDate.Value = dateTime; this.dtpTime.Value = dateTime; this.nudProductID.Value = productID; switch (dateMode) { case DateMode.Time: this.rdbTime.Checked = true; break; case DateMode.ProductId: this.rdbProductID.Checked = true; break; default: this.rdbTime.Checked = true; break; } this.nudPrice.Value = (decimal) price; this.cbbCurrency.SelectedIndex = (int) currency; switch (displayMode) { case DisplayMode.RSSI: this.rdbRSSI.Checked = true; return; case DisplayMode.VBAT: this.rdbBattertyVoltage.Checked = true; return; case DisplayMode.Humidity: this.rdbHumidity.Checked = true; return; case DisplayMode.Temperature: this.rdbTemperature.Checked = true; return; } this.rdbPrice.Checked = true; }
public static IServiceCollection AddModes(this IServiceCollection serviceCollection) { var clockMode = new ClockMode(); serviceCollection.AddSingleton <IClockMode>(clockMode); serviceCollection.AddSingleton(clockMode); var timerMode = new TimerMode(); serviceCollection.AddSingleton <IClockMode>(timerMode); serviceCollection.AddSingleton(timerMode); var dateMode = new DateMode(); serviceCollection.AddSingleton <IClockMode>(dateMode); serviceCollection.AddSingleton(dateMode); var stopperMode = new StopperMode(); serviceCollection.AddSingleton <IClockMode>(stopperMode); serviceCollection.AddSingleton(stopperMode); return(serviceCollection); }
/// <summary> /// 格式化日期时间 /// </summary> /// <param name="dateTime">日期时间</param> /// <param name="dateMode">显示模式</param> /// <returns>0-9种模式的日期</returns> public static string DateTimeFormat(DateTime dateTime, DateMode dateMode) { switch (dateMode) { case DateMode.yyyy_MM_dd: return(dateTime.ToString("yyyy-MM-dd")); case DateMode.yyyy_MM_dd_HH_mm_ss: return(dateTime.ToString("yyyy-MM-dd HH:mm:ss")); case DateMode.yyyyMMdd: return(dateTime.ToString("yyyy/MM/dd")); case DateMode.yyyy_Year_MM_Month_dd_Day: return(dateTime.ToString("yyyy年MM月dd日")); case DateMode.MM_dd: return(dateTime.ToString("MM-dd")); case DateMode.MMdd: return(dateTime.ToString("MM/dd")); case DateMode.MM_Month_dd_Day: return(dateTime.ToString("MM月dd日")); case DateMode.yyyy_MM: return(dateTime.ToString("yyyy-MM")); case DateMode.yyyyMM: return(dateTime.ToString("yyyy/MM")); case DateMode.yyyy_Year_MM_Month: return(dateTime.ToString("yyyy年MM月")); case DateMode.Default: return(dateTime.ToString()); default: return(dateTime.ToString()); } }
private static void DateModeChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) { SelectorPicker timePicker = d as SelectorPicker; DateMode dateMode = (DateMode)e.NewValue; if (dateMode == DateMode.Day) { timePicker.StringFormat = "dd日"; } else if (dateMode == DateMode.Month) { timePicker.StringFormat = "MM月"; } else if (dateMode == DateMode.Year) { timePicker.StringFormat = "yyyy年"; } else if (dateMode == DateMode.YearMonth) { timePicker.StringFormat = "yyyy年MM月"; } else if (dateMode == DateMode.YearMonthDay) { timePicker.StringFormat = "yyyy年MM月dd日"; } else if (dateMode == DateMode.MonthDay) { timePicker.StringFormat = "MM月dd日"; } if (dateMode == DateMode.None) { timePicker.SelectedTimeString = timePicker.Value.ToString(); } else if (timePicker.SelectedTime != null) { timePicker.SelectedTimeString = timePicker.SelectedTime.Value.ToString(timePicker.StringFormat); } }
public override void Execute(System.Data.Common.DbTransaction tran, string workflowCode, string fromWorkflowStepCode, string toWorkflowStepCode, string entityID, string comment, string userName) { EmailAddress address = null; Workflow workflow = Workflow.GetWorkflowByCode(workflowCode); //select template Template contentTemplate = GetTemplate(tran, workflowCode, fromWorkflowStepCode, toWorkflowStepCode, entityID, comment, userName); DateMode dateMode = Configuration.GetInstance().App.DateMode; if (contentTemplate != null) { DataTable subjects = GetSubjects(tran, workflowCode, fromWorkflowStepCode, toWorkflowStepCode, entityID, comment, userName); DataTable from = GetAddresses(tran, "from", workflowCode, fromWorkflowStepCode, toWorkflowStepCode, entityID, comment, userName); DataTable cc = GetAddresses(tran, "cc", workflowCode, fromWorkflowStepCode, toWorkflowStepCode, entityID, comment, userName); DataTable bcc = GetAddresses(tran, "bcc", workflowCode, fromWorkflowStepCode, toWorkflowStepCode, entityID, comment, userName); DataTable to = GetAddresses(tran, "to", workflowCode, fromWorkflowStepCode, toWorkflowStepCode, entityID, comment, userName); DataTable replyto = GetAddresses(tran, "to", workflowCode, fromWorkflowStepCode, toWorkflowStepCode, entityID, comment, userName); DataTable attachments = GetAttachments(tran, workflowCode, fromWorkflowStepCode, toWorkflowStepCode, entityID, comment, userName); DataTable mailitems = GetMailItems(to); Hashtable contentItems = GetContentItems(tran, contentTemplate, workflowCode, fromWorkflowStepCode, toWorkflowStepCode, entityID, comment, userName); IEmailProvider email = null; //individual emails for each tos foreach (DataRow mail in mailitems.Rows) { EmailMessage message = new EmailMessage(); if (email == null) { //set connection message.EmailConnection = this.EmailConnection; email = EmailService.GetInstance().GetProvider(message); } message.Subject = GetSubject(mail, subjects); message.Body = GetBody(mail, contentTemplate, contentItems); message.EntityID = entityID; message.EntityType = workflow.EntityName; message.IsBodyHtml = this.IsBodyHtml; message.Priority = this.Priority; message.Template = contentTemplate.Name; //from DataRow[] fromList = from.Select(String.Format("(TO = '{0}') OR (TO IS NULL)", mail["TO"])); if (fromList.Length > 0) { DataRow a = fromList[0]; address = new EmailAddress(); address.DisplayName = a["DisplayName"].ToString(); address.Address = a["Address"].ToString(); message.From = address; } //to if (this.ToAddressSendMode == EmailAddressSendMode.Individual) { address = new EmailAddress(); address.DisplayName = mail["DisplayName"].ToString(); address.Address = mail["Address"].ToString(); message.To.Add(address); } else { foreach (DataRow a in to.Rows) { address = new EmailAddress(); address.DisplayName = a["DisplayName"].ToString(); address.Address = a["Address"].ToString(); message.To.Add(address); } } //cc foreach (DataRow a in cc.Select(String.Format("(TO = '{0}') OR (TO IS NULL)", mail["TO"]))) { address = new EmailAddress(); address.DisplayName = a["DisplayName"].ToString(); address.Address = a["Address"].ToString(); message.CC.Add(address); } //bcc foreach (DataRow a in bcc.Select(String.Format("(TO = '{0}') OR (TO IS NULL)", mail["TO"]))) { address = new EmailAddress(); address.DisplayName = a["DisplayName"].ToString(); address.Address = a["Address"].ToString(); message.BCC.Add(address); } foreach (DataRow a in replyto.Select(String.Format("(TO = '{0}') OR (TO IS NULL)", mail["TO"]))) { address = new EmailAddress(); address.DisplayName = a["DisplayName"].ToString(); address.Address = a["Address"].ToString(); message.ReplyTo.Add(address); } //attachments foreach (DataRow a in attachments.Select(String.Format("(TO = '{0}') OR (TO IS NULL)", mail["TO"]))) { EmailAttachment attachment = new EmailAttachment(); attachment.DocumentID = a["DocumentID"].ToString(); message.Attachments.Add(attachment); } email.Send(message); } } else { throw new ApplicationException("No Email Template found"); } }
public string InsertMessage( DateMode DateMode, string PhoneNo, string MessageText, string Template, string EntityType, string EntityID, string UserName, string Password, string ChannelID, string CreatedBy) { string MessageID = Guid.NewGuid().ToString(); DataCommandService dataCommandDB = DataCommandService.GetInstance();; List <ScreenDataCommandParameter> parameters = new List <ScreenDataCommandParameter>(); ScreenDataCommandParameter p = null; p = new ScreenDataCommandParameter(); p.Name = "@MessageID"; p.Value = MessageID; parameters.Add(p); p = new ScreenDataCommandParameter(); p.Name = "@PhoneNo"; p.Value = PhoneNo; parameters.Add(p); p = new ScreenDataCommandParameter(); p.Name = "@MessageText"; p.Value = MessageText; parameters.Add(p); p = new ScreenDataCommandParameter(); p.Name = "@Template"; p.Value = Template; parameters.Add(p); p = new ScreenDataCommandParameter(); p.Name = "@EntityType"; p.Value = EntityType; parameters.Add(p); p = new ScreenDataCommandParameter(); p.Name = "@EntityID"; p.Value = EntityID; parameters.Add(p); p = new ScreenDataCommandParameter(); p.Name = "@UserName"; p.Value = UserName; parameters.Add(p); p = new ScreenDataCommandParameter(); p.Name = "@Password"; p.Value = Password; parameters.Add(p); p = new ScreenDataCommandParameter(); p.Name = "@ChannelID"; p.Value = ChannelID; parameters.Add(p); p = new ScreenDataCommandParameter(); p.Name = "@CreatedOn"; switch (DateMode) { case DateMode.LocalDate: p.Value = DateTime.Now; break; case DateMode.UniversalDate: p.Value = DateTime.UtcNow; break; } parameters.Add(p); p = new ScreenDataCommandParameter(); p.Name = "@CreatedBy"; p.Value = CreatedBy; parameters.Add(p); dataCommandDB.ExecuteDataCommand(Configuration.GetInstance().App.SaveSequenceDataCommand, parameters); return(MessageID); }
public ToDateConverter(XmlNode node, String type) : base(node) { XmlNodeList nodes; this.formats = stdFormats; bool includeStd = node.ReadBool("includestandard", true); String[] formats = node.ReadStr("@formats", null).SplitStandard(); if (formats != null) { this.formats = includeStd ? formats.ToList().Concat(stdFormats).ToArray() : formats; } else { nodes = node.SelectNodes("format"); if (nodes.Count > 0) { var tmp = new List <String>(); foreach (XmlNode fn in nodes) { tmp.Add(fn.Value); } if (includeStd) { tmp.Concat(stdFormats); } this.formats = tmp.ToArray(); } } nodes = node.SelectNodes("timezone"); if (nodes.Count > 0) { var tmp = new List <_TZ>(); foreach (XmlNode x in nodes) { tmp.Add(new _TZ(x)); } timezones = tmp.ToArray(); } if (type == "dateonly") { mode = DateMode.none; } else { if (node.SelectSingleNode("@mode") == null) { mode = node.ReadBool("@utc", false) ? DateMode.ToUtc : DateMode.none; } else { mode = node.ReadEnum("@mode", DateMode.ToUtc); } } //var logger = Logs.DebugLog; //logger.Log ("{0}: Dumping formats...", this.GetType().Name); //foreach (var s in this.formats) logger.Log("-- " + s); }
public ToDateConverter(String type) : base(type) { this.formats = stdFormats; mode = (type == "dateonly") ? DateMode.none : DateMode.ToUtc; }
private void lbcShelfLabel3_DataChanged(bool enableAssoc, DateTime dateTime, int productID, DateMode dateMode, double price, NewWDS.Demo_applications.ShelfLabelDemo.Currency currency, DisplayMode displayMode, bool identifyTag) { this._shelfLabelDescriptorSet[2].setValues(enableAssoc, dateTime, productID, dateMode, price, currency, displayMode, identifyTag); if (identifyTag) { this.slpPanel.identifyLabel(3); } }
public void setNewModes(DisplayMode displayMode, DateMode dateMode) { if (!this.chbShuffleModes.Checked) { this._disableDataChangedEvent = true; switch (displayMode) { case DisplayMode.RSSI: this.rdbRSSI.Checked = true; goto Label_0076; case DisplayMode.VBAT: this.rdbBattertyVoltage.Checked = true; goto Label_0076; case DisplayMode.Humidity: this.rdbHumidity.Checked = true; goto Label_0076; case DisplayMode.Temperature: this.rdbTemperature.Checked = true; goto Label_0076; } this.rdbPrice.Checked = true; } Label_0076: if (!this.chbShuffleDateModes.Checked) { this._disableDataChangedEvent = true; switch (dateMode) { case DateMode.Time: this.rdbTime.Checked = true; goto Label_00C8; case DateMode.ProductId: this.rdbProductID.Checked = true; goto Label_00C8; } this.rdbDate.Checked = true; } Label_00C8: this._disableDataChangedEvent = false; }