Exemple #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;
        }
Exemple #2
0
        public static ItemReport GetReportByID(string id)
        {
            ItemReport item = null;

            foreach (ItemReport report in Instance.ReportItems)
            {
                if (report.ID.ToUpper().Equals(id.ToUpper()))
                {
                    item = report;
                }
            }

            return(item);
        }
Exemple #3
0
        public static void Main(string[] args)
        {
            Logging.ToLog("Старт");

            if (!Configuration.Instance.IsConfigReadedSuccessfull)
            {
                Logging.ToLog("Отсутсвует файл конфигурации. " +
                              "Воспользуйтесь утилитой CustomReportsManager.exe " +
                              "для создания файла конфигурации.");
                return;
            }

            if (args.Length < 2 || args.Length > 3)
            {
                Logging.ToLog("Неверное количество параметров");
                WriteOutAcceptedParameters();
                return;
            }

            string reportID = args[0];

            itemReport = Configuration.GetReportByID(reportID);
            if (itemReport == null)
            {
                Logging.ToLog("Неизвестный ID отчета: " + reportID);
                WriteOutAcceptedParameters();
                return;
            }

            ParseDateInterval(args);

            if (itemReport.DateBegin == null || itemReport.DateEnd == null)
            {
                Logging.ToLog("Не удалось распознать временные интервалы формирования отчета");
                WriteOutAcceptedParameters();
                return;
            }

            CreateReport(itemReport);
        }