public async Task AnalysisErrorMessage(IEnumerable <Error> errors)
        {
            foreach (var error in errors)
            {
                var unQueryBuilder = Builders <UnKnownError> .Filter.Eq(error => error.Message, error.Message);

                var unKnownErrors = await _dbService.UnKnownErrors.GetAsync(unQueryBuilder);

                var queryBuilder = Builders <KnownError> .Filter.Eq(error => error.Message, error.Message);

                var knownErrors = await _dbService.KnownErrors.GetAsync(queryBuilder);

                if (!unKnownErrors.Any() && !knownErrors.Any())
                {
                    var unError = new UnKnownError()
                    {
                        MessageId    = error.MessageId,
                        Message      = error.Message,
                        Error        = error.ResponsError,
                        CountFounded = error.CountFounded
                    };
                    await _dbService.UnKnownErrors.Create(unError);
                }
                else if (unKnownErrors.Any())
                {
                    foreach (var unKnownError in unKnownErrors)
                    {
                        unKnownError.CountFounded += error.CountFounded;
                        if (unKnownError.Id != ObjectId.Empty)
                        {
                            unKnownError.IsModified = true;
                        }
                        await _dbService.UnKnownErrors.Update(unKnownError);
                    }
                }
                else if (knownErrors.Any())
                {
                    foreach (var knownError in knownErrors)
                    {
                        knownError.CountFounded += error.CountFounded;
                        var existOffer = _processOffer.getExistOffer(knownError.Id);
                        if (existOffer == null)
                        {
                            _processOffer.AddKnowErrorToOffer(knownError);
                        }
                        await _dbService.KnownErrors.Update(knownError);
                    }
                }
            }
        }
Esempio n. 2
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex];

                var id      = row.Cells["Id"].Value.ToString();
                var message = row.Cells["ErrorText"].Value.ToString();
                var error   = row.Cells["Error"].Value.ToString();
                textBox2.Text        = message;
                SelectedUnknownError = new UnKnownError()
                {
                    Id = new ObjectId(id), ErrorText = message, Error = BsonDocument.Parse(error)
                };
            }
        }
Esempio n. 3
0
        /// <summary>
        /// создаем не извесные ошибки
        /// </summary>
        private static void CreateUnKnownError(Error error)
        {
            var index = error.Message.IndexOf(".'");
            var sms   = index >= 0 ? error.Message.Substring(0, index) : error.Message;

            IEnumerable <string> arrError = sms.Trim().Split(' ');

            UnKnownError findUnKnownError = null;
            KnownError   findKnownError   = null;

            string message = "";

            foreach (var err in arrError)
            {
                int res;
                var dd = Int32.TryParse(err, out res);
                if (err.IndexOf("'") < 0 && res == 0)
                {
                    message += err + " ";
                }
            }

            findUnKnownError = unKnownErrorsList.Find(o => o.ErrorText == message.TrimEnd());
            findKnownError   = knownErrorsList.Find(o => o.Message == message.TrimEnd());

            if (findUnKnownError == null && findKnownError == null)
            {
                var unError = new UnKnownError()
                {
                    ErrorText    = message.TrimEnd(),
                    Error        = error.ResponsError,
                    CountFounded = 1
                };

                unKnownErrorsList.Add(unError);
            }
            else if (findUnKnownError != null)
            {
                findUnKnownError.CountFounded++;
                if (findUnKnownError.Id != ObjectId.Empty)
                {
                    findUnKnownError.IsModified = true;
                }
            }
        }
        /// <summary>
        /// создаем не извесные ошибки
        /// </summary>
        private static void CreateUnKnownError(Error error)
        {
            var index = error.Message.IndexOf(".'");
            var sms   = index >= 0 ? error.Message.Substring(0, index) : error.Message;

            IEnumerable <string> arrError = sms.Trim().Split(' ');

            UnKnownError findUnKnownError = null;
            KnownError   findKnownError   = null;

            string message = "";

            foreach (var err in arrError)
            {
                int res;
                var dd = Int32.TryParse(err, out res);
                if (err.IndexOf("'") < 0 && res == 0)
                {
                    message += err + " ";
                }
            }

            findUnKnownError = unKnownErrorsList.Find(o => o.ErrorText == message.TrimEnd());
            findKnownError   = knownErrorsList.Find(o => o.Message == message.TrimEnd());

            if (findUnKnownError == null && findKnownError == null)
            {
                var unError = new UnKnownError()
                {
                    ErrorText    = message.TrimEnd(),
                    Error        = error.ResponsError,
                    CountFounded = 1
                };

                unKnownErrorsList.Add(unError);
            }
            else if (findUnKnownError != null)
            {
                findUnKnownError.CountFounded++;
                if (findUnKnownError.Id != ObjectId.Empty)
                {
                    findUnKnownError.IsModified = true;
                }
            }
            else if (findKnownError != null)
            {
                var existOffer = offerAnswers.Find(o => o.Message == findKnownError.Message);
                if (existOffer == null)
                {
                    var st = BsonSerializer.Deserialize <StatusError>(findKnownError.Status.ToJson());
                    var an = BsonSerializer.Deserialize <Answer>(findKnownError.Answer.ToJson());

                    var knowView = new KnownErrorView()
                    {
                        Message     = findKnownError.Message,
                        Count       = 1,
                        StatusCode  = st.StatusCode,
                        StatusTitle = st.StatusTitle,
                        Answer      = an.Text
                    };

                    offerAnswers.Add(knowView);
                }
                else
                {
                    existOffer.Count++;
                }
            }
        }