示例#1
0
        public void CloseAllPages(object sender, RoutedEventArgs e)
        {
            Logging.ToLog("MainWindow - закрытие всех страниц");

            try {
                while (FrameMain.NavigationService.CanGoBack)
                {
                    FrameMain.NavigationService.GoBack();
                    FrameMain.NavigationService.RemoveBackEntry();
                }
            } catch (Exception exc) {
                Logging.ToLog(exc.Message + Environment.NewLine + exc.StackTrace);
            }

            if (!(FrameMain.Content is PageRangeSelection))
            {
                FrameMain.NavigationService.Navigate(rootPage);
            }

            if (ItemSurveyResult.Instance.NeedToWriteToDb)
            {
                ItemSurveyResult.WriteSurveyResultToDb();
            }

            autoCloseTimer.Stop();
            GC.Collect();
        }
示例#2
0
        private void AutoCloseTimer_Tick(object sender, EventArgs e)
        {
            infoPageCloseCounter++;

            if (FrameMain.Content is PageServices ||
                FrameMain.Content is PageSchedule)
            {
                if (infoPageCloseCounter < Services.Config.Instance.AutoCloseTImerInfoPageMultiplier)
                {
                    return;
                }
            }

            Logging.ToLog("MainWindow - Автозакрытие страницы по таймеру");

            if (ItemSurveyResult.Instance.NeedToWriteToDb)
            {
                if (FrameMain.Content is PageCallback)
                {
                    ItemSurveyResult.Instance.SetPhoneNumber("Timeout");
                }
                else if (FrameMain.Content is PageComment)
                {
                    ItemSurveyResult.Instance.SetComment("Timeout");
                }

                ItemSurveyResult.WriteSurveyResultToDb();
            }

            CloseAllPages(null, null);
        }
示例#3
0
        public static async void WriteSurveyResultToDb()
        {
            await Task.Run(() => {
                ItemSurveyResult surveyResult = Instance;
                SendMailAboutNegativeMark(surveyResult);

                if ((DateTime.Now - previousRateTime).TotalSeconds >= 120)
                {
                    previousRatesDcodes.Clear();
                }

                string mark = surveyResult.Mark;
                if (previousRatesDcodes.Contains(surveyResult.DCode))
                {
                    mark = "Duplicate";
                }
                else
                {
                    previousRatesDcodes.Add(surveyResult.DCode);
                }

                Logging.ToLog("ItemSurveyResult - Запись результата опроса в базу данных: " + surveyResult.ToString());

                using (Services.FirebirdClient fBClient = new Services.FirebirdClient(
                           Services.Config.Instance.MisDbAddress,
                           Services.Config.Instance.MisDbPort,
                           Services.Config.Instance.MisDbName,
                           Services.Config.Instance.MisDbUserName,
                           Services.Config.Instance.MisDbUserPassword)) {
                    Dictionary <string, object> surveyResults = new Dictionary <string, object>()
                    {
                        { "@dcode", surveyResult.DCode },
                        { "@docrate", mark },
                        { "@comment", surveyResult.Comment },
                        { "@phonenumber", surveyResult.PhoneNumber },
                        { "@photopath", surveyResult.PhotoLink },
                        { "@depnum", surveyResult.DocDeptCode }
                    };

                    string query = Services.Config.Instance.SqlInsertLoyaltySurveyResult;
                    Logging.ToLog("ItemSurveyResult - Результат выполнения: " + fBClient.ExecuteUpdateQuery(query, surveyResults));

                    previousRateTime = surveyResult.SurveyDateTime.Value;
                }
            }).ConfigureAwait(false);
        }
示例#4
0
        public static void SendMailAboutNegativeMark(ItemSurveyResult surveyResult)
        {
            if (surveyResult == null)
            {
                return;
            }

            string header = "";

            string recipients = string.Empty;
            string mark;

            switch (surveyResult.Type)
            {
            case SurveyType.Doctor:
                recipients = Services.Config.Instance.MailRecipientsNegativeMarksDoctor;
                break;

            case SurveyType.Registry:
                recipients = Services.Config.Instance.MailRecipientsNegativeMarksRegistry;
                break;

            case SurveyType.Clinic:
                recipients = Services.Config.Instance.MailRecipientsNegativeMarksClinic;
                break;

            default:
                break;
            }

            if (surveyResult.Mark.Equals("0"))
            {
                mark = "Крайне не буду рекомендовать";
            }
            else if (surveyResult.Mark.Equals("1"))
            {
                mark = "Очень плохо";
            }
            else if (surveyResult.Mark.Equals("2"))
            {
                mark = "Плохо";
            }
            else
            {
                return;
            }

            if (surveyResult.PhoneNumber.Length == 10 &&
                !surveyResult.PhoneNumber.Equals("skipped"))
            {
                header = "Пациент указал, что ему можно позвонить для уточнения подробностей " +
                         "о его негативной оценке.";
            }
            else if (!string.IsNullOrEmpty(surveyResult.Comment) &&
                     !string.IsNullOrWhiteSpace(surveyResult.Comment) &&
                     !surveyResult.Comment.Equals("skipped"))
            {
                header = "Пациент оставил комментарий к своей негативной оценке";
            }

            if (string.IsNullOrEmpty(header))
            {
                Logging.ToLog("ItemSurveyResult - Пропуск отправки сообщения об обратной связи - " +
                              "неверный формат номера телефона и отсутствует комментарий");
                return;
            }

            string subject = Services.Config.Instance.MailClinicName + " - обратная связь с пациентом через монитор лояльности";
            string body    =
                header + "<br><br>" +
                "<table border=\"1\">" +
                "<tr><td>Сотрудник</td><td><b>" + surveyResult.DocName + "</b></td></tr>" +
                "<tr><td>Отделение</td><td><b>" + surveyResult.DocDepartment + "</b></td></tr>" +
                "<tr><td>Оценка</td><td><b>" + mark + "</b></td></tr>" +
                "<tr><td>Комментарий</td><td><b>" +
                (surveyResult.Comment.Equals("skipped") ? "отказался" : surveyResult.Comment) + "</b></td></tr>" +
                "<tr><td>Номер телефона для связи</td><td><b>" +
                (surveyResult.PhoneNumber.Equals("skipped") ? "отказался" : surveyResult.PhoneNumber) + "</b></td></tr>" +
                "</table><br>";

            string attachmentPath = surveyResult.PhotoLink;

            if (File.Exists(attachmentPath))
            {
                body += "Фотография с камеры терминала:";
            }
            else
            {
                body += "Фотография отсутствует";
            }
            body += "</b>";

            ClientMail.SendMail(subject, body, recipients, attachmentPath);
        }