Esempio n. 1
0
        public void Initilize(IUnitOfWork uow)
        {
            SubjectFacade subjectFacade = new SubjectFacade(uow);

            SubjectList = subjectFacade.GetSubjectList();

            DomainFacade domainFacade = new DomainFacade(uow);

            DomainSettingList = domainFacade.GetDomainSettingList();

            ApplicationSettingFacade settingFacade = new ApplicationSettingFacade(uow);

            ApplicationOption = settingFacade.GetApplicationOption();

            LanguageFacade languageFacade = new LanguageFacade(uow);

            LanguageDic          = languageFacade.RetrievePublishedLanguagesAndPhrases(ApplicationOption.IsMultiLanguageSupported);
            LanguageDicByCulture = new Dictionary <string, LanguageDto>();
            foreach (var language in LanguageDic.Values)
            {
                LanguageDicByCulture.Add(language.Culture, language);
            }

            DefaultLanguage = LanguageDic[ApplicationOption.DefaultLanguageId];

            SetupEmailSender(ApplicationOption);

            SetupNotificationtemplate(uow);
        }
Esempio n. 2
0
        private void SaveAsSystemPhrases(ExcelImportEventArgs arg)
        {
            ExcelSheet excelSheet = arg.Result;
            // Extract data from imported Excel sheet
            List <LanguagePhraseDto> languagePhrases = new List <LanguagePhraseDto>();

            for (int index = excelSheet.DataStartRowIndex; index < excelSheet.Rows.Count; index++)
            {
                ExcelSheetRow     excelRow       = excelSheet.Rows[index];
                LanguagePhraseDto languagePhrase = new LanguagePhraseDto();
                languagePhrases.Add(languagePhrase);
                languagePhrase.PhraseKey   = excelRow.GetValue(Col_Key);
                languagePhrase.PhraseValue = excelRow.GetValue(Col_Value);
            }

            // Save batch
            using (IUnitOfWork uow = UnitOfWorkFactory.Instance.Start(DataStoreResolver.CRMDataStoreKey))
            {
                LanguageFacade facade = new LanguageFacade(uow);
                IFacadeUpdateResult <LanguagePhraseData> result = facade.SaveSystemPhrases(SelectedLanguageId, languagePhrases);
                if (result.IsSuccessful)
                {
                    arg.IsSuccessful = true;
                    arg.Message      = string.Format("Batch save done. \\nTotal {0} rows.", languagePhrases.Count);
                }
                else
                {
                    arg.IsSuccessful = false;
                    // Deal with Update result
                    ProcUpdateResult(result.ValidationResult, result.Exception);
                }
            }
        }
Esempio n. 3
0
        private IList <BindingListItem> GetBindingList(string subjectType, IUnitOfWork unitOfWork)
        {
            IList <BindingListItem> dataSource = null;

            switch ((InstanceTypes)Enum.Parse(typeof(InstanceTypes), subjectType))
            {
            case InstanceTypes.Language:
                LanguageFacade languageFacade = new LanguageFacade(unitOfWork);
                dataSource = languageFacade.GetBindingList();
                break;

            case InstanceTypes.Location:
                LocationFacade locationFacade = new LocationFacade(unitOfWork);
                dataSource = locationFacade.GetBindingList();
                break;

            case InstanceTypes.Folder:
                FolderFacade folderFacade = new FolderFacade(unitOfWork);
                dataSource = folderFacade.GetBindingList();
                break;

            case InstanceTypes.Reference:
                ReferenceFacade referenceFacade = new ReferenceFacade(unitOfWork);
                dataSource = referenceFacade.GetBindingList();
                break;
            }

            return(dataSource);
        }
 private void RetrieveData()
 {
     using (IUnitOfWork uow = UnitOfWorkFactory.Instance.Start(DataStoreResolver.CRMDataStoreKey))
     {
         LanguageFacade facade = new LanguageFacade(uow);
         Sheet = facade.CreateSystemPhraseSheet(WebContext.Current.ApplicationOption.DefaultLanguageId);
     }
 }
 private void RetrieveData()
 {
     using (IUnitOfWork uow = UnitOfWorkFactory.Instance.Start(DataStoreResolver.CRMDataStoreKey))
     {
         LanguageFacade facade = new LanguageFacade(uow);
         Sheet = facade.GetMenuPhraseSheet();
     }
 }
