private void TechSpecReport(int type)
        {
            // Check for info for choosed data
            var lotExtended = DataBaseClient.ReadLotsExtended(StartDate, EndDate);

            if (lotExtended != null && lotExtended.Count > 0)
            {
                // Variables info
                string path         = "";
                string templateFile = "";
                string templatePath = @"\\192.168.11.5\Archive\Templates\ETS\TechSpecReport.xlsx";

                // Get path to save template
                try {
                    path = Service.GetDirectory().FullName;
                } catch { path = ""; }

                if (!string.IsNullOrEmpty(path))
                {
                    // Get template file
                    templateFile = path + "\\Отчет по тех. спец. с " + StartDate.ToShortDateString() + " по " + EndDate.ToShortDateString() + ".xlsx";

                    if (Service.CopyFile(templatePath, templateFile, true))
                    {
                        // Fill template file with info
                        try {
                            // Convert EF to BO
                            var techSpecReports = DataBaseClient.ReadTechSpecReport(1, StartDate, EndDate, new List <int>()
                            {
                                4
                            }, type == 1 ? new List <int>()
                            {
                                2
                            } : new List <int>()
                            {
                                2, 3, 4
                            });

                            if (techSpecReports != null && techSpecReports.Count > 1)
                            {
                                // Create report document
                                TechSpecReportService.CreateDocument(techSpecReports, templateFile);

                                // Open folder with file
                                FolderExplorer.OpenFolder(path + "\\");
                            }
                            else
                            {
                                MessagesService.Show("Оповещение", "На эти даты записей нет");
                            }
                        } catch (Exception ex) { MessagesService.Show("Оповещение", "Произошла ошибка во время формирования отчета\n" + ex.ToString()); }
                    }
                    else
                    {
                        MessagesService.Show("Оповещение", "Произошла ошибка во время копирования шаблона");
                    }
                }
            }
            else
            {
                MessagesService.Show("Оповещение", "Нет данных для формирования");
            }
        }
        public HttpResponseMessage GenerateReport(DateTime startDate, DateTime endDate, string dateFilterType, int siteId = 0, int statusId = 0, short sortMode = 0, string sortColumnName = null)
        {
            List <int> sites    = new List <int>();
            List <int> statuses = new List <int>();

            if (siteId > 0)
            {
                sites.Add(siteId);
            }

            switch (statusId)
            {
            case (1):
            {
                statuses.Add(2);
            }
            break;

            case (2):
            {
                statuses.Add(1);
                statuses.Add(4);
                statuses.Add(5);
            }
            break;
            }

            List <TechSpecReportBO> reports = null;

            switch (dateFilterType)
            {
            case ("auctionDate"):
            {
                reports = DataManager.GetTechSpecReport(CurrentUser.CustomerId, startDate, endDate, sites, statuses, sortMode: sortMode, sortColumnName: sortColumnName);
            }
            break;

            case ("orderDate"):
            {
                reports = DataManager.GetTechSpecReportByOrderDate(CurrentUser.CustomerId, startDate, endDate, sites, statuses, sortMode: sortMode, sortColumnName: sortColumnName);
            }
            break;
            }
            if (reports == null || reports.Count == 0)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            var templateRequisite = ArchiveManager.GetTemplateRequisite(MarketPlaceEnum.ETS, DocumentTemplateEnum.TechSpecReport);

            if (templateRequisite == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotImplemented);
            }

            var localPath = ArchiveManager.LoadTemplateToLocalStorage(templateRequisite);

            TechSpecReportService.CreateDocument(reports, localPath);

            var fileName     = string.Format("{0}_from_{1:dd-MM-yyyy}_to_{2:dd-MM-yyyy}.{3}", REPORT_OF_THE_PERIOD, startDate, endDate, templateRequisite.extension);
            var responceFile = HttpResponceFile.Create(fileName, localPath);

            if (responceFile == null)
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }

            return(responceFile);
        }