示例#1
0
        public void ParseGetLnDataResponse(string response)
        {
            bworker.ReportProgress((int)progressCurrent, "Разбор полученных данных");

            XmlDocument xlDoc = new XmlDocument();

            xlDoc.LoadXml(response);

            XmlNodeList root = xlDoc.GetElementsByTagName("FileOperationsLnUserGetLNDataOut");

            if (root == null || root.Count == 0)
            {
                bworker.ReportProgress((int)progressCurrent,
                                       "Не удается найти базовый элемент - FileOperationsLnUserGetLNDataOut");
                return;
            }

            XmlElement  rootElement = root[0] as XmlElement;
            XmlNodeList status      = rootElement.GetElementsByTagName("STATUS");

            if (status == null && status.Count != 1)
            {
                bworker.ReportProgress((int)progressCurrent,
                                       "Не удается найти элемент - STATUS");
                return;
            }

            string statusValue = status[0].InnerText;

            if (!statusValue.Equals("1"))
            {
                XmlNodeList requestId      = rootElement.GetElementsByTagName("REQUEST_ID");
                string      requestIdValue = string.Empty;
                if (requestId != null && requestId.Count > 0)
                {
                    requestIdValue = requestId[0].InnerText;
                }

                XmlNodeList mess      = rootElement.GetElementsByTagName("MESS");
                string      messValue = string.Empty;
                if (mess != null && mess.Count > 0)
                {
                    messValue = mess[0].InnerText;
                }

                bworker.ReportProgress((int)progressCurrent,
                                       "Статус выполнения запроса - метод отработал с ошибками");
                bworker.ReportProgress((int)progressCurrent,
                                       "REQUEST_ID: " + requestIdValue + "; STATUS: " + statusValue + "; MESS: " + messValue);
                return;
            }

            XmlNodeList rows = rootElement.GetElementsByTagName("ROW");

            if (rows == null || rows.Count == 0)
            {
                bworker.ReportProgress((int)progressCurrent,
                                       "Отсутствуют данные о больничном листе");
                return;
            }

            XmlElement          data   = rows[0] as XmlElement;
            XmlNodeList         lnCode = data.GetElementsByTagName("LN_CODE");
            ItemDisabilitySheet item   = null;

            if (lnCode != null || lnCode.Count == 1)
            {
                if (DisabilitySheets.ContainsKey(Convert.ToInt64(lnCode[0].InnerText)))
                {
                    item = DisabilitySheets[Convert.ToInt64(lnCode[0].InnerText)];
                }
            }

            if (item == null)
            {
                bworker.ReportProgress((int)progressCurrent,
                                       "Не удалось найти больничный лист в списке по номеру: " + lnCode);
                return;
            }

            XmlNodeList searchList = null;

            searchList = data.GetElementsByTagName("SURNAME");
            if (searchList != null && searchList.Count == 1)
            {
                item.SURNAME = searchList[0].InnerText;
            }

            searchList = data.GetElementsByTagName("NAME");
            if (searchList != null && searchList.Count == 1)
            {
                item.NAME = searchList[0].InnerText;
            }

            searchList = data.GetElementsByTagName("PATRONIMIC");
            if (searchList != null && searchList.Count == 1)
            {
                item.PATRONIMIC = searchList[0].InnerText;
            }

            searchList = data.GetElementsByTagName("BOZ_FLAG");
            if (searchList != null && searchList.Count == 1)
            {
                item.BOZ_FLAG = searchList[0].InnerText;
            }

            searchList = data.GetElementsByTagName("LPU_EMPLOYER");
            if (searchList != null && searchList.Count == 1)
            {
                item.LPU_EMPLOYER = searchList[0].InnerText;
            }

            searchList = data.GetElementsByTagName("LPU_EMPL_FLAG");
            if (searchList != null && searchList.Count == 1)
            {
                item.LPU_EMPL_FLAG = searchList[0].InnerText;
            }

            searchList = data.GetElementsByTagName("PREV_LN_CODE");
            if (searchList != null && searchList.Count == 1)
            {
                if (long.TryParse(searchList[0].InnerText, out long prevLnCode))
                {
                    item.PREV_LN_CODE = prevLnCode;
                }
            }

            searchList = data.GetElementsByTagName("PRIMARY_FLAG");
            if (searchList != null && searchList.Count == 1)
            {
                item.PRIMARY_FLAG = searchList[0].InnerText;
            }

            searchList = data.GetElementsByTagName("DUPLICATE_FLAG");
            if (searchList != null && searchList.Count == 1)
            {
                item.DUPLICATE_FLAG = searchList[0].InnerText;
            }

            searchList = data.GetElementsByTagName("LN_DATE");
            if (searchList != null && searchList.Count == 1)
            {
                if (DateTime.TryParse(searchList[0].InnerText, out DateTime lnDate))
                {
                    item.LN_DATE = lnDate;
                }
            }

            searchList = data.GetElementsByTagName("LPU_NAME");
            if (searchList != null && searchList.Count == 1)
            {
                item.LPU_NAME = searchList[0].InnerText;
            }

            searchList = data.GetElementsByTagName("LPU_ADDRESS");
            if (searchList != null && searchList.Count == 1)
            {
                item.LPU_ADDRESS = searchList[0].InnerText;
            }

            searchList = data.GetElementsByTagName("LPU_OGRN");
            if (searchList != null && searchList.Count == 1)
            {
                if (long.TryParse(searchList[0].InnerText, out long lpuOgrn))
                {
                    item.LPU_OGRN = lpuOgrn;
                }
            }

            searchList = data.GetElementsByTagName("BIRTHDAY");
            if (searchList != null && searchList.Count == 1)
            {
                if (DateTime.TryParse(searchList[0].InnerText, out DateTime birthday))
                {
                    item.BIRTHDAY = birthday;
                }
            }

            searchList = data.GetElementsByTagName("GENDER");
            if (searchList != null && searchList.Count == 1)
            {
                item.GENDER = searchList[0].InnerText;
            }

            searchList = data.GetElementsByTagName("REASON1");
            if (searchList != null && searchList.Count == 1)
            {
                item.REASON1 = searchList[0].InnerText;
            }

            searchList = data.GetElementsByTagName("REASON2");
            if (searchList != null && searchList.Count == 1)
            {
                item.REASON2 = searchList[0].InnerText;
            }

            searchList = data.GetElementsByTagName("REASON3");
            if (searchList != null && searchList.Count == 1)
            {
                item.REASON3 = searchList[0].InnerText;
            }

            searchList = data.GetElementsByTagName("DIAGNOS");
            if (searchList != null && searchList.Count == 1)
            {
                item.DIAGNOS = searchList[0].InnerText;
            }

            searchList = data.GetElementsByTagName("PARENT_CODE");
            if (searchList != null && searchList.Count == 1)
            {
                if (long.TryParse(searchList[0].InnerText, out long parentCode))
                {
                    item.PARENT_CODE = parentCode;
                }
            }

            searchList = data.GetElementsByTagName("DATE1");
            if (searchList != null && searchList.Count == 1)
            {
                if (DateTime.TryParse(searchList[0].InnerText, out DateTime date1))
                {
                    item.DATE1 = date1;
                }
            }

            searchList = data.GetElementsByTagName("DATE2");
            if (searchList != null && searchList.Count == 1)
            {
                if (DateTime.TryParse(searchList[0].InnerText, out DateTime date2))
                {
                    item.DATE2 = date2;
                }
            }

            searchList = data.GetElementsByTagName("VOUCHER_NO");
            if (searchList != null && searchList.Count == 1)
            {
                if (long.TryParse(searchList[0].InnerText, out long voucherNo))
                {
                    item.VOUCHER_NO = voucherNo;
                }
            }

            searchList = data.GetElementsByTagName("VOUCHER_OGRN");
            if (searchList != null && searchList.Count == 1)
            {
                if (long.TryParse(searchList[0].InnerText, out long voucherOgrn))
                {
                    item.VOUCHER_OGRN = voucherOgrn;
                }
            }

            searchList = data.GetElementsByTagName("SERV1_AGE");
            if (searchList != null && searchList.Count == 1)
            {
                if (long.TryParse(searchList[0].InnerText, out long serv1Age))
                {
                    item.SERV1_AGE = serv1Age;
                }
            }

            searchList = data.GetElementsByTagName("SERV1_MM");
            if (searchList != null && searchList.Count == 1)
            {
                if (long.TryParse(searchList[0].InnerText, out long serv1Mm))
                {
                    item.SERV1_MM = serv1Mm;
                }
            }

            searchList = data.GetElementsByTagName("SERV1_RELATION_CODE");
            if (searchList != null && searchList.Count == 1)
            {
                item.SERV1_RELATION_CODE = searchList[0].InnerText;
            }

            searchList = data.GetElementsByTagName("SERV1_FIO");
            if (searchList != null && searchList.Count == 1)
            {
                item.SERV1_FIO = searchList[0].InnerText;
            }

            searchList = data.GetElementsByTagName("SERV2_AGE");
            if (searchList != null && searchList.Count == 1)
            {
                if (long.TryParse(searchList[0].InnerText, out long serv2Age))
                {
                    item.SERV2_AGE = serv2Age;
                }
            }

            searchList = data.GetElementsByTagName("SERV2_MM");
            if (searchList != null && searchList.Count == 1)
            {
                if (long.TryParse(searchList[0].InnerText, out long serv2Mm))
                {
                    item.SERV2_MM = serv2Mm;
                }
            }

            searchList = data.GetElementsByTagName("SERV2_RELATION_CODE");
            if (searchList != null && searchList.Count == 1)
            {
                item.SERV2_RELATION_CODE = searchList[0].InnerText;
            }

            searchList = data.GetElementsByTagName("SERV2_FIO");
            if (searchList != null && searchList.Count == 1)
            {
                item.SERV2_FIO = searchList[0].InnerText;
            }

            searchList = data.GetElementsByTagName("PREGN12W_FLAG");
            if (searchList != null && searchList.Count == 1)
            {
                item.PREGN12W_FLAG = searchList[0].InnerText;
            }

            searchList = data.GetElementsByTagName("HOSPITAL_DT1");
            if (searchList != null && searchList.Count == 1)
            {
                if (DateTime.TryParse(searchList[0].InnerText, out DateTime hospitalDt1))
                {
                    item.HOSPITAL_DT1 = hospitalDt1;
                }
            }

            searchList = data.GetElementsByTagName("HOSPITAL_DT2");
            if (searchList != null && searchList.Count == 1)
            {
                if (DateTime.TryParse(searchList[0].InnerText, out DateTime hospitalDt2))
                {
                    item.HOSPITAL_DT2 = hospitalDt2;
                }
            }

            searchList = data.GetElementsByTagName("MSE_DT1");
            if (searchList != null && searchList.Count == 1)
            {
                if (DateTime.TryParse(searchList[0].InnerText, out DateTime mseDt1))
                {
                    item.MSE_DT1 = mseDt1;
                }
            }

            searchList = data.GetElementsByTagName("MSE_DT2");
            if (searchList != null && searchList.Count == 1)
            {
                if (DateTime.TryParse(searchList[0].InnerText, out DateTime mseDt2))
                {
                    item.MSE_DT2 = mseDt2;
                }
            }

            searchList = data.GetElementsByTagName("MSE_DT3");
            if (searchList != null && searchList.Count == 1)
            {
                if (DateTime.TryParse(searchList[0].InnerText, out DateTime mseDt3))
                {
                    item.MSE_DT3 = mseDt3;
                }
            }

            searchList = data.GetElementsByTagName("MSE_INVALID_GROUP");
            if (searchList != null && searchList.Count == 1)
            {
                item.MSE_INVALID_GROUP = searchList[0].InnerText;
            }

            searchList = data.GetElementsByTagName("LN_HASH");
            if (searchList != null && searchList.Count == 1)
            {
                item.LN_HASH = searchList[0].InnerText;
            }

            searchList = data.GetElementsByTagName("LN_STATE");
            if (searchList != null && searchList.Count == 1)
            {
                item.LN_STATE = searchList[0].InnerText;
            }

            searchList = data.GetElementsByTagName("HOSPITAL_BREACH");
            if (searchList != null)
            {
                foreach (XmlElement breachElement in searchList)
                {
                    ItemDisabilitySheet.HospitalBreach breach = new ItemDisabilitySheet.HospitalBreach();

                    XmlNodeList breachSearchList = breachElement.GetElementsByTagName("HOSPITAL_BREACH_CODE");
                    if (breachSearchList != null && breachSearchList.Count == 1)
                    {
                        breach.HOSPITAL_BREACH_CODE = breachSearchList[0].InnerText;
                    }

                    breachSearchList = breachElement.GetElementsByTagName("HOSPITAL_BREACH_DT");
                    if (breachSearchList != null && breachSearchList.Count == 1)
                    {
                        breach.HOSPITAL_BREACH_DT = breachSearchList[0].InnerText;
                    }

                    item.HospitalBreachs.Add(breach);
                }
            }

            searchList = data.GetElementsByTagName("LN_RESULT");
            if (searchList != null)
            {
                foreach (XmlElement resultElement in searchList)
                {
                    ItemDisabilitySheet.LNResult result = new ItemDisabilitySheet.LNResult();

                    XmlNodeList resultSearchList = resultElement.GetElementsByTagName("MSE_RESULT");
                    if (resultSearchList != null && resultSearchList.Count == 1)
                    {
                        result.MSE_RESULT = resultSearchList[0].InnerText;
                    }

                    resultSearchList = resultElement.GetElementsByTagName("OTHER_STATE_DT");
                    if (resultSearchList != null && resultSearchList.Count == 1)
                    {
                        result.OTHER_STATE_DT = resultSearchList[0].InnerText;
                    }

                    resultSearchList = resultElement.GetElementsByTagName("RETURN_DATE_LPU");
                    if (resultSearchList != null && resultSearchList.Count == 1)
                    {
                        result.RETURN_DATE_LPU = resultSearchList[0].InnerText;
                    }

                    resultSearchList = resultElement.GetElementsByTagName("NEXT_LN_CODE");
                    if (resultSearchList != null && resultSearchList.Count == 1)
                    {
                        result.NEXT_LN_CODE = resultSearchList[0].InnerText;
                    }

                    item.LNResults.Add(result);
                }
            }

            searchList = data.GetElementsByTagName("TREAT_FULL_PERIOD");
            if (searchList != null)
            {
                foreach (XmlElement fullPeriodElement in searchList)
                {
                    ItemDisabilitySheet.TreatFullPeriod fullPeriod = new ItemDisabilitySheet.TreatFullPeriod();

                    XmlNodeList fullPeriodSearchList = fullPeriodElement.GetElementsByTagName("TREAT_CHAIRMAN_ROLE");
                    if (fullPeriodSearchList != null && fullPeriodSearchList.Count == 1)
                    {
                        fullPeriod.TREAT_CHAIRMAN_ROLE = fullPeriodSearchList[0].InnerText;
                    }

                    fullPeriodSearchList = fullPeriodElement.GetElementsByTagName("TREAT_CHAIRMAN");
                    if (fullPeriodSearchList != null && fullPeriodSearchList.Count == 1)
                    {
                        fullPeriod.TREAT_CHAIRMAN = fullPeriodSearchList[0].InnerText;
                    }


                    XmlNodeList periodsSearchList = fullPeriodElement.GetElementsByTagName("TREAT_PERIOD");
                    if (periodsSearchList != null)
                    {
                        foreach (XmlElement period in periodsSearchList)
                        {
                            ItemDisabilitySheet.TreatFullPeriod.TreatPeriod treatPeriod =
                                new ItemDisabilitySheet.TreatFullPeriod.TreatPeriod();

                            XmlNodeList periodList = period.GetElementsByTagName("TREAT_DT1");
                            if (periodList != null && periodList.Count == 1)
                            {
                                treatPeriod.TREAT_DT1 = periodList[0].InnerText;
                            }

                            periodList = period.GetElementsByTagName("TREAT_DT2");
                            if (periodList != null && periodList.Count == 1)
                            {
                                treatPeriod.TREAT_DT2 = periodList[0].InnerText;
                            }

                            periodList = period.GetElementsByTagName("TREAT_DOCTOR_ROLE");
                            if (periodList != null && periodList.Count == 1)
                            {
                                treatPeriod.TREAT_DOCTOR_ROLE = periodList[0].InnerText;
                            }

                            periodList = period.GetElementsByTagName("TREAT_DOCTOR");
                            if (periodList != null && periodList.Count == 1)
                            {
                                treatPeriod.TREAT_DOCTOR = periodList[0].InnerText;
                            }

                            fullPeriod.TreatPeriods.Add(treatPeriod);
                        }
                    }

                    item.TreatFullPeriods.Add(fullPeriod);
                }
            }
        }
