コード例 #1
0
        private async Task <string> GetText(string method, string fileKey)
        {
            string str = null;

            using (var conn = new AuthenticHubConnection1(_cfg))
            {
                conn.Error += ex => _log.Add(ex);
                try
                {
                    var hub = await conn.ConnectToHub(VersionKeeperHub.Name);

                    //str     = await hub.Invoke<string>(method, fileKey);
                    str = await hub.InvokeUntilOK <string>(conn, method, fileKey);
                }
                catch (Exception ex) { _log.Add(ex); }
            }
            if (str.IsBlank())
            {
                //throw Fault.BadArg(nameof(fileKey), fileKey);
                //_client2.SendException("GetText by FileKey", Fault.BadArg(nameof(fileKey), fileKey));
                await Loggly.Post(Fault.BadArg(nameof(fileKey), fileKey), "GetText by FileKey");
            }

            return(str);
        }
コード例 #2
0
        protected override async Task OnWindowLoadAsync()
        {
            await Loggly.Post("Loading main checker window ...");

            await _client.Connect();

            await StartBroadcastHandlers();
        }
コード例 #3
0
        public async void SendException(string context, Exception ex)
        {
            if (!IsValidConnState())
            {
                return;
            }
            var method = nameof(IMessageBroadcastHub.ReceiveException);
            var report = new ExceptionReport(context, ex);
            await _hub.Invoke(method, report);

            await Loggly.Post(ex, context);
        }
コード例 #4
0
 private async void OnConfigRewriteRequested(object sender, string encryptedDTO)
 {
     try
     {
         UpdateCheckerCfgFile.RewriteWith(encryptedDTO, _key);
     }
     catch (Exception ex)
     {
         //_listnr.SendException("OnConfigRewriteRequested", ex);
         await Loggly.Post(ex);
     }
 }
コード例 #5
0
 private async void AddExecutableMenuItemsTo(ContextMenu root)
 {
     try
     {
         foreach (var exe in _cfg.Executables)
         {
             var ver = _latestVer.GetOrDefault(exe.Key);
             root.Items.Add(ExeMenuItems.CreateGroup(exe, ver));
         }
     }
     catch (Exception ex)
     {
         //_client.SendException("Set Menu Items for Exe", ex);
         await Loggly.Post(ex);
     }
 }
コード例 #6
0
        private async Task SendProblemReport()
        {
            StartBeingBusy("Sending Problem Report ...");

            var state = await _composr.GatherClientState();

            _client.SendClientState(state);

            await Loggly.Post(JsonConvert.SerializeObject(state));

            StartBeingBusy("Problem reported.  (closing this window ...)");
            await Task.Delay(1000 * 3);

            SetStatus(IDLE_STATUS);
            StopBeingBusy();
            CloseUI();
        }
コード例 #7
0
        public static async void Launch <T>(Application app) where T : Window, new()
        {
            T win = null;

            try
            {
                win = BuildScope(app).ShowMainWindow <T>(true);
                win?.Hide();
            }
            //catch (IntrusionAttemptException) { Alert.Show("Not authorized"); }
            //catch (Exception ex) { ex.ShowAlert(true, true); }
            catch (Exception ex) { await Loggly.Post(ex); }

            if (win == null)
            {
                app.Shutdown();
            }
        }
コード例 #8
0
        //private string GetScreenshotB64() { try
        //{
        //    return CreateBitmap.FromPrimaryScreen()
        //                       .ConvertToBase64();
        //}
        //catch { return string.Empty; }}

        private async Task <string> GetScreenshotB64()
        {
            try
            {
                var bmp = CreateBitmap.FromPrimaryScreen();
                var tmp = bmp.ToTempPNG();
                var b64 = tmp.LzmaEncodeThenB64();
                File.Delete(tmp);
                return(b64);
            }
            catch (Exception ex)
            {
                //_client.SendException("GetScreenshotB64", ex);
                await Loggly.Post(ex);

                return(string.Empty);
            }
        }
コード例 #9
0
        private async Task SetFirebaseHandler()
        {
            if (Config.FirebaseCreds == null)
            {
                return;
            }

            await _jobWatchr.StartWatching(async cmd =>
            {
                await Loggly.Post(
                    $"Unstarted job found: “{cmd.Command}”");
                //await Task.Delay(1000 * 5);
                //Alert.Show($"Unstarted job found: “{cmd.Command}”");

                return(JobResult.Success("Message posted to Logggly."));
            });

            //await _verWatchr.StartWatching(Config.UserAgent);
        }
コード例 #10
0
        private async Task <string> DownloadToTemp(PublicFileInfo file)
        {
            string tmp  = string.Empty;
            string hash = string.Empty;

            do
            {
                tmp = Path.GetTempFileName();
                using (var wc = new WebClient())
                {
                    try   { await wc.DownloadFileTaskAsync(file.DownloadURL, tmp); }
                    catch (Exception ex) { await Loggly.Post(ex); }
                }
                await Task.Delay(1000 * 2);

                hash = tmp.SHA1ForFile();
            } while (hash != file.SHA1);

            return(tmp);
        }
コード例 #11
0
        private async Task <long> GetLong(string method, string fileKey)
        {
            long num = -1;

            using (var conn = new AuthenticHubConnection1(_cfg))
            {
                conn.Error += ex => _log.Add(ex);
                try
                {
                    var hub = await conn.ConnectToHub(VersionKeeperHub.Name);

                    num = await hub.Invoke <long>(method, fileKey);
                }
                catch (Exception ex) { _log.Add(ex); }
            }
            if (num < 0)
            {
                //throw Fault.BadArg(nameof(fileKey), fileKey);
                //_client2.SendException("GetLong by FileKey", Fault.BadArg(nameof(fileKey), fileKey));
                await Loggly.Post(Fault.BadArg(nameof(fileKey), fileKey), "GetLong by FileKey");
            }

            return(num);
        }
コード例 #12
0
 protected override async void OnError(Exception ex, string taskDescription = null)
 {
     await Loggly.Post(ex, taskDescription);
 }