Пример #1
0
        private SpRecordFileInformation ParseLastRow(string str)
        {
            SpRecordFileInformation fileInformation = new SpRecordFileInformation();

            try {
                int    colonSymbol      = str.IndexOf(":");
                int    dotSymbol        = str.IndexOf('.');
                string totalRecordsText = str.Substring(
                    colonSymbol + 2, dotSymbol - colonSymbol - 2);

                int totalRecords = 0;
                if (!int.TryParse(totalRecordsText, out totalRecords))
                {
                    UpdateTextBox("Не удалось считать общее количество записей", error: false);
                }

                fileInformation.CallsTotal = totalRecords;

                int    secondColonSymbol = str.IndexOf("ть:");
                string totalTimeText     = str.Substring(secondColonSymbol + 4,
                                                         str.Length - secondColonSymbol - 4);

                fileInformation.TimeTotal = ParseTimeSpan(totalTimeText);
            } catch (Exception e) {
                UpdateTextBox("Не удалось выполнить разбор последней строки" +
                              Environment.NewLine + "Ошибка: " + e.Message + " " + e.StackTrace, error: true);
            }

            return(fileInformation);
        }
Пример #2
0
 private void ParseLineAccountingPeriod(string str, ref SpRecordFileInformation fileInformation)
 {
     try {
         int    mark             = str.IndexOf("записи");
         string accountingPeriod = str.Substring(mark + 7, str.Length - mark - 7);
         fileInformation.AccountingPeriod = accountingPeriod;
         UpdateTextBox("Период отчета: " + accountingPeriod);
     } catch (Exception e) {
         UpdateTextBox("Не удалось выполнить разбор строки с периодом отчета" +
                       Environment.NewLine + "Ошибка: " + e.Message + " " + e.StackTrace, error: true);
     }
 }
Пример #3
0
 private void ParseLineWorkstation(string str, ref SpRecordFileInformation fileInformation)
 {
     try {
         int    colonSymbol     = str.IndexOf(":");
         string workstationName = str.Substring(colonSymbol + 2, str.Length - colonSymbol - 3);
         fileInformation.WorkstationName = workstationName;
         UpdateTextBox("Рабочая станция: " + workstationName);
     } catch (Exception e) {
         UpdateTextBox("Не удалось выполнить разбор строки с рабочей станцией" +
                       Environment.NewLine + "Ошибка: " + e.Message + " " + e.StackTrace, error: true);
     }
 }
Пример #4
0
 private void ParseLineCreationDate(string str, ref SpRecordFileInformation fileInformation)
 {
     try {
         int    colonSymbol  = str.IndexOf(":");
         string creationDate = str.Substring(colonSymbol + 2, str.Length - colonSymbol - 3);
         fileInformation.CreationDate = creationDate;
         UpdateTextBox("Дата создания списка: " + creationDate);
     } catch (Exception e) {
         UpdateTextBox("Не удалось выполнить разбор строки с датой создания" +
                       Environment.NewLine + "Ошибка: " + e.Message + " " + e.StackTrace, error: true);
     }
 }