示例#2
0
        public void ParseGetLNListByDateResponse(string response)
        {
            bworker.ReportProgress((int)progressCurrent, "Разбор полученных данных");

            XmlDocument xlDoc = new XmlDocument();

            xlDoc.LoadXml(response);

            XmlNodeList root = xlDoc.GetElementsByTagName("FileOperationsLnUserGetLNListByDateOut");

            if (root == null || root.Count == 0)
            {
                bworker.ReportProgress((int)progressCurrent, "!!! Не удается найти базовый элемент - FileOperationsLnUserGetLNListByDateOut");
                return;
            }

            XmlElement  rootElement = root[0] as XmlElement;
            XmlNodeList status      = rootElement.GetElementsByTagName("STATUS");

            if (status == null && status.Count != 1)
            {
                bworker.ReportProgress((int)progressCurrent, "!!! Не удается найти элемент - STATUS");
                return;
            }

            string statusValue = status[0].InnerText;

            if (!statusValue.Equals("1"))
            {
                XmlNodeList requestId      = rootElement.GetElementsByTagName("REQUEST_ID");
                string      requestIdValue = string.Empty;
                if (requestId != null && requestId.Count > 0)
                {
                    requestIdValue = requestId[0].InnerText;
                }

                XmlNodeList mess      = rootElement.GetElementsByTagName("MESS");
                string      messValue = string.Empty;
                if (mess != null && mess.Count > 0)
                {
                    messValue = mess[0].InnerText;
                }

                bworker.ReportProgress((int)progressCurrent, "!!! Статус выполнения запроса - метод отработал с ошибками");
                bworker.ReportProgress((int)progressCurrent, "REQUEST_ID: " + requestIdValue + "; STATUS: " + statusValue + "; MESS: " + messValue);
                return;
            }

            XmlNodeList rows = rootElement.GetElementsByTagName("RowLNbyDate");

            if (rows == null || rows.Count == 0)
            {
                bworker.ReportProgress((int)progressCurrent, "Отсутствуют данные о больничных листах");
                return;
            }

            bworker.ReportProgress((int)progressCurrent, "Получено строк: " + rows.Count);

            foreach (XmlElement row in rows)
            {
                XmlNodeList lnCode  = row.GetElementsByTagName("LN_CODE");
                XmlNodeList lnState = row.GetElementsByTagName("LN_STATE");
                XmlNodeList snils   = row.GetElementsByTagName("SNILS");

                if (lnCode == null || lnState == null || snils == null)
                {
                    bworker.ReportProgress((int)progressCurrent, "!!! Пропуск обработки строки, незвестный формат");
                    continue;
                }

                ItemDisabilitySheet item = new ItemDisabilitySheet {
                    LN_CODE  = Convert.ToInt64(lnCode[0].InnerText),
                    LN_STATE = lnState[0].InnerText,
                    SNILS    = snils[0].InnerText
                };

                if (!DisabilitySheets.ContainsKey(item.LN_CODE))
                {
                    DisabilitySheets.Add(item.LN_CODE, item);
                }
            }
        }
