public Task <HttpResponseMessage> Index([FromBody] NewReport newReport)
        {
            IEnumerable <string> headerValues;

            try
            {
                headerValues = Request.Headers.GetValues("AuthKey");
            }
            catch (Exception)
            {
                return(Task.FromResult(Request.CreateResponse(HttpStatusCode.Unauthorized)));
            }

            var authKey = headerValues.FirstOrDefault();

            try
            {
                this.reportService.Create(authKey, newReport.WordId);
            }
            catch (Exception)
            {
                return(Task.FromResult(Request.CreateResponse(HttpStatusCode.Unauthorized)));
            }

            return(Task.FromResult(Request.CreateResponse(HttpStatusCode.Created)));
        }
Exemple #2
0
        private void HandleClient(HttpListenerContext client)
        {
            try
            {
                byte[] data;

                if (client.Request.RawUrl != "/api/dump-report" || client.Request.HttpMethod != "POST")
                {
                    var msg = "The requested resource could not be found.";
                    client.SendResponseAndClose(msg, 404);
                    return;
                }
                else
                {
                    var sc = 200;

                    var reqBytes = new byte[client.Request.ContentLength64];

                    using (var ms = new MemoryStream())
                    {
                        client.Request.InputStream.CopyTo(ms);
                        reqBytes = ms.ToArray();
                    }
                    var isZipped = client.Request.Headers["Content-Encoding"]?.Contains("gzip") ?? false;
                    var strData  = RequestHandler.HandleReportRequest(reqBytes, isZipped, out sc);

                    client.Response.StatusCode = sc;
                    data = Encoding.UTF8.GetBytes(strData);

                    if (sc == 200)
                    {
                        NewReport?.Invoke(strData);
                    }
                }

                WriteData(ref client, data);
            }
            // Ignore not being able to send the response if the client left.
            catch (HttpListenerException ex)
                // Mono throws error code ???, .NET throws error code 64.
                when(/*(onMono && ex.NativeErrorCode == 0) || */ (!onMono && (ex.NativeErrorCode == 64 || ex.NativeErrorCode == 1229)))
                {
                }
            catch (Exception ex)
            {
                OnException?.Invoke(ex);
                try
                {
                    var msg = "An error occurred while processing your request.";
                    client.SendResponseAndClose(msg, 500);
                }
                catch
                {
                    client.Response.Abort();
                }
            }
        }
Exemple #3
0
        protected override void OnFirstLoad()
        {
            ShowMdiForm(new UCQuestionnaire(TmoComm.login_userInfo));

            ShowMdiForm <UCDeviceDataSync>();

            tmodatashow datashow = new tmodatashow();

            datashow.Userid = TmoComm.login_userInfo.user_id;
            ShowMdiForm(datashow);

            NewReportList nrl = new NewReportList();

            nrl.Userid = TmoComm.login_userInfo.user_id;
            ShowMdiForm(nrl);

            NewReport nr = new NewReport();

            nr.Userid = TmoComm.login_userInfo.user_id;
            ShowMdiForm(nr);

            NewReporttenance nrt = new NewReporttenance();

            nrt.Userid = TmoComm.login_userInfo.user_id;
            ShowMdiForm(nrt);

            ExtendServerNew esn = new ExtendServerNew();

            esn.Userid = TmoComm.login_userInfo.user_id;
            ShowMdiForm(esn);

            UCIntervene inter = new UCIntervene();

            inter.Userid = TmoComm.login_userInfo.user_id;
            ShowMdiForm(inter);

            TmoNewEvaluation ne = new TmoNewEvaluation();

            ne.Userid = TmoComm.login_userInfo.user_id;
            ShowMdiForm(ne);

            ucPointsCenter pc = new ucPointsCenter();

            pc.Userid = TmoComm.login_userInfo.user_id;
            ShowMdiForm(pc);

            mdiForms[typeof(UCQuestionnaire)].Activate();

            CenterToScreen();

            base.OnFirstLoad();
        }
Exemple #4
0
            public void Push(MustAssertionReport report)
            {
                var _observers     = _Observers.ToArray();
                var _observerTasks = new Task[_observers.Length];

                for (var _i = 0; _i < _observers.Length; _i++)
                {
                    var _observer = _observers[_i].Value;
                    _observerTasks[_i] = Task.Run(() => _observer.OnNext(report));
                }

                Task.WaitAll(_observerTasks);

                NewReport?.Invoke(report);
            }
Exemple #5
0
        /// <summary>
        /// The ButtonGenerate_Click method.
        /// </summary>
        /// <param name="sender">The <paramref name="sender"/> parameter.</param>
        /// <param name="args">The <paramref name="args"/> parameter.</param>
        private void ButtonGenerate_Click(object sender, EventArgs args)
        {
            if (lvTemplates.SelectedItems.Count == 0 || !(lvTemplates.SelectedItems[0].Tag is ReportTemplate selectedTemplate))
            {
                return;
            }

            var newReport = new NewReport
            {
                TemplateId = selectedTemplate.Id,
                Name       = string.IsNullOrEmpty(tbxReportName.Text) ? selectedTemplate.Name : tbxReportName.Text
            };

            MainForm.CurrentSystem.AddReport(newReport);
            PopulateReports();
        }