Esempio n. 6
0
 public IEnumerable <LanguageDto> GetLanguages()
 {
     using (IUnitOfWork uow = UnitOfWorkFactory.Instance.Start(DataStoreResolver.CMSDataStoreKey))
     {
         LanguageFacade            languageFacade = new LanguageFacade(uow);
         IEnumerable <LanguageDto> result         = languageFacade.RetrieveAllLanguage(new LanguageConverter());
         return(result);
     }
 }
Esempio n. 7
0
 public void Should_return_model_for_admin()
 {
     using (var context = new MSSQLDbContext(_contextOptions))
     {
         var facade = new LanguageFacade(DbContextShared.CreateNewContextFactory(context), new Mock <ICacheManager>().Object, Shared.CreateNewMapper());
         var model  = facade.GetForAdminAsync(_siteId, _languageId);
         Assert.NotNull(model);
     }
 }
 private void RetrieveData()
 {
     using (IUnitOfWork uow = UnitOfWorkFactory.Instance.Start(DataStoreResolver.CRMDataStoreKey))
     {
         LanguageKeyFacade           keyFacade = new LanguageKeyFacade(uow);
         Dictionary <string, string> phrases   = keyFacade.GetCategoryLanguagePhrasesKeyValue();
         LanguageFacade facade = new LanguageFacade(uow);
         Sheet = facade.CreateDataPhraseSheet(phrases);
     }
 }
Esempio n. 9
0
        public async Task Should_return_all_models_for_admin()
        {
            using (var context = new MSSQLDbContext(_contextOptions))
            {
                var facade = new LanguageFacade(DbContextShared.CreateNewContextFactory(context), new Mock <ICacheManager>().Object, Shared.CreateNewMapper());
                var models = await facade.GetAllForAdminAsync(_siteId);

                Assert.IsNotEmpty(models);
            }
        }
Esempio n. 10
0
        private void LoadDDL()
        {
            using (IUnitOfWork uow = UnitOfWorkFactory.Instance.Start(DataStoreResolver.CRMDataStoreKey))
            {
                LanguageFacade facade = new LanguageFacade(uow);
                ddlLanguage.DataSource = facade.GetBindingList();
            }

            ddlLanguage.DataValueField = BindingListItem.ValueProperty;
            ddlLanguage.DataTextField  = BindingListItem.TextProperty;
            ddlLanguage.DataBind();
        }
Esempio n. 11
0
        public static string FindDocument()
        {
            int filtersSet = 0;

            HttpRequest request = HttpContext.Current.Request;


            // Check at least 1 filter set.
            foreach (string name in request.Form.AllKeys)
            {
                // Process all checkboxes - excluding non-filter checkboxes.
                string value = request.Form[name];
                if (name != FundControls.ToggleFilters && name != FundControls.DocumentTextbox && name != SharedControls.CurrentLanguage)
                {
                    filtersSet++;
                }
                // Validate textboxes.
                else if (name == FundControls.DocumentTextbox && !string.IsNullOrEmpty(value))
                {
                    filtersSet++;
                }
            }


            var currentLangauge = request.Form[SharedControls.CurrentLanguage] ?? Languages.English;

            if (filtersSet == 0)
            {
                var msg = LanguageFacade.DictionaryItem("nodocumentfound", currentLangauge);

                return(string.Format("<span>{0}</span>", msg));
            }
            else
            {
                // Setup document filters for documents results page in Session.
                Dictionary <string, string> finddocumentParams = request.Form.AllKeys.ToDictionary(key => key, key => request.Form[key]);
                HttpContext.Current.Session[SessionKeys.FindDocumentParams] = finddocumentParams;

                // TBD: response.redirect crashes the browser.
                // HttpResponse response = HttpContext.Current.Response;
                //response.Redirect("/en/funddocuments.aspx",false);
                // TBD: Seerver transfer gives an ajax error that the url does not exist.
                //HttpContext.Current.Server.Transfer("/en/funddocuments.aspx", true);

                // Complete the Ajax call, and redirect on the client.
                return(string.Format(URLs.FundDocuments, currentLangauge));
            }
        }