Пример #5
0
        private void AnalyseFileContentAndAddToDictionary(string fileName, List <List <string> > fileContent)
        {
            if (filesInfo.ContainsKey(fileName))
            {
                UpdateTextBox("Файл уже проанализирован ранее");
                return;
            }

            if (fileContent.Count < 7)
            {
                UpdateTextBox("Файл не соответствует формату SpRecord" +
                              "(должно быть минимум 7 строк, в файле: " +
                              fileContent.Count, error: true);
                return;
            }

            List <string> lastRow = fileContent.Last();

            if (lastRow.Count < 1)
            {
                UpdateTextBox("Не соответсвует формат последней строки, " +
                              "должен быть хотя бы 1 столбец", error: true);
            }

            string lastRowText = lastRow[0];

            if (!lastRowText.StartsWith("Всего записей:"))
            {
                UpdateTextBox("В последней строке отсутствует информация об общем " +
                              "количестве записей");
                return;
            }

            SpRecordFileInformation fileInformation = ParseLastRow(lastRowText);

            for (int row = 0; row < 5; row++)
            {
                if (row >= fileContent.Count)
                {
                    break;
                }

                List <string> line = fileContent[row];

                if (line.Count == 1)
                {
                    string text = line[0];

                    if (text.StartsWith("Выбраны записи"))
                    {
                        ParseLineAccountingPeriod(text, ref fileInformation);
                    }

                    if (text.StartsWith("Рабочая станция"))
                    {
                        ParseLineWorkstation(text, ref fileInformation);
                    }

                    if (text.StartsWith("Отчет создан"))
                    {
                        ParseLineCreationDate(text, ref fileInformation);
                    }
                }
            }

            for (int row = fileContent.Count - 2; row >= 0; row--)
            {
                List <string> line = fileContent[row];

                if (line.Count < 8 && line.Count != 1)
                {
                    UpdateTextBox("Размер строки " + (row + 1) + " не совпадает с форматом SpRecord");
                    continue;
                }

                if (line.Count >= 8)
                {
                    if (line[0].Equals("Название канала"))
                    {
                        continue;
                    }

                    try {
                        DateTime dateTime = DateTime.Parse(line[1]);
                        dateTime = dateTime.AddMilliseconds(dateTime.TimeOfDay.TotalMilliseconds * -1);

                        if (!fileInformation.DaysInfo.ContainsKey(dateTime))
                        {
                            fileInformation.DaysInfo.Add(dateTime, new SpRecordFileInformation.DayInfo());
                        }

                        SpRecordFileInformation.DayInfo dayInfo = fileInformation.DaysInfo[dateTime];

                        TimeSpan duration     = ParseTimeSpan(line[2]);
                        double   totalSeconds = duration.TotalSeconds;
                        string   callType     = line[3];
                        string   phoneNumbers = line[4];

                        if (fileInformation.WorkstationName.ToLower().Contains("splp"))
                        {
                            ParseLineForSplp(phoneNumbers, totalSeconds, ref dayInfo);
                        }
                        else if (fileInformation.WorkstationName.ToLower().Contains("kdtt"))
                        {
                            ParseLineForKdtt(callType, totalSeconds, ref dayInfo);
                        }
                    } catch (Exception e) {
                        Console.WriteLine(e.Message + Environment.NewLine + e.StackTrace);
                    }

                    //TimeSpan duration = ParseTimeSpan(line[2]);
                    //string type = line[3];

                    //if (type.Contains("Принятый")) {
                    //	fileInformation.CallsAccepted++;
                    //	fileInformation.TimeAccepted = fileInformation.TimeAccepted.Add(duration);
                    //} else if (type.Contains("Набранный")) {
                    //	fileInformation.CallsDialed++;
                    //	fileInformation.TimeDialed = fileInformation.TimeDialed.Add(duration);
                    //} else if (type.Contains("Непринятый")) {
                    //	if (line.Count > 9) {
                    //		fileInformation.CallsMissedAccidentialWrongValues++;
                    //		fileInformation.TimeAccidential = fileInformation.TimeAccidential.Add(duration);
                    //		continue;
                    //	}

                    //	if (duration.TotalSeconds <= 5) {
                    //		fileInformation.CallsMissedAccidentialShort++;
                    //		fileInformation.TimeAccidential = fileInformation.TimeAccidential.Add(duration);
                    //		fileContent[row].Add("Ошибочный, длительность меньше 6 секунд");
                    //	} else {
                    //		if (IsAnalysingAMissedCallSucceed(row, ref fileInformation, ref fileContent)) {
                    //			fileInformation.CallsMissed++;
                    //			fileInformation.TimeMissed = fileInformation.TimeMissed.Add(duration);
                    //		} else {
                    //			fileInformation.CallsMissedAccidentialWrongValues++;
                    //			fileInformation.TimeAccidential = fileInformation.TimeAccidential.Add(duration);
                    //		}
                    //	}
                    //} else {
                    //	UpdateTextBox("Неизвестный тип звонка: " + type);
                    //}
                }
            }

            fileInformation.FileContent = fileContent;
            filesInfo.Add(fileName, fileInformation);
        }
