/// <summary> /// Insert new events and Bolded Dates into queues. /// </summary> /// <param name="events">Source of events, that should be inserted.</param> /// <param name="from">Local paramater from with which this was started.</param> /// <param name="to">Local paramater to with which this was started.</param> private void insertEventsAndBoldedDates(IEnumerable <TimeEvent> events, DateTime from, DateTime to) { foreach (var item in events) { if (invokeStopPreviewQueing(from, to)) { return; } lock (listboxPreviewData) { while (listboxPreviewData.Count > 500) { Monitor.Wait(listboxPreviewData, 250); if (invokeStopPreviewQueing(from, to)) { return; } } listboxPreviewData.Enqueue(item); } lock (previewBoldedDates) { if (invokeStopPreviewQueing(from, to)) { return; } SupportMethods.EnqueInterval(previewBoldedDates, item.StartDate, item.EndDate); } } }
/// <summary> /// Calculate new hash and return new <see cref="TimeEvent"/> with same data but newly generated hash. /// </summary> /// <param name="te">Already existing TimeEvent with good datas, but wrong hash.</param> /// <returns></returns> public static TimeEvent CreateTimeEventWithDuplicitHash(TimeEvent te) { Random rand = new Random(); string hash = SupportMethods.GetMd5Hash(DateTime.Now + rand.NextDouble().ToString() + te.Name + te.Description + te.StartDate + te.EndDate + te.Notification + te.NotificationDate); return(new TimeEvent(hash, te.Name, te.Description, te.StartDate, te.EndDate, te.Notification, te.NotificationDate)); }
/// <summary> /// Insert new Events and Bolded Dates into queues. /// </summary> /// <param name="events">Source of events, that should be inserted.</param> /// <param name="sParams">Local paramater with which this was started.</param> private void insertEventsAndBoldedDates(IEnumerable <TimeEvent> events, SearchParams sParams) { foreach (var item in events) { if (invokeStopSearchQueing(sParams)) { return; } lock (listboxSearchData) { while (listboxSearchData.Count > 500) { Monitor.Wait(listboxSearchData, 250); if (invokeStopSearchQueing(sParams)) { return; } } listboxSearchData.Enqueue(item); } lock (searchBoldedDates) { if (invokeStopSearchQueing(sParams)) { return; } SupportMethods.EnqueInterval(searchBoldedDates, item.StartDate, item.EndDate); } } }
/// <summary> /// Create new <see cref="TimeEvent"/> and calculate hash by inserted Datas and other value. /// </summary> /// <param name="hash">Hash of <see cref="TimeEvent"/></param> /// <param name="name">Name of <see cref="TimeEvent"/></param> /// <param name="description">Description of <see cref="TimeEvent"/></param> /// <param name="startDate">StartDate of <see cref="TimeEvent"/></param> /// <param name="endDate">EndDate of <see cref="TimeEvent"/></param> /// <param name="notification">Notification of <see cref="TimeEvent"/></param> /// <param name="notificationDate">NotificationDate of <see cref="TimeEvent"/></param> /// <returns><see cref="TimeEvent"/> with given parameters.</returns> public static TimeEvent CreateTimeEvent(string name, string description, DateTime startDate, DateTime endDate, bool notification, DateTime notificationDate) { Random rand = new Random(); string hash = SupportMethods.GetMd5Hash(DateTime.Now + rand.NextDouble().ToString() + name + description + startDate + endDate + notification + notificationDate); return(new TimeEvent(hash, name, description, startDate, endDate, notification, notificationDate)); }
/// <summary> /// Create database with local databaseName. /// </summary> void createNewDatabase() { #if Mono SqliteConnection.CreateFile(databaseName + ".sqlite"); #else SQLiteConnection.CreateFile(databaseName + ".sqlite"); #endif connectToDatabase(); createTimeEventTable(); createChangeTable(); createSynchronizationDeviceTable(); createApplicationInfoTable(); InsertApplicationInfo( new ApplicationInfo("", SupportMethods.GetMd5Hash(DateTime.Now.Ticks.ToString()).Substring(24), "", false, true)); }