Exemplo n.º 1
0
        private void ReportIntel(string lastline, string status = "")
        {
            Encoding myEncoding = System.Text.UTF8Encoding.UTF8;
            //WebClient client = new WebClient();
            RestClient client = new RestClient(Configuration.ReportServer);

            try
            {
                if (lastline.Contains("EVE System > Channel MOTD:"))
                {
                    return;
                }
                lastline = lastline.Replace('"', '\'');
                string postMessage = new ReportLine(lastline, status).ToJson();

                RestRequest request = new RestRequest("EveIntelServer/report", Method.PUT);
                request.AddParameter("application/json", postMessage, ParameterType.RequestBody);

                IRestResponse response = client.Execute(request);

                if (response.Content == "OK\n")
                {
                    reported++;
                }

                //byte[] KiuResponse = client.UploadData(Configuration.ReportServer, "PUT", myEncoding.GetBytes(postMessage));

                //if (myEncoding.GetString(KiuResponse) == "OK\n") reported++;
            }
            catch (Exception ex)
            {
                failed++;
                if (ex.Message == "The remote server returned an error: (401) Unauthorized." && !InvalidAuthToken)
                {
                    appendText("Authorization Token Invalid.  Try refreshing your auth token in settings.\r\n");
                    if (Configuration.MapURL != string.Empty)
                    {
                        ProcessStartInfo sInfo = new ProcessStartInfo(Configuration.MapURL + "/?nav=uploader");
                        Process.Start(sInfo);
                    }
                    MessageBox.Show("Authorization Token Invalid.  Try refreshing your auth token in settings.\r\n");
                    new frmSettings().ShowDialog();
                    InvalidAuthToken = true; // We really don't want to pop up windows and webpages more than once.
                }
                else if (ex.Message == "The remote server returned an error: (426) 426.")
                {
                    appendText("Client version not supported.  Please close and restart application to update. (May require two restarts.)\r\n");
                }
                else
                {
                    appendText(string.Format("Intel Server Error: {0}\r\n", ex.Message));
                }
                Debug.Write(string.Format("Exception: {0}", ex.Message));
            }
            lblReported.Invoke(new MethodInvoker(() => lblReported.Text = reported.ToString()));
            lblFailed.Invoke(new MethodInvoker(() => lblFailed.Text     = failed.ToString()));
        }
Exemplo n.º 2
0
        private void ReportIntel(string lastline, string status = "")
        {
            Encoding  myEncoding = System.Text.UTF8Encoding.UTF8;
            WebClient client     = new WebClient();

            try
            {
                if (lastline.Contains("EVE System > Channel MOTD:"))
                {
                    return;
                }
                lastline = lastline.Replace('"', '\'');
                string postMessage = new ReportLine(lastline, status).ToJson();

                byte[] KiuResponse = client.UploadData(Configuration.ReportServer, "PUT", myEncoding.GetBytes(postMessage));

                if (myEncoding.GetString(KiuResponse) == "OK\n")
                {
                    reported++;
                }
            }
            catch (Exception ex)
            {
                failed++;
                if (ex.Message == "The remote server returned an error: (401) Unauthorized.")
                {
                    appendText("Authorization Token Invalid.  Try refreshing your auth token in settings.\r\n");
                }
                else if (ex.Message == "The remote server returned an error: (426) 426.")
                {
                    appendText("Client version not supported.  Please close and restart application to update. (May require two restarts.)\r\n");
                }
                else
                {
                    appendText(string.Format("Intel Server Error: {0}\r\n", ex.Message));
                }
                Debug.Write(string.Format("Exception: {0}", ex.Message));
            }
            lblReported.Invoke(new MethodInvoker(() => lblReported.Text = reported.ToString()));
            lblFailed.Invoke(new MethodInvoker(() => lblFailed.Text     = failed.ToString()));
        }
Exemplo n.º 3
0
        private void ReportIntel(string lastline, string status = "")
        {
            Encoding myEncoding = System.Text.UTF8Encoding.UTF8;
            WebClient client = new WebClient();
            try
            {
                if (lastline.Contains("EVE System > Channel MOTD:")) return;
                lastline = lastline.Replace('"', '\'');
                string postMessage = new ReportLine(lastline, status).ToJson();

                byte[] KiuResponse = client.UploadData(Configuration.ReportServer, "PUT", myEncoding.GetBytes(postMessage));

                if (myEncoding.GetString(KiuResponse) == "OK\n") reported++;
            }
            catch (Exception ex)
            {
                failed++;
                if (ex.Message == "The remote server returned an error: (401) Unauthorized.")
                    appendText("Authorization Token Invalid.  Try refreshing your auth token in settings.\r\n");
                else if (ex.Message == "The remote server returned an error: (426) 426.")
                    appendText("Client version not supported.  Please close and restart application to update. (May require two restarts.)\r\n");
                else
                    appendText(string.Format("Intel Server Error: {0}\r\n", ex.Message));
                Debug.Write(string.Format("Exception: {0}", ex.Message));
            }
            lblReported.Invoke(new MethodInvoker(() => lblReported.Text = reported.ToString()));
            lblFailed.Invoke(new MethodInvoker(() => lblFailed.Text = failed.ToString()));
        }