Ejemplo n.º 1
0
        public void TestInitilize()
        {
            #region Test Data

            _templateRows = new List <TemplateRow>
            {
                UnitTestHelper.GenerateRandomData <TemplateRow>(x =>
                {
                    x.Id            = 1;
                    x.ServiceDomain = "Service Domain A";
                    x.TemplateId    = 1;
                }),
                UnitTestHelper.GenerateRandomData <TemplateRow>(x =>
                {
                    x.Id            = 2;
                    x.ServiceDomain = "Service Domain B";
                    x.TemplateId    = 1;
                }),
                UnitTestHelper.GenerateRandomData <TemplateRow>(x =>
                {
                    x.Id            = 3;
                    x.ServiceDomain = "Service Domain C";
                    x.TemplateId    = 1;
                }),
            };

            _templateDomainListItems = new List <TemplateDomainListItem>
            {
                new TemplateDomainListItem
                {
                    Id         = 1,
                    DomainName = "Service Domain A",
                    TemplateId = 1
                },
                new TemplateDomainListItem
                {
                    Id         = 2,
                    DomainName = "Service Domain B",
                    TemplateId = 1
                }
            };

            #endregion

            _mockTemplateRowRepository = MockRepositoryHelper.Create(_templateRows);
            _mockRepositoryTransaction = new Mock <IRepositoryTransaction>();

            _mockUnitOfWork = new Mock <IUnitOfWork>();
            _mockUnitOfWork.Setup(s => s.BeginTransaction()).Returns(_mockRepositoryTransaction.Object);
            _mockUnitOfWork.Setup(s => s.CreateConnection()).Returns(new SqlConnection());



            _mockTransformData = new Mock <ITransformTemplateToDesign>();


            _templateProcessor = new TemplateProcessor(_mockTemplateRowRepository.Object,
                                                       _mockTransformData.Object,
                                                       _mockUnitOfWork.Object);
        }
        public OrchardRazorTransform(ITemplateProcessor processor, IContext context = null) : base(context, null)
        {
            if (IsMissingContext())
            {
                return;
            }

            Returns = Context.Field.Type;

            _processor = processor;

            var fields = MultipleInput().ToList();

            _input = fields.Union(Context.Entity.GetFieldMatches(Context.Operation.Template)).ToArray();

            // test it out
            var testObject = new ExpandoObject();
            var dict       = (IDictionary <string, object>)testObject;

            foreach (var field in _input)
            {
                dict[field.Alias] = field.DefaultValue();
            }
            try {
                _processor.Process(Context.Operation.Template, Context.Key, null, testObject);
            } catch (System.Exception ex) {
                Context.Error("Razor error parsing script in {0} field.", Context.Field.Alias);
                Context.Error(ex.Message);
                Utility.CodeToError(Context, Context.Operation.Template);
                Run = false;
            }
        }
        // Wrap template with borders
        public static string WrapTemplate(this ITemplateProcessor processor, string template, bool isRegex = false)
        {
            string leftBorder  = isRegex ? Regex.Escape(processor.LeftTemplateBorder) : processor.LeftTemplateBorder;
            string rightBorder = isRegex ? Regex.Escape(processor.RightTemplateBorder) : processor.RightTemplateBorder;

            return($"{leftBorder}{template}{rightBorder}");
        }
Ejemplo n.º 4
0
 public FunctionResolvingMethod(ITemplateProcessor TemplateProcessor)
 {
     _functions =
         new Dictionary <string, IResolvingFunction>
     {
         { "expand", new ExpandFunction(TemplateProcessor) }
     };
 }
 // Regex pattern that includes all member types
 public static string GetFullRegexPattern(this ITemplateProcessor processor)
 {
     return(GetRegexPattern(processor, $"({Regex.Escape(processor.PropertyMemberLabel)}" +
                            $"|{Regex.Escape(processor.DataItemMemberLabel)}" +
                            $"|{Regex.Escape(processor.MethodCallMemberLabel)}" +
                            $"|{Regex.Escape(processor.SystemVariableMemberLabel)}" +
                            $"|{Regex.Escape(processor.SystemFunctionMemberLabel)})"));
 }
Ejemplo n.º 6
0
        public TemplateService(FormlyDbContext context, ITemplateProcessor templateProcessor)
        {
            Check.Assigned(context, nameof(context));
            Check.Assigned(templateProcessor, nameof(templateProcessor));

            mContext           = context;
            mTemplateProcessor = templateProcessor;
        }
Ejemplo n.º 7
0
        private void print_Click(object sender, EventArgs e)
        {
            saveObject();
            ITemplateProcessor processor = TemplateProcessorManager.getProcessorByObjectType(DdtEpicrisis.NAME);
            string             path      = processor.processTemplate(service, hospitalitySession.ObjectId, objectId, new Dictionary <string, string>());

            TemplatesUtils.ShowDocument(path);
        }