Esempio n. 12
0
        public void Initilize(IUnitOfWork uow)
        {
            SubjectFacade subjectFacade = new SubjectFacade(uow);

            SubjectList = subjectFacade.GetSubjectList();

            DomainFacade domainFacade = new DomainFacade(uow);

            DomainSettingList = domainFacade.GetDomainSettingList();

            ApplicationSettingFacade settingFacade = new ApplicationSettingFacade(uow);

            ApplicationOption = settingFacade.GetApplicationOption();

            LanguageFacade languageFacade = new LanguageFacade(uow);

            LanguageList = languageFacade.RetrievePublishedLanguagesAndPhrases(ApplicationOption.IsMultiLanguageSupported);

            SetupEmailSender(ApplicationOption);

            SetupNotificationtemplate(uow);
        }
Esempio n. 13
0
        private IList <BindingListItem> GetBindingList(string subjectType)
        {
            IList <BindingListItem> dataSource = null;

            switch ((InstanceTypes)Enum.Parse(typeof(InstanceTypes), subjectType))
            {
            case InstanceTypes.Customer:
                CustomerSystem sys = new CustomerSystem(UnitOfWork);
                dataSource = sys.GetBindingList();
                break;

            case InstanceTypes.Contact:
                ContactSystem contactSystem = new ContactSystem(UnitOfWork);
                dataSource = contactSystem.GetBindingList();
                break;

            case InstanceTypes.Product:
                ProductSystem productSystem = new ProductSystem(UnitOfWork);
                dataSource = productSystem.GetBindingList();
                break;

            case InstanceTypes.Supplier:
                SupplierSystem supplierSystem = new SupplierSystem(UnitOfWork);
                dataSource = supplierSystem.GetBindingList();
                break;

            case InstanceTypes.Catalog:
                CatalogSystem catalogSystem = new CatalogSystem(UnitOfWork);
                dataSource = catalogSystem.GetBindingList();
                break;

            case InstanceTypes.Employee:
                EmployeeSystem employeeSystem = new EmployeeSystem(UnitOfWork);
                dataSource = employeeSystem.GetBindingList();
                break;

            case InstanceTypes.Document:
                DocumentSystem docSystem = new DocumentSystem(UnitOfWork);
                dataSource = docSystem.GetBindingList();
                break;

            case InstanceTypes.User:
                UserFacade facade = new UserFacade(UnitOfWork);
                dataSource = facade.GetBindingList();
                break;

            case InstanceTypes.Language:
                LanguageFacade languageFacade = new LanguageFacade(UnitOfWork);
                dataSource = languageFacade.GetBindingList();
                break;

            case InstanceTypes.Domain:
                DomainFacade domainFacade = new DomainFacade(UnitOfWork);
                dataSource = domainFacade.GetBindingList();
                break;

            case InstanceTypes.MainMenu:
                MainMenuFacade mainMenuFacade = new MainMenuFacade(UnitOfWork);
                dataSource = mainMenuFacade.GetBindingList();
                break;

            case InstanceTypes.SetupMenu:
                SetupMenuFacade setupMenuFacade = new SetupMenuFacade(UnitOfWork);
                dataSource = setupMenuFacade.GetBindingList();
                break;

            case InstanceTypes.ShipTo:
                ShipToFacade shipTofacade = new ShipToFacade(UnitOfWork);
                dataSource = shipTofacade.GetBindingList();
                break;

            case InstanceTypes.SellingPeriod:
                SellingPeriodFacade sellingPeriodfacade = new SellingPeriodFacade(UnitOfWork);
                dataSource = sellingPeriodfacade.GetBindingList();
                break;

            case InstanceTypes.UserMatch:
                dataSource = GetUserMatch();
                break;
            }

            return(dataSource);
        }
