Exemplo n.º 1
0
        /// <summary>
        /// Get helper for processing a document, based on document extension
        /// </summary>
        /// <param name="path">Source document full path</param>
        /// <returns></returns>
        private static DocumentHelper GetHelperForDocument(String path)
        {
            DocumentHelper helper = null;
            FileInfo       fi     = new FileInfo(path);
            String         ext    = fi.Extension.Substring(1).ToLower();

            if (ext.Equals("docx"))
            {
                helper = new WordDocumentHelper();
            }
            else if (ext.Equals("xlsx"))
            {
                helper = new ExcelDocumentHelper();
            }
            else if (ext.Equals("pptx"))
            {
                helper = new PowerPointDocumentHelper();
            }
            else if (ext.Equals("jpeg") || ext.Equals("jpg") || ext.Equals("png") || ext.Equals("bmp") || ext.Equals("gif") || ext.Equals("tiff"))
            {
                helper = new PictureDocumentHelper();
            }
            else
            {
                if (TextHighlightConfiguration.GetTextHighlightForTextFile(path) != null)
                {
                    helper = new TextDocumentHelper();
                }
            }
            return(helper);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> PrintMedicalTestProtocol(string teamNumber)
        {
            teamNumber = teamNumber.TrimEnd('а', 'б', 'в', 'г', 'д', 'е', 'ж');
            var numbers = new List <string>
            {
                teamNumber,
                teamNumber + "а",
                teamNumber + "б",
                teamNumber + "в",
                teamNumber + "г",
                teamNumber + "д",
                teamNumber + "е",
                teamNumber + "ж"
            };
            var teams = await _zarnicaDb.Teams.Where(m => numbers.Contains(m.TeamNumber)).ToListAsync();

            var dateTime = teams[0].SendDate;
            var sendDate = dateTime ?? DateTime.Today;

            var recruits = await _zarnicaDb.Recruits.Where(m =>
                                                           m.TeamId != null && teams.Select(t => t.Id).Contains(m.TeamId.Value))
                           .Include(m => m.AdditionalData)
                           .Include(m => m.MilitaryComissariat)
                           .OrderBy(m => m.LastName)
                           .AsNoTracking().ToListAsync();

            return(File(WordDocumentHelper.GenerateMedicalTestProtocol(recruits, teamNumber, sendDate),
                        WordDocumentHelper.OutputFormatType,
                        $"Список призывников получивших результаты теста ВКО {teamNumber}.docx"));
        }
Exemplo n.º 3
0
        public static FileStream GeneratePersonalGuidanceReport(IEnumerable <MilitaryComissariat> militaryComissariats,
                                                                List <SpecialPerson> persons)
        {
            const string tempDirectory = TempPath + "PersonalGuidance";
            const string zipFile       = TempPath + "personalGuidanceReport.zip";

            if (Directory.Exists(tempDirectory))
            {
                Directory.Delete(tempDirectory, true);
            }
            Directory.CreateDirectory(tempDirectory);
            File.Delete(zipFile);
            foreach (var militaryComissariat in militaryComissariats)
            {
                var mcRecruits = persons.Where(m => m.MilitaryComissariatCode == militaryComissariat.Id).ToList();
                if (mcRecruits.Count == 0)
                {
                    continue;
                }

                var file = WordDocumentHelper.GeneratePersonalGuidanceReport(mcRecruits, militaryComissariat);
                file.Close();
            }

            ZipFile.CreateFromDirectory(tempDirectory, zipFile);
            return(new FileStream(zipFile, FileMode.Open));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> PrintDactyloscopyCard(int recruitId)
        {
            var recruit = await _appDb.Recruits.AsNoTracking()
                          .FirstOrDefaultAsync(m => m.Id == recruitId);

            var zRecruit = await _zarnicaDb.Recruits
                           .Include(m => m.Settlement)
                           .Include(m => m.AdditionalData)
                           .AsNoTracking().FirstOrDefaultAsync(m =>
                                                               m.Code == recruit.UniqueRecruitNumber && m.Id == recruit.RecruitId &&
                                                               m.DelivaryDate.DayOfYear == recruit.DeliveryDate.DayOfYear
                                                               );

            if (zRecruit != null)
            {
                return(File(WordDocumentHelper.GenerateDactyloscopyRecruitCard(zRecruit),
                            WordDocumentHelper.OutputFormatType,
                            $"Дактокарта {zRecruit.LastName} {zRecruit.FirstName[0]}.{zRecruit.Patronymic[0]}.docx"));
            }

            HttpContext.Session.Set("alert",
                                    new AlertViewModel(AlertType.Error,
                                                       "Призывник в Зарнице не найден!"));
            return(RedirectToAction("Show", "Recruit", new { id = recruitId }));
        }
Exemplo n.º 5
0
        /// <summary>
        /// After document was parsed, now it's time for charts, processed concurrent with presentation
        /// </summary>
        /// <param name="path">Source document path</param>
        /// <param name="worker">Background Worker</param>
        /// <param name="document">Current KineSis Document</param>
        public static void CreateNewDocumentCharts(String path, BackgroundWorker worker, Document document)
        {
            FileInfo file = new FileInfo(path);

            DocumentHelper helper = GetHelperForDocument(path);

            if (helper != null)
            {
                ProcessingProgress pp = new ProcessingProgress(worker);
                try
                {
                    if (helper is PowerPointDocumentHelper)
                    {
                        PowerPointDocumentHelper h = (PowerPointDocumentHelper)helper;
                        h.ParseNewDocumentCharts(path, pp, document);
                    }
                    else if (helper is ExcelDocumentHelper)
                    {
                        ExcelDocumentHelper h = (ExcelDocumentHelper)helper;
                        h.ParseNewDocumentCharts(path, pp, document);
                    }
                    else if (helper is WordDocumentHelper)
                    {
                        WordDocumentHelper h = (WordDocumentHelper)helper;
                        h.ParseNewDocumentCharts(path, pp, document);
                    }
                }
                catch (Exception ex)
                {
                    pp.OverallOperationName = "[Exception] " + ex.Message;
                    //    pp.OverallOperationTotalElements = 1;
                    //    MessageBox.Show(ex.Message);
                }

                Document.serialize(document, TEMP_DIRECTORY + "\\" + document.Location + ".xml");

                ProfileManager.AddDocumentToActive(document.Name, document.Location);
                ProfileManager.Serialize();
            }
        }