private ShareSettings ReadSettings() { try { if (System.IO.File.Exists(_configPath)) { using (var stream = System.IO.File.OpenRead(_configPath)) { var serializer = new XmlSerializer(typeof(ShareSettings)); return(serializer.Deserialize(stream) as ShareSettings ?? new ShareSettings()); } } else { //This probably means that this is the first time they start the application with this package installed. //So we generate a random private key so it works out of the box. var randomSettings = new ShareSettings { PrivateKey = Guid.NewGuid().ToString(), NotValidUrl = "/" }; UpdateSettings(randomSettings); return(randomSettings); } } catch (Exception ex) { Current.Logger.Error(typeof(SharePreviewSettingsService), ex, "Error occured whilst reading out the settings."); return(null); } }
private void SaveSetting() { MessageDisplay msgDisplay = CreateMessageDisplay("EnableShareFunction", "HotDays"); ShareSettings shareSettings = new ShareSettings(); shareSettings.EnableShareFunction = _Request.Get <bool>("EnableShareFunction", Method.Post, true); shareSettings.HotShareSortType = _Request.Get <HotShareSortType>("HotShareSortType", Method.Post, HotShareSortType.ShareCount); int hotDays = _Request.Get <int>("HotDays", Method.Post, 3); if (hotDays < 1) { msgDisplay.AddError("HotDays", "天数必须大于0"); return; } shareSettings.HotDays = hotDays; if (!msgDisplay.HasAnyError()) { SettingManager.SaveSettings(shareSettings); } }
public bool UpdateSettings(ShareSettings newSettings) { if (SetSettings(newSettings)) { HttpRuntime.Cache.Insert(_settingsCacheKey, newSettings, null, DateTime.Now.AddHours(1), Cache.NoSlidingExpiration); return(true); } else { return(false); } }
private bool SetSettings(ShareSettings newSettings) { try { using (var writer = new System.IO.StreamWriter(_configPath)) { var serializer = new XmlSerializer(typeof(ShareSettings)); serializer.Serialize(writer, newSettings); } return(true); } catch (Exception ex) { Current.Logger.Error(typeof(SharePreviewSettingsService), ex, "Error occured whilst saving the settings."); return(false); } }
private void AddShareButton_Click(object sender, RoutedEventArgs e) { FolderBrowserDialog fbDialog = new FolderBrowserDialog(); DialogResult result = fbDialog.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { string folderPath = fbDialog.SelectedPath; string folderName = System.IO.Path.GetFileName(folderPath); if (CommonUtils.IsEmptyString(folderName)) { folderName = folderPath.Substring(0, 1); } List <string> permissionList = new List <string>(); permissionList.Add("*"); ShareSettings share = new ShareSettings(folderName, folderPath, permissionList, permissionList); this.m_sharesSettings.Add(share); this.shares_listbox.Items.Refresh(); SettingsHelper.WriteSharesSettings(m_sharesSettings); } }
public void CreateLocationShareAsync(UserInfo user, ShareSettings settings, object userState) { if ((this.CreateLocationShareOperationCompleted == null)) { this.CreateLocationShareOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCreateLocationShareCompleted); } this.InvokeAsync("CreateLocationShare", new object[] { user, settings}, this.CreateLocationShareOperationCompleted, userState); }
public void CreateLocationShareAsync(UserInfo user, ShareSettings settings) { this.CreateLocationShareAsync(user, settings, null); }
public LocationShare CreateLocationShare(UserInfo user, ShareSettings settings) { object[] results = this.Invoke("CreateLocationShare", new object[] { user, settings}); return ((LocationShare)(results[0])); }
public System.IAsyncResult BeginCreateLocationShare(UserInfo user, ShareSettings settings, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("CreateLocationShare", new object[] { user, settings}, callback, asyncState); }
public void ConfigureServices(IServiceCollection services) { ConfigureSession(services); services.AddMvc(); ILuisSettings luisSettings = new LuisSettings(Configuration.GetSection("Luis")); services.AddSingleton(luisSettings); IBingSettings bingSettings = new BingSettings(Configuration.GetSection("Bing")); services.AddSingleton(bingSettings); IShareSettings shareSettings = new ShareSettings(Configuration.GetSection("Share")); services.AddSingleton(shareSettings); IKeyVaultSettings keyVaultSettings = new KeyVaultSettings(Configuration.GetSection("KeyVault")); services.AddSingleton(keyVaultSettings); IAdminSettings adminSettings = new AdminSettings(Configuration.GetSection("Admin")); services.AddSingleton(adminSettings); IOnboardingInfoSettings onboardingInfoSettings = new OnboardingInfoSettings(Configuration.GetSection("EmailService"), Configuration.GetSection("KeyVault")); services.AddSingleton(onboardingInfoSettings); IQnAMakerSettings qnAMakerSettings = new QnAMakerSettings(Configuration.GetSection("QnAMaker")); services.AddSingleton(qnAMakerSettings); services.AddSingleton <ILuisProxy, LuisProxy>(); services.AddSingleton <ILuisBusinessLogic, LuisBusinessLogic>(); services.AddSingleton <ITopicsResourcesBusinessLogic, TopicsResourcesBusinessLogic>(); services.AddSingleton <IWebSearchBusinessLogic, WebSearchBusinessLogic>(); services.AddSingleton <ICuratedExperienceConvertor, A2JAuthorBusinessLogic>(); services.AddSingleton <ICuratedExperienceBusinessLogic, CuratedExperienceBuisnessLogic>(); services.AddTransient <IHttpClientService, HttpClientService>(); services.AddSingleton <IUserProfileBusinessLogic, UserProfileBusinessLogic>(); services.AddSingleton <IPersonalizedPlanBusinessLogic, PersonalizedPlanBusinessLogic>(); services.AddSingleton <IStaticResourceBusinessLogic, StaticResourceBusinessLogic>(); services.AddSingleton <IShareBusinessLogic, ShareBusinessLogic>(); services.AddSingleton <ICuratedExperienceConvertor, A2JAuthorBusinessLogic>(); services.AddSingleton <IPersonalizedPlanEngine, PersonalizedPlanEngine>(); services.AddSingleton <IA2JAuthorLogicParser, LogicParser>(); services.AddSingleton <IA2JAuthorLogicInterpreter, LogicInterpreter>(); services.AddSingleton <IPersonalizedPlanViewModelMapper, PersonalizedPlanViewModelMapper>(); services.AddSingleton <IUserRoleBusinessLogic, UserRoleBusinessLogic>(); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddSingleton <ISessionManager, SessionManager>(); services.AddSingleton <IAdminBusinessLogic, AdminBusinessLogic>(); services.AddSingleton <IStateProvinceBusinessLogic, StateProvinceBusinessLogic>(); services.AddSingleton <IOnboardingInfoBusinessLogic, OnboardingInfoBusinessLogic>(); services.AddSingleton <IQnABotBusinessLogic, QnABotBusinessLogic>(); services.AddAuthentication(sharedOptions => { sharedOptions.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; }).AddAzureAdBearer(options => Configuration.Bind("AzureAd", options)); services.AddAuthorization(options => { options.DefaultPolicy = new AuthorizationPolicyBuilder(JwtBearerDefaults.AuthenticationScheme) .RequireAuthenticatedUser() .Build(); }); ConfigureCosmosDb(services); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "Access2Justice API", Version = "1.0.0", Description = "List of all APIs for Access2Justice", TermsOfService = "None" }); c.TagActionsBy(api => api.GroupName); c.DescribeAllEnumsAsStrings(); c.OrderActionsBy((apiDesc) => $"{apiDesc.RelativePath}_{apiDesc.HttpMethod}"); c.OperationFilter <FileUploadOperation>(); //Register File Upload Operation Filter c.OperationFilter <FileUploadOperationResource>(); c.CustomSchemaIds(x => x.FullName); var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); c.IncludeXmlComments(xmlPath); }); }
public void SetShareSettings(ShareSettings shareSettings) { this.shareSettings = shareSettings; }
public bool SaveSettings(ShareSettings settings) { return(_shareablePreviewSettingsService.UpdateSettings(settings)); }