Esempio n. 14
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            // ===== Temporary ===== //
            CheckIfDeafultAppsHaveBeenInstalled();
            CheckIfDeafultSiteHasBeenInstalled();
            CheckIfAdminUserHasBeenCreated();
            // ==================== //

            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseApplicationInsightsRequestTelemetry();

            app.UseStatusCodePagesWithRedirects("~/error/{0}");

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/error/500");
            }

            app.UseApplicationInsightsExceptionTelemetry();

            app.UseStaticFiles();

            app.UseIdentity();

            // Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715

            var site            = SiteRepository.GetByName("Default");
            var activeLanguages = LanguageFacade.GetAllActive(site.Id);

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "area",
                    template: "{area:exists}/{controller=Home}/{action=Index}/{id?}");

                if (site != null)
                {
                    foreach (var page in PageFacade.GetAllForAdminAsync(site.Id).Result)
                    {
                        var defaults    = new RouteValueDictionary();
                        var constraints = new RouteValueDictionary();
                        var tokens      = new RouteValueDictionary();

                        defaults.Add("controller", "Home");
                        defaults.Add("action", "Index");
                        defaults.Add("data", string.Empty);

                        constraints.Add("data", @"[a-zA-Z0-9\-]*");

                        tokens.Add("namespaces", new[] { "Weapsy.Controllers" });
                        tokens.Add(ContextKeys.PageKey, page.Id);
                        //tokens.Add("languageId", default language id);

                        routes.MapRoute(
                            name: page.Name,
                            template: page.Url,
                            defaults: defaults,
                            constraints: constraints,
                            dataTokens: tokens);

                        foreach (var language in activeLanguages)
                        {
                            if (tokens.ContainsKey(ContextKeys.LanguageKey))
                            {
                                tokens.Remove(ContextKeys.LanguageKey);
                            }

                            tokens.Add(ContextKeys.LanguageKey, language.Id);

                            var pageLocalisation = page.PageLocalisations.FirstOrDefault(x => x.LanguageId == language.Id);

                            var url = (pageLocalisation != null && !string.IsNullOrWhiteSpace(pageLocalisation.Url))
                                ? pageLocalisation.Url
                                : page.Url;

                            routes.MapRoute(
                                name: $"{page.Name} - {language.Name}",
                                template: $"{language.Url}/{url}",
                                defaults: defaults,
                                constraints: constraints,
                                dataTokens: tokens);
                        }
                    }
                }

                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            var            supportedCultures = new List <CultureInfo>();
            RequestCulture defaultRequestCulture;

            try
            {
                foreach (var language in activeLanguages)
                {
                    supportedCultures.Add(new CultureInfo(language.CultureName));
                }

                defaultRequestCulture = new RequestCulture(supportedCultures[0].Name);
            }
            catch (Exception)
            {
                supportedCultures.Add(new CultureInfo("en"));
                defaultRequestCulture = new RequestCulture("en");
            }

            app.UseRequestLocalization(new RequestLocalizationOptions
            {
                DefaultRequestCulture = defaultRequestCulture,
                SupportedCultures     = supportedCultures,
                SupportedUICultures   = supportedCultures
            });
        }
 public LanguageController(LanguageFacade languageFacade, Container container) : base(container)
 {
     this.languageFacade = languageFacade;
 }