Exemple #1
0
        public ActionResult Index(IndexViewModel vm, int?PageIndex)
        {
            vm.searchCondition = new SearchCondition();
            var CustomerListAll = ApplicationConfigHelper.GetProjectUserCustomers(base.UserInfo.ProjectID, base.UserInfo.ID).Where(t => t.StoreType == 2 || t.StoreType == 3);
            var ProjectList     = CustomerListAll.Select(t => new { Value = t.ProjectID, Text = t.ProjectName }).Distinct().Select(c => new SelectListItem()
            {
                Value = c.Value.ToString(), Text = c.Text
            });
            var CustomerList = CustomerListAll.Select(c => new SelectListItem()
            {
                Value = c.CustomerID.ToString(), Text = c.CustomerName
            });

            ViewBag.CustomerList = CustomerList;
            ViewBag.ProjectList  = ProjectList;
            GetTemplateByConditionRequest getTemplateByConditionRequest = new GetTemplateByConditionRequest();

            getTemplateByConditionRequest.SearchCondition = vm.searchCondition;
            getTemplateByConditionRequest.PageSize        = UtilConstants.PAGESIZE;
            getTemplateByConditionRequest.PageIndex       = PageIndex ?? 0;
            var getTemplateByConditionResponse = new TemplateManagementService().GetTemplateByCondition(getTemplateByConditionRequest);

            if (getTemplateByConditionResponse.IsSuccess)
            {
                vm.TemplateCollection = getTemplateByConditionResponse.Result.TemplateCollection;
                vm.PageIndex          = getTemplateByConditionResponse.Result.PageIndex;
                vm.PageCount          = getTemplateByConditionResponse.Result.PageCount;
            }
            return(View(vm));
        }
Exemple #2
0
        public void SetUp()
        {
            ServiceLocatorInitializer.Init();

            templateRepository =
                MockRepository.GenerateMock <ITemplateRepository>();
            templateRepository.Stub(r => r.DbContext)
            .Return(MockRepository.GenerateMock <IDbContext>());

            templateManagementService =
                new TemplateManagementService(templateRepository);
        }
        /// <summary>
        /// Install the "TriTech Default" Templates into the Agency
        /// </summary>
        private static void UpdateTriTechDefaultTemplatesInAgency(Domain.Administration.Aggregates.Agency.Agency agency,
                                                                  IAdministrationUnitOfWork admin, IMetadataUnitOfWork meta)
        {
            Log.Info("Processing TriTech Default Templates for {0}", agency.Jurisdiction.Ori);

            // Create a Template Manager Service Instance
            var templateManager = new TemplateManagementService(admin, meta);

            // Create or Update the TriTech Default Template for all Modules.
            foreach (var dataEntryContract in meta.GetAllDataEntryContracts())
            {
                // Get the "TriTech Default" Template Name
                var defaultTemplateName = DataEntryContractInspector.GetContractNameForModule(dataEntryContract.ModuleType);

                // Find or Create the Default Template
                var triTechDefaultTemplate = agency.GetTemplate(dataEntryContract.ModuleType, defaultTemplateName);
                if (triTechDefaultTemplate == null)
                {
                    Log.Info("Installing {0}", defaultTemplateName);

                    // Create the TriTech Default Template.
                    triTechDefaultTemplate = agency.CreateTemplate(dataEntryContract.Id, dataEntryContract.ModuleType, defaultTemplateName);

                    // Set the Template Workflow [Until the Concept of a "Default" workflow is defined this is the best we can do.]
                    triTechDefaultTemplate.SetWorkflow(agency.Workflows.First());

                    // Assign all roles to the Template
                    agency.Roles.ForEach(x => triTechDefaultTemplate.AssignRole(x));
                }
                else
                {
                    Log.Info("Updating {0} ", defaultTemplateName);
                }

                // Reset the Template Layout
                templateManager.ResetTemplateLayout(triTechDefaultTemplate);

                // Load the Template Layout from the Metadata
                templateManager.LoadFromMeta(triTechDefaultTemplate, dataEntryContract);
            }
        }