Exemple #6
0
        public async Task ReportMessage(NewReport newReport) // ur reported dude
        {
            if (Context.Items.ContainsKey("account"))
            {
                Account account    = (Account)Context.Items["account"];
                Account newAccount = _unitOfWork.Account.GetById(account.Id.ToString());

                Report report = new Report()
                {
                    Account       = newAccount,
                    Id            = Guid.NewGuid(),
                    Message       = _unitOfWork.Message.GetById(newReport.MessageId),
                    ReportMessage = newReport.ReportMessage
                };
                report.Message.Type = MessageType.PossibleSpam;
                _unitOfWork.Report.Add(report);
                _unitOfWork.SaveChanges();
                await Clients.Caller.ConfirmReport(true);
            }

            await Clients.Caller.ConfirmReport(false);
        }
Exemple #7
0
 public void FireNewReport(string rptdVarQualityLog, string rptdVarTimestampLog, string rptdVarPathLog, string rptdVarDescriptionLog, string rptdVarValueLog)
 {
     NewReport?.Invoke(rptdVarQualityLog, rptdVarTimestampLog, rptdVarPathLog, rptdVarDescriptionLog, rptdVarValueLog);
 }
 public void Insert(NewReport item)
 {
     BulkInsert(new List <NewReport>(new NewReport[] { item }));
 }
        private List <NewReport> parseNewReport(OldReport info)
        {
            List <NewReport> results = new List <NewReport>();

            //get all old report urls
            JArray reports = JArray.Parse(info.OldReportInfo);

            foreach (var report in reports)
            {
                string noticeMessage = report.SelectToken("noticeMessage").ToString();
                string reportUrl     = report.SelectToken("reportUrl").ToString();
                string time          = report.SelectToken("time").ToString();

                //call and get old report content
                WebHeaderCollection header = new WebHeaderCollection();
                header.Add("Authorization", "Basic 5d076e5c3d34cb8bb08e54a4bb7e223e");
                string body = HttpHelper.WebRequestToServer(reportUrl, "", null, 60000, "GET", "utf-8", "json", header, null, false, false);
                Console.Write(body);

                if (string.IsNullOrWhiteSpace(body))
                {
                    continue;
                }

                NewReport newReport = new NewReport()
                {
                    VendorId = info.VendorId
                };

                List <string> result1 = RegexUtil.getMatchedStrings(body, RegexUtil.GetReportTimePattern);
                DateTime      tempDateTime; decimal tempDecimal;
                newReport.CreateTime = result1.Count > 1 && DateTime.TryParse(result1[1], out tempDateTime) ? tempDateTime : DateTime.MinValue;

                List <InterfaceInfoNode> interfaceList = new List <InterfaceInfoNode>();
                List <string>            result2       = RegexUtil.getMatchedStrings(body, RegexUtil.GetInterfaceProcessInfoPattern);
                for (int i = 0; i < result2.Count; i += 3)
                {
                    InterfaceInfoNode interfaceInfoNode = new InterfaceInfoNode();
                    interfaceInfoNode.caseTypeName = (result2.Count > i + 1) ? result2[i + 1] : "";
                    interfaceInfoNode.progress     = (result2.Count > i + 2) && decimal.TryParse(result2[i + 2], out tempDecimal) ? tempDecimal : 0m;
                    interfaceInfoNode.caseType     = getCaseType(interfaceInfoNode.caseTypeName);

                    interfaceList.Add(interfaceInfoNode);
                }
                newReport.InterfaceProcessInfo = JsonConvert.SerializeObject(interfaceList);

                List <CaseInfoNode> caseList = new List <CaseInfoNode>();
                List <string>       result3  = RegexUtil.getMatchedStrings(body, RegexUtil.GetCaseInfoPattern);
                for (int i = 0; i < result3.Count; i += 5)
                {
                    CaseInfoNode caseInfo = new CaseInfoNode();
                    caseInfo.caseId        = (result3.Count > i + 1) ? result3[i + 1] : "";
                    caseInfo.caseName      = (result3.Count > i + 2) ? result3[i + 2] : "";
                    caseInfo.caseTypeName  = (result3.Count > i + 3) ? result3[i + 3] : "";
                    caseInfo.caseStateDesc = (result3.Count > i + 4) ? result3[i + 4] : "";

                    caseList.Add(caseInfo);
                }
                newReport.CaseInfo = JsonConvert.SerializeObject(caseList);

                results.Add(newReport);
            }

            return(results);
        }
Exemple #10
0
        private void CreateReport(object sender, RoutedEventArgs e)
        {
            NewReport NR = new NewReport(EuroCurTBox.Text, DollarCurTBox.Text);

            NR.ShowDialog();
        }