示例#3
0
        static public void LoadDataAndWriteToDb(DateTime dateBegin, DateTime dateEnd, bool updateOpened = false)
        {
            string message = string.Empty;
            string tmp     = string.Empty;

            if (updateOpened)
            {
                tmp      = "---Обновление информации по открытым больничным листам в БД";
                message += tmp + Environment.NewLine;
                Logging.ToLog(tmp);
            }
            else
            {
                tmp = "---Загрузка данных по больничным листам в БД за период: с " +
                      dateBegin.ToShortDateString() + " по " + dateEnd.ToShortDateString();
                message += tmp + Environment.NewLine;
                Logging.ToLog(tmp);
            }

            X509Certificate2 userCertificate = GetCertificate(true);
            X509Certificate2 fssCertificate  = GetCertificate(false);

            if (userCertificate == null || fssCertificate == null)
            {
                tmp      = "!!! Не удалось определить сертификат(ы)";
                message += tmp + Environment.NewLine;
                Logging.ToLog(tmp);
            }
            else
            {
                WsdlServiceHandle.Instance.Initialize(
                    dateBegin,
                    dateEnd,
                    userCertificate,
                    fssCertificate);

                BackgroundWorker bw = new BackgroundWorker();
                bw.WorkerReportsProgress = true;
                bw.ProgressChanged      += (s, e) => {
                    if (e.UserState != null)
                    {
                        tmp      = e.UserState.ToString();
                        message += tmp + Environment.NewLine;
                        Logging.ToLog(tmp);
                    }
                };

                FirebirdClient firebirdClient = new FirebirdClient(
                    Properties.Settings.Default.MisDbAddress,
                    Properties.Settings.Default.MisDbName,
                    Properties.Settings.Default.MisDbUser,
                    Properties.Settings.Default.MisDbPassword);

                if (firebirdClient.IsConnectionOpened())
                {
                    if (updateOpened)
                    {
                        tmp      = "Получение списка больничных листов из БД со статусом 'ЭЛН открыт'";
                        message += tmp + Environment.NewLine;
                        Logging.ToLog(tmp);

                        try {
                            string    queryGetOpened = Properties.Settings.Default.SqlSelectOpened;
                            DataTable dt             = firebirdClient.GetDataTable(queryGetOpened, new Dictionary <string, object>());
                            tmp      = "Получено строк из БД: " + dt.Rows.Count;
                            message += tmp + Environment.NewLine;
                            Logging.ToLog(tmp);

                            if (dt.Rows.Count > 0)
                            {
                                foreach (DataRow row in dt.Rows)
                                {
                                    ItemDisabilitySheet item = new ItemDisabilitySheet()
                                    {
                                        LN_CODE = Convert.ToInt64(row[0].ToString()),
                                        SNILS   = row[1].ToString()
                                    };

                                    WsdlServiceHandle.Instance.DisabilitySheets.Add(item.LN_CODE, item);
                                }
                            }
                        } catch (Exception e) {
                            tmp      = "!!! " + e.Message + Environment.NewLine + e.StackTrace;
                            message += tmp + Environment.NewLine;
                            Logging.ToLog(tmp);
                        }
                    }

                    WsdlServiceHandle.Instance.LoadDisabilitySheetList(bw, updateOpened);

                    if (WsdlServiceHandle.Instance.DisabilitySheets.Count == 0)
                    {
                        tmp      = "Нет записей за указанный период, завершение работы";
                        message += tmp + Environment.NewLine;
                        Logging.ToLog(tmp);
                    }
                    else
                    {
                        tmp      = "Запись полученных данных в БД";
                        message += tmp;
                        Logging.ToLog(tmp);

                        try {
                            string queryUpdate = Properties.Settings.Default.SqlUpdateRow;
                            foreach (ItemDisabilitySheet item in WsdlServiceHandle.Instance.DisabilitySheets.Values)
                            {
                                firebirdClient.ExecuteUpdateQuery(queryUpdate, item.GetDictionary());
                            }
                        } catch (Exception e) {
                            tmp      = "!!! " + e.Message + Environment.NewLine + e.StackTrace;
                            message += tmp + Environment.NewLine;
                            Logging.ToLog(tmp);
                        }
                    }
                }
                else
                {
                    tmp = "!!! Не удалось открыть подключение к БД: " +
                          Properties.Settings.Default.MisDbAddress + ":" +
                          Properties.Settings.Default.MisDbName;
                    message += tmp + Environment.NewLine;
                    Logging.ToLog(tmp);
                }
            }

            string subject  = message.Contains("!!!") ? "!!! Выполнено с ошибками" : "Выполнено успешно";
            string body     = message;
            string receiver = Properties.Settings.Default.MailTo;

            SystemMail.SendMail(subject, body, receiver);
        }