Exemple #4
0
        public ActionResult TemplateCreate(string TableName, string TableNameCH, string ProjectName, string CustomerName, long ProjectID = 0, long CustomerID = 0)
        {
            IndexViewModel vm = new IndexViewModel();

            vm.searchCondition              = new SearchCondition();
            vm.searchCondition.ProjectID    = ProjectID;
            vm.searchCondition.CustomerID   = CustomerID;
            vm.searchCondition.ProjectName  = ProjectName;
            vm.searchCondition.CustomerName = CustomerName;
            vm.searchCondition.TableName    = TableName;
            vm.searchCondition.TableNameCH  = TableNameCH;
            GetTemplateByConditionRequest getTemplateByConditionRequest = new GetTemplateByConditionRequest();

            getTemplateByConditionRequest.SearchCondition = vm.searchCondition;
            var getTemplateDetailByConditionResponse = new TemplateManagementService().GetTemplateDetailByCondition(getTemplateByConditionRequest);

            if (getTemplateDetailByConditionResponse.IsSuccess)
            {
                vm.TemplateCollection = getTemplateDetailByConditionResponse.Result.TemplateCollection;
            }
            return(View(vm));
        }
Exemple #5
0
        public string TemplateCreate(string jsonString, long ProjectID, long CustomerID, string TableName)
        {
            string s = "";
            JavaScriptSerializer          Serializer = new JavaScriptSerializer();
            List <TableColumn>            objs       = Serializer.Deserialize <List <TableColumn> >(jsonString);
            GetTemplateByConditionRequest getTemplateByConditionRequest = new GetTemplateByConditionRequest();

            getTemplateByConditionRequest.tableColumns = objs;
            SearchCondition serch = new SearchCondition();

            serch.ProjectID  = ProjectID;
            serch.CustomerID = CustomerID;
            serch.TableName  = TableName;
            getTemplateByConditionRequest.SearchCondition = serch;
            var Responses = new TemplateManagementService().EditTemplateDetail(getTemplateByConditionRequest);

            if (Responses.IsSuccess)
            {
                s = Responses.Result;
                ApplicationConfigHelper.RefreshGetApplicationConfigNew(ProjectID, CustomerID);
            }
            return(s);
        }
        private static void InstallOrUpdateTemplatesInAgency(Domain.Administration.Aggregates.Agency.Agency agency,
                                                             string implementation, IAdministrationUnitOfWork admin, IMetadataUnitOfWork meta)
        {
            Log.Info("Processing {0} templates for {1}", implementation, agency.Jurisdiction.Ori);

            // Template Manager Service Instance
            var templateManager       = new TemplateManagementService(admin, meta);
            var templateLayoutService = new TemplateLayoutService(admin, meta);

            // Load All the Metadata
            var dataEntryContracts = meta.GetAllDataEntryContracts();

            // Load All the Template Layouts
            var templateLayouts = LoadTemplateLayoutsFromFolder(TemplateFolder);

            // Setup the Default Templates for Each DataEntryContract defined in the Metadata
            foreach (var contract in dataEntryContracts)
            {
                // Find any layouts defined for the Implementation
                var impTemplateLayouts = templateLayouts.Where(t => t.ModuleType == contract.ModuleType && t.Implementation == implementation).ToList();

                // If none are defined use the "Generic" templates
                if (impTemplateLayouts.Count == 0)
                {
                    impTemplateLayouts = templateLayouts.Where(t => t.ModuleType == contract.ModuleType && t.Implementation == StateImplementations.Generic).ToList();
                }

                // Setup the Templates in the Agency
                foreach (var templateLayout in impTemplateLayouts)
                {
                    // Find or Create the Template
                    var agencyTemplate = agency.GetTemplate(templateLayout.ModuleType, templateLayout.Name);
                    if (agencyTemplate == null)
                    {
                        Log.Info("Installing {0}", templateLayout.Name);
                        agencyTemplate = agency.CreateTemplate(contract.Id, contract.ModuleType, templateLayout.Name);

                        // TODO: This assumes the First Workflow is the Correct Workflow
                        agencyTemplate.SetWorkflow(agency.Workflows.First());

                        // Make the Template Active
                        agencyTemplate.MakeActive();

                        // Assign all roles to the Template
                        agency.Roles.ForEach(x => agencyTemplate.AssignRole(x));

                        // Determine if the template should be set as the Agency Default
                        var templateIsDefault = templateLayout.IsDefault ||    // Template is Explicitly Marked as a Default.
                                                impTemplateLayouts.Count == 1; // There is only one template being installed for this contract.

                        // Set the template as the Agency Default
                        if (templateIsDefault)
                        {
                            agency.SetDefaultTemplate(agencyTemplate);
                        }
                    }
                    else
                    {
                        Log.Info("Updating {0}", templateLayout.Name);

                        // Reset the Template
                        templateManager.ResetTemplateLayout(agencyTemplate);
                    }

                    // Load the Template Layout Information
                    templateLayoutService.LoadLayout(templateLayout, agencyTemplate);
                }
            }
        }