Example #1
0
        public static void CreateReport(ItemReport itemReportToCreate)
        {
            itemReport   = itemReportToCreate;
            dateBeginStr = itemReport.DateBegin.ToShortDateString();
            dateEndStr   = itemReport.DateEnd.ToShortDateString();
            subject      = itemReport.Name + " с " + dateBeginStr + " по " + dateEndStr;
            Logging.ToLog("Формирование: " + subject);

            using (FirebirdClient firebirdClient = new FirebirdClient(
                       Configuration.Instance.MisDbAddress,
                       Configuration.Instance.MisDbName,
                       Configuration.Instance.MisDbUserName,
                       Configuration.Instance.MisDbUserPassword)) {
                LoadData(firebirdClient);
            }

            WriteDataToFile();

            if (hasError)
            {
                Logging.ToLog(body);
                itemReport.FileResult = string.Empty;
            }

            if (itemReport.ShouldBeSavedToFolder)
            {
                SaveReportToFolder();
            }

            if (Logging.bw != null)
            {
                if (MessageBox.Show("Отправить сообщение с отчетом следующим адресатам?" +
                                    Environment.NewLine + Environment.NewLine + itemReport.Recipients,
                                    "Отправка сообщения", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
                {
                    return;
                }
            }

            //if (Debugger.IsAttached)
            //	return;

            string recipients = itemReport.Recipients;

            if (hasError)
            {
                recipients = Configuration.Instance.MailAdminAddress;
            }

            Mail.SendMail(subject, body, recipients, itemReport.FileResult);
            Logging.ToLog("Завершение работы");

            return;
        }
Example #2
0
        private async void CheckDbConnection()
        {
            List <string> emptyStrings = new List <string>();

            if (string.IsNullOrEmpty(MisDbAddress))
            {
                emptyStrings.Add("Адрес БД МИС Инфоклиника");
            }
            if (string.IsNullOrEmpty(MisDbName))
            {
                emptyStrings.Add("Имя базы");
            }
            if (string.IsNullOrEmpty(MisDbUserName))
            {
                emptyStrings.Add("Имя пользователя");
            }
            if (string.IsNullOrEmpty(MisDbUserPassword))
            {
                emptyStrings.Add("Пароль");
            }

            if (emptyStrings.Count > 0)
            {
                string msg = "Для проверки подключения к БД необходимо заполнить:" + Environment.NewLine +
                             string.Join(Environment.NewLine, emptyStrings);
                MessageBox.Show(msg, string.Empty, MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            await Task.Run(() => {
                using (FirebirdClient firebirdClient = new FirebirdClient(
                           MisDbAddress,
                           MisDbName,
                           MisDbUserName,
                           MisDbUserPassword)) {
                    DataTable dt = firebirdClient.GetDataTable("select date 'Now' from rdb$database");

                    string msg = "Подключение к БД: ";
                    MessageBoxImage image;
                    if (dt.Rows.Count == 1)
                    {
                        msg  += "Успешно";
                        image = MessageBoxImage.Information;
                    }
                    else
                    {
                        msg  += "Ошибка";
                        image = MessageBoxImage.Error;
                    }

                    MessageBox.Show(msg, string.Empty, MessageBoxButton.OK, image);
                };
            }).ConfigureAwait(false);
        }
Example #3
0
        private static void LoadData(FirebirdClient firebirdClient)
        {
            parameters = new Dictionary <string, object>()
            {
                { "@dateBegin", dateBeginStr },
                { "@dateEnd", dateEndStr }
            };

            Logging.ToLog("Получение данных из базы МИС Инфоклиника за период с " + dateBeginStr + " по " + dateEndStr);

            try {
                dataTableMainData = firebirdClient.GetDataTable(itemReport.Query, parameters, true);
            } catch (Exception e) {
                Logging.ToLog(e.Message + Environment.NewLine + e.StackTrace);
                hasError = true;
            }

            Logging.ToLog("Получено строк: " + dataTableMainData.Rows.Count);
        }