internal static void ValidateGetEventQueryResult(EventQuery eventQuery) { Assert.Equal("startTime eq 2015-05-10T18:02:00Z and endTime eq 2015-05-28T18:02:00Z", eventQuery.FilterUri); Assert.Equal("http://localhost", eventQuery.TableEndpoint); Assert.Equal(2, eventQuery.TableInfos.Count); Assert.Equal(new DateTime(2015, 5, 15, 18, 2, 0, DateTimeKind.Utc), eventQuery.TableInfos[0].StartTime); Assert.Equal(new DateTime(2015, 5, 25, 18, 2, 0, DateTimeKind.Utc), eventQuery.TableInfos[0].EndTime); Assert.Equal("WDEvent20150515", eventQuery.TableInfos[0].TableName); Assert.Equal("sv=2014-02-14&sr=b&st=2015-01-02T01%3A40%3A51Z&se=2015-01-02T02%3A00%3A51Z&sp=r", eventQuery.TableInfos[0].SasToken); }
private void DeleteEvent() { CalendarService oCalendarService = GAuthenticate(); //Search for Event EventQuery oEventQuery = new EventQuery(); oEventQuery.Uri = new Uri("https://www.google.com/calendar/feeds/[email protected]/private/full"); oEventQuery.ExtraParameters = "extq=[SynchronizationID:{Your GUID Here}]"; Google.GData.Calendar.EventFeed oEventFeed = oCalendarService.Query(oEventQuery); //Delete Related Events foreach (Google.GData.Calendar.EventEntry oEventEntry in oEventFeed.Entries) { oEventEntry.Delete(); break; } }
public void GetVirtualEvents() { EventQuery query = new EventQuery("virtual * *"); var events = query.GetMatchingEvents(myClassWithManyEvents); try { Assert.AreEqual(1, events.Count, "Event count"); } finally { if (ExceptionHelper.InException) { foreach (var ev in events) { Console.WriteLine("{0}", ev.Print()); } } } }
public async Task <PagedResult <Event> > GetEventsQuery(EventQuery query) { var queryable = context.Events.Include(e => e.Venue).ThenInclude(v => v.City).AsQueryable(); if (query.searchString != null) { queryable = queryable.Where(e => e.Name.Contains(query.searchString.Trim())); } if (query.EventCategories != null) { queryable = queryable.Where(e => query.EventCategories.Contains(e.EventCategoryId)); } if (query.Cities != null) { queryable = queryable.Where(e => query.Cities.Contains(e.Venue.CityId)); } if (query.Venues != null) { queryable = queryable.Where(e => query.Venues.Contains(e.VenueId)); } if (query.DateFrom != null) { queryable = queryable.Where(e => e.Date >= query.DateFrom); } if (query.DateTo != null) { queryable = queryable.Where(e => e.Date <= query.DateTo); } var count = await queryable.CountAsync(); queryable = sortingProvider.ApplySorting(queryable, query); queryable = queryable.ApplyPagination(query); var items = await queryable.ToListAsync(); return(new PagedResult <Event> { TotalCount = count, Items = items }); }
public CalendarData GetFeedOfCalendar(String feedUrl, String user, String pass) { var myService = new CalendarService("Newgen_Calendar"); myService.setUserCredentials(user, pass); var myQuery = new EventQuery(feedUrl); myQuery.StartTime = DateTime.Now; myQuery.EndTime = DateTime.Today.AddDays(2); // we search two days after EventFeed calFeed = myService.Query(myQuery); // now populate the calendar if (calFeed.Entries.Count > 0) { var entry = (EventEntry)calFeed.Entries[0]; var result = new CalendarData(); // Title result.Title = entry.Title.Text; if (entry.Locations.Count > 0 && !string.IsNullOrEmpty(entry.Locations[0].ValueString)) { result.Location = entry.Locations[0].ValueString; } else if (entry.Content != null) { result.Description = entry.Content.Content; } if (entry.Times.Count > 0) { result.BeginTime = entry.Times[0].StartTime; result.EndTime = entry.Times[0].EndTime; } return(result); } return(null); }
//get public ActionResult Edit(int?id) { EventQuery Equery = new EventQuery(); EventDTO Edto = new EventDTO(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Edto = Equery.FindEvent(id); if (Edto == null) { return(HttpNotFound()); } EventsViewModel vm = new EventsViewModel(); vm.Address = Edto.Address; vm.Categories = Edto.Categories; vm.City = Edto.City; vm.Zip = Edto.Zip; vm.Description = Edto.Description; vm.Detail = Edto.Detail; vm.HashTag = Edto.HashTag; vm.Id = Edto.Id; vm.IsActive = Edto.IsActive; vm.Logo = Edto.Logo; vm.Name = Edto.Name; vm.State = Edto.State; vm.TicketPrice = Edto.TicketPrice; vm.TimeStart = Edto.TimeStart; vm.TimeStop = Edto.TimeStop; vm.TwitterHandle = Edto.TwitterHandle; vm.Web = Edto.Web; vm.AttendeeCap = Edto.AttendeeCap; return(View(vm)); }
private void UpdateEvent() { CalendarService oCalendarService = GAuthenticate(); //Search for Event EventQuery oEventQuery = new EventQuery(); oEventQuery.Uri = new Uri("https://www.google.com/calendar/feeds/[email protected]/private/full"); oEventQuery.ExtraParameters = "extq=[SynchronizationID:{Your GUID Here}]"; Google.GData.Calendar.EventFeed oEventFeed = oCalendarService.Query(oEventQuery); //Update Related Events foreach (Google.GData.Calendar.EventEntry oEventEntry in oEventFeed.Entries) { //Update Event oEventEntry.Title.Text = "Updated Entry"; oCalendarService.Update(oEventEntry); break; } }
public static IEnumerable <EventEntry> GetAllEventsModifiedSince(CalendarService service, string feedUrl, DateTime modifiedSince, CancellationToken token) { // Create the query object: EventQuery query = new EventQuery(); query.Uri = new Uri(feedUrl); DateTime mod = modifiedSince; if (mod.Year >= 19) { //mod = mod.AddYears(19 - mod.Year); query.ExtraParameters = "updated-min=" + modifiedSince.ToString("yyyy-MM-ddTHH:mm:ssZ"); //query.ModifiedSince = modifiedSince; } query.NumberToRetrieve = 1000; // int.MaxValue; return(DownloadAll(query, service, token)); }
public void ExportToGoogleCalendar(string url, IEnumerable <ICalEvent> ics) { CalendarService calendarService = new CalendarService("dhtmlxScheduler .Net"); ((Service)calendarService).setUserCredentials(this.UserName, this.Password); EventQuery eventQuery = new EventQuery(url); EventFeed eventFeed1 = calendarService.Query(eventQuery); AtomFeed atomFeed = new AtomFeed((AtomFeed)eventFeed1); foreach (ICalEvent ic in ics) { EventEntry eventEntry = new EventEntry(); ((AtomEntry)eventEntry).Title.Text = ic.Summary; ((AtomEntry)eventEntry).Content.Content = ic.Description; When when = new When(ic.SDate, ic.EDate); eventEntry.Times.Add(when); ((AtomEntry)eventEntry).BatchData = (new GDataBatchEntryData((GDataBatchOperationType)0)); atomFeed.Entries.Add((AtomEntry)eventEntry); } EventFeed eventFeed2 = (EventFeed)((Service)calendarService).Batch(atomFeed, new Uri(((AtomFeed)eventFeed1).Batch)); }
private EventEntry FindByExtensionProperty(string name, string value) { CalendarService calendarService = GetCalendarService(); var eventQuery = new EventQuery(_settings.CalendarUrl); eventQuery.ExtraParameters = string.Format("extq=[{0}:{1}]", name, value); EventFeed eventFeed = calendarService.Query(eventQuery); var entries = eventFeed.Entries; if (entries.Count > 0) { var feedEntry = (EventEntry)entries.FirstOrDefault(); return(feedEntry); } return(null); }
private EventQuery EventQuery(long Id, bool Create = false) { EventQuery query; if (m_EventQueries.TryGetValue(Id, out query)) { return(query); } if (!Create) { return(null); } query = new EventQuery() { Id = Id }; m_EventQueries.Add(Id, query); return(query); }
List <GCalendarEventItem> UpdateEvents(GCalendarItem calendar) { EventQuery query; EventFeed eventFeed; List <GCalendarEventItem> events; query = new EventQuery(calendar.Url); query.StartTime = DateTime.UtcNow; query.EndTime = DateTime.Now.AddMonths(MonthsToIndex); events = new List <GCalendarEventItem> (); try { eventFeed = service.Query(query); foreach (EventEntry entry in eventFeed.Entries) { string eventTitle, eventUrl, eventDesc, start; eventTitle = entry.Title.Text; eventDesc = entry.Content.Content; eventUrl = entry.AlternateUri.Content; // check if the event has associated dates if (entry.Times.Any()) { start = entry.Times [0].StartTime.ToShortDateString(); eventDesc = start + " - " + eventDesc; } events.Add(new GCalendarEventItem(eventTitle, eventUrl, eventDesc)); } } catch (Exception e) { Log.Error(ErrorInMethod, "UpdateEvents", e.Message); Log.Debug(e.StackTrace); } return(events); }
public async Task <IResultList <Event> > QueryAsync(string appId, EventQuery query, CancellationToken ct = default) { using (var activity = Telemetry.Activities.StartActivity("MongoDbEventRepository/QueryAsync")) { var filter = BuildFilter(appId, query); var resultItems = await Collection.Find(filter).SortByDescending(x => x.Doc.Created).ToListAsync(query, ct); var resultTotal = (long)resultItems.Count; if (query.ShouldQueryTotal(resultItems)) { resultTotal = await Collection.Find(filter).CountDocumentsAsync(ct); } activity?.SetTag("numResults", resultItems.Count); activity?.SetTag("numTotal", resultTotal); return(ResultList.Create(resultTotal, resultItems.Select(x => x.ToEvent()))); } }
public void FireMessageToWMI(string eventName, WmiEventDelegate action, string expected) { ManagementScope scope = new ManagementScope(@"\\." + WmiPath); scope.Options.EnablePrivileges = true; EventQuery eq = new EventQuery("SELECT * FROM " + eventName); using (ManagementEventWatcher watcher = new ManagementEventWatcher(scope, eq)) { watcher.EventArrived += new EventArrivedEventHandler(WatcherEventArrived); watcher.Start(); action(); WaiUntilWMIEventArrives(); watcher.Stop(); } Assert.IsTrue(this.wmiLogged); Assert.IsTrue(this.wmiResult.IndexOf(expected) > -1); }
public static Tuple <Boolean, Boolean> checkCredentials(String scope, String username, String password) { EventEntry entry; try { CalendarService service = new CalendarService(APP_NAME); service.setUserCredentials(username, password); EventQuery query = new EventQuery(scope); query.StartTime = DateTime.Parse("12/31/1979"); query.EndTime = DateTime.Parse("1/2/1981"); query.Query = "Authentication"; query.NumberToRetrieve = 1; EventFeed calFeed = service.Query(query); if (calFeed.Entries.Count != 1) { throw new Exception("Unable to find Authentication Event!!!"); } entry = (EventEntry)calFeed.Entries[0]; entry.Content.Content = DateTime.Now.ToString(); //entry.Locations[0].ValueString = DateTime.Now.ToString(); } catch (Exception ex) { Trace.WriteLine(ex.ToString()); return(new Tuple <Boolean, Boolean>(false, false)); } try { entry.Update(); return(new Tuple <Boolean, Boolean>(true, true)); } catch (Exception ex) { Trace.WriteLine(ex.ToString()); return(new Tuple <Boolean, Boolean>(true, false)); } }
void SendLogEntry(WmiTraceListener listener, LogEntry logEntry) { ManagementScope scope = new ManagementScope(@"\\." + wmiPath); scope.Options.EnablePrivileges = true; StringBuilder sb = new StringBuilder("SELECT * FROM "); sb.Append("LogEntryV20"); string query = sb.ToString(); EventQuery eq = new EventQuery(query); using (ManagementEventWatcher watcher = new ManagementEventWatcher(scope, eq)) { watcher.EventArrived += new EventArrivedEventHandler(watcher_EventArrived); watcher.Start(); LogSource source = new LogSource("notfromconfig", SourceLevels.All); source.Listeners.Add(listener); source.TraceData(TraceEventType.Error, 1, logEntry); BlockUntilWMIEventArrives(); watcher.Stop(); } }
/// <summary> /// Gets the event stream. /// </summary> /// <typeparam name="TSource">The type of the source.</typeparam> /// <typeparam name="TResult">The type of the result.</typeparam> /// <param name="query">The query.</param> /// <returns></returns> public IObservable <TResult> GetEventStream <TSource, TResult>(EventQuery <TSource, TResult> query) { Uri uri = uriProvider.GetQueryUri(query); logger.Log(Logger.LogLevel.Debug, "Opening connection"); Connection connection = new Connection(uri.GetComponents(UriComponents.Scheme | UriComponents.HostAndPort | UriComponents.Path, UriFormat.SafeUnescaped), uri.Query.Trim('?').Split('&').Where(x => !string.IsNullOrWhiteSpace(x)).Select(pair => new KeyValuePair <string, string>(pair.Substring(0, pair.IndexOf('=')), pair.Substring(pair.IndexOf('=') + 1))).ToDictionary(x => x.Key, x => x.Value)); connection.Start(); connection.Closed += () => logger.Log(Logger.LogLevel.Debug, string.Format("Connection {0} closed", connection.ConnectionId)); return(connection.AsObservable() .Select(messageSerializer.Deserialize <EventWrapper <TResult> >) .TakeWhile(message => message.Type != EventWrapper <TResult> .EventType.Completed) .Select(message => { if (message.Type == EventWrapper <TResult> .EventType.Error) { throw new PushqaEventSourceException(message.ErrorMessage); } return message.Message; }) .Finally(connection.Stop)); }
public override bool ExtractAndValidateTypeQuery(string query) { bool lret = base.ExtractAndValidateTypeQuery(query); if (lret == false) { Out.WriteLine("The Type/event query must be of the form typeName([<visiblity>] <delegatetype> <event name>)"); Out.WriteLine("Example: *(public * *) searches for users all public events in the -in query."); } else { if (base.myInnerQuery.Trim() == "*") { myEventQuery = EventQuery.AllEvents; } else { myEventQuery = new EventQuery(base.myInnerQuery); } } return(lret); }
public static int Main(string[] args) { // Create event query to be notified within 1 second of // a change in a service EventQuery query = new EventQuery(); query.QueryString = "SELECT * FROM" + " __InstanceCreationEvent WITHIN 1 " + "WHERE TargetInstance isa \"Win32_Process\""; // Initialize an event watcher and subscribe to events // that match this query ManagementEventWatcher watcher = new ManagementEventWatcher(query); // times out watcher.WaitForNextEvent in 5 seconds watcher.Options.Timeout = new TimeSpan(0, 0, 5); // Block until the next event occurs // Note: this can be done in a loop if waiting for // more than one occurrence Console.WriteLine( "Open an application (notepad.exe) to trigger an event."); ManagementBaseObject e = watcher.WaitForNextEvent(); //Display information from the event Console.WriteLine( "Process {0} has been created, path is: {1}", ((ManagementBaseObject)e ["TargetInstance"])["Name"], ((ManagementBaseObject)e ["TargetInstance"])["ExecutablePath"]); //Cancel the subscription watcher.Stop(); return(0); }
public static void deleteEvent(Appointment appt) { if (authenticated == true) { //create new thread for deleting events BackgroundWorker bw = new BackgroundWorker(); bw.DoWork += delegate(object s, DoWorkEventArgs args) { lock (threadLock) { try { if (eventIDs.ContainsKey(appt.AppointmentId) == false) { return; } EventQuery myQuery = new EventQuery(postUri.ToString() + "/" + eventIDs[appt.AppointmentId]); EventFeed resultFeed = (EventFeed)service.Query(myQuery); //only delete if an event is found if (resultFeed.Entries.Count > 0) { resultFeed.Entries[0].Delete(); } //ensure associated google event information tied to this event is removed deleteEventID(appt.AppointmentId); } catch (Exception e) { Util.logError("Google Calendar Error: " + e.Message); } } }; //start the thread bw.RunWorkerAsync(); } }
protected override void Execute() { List <string> filterList = new List <string>(); filterList.Add(string.Format(CultureInfo.InvariantCulture, "startTime eq '{0:O}'", StartTime.ToUniversalTime())); filterList.Add(string.Format(CultureInfo.InvariantCulture, "endTime eq '{0:O}'", EndTime.ToUniversalTime())); if (!string.IsNullOrEmpty(NodeName)) { filterList.Add(string.Format(CultureInfo.InvariantCulture, "computerName eq '{0}'", NodeName)); } if (!string.IsNullOrEmpty(ResourceUri)) { filterList.Add(string.Format(CultureInfo.InvariantCulture, "resourceUri eq '{0}'", ResourceUri)); } if (ProviderGuid != null) { filterList.Add(string.Format(CultureInfo.InvariantCulture, "providerId eq '{0}'", ProviderGuid)); } if (EventId != null) { List <string> eventIdFilters = new List <string>(); foreach (var eventId in EventId) { eventIdFilters.Add(string.Format(CultureInfo.InvariantCulture, "eventId eq '{0}'", eventId)); } if (eventIdFilters.Any()) { string eventIdFilter = eventIdFilters.Aggregate((current, next) => string.Format(CultureInfo.InvariantCulture, "{0} or {1}", current, next)); filterList.Add(string.Format(CultureInfo.InvariantCulture, "({0})", eventIdFilter)); } } string filter = filterList.Aggregate((current, next) => string.Format(CultureInfo.InvariantCulture, "{0} and {1}", current, next)); EventQuery eventQuery = Client.Farms.GetEventQuery(ResourceGroupName, FarmName, filter); WriteObject(eventQuery, true); }
private void SetUpQuery() { _queryBuilder = new ProcessesQueryBuilder(); _queryBuilder.Visit(_expression); var selection = "*"; if (_queryBuilder.Selects.Count > 0) { selection = String.Join(", ", _queryBuilder.Selects .Select(s => "TargetInstance." + s)); } EventQuery q = new EventQuery(); // TODO: also support __InstanceDeletionEvent and __InstanceModificationEvent based on // say a Kind flag in the ProcessEvent type and Where(pi => pi.Kind == ...) filters. q.QueryString = "SELECT " + selection + " FROM __InstanceCreationEvent WITHIN 1 WHERE TargetInstance isa \"Win32_Process\""; foreach (var where in _queryBuilder.Wheres) { q.QueryString += " AND TargetInstance." + where.Item1 + " = \"" + where.Item2.ToString() + "\""; } Console.WriteLine(q.QueryString); ManagementScope scope = new ManagementScope(@"\\localhost\root\cimv2"); ManagementEventWatcher w = new ManagementEventWatcher(scope, q); w.Options.Timeout = TimeSpan.FromSeconds(60); w.Start(); w.EventArrived += w_EventArrived; }
public void TestLoggingACustomEntry() { ManagementScope scope = new ManagementScope(@"\\." + this.wmiPath); scope.Options.EnablePrivileges = true; string query = "SELECT * FROM MyCustomLogEntry"; EventQuery eq = new EventQuery(query); using (ManagementEventWatcher watcher = new ManagementEventWatcher(scope, eq)) { watcher.EventArrived += new EventArrivedEventHandler(watcher_EventArrived); watcher.Start(); this.sink.SendMessage(GetCustomLogEntry()); BlockUntilWMIEventArrives(); watcher.Stop(); } Assert.IsTrue(this.wmiLogged); Assert.IsTrue(this.wmiResult.IndexOf(CommonUtil.MsgBody) > -1); }
// Iterate over all trades public static long ViewAll(Event xepEvent) { // Create and execute query using EventQuery String sqlQuery = "SELECT * FROM MyApp.Trade WHERE purchaseprice > ? ORDER BY stockname, purchaseDate"; EventQuery <Trade> xepQuery = xepEvent.CreateQuery <Trade>(sqlQuery); xepQuery.AddParameter(0); // find stocks purchased > $0/share (all) long startTime = DateTime.Now.Ticks; xepQuery.Execute(); // Iterate through and write names of stocks using EventQueryIterator Trade trade = xepQuery.GetNext(); while (trade != null) { Console.WriteLine(trade.stockName + "\t" + trade.purchasePrice + "\t" + trade.purchaseDate); trade = xepQuery.GetNext(); } long totalTime = DateTime.Now.Ticks - startTime; xepQuery.Close(); return(totalTime / TimeSpan.TicksPerMillisecond); }
/// <exception cref="System.Security.SecurityException"> /// Thrown when current user does not have the permission to access the key /// to monitor. /// </exception> /// <exception cref="System.ArgumentException"> /// Thrown when the key to monitor does not exist. /// </exception> public RegistryWatcher(RegistryKey hive, string keyPath, string valueName) { Hive = hive ?? throw new ArgumentNullException(nameof(hive)); KeyPath = keyPath ?? throw new ArgumentNullException(nameof(keyPath)); ValueName = valueName ?? throw new ArgumentNullException(nameof(valueName)); if (!SupportedHives.Contains(hive)) { throw new ArgumentException($"{hive} not supported", nameof(hive)); } // If you set the platform of this project to x86 and run it on a 64bit // machine, you will get the Registry Key under // HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node when the key path is // HKEY_LOCAL_MACHINE\SOFTWARE KeyToMonitor = hive.OpenSubKey(keyPath, true); if (KeyToMonitor == null) { throw new ArgumentException($@"The registry key {Hive.Name}\{KeyPath} does not exist"); } if (Value == null) { throw new ArgumentException($@"The registry value {ValueName} does not exist in {Hive.Name}\{KeyPath}"); } // Construct the query string. string queryString = $@"SELECT * FROM RegistryValueChangeEvent WHERE Hive = '{Hive.Name}' AND KeyPath = '{KeyPath.Replace(@"\", @"\\")}' AND ValueName = '{ValueName}'"; Query = new EventQuery(queryString); EventArrived += RegistryWatcher_EventArrived; Start(); }
/// <summary> /// Your documentation here. (see /// http://msdn.microsoft.com/en-us/library/windowsazure/XXXXX.aspx /// for more information) /// </summary> /// <param name="eventQuery"> /// Required. Your documentation here. /// </param> /// <param name="continuationToken"> /// Optional. Your documentation here. /// </param> /// <param name="maxCount"> /// Optional. Your documentation here. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> /// <returns> /// Your documentation here. /// </returns> public async Task <EventListResponse> ExecuteEventQuerySegmentedAsync( EventQuery eventQuery, EventQueryContinuationToken continuationToken, int?maxCount, CancellationToken cancellationToken) { // Validate if (eventQuery == null) { throw new ArgumentNullException("eventQuery"); } if (maxCount.HasValue && maxCount.Value <= 0) { throw new ArgumentOutOfRangeException("maxCount"); } var shouldTrace = TracingAdapter.IsEnabled; string invocationId = String.Empty; if (shouldTrace) { invocationId = TracingAdapter.NextInvocationId.ToString(); var tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("eventQuery", eventQuery); tracingParameters.Add("continuationToken", continuationToken); tracingParameters.Add("maxCount", maxCount); TracingAdapter.Enter(invocationId, this, "ExecuteEventQuerySegmentedAsync", tracingParameters); } var response = await QueryEventAsync(eventQuery, continuationToken, maxCount, cancellationToken); if (shouldTrace) { TracingAdapter.Exit(invocationId, response); } return(response); }
public CalendarEventObject[] GetEvents() { try { if (Authenticate()) { EventQuery query = new EventQuery(m_CalendarUrl); EventFeed feed = m_Service.Query(query); return((from EventEntry entry in feed.Entries select new CalendarEventObject() { Date = entry.Times[0].StartTime, Title = entry.Title.Text }).ToArray()); } else { return(new CalendarEventObject[0]); } } catch (Exception) { return(new CalendarEventObject[0]); } }
public IObservable <TResult> GetEventStream <TSource, TResult>(EventQuery <TSource, TResult> query) { Uri = new QueryUriProvider().GetQueryUri(query); return(new TResult[0].ToObservable()); }
/// <summary> /// Refreshes the current entries for this month. /// Does only really retrieve if it is not in this month. /// </summary> /// <returns> /// A primitive vector of EventEntry object, which is also the new /// feed of entries of the object. /// </returns> /// <param name='time'> /// The time the events should be retrieved for. /// </param> public EventEntry[] RefreshFeed(DateTime time, bool forced) { if (this.NeedsUpdateFor(time) || forced) { ServicePointManager.ServerCertificateValidationCallback = Validator; EventQuery query = new EventQuery(); var service = new CalendarService(AppInfo.Name); var toret = new List <EventEntry>(); while (this.OnTransaction) { } this.OnTransaction = true; if (this.IsUsrSet) { service.setUserCredentials(this.Usr, this.Psw); // only get event's for this month this.currentDate = new DateTime(time.Year, time.Month, 1); query.Uri = new Uri(GCalURI); query.StartTime = this.CurrentDate; query.EndTime = new DateTime( time.Year, time.Month, DateTime.DaysInMonth(time.Year, time.Month) ); query.EndTime = query.EndTime.AddDays(1); // create the list of events var calFeed = (service.Query(query) as EventFeed); while (calFeed != null && calFeed.Entries.Count > 0) { foreach (EventEntry entry in calFeed.Entries) { InsertOrdered(toret, entry); } // just query the same query again. if (calFeed.NextChunk != null) { query.Uri = new Uri(calFeed.NextChunk); calFeed = service.Query(query) as EventFeed; } else { calFeed = null; } } // Update current entries record this.currentEvents = toret.ToArray(); } else { throw new Exception("User field cannot be empty"); } this.OnTransaction = false; } return(this.CurrentEvents); }
private void RefreshFeed() { string calendarURI = "https://www.google.com/calendar/feeds/default/private/full"; string userName = "******"; string passWord = "******"; this.entryList = new ArrayList(); EventQuery query = new EventQuery(); CalendarService service = new CalendarService("CalendarSampleApp"); service.setUserCredentials(userName, passWord); // only get event's for today - 48 months until today + ½ year query.Uri = new Uri(calendarURI); query.StartTime = DateTime.Now.AddMonths(-48); query.EndTime = DateTime.Now.AddMonths(6); EventFeed calFeed = service.Query(query) as EventFeed; // now populate the calendar while (calFeed != null && calFeed.Entries.Count > 0) { // look for the one with dinner time... foreach (EventEntry entry in calFeed.Entries) { this.entryList.Add(entry); } // just query the same query again. if (calFeed.NextChunk != null) { query.Uri = new Uri(calFeed.NextChunk); calFeed = service.Query(query) as EventFeed; } else calFeed = null; } }
private void InitLogTime(EventQuery.CQuery.CTimeCreated time) { int selIdx = -1; if (time == null) { selIdx = 0; } else if (!time.HasDates) { for (int i = 0; i < LogTimeBaseItems.Length; i++) if (LogTimeBaseItems[i].DiffTime == time.span) { selIdx = i; break; } if (selIdx == -1) throw new ArgumentOutOfRangeException("Unable to identify selection option for specified log time."); } else { int x = (time.low.HasValue ? 1 : 0) | (time.high.HasValue ? 2 : 0); string resStr; switch (x) { case 1: resStr = EditorProperties.Resources.EventLogTimeCustomFrom; break; case 2: resStr = EditorProperties.Resources.EventLogTimeCustomTo; break; case 3: resStr = EditorProperties.Resources.EventLogTimeCustomFromTo; break; case 0: default: resStr = null; break; } if (resStr == null) selIdx = 0; else { string txt = string.Format(resStr, time.low, time.high); if (logTimeCombo.Items.Count == 7) logTimeCombo.Items.Insert(6, txt); else logTimeCombo.Items[6] = txt; selIdx = 6; } } logTimeCombo.SelectedIndex = selIdx; }
private bool UpdateQLFromText(bool initForm = true) { if (queryTextIsDirty) // && editManuallyCheckBox.Checked) { try { ql = EventQuery.Deserialize(queryText.Text); queryTextIsDirty = false; if (initForm) Initialize(); } catch (Exception ex) { var s = EditorProperties.Resources.Error_EventFilterBadQuery; if (ex is InvalidOperationException && ex.InnerException is InvalidOperationException && ex.InnerException.Data.Contains("Remaining text")) s += string.Format("\r\n" + EditorProperties.Resources.Error_EventFilterBadQueryText, ex.InnerException.Data["Remaining text"].ToString()); MessageBox.Show(this, s, null, MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } } return true; }
/// <summary> /// Your documentation here. (see /// http://msdn.microsoft.com/en-us/library/windowsazure/XXXXX.aspx /// for more information) /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.AzureStack.Management.StorageAdmin.IFarmOperations. /// </param> /// <param name="eventQuery"> /// Required. Your documentation here. /// </param> /// <returns> /// Your documentation here. /// </returns> public static IEnumerable <EventModel> ExecuteEventQuery( this IFarmOperations operations, EventQuery eventQuery) { return(operations.ExecuteEventQuery(eventQuery)); }
private static async Task <EventListResponse> QueryEventAsync( EventQuery eventQuery, EventQueryContinuationToken continuationToken, int?maxCount, CancellationToken cancellationToken) { if (maxCount.HasValue && maxCount.Value <= 0) { throw new ArgumentOutOfRangeException("maxCount"); } if (eventQuery == null) { throw new ArgumentNullException("eventQuery"); } if (eventQuery.TableInfos == null) { throw new ArgumentException("eventQuery.TableInfos is null"); } var response = new EventListResponse { Events = new List <EventModel>(), ContinuationToken = new EventQueryContinuationToken() }; var tableinfoIterator = eventQuery.TableInfos.GetEnumerator(); do { if (tableinfoIterator.MoveNext()) { cancellationToken.ThrowIfCancellationRequested(); continue; } response.ContinuationToken = null; return(response); } while (continuationToken != null && tableinfoIterator.Current.TableName != continuationToken.NextTableName); try { var tableClient = new CloudTableClient( new Uri(eventQuery.TableEndpoint), new StorageCredentials(tableinfoIterator.Current.SasToken)); var cloudTable = tableClient.GetTableReference(tableinfoIterator.Current.TableName); var tableQuery = new TableQuery <DynamicTableEntity>().Where(eventQuery.FilterUri).Take(maxCount); cancellationToken.ThrowIfCancellationRequested(); var tableContinuationToken = continuationToken == null ? null : continuationToken.NextTableContinuationToken; var tableResults = await cloudTable.ExecuteQuerySegmentedAsync(tableQuery, tableContinuationToken, cancellationToken); response.Events = tableResults.Select( _ => new EventModel { Properties = ResolveEventEntity(_) }).ToList(); response.ContinuationToken.NextTableContinuationToken = tableResults.ContinuationToken; if (response.ContinuationToken.NextTableContinuationToken == null) { if (!tableinfoIterator.MoveNext()) { response.ContinuationToken = null; return(response); } } response.ContinuationToken.NextTableName = tableinfoIterator.Current.TableName; } catch (StorageException error) { throw new EventQueryException("Error occurs when query event table", error); } return(response); }
public ManagementEventWatcher(ManagementScope scope, EventQuery query) {}
public ManagementEventWatcher(ManagementScope scope, EventQuery query, EventWatcherOptions options) {}
public ManagementEventWatcher(EventQuery query) {}
public EntryJsonResponseBase Search(EventQuery query) { var parameters = query.ToParameters(); return(Search <EntryJsonResponse>("apiv2/events", parameters)); }
private void GetEvents() { CalendarService oCalendarService = GAuthenticate(); //Uri oCalendarUri = new Uri("https://www.google.com/calendar/feeds/[email protected]/private/full"); //Search for Event EventQuery oEventQuery = new EventQuery(); oEventQuery.Uri = new Uri("https://www.google.com/calendar/feeds/[email protected]/private/full"); //oEventQuery.Query = "Query String"; oEventQuery.ExtraParameters = "orderby=starttime&sortorder=ascending"; oEventQuery.StartTime = DateTime.Now; oEventQuery.EndTime = DateTime.Now.AddDays(50); //oEventQuery.SingleEvents = true; Google.GData.Calendar.EventFeed oEventFeed = oCalendarService.Query(oEventQuery); string dt = ""; DataTable table = new DataTable(); table.Columns.Add(new DataColumn("EventTitle")); table.Columns.Add(new DataColumn("EventSummary")); table.Columns.Add(new DataColumn("EventStartDate")); table.Columns.Add(new DataColumn("EventEndDate")); table.Columns.Add(new DataColumn("EventStatus")); table.Columns.Add(new DataColumn("EventId")); table.Columns.Add(new DataColumn("EventLocation")); table.Columns.Add(new DataColumn("EventUId")); foreach (var entry in oEventFeed.Entries) { Google.GData.Calendar.EventEntry eventEntry = entry as Google.GData.Calendar.EventEntry; if (eventEntry != null) { if (eventEntry.Times.Count != 0) { DataRow dr = table.NewRow(); dr["EventUId"] = eventEntry.Uid.Value; dr["EventId"] = eventEntry.EventId.ToString(); dr["EventTitle"] = eventEntry.Title.Text; dr["EventSummary"] = eventEntry.Summary.Text; dr["EventStartDate"] = eventEntry.Times[0].StartTime.ToString("dd/MM/yyyy"); dr["EventEndDate"] = eventEntry.Times[0].EndTime.ToString("dd/MM/yyyy"); dr["EventStatus"] = eventEntry.Status.Value.ToString(); dr["EventLocation"] = Convert.ToString(eventEntry.Locations[0].ValueString); table.Rows.Add(dr); //dt = dt + eventEntry.Title.Text + "<br/>"; } } } //eventsLabel.Text = dt; gvCal.DataSource = table; gvCal.DataBind(); }