private void LoadTradesFromFile(DateCollection newCol) { FileLib.WFile f = new FileLib.WFile(GetFilePath(newCol.Date)); if (!f.Exists()) { return; } var strings = f.ReadAllLines(); strings.ForEach <string>((s) => { if (s.Empty()) { return; } var dataTrade = s.Split('\t'); var trade = new Trade(); trade.Number = dataTrade[0].ToLong(); trade.Price = dataTrade[2].ToDecimal(); trade.Volume = dataTrade[3].ToInt32(); trade.Direction = dataTrade[4] == "B" ? OrderDirection.Buy : OrderDirection.Sell; trade.SecCode = dataTrade[5]; newCol.Trades.Add(trade); }); }
private static uint GetOccurrenceCount(DateTime start, DateTime endBy, string rrule) { CalendarRecurrence pattern = new CalendarRecurrence(string.Format("DTSTART:{0}\r\nRRULE:{1}", start.ToString("yyyyMMdd"), rrule)); DateCollection date = pattern.GenerateOccurrences(start, endBy); return((uint)date.Count); }
public void Add(Trade trade) { mutex.WaitOne(); var date = trade.DateTrade.Date; var el = this.ListDate.FirstOrDefault(d => d.Date == date); if (el.IsNull()) { el = new DateCollection() { Date = date }; LoadTradesFromFile(el); this.ListDate.Add(el); var tradeExists = el.Trades.FirstOrDefault(t => t.Number == trade.Number); if (tradeExists.IsNull()) { AppendTradeFile(trade); el.Trades.Add(trade); } } else { var tradeExists = el.Trades.FirstOrDefault(t => t.Number == trade.Number); if (tradeExists.IsNull()) { AppendTradeFile(trade); el.Trades.Add(trade); } } mutex.ReleaseMutex(); }
}//end constructor /// <summary> /// Method triggered when date value is changed in the Form's dateTimePicked. /// Refreshes content to represent the data of the new Date's daily tracker. /// </summary> /// <param name="date">date to switch to</param> private void ChangeFormContentByDate(DateTime date) { bool dateExists = false; Date selectedDate = null; foreach (Date d in DateCollection.GetCalendar()) { if (d.DoDatesMatch(date)) { selectedDate = d; dateExists = true; break; } }//end loop if (!dateExists) { Date d = new Date(date.Year, date.Month, date.Day); DateCollection.GetCalendar().Add(d); selectedDate = d; } if (selectedDate != null) { this.tracker = selectedDate.GetDailyTracker(); UpdateProgress(); } }//end method
static void Main() { Date currentDate = new Date(DateTime.Now); DateCollection.GetCalendar().Add(currentDate); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm(currentDate)); } //end Main()
// public internal CalendarViewHelper() { m_loadedEvent = new Event(); m_selectedDatesChangedEvent = new Event(); m_cicEvent = new Event(); m_addedDates = new DateCollection(); m_removedDates = new DateCollection(); m_loadedRegistration = CreateSafeEventRegistration <CalendarView, RoutedEventHandler>("Loaded"); m_selectedDatesChangedRegistration = CreateSafeEventRegistration <CalendarView, TypedEventHandler <CalendarView, CalendarViewSelectedDatesChangedEventArgs> >("SelectedDatesChanged"); m_cicRegistration = CreateSafeEventRegistration <CalendarView, TypedEventHandler <CalendarView, CalendarViewDayItemChangingEventArgs> >("CalendarViewDayItemChanging"); }
private ObservableCollection <string> CreateYearCollection() { Year = new ObservableCollection <string>(); int currentYear = GetLatestRevenueYear(); //populate year for (int i = currentYear; i >= currentYear - 5; i--) { Year.Add(i.ToString()); } if (DateCollection.Count > 0) { DateCollection.RemoveAt(0); } DateCollection.Insert(0, Year); return(Year); }
// ExStart:GeneratingOccurrencesFromRecurrencePatterns public static void GetOccurences() { // The path to the File directory string dataDir = RunExamples.GetDataDir_KnowledgeBase(); string tempFileName = dataDir + "Sample.pst"; Appointment appointment = CreateAppointment(); MailMessage mailMessage = CreateMessage(); AlternateView alternateView = appointment.RequestApointment(); mailMessage.AddAlternateView(alternateView); MapiMessage mapiMessage = MapiMessage.FromMailMessage(mailMessage); using (PersonalStorage pst = PersonalStorage.Create(tempFileName, FileFormatVersion.Unicode)) { FolderInfo folder = pst.RootFolder.AddSubFolder("Calendar"); folder.AddMessage(mapiMessage); } using (PersonalStorage pst = PersonalStorage.FromFile(tempFileName)) { var folder = pst.RootFolder.GetSubFolder("Calendar"); foreach (MessageInfo messageInfo in folder.GetContents()) { MapiMessage message = pst.ExtractMessage(messageInfo); MapiCalendar meeting = (MapiCalendar)message.ToMapiMessageItem(); using (MemoryStream memoryStream = new MemoryStream()) { meeting.Save(memoryStream); string s = StreamToString(memoryStream); CalendarRecurrence recurrencePattern = new CalendarRecurrence(s); DateCollection occurrences = recurrencePattern.GenerateOccurrences(); foreach (DateTime occurrence in occurrences) { Console.WriteLine("{0}", occurrence); } } } } File.Delete(tempFileName); }
/// <summary> /// This method reverse engineers the active custom schedule from the given /// MIF file. /// </summary> /// <returns>The reverse engineered custom schedule.</returns> // Revision History // MM/DD/YY Who Version Issue# Description // -------- --- ------- ------ --------------------------------------------- // 10/08/08 jrf 9.50 Created. // private void ReverseEngineerCustomSchedule() { object objValue = null; short sResponse = DEVICE_SERVER_SUCCESS; short sDisplayProgress = 0; DateTime[] adtBillingDates; DateCollection colBillingDates = new DateCollection(); if (false == m_bHasHHFBeenRead) { sResponse = (short)OpenHHF(); } if (DEVICE_SERVER_SUCCESS == sResponse) { //Get the array of billing dates sResponse = VirtualDevice.GetValue(BILLING_SCHEDULE_ITEMS, ref objValue, sDisplayProgress); } if (DEVICE_SERVER_SUCCESS == sResponse && null != objValue) { adtBillingDates = (DateTime[])Convert.ChangeType(objValue, typeof(DateTime[]), CultureInfo.InvariantCulture); //Populate a date collection foreach (DateTime dtDate in adtBillingDates) { colBillingDates.Add(dtDate); } //Add dates to the new schedule m_CustomSchedule = new CCustomSchedule(); m_CustomSchedule.AddDates(colBillingDates); } }
private ObservableCollection <string> CreateMonthCollection() { Month = new ObservableCollection <string>(); int loopMonth = 12; int latestMonth = GetLatestRevenueMonth(); if (SelectedYear == null || (SelectedYear == Convert.ToString(System.DateTime.Now.Year) && latestMonth != 12)) { loopMonth = latestMonth; } //populate months for (int i = 1; i <= loopMonth; i++) { Month.Add((i < 10 ? "0" + i : Convert.ToString(i)) + AppResources.Month); } if (DateCollection.Count > 1) { DateCollection.RemoveAt(1); } DateCollection.Insert(1, Month); return(Month); }
/// <summary> /// This method reverse engineers multiple custom schedules from a given device server. /// </summary> // Revision History // MM/DD/YY Who Version Issue# Description // -------- --- ------- ------ ------------------------------------------- // 10/06/08 jrf 9.50 Created // 12/12/08 jrf 9.50.26 124330 Set a max number of multiple custom schedules // to look for to avoid entering an infinite loop. // 124361 Added code to handle slots with no schedules configured. // 01/07/09 jrf 9.50.29 125402 Switched comparison statements in the last while loop. // The comparison checking if the index is valid needed to // come before the comparison the comparison accessing the // list. // private void ReverseEngineerMultipleCustomSchedules() { string strFilePath = CRegistryHelper.GetFilePath(PEDATA) + PEDATA + XML_EXT; int iMCSIndex = 0; int iMCSNumber = 0; object objType = MULT_CUSTOM_SCHED_DATA; object objSubType = iMCSIndex; object objFileName = strFilePath; object objStartDate = null; object objStopDate = null; CCustomSchedule BillingSchedule; DateCollection BillingDates = new DateCollection(); DateTime dtStartDate; string strMIFName = Path.GetFileNameWithoutExtension(FileName); bool blnCustomScheduleFound = true; FileStream Stream; StreamWriter Writer; XmlReader Reader; short sDisplayProgress = 0; while (iMCSIndex < MAX_MULTIPLE_CUSTOM_SCHEDULES) { //Set the PEData file to a default empty format Stream = new FileStream(strFilePath, FileMode.Create); Writer = new StreamWriter(Stream); Writer.Write(MCS_PEDATA); Writer.Close(); Stream.Close(); //Get the multiple custom schedule data out of the device server VirtualDevice.GetXMLData(objType, objSubType, objFileName, sDisplayProgress, ref objStartDate, ref objStopDate); Reader = XmlReader.Create(strFilePath); //if we don't have a year node then no custom schedule //was retreived blnCustomScheduleFound = Reader.ReadToFollowing(YEAR); if (true == blnCustomScheduleFound) { //Clear out dates for the previous schedule BillingDates.Clear(); //Read each starting time and add them to the billing schedule while (true == Reader.ReadToFollowing(START_TIME)) { string strDate = Reader.ReadElementContentAsString(); dtStartDate = (DateTime)Convert.ChangeType(strDate, typeof(DateTime), CultureInfo.InvariantCulture); BillingDates.Add(dtStartDate); } //Convert to a 1 based index for the name iMCSNumber = iMCSIndex + 1; BillingSchedule = new CCustomSchedule(); BillingSchedule.AddDates(BillingDates); BillingSchedule.Name = strMIFName + "_" + iMCSNumber.ToString(CultureInfo.InvariantCulture); BillingSchedule.Description = m_rmStrings.GetString("REVERSE_ENGINEERED_FROM") + Path.GetFileName(FileName); m_lstMultipleCustomSchedules.Add(BillingSchedule); } else { //Keep the place for an empty slot. We may have other schedules //configured after this. m_lstMultipleCustomSchedules.Add(null); } Reader.Close(); iMCSIndex++; objSubType = iMCSIndex; } //Remove null schedules from the end iMCSIndex--; while (iMCSIndex >= 0 && null == m_lstMultipleCustomSchedules[iMCSIndex]) { m_lstMultipleCustomSchedules.RemoveAt(iMCSIndex); iMCSIndex--; } }