private void asyncTrackGoogleEvents(string Category, string Action, string Label) { GoogleEvent GoogleEvent = new GoogleEvent("MadeToEarn.com", Category, Action, Label, 1); TrackingRequest requestEvent = new RequestFactory().BuildRequest(GoogleEvent); GoogleTracking.FireTrackingEvent(requestEvent); }
private static void TrackEvent(string location, string variable, string startDate, string endDate, int?count, HttpContext httpContext) { try { GoogleEvent googleEvent = new GoogleEvent("river.sdsc.edu", "NWISUV", "GetValuesObject", String.Format("{0}|{1}|{2}|{3}", location, variable, startDate, endDate), count ); TrackingRequest request = new RequestFactory().BuildRequest(googleEvent, httpContext); request.RequestedByIpAddress = httpContext.Request.UserHostAddress; GoogleTracking.FireTrackingEvent(request); } catch { return; } }
public async Task PersistCalendarEvents(ExecutionContext context) { var events = await _googleCalendarService.GetEvents(context); var savedEvents = _eventRepository.LoadAll(); try { if (events.Items is { Count : > 0 }) { foreach (var item in events.Items) { var googleEvent = new GoogleEvent(item); if (!googleEvent.HappenedToday()) { continue; } var @event = savedEvents.FirstOrDefault(e => e.Id == item.Id); if (@event == null) { await _eventRepository.Upsert(new Event(googleEvent)); } else if ([email protected](googleEvent.StartDate)) { @event.UpdateEvent(googleEvent); await _eventRepository.Upsert(@event); } } } }
/// <summary> /// Track the download event /// </summary> /// <param name="path"></param> /// <param name="context"></param> /// <param name="bytes"></param> private static void TrackDownloadEvent(string path, HttpContextWrapper context, long bytes) { ConfigurationManager.AppSettings["GoogleAnalyticsAccountCode"] = SettingsHelper.GetGoogleAnalyticsProfile(); var code = GaDotNet.Common.Data.ConfigurationSettings.GoogleAccountCode; string referrer = "NoReferrer"; if (context.Request != null && context.Request.UrlReferrer != null) { referrer = context.Request.UrlReferrer.Host; } int kiloBytes = (int)(bytes / 1024); GoogleEvent googleEvent = new GoogleEvent("http://localhost.local", "Download", referrer, path, kiloBytes); var app = (HttpApplication)context.GetService(typeof(HttpApplication)); TrackingRequest request = new RequestFactory().BuildRequest(googleEvent, app.Context); GoogleTracking.FireTrackingEvent(request); }
public Event EventMixedFromGoogle(GoogleEvent i, Event j) { if (i == null) { return(null); } if (j == null) { j = new Event { Start = new EventDateTime { TimeZone = "Europe/Rome" }, End = new EventDateTime { TimeZone = "Europe/Rome" } }; } j.Id = i.ID; j.Summary = i.Name; j.Description = i.Description; j.Location = i.Luogo; j.Start.DateTime = i.StartDate; j.End.DateTime = i.EndDate; return(j); }
private void SendData(object sender, RoutedEventArgs e) { List <RadioButton> buttons = myGrid.Children.OfType <RadioButton>().ToList(); GoogleEvent googleevent; foreach (RadioButton butt in buttons) { if ((bool)butt.IsChecked) { if (butt.Tag.ToString().Equals("Yes")) { googleevent = new GoogleEvent("SocialSilence", butt.GroupName, (string)butt.Tag, (string)butt.Tag, 1); } else if (butt.Tag.ToString().Equals("No")) { googleevent = new GoogleEvent("SocialSilence", butt.GroupName, (string)butt.Tag, (string)butt.Tag, -1); } else { googleevent = new GoogleEvent("SocialSilence", butt.GroupName, (string)butt.Tag, (string)butt.Tag, 0); } TrackingRequest request = new RequestFactory().BuildRequest(googleevent); GoogleTracking.FireTrackingEvent(request); } } this.Close(); }
public void AsyncTrackGoogleEvents(string category, string action, string label) { var googleEvent = new GoogleEvent("MadeToEarn.com", category, action, label, 1); var requestEvent = new RequestFactory().BuildRequest(googleEvent); GoogleTracking.FireTrackingEvent(requestEvent); }
private static void TrackEvent(string location, string variable, string startDate, string endDate, int?count, HttpContext httpContext, string ServiceName, string MethodName) { try { GoogleEvent googleEvent = new GoogleEvent("river.sdsc.edu", ServiceName, MethodName, String.Format("{0}|{1}|{2}|{3}", location, variable, startDate, endDate), count ); TrackingRequest request = new RequestFactory().BuildRequest(googleEvent, httpContext); request.RequestedByIpAddress = httpContext.Request.UserHostAddress; GoogleTracking.FireTrackingEvent(request); } catch { log.Error("GoogleTracker Failed"); } }
public async Task <GoogleEvent.UpdateResponse> UploadData() { IsLoadingData = true; ObjEvent.FixDates(false); var request = new GoogleEventUpdateRequest { ObjGoogleEvent = ObjEvent, RelatedOwnerGuid = App.VM.user.Guid, }; try { var ws = new WebServiceV2(); var config = new WebServiceV2.UrlToStringConfiguration { url = Globals.RestApiV1 + "loft/event/" + ObjEvent.ID + "/update", Type = WebServiceV2.UrlToStringConfiguration.RequestType.JsonRaw, Verb = WebServiceV2.UrlToStringConfiguration.RequestVerb.POST, RawContent = JsonConvert.SerializeObject(request), timeout = TimeSpan.FromSeconds(60) }; if (string.IsNullOrWhiteSpace(ObjEvent.ID)) { config.url = Globals.RestApiV1 + "loft/event/null/update"; } var res = await ws.UrlToString(config); if (res == null) { Visual1993.Console.WriteLine("bad response"); return(new GoogleEvent.UpdateResponse()); } var resObj = JsonConvert.DeserializeObject <GoogleEvent.UpdateResponse>(res); if (resObj != null) { this.ObjEvent = resObj.item; if (this.ObjEvent == null) { return(resObj); } this.ObjInternalEvent.data.RelatedGoogleEventID = this.ObjEvent.ID; if (IsNew == false) { var resInterno = await this.ObjInternalEvent.update(); } if (IsNew) { var resInterno = await this.ObjInternalEvent.insert(); IsNew = false; } //qui non ci posso mettere l'else } return(resObj); } finally { IsLoadingData = false; } }
public void Notify(string action, string label, int?value) { try { var googleEvent = new GoogleEvent(Constants.BaseAnalyticsDomainName, Constants.GaCategory, action, label, value); _log.Debug("Building event " + googleEvent); var request = _requestFactory.BuildRequest(googleEvent); _log.Debug("Firing event " + googleEvent); GoogleTracking.FireTrackingEvent(request); _log.Debug("Event " + googleEvent + " Fired"); } catch (Exception e) { _log.ErrorException("Error while trying to perform analytics event", e); } }
public static void DownloadStart(int count) { var evnt = new GoogleEvent(Domain, "Download", "Start", "Queue", count); GoogleTracking.TrackEvent(evnt); }
public async Task <string> UpdateEvent(GoogleEvent i, Guid OwnerGuid) { Event eventoEsistente = null; //verifica se fare update o insert var IsUpdate = (string.IsNullOrWhiteSpace(i.ID) == false); if (i.ID == "null") { IsUpdate = false; } if (IsUpdate == false) { EventsResource.GetRequest request = Generic.Calendar.Events.Get(MainClass.StudentsCalendar, i.ID); try { eventoEsistente = await request.ExecuteAsync(); } catch { } IsUpdate = eventoEsistente != null; } GoogleEvent.UpdateResponse output = new GoogleEvent.UpdateResponse(); try { eventoEsistente = EventMixedFromGoogle(i, eventoEsistente); if (IsUpdate) { EventsResource.UpdateRequest request = Generic.Calendar.Events.Update( eventoEsistente, MainClass.StudentsCalendar, eventoEsistente.Id ); eventoEsistente = await request.ExecuteAsync(); } else { eventoEsistente.Id = null; EventsResource.InsertRequest request = Generic.Calendar.Events.Insert( eventoEsistente, MainClass.StudentsCalendar ); eventoEsistente = await request.ExecuteAsync(); } if (eventoEsistente != null) { output.item = eventoEsistente.ToGoogleEvent(); output.state = Visual1993.Data.WebServiceV2.WebRequestState.Ok; } } catch (Exception ex) { output.state = Visual1993.Data.WebServiceV2.WebRequestState.GenericError; output.errorMessage = ex.Message; } //manda la mail al Loft team //prendi le info dell'utente per la mail //var internalEvent = (await InternalEvent.getAllFromGoogleID(i.ID)).items.FirstOrDefault(); //if (internalEvent == null) { output.errorMessage = "Impossibile trovare l'evento correlato"; return JsonConvert.SerializeObject(output);} var utente = (await User.GetOne(OwnerGuid)).items.FirstOrDefault(); if (utente == null) { output.errorMessage = "Impossibile trovare l'utente che ha inserito l'evento"; return(JsonConvert.SerializeObject(output)); } try { var msgStr = "<html><body>" + "<p>Nome: " + i.Name + "</p>" + "<p>Inizio: " + i.StartDate.ToString() + "</p>" + "<p>Fine: " + i.EndDate.ToString() + "</p>" + "<p>Owner: " + i.OwnerName + "</p>" + "<p>Luogo: " + i.Luogo + "</p>" + "<p>Descrizione: " + i.Description + "</p>" + "<p><a href=\"" + MainClass.ExternalAccessBaseUri + MainClass.LoftPrefix + "event/" + i.InternalEventGuid + "/accept\">Accetta</a></p>" + "<p><a href=\"" + MainClass.ExternalAccessBaseUri + MainClass.LoftPrefix + "event/" + i.InternalEventGuid + "/deny\">Rifiuta</a></p>" + "</body></html>" ; var mail = new MailRESTRequest { From = utente?.data?.Email ?? null, To = MainClass.StaffMail, Cc = MainClass.StaffCcMail, IsBodyHtml = true, SmtpProvider = MailRESTRequest.SmtpProviderEnum.Luiss, Body = msgStr, Subject = "Prenotazione evento Loft" }; var web = new Visual1993.Data.WebServiceV2(); var config = new WebServiceV2.UrlToStringConfiguration { url = MainClass.Visual1993RestServer + "visual1993/mail/send", Type = WebServiceV2.UrlToStringConfiguration.RequestType.JsonRaw, Verb = WebServiceV2.UrlToStringConfiguration.RequestVerb.POST, RawContent = JsonConvert.SerializeObject(mail) }; var res = await web.UrlToString(config); var resAsObj = JsonConvert.DeserializeObject <WebServiceV2.DefaultResponse>(res); if (resAsObj.state != WebServiceV2.WebRequestState.Ok) { output.errorMessage = "mail not sent. Error: " + resAsObj.errorMessage; } //ma non impostare lo stato a !=Ok perchè la richiesta in se è andata a buon fine } catch (Exception ex) { output.errorMessage = ex.Message; } return(JsonConvert.SerializeObject(output)); }
public bool UpdateModel() { if (App.VM.user == null) { UIPage.DisplayAlert("Attenzione", "E' necessario loggarsi", "Ok"); return(false); } if (IsNew) { ObjEvent = new GoogleEvent { ID = "" }; ObjInternalEvent = new Event { Guid = Guid.NewGuid(), data = new Event.PersonalizedData { RelatedOwnerGuid = App.VM.user.Guid, State = Event.PersonalizedData.EventStateEnum.Inserted } }; } ObjEvent.Name = Title; //Img = ObjEvent.ImageUris?.FirstOrDefault() ?? Globals.DefaultThumb; ObjEvent.Description = Description; ObjEvent.StartDate = StartDate.SetTime(StartTime); ObjEvent.EndDate = EndDate.SetTime(EndTime); ObjEvent.InternalEventGuid = ObjInternalEvent.Guid; ObjEvent.OwnerName = App.VM.user?.data?.Nome ?? "ND" + " " + App.VM.user?.data?.Cognome ?? "ND" + " - " + App.VM.user?.data?.Email ?? "ND"; ObjInternalEvent.data.State = Event.PersonalizedData.EventStateEnum.Pending; if ( ObjEvent.EndDate < ObjEvent.StartDate || ObjEvent.StartDate < DateTime.Now ) { UIPage.DisplayAlert("Attenzione", "Errore nella data", "Ok"); return(false); } var dataInizio_ = ObjEvent.StartDate.TimeOfDay; var dataFine = ObjEvent.EndDate.TimeOfDay; if ( (dataInizio_.Hours >= 8 && (dataInizio_.Hours < 19 && dataInizio_.Minutes <= 30)) && (dataFine.Hours >= 8 && (dataFine.Hours < 20)) ) { } else { UIPage.DisplayAlert("Attenzione", "Il LOFT è chiuso", "Ok"); return(false); } if ((ObjEvent.EndDate - ObjEvent.StartDate) < Globals.DurataMinimaEvento) { UIPage.DisplayAlert("Attenzione", "Prenotazione minima " + Globals.DurataMinimaEvento.Minutes + " minuti", "Ok"); return(false); } if ( ObjEvent.StartDate.DayOfWeek == DayOfWeek.Saturday || ObjEvent.StartDate.DayOfWeek == DayOfWeek.Sunday || ObjEvent.EndDate.DayOfWeek == DayOfWeek.Saturday || ObjEvent.EndDate.DayOfWeek == DayOfWeek.Sunday ) { UIPage.DisplayAlert("Attenzione", "Non è possibile prenotare eventi nel weekend", "Ok"); return(false); } return(true); }
public List <string> GetLuoghiDisponibili(List <GoogleEvent> eventi, GoogleEvent eventoInCorsoDiModifica = null) { var listaLuoghi = new List <LuoghiEnum>(); foreach (LuoghiEnum luogoEnum in Enum.GetValues(typeof(LuoghiEnum))) { listaLuoghi.Add(luogoEnum); } var o = new List <string>(); if (eventi == null) { } //StartDate ed EndDate sono già valorizzati con SetTime perchè dopo .UpdateModel() var luoghiDisponibiliTot = listaLuoghi.ToList(); foreach (var evento in GetOnlyEventsFromWithinDateTime(eventi, ObjEvent.StartDate, ObjEvent.EndDate)) { if (eventoInCorsoDiModifica != null && evento.ID == eventoInCorsoDiModifica?.ID) { continue; } System.Console.WriteLine("luogo occupato: " + evento.Luogo); var luoghiOccupatiPerSingoloEvento = new List <LuoghiEnum>(); foreach (var luogoString in Globals.Luoghi) { if (string.IsNullOrWhiteSpace(evento.Luogo)) { continue; } //cioè non aggiungerlo a quelli occupati if ( luogoString.LuogoStringa.ToLowerInvariant().Contains(evento.Luogo.ToLowerInvariant()) || evento.Luogo.ToLowerInvariant().Contains(luogoString.LuogoStringa.ToLowerInvariant()) ) { //se è presente tuttoLoft, ritorna if (luogoString.LuogoEnum == LuoghiEnum.Intero) { return(new List <string>()); } try { luoghiOccupatiPerSingoloEvento.Add(luogoString.LuogoEnum); } catch { } } } if (luoghiOccupatiPerSingoloEvento.Count > 0) { //allora elimina il tutto loft try { luoghiDisponibiliTot.Remove(LuoghiEnum.Intero); } catch { } } foreach (var luogoOccupatoTemp in luoghiOccupatiPerSingoloEvento.ToList()) { try { luoghiDisponibiliTot.Remove(luogoOccupatoTemp); } catch { } } } foreach (var luogoDisponibile in luoghiDisponibiliTot) { var luogoDisponibileStr = ""; luogoDisponibileStr = Globals.Luoghi.FirstOrDefault(x => x.IsCorretto == true && x.LuogoEnum == luogoDisponibile)?.LuogoStringa ?? ""; if (string.IsNullOrWhiteSpace(luogoDisponibileStr) == false) { o.Add(luogoDisponibileStr); } } return(o); }
public GoogleEventVM(GoogleEvent i) { ObjEvent = i; }
public EventCellVM(GoogleEvent i) { Obj = i; }