public async Task <List <TimeReport> > GetAllClients() { List <TimeReport> clients = new List <TimeReport>(); var handle = Insights.TrackTime("Time_GetAllClients"); handle.Start(); try { HttpClient client = new HttpClient(); // Set pref result as JSON client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); // Call the API for clients Task <string> contentsTask = client.GetStringAsync(Url); // await! control returns to the caller and the task continues to run on another thread string contents = await contentsTask.ConfigureAwait(false); // Deserialize the JSON data into ContactManager (List of contacts) clients = JsonConvert.DeserializeObject <List <TimeReport> >(contents); } catch (Exception ex) { Dictionary <string, string> myDictionary = new Dictionary <string, string> { { "Function", "ClientManager.GetAllClients" } }; _logger.LoggError(ex, myDictionary, (Xamarin.Insights.Severity.Error)); } finally { // Stop the GetAllClients-timer handle.Stop(); } return(clients); }
private async Task ExecuteSearchBeersCommand() { if (IsBusy) { return; } using (Insights.TrackTime("BeerSearch", "searchTerm", SearchTerm)) { _userDialogs.ShowLoading("Searching..."); IsBusy = true; IsSearched = true; try { var results = await _beerDrinkinClient.SearchBeersAsync(SearchTerm); Beers.Clear(); if (results?.Count > 0) { foreach (var beer in results) { Beers.Add(beer); } } _userDialogs.HideLoading(); } catch (Exception ex) { _userDialogs.ShowError(ex.Message); } finally { IsBusy = false; } } }
public async Task <Client> GetClient(int id) { Client client = new Client(); var handle = Insights.TrackTime("Time_GetClient"); handle.Start(); try { HttpClient httpClient = new HttpClient(); // Set pref result as JSON httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); // Call the API with id as request args Task <string> contentsTask = httpClient.GetStringAsync(Url + id.ToString()); // await! control returns to the caller and the task continues to run on another thread string contents = await contentsTask.ConfigureAwait(false); // Deserialize the JSON data into Contact client = JsonConvert.DeserializeObject <Client>(contents); } catch (Exception ex) { Dictionary <string, string> myDictionary = new Dictionary <string, string> { { "Function", "ClientManager.GetClient" }, { "Key", id.ToString() } }; _logger.LoggError(ex, myDictionary, (Xamarin.Insights.Severity.Error)); } finally { // Stop the GetContact-timer handle.Stop(); } return(client); }
public async Task SaveContract(Contract contract) { string uri = $"http://consultadminwebserver.azurewebsites.net/api/Contract"; var handle = Insights.TrackTime("Time-SaveContract"); handle.Start(); HttpClient httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); try { var requestJSON = JsonConvert.SerializeObject(contract); await httpClient.PostAsync(uri, new StringContent(requestJSON.ToString(), Encoding.UTF8, "application/json")); _logger.LoggEvent("SaveContract", new Dictionary <string, string>() { { "EmployeeId", contract.EmployeeId.ToString() }, //{"EmployeeId", CurrentUser.EmployeeId.ToString()}, { "ClientId", contract.ClientId.ToString() }, { "ClientName", contract.ClientName }, { "ContractName", contract.ContractName }, { "StartDate", contract.StartDate.ToString("yyyy-MM-dd") }, { "EndDate", contract.EndDate.ToString("yyyy-MM-dd") } }); handle.Stop(); } catch (Exception ex) { _logger.LoggError(ex, new Dictionary <string, string>() { { "Function", "SaveContract" } }, Insights.Severity.Error); } return; }
public string ReadOutLoudYoda(string yoda) { var handle = Insights.TrackTime("Time for API to connect"); handle.Start(); var response = Unirest.get("https://yoda.p.mashape.com/yoda?sentence=" + yoda) .header("X-Mashape-Key", "jNdTUH1UxUmshWJ0duG9JGydgLqGp13bv6IjsnmZCuwlTEAK62") .header("Accept", "text/plain") .asString(); if (response.Code == 200) { return(response.Body); } handle.Stop(); string errorMessages = "Could not connect to API"; return(errorMessages); }
public async void ContinueFileSavePicker(FileSavePickerContinuationEventArgs args) { var file = args.File; if (file == null) { CurtainPrompt.ShowError("Backup cancelled."); return; } using (Insights.TrackTime("Create Backup")) { UiBlockerUtility.Block("Backing up (this may take a bit)..."); App.Locator.SqlService.Dispose(); App.Locator.BgSqlService.Dispose(); try { var data = await AutcpFormatHelper.CreateBackup(ApplicationData.Current.LocalFolder); using (var stream = await file.OpenStreamForWriteAsync()) { await stream.WriteAsync(data, 0, data.Length); } } catch (Exception e) { Insights.Report(e, "Where", "Creating Backup"); CurtainPrompt.ShowError("Problem creating backup."); } App.Locator.SqlService.Initialize(); App.Locator.BgSqlService.Initialize(); UiBlockerUtility.Unblock(); } CurtainPrompt.Show("Backup completed."); }
public async void OnButtonClick(object sender, EventArgs e) { string entryText = textEntry.Text; Insights.Track(Insights_Constants.GO_BUTTON_TAPPED, Insights_Constants.TEXT_ENTERED, entryText); Device.BeginInvokeOnMainThread(() => { //Hide the keyboard textEntry.Unfocus(); //Show the activity indicator and hide the Go Button activityIndicator.IsRunning = true; activityIndicator.IsVisible = true; goButton.IsVisible = false; goButton.IsEnabled = false; }); //Perform a task for 2000 miliseconds var timer = Insights.TrackTime(Insights_Constants.ACTIVITY_INDICATOR_ONSCREEN); timer.Start(); await Task.Delay(2000); timer.Stop(); Device.BeginInvokeOnMainThread(() => { //Hide the activity indicator now that task has completed activityIndicator.IsRunning = false; activityIndicator.IsVisible = false; goButton.IsVisible = true; goButton.IsEnabled = true; //display the textLabel.Text = entryText; }); }
public async Task <IEnumerable <Order> > GetAllOrdersAsync() { try { using (var handle = Insights.TrackTime("TimeToGetAllOrders")) { return(await _OrderTable // .Where(order => order.IsOpen == false) .ToEnumerableAsync()); } } catch (MobileServiceInvalidOperationException ex) { Insights.Report(ex, Insights.Severity.Error); Debug.WriteLine(@"ERROR {0}", ex.Message); } catch (Exception ex2) { Insights.Report(ex2, Insights.Severity.Error); Debug.WriteLine(@"ERROR {0}", ex2.Message); } return(new List <Order>()); }
public async Task <CreateProfileResponse> RegisterUser(CancellationToken cancellationToken, UserProfile user) { var postDictionary = (from x in user.GetType().GetRuntimeProperties() select x) .ToDictionary(x => x.Name, x => x.GetMethod.Invoke(user, null) == null ? "" : x.GetMethod.Invoke(user, null).ToString()); var content = new FormUrlEncodedContent(postDictionary); using (var handle = Insights.TrackTime("RegisterUser", postDictionary)) { var response = await _client.PostAsync("/api/audience/createprofile", content, cancellationToken); if (!response.IsSuccessStatusCode) { return(null); } var jsonMessage = await response.Content.ReadAsStringAsync(); var tokenResponse = JsonConvert.DeserializeObject <CreateProfileResponse>(jsonMessage); return(tokenResponse); } }
public void OnSave(object o, EventArgs e) { try { var handle = Insights.TrackTime("Time to save new task"); handle.Start(); vm.AddTask( ToDoEntry.Text, Priority.Text, Date.Date, Time.Time.Hours, Time.Time.Minutes, Time.Time.Seconds, updateID, false); handle.Stop(); string savedString = "Your saved task was: " + ToDoEntry.Text; Insights.Track("Saved string", new Dictionary <string, string> { { "The saved string", savedString } }); } catch (Exception ex) { Insights.Report(ex, new Dictionary <string, string> { { "Method name: ", "OnSave()" }, { "Where: ", "Main.xaml.cs" } }); } }
public async void RefreshCritics(int movieId) { var handle = Insights.TrackTime("TimeLoadReview", new Dictionary <string, string> { { "MovieID", movieId.ToString() } }); handle.Start(); List <Review> reviewList = await PotatoesManager.Instance.GetReviews(movieId); handle.Stop(); LinearLayout criticsReviewList = FindViewById <LinearLayout>(Resource.Id.criticsReviewListView); criticsReviewList.RemoveAllViews(); LayoutInflater inflater = (LayoutInflater)this.GetSystemService(Context.LayoutInflaterService); foreach (Review r in reviewList) { View view = inflater.Inflate(Resource.Layout.Adapter_Movie_Reviews, null); TextView nameView = view.FindViewById <TextView>(Resource.Id.nameView); nameView.Text = r.Critic; TextView sourceView = view.FindViewById <TextView>(Resource.Id.sourceView); sourceView.Text = r.Publication; TextView quoteView = view.FindViewById <TextView>(Resource.Id.quoteView); quoteView.Text = r.Quote; ImageView ratingPicView = view.FindViewById <ImageView>(Resource.Id.certifiedView); int certifiedPic = this.Resources.GetIdentifier("drawable/" + r.GetFreshnessIcon(), null, this.PackageName); ratingPicView.SetImageResource(certifiedPic); view.Click += delegate { this.openUrl(r.Links.Review.AbsoluteUri); }; criticsReviewList.AddView(view); } }
public async Task <IEnumerable <Order> > GetClosedOrdersForAccountAsync(string accountId) { try { using (var handle = Insights.TrackTime("TimeToGetAccountHistory")) { return(await _OrderTable .Where(order => order.AccountId == accountId && order.IsOpen == false) .OrderByDescending(order => order.ClosedDate) .ToEnumerableAsync()); } } catch (MobileServiceInvalidOperationException ex) { Insights.Report(ex, Insights.Severity.Error); Debug.WriteLine(@"ERROR {0}", ex.Message); } catch (Exception ex2) { Insights.Report(ex2, Insights.Severity.Error); Debug.WriteLine(@"ERROR {0}", ex2.Message); } return(new List <Order>()); }
public async Task <IEnumerable <Account> > GetAccountsAsync(bool leads = false) { try { using (var handle = Insights.TrackTime("TimeToGetAccountList")) { return(await _AccountTable .Where(account => account.IsLead == leads) .OrderBy(b => b.Company) .ToEnumerableAsync()); } } catch (MobileServiceInvalidOperationException ex) { Insights.Report(ex, Insights.Severity.Error); Debug.WriteLine(@"ERROR {0}", ex.Message); } catch (Exception ex2) { Insights.Report(ex2, Insights.Severity.Error); Debug.WriteLine(@"ERROR {0}", ex2.Message); } return(new List <Account>()); }
private ITracker TrackTime(string identifier, IDictionary <string, string> extraData) { return(new Tracker(Insights.TrackTime(identifier, extraData))); }
public IDisposable TrackTimeContext(string identifier) { var handler = Insights.TrackTime(identifier); return(new DisposableContext(handler.Start, handler.Stop)); }
private async Task <ResponseInfo> SendRequest(RequestAction action, object parameters = null) { Guid id = Guid.NewGuid(); var requestInfo = new RequestInfo { RequestAction = action, Parameters = parameters == null ? null : JObject.FromObject(parameters), RequestId = id }; var message = new NetworkMessage { MessageType = NetworkMessageType.Request, Payload = JObject.FromObject(requestInfo) }; Task <ResponseInfo> responseMessage = this.GetResponsePipeline() .FirstAsync(x => x.RequestId == id) .ToTask(); var traits = new Dictionary <string, string> { { "Operation", action.ToString() } }; if (requestInfo.Parameters != null) { foreach (KeyValuePair <string, JToken> parameter in requestInfo.Parameters) { traits.Add(parameter.Key, parameter.Value.ToString()); } } ResponseInfo response; try { using (Insights.TrackTime("Network", traits)) { await this.SendMessage(message); response = await responseMessage; traits.Add("Response", response.Status.ToString()); } } catch (Exception ex) { ex.Data["requestInfo"] = requestInfo; Insights.Report(ex); this.Log().ErrorException("Fatal error while sending or receiving a network response", ex); this.Disconnect(); throw new NetworkException("Fatal error while sending or receiving a network response", ex); } if (response.Status != ResponseStatus.Success) { var exception = new NetworkRequestException(requestInfo, response); Insights.Report(exception); throw exception; } return(response); }
public ExtendedSessionFeedback() { //if (!Xamarin.Insights.IsInitialized) //{ // Xamarin.Insights.Initialize("cb9dddf47d18b81b88181a4f106fcb7565048148"); // Insights.ForceDataTransmission = true; // if (!string.IsNullOrEmpty(App.uuid)) // { // var manyInfos = new Dictionary<string, string> { // { Xamarin.Insights.Traits.GuestIdentifier, App.uuid }, // { "CurrentCulture", CultureInfo.CurrentCulture.Name } // }; // Xamarin.Insights.Identify(App.uuid, manyInfos); // } //} IDictionary <string, string> info = new Dictionary <string, string>(); if (App.CurrentSession != null) { info = new Dictionary <string, string> { { "SessionId", App.CurrentSession.Id } } } ; handle = Insights.TrackTime("ExtendedFeedbackTime", info); var titleLabel = new FontLabel { Font = Device.OnPlatform(Font.OfSize("HelveticaNeue-Light", NamedSize.Small), Font.SystemFontOfSize(18), Font.SystemFontOfSize(22)), FontLabelType = FontLabelType.Light, LineBreakMode = LineBreakMode.WordWrap, TextColor = App.XamBlue, Text = "Session" }; var title = new FontLabel { Font = Device.OnPlatform(Font.OfSize("HelveticaNeue-Light", NamedSize.Small), Font.SystemFontOfSize(18), Font.SystemFontOfSize(22)), FontLabelType = FontLabelType.Light, LineBreakMode = LineBreakMode.WordWrap, TextColor = Color.White, Text = App.CurrentSession.Title }; var registrationIdLabel = new FontLabel { Font = Device.OnPlatform(Font.OfSize("HelveticaNeue-Light", NamedSize.Small), Font.SystemFontOfSize(18), Font.SystemFontOfSize(22)), FontLabelType = FontLabelType.Light, LineBreakMode = LineBreakMode.WordWrap, TextColor = App.XamBlue, Text = "Registration Id *" }; registrationEntry = new Entry { Placeholder = "XXXXXXXX", TextColor = Device.OnPlatform(Color.Black, Color.White, Color.White), Keyboard = Keyboard.Numeric, }; registrationEntry.Unfocused += async(sender, args) => { if (!String.IsNullOrEmpty(registrationEntry.Text) && !long.TryParse(registrationEntry.Text, out uuid)) { registrationEntry.Text = ""; await DisplayAlert("Invalid Registration Id!", "Please check your Tag for Registration Id.", "OK"); registrationEntry.Focus(); } }; var changeLink = new FontLabel { Font = Device.OnPlatform(Font.OfSize("HelveticaNeue-Light", NamedSize.Micro), Font.SystemFontOfSize(14), Font.SystemFontOfSize(22)), FontAttributes = FontAttributes.Italic, FontLabelType = FontLabelType.Light, LineBreakMode = LineBreakMode.WordWrap, VerticalOptions = LayoutOptions.End, TextColor = App.XamDarkBlue, Text = "Edit" }; var tap = new TapGestureRecognizer((view, obj) => { registrationEntry.IsEnabled = true; registrationEntry.Focus(); changeLink.IsVisible = false; }); changeLink.GestureRecognizers.Add(tap); var registrationStack = new StackLayout { Orientation = StackOrientation.Horizontal, }; if (!String.IsNullOrEmpty(App.uuid)) { registrationEntry.Text = App.uuid; registrationEntry.IsEnabled = false; registrationStack.Children.Add(registrationEntry); registrationStack.Children.Add(changeLink); } else { registrationStack.Children.Add(registrationEntry); registrationEntry.IsEnabled = true; } var questionOne = new FontLabel { Font = Device.OnPlatform(Font.OfSize("HelveticaNeue-Light", NamedSize.Small), Font.SystemFontOfSize(18), Font.SystemFontOfSize(22)), FontLabelType = FontLabelType.Light, LineBreakMode = LineBreakMode.WordWrap, TextColor = App.XamBlue, Text = "Quality of Session Content *" }; var answerOnePicker = new Picker { Title = "Select", }; answerOnePicker.Items.Add("4 - Excellent"); answerOnePicker.Items.Add("3"); answerOnePicker.Items.Add("2"); answerOnePicker.Items.Add("1 - Poor"); var questionTwo = new FontLabel { Font = Device.OnPlatform(Font.OfSize("HelveticaNeue-Light", NamedSize.Small), Font.SystemFontOfSize(18), Font.SystemFontOfSize(22)), FontLabelType = FontLabelType.Light, LineBreakMode = LineBreakMode.WordWrap, TextColor = App.XamBlue, Text = "Quality of Session Delivery *" }; var answerTwoPicker = new Picker { Title = "Select", }; answerTwoPicker.Items.Add("4 - Excellent"); answerTwoPicker.Items.Add("3"); answerTwoPicker.Items.Add("2"); answerTwoPicker.Items.Add("1 - Poor"); var questionThree = new FontLabel { Font = Device.OnPlatform(Font.OfSize("HelveticaNeue-Light", NamedSize.Small), Font.SystemFontOfSize(18), Font.SystemFontOfSize(22)), FontLabelType = FontLabelType.Light, LineBreakMode = LineBreakMode.WordWrap, TextColor = App.XamBlue, Text = "Overall Session Quality *" }; var answerThreePicker = new Picker { Title = "Select", }; answerThreePicker.Items.Add("4 - Excellent"); answerThreePicker.Items.Add("3"); answerThreePicker.Items.Add("2"); answerThreePicker.Items.Add("1 - Poor"); var feedbackLabel = new FontLabel { Font = Device.OnPlatform(Font.OfSize("HelveticaNeue-Light", NamedSize.Small), Font.SystemFontOfSize(18), Font.SystemFontOfSize(22)), FontLabelType = FontLabelType.Light, LineBreakMode = LineBreakMode.WordWrap, TextColor = App.XamBlue, Text = "Feedback" }; var txtFeedback = new Editor { VerticalOptions = LayoutOptions.FillAndExpand, }; var extendedQuestion = new FontLabel { Font = Device.OnPlatform(Font.OfSize("HelveticaNeue-Light", NamedSize.Small), Font.SystemFontOfSize(18), Font.SystemFontOfSize(22)), FontLabelType = FontLabelType.Light, LineBreakMode = LineBreakMode.WordWrap, TextColor = App.XamBlue, Text = "Overall feedback for your experience at Azure Conference till now:" }; var questionFour = new FontLabel { Font = Device.OnPlatform(Font.OfSize("HelveticaNeue-Light", NamedSize.Small), Font.SystemFontOfSize(18), Font.SystemFontOfSize(22)), FontLabelType = FontLabelType.Light, LineBreakMode = LineBreakMode.WordWrap, TextColor = App.XamBlue, Text = "How satisfied were you with this event *" }; var answerFourPicker = new Picker { Title = "Select", }; answerFourPicker.Items.Add("4 - Very Satisfied"); answerFourPicker.Items.Add("3"); answerFourPicker.Items.Add("2"); answerFourPicker.Items.Add("1 - Very Dissatisfied"); var questionFive = new FontLabel { Font = Device.OnPlatform(Font.OfSize("HelveticaNeue-Light", NamedSize.Small), Font.SystemFontOfSize(18), Font.SystemFontOfSize(22)), FontLabelType = FontLabelType.Light, LineBreakMode = LineBreakMode.WordWrap, TextColor = App.XamBlue, Text = "How likely are you to complete a web site, business solution, or consumer app (using any OS) that utilizes Azure services in the next 6 months? *" }; var answerFivePicker = new Picker { Title = "Select", }; answerFivePicker.Items.Add("4 - Very likely"); answerFivePicker.Items.Add("3"); answerFivePicker.Items.Add("2"); answerFivePicker.Items.Add("1 - Not at all"); var questionSix = new FontLabel { Font = Device.OnPlatform(Font.OfSize("HelveticaNeue-Light", NamedSize.Small), Font.SystemFontOfSize(18), Font.SystemFontOfSize(22)), FontLabelType = FontLabelType.Light, LineBreakMode = LineBreakMode.WordWrap, TextColor = App.XamBlue, Text = "How likely are you to recommend the use of Microsoft products/solutions to colleagues or peers? *" }; var answerSixPicker = new Picker { Title = "Select", }; answerSixPicker.Items.Add("4 - Very likely"); answerSixPicker.Items.Add("3"); answerSixPicker.Items.Add("2"); answerSixPicker.Items.Add("1 - Not at all"); var buttonReset = new Button { Text = "Reset" }; var buttonSubmit = new Button { Text = "Submit" }; buttonReset.Clicked += (sender, args) => { answerOnePicker.SelectedIndex = answerTwoPicker.SelectedIndex = answerThreePicker.SelectedIndex = answerFourPicker.SelectedIndex = answerFivePicker.SelectedIndex = answerSixPicker.SelectedIndex = -1; txtFeedback.Text = ""; }; var spinner = new ActivityIndicator { IsRunning = false, IsVisible = false, Color = Device.OnPlatform(App.XamBlue, Color.White, Color.White) }; var isSubmitting = false; buttonSubmit.Clicked += async(sender, args) => { if (!App.NetworkMonitor.IsAvailable()) { await DisplayAlert("No Internet Connectivity!", "Your Phone is not connected to the Internet. Please connect and try again.", "OK"); } else if (isSubmitting == false) { isSubmitting = true; var answerOne = Utils.GetPickerValue(answerOnePicker.SelectedIndex); var answerTwo = Utils.GetPickerValue(answerTwoPicker.SelectedIndex); var answerThree = Utils.GetPickerValue(answerThreePicker.SelectedIndex); var answerFour = Utils.GetPickerValue(answerFourPicker.SelectedIndex); var answerFive = Utils.GetPickerValue(answerFivePicker.SelectedIndex); var answerSix = Utils.GetPickerValue(answerSixPicker.SelectedIndex); if (!String.IsNullOrEmpty(registrationEntry.Text) && !long.TryParse(registrationEntry.Text, out uuid)) { registrationEntry.Text = ""; await DisplayAlert("Invalid Registration Id!", "Please check your Tag for Registration Id.", "OK"); registrationEntry.Focus(); } else if (uuid == 0 || answerOne == -1 || answerTwo == -1 || answerThree == -1) { await DisplayAlert("Mandatory inputs missing!", "Please provide your response for the mandatory(*) fields.", "OK"); isSubmitting = false; } else { try { spinner.IsRunning = true; spinner.IsVisible = true; var feedback = new Feedback2(); feedback.OverallRating = answerThree; feedback.PlatformId = Device.OnPlatform(3, 2, 1); feedback.SessionId = App.CurrentSession.Id; feedback.SessionRating = answerOne; feedback.SpeakerRating = answerTwo; feedback.TextFeedback = txtFeedback.Text; feedback.UserId = uuid; App.uuid = uuid.ToString(); feedback.ToContact = true; var eventFeedback = new Eventfeedback(); eventFeedback.UserId = uuid; eventFeedback.OverallSatisfaction = answerFour; eventFeedback.CompleteAzure = answerFive; eventFeedback.RecommendAzure = answerSix; Insights.Track("ContactUs Data", new Dictionary <string, string> { { "UserID", uuid.ToString() }, { "Feedback", JsonConvert.SerializeObject(feedback) }, { "EventFeedback", JsonConvert.SerializeObject(eventFeedback) } }); await DisplayAlert("Submitting you feedback!", "Please wait while we submit your feedback.", "OK"); var res = await App.feedbackManager.SaveFeedbackTaskAsync(feedback); var res1 = await App.feedbackManager.SaveEventFeedbackTaskAsync(eventFeedback); if (!res || !res1) { await DisplayAlert("No Internet Connectivity!", "Your Phone is not connected to the Internet. Please connect and try again.", "OK"); } else { App.FeedbackList.Add(App.CurrentSession.Id); if (App.CurrentDayType == DayTypes.Day1) { App.DayOneFeedbackCount = App.DayOneFeedbackCount + 1; App.DayOneExtFeedback = true; AppStorageHelper.SaveDayOneExtFeedback(1); AppStorageHelper.SaveDayOneFeedbackCount(App.DayOneFeedbackCount); } else if (App.CurrentDayType == DayTypes.Day2) { App.DayTwoFeedbackCount = App.DayTwoFeedbackCount + 1; App.DayTwoExtFeedback = true; AppStorageHelper.SaveDayTwoExtFeedback(1); AppStorageHelper.SaveDayTwoFeedbackCount(App.DayTwoFeedbackCount); } await DisplayAlert("Thank You!", "Thanks for providing your valuable feedback.", "OK"); handle.Stop(); await this.Navigation.PopAsync(); } } catch (Exception ex) { Insights.Report(ex); } isSubmitting = false; spinner.IsVisible = false; spinner.IsRunning = false; } } }; var stackButtons = new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.CenterAndExpand, Children = { buttonReset, buttonSubmit }, }; var feedbackStack = new StackLayout { Children = { titleLabel, title, registrationIdLabel, registrationStack, questionOne, answerOnePicker, questionTwo, answerTwoPicker, questionThree, answerThreePicker, feedbackLabel, txtFeedback, extendedQuestion, questionFour, answerFourPicker, questionFive, answerFivePicker, questionSix, answerSixPicker, spinner, stackButtons }, }; var scrollView = new ScrollView { VerticalOptions = LayoutOptions.Fill, Orientation = ScrollOrientation.Vertical, Content = feedbackStack, }; Content = scrollView; Title = "Feedback"; Padding = new Thickness(10, 0); BackgroundColor = Color.Black; BindingContext = _viewModel; }
public ContactUsPage() { //if (!Xamarin.Insights.IsInitialized) //{ // Xamarin.Insights.Initialize("cb9dddf47d18b81b88181a4f106fcb7565048148"); // Insights.ForceDataTransmission = true; // if (!string.IsNullOrEmpty(App.uuid)) // { // var manyInfos = new Dictionary<string, string> { // { Xamarin.Insights.Traits.GuestIdentifier, App.uuid }, // { "CurrentCulture", CultureInfo.CurrentCulture.Name } // }; // Xamarin.Insights.Identify(App.uuid, manyInfos); // } //} handle = Insights.TrackTime("ContactUsTime"); var registrationIdLabel = new FontLabel { Font = Device.OnPlatform(Font.OfSize("HelveticaNeue-Light", NamedSize.Small), Font.SystemFontOfSize(18), Font.SystemFontOfSize(22)), FontLabelType = FontLabelType.Light, LineBreakMode = LineBreakMode.WordWrap, TextColor = App.XamBlue, Text = "Registration Id *" }; registrationEntry = new Entry { Placeholder = "XXXXXXXX", TextColor = Device.OnPlatform(Color.Black, Color.White, Color.White), Keyboard = Keyboard.Numeric, }; registrationEntry.Unfocused += async(sender, args) => { if (!String.IsNullOrEmpty(registrationEntry.Text) && !long.TryParse(registrationEntry.Text, out uuid)) { registrationEntry.Text = ""; await DisplayAlert("Invalid Registration Id!", "Please check your Tag for Registration Id.", "OK"); registrationEntry.Focus(); } }; var changeLink = new FontLabel { Font = Device.OnPlatform(Font.OfSize("HelveticaNeue-Light", NamedSize.Small), Font.SystemFontOfSize(14), Font.SystemFontOfSize(22)), FontAttributes = FontAttributes.Italic, FontLabelType = FontLabelType.Light, LineBreakMode = LineBreakMode.WordWrap, VerticalOptions = LayoutOptions.End, TextColor = App.XamDarkBlue, Text = "Edit" }; var tap = new TapGestureRecognizer((view, obj) => { registrationEntry.IsEnabled = true; registrationEntry.Focus(); changeLink.IsVisible = false; }); changeLink.GestureRecognizers.Add(tap); var registrationStack = new StackLayout { Orientation = StackOrientation.Horizontal, }; if (!String.IsNullOrEmpty(App.uuid)) { registrationEntry.Text = App.uuid; registrationEntry.IsEnabled = false; registrationStack.Children.Add(registrationEntry); registrationStack.Children.Add(changeLink); } else { registrationStack.Children.Add(registrationEntry); registrationEntry.IsEnabled = true; } var questionOne = new FontLabel { Font = Device.OnPlatform(Font.OfSize("HelveticaNeue-Light", NamedSize.Small), Font.SystemFontOfSize(18), Font.SystemFontOfSize(22)), FontLabelType = FontLabelType.Light, LineBreakMode = LineBreakMode.WordWrap, TextColor = App.XamBlue, Text = "As a result of attending this event, my propensity to recommend Microsoft Cloud Services has *" }; var answerOnePicker = new Picker { Title = "Select", }; answerOnePicker.Items.Add("Increased"); answerOnePicker.Items.Add("Decreased"); answerOnePicker.Items.Add("Stayed the same"); var questionTwo = new FontLabel { Font = Device.OnPlatform(Font.OfSize("HelveticaNeue-Light", NamedSize.Small), Font.SystemFontOfSize(18), Font.SystemFontOfSize(22)), FontLabelType = FontLabelType.Light, LineBreakMode = LineBreakMode.WordWrap, TextColor = App.XamBlue, Text = "Which of the following best describes your role in deciding on investing in the Microsoft Cloud Solution? *" }; var answerTwoPicker = new Picker { Title = "Select", }; answerTwoPicker.Items.Add("I am a Technical Decision Maker"); answerTwoPicker.Items.Add("I am a Business Decision Maker"); answerTwoPicker.Items.Add("I influence the above decision"); var questionTwoText = new FontLabel { Font = Device.OnPlatform(Font.OfSize("HelveticaNeue-Light", NamedSize.Small), Font.SystemFontOfSize(18), Font.SystemFontOfSize(22)), FontLabelType = FontLabelType.Light, LineBreakMode = LineBreakMode.WordWrap, TextColor = App.XamBlue, Text = "My role is: " }; var answerTwoText = new Entry { HorizontalOptions = LayoutOptions.FillAndExpand, IsEnabled = false }; answerTwoPicker.SelectedIndexChanged += (sender, args) => { if (answerTwoPicker.SelectedIndex == 2) { answerTwoText.IsEnabled = true; answerTwoText.Focus(); } else { answerTwoText.IsEnabled = false; answerTwoText.Text = ""; } }; var questionTwoStack = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { questionTwoText, answerTwoText } }; var questionThree = new FontLabel { Font = Device.OnPlatform(Font.OfSize("HelveticaNeue-Light", NamedSize.Small), Font.SystemFontOfSize(18), Font.SystemFontOfSize(22)), FontLabelType = FontLabelType.Light, LineBreakMode = LineBreakMode.WordWrap, TextColor = App.XamBlue, Text = "Approximately how many PCs do you have in your organization? (Please mention nos.) *" }; var answerThree = new Entry { TextColor = Device.OnPlatform(Color.Black, Color.White, Color.White), Keyboard = Keyboard.Numeric, }; //var answerThreePicker = new Picker //{ // Title = "Select", //}; //answerThreePicker.Items.Add("< 10"); //answerThreePicker.Items.Add("11 - 50"); //answerThreePicker.Items.Add("51 - 100"); //answerThreePicker.Items.Add("> 100"); var questionFour = new FontLabel { Font = Device.OnPlatform(Font.OfSize("HelveticaNeue-Light", NamedSize.Small), Font.SystemFontOfSize(18), Font.SystemFontOfSize(22)), FontLabelType = FontLabelType.Light, LineBreakMode = LineBreakMode.WordWrap, TextColor = App.XamBlue, Text = "When do you intent to deploy Microsoft Cloud Solution? *" }; var answerFourPicker = new Picker { Title = "Select", }; answerFourPicker.Items.Add("0 - 3 months"); answerFourPicker.Items.Add("3 - 6 months"); answerFourPicker.Items.Add("6 months - 1 year"); answerFourPicker.Items.Add("More than 1 year"); var questionFive = new FontLabel { Font = Device.OnPlatform(Font.OfSize("HelveticaNeue-Light", NamedSize.Small), Font.SystemFontOfSize(18), Font.SystemFontOfSize(22)), FontLabelType = FontLabelType.Light, LineBreakMode = LineBreakMode.WordWrap, TextColor = App.XamBlue, Text = "Do you have a planned budget for implementing Microsoft Cloud Solution offerings interested in? *" }; var answerFivePicker = new Picker { Title = "Select", }; answerFivePicker.Items.Add("Yes"); answerFivePicker.Items.Add("No"); var questionFiveText = new FontLabel { Font = Device.OnPlatform(Font.OfSize("HelveticaNeue-Light", NamedSize.Small), Font.SystemFontOfSize(18), Font.SystemFontOfSize(22)), FontLabelType = FontLabelType.Light, LineBreakMode = LineBreakMode.WordWrap, TextColor = App.XamBlue, Text = "Estimated budget (optional)" }; var answerFiveText = new Entry { HorizontalOptions = LayoutOptions.FillAndExpand, IsEnabled = false }; answerFivePicker.SelectedIndexChanged += (sender, args) => { if (answerFivePicker.SelectedIndex == 0) { answerFiveText.IsEnabled = true; answerFiveText.Focus(); } else { answerFiveText.IsEnabled = false; answerFiveText.Text = ""; } }; var questionFiveStack = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { questionFiveText, answerFiveText } }; var questionSix = new FontLabel { Font = Device.OnPlatform(Font.OfSize("HelveticaNeue-Light", NamedSize.Small), Font.SystemFontOfSize(18), Font.SystemFontOfSize(22)), FontLabelType = FontLabelType.Light, LineBreakMode = LineBreakMode.WordWrap, TextColor = App.XamBlue, Text = "Comments:" }; var answerSix = new Editor { VerticalOptions = LayoutOptions.FillAndExpand, }; var buttonReset = new Button { Text = "Reset" }; var buttonSubmit = new Button { Text = "Submit" }; buttonReset.Clicked += (sender, args) => { answerOnePicker.SelectedIndex = answerTwoPicker.SelectedIndex = answerFourPicker.SelectedIndex = answerFivePicker.SelectedIndex = -1; answerTwoText.Text = answerSix.Text = answerThree.Text = ""; }; var stackButtons = new StackLayout { HorizontalOptions = LayoutOptions.CenterAndExpand, Orientation = StackOrientation.Horizontal, Children = { buttonReset, buttonSubmit }, }; var spinner = new ActivityIndicator { IsRunning = false, IsVisible = false, Color = Device.OnPlatform(App.XamBlue, Color.White, Color.White) }; //spinner.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy"); //spinner.SetBinding(ActivityIndicator.IsVisibleProperty, "IsBusy"); var isSubmitting = false; buttonSubmit.Clicked += async(sender, args) => { if (!App.NetworkMonitor.IsAvailable()) { await DisplayAlert("No Internet Connectivity!", "Your Phone is not connected to the Internet. Please connect and try again.", "OK"); } else if (isSubmitting == false) { isSubmitting = true; var answerOne = Utils.GetPickerValue(answerOnePicker.SelectedIndex); var answerTwo = Utils.GetPickerValue(answerTwoPicker.SelectedIndex); var answerFour = Utils.GetPickerValue(answerFourPicker.SelectedIndex); var answerFive = Utils.GetPickerValue(answerFivePicker.SelectedIndex); var answerTwoTextReq = false; var answerFiveTextReq = false; if (answerTwo == 2 && String.IsNullOrEmpty(answerTwoText.Text)) { answerTwoTextReq = true; answerTwoText.Focus(); } if (answerFive == 0 && String.IsNullOrEmpty(answerFiveText.Text)) { answerFiveTextReq = true; answerFiveText.Focus(); } if (!String.IsNullOrEmpty(registrationEntry.Text) && !long.TryParse(registrationEntry.Text, out uuid)) { registrationEntry.Text = ""; await DisplayAlert("Invalid Registration Id!", "Please check your Tag for Registration Id.", "OK"); registrationEntry.Focus(); } else if (uuid == 0 || answerOne == -1 || answerTwo == -1 || answerFour == -1 || answerFive == -1 || String.IsNullOrEmpty(answerThree.Text) || answerTwoTextReq || answerFiveTextReq) { await DisplayAlert("Mandatory inputs missing!", "Please provide your response for the mandatory(*) fields.", "OK"); } else { try { spinner.IsRunning = true; spinner.IsVisible = true; var contactUs = new ContactUs(); contactUs.AnswerOne = answerOne; contactUs.AnswerTwo = answerTwo; contactUs.AnswerTwoText = answerTwoText.Text; contactUs.AnswerThree = answerThree.Text; contactUs.AnswerFour = answerFour; contactUs.AnswerFive = answerFive; contactUs.AnswerFiveText = answerFiveText.Text; contactUs.AnswerSix = answerSix.Text; contactUs.PlatformId = Device.OnPlatform(3, 2, 1); contactUs.UserId = uuid; App.uuid = uuid.ToString(); Insights.Track("ContactUs Data", new Dictionary <string, string> { { "UserID", uuid.ToString() }, { "Data", JsonConvert.SerializeObject(contactUs) } }); //await DisplayAlert("Submitting your data!", "Please wait while we submit your feedback.", "OK"); var res = await App.feedbackManager.SaveContactUsTaskAsync(contactUs); if (!res) { await DisplayAlert("No Internet Connectivity!", "Your Phone is not connected to the Internet. Please connect and try again.", "OK"); } else { await DisplayAlert("Thank You!", "Thanks for providing your valuable feedback.", "OK"); //await this.Navigation.PopAsync(); answerOnePicker.SelectedIndex = answerTwoPicker.SelectedIndex = answerFourPicker.SelectedIndex = answerFivePicker.SelectedIndex = -1; answerTwoText.Text = answerSix.Text = answerThree.Text = ""; handle.Stop(); } } catch (Exception ex) { Insights.Report(ex); } isSubmitting = false; spinner.IsVisible = false; spinner.IsRunning = false; App.IOsMasterDetailPage.IsPresented = true; } } }; var contactStack = new StackLayout { Children = { registrationIdLabel, registrationStack, questionOne, answerOnePicker, questionTwo, answerTwoPicker, questionTwoStack, questionThree, answerThree, questionFour, answerFourPicker, questionFive, answerFivePicker, questionFiveStack, questionSix, answerSix, spinner, stackButtons }, }; var scrollView = new ScrollView { VerticalOptions = LayoutOptions.Fill, Orientation = ScrollOrientation.Vertical, Content = contactStack, }; Content = scrollView; Title = "Contact Us"; Padding = new Thickness(10, 0); BackgroundColor = Color.Black; BindingContext = App.ViewModel; }
async Task <bool> InitIntra(string login, string password) { Content = new ActivityIndicator { IsRunning = true, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center }; bool res = await App.API.CreditialTest(login, password); if (!res) { return(res); } RootMaster.CreateChidrens(); var handle = Insights.TrackTime("TimeToLogin"); handle.Start(); var progressbar = new ActivityIndicator(); var status = new Label { FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), XAlign = TextAlignment.Center }; var root = new StackLayout { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, Children = { status, progressbar } }; Content = root; progressbar.IsRunning = true; status.Text = "On y est presque..."; ((App)Application.Current).User = ((User)await RootMaster.MenuTabs [0].Page.SilentUpdate(login)); ((Profile)RootMaster.MenuTabs [0].Page).DisplayContent(RootMaster.MenuTabs [0].Page.Data); ((Profile)RootMaster.MenuTabs [0].Page).TargetUser = login; ((App)Application.Current).Root.DrawMenu(); var user = ((User)((RootMaster.MenuTabs [0].Page.Data))); var traits = new Dictionary <string, string> { { Insights.Traits.Email, user.InternalEmail }, { Insights.Traits.Name, user.Firstname + " " + user.Lastname }, { Insights.Traits.FirstName, user.Firstname }, { Insights.Traits.LastName, user.Lastname } }; traits.Add("promotion", user.Promo.ToString()); traits.Add("location", user.Location); traits.Add("school", user.SchoolTitle); traits.Add("GPA", user.Gpa [user.Gpa.Length - 1].GPA.ToString()); traits.Add("cycle", user.Gpa [user.Gpa.Length - 1].Cycle); Insights.Identify(user.Login, traits); handle.Stop(); ((App)Application.Current).IsUserConnected = true; ((App)Application.Current).UserLogin = login; return(true); }
public async Task BootAppServicesAsync() { if (!_init) { Locator.CollectionService.ScaledImageSize = GetScaledImageSize(); using (var handle = Insights.TrackTime("Boot App Services")) { StatusBar.GetForCurrentView().ForegroundColor = Colors.White; try { try { await Locator.SqlService.InitializeAsync().ConfigureAwait(false); } catch (SQLiteException ex) { if (ex.Message.Contains("IOError") || ex.Message.Contains("I/O")) { // issues when SQLite can't delete the wal related files, so init in delete mode // and then go back to wal mode Locator.SqlService.Dispose(); Locator.SqlService.Initialize(false); Locator.SqlService.Dispose(); Locator.SqlService.Initialize(); } } try { await Locator.BgSqlService.InitializeAsync().ConfigureAwait(false); } catch (SQLiteException ex) { if (ex.Message.Contains("IOError") || ex.Message.Contains("I/O")) { // issues when SQLite can't delete the wal related files, so init in delete mode // and then go back to wal mode Locator.BgSqlService.Dispose(); Locator.BgSqlService.Initialize(false); Locator.BgSqlService.Dispose(); Locator.BgSqlService.Initialize(); } } await Locator.CollectionService.LoadLibraryAsync().ConfigureAwait(false); handle.Data.Add("SongCount", Locator.CollectionService.Songs.Count.ToString()); DispatcherHelper.RunAsync(() => Locator.Download.LoadDownloads()); } catch (Exception ex) { Insights.Report(ex, "Where", "Booting App Services"); DispatcherHelper.RunAsync( () => CurtainPrompt.ShowError("AppErrorBooting".FromLanguageResource())); } LoadCortana(); _init = true; } } Locator.AudioPlayerHelper.OnAppActive(); Locator.Player.OnAppActive(); }
public ITrackHandle TrackTime(string identifier, string key, string value) { return(Insights.TrackTime(identifier, key, value)); }
public IDisposable TrackTime(string id, IDictionary <string, string> metadata = null) => Insights.TrackTime(id, metadata);
protected override ITrackHandle InsightsTrackTime(string identifier, IDictionary <string, string> table = null) { return(Insights.TrackTime(identifier, table)); }
public static async Task <Emotion[]> GetEmotionResultsFromMediaFile(MediaFile mediaFile, bool disposeMediaFile) { using (var handle = Insights.TrackTime(InsightsConstants.AnalyzeEmotion)) return(await EmotionClient.RecognizeAsync(MediaService.GetPhotoStream(mediaFile, disposeMediaFile)).ConfigureAwait(false)); }
public IDisposable TrackTime(string key, IDictionary <string, string> traits = null) => Insights.TrackTime(key, traits);
public ContentPage GenerateContent() { var btnCrashApp = new Button { Text = "Additional information reports" }; var btnDivByZero = new Button { Text = "Divide by zero" }; var btnFileException = new Button { Text = "File exception" }; var btnNullRef = new Button { Text = "Null ref" }; var btnPartialInfo = new Button { Text = "Partial info" }; var btnStartMultiTracker = new Button { Text = "Start mult tracker" }; var btnStartTimer = new Button { Text = "Start timer" }; var btnSingle = new Button { Text = "Single identity" }; var btnMultipleId = new Button { Text = "Multiple Identities" }; var stackIds = new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Orientation = StackOrientation.Vertical, BackgroundColor = Color.White, Children = { new Label { Text = "Identities" }, new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, Children ={ btnSingle, btnMultipleId } }, new Label { Text = "Divide By Zero" }, new StackLayout { HorizontalOptions = LayoutOptions.Center, Children ={ btnDivByZero } }, new Label { Text = "Additional information reports" }, new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, Children ={ btnFileException, btnNullRef, btnPartialInfo} }, new Label { Text = "Uncaught exception" }, new StackLayout { HorizontalOptions = LayoutOptions.Center, Children ={ btnCrashApp } }, new Label { Text = "Timer tracking" }, new StackLayout { HorizontalOptions = LayoutOptions.Center, Children ={ btnStartTimer } }, new Label { Text = "Multiple tracking" }, new StackLayout { HorizontalOptions = LayoutOptions.Center, Children ={ btnStartMultiTracker } } } }; var content = new ContentPage { Content = stackIds, Padding = new Thickness(0, 20, 0, 0) // really just for iOS }; btnCrashApp.IsEnabled = btnDivByZero.IsEnabled = btnFileException.IsEnabled = btnNullRef.IsEnabled = btnPartialInfo.IsEnabled = btnStartMultiTracker.IsEnabled = btnStartTimer.IsEnabled = false; // let's identify the user of this software. This can be a single person, or a group of people (perhaps from a group subscription to an app) // 1. For a single user // The format is unique identifier, key, value btnSingle.Clicked += delegate { Insights.Identify("*****@*****.**", "Name", "Alan James User"); btnCrashApp.IsEnabled = btnDivByZero.IsEnabled = btnFileException.IsEnabled = btnNullRef.IsEnabled = btnPartialInfo.IsEnabled = btnStartMultiTracker.IsEnabled = btnStartTimer.IsEnabled = true; btnMultipleId.IsEnabled = false; }; // 2. For a group of users, a dictionary is used, this should be provided after the unique ID btnMultipleId.Clicked += delegate { var extraInformation = new Dictionary <string, string> { { "Email", "*****@*****.**" }, { "Name", "Alan James User" }, }; Insights.Identify("UniqueUserId", extraInformation); btnCrashApp.IsEnabled = btnDivByZero.IsEnabled = btnFileException.IsEnabled = btnNullRef.IsEnabled = btnPartialInfo.IsEnabled = btnStartMultiTracker.IsEnabled = btnStartTimer.IsEnabled = true; btnSingle.IsEnabled = false; }; // to make the Insights reporting tool report, an exception has to be thrown // the reports can be sent via one of three ways // the simplest is to just send back the exception btnDivByZero.Clicked += delegate { try { int divByZero = 42 / int.Parse("0"); } catch (DivideByZeroException ex) { Insights.Report(); } }; // the next is to send specific information. This can achieved using a Dictionary<string,string>() // and may be constructed as part of the report or outside of it // 1. as part of the exception btnFileException.Clicked += async delegate { try { var text = await rootFolder.GetFileAsync("some_file.tardis"); Debug.WriteLine("{0}", text.Path); } catch (FileNotFoundException ex) { Insights.Report(ex, new Dictionary <string, string> { { "File missing", "some_file.tardis" }, { "Source file", "MainActivity.cs" }, { "Method name", "protected override void OnCreate(Bundle bundle)" } }); } }; // 2. outside the exception. Essentially, this is the same as the 1st type, but there is additional flexibility // Here it calls CreateDictionary which takes a T exception and produces a new dictionary from it // This is a very trivial example - data from Reflection would probably be of more use btnNullRef.Clicked += delegate { try { List <string> myList = null; myList.Add("Hello"); } catch (NullReferenceException ex) { var report = CreateDictionary(ex); Insights.Report(ex, report); } }; // 3. Instead of sending over the full exception, just send a piece over btnPartialInfo.Clicked += async delegate { try { var block = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; var file = await rootFolder.CreateFileAsync(@"/bin/hello.txt", CreationCollisionOption.OpenIfExists); await file.WriteAllTextAsync(block.ToString()); } catch (IOException ex) { // see http://msdn.microsoft.com/en-us/library/system.exception.data%28v=vs.110%29.aspx for more details on this ex.Data["MoreData"] = "You can't write to the bin directory!"; // send the report Insights.Report(ex); // throw the exception - this exception would need to be caught using another try/catch throw ex; } }; // catching an uncaught exception btnCrashApp.Clicked += delegate { var block = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; block[11] = 10; }; // An important aspect of any form of trace software is the ability to track an event. In the following example. // a simple reaction time will be measured. btnStartTimer.Clicked += delegate { btnStartTimer.Text = "Stop the clock"; var timer = Stopwatch.StartNew(); // from System.Diagnostics btnStartTimer.Clicked += delegate { using (var react = Insights.TrackTime("reactionTime")) { btnStartTimer.Clicked += async delegate { timer.Stop(); var timeSpan = timer.Elapsed; await StoreReactionTime(DateTime.Now.Subtract(timeSpan).Second); }; } }; }; // it is also possible to track a specific thread. There are two ways to do this - with and without additional parameters btnStartMultiTracker.Clicked += delegate { Insights.Track("mySpecificProcess"); // In a similar way to using Debug.WriteLine, a dictionary can be used to track Insights.Track("setUpForEach", new Dictionary <string, string> { { "process1", "create list" }, { "process2", "populate list" } }); var myList = new List <string>(); myList.AddRange(new string[] { "iOS", "Android", "Symbian", "Windows Mobile", "Blackberry" }); // The next part is to do some work on the list. This will be a mix of TrackTimer and Track Insights.Track("doSomeWorkOnList", new Dictionary <string, string> { { "process3", "encrypt and time data" } }); var timer = Stopwatch.StartNew(); using (var handle = Insights.TrackTime("encrypter")) { EncryptData(myList); WorkCompleted.Change += async delegate(object s, WorkCompletedEventArgs ea) { if (ea.ModuleName == "Encryption") { timer.Stop(); var timeSpan = timer.Elapsed; await StoreReactionTime(DateTime.Now.Subtract(timeSpan).Second); } }; } // tell the tracker we're done Insights.Track("mySpecificProcess", new Dictionary <string, string> { { "process4", "processing completed" } }); }; return(content); }
private void RunInsights() { // let's identify the user of this software. This can be a single person, or a group of people (perhaps from a group subscription to an app) // 1. For a single user // The format is unique identifier, key, value btnSingle.TouchUpInside += delegate { Insights.Identify("*****@*****.**", "Name", "Alan James User"); btnCrashApp.Enabled = btnDivByZero.Enabled = btnFileException.Enabled = btnNullRef.Enabled = btnPartialInfo.Enabled = btnStartMultiTracker.Enabled = btnStartTimer.Enabled = true; btnMultipleId.Enabled = false; }; // 2. For a group of users, a dictionary is used, this should be provided after the unique ID btnMultipleId.TouchUpInside += delegate { var extraInformation = new Dictionary <string, string> { { "Email", "*****@*****.**" }, { "Name", "Alan James User" }, }; Insights.Identify("UniqueUserId", extraInformation); btnCrashApp.Enabled = btnDivByZero.Enabled = btnFileException.Enabled = btnNullRef.Enabled = btnPartialInfo.Enabled = btnStartMultiTracker.Enabled = btnStartTimer.Enabled = true; btnSingle.Enabled = false; }; // to make the Insights reporting tool report, an exception has to be thrown // the reports can be sent via one of three ways // the simplest is to just send back the exception btnDivByZero.TouchUpInside += delegate { try { int divByZero = 42 / int.Parse("0"); } catch (DivideByZeroException ex) { Insights.Report(); } }; // the next is to send specific information. This can achieved using a Dictionary<string,string>() // and may be constructed as part of the report or outside of it // 1. as part of the exception btnFileException.TouchUpInside += delegate { try { using (var text = File.OpenText("some_file.tardis")) { Console.WriteLine("{0}", text.ReadLine()); } } catch (FileNotFoundException ex) { Insights.Report(ex, new Dictionary <string, string> { { "File missing", "some_file.tardis" }, { "Source file", "MainActivity.cs" }, { "Method name", "protected override void OnCreate(Bundle bundle)" } }); } }; // 2. outside the exception. Essentially, this is the same as the 1st type, but there is additional flexibility // Here it calls CreateDictionary which takes a T exception and produces a new dictionary from it // This is a very trivial example - data from Reflection would probably be of more use btnNullRef.TouchUpInside += delegate { try { List <string> myList = null; myList.Add("Hello"); } catch (NullReferenceException ex) { var report = CreateDictionary(ex); Insights.Report(ex, report); } }; // 3. Instead of sending over the full exception, just send a piece over btnPartialInfo.TouchUpInside += delegate { try { var block = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; using (var text = File.OpenWrite(@"/bin/hello.txt")) { text.Write(block, 0, 10); } } catch (UnauthorizedAccessException ua) { ua.Data["MoreData"] = "You can't write to the bin directory!"; // send the report Insights.Report(ua); // throw the exception - this exception would need to be caught using another try/catch throw ua; } catch (IOException ex) { // see http://msdn.microsoft.com/en-us/library/system.exception.data%28v=vs.110%29.aspx for more details on this ex.Data["MoreData"] = "You can't write to the bin directory!"; // send the report Insights.Report(ex); // throw the exception - this exception would need to be caught using another try/catch throw ex; } }; // catching an uncaught exception btnCrashApp.TouchUpInside += delegate { var block = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; block[11] = 10; }; // An important aspect of any form of trace software is the ability to track an event. In the following example. // a simple reaction time will be measured. btnStartTimer.TouchUpInside += delegate { btnStartTimer.SetTitle("Stop the clock", UIControlState.Normal); var timer = Stopwatch.StartNew(); // from System.Diagnostics btnStartTimer.TouchUpInside += delegate { using (var react = Insights.TrackTime("reactionTime")) { btnStartTimer.TouchUpInside += async delegate { timer.Stop(); var timeSpan = timer.Elapsed; await StoreReactionTime(DateTime.Now.Subtract(timeSpan).Second); }; } }; }; // it is also possible to track a specific thread. There are two ways to do this - with and without additional parameters btnStartMultiTracker.TouchUpInside += delegate { Insights.Track("mySpecificProcess"); // In a similar way to using Debug.WriteLine, a dictionary can be used to track Insights.Track("setUpForEach", new Dictionary <string, string> { { "process1", "create list" }, { "process2", "populate list" } }); var myList = new List <string>(); myList.AddRange(new string[] { "iOS", "Android", "Symbian", "Windows Mobile", "Blackberry" }); // The next part is to do some work on the list. This will be a mix of TrackTimer and Track Insights.Track("doSomeWorkOnList", new Dictionary <string, string> { { "process3", "encrypt and time data" } }); var timer = Stopwatch.StartNew(); using (var handle = Insights.TrackTime("encrypter")) { EncryptData(myList); WorkCompleted.Change += async delegate(object s, WorkCompletedEventArgs ea) { if (ea.ModuleName == "Encryption") { timer.Stop(); var timeSpan = timer.Elapsed; await StoreReactionTime(DateTime.Now.Subtract(timeSpan).Second); } }; } // tell the tracker we're done Insights.Track("mySpecificProcess", new Dictionary <string, string> { { "process4", "processing completed" } }); }; }
public async override void NavigatedTo(Windows.UI.Xaml.Navigation.NavigationMode mode, object parameter) { base.NavigatedTo(mode, parameter); var reset = App.Locator.AppSettingsHelper.Read <bool>("FactoryReset"); var startingMsg = "Restoring (this may take a bit)..."; if (reset) { startingMsg = "Factory resetting..."; } using (Insights.TrackTime(reset ? "Factory Reset" : "Restore Collection")) { StatusBarHelper.ShowStatus(startingMsg); var file = reset ? null : await StorageHelper.GetFileAsync("_current_restore.autcp"); //delete artowkr and mp3s var artworkFolder = await StorageHelper.GetFolderAsync("artworks"); var artistFolder = await StorageHelper.GetFolderAsync("artists"); var songFolder = await StorageHelper.GetFolderAsync("songs"); if (artworkFolder != null) { await artworkFolder.DeleteAsync(); } if (artistFolder != null) { await artistFolder.DeleteAsync(); } if (songFolder != null) { await songFolder.DeleteAsync(); } if (!reset) { using (var stream = await file.OpenAsync(FileAccess.ReadAndWrite)) { await AutcpFormatHelper.UnpackBackup(ApplicationData.Current.LocalFolder, stream); } await file.DeleteAsync(); App.Locator.CollectionService.LibraryLoaded += async(sender, args) => { await CollectionHelper.DownloadArtistsArtworkAsync(false); await CollectionHelper.DownloadAlbumsArtworkAsync(false); }; App.Locator.AppSettingsHelper.Write("Restore", false); } else { var dbs = (await ApplicationData.Current.LocalFolder.GetFilesAsync()) .Where(p => p.FileType == ".sqldb").ToList(); foreach (var db in dbs) { await db.DeleteAsync(); } App.Locator.AppSettingsHelper.Write("FactoryReset", false); } StatusBarHelper.HideStatus(); } (Application.Current as App).BootAppServicesAsync(); App.Navigator.GoTo <HomePage, ZoomOutTransition>(null, false); }
protected override ITrackHandle InsightsTrackTime(string identifier, string key, string value) { return(Insights.TrackTime(identifier, key, value)); }
public ITrackHandle TrackTime(string identifier, IDictionary <string, string> table = null) { return(Insights.TrackTime(identifier, table)); }