Ejemplo n.º 8
0
        public TemplateController(ITemplateService templateService, ITemplateProcessor templateProcessor)
        {
            Check.Assigned(templateService, nameof(templateService));
            Check.Assigned(templateProcessor, nameof(templateProcessor));

            mTemplateService   = templateService;
            mTemplateProcessor = templateProcessor;
        }
Ejemplo n.º 9
0
 public RunTimeExecuter(IContext context,
                        IAppDataFolder appDataFolder,
                        ITemplateProcessor templateProcessor
                        )
 {
     _appDataFolder     = appDataFolder;
     _templateProcessor = templateProcessor;
     _context           = context;
 }
 public virtual ITemplateContext BuildTemplateContext(IFileSystem fileSystem,
     ITemplateProcessor templateProcessor, IProjectEnvironment environment)
 {
     ITemplateContext context = templateProcessor.CreateTemplateContext();
     context.Items[PROJECT_KEY] = environment.ProjectName;
     context.Items[DIRECTORY_KEY] = environment.ProjectDirectory;
     context.Items[DIRECTORY_SEPARATOR_KEY] = fileSystem.DirectorySeparatorChar;
     return context;
 }
Ejemplo n.º 11
0
 public FileModule(Process process,
                   IAppDataFolder appDataFolder,
                   ITemplateProcessor templateProcessor
                   )
 {
     _process           = process;
     _appDataFolder     = appDataFolder;
     _templateProcessor = templateProcessor;
 }
Ejemplo n.º 12
0
 private void printBtn_Click(object sender, EventArgs e)
 {
     if (Save())
     {
         ITemplateProcessor processor = TemplateProcessorManager.getProcessorByObjectType(DdtJournal.NAME);
         string             path      = processor.processTemplate(service, hospitalitySession.ObjectId, journalDayId, null);
         TemplatesUtils.ShowDocument(path);
     }
 }
Ejemplo n.º 13
0
        public void TemplateProcessor_Contructor_NoTemplateRowRepository_ThrowsException()
        {
            #region Arrange

            _templateProcessor = new TemplateProcessor(null,
                                                       _mockTransformData.Object,
                                                       _mockUnitOfWork.Object);

            #endregion
        }
Ejemplo n.º 14
0
 public IPropertiesResolver GetPropertiesResolver(ITemplateProcessor TemplateProcessor)
 {
     return(new PropertiesResolver(new Dictionary <string, IResolvingMethod>
     {
         { string.Empty, new InternalDictionaryResolvingMethod() },
         { "global", new DictionaryResolvingMethod(_globalProperties) },
         { "function", new FunctionResolvingMethod(TemplateProcessor) },
         { "parent", new ParentPropertyResolvingMethod() }
     }));
 }
 public RunTimeDataReader(
     IPipelineLogger logger,
     IAppDataFolder appDataFolder,
     ITemplateProcessor templateProcessor,
     INotifier notifier)
 {
     _logger            = logger;
     _appDataFolder     = appDataFolder;
     _templateProcessor = templateProcessor;
     _notifier          = notifier;
 }
Ejemplo n.º 16
0
        public CodeGenCommand(ILogger logger,
                              ITemplateLocator templateLocator,
                              ITemplateDataProviderLocator dataProviderLocator,
                              ITemplateProcessor templateProcessor)

        {
            _logger              = logger ?? throw new ArgumentNullException(nameof(logger));
            _templateLocator     = templateLocator ?? throw new ArgumentNullException(nameof(templateLocator));
            _dataProviderLocator = dataProviderLocator ?? throw new ArgumentNullException(nameof(dataProviderLocator));
            _templateProcessor   = templateProcessor ?? throw new ArgumentNullException(nameof(templateProcessor));
        }
Ejemplo n.º 17
0
        private void requestBtnClik(object sender, EventArgs e)
        {
            Save();
            ITemplateProcessor processor = TemplateProcessorManager.getProcessorByObjectType("request_blood");

            if (processor != null)
            {
                string path = processor.processTemplate(service, hospitalSession?.ObjectId, transfusion?.ObjectId, new Dictionary <string, string>());
                TemplatesUtils.ShowDocument(path);
            }
        }
Ejemplo n.º 18
0
 public OrchardRazorTemplateEngine(
     IContext context,
     ITemplateProcessor templateProcessor,
     Transformalize.Configuration.Template template,
     IReader templateReader)
 {
     _context           = context;
     _templateProcessor = templateProcessor;
     _template          = template;
     _templateReader    = templateReader;
 }