Пример #6
0
        private bool IsAnalysingAMissedCallSucceed(
            int row, ref SpRecordFileInformation fileInformation, ref List <List <string> > fileContent)
        {
            //UpdateTextBox("Анализ пропущенного звонка, строка: " + (row + 1) + Environment.NewLine +
            //	string.Join(";", fileContent[row]));

            DateTime dateTimeMissedTime;

            if (!DateTime.TryParse(fileContent[row][1], out dateTimeMissedTime))
            {
                fileContent[row].Add("Ошибочный, не удалось разобрать время звонка");
                UpdateTextBox("Не удалось разобрать время звонка, строка: " + (row + 1) +
                              " значение: " + fileContent[row][1]);
                return(false);
            }
            else if (Properties.Settings.Default.IgnoreNonworkingTimeMissedCalls &&
                     (dateTimeMissedTime.TimeOfDay.TotalSeconds < Properties.Settings.Default.WorkingTimeBegin.TotalSeconds ||
                      dateTimeMissedTime.TimeOfDay.TotalSeconds > Properties.Settings.Default.WorkingTimeEnd.TotalSeconds))
            {
                fileContent[row].Add("Ошибочный, время звонка выходит за границы времени работы клиники");
                return(false);
            }

            string[] phoneNumbers = SplitPhoneNumbers(fileContent[row][4]);
            string   callerNumber = phoneNumbers[0];

            if (string.IsNullOrEmpty(callerNumber))
            {
                fileContent[row].Add("Ошибочный, номер звонившего не удалось определить");
                UpdateTextBox("Номер звонившего не удалось определить");
                return(false);
            }
            else if (callerNumber.Length <= 5 && Properties.Settings.Default.IgnoreInternalMissedCalls)
            {
                fileContent[row].Add("Ошибочный, внутренний номер");
                return(false);
            }

            int      callBackTries            = 0;
            bool     regulationsObserved      = true;
            bool     registryCallBackSucceded = false;
            bool     conversationTookPlace    = false;
            DateTime dateTimeCallBack         = dateTimeMissedTime;

            for (int i = row - 1; i >= 0; i--)
            {
                if (fileContent[i].Count < 9)
                {
                    break;
                }

                if (fileContent[i][0].Equals("Название канала"))
                {
                    break;
                }

                DateTime dateTimeCurrentCall;
                if (!DateTime.TryParse(fileContent[i][1], out dateTimeCurrentCall))
                {
                    UpdateTextBox("Не удалось разобрать время звонка, строка: " + (i + 1) +
                                  " значение: " + fileContent[i][1]);
                    continue;
                }

                if (!dateTimeMissedTime.Date.Equals(dateTimeCurrentCall.Date))
                {
                    break;
                }

                string callPhoneNumbers = fileContent[i][4];
                if (!callPhoneNumbers.Contains(callerNumber))
                {
                    continue;
                }

                dateTimeCallBack = dateTimeCurrentCall;

                string callType = fileContent[i][3];

                if (callType.Contains("Непринятый"))
                {
                    if (!Properties.Settings.Default.CalcRepeatedMissedAsOne)
                    {
                        break;
                    }

                    String[] currentCallPhoneNumber = SplitPhoneNumbers(callPhoneNumbers);
                    if (currentCallPhoneNumber[0].Length < 10)
                    {
                        break;
                    }

                    if (dateTimeCurrentCall.Subtract(dateTimeMissedTime).TotalSeconds >
                        Properties.Settings.Default.CallbackThirdAttemptMax * 60)
                    {
                        break;
                    }

                    fileContent[i].Add("Ошибочный, дубль предыдущего непринятого звонка с таким же номером (" + (row + 1) + ")");
                    continue;
                }

                fileContent[i].Add("Связка с пропущенным звонком");
                fileContent[i].Add("Строка: " + (row + 1));

                if (callType.Contains("Принятый"))
                {
                    conversationTookPlace = true;
                    break;
                }
                else if (callType.Contains("Набранный"))
                {
                    string comment = fileContent[row][8];
                    if (comment.Contains("Вызываемый абонент не ответил"))
                    {
                        callBackTries++;

                        double minutesAfterMissedCall = dateTimeCurrentCall.Subtract(dateTimeMissedTime).TotalMinutes;
                        CheckRegulationObservedStatus(ref regulationsObserved, callBackTries, minutesAfterMissedCall);
                    }
                    else
                    {
                        conversationTookPlace    = true;
                        registryCallBackSucceded = true;
                        break;
                    }
                }
            }

            string resultColumn1 = "";
            string resultColumn2 = "Регламент соблюден";
            string resultColumn3 = "";

            if (!conversationTookPlace)
            {
                resultColumn1 = "Не дозвонились";
                resultColumn3 = "Попыток сделано: " + callBackTries;

                if (callBackTries == 0)
                {
                    regulationsObserved = false;
                    fileInformation.RingUpDidNotTried++;
                    resultColumn1 = "Не пытались перезвонить";
                    resultColumn3 = "";
                }
                else if (callBackTries < 3)
                {
                    regulationsObserved = false;
                    fileInformation.RingUpNotRegulationNotObserved++;
                }
                else
                {
                    if (regulationsObserved)
                    {
                        fileInformation.RingUpNotRegulationObserved++;
                    }
                    else
                    {
                        fileInformation.RingUpNotRegulationNotObserved++;
                    }
                }
            }
            else
            {
                callBackTries++;
                double minutesAfterMissedCall = dateTimeCallBack.Subtract(dateTimeMissedTime).TotalMinutes;
                CheckRegulationObservedStatus(ref regulationsObserved, callBackTries, minutesAfterMissedCall);
                resultColumn3 = "Прошло минут: " + string.Format("{0:N2}", minutesAfterMissedCall) +
                                ", попыток сделано: " + callBackTries;

                if (registryCallBackSucceded)
                {
                    switch (callBackTries)
                    {
                    case 1:
                        resultColumn1 = "Дозвонились с одной попытки";
                        if (regulationsObserved)
                        {
                            fileInformation.RingUp1tryRegulationObserved++;
                        }
                        else
                        {
                            fileInformation.RingUp1tryRegulationNotObserved++;
                        }
                        break;

                    case 2:
                        resultColumn1 = "Дозвонились с двух попыток";
                        if (regulationsObserved)
                        {
                            fileInformation.RingUp2tryRegulationObserved++;
                        }
                        else
                        {
                            fileInformation.RingUp2tryRegulationNotObserved++;
                        }
                        break;

                    case 3:
                        resultColumn1 = "Дозвонились с трех попыток";
                        if (regulationsObserved)
                        {
                            fileInformation.RingUp3tryRegulationObserved++;
                        }
                        else
                        {
                            fileInformation.RingUp3tryRegulationNotObserved++;
                        }
                        break;

                    default:
                        resultColumn1 = "Дозвонились с более чем трех попыток";
                        if (regulationsObserved)
                        {
                            fileInformation.RingUp3MoreTryRegulationObserved++;
                        }
                        else
                        {
                            fileInformation.RingUp3MoreTryRegulationNotObserved++;
                        }
                        break;
                    }
                }
                else
                {
                    resultColumn1 = "Пациент перезвонил самостоятельно";
                    if (regulationsObserved)
                    {
                        fileInformation.RingUpByPatientRegulationObserved++;
                    }
                    else
                    {
                        fileInformation.RingUpByPatientRegulationNotObserved++;
                    }
                }
            }

            if (!regulationsObserved)
            {
                resultColumn2 = "Регламент нарушен";
            }

            fileContent[row].Add(resultColumn1);
            fileContent[row].Add(resultColumn2);
            fileContent[row].Add(resultColumn3);

            return(true);
        }