public SupportPage(string title, byte[] imageArray) { XyrohLib.LogEvent("Page : Support : With Screenshot"); this.pageTitle = title; this.capturedImageBytes = imageArray; try { // save to disk this.captureImagePath = "Screen" + new DateTimeOffset(DateTime.Now).ToUnixTimeMilliseconds().ToString() + "_" + Guid.NewGuid().ToString().ToString() + ".jpg"; this.captureImagePath = Path.Combine(App.ImagesStore, this.captureImagePath); XyrohLib.Log("** fileName: " + this.captureImagePath); File.WriteAllBytes(this.captureImagePath, imageArray); } catch (Exception ex) { XyrohLib.LogCrash("Screen Capture", ex); } this.capturedImageBytes = null; this.Init(); }
private async Task ExecuteRefreshCommand() { XyrohLib.LogEvent("Refresh History", "DB"); if (IsBusy) { XyrohLib.Log("VM BUSY - RETURNING"); return; } IsBusy = true; try { var record = await this.GetHistory(); } catch (Exception ex) { XyrohLib.LogCrash("DB", ex); } finally { IsBusy = false; } }
protected ShareViewController(IntPtr handle) : base(handle) { // Note: this .ctor should not contain any initialization logic. XyrohLib.setFileLog(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "sharedebug.txt"), 500000); // 0.5MB XyrohLib.setCrashreporter(BaseConfig.SentryKey); XyrohLib.setAnalytics(BaseConfig.AppCenteriOSKey, BaseConfig.AppCenterAndroidKey); XyrohLib.Log("**HERE**"); XyrohLib.LogEvent("Extension : Share "); }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { XyrohLib.Log("Configuring DB: "); var dbFolder = DependencyService.Get <IDBPath>().GetDBPath(); XyrohLib.Log("Using Folder: " + dbFolder); var dbPath = Path.Combine(dbFolder, BaseConfig.dbName); XyrohLib.Log("Using DB: " + dbPath); optionsBuilder .UseSqlite($"Filename={dbPath}"); }
private async void OnSendTicketButtonClicked(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(this.TicketEmail.Text) || string.IsNullOrEmpty(this.TicketSubject.Text) || string.IsNullOrEmpty(this.TicketDescription.Text)) { await this.DisplayAlert("Oops", "Please ensure all fields are completed", "OK"); } else { XyrohLib.LogEvent("Support Page : Send Ticket"); this.SendButton.IsEnabled = false; // get log and db var attachments = new List <string>(); attachments.Add(XyrohLib.GetLogPath()); // screencap? if (File.Exists(this.captureImagePath)) { XyrohLib.Log("Attaching: " + this.captureImagePath); attachments.Add(this.captureImagePath); } var ticketId = await XyrohLib.CreateTicketWithAttachment(this.TicketEmail.Text, this.TicketSubject.Text, this.TicketDescription.Text, new string[] { "urlshortener", "worst", "mobile", "xyrohlib" }, attachments); if (ticketId > 0) { await this.DisplayAlert("Ticket Created", "Ticket Ref: " + ticketId.ToString() + " Successfully Created", "OK"); await this.Navigation.PopAsync(); } else { throw new Exception("Couldn't create Ticket - Please try again"); } } } catch (Exception ex) { XyrohLib.LogCrash(ex); await this.DisplayAlert("Error", "Error: " + ex.Message, "OK"); this.SendButton.IsEnabled = true; } }
public BaseViewModel() { var connectivity = Connectivity.NetworkAccess; if (connectivity == NetworkAccess.Internet) { // Connection to internet is available this.IsOnline = true; } else { this.IsOnline = false; } XyrohLib.Log("ONLINE: " + this.IsOnline); Connectivity.ConnectivityChanged += this.ConnectivityChanged; }
// public static SQLiteContext DB { get; set; } public App(string sharedURL) { this.InitializeComponent(); // XyrohLib Crash handler Setup XyrohLib.setFileLog(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "debug.txt"), 500000); // 0.5MB XyrohLib.setCrashreporter(BaseConfig.SentryKey); #if DEBUG // XyrohLib.setAnalytics(SettingsViewModel.AppCenteriOSKey, SettingsViewModel.AppCenterAndroidKey); #else XyrohLib.setAnalytics(BaseConfig.AppCenteriOSKey, BaseConfig.AppCenterAndroidKey); #endif // Freshdesk XyrohLib.SetHelpDesk(BaseConfig.FreshDeskURL, BaseConfig.FreshDeskKey, "c29tZSByYW5kb20gdW5uZWNlc3Nhcnkga2V5"); VersionTracking.Track(); // filesystem prep try { App.ImagesStore = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "screenshots"); Directory.CreateDirectory(App.ImagesStore); } catch (Exception ex) { XyrohLib.LogCrash(ex); } // db Prep - Singleton doesn't work in share extension as no 'App' // App.DB = new SQLiteContext(); if (!string.IsNullOrEmpty(sharedURL)) { XyrohLib.Log(sharedURL); App.SharedURL = sharedURL; } // this.MainPage = new MainPage(); this.MainPage = new NavigationPage(new MainPage()); }
private async void OnShortenCommandExecuted(object state) { XyrohLib.Log("SERVICE: " + this.ShortenService); XyrohLib.Log("URL: " + this.LongURL); var shortenedURl = string.Empty; this.ShortURL = shortenedURl; this.HasResults = false; switch (this.shortenService) { default: case "TinyUrl": { var client = new HttpClient(); var url = "http://tinyurl.com/api-create.php?url=" + this.LongURL; XyrohLib.Log("REQUEST: " + url); client.Timeout = TimeSpan.FromSeconds(5); try { var response = await client.GetAsync(url); var responseBody = await response.Content.ReadAsStringAsync(); XyrohLib.Log("RESP: " + responseBody); XyrohLib.Log("Status Code: " + response.StatusCode.ToString()); if (response.IsSuccessStatusCode) { shortenedURl = responseBody.ToString(); XyrohLib.Log("Short: " + shortenedURl); } else { this.LastError = "Something went wrong, error: " + response.StatusCode.ToString(); } } catch (Exception postEx) { XyrohLib.LogCrash(postEx); this.LastError = "We couldn't shorten that URL, please check and try again"; } break; } case "Firebase": { var client = new HttpClient(); var url = "https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=" + BaseConfig.FirebaseAPIKey.ToString(); client.Timeout = TimeSpan.FromSeconds(5); try { var json = new FirebaseLinkRequest(); json.longDynamicLink = BaseConfig.FirebaseURLDomain + "/?link=" + this.LongURL + "&apn=" + AppInfo.PackageName + "&ibi=" + AppInfo.PackageName; XyrohLib.Log("JSON: " + JsonConvert.SerializeObject(json)); var requestBody = new StringContent(JsonConvert.SerializeObject(json).ToString(), Encoding.UTF8, "application/json"); var response = await client.PostAsync(url, requestBody); var responseString = await response.Content.ReadAsStringAsync(); XyrohLib.Log("RESP: " + responseString); XyrohLib.Log("Status Code: " + response.StatusCode.ToString()); if (response.IsSuccessStatusCode) { var responseBody = JsonConvert.DeserializeObject <FirebaseLinkResponse>(responseString); shortenedURl = responseBody.shortLink.ToString(); XyrohLib.Log("Short: " + shortenedURl); } else { this.LastError = "Something went wrong, error: " + response.StatusCode.ToString(); } } catch (Exception postEx) { XyrohLib.LogCrash(postEx); this.LastError = "We couldn't shorten that URL, please check and try again"; } break; } } this.ShortURL = shortenedURl; if (!string.IsNullOrEmpty(this.ShortURL)) { // save to history var history = new ShortenedUrl(); history.ShortenService = this.shortenService; history.FullUrl = this.LongURL; history.ShortUrl = this.ShortURL; try { // Can't use App singleton as App doesn't exist for the extension this.db.Add(history); await this.db.SaveChangesAsync(); XyrohLib.Log("Saved History: " + shortenedURl); } catch (Exception ex) { XyrohLib.LogCrash("DB", ex); } await Clipboard.SetTextAsync(shortenedURl); this.HasResults = true; XyrohLib.Log("Final: " + this.ShortURL); await this.refresh(); } }