Ejemplo n.º 19
0
 public RunTimeSchemaReader(
     IContext host,
     IAppDataFolder appDataFolder,
     ITemplateProcessor templateProcessor,
     INotifier notifier)
 {
     _host              = host;
     _appDataFolder     = appDataFolder;
     _templateProcessor = templateProcessor;
     _notifier          = notifier;
 }
Ejemplo n.º 20
0
 public RunTimeRunner(IContext context,
                      IAppDataFolder appDataFolder,
                      ITemplateProcessor templateProcessor,
                      INotifier notifier
                      )
 {
     _context           = context;
     _appDataFolder     = appDataFolder;
     _templateProcessor = templateProcessor;
     _notifier          = notifier;
 }
Ejemplo n.º 21
0
 public OrchardRazorTemplateEngine(
     PipelineContext context,
     ITemplateProcessor templateProcessor,
     Configuration.Template template,
     IReader templateReader)
 {
     _context           = context;
     _templateProcessor = templateProcessor;
     _template          = template;
     _templateReader    = templateReader;
 }
Ejemplo n.º 22
0
 private void printBtn_Click(object sender, EventArgs e)
 {
     if (Save())
     {
         ITemplateProcessor processor = TemplateProcessorManager.getProcessorByObjectType(DdtConsilium.NAME);
         if (processor != null)
         {
             string path = processor.processTemplate(service, hospitalitySession.ObjectId, consiliumId, new Dictionary <string, string>());
             TemplatesUtils.ShowDocument(path);
         }
     }
 }
Ejemplo n.º 23
0
 public AuthController(IAuthService authService,
                       ISenderService senderService,
                       ITemplateProcessor templateProcessor,
                       IDistributedCache cache,
                       ILogger <AuthController> logger)
 {
     _authService       = authService;
     _senderService     = senderService;
     _templateProcessor = templateProcessor;
     _cache             = cache;
     _logger            = logger;
 }
Ejemplo n.º 24
0
 public Handler(
     IFileSystem fileSystem,
     ITemplateLocator templateLocator,
     ITemplateProcessor templateProcessor,
     ICommandService commandService
     )
 {
     _fileSystem        = fileSystem;
     _templateProcessor = templateProcessor;
     _templateLocator   = templateLocator;
     _commandService    = commandService;
 }
 public Handler(
     IFileWriter fileWriter,
     INamingConventionConverter namingConventionConverter,
     ITemplateLocator templateLocator,
     ITemplateProcessor templateProcessor
     )
 {
     _fileWriter = fileWriter;
     _namingConventionConverter = namingConventionConverter;
     _templateProcessor         = templateProcessor;
     _templateLocator           = templateLocator;
 }
Ejemplo n.º 26
0
 public Handler(
     IFileSystem fileWriter,
     ITemplateProcessor templateProcessor,
     INamingConventionConverter namingConventionConverter,
     ISettingsProvider settingsProvider
     )
 {
     _fileWriter                = fileWriter;
     _templateProcessor         = templateProcessor;
     _namingConventionConverter = namingConventionConverter;
     _settingsProvider          = settingsProvider;
 }
