Esempio n. 1
0
        /// <summary>
        ///     инициализация визарда
        /// </summary>
        /// <param name="id"></param>
        /// <param name="cryptxService"></param>
        /// <param name="authService"></param>
        /// <param name="token"></param>
        public WizardModel(Guid id, CryptxServiceClient cryptxService, AuthorizeServiceClient authService, Guid token)
        {
            ProfileSelect            = new ProfileSelect();
            CanBack                  = true;
            CanNext                  = true;
            CanmakeOperation         = false;
            ProfileSelect.UseDefault = false;
            ProfileResponse userDefaultResponse = cryptxService.GetDefaultProfile(token);

            if (userDefaultResponse.Exception == null)
            {
                if (userDefaultResponse.Settings.Id == Guid.Empty)
                {
                    ProfileResponse response = cryptxService.GetBlankProfile();
                    if (response.Exception == null)
                    {
                        ProfileSelect.UseDefault = true;
                        Settings = response.Settings;
                    }
                    else
                    {
                        throw new Exception("Ошибка при получении настроек по умолчанию");
                    }
                }
                else
                {
                    Settings = userDefaultResponse.Settings;
                }
            }
            else
            {
                throw new Exception("Ошибка при получении ваших настроек по умолчанию");
            }
            //зануляем пароли
            Settings._SignatureSettings.KeysetPassword  = "";
            Settings._DecryptionSettings.KeysetPassword = "";

            //Settings = _cryptxService.GetDefaultProfile();// SettingInitializer.InitializeSettings();
            UserInfo = new UserInfoW();
            UserInfoResponse userInfo = authService.GetUserData(token);

            DownloadedFiles        = new List <DownloadedFile>();
            UserInfo.WebDavRootDir = userInfo.WebDavRootDir;
            UserInfo.User          = userInfo.User;
            Id           = id;
            CreationTime = DateTime.Now;
        }
Esempio n. 2
0
        public MasterInitModel(Guid token, CryptxServiceClient cryptx, AuthorizeServiceClient authorize, string files,
                               OperationType?type)
        {
            UserInfoResponse curUser = authorize.GetUserData(token);

            ProfileResponse      blankProfileResponse = cryptx.GetBlankProfile();
            UserProfilesResponse response             = cryptx.GetUserProfiles(Guid.Empty, token);

            OperationType    = (type == null) ? 0 : (OperationType)type;
            FilesJSON        = string.IsNullOrEmpty(files) ? "[]" : files;
            BlankProfileJSON = JsonConvert.SerializeObject(blankProfileResponse.Settings, Formatting.Indented);

            if (response.UserProfileList.Count == 0)
            {
                response.UserProfileList.Add(new UserProfileListElement
                {
                    Name = "Стандартные"
                });
            }

            SettingsJSON = JsonConvert.SerializeObject(response.UserProfileList, Formatting.Indented);
            UserInfo     = curUser.User;
        }