Esempio n. 1
0
        private void initializeCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            IUser newUser = DataFacade.BuildNew <IUser>();

            newUser.Id = Guid.NewGuid();

            var userFormLogin = DataFacade.BuildNew <IUserFormLogin>();

            userFormLogin.PasswordHash     = "";
            userFormLogin.PasswordHashSalt = "";


            var groupEntityToken = this.EntityToken as UserElementProviderGroupEntityToken;

            if (groupEntityToken != null)
            {
                userFormLogin.Folder = groupEntityToken.Id;
            }

            CultureInfo userCulture         = UserSettings.CultureInfo;         // Copy admins settings
            CultureInfo c1ConsoleUiLanguage = UserSettings.C1ConsoleUiLanguage; // Copy admins settings

            List <KeyValuePair>         regionLanguageList = StringResourceSystemFacade.GetSupportedCulturesList();
            Dictionary <string, string> culturesDictionary = StringResourceSystemFacade.GetAllCultures();

            this.Bindings.Add(BindingNames.NewUser, newUser);
            this.Bindings.Add(BindingNames.UserFormLogin, userFormLogin);

            this.Bindings.Add("AllCultures", culturesDictionary);
            this.Bindings.Add("CultureName", userCulture.Name);

            this.Bindings.Add("C1ConsoleUiCultures", regionLanguageList);
            this.Bindings.Add("C1ConsoleUiLanguageName", c1ConsoleUiLanguage.Name);
        }
Esempio n. 2
0
        private void stepInitialize_codeActivity_ExecuteCode(object sender, EventArgs e)
        {
            CultureInfo userCulture         = UserSettings.CultureInfo;         // Copy admins settings
            CultureInfo c1ConsoleUiLanguage = UserSettings.C1ConsoleUiLanguage; // Copy admins settings

            List <KeyValuePair>         regionLanguageList = StringResourceSystemFacade.GetSupportedCulturesList();
            Dictionary <string, string> culturesDictionary = StringResourceSystemFacade.GetAllCultures();

            this.Bindings.Add("AllCultures", culturesDictionary);
            this.Bindings.Add("CultureName", userCulture.Name);

            this.Bindings.Add("C1ConsoleUiCultures", regionLanguageList);
            this.Bindings.Add("C1ConsoleUiLanguageName", c1ConsoleUiLanguage.Name);
        }
        private void initializeCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            var dataEntityToken = (DataEntityToken)this.EntityToken;

            var user          = (IUser)dataEntityToken.Data;
            var userFormLogin = user.GetUserFormLogin();

            this.Bindings.Add(BindingNames.User, user);
            this.Bindings.Add(BindingNames.UserFormLogin, userFormLogin);
            this.Bindings.Add(BindingNames.NewPassword, NotPassword);

            CultureInfo userCulture         = UserSettings.GetUserCultureInfo(user.Username);
            CultureInfo c1ConsoleUiLanguage = UserSettings.GetUserC1ConsoleUiLanguage(user.Username);

            List <KeyValuePair>         regionLanguageList = StringResourceSystemFacade.GetSupportedCulturesList();
            Dictionary <string, string> culturesDictionary = StringResourceSystemFacade.GetAllCultures();

            this.Bindings.Add("AllCultures", culturesDictionary);
            this.Bindings.Add("CultureName", userCulture.Name);

            this.Bindings.Add("C1ConsoleUiCultures", regionLanguageList);
            this.Bindings.Add("C1ConsoleUiLanguageName", c1ConsoleUiLanguage.Name);

            if (UserSettings.GetActiveLocaleCultureInfos(user.Username).Any() && (user.Username != UserSettings.Username))
            {
                this.Bindings.Add("ActiveLocaleName", UserSettings.GetCurrentActiveLocaleCultureInfo(user.Username).Name);
                this.Bindings.Add("ActiveLocaleList", DataLocalizationFacade.ActiveLocalizationCultures.ToDictionary(f => f.Name, DataLocalizationFacade.GetCultureTitle));
            }

            var clientValidationRules = new Dictionary <string, List <ClientValidationRule> >
            {
                { "Username", ClientValidationRuleFacade.GetClientValidationRules(user, "Username") },
                { "Group", ClientValidationRuleFacade.GetClientValidationRules(user, "Group") }
            };


            IFormMarkupProvider markupProvider = new FormDefinitionFileMarkupProvider(@"\Administrative\EditUserStep1.xml");

            XDocument formDocument;

            using (var reader = markupProvider.GetReader())
            {
                formDocument = XDocument.Load(reader);
            }

            XElement        bindingsElement     = formDocument.Root.Element(DataTypeDescriptorFormsHelper.CmsNamespace + FormKeyTagNames.Bindings);
            XElement        layoutElement       = formDocument.Root.Element(DataTypeDescriptorFormsHelper.CmsNamespace + FormKeyTagNames.Layout);
            XElement        tabPanelsElement    = layoutElement.Element(DataTypeDescriptorFormsHelper.MainNamespace + "TabPanels");
            List <XElement> placeHolderElements = tabPanelsElement.Elements(DataTypeDescriptorFormsHelper.MainNamespace + "PlaceHolder").ToList();

            UpdateFormDefinitionWithUserGroups(user, bindingsElement, placeHolderElements[1]);
            UpdateFormDefinitionWithActivePerspectives(user, bindingsElement, placeHolderElements[2]);
            //UpdateFormDefinitionWithGlobalPermissions(user, bindingsElement, placeHolderElements[1]);

            if (DataLocalizationFacade.ActiveLocalizationCultures.Any())
            {
                UpdateFormDefinitionWithActiveLocales(user, bindingsElement, placeHolderElements[1]);
            }

            string formDefinition = formDocument.GetDocumentAsString();

            this.DeliverFormData(
                user.Username,
                StandardUiContainerTypes.Document,
                formDefinition,
                this.Bindings,
                clientValidationRules
                );
        }