Ejemplo n.º 27
0
        private void printBtn_Click(object sender, EventArgs e)
        {
            int           rowCount = patientHistoryGrid.Rows.Count;
            DdvPatient    patient  = service.GetDdvPatientService().GetById(hospitalitySession.Patient);
            List <string> paths    = new List <string>();

            if (printTitlePage.Checked)
            {
                List <string> prePaths = new List <string>();
                Dictionary <string, string> titleDict = new Dictionary <string, string>();
                titleDict.Add("{mednumber}", patient.MedCode);
                titleDict.Add("{admission_date}", hospitalitySession.AdmissionDate.ToShortDateString());
                titleDict.Add("{leaving_date}", DateTime.Now.ToShortDateString());
                titleDict.Add("{med_policy}", patient.Oms);
                titleDict.Add("{room}", hospitalitySession.RoomCell);
                titleDict.Add("{daysinhospital}", (DateTime.Now.Year - hospitalitySession.AdmissionDate.Year) + "");
                DdtSerology serology = service.GetDdtSerologyService().GetByHospitalSession(hospitalitySession.ObjectId);
                titleDict.Add("{blood_n}", serology?.BloodType);
                titleDict.Add("{rhesus}", serology?.RhesusFactor);
                titleDict.Add("{height}", patient.High + "");
                titleDict.Add("{weight}", patient.Weight + "");
                titleDict.Add("{patient_full_name}", patient.FullName);
                titleDict.Add("{sex}", patient.Sex ? "мужской" : "женский");
                titleDict.Add("{passport}", patient.PassportSerial + " " + patient.PassportNum + " " + patient.PassportIssuePlace + " " + patient.PassportDate.ToShortDateString());
                titleDict.Add("{age}", (DateTime.Now.Year - patient.Birthdate.Year) + "");
                titleDict.Add("{birthdate}", patient.Birthdate.ToShortDateString());
                titleDict.Add("{address}", patient.Address);
                DdtAnamnesis firstIspection = service.GetDdtAnamnesisService().GetByHospitalSessionId(hospitalitySession.ObjectId);
                titleDict.Add("{diagnosis_first}", firstIspection?.Diagnosis);
                titleDict.Add("{diagnosis_last}", hospitalitySession.Diagnosis);

                prePaths.Add(TemplatesUtils.FillTemplate(Directory.GetCurrentDirectory() + "\\Templates\\" + "title.docx", titleDict));
                paths.Add(TemplatesUtils.MergeFiles(prePaths.ToArray(), true, null));
            }
            foreach (DataGridViewRow row in patientHistoryGrid.Rows)
            {
                bool checkd = (bool)row.Cells[0].Value;
                if (checkd)
                {
                    ITemplateProcessor te = TemplateProcessorManager.getProcessorByObjectType((string)row.Cells[2].Value);
                    if (te != null)
                    {
                        string pathFile = te.processTemplate(service, hospitalitySession.ObjectId, (string)row.Cells[3].Value, null);
                        paths.Add(pathFile);
                    }
                }
            }
            string resultFileName = TemplatesUtils.getTempFileName("История болезни", patient.FullName);
            string resultPath     = TemplatesUtils.MergeFiles(paths.ToArray(), false, resultFileName);

            TemplatesUtils.ShowDocument(resultPath);
        }
Ejemplo n.º 28
0
        private void consentBtnClik(object sender, EventArgs e)
        {
            //if (Save())
            //{
            ITemplateProcessor processor = TemplateProcessorManager.getProcessorByObjectType("transfusion_consent");

            if (processor != null)
            {
                string path = processor.processTemplate(service, hospitalSession?.ObjectId, patient?.ObjectId, new Dictionary <string, string>());
                TemplatesUtils.ShowDocument(path);
            }
            //}
        }
Ejemplo n.º 29
0
 public BackgroundTasks(IConnectionStringProvider connectionStringProvider, SpecialFolderProvider specialFolderProvider, RazorTemplateProcessor razorTemplateProcessor, IReportRunner reportRunner, IOptions <Config> configOptions, UserHelpers userHelpers, IEmailServer emailServer, UloDbContext db, IWorkflowManager workflowManager, ILogger <BackgroundTasks> logger, PortalHelpers portalHelpers)
     : base(logger)
 {
     ConnectionStringProvider = connectionStringProvider;
     SpecialFolderProvider    = specialFolderProvider;
     RazorTemplateProcessor   = razorTemplateProcessor;
     ReportRunner             = reportRunner;
     ConfigOptions            = configOptions;
     UserHelpers     = userHelpers;
     EmailServer     = emailServer;
     DB              = db;
     WorkflowManager = workflowManager;
     PortalHelpers   = portalHelpers;
 }
Ejemplo n.º 30
0
        private void printBtn_Click(object sender, EventArgs e)
        {
            if (validate())
            {
                Save();

                ITemplateProcessor processor  = TemplateProcessorManager.getProcessorByObjectType(DdtJournal.NAME);
                string             path       = processor.processTemplate(service, hospitalitySession.ObjectId, journalDayId, null);
                DdvPatient         patient    = service.GetDdvPatientService().GetById(hospitalitySession.Patient);
                string             resultName = TemplatesUtils.getTempFileName("Журнал", patient.FullName);
                string             result     = TemplatesUtils.MergeFiles(new string[] { path }, false, resultName);
                TemplatesUtils.ShowDocument(result);
            }
        }
        public OrchardRazorTransform(ITemplateProcessor processor, IContext context = null) : base(context, null)
        {
            if (IsMissingContext())
            {
                return;
            }

            Returns = Context.Field.Type;

            _processor = processor;

            var fields = MultipleInput().ToList();

            _input = fields.Union(Context.Entity.GetFieldMatches(Context.Operation.Template)).ToArray();
        }
Ejemplo n.º 32
0
 public FileTransformationElement(ITemplateProcessor processor, IFileSystem fileSystem, IProjectManifestRepository manifestRepository)
 {
     _processor = processor;
     _fileSystem = fileSystem;
     _manifestRepository = manifestRepository;
 }
Ejemplo n.º 33
0
 protected override void Before_each_spec()
 {
     processor = new NVelocityTemplateProcessor();
     context = processor.CreateTemplateContext();
 }