Пример #1
0
        public JSON GenerateJobOfferForSupervisoryAndRankAndFile(JobOfferForOfficer Param)
        {
            JSON returnJSON = new JSON();

            Application app      = new Application();
            object      misValue = System.Reflection.Missing.Value;


            if (File.Exists(FormController.ServerPathTempForms() + Param.Filename + ".docx"))
            {
                File.Delete(FormController.ServerPathTempForms() + Param.Filename + ".docx");
            }

            try
            {
                File.Copy(FormController.ServerPathFormsTemplate() + "Job Offer For Supervisory And Rank & File.docx", FormController.ServerPathTempForms() + Param.Filename + ".docx");

                Document doc = app.Documents.Open(FormController.ServerPathTempForms() + Param.Filename + ".docx");

                Dictionary <string, string> bookmarks = new Dictionary <string, string> {
                    { "Date", Param.Date },
                    { "PersonName", GenFunct.ToTitleCase($"{Param.PersonName.FirstName} {Param.PersonName.MiddleName}. {Param.PersonName.LastName} {Param.PersonName.Suffix}") },
                    { "PositionTitle", Param.Position.PositionDescription },
                    { "SalaryGrade", $"{Param.SalaryGrade} / {Param.SalaryGradeStep}" },
                    { "MonthlySalary", Param.MonthlySalary },
                    { "GroupUnit", Param.GroupUnit },
                    { "StartDate", Param.StartDate },
                    { "WorkIn", Param.WorkIn },
                    { "WorkOut", Param.WorkOut },
                };

                FormToWord.ApplyDataToBookmark(bookmarks, doc);

                doc.Save();
                doc.ExportAsFixedFormat(FormController.ServerPathTempForms() + Param.Filename + ".pdf", WdExportFormat.wdExportFormatPDF);
                doc.Close();

                app.Quit();

                LLFCForm LLFCFormObj = new LLFCForm();
                LLFCFormObj.FormDownloadFile = Param.Filename;

                returnJSON.FormData = LLFCFormObj;
            }
            catch (Exception ex)
            {
                app.Quit();
                returnJSON.Message = $"Error Occured: {ex.Message}";
            }

            return(returnJSON);
        }
Пример #2
0
        public IHttpActionResult GenerateJobOfferForSupervisoryAndRankAndFile(JobOfferForOfficer Param)
        {
            JSON returnJSON = new JSON();

            try
            {
                JobOfferForSupervisoryAndRankAndFileClass jobOfferForSupervisoryAndRankAndFileClass = new JobOfferForSupervisoryAndRankAndFileClass();

                returnJSON = jobOfferForSupervisoryAndRankAndFileClass.GenerateJobOfferForSupervisoryAndRankAndFile(Param);

                var response = ResponseMessage(Response(returnJSON.FormData.FormDownloadFile));

                return(response);
            }
            catch (Exception ex)
            {
                returnJSON.Message = ex.Message;
                return(Json(returnJSON));
            }
        }