public static List<Client> Get(AppConfiguration config) { string clientId = ConfigurationManager.AppSettings["Weee.ApiClientID"]; string clientSecret = ConfigurationManager.AppSettings["Weee.ApiSecret"]; if (string.IsNullOrEmpty(clientId) || string.IsNullOrEmpty(clientSecret)) { throw new ConfigurationErrorsException("API client configuration must be provided."); } return new List<Client> { new IdentityServer3.Core.Models.Client { ClientName = "WEEE Web", ClientId = clientId, Enabled = true, AccessTokenType = AccessTokenType.Reference, Flow = Flows.ResourceOwner, ClientSecrets = new List<Secret> { new Secret(config.ApiSecret.Sha256()) }, AccessTokenLifetime = 3600, // 1 hour AllowAccessToAllScopes = true } }; }
public static bool SaveApplicationConfig(Stream stream, AppConfiguration config) { XmlSerializer xmls = null; StreamWriter sw = null; string msg = string.Empty; try { xmls = new XmlSerializer(typeof(AppConfiguration)); sw = new StreamWriter(stream); //XmlWriterSettings setting = new XmlWriterSettings(); //setting.CloseOutput = true; XmlWriter xmlWriter = XmlWriter.Create(sw); xmls.Serialize(sw, config); sw.Close(); return true; } catch (System.Exception ex) { Debug.WriteLine(ex.ToString()); return false; } finally { if (sw != null) { sw.Close(); sw.Dispose(); } } }
public static IdentityServerServiceFactory Configure(AppConfiguration config) { var factory = new IdentityServerServiceFactory(); var scopeStore = new InMemoryScopeStore(Scopes.Get()); factory.ScopeStore = new Registration<IScopeStore>(scopeStore); var clientStore = new InMemoryClientStore(Clients.Get(config)); factory.ClientStore = new Registration<IClientStore>(clientStore); var efConfig = new EntityFrameworkServiceOptions { ConnectionString = "Weee.DefaultConnection", Schema = "Identity" }; factory.RegisterOperationalServices(efConfig); var cleanup = new TokenCleanup(efConfig); cleanup.Start(); string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["Weee.DefaultConnection"].ConnectionString; var auditSecurityEventService = new SecurityEventDatabaseAuditor(connectionString); SecurityEventService eventService = new SecurityEventService(auditSecurityEventService); factory.Register<ISecurityEventAuditor>(new Registration<ISecurityEventAuditor>(auditSecurityEventService)); factory.EventService = new Registration<IEventService>(eventService); return factory; }
public InterceptMailDeliveryDecorator( IDeliverMailMessage decorated , AppConfiguration appConfiguration ) { _decorated = decorated; _appConfiguration = appConfiguration; }
public ChallengeResult(AppConfiguration appConfiguration, string provider, string redirectUri, string userId = null) { _appConfiguration = appConfiguration; _loginProvider = provider; _redirectUri = redirectUri; _userId = userId; }
public ElmahExceptionAuditor( IDeliverMailMessage mailMessageSender , AppConfiguration appConfiguration ) { _mailMessageSender = mailMessageSender; _appConfiguration = appConfiguration; }
public OwinAuthenticator( IAuthenticationManager authenticationManager , UserManager<User, int> userManager , AppConfiguration appConfiguration ) { _authenticationManager = authenticationManager; _userManager = userManager; _appConfiguration = appConfiguration; }
private static IdentityServerOptions GetIdentityServerOptions(IAppBuilder app, AppConfiguration config) { var factory = Factory.Configure(config); factory.ConfigureUserService(app); return new IdentityServerOptions { Factory = factory }; }
public SignOnController( IProcessQueries queries , IProcessCommands commands , AppConfiguration appConfiguration ) { _queries = queries; _commands = commands; _appConfiguration = appConfiguration; }
public UserLoginsController( IProcessQueries queries , IProcessValidation validation , IProcessCommands commands , AppConfiguration appConfiguration) { _queries = queries; _validation = validation; _commands = commands; _appConfiguration = appConfiguration; }
public void ConfigureAuth(IAppBuilder app, AppConfiguration config) { app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = Constants.IwsAuthType, CookieName = Prsd.Core.Web.Constants.CookiePrefix + Constants.IwsAuthType, LoginPath = new PathString("/Account/Login"), SlidingExpiration = true, ExpireTimeSpan = TimeSpan.FromHours(2), Provider = new CookieAuthenticationProvider { OnValidateIdentity = context => OnValidateIdentity(context), OnApplyRedirect = context => OnApplyRedirect(context) } }); }
private static IdentityServerOptions GetIdentityServerOptions(IAppBuilder app, AppConfiguration config) { var factory = Factory.Configure(config); factory.ConfigureUserService(app); return new IdentityServerOptions { Factory = factory, RequireSsl = false, EventsOptions = new EventsOptions() { RaiseSuccessEvents = true, RaiseFailureEvents = true } }; }
public static List<Client> Get(AppConfiguration config) { return new List<Client> { new Client { ClientName = "IWS Web", ClientId = config.ApiClientId, Enabled = true, AccessTokenType = AccessTokenType.Reference, Flow = Flows.ResourceOwner, ClientSecrets = new List<Secret> { new Secret(config.ApiSecret.Sha256()) }, AllowAccessToAllScopes = true, AccessTokenLifetime = 43200 // 12 hours } }; }
public static IdentityServerServiceFactory Configure(AppConfiguration config) { var factory = new IdentityServerServiceFactory(); var scopeStore = new InMemoryScopeStore(Scopes.Get()); factory.ScopeStore = new Registration<IScopeStore>(scopeStore); var clientStore = new InMemoryClientStore(Clients.Get(config)); factory.ClientStore = new Registration<IClientStore>(clientStore); var efConfig = new EntityFrameworkServiceOptions { ConnectionString = "Iws.DefaultConnection", Schema = "Identity" }; factory.RegisterOperationalServices(efConfig); var cleanup = new TokenCleanup(efConfig); cleanup.Start(); return factory; }
public static void Update(AppConfiguration cfg) { using (var context = ApplicationDbContext.Create()) { var existing = context.AppConfiguration.FirstOrDefault(); if (existing == null) { context.AppConfiguration.Add(cfg); } else { existing.IsFakeCom = cfg.IsFakeCom; existing.ScannerComPort = cfg.ScannerComPort; existing.ScannerTimeout = cfg.ScannerTimeout; existing.StationComPorts = cfg.StationComPorts; existing.ExportFilePin = cfg.ExportFilePin; existing.ExportFilePrint = cfg.ExportFilePrint; context.AppConfiguration.AddOrUpdate(existing); } context.SaveChanges(); } }
public Task <RepositoryImportResult> ImportAsync(Project project, AppConfiguration appConfiguration, IRepositoryAuthenticationInfo authInfo, CustomLogger runnerLogger, string commitId = null) { return(Task.Run(() => { // Try to get the auth data. var info = authInfo as AuthInfo; if (info == null) { return new RepositoryImportResult(string.Empty, true); } // Setup storage directory. var folderName = $"{project.Name}_{DateTime.UtcNow.Ticks}"; var path = Path.Combine(appConfiguration.BaseDirectory, folderName); try { // Create the path before we start. Directory.CreateDirectory(path); // Clone the repository first. var cloneOptions = new CloneOptions { CredentialsProvider = (_url, _user, _cred) => new UsernamePasswordCredentials { Username = info.Username, Password = info.Password } }; var cloneResult = Repository.Clone(project.RepositoryUrl, path, cloneOptions); if (string.IsNullOrEmpty(cloneResult)) { return new RepositoryImportResult(string.Empty, true); } // Checkout the branch. using (var repo = new Repository(path)) { var branch = repo.Branches[project.BranchName ?? "main"]; if (branch == null) { new RepositoryImportResult(string.Empty, true); } runnerLogger.Information("Checking out..."); Branch currentBranch; if (commitId != null) { var localCommit = repo.Lookup <Commit>(new ObjectId(commitId)); if (localCommit == null) { runnerLogger.Error("Could not find branch."); return new RepositoryImportResult(null, true); } currentBranch = Commands.Checkout(repo, localCommit); } else { currentBranch = Commands.Checkout(repo, branch); } runnerLogger.Information($"Check out complete. Result = {currentBranch != null}"); if (currentBranch != null) { return new RepositoryImportResult(path, false); } else { return new RepositoryImportResult(path, true); } } } catch (Exception exp) { runnerLogger.Error(exp); return new RepositoryImportResult(string.Empty, true); } })); }
public void Run <T>(IEnumerable <T> data, string title, string fileName) { Presentation presentation = new Presentation(); int totalNoOfRows = data.ToList().Count(); double noOfSlidesDouble = Convert.ToDouble(totalNoOfRows) / Convert.ToDouble(rowsPerSlide); // get closest upper number from the double double noOfSlides = Math.Ceiling(noOfSlidesDouble); // use reflection to get the number of columns in the list int noOfColumns = data.FirstOrDefault()?.GetType()?.GetProperties()?.Length ?? 0; // use reflection to get the column names var columnNames = data.FirstOrDefault()?.GetType()?.GetProperties()?.Select(c => c.Name).ToList(); // add space between capital letters columnNames = columnNames.Select(c => (string.Concat(c.Select(x => Char.IsUpper(x) ? " " + x : x.ToString())).TrimStart(' '))).ToList(); int rowCounter = 0; // create no of slides needed is spire (1 already exists from the start) for (int i = 1; i < noOfSlides; i++) { presentation.Slides.Append(); } // foreach slide starting at first one for (int i = 0; i < noOfSlides; i++) { CreateTitle(presentation, i, title); // number of data rows left to insert int noOfRowsLeft = totalNoOfRows - rowCounter; // get number of rows to insert either rowsPerSlide or the remaining rows e.g 4 int rowsPerCurrentSlide = noOfRowsLeft > rowsPerSlide ? rowsPerSlide : noOfRowsLeft; // widths and heighs for table var widthsAndHeights = GetCellWidthsAndHeights(rowsPerCurrentSlide, noOfColumns); // needed to calculate column space int y = noOfColumns * 50; // create table ITable table = presentation.Slides[i].Shapes.AppendTable(presentation.SlideSize.Size.Width / 2 - y, 50, widthsAndHeights.widths, widthsAndHeights.heights); // insert column names InsertColumnNames(columnNames, table); // create databale to work with for data insert DataTable dataTable = Helper.CreateDataTable(data); // insert data rowCounter = InsertData(noOfColumns, rowCounter, rowsPerCurrentSlide, table, dataTable); } // get file path configuration AppConfiguration config = new AppConfiguration(); var filePath = config.OutputFolderDirectory + $@"\\{fileName}"; // save file presentation.SaveToFile(filePath, FileFormat.Pptx2010); }
protected override void DoProcessSafe(GetLayoutServiceContextArgs args, AppConfiguration application) { var model = this.visitorContext.CurrentUser; args.ContextData.Add(Constants.Context.CommerceUserPropertyName, model); }
public GenreService(AppConfiguration configuration, DAOStorage daoStorage, Mapper mapper, BaseCrudDAO <GenreDTO> dao) : base(configuration, daoStorage, mapper, dao) { }
public Cleaner(AppConfiguration config) { _config = config; }
public WriteFileVirusScanner(AppConfiguration config, IFileAccess fileAccess) { this.config = config; this.fileAccess = fileAccess; fileWriteTimeout = TimeSpan.FromMilliseconds(config.FileSafeTimerMilliseconds); }
public VendorTypeService(EMSUoW uow) { _VendorTypeRepo = new EFRepository <VendorTypeDE>(uow); _appConfiguration = new AppConfiguration(); }
public MoodleFromToCacheAdapter AddConfiguration(AppConfiguration config) { Configuration = config; return(this); }
public void TestServerSubscribe() { var config = new AppConfiguration { MarketDataBrokerUrl = BrokerFactoryTest.Nyws802 }; var server = new ActiveMQRtdServer(config); IRTDUpdateEvent updateEventHandler = new TestEventHandler(); var startResult = server.ServerStart(updateEventHandler); Assert.AreEqual(1, startResult); Assert.AreEqual(1, server.Heartbeat()); // Use the default broker var newValues = false; Array parameters = new[] { "Test.Topic", "FieldName1" }; Assert.AreEqual("N/A", server.ConnectData(1, ref parameters, ref newValues)); Assert.IsTrue(newValues); Assert.AreEqual(1, server.TopicCount); Assert.AreEqual(1, server.FieldCount); var testBroker = BrokerFactory.Broker(BrokerFactoryTest.Nyws802); //PublishTestMessage(testBroker, "Test.Topic", "FieldName", "FieldValue"); var multiFieldRecord = new Dictionary <string, string> { { "FieldName1", "FieldValue1" }, { "FieldName2", "FieldValue2" } }; PublishTestMessage(testBroker, "Test.Topic", multiFieldRecord); Thread.Sleep(1000); Assert.AreEqual("FieldValue1", server.ConnectData(2, ref parameters, ref newValues)); Assert.AreEqual(2, server.TopicCount); Assert.AreEqual(1, server.FieldCount); // subscribe to field already in the message/cache parameters = new[] { "Test.Topic", "FieldName2" }; Assert.AreEqual("FieldValue2", server.ConnectData(3, ref parameters, ref newValues)); Assert.AreEqual(3, server.TopicCount); Assert.AreEqual(2, server.FieldCount); server.DisconnectData(3); Assert.AreEqual(2, server.TopicCount); Assert.AreEqual(1, server.FieldCount); var topicCount = 0; var updatedTopics = server.RefreshData(ref topicCount); Assert.AreEqual(1, topicCount); Assert.IsNotNull(updatedTopics); // Publish again to ensure we get both updates Console.WriteLine("Publish second message, when we have two Excel topics"); PublishTestMessage(testBroker, "Test.Topic", "FieldName1", "FieldValue1"); Thread.Sleep(1000); Console.WriteLine("Calling Refresh"); updatedTopics = server.RefreshData(ref topicCount); Assert.AreEqual(2, topicCount); Assert.IsNotNull(updatedTopics); server.DisconnectData(1); Assert.AreEqual(1, server.TopicCount); Assert.AreEqual(1, server.FieldCount); server.DisconnectData(2); Assert.AreEqual(0, server.TopicCount); Assert.AreEqual(0, server.FieldCount); // Check constant lookups var newValues2 = false; Array parameters2 = new[] { "Test.Topic", "brokerUrl" }; Assert.AreEqual(BrokerFactoryTest.Nyws802, server.ConnectData(10, ref parameters2, ref newValues2)); parameters2 = new[] { "Test.Topic", "productVersion" }; var productVersion = server.ConnectData(11, ref parameters2, ref newValues2); Assert.IsNotNull(productVersion); Assert.AreNotEqual("#Error", productVersion); Console.WriteLine(productVersion); }
public VendorService(IUnitOfWork uow) { _VendorRepo = new EFRepository <VendorDE>(uow); _appConfiguration = new AppConfiguration(); }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseNpgsql(AppConfiguration.GetConnectionString(ConnectionStrings.PostgresqlConnection)); }
public bool saveTag(TagItem item) { string insertSQL = string.Format("INSERT INTO XueBa.dbo.Tag(tid,name,prevtid) VALUES('{0}','{1}',NULL)", item.gettid(), item.getname()); SqlConnection con = Connection.instance(AppConfiguration.GetConfigValue("serverIp"), "crawler", AppConfiguration.GetConfigValue("username"), AppConfiguration.GetConfigValue("password")); SqlCommand Command = con.CreateCommand(); Command.CommandText = insertSQL; try { Command.ExecuteNonQuery(); } catch (Exception e) { Console.WriteLine(e.StackTrace); return(false); } con.Close(); return(true); }
public ProcessComponent(AppConfiguration config, IBackgroundComponent backgroundComponent, IBarComponent barComponent) { _config = config; _backgroundComponent = backgroundComponent; _barComponent = barComponent; }
protected virtual void OnConfigureWebApp(IApplicationBuilder app, IWebHostEnvironment env) { AppConfiguration.ConfigureDefaultWebApp(app, env); }
public static bool LoadApplicationConfig(Stream stream, out AppConfiguration config) { XmlSerializer xmls = null; StreamReader sr = null; XmlReader xmlReader = null; string msg = string.Empty; config = null; try { xmls = new XmlSerializer(typeof(AppConfiguration)); sr = new StreamReader(stream); xmlReader = XmlReader.Create(sr); if (!xmls.CanDeserialize(xmlReader)) { return false; } else { config = (AppConfiguration)xmls.Deserialize(xmlReader); } return true; } catch (System.Exception ex) { Debug.WriteLine(ex.ToString()); return false; } finally { if (sr != null) { sr.Close(); sr.Dispose(); } if (xmlReader != null) { xmlReader.Close(); } } }
private static void Main(string[] args) { var app = new App(AppConfiguration.Create()); app.Run(); }
public FeedbackController(IMediator mediator, AppConfiguration config) { this.mediator = mediator; this.config = config; }
public IndexModel(AppDbContext db, AppConfiguration appConfig) { _db = db; AppConfiguration = appConfig; }
private async void OnActivated(object sender, ActivationEventArgs activationEventArgs) { _config = _configService.GetEffectiveConfiguration(); var chocolateyFeatures = await _chocolateyService.GetFeatures(); foreach (var chocolateyFeature in chocolateyFeatures) { ChocolateyFeatures.Add(chocolateyFeature); } _changedChocolateyFeature = new Subject <ChocolateyFeature>(); _changedChocolateyFeature .Select(f => Observable.FromAsync(() => UpdateChocolateyFeature(f))) .Concat() .Subscribe(); var chocolateySettings = await _chocolateyService.GetSettings(); foreach (var chocolateySetting in chocolateySettings) { ChocolateySettings.Add(chocolateySetting); } _changedChocolateySetting = new Subject <ChocolateySetting>(); _changedChocolateySetting .Select(s => Observable.FromAsync(() => UpdateChocolateySetting(s))) .Concat() .Subscribe(); var chocolateyGuiFeatures = _configService.GetFeatures(global: false); foreach (var chocolateyGuiFeature in chocolateyGuiFeatures) { ChocolateyGuiFeatures.Add(chocolateyGuiFeature); } _changedChocolateyGuiFeature = new Subject <ChocolateyGuiFeature>(); _changedChocolateyGuiFeature .Select(s => Observable.FromAsync(() => UpdateChocolateyGuiFeature(s))) .Concat() .Subscribe(); var chocolateyGuiSettings = _configService.GetSettings(global: false); foreach (var chocolateyGuiSetting in chocolateyGuiSettings) { ChocolateyGuiSettings.Add(chocolateyGuiSetting); } _changedChocolateyGuiSetting = new Subject <ChocolateyGuiSetting>(); _changedChocolateyGuiSetting .Select(s => Observable.FromAsync(() => UpdateChocolateyGuiSetting(s))) .Concat() .Subscribe(); var sources = await _chocolateyService.GetSources(); foreach (var source in sources) { Sources.Add(source); } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //AppSetting配置文件 var config = new AppConfiguration(Configuration); var appSetting = config.GetAppSetting(); //自定义序列化程序 services.AddControllers().AddXmlSerializerFormatters().AddJsonOptions(opt => { opt.JsonSerializerOptions.Converters.Add(new IPAddressConverter()); }); services.AddSignalR(); //数据库连接 // ReSharper disable once ObjectCreationAsStatement services.AddDbContextPool <DanmuContext>(option => new DbContextBuild(config, option), appSetting.DanmuSql.PoolSize); //Http请求 services.AddHttpClient(); services.AddHttpClient(Gzip).ConfigurePrimaryHttpMessageHandler(() => new SocketsHttpHandler { AutomaticDecompression = DecompressionMethods.GZip }); services.AddHttpClient(Deflate).ConfigurePrimaryHttpMessageHandler(() => new SocketsHttpHandler { AutomaticDecompression = DecompressionMethods.Deflate }); // 转接头,代理 services.Configure <ForwardedHeadersOptions>(options => { options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto; }); //配置跨域 services.AddCors(options => { options.AddDefaultPolicy(builder => builder.WithMethods("GET", "POST", "OPTIONS")); options.AddPolicy(DanmuAllowSpecificOrigins, builder => builder.WithOrigins(appSetting.WithOrigins) .SetIsOriginAllowedToAllowWildcardSubdomains().WithMethods("GET", "POST", "OPTIONS") .AllowAnyHeader()); options.AddPolicy(LiveAllowSpecificOrigins, builder => builder.WithOrigins(appSetting.LiveWithOrigins) .SetIsOriginAllowedToAllowWildcardSubdomains().WithMethods("GET", "POST", "OPTIONS") .AllowAnyHeader().AllowCredentials()); options.AddPolicy(AdminAllowSpecificOrigins, builder => builder.WithOrigins(appSetting.AdminWithOrigins) .WithMethods("GET", "POST", "OPTIONS")); }); //权限 services.AddTransient <IClaimsTransformation, ClaimsTransformer>(); services.AddAuthorization(options => { options.AddPolicy(AdminRolePolicy, policy => policy.RequireRole(nameof(UserRole.SuperAdmin), nameof(UserRole.Admin))); options.AddPolicy(GeneralUserRolePolicy, policy => policy.RequireRole(nameof(UserRole.GeneralUser), nameof(UserRole.SuperAdmin), nameof(UserRole.Admin))); }); services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(options => { options.ReturnUrlParameter = "url"; options.AccessDeniedPath = "/api/admin/noAuth"; options.LoginPath = "/api/admin/login"; options.LogoutPath = "/api/admin/logout"; options.Cookie.Name = "DCookie"; options.Cookie.MaxAge = TimeSpan.FromMinutes(appSetting.Admin.MaxAge); }); // SPA根目录 services.AddSpaStaticFiles(opt => opt.RootPath = "wwwroot"); //注入 services.AddSingleton(s => config); services.AddScoped <UserDao>(); services.AddScoped <DanmuDao>(); services.AddScoped <VideoDao>(); services.AddScoped <CacheDao>(); services.AddScoped <BiliBiliHelp>(); }
private AppConfiguration GetCurrentAppConfiguration(MemberInfo memberInfo, Type testClassType, ServicesCollection container) { var androidAttribute = GetAppAttribute <AndroidAttribute>(memberInfo, testClassType); var iosAttribute = GetAppAttribute <IOSAttribute>(memberInfo, testClassType); var androidWebAttribute = GetAppAttribute <AndroidWebAttribute>(memberInfo, testClassType); var androidSauceLabsAttribute = GetAppAttribute <AndroidSauceLabsAttribute>(memberInfo, testClassType); var androidCrossappTestingAttribute = GetAppAttribute <AndroidCrossBrowserTestingAttribute>(memberInfo, testClassType); var androidappStackAttribute = GetAppAttribute <AndroidBrowserStackAttribute>(memberInfo, testClassType); var iosWebAttribute = GetAppAttribute <IOSWebAttribute>(memberInfo, testClassType); var iosSauceLabsAttribute = GetAppAttribute <IOSSauceLabsAttribute>(memberInfo, testClassType); var iosCrossappTestingAttribute = GetAppAttribute <IOSCrossBrowserTestingAttribute>(memberInfo, testClassType); var iosappStackAttribute = GetAppAttribute <IOSBrowserStackAttribute>(memberInfo, testClassType); AppConfiguration currentAppConfiguration; if (androidAttribute != null && iosAttribute != null) { throw new ArgumentException("You need to specify only single platform attribute - Android or IOS."); } else if (androidAttribute != null) { currentAppConfiguration = androidAttribute.AppConfiguration; } else if (androidWebAttribute != null) { currentAppConfiguration = androidWebAttribute.AppConfiguration; } else if (androidSauceLabsAttribute != null) { currentAppConfiguration = androidSauceLabsAttribute.AppConfiguration; currentAppConfiguration.AppiumOptions = androidSauceLabsAttribute.CreateAppiumOptions(memberInfo, testClassType); } else if (androidCrossappTestingAttribute != null) { currentAppConfiguration = androidCrossappTestingAttribute.AppConfiguration; currentAppConfiguration.AppiumOptions = androidCrossappTestingAttribute.CreateAppiumOptions(memberInfo, testClassType); } else if (androidappStackAttribute != null) { currentAppConfiguration = androidappStackAttribute.AppConfiguration; currentAppConfiguration.AppiumOptions = androidappStackAttribute.CreateAppiumOptions(memberInfo, testClassType); } else if (iosAttribute != null) { currentAppConfiguration = iosAttribute.AppConfiguration; } else if (iosWebAttribute != null) { currentAppConfiguration = iosWebAttribute.AppConfiguration; } else if (iosSauceLabsAttribute != null) { currentAppConfiguration = iosSauceLabsAttribute.AppConfiguration; currentAppConfiguration.AppiumOptions = iosSauceLabsAttribute.CreateAppiumOptions(memberInfo, testClassType); } else if (iosCrossappTestingAttribute != null) { currentAppConfiguration = iosCrossappTestingAttribute.AppConfiguration; currentAppConfiguration.AppiumOptions = iosCrossappTestingAttribute.CreateAppiumOptions(memberInfo, testClassType); } else if (iosappStackAttribute != null) { currentAppConfiguration = iosappStackAttribute.AppConfiguration; currentAppConfiguration.AppiumOptions = iosappStackAttribute.CreateAppiumOptions(memberInfo, testClassType); } else { // TODO: --> add Test Case attribute for Andoid and IOS? Extend the Test Case attribute? Lifecycle currentLifecycle = Parse <Lifecycle>(ConfigurationService.GetSection <MobileSettings>().ExecutionSettings.DefaultLifeCycle); var appConfiguration = new AppConfiguration { AppPath = ConfigurationService.GetSection <MobileSettings>().ExecutionSettings.DefaultAppPath, Lifecycle = currentLifecycle, AppiumOptions = new AppiumOptions(), ClassFullName = testClassType.FullName, }; InitializeGridOptionsFromConfiguration(appConfiguration.AppiumOptions, testClassType); InitializeCustomCodeOptions(appConfiguration.AppiumOptions, testClassType); container.RegisterInstance(appConfiguration, "_currentAppConfiguration"); return(appConfiguration); } container.RegisterInstance(currentAppConfiguration, "_currentAppConfiguration"); return(currentAppConfiguration); }
public void LocalSetup() { this.appConfig = new AppConfiguration("abc", "def", "ghi", "jkl", "efg", "mno", "p!q@r", "stu", "''d", "v!w@x"); }
public FileUploadController(ILogger <FileUploadController> logger, IOptions <AppConfiguration> configuration) { _logger = logger; _configuration = configuration.Value; }
public PickupDirectoryMailMessageDelivery(AppConfiguration appConfiguration) { _appConfiguration = appConfiguration; }
public BaseViewModel(AppConfiguration applicationConfiguration, HttpRequest request) { AppConfiguration = applicationConfiguration; BaseURL = $"{request.Scheme}://{request.Host}{request.PathBase}"; }
public bool SaveAppConfig(AppConfiguration config) { MemoryStream stream = new MemoryStream(); bool res = CommonStaticMethod.SaveApplicationConfig(stream, config); if (!res) { return false; } string sql = "SELECT rowid, AppConfig FROM AppConfiguration"; DataTableUpdate dtUpdate = _helper.ExecuteDataTableUpdate(sql); DataRow row = null; bool isAdd = false; if (dtUpdate.DtResult.Rows.Count == 0) { row = dtUpdate.DtResult.NewRow(); isAdd = true; } else { row = dtUpdate.DtResult.Rows[0]; } row["AppConfig"] = (byte[])stream.ToArray(); if (isAdd) { dtUpdate.DtResult.Rows.Add(row); } dtUpdate.DtResult.TableName = "AppConfiguration"; int isOK = _helper.DataTableUpdateToDB(dtUpdate); if (isOK == -5) { return false; } return true; }
public Startup(IConfiguration configuration) { AppConfiguration = new AppConfiguration(); configuration.Bind(AppConfiguration); }
/// <summary> /// /// </summary> /// <remarks></remarks> /// <seealso cref=""/> /// <param name="variables"></param> /// <param name="path"></param> /// <param name="filename"></param> /// <returns></returns> public SpreadsheetDocument CreateTemplate(List <Variable> variables, string path, string filename) { if (!Directory.Exists(Path.Combine(AppConfiguration.DataPath, path))) { Directory.CreateDirectory(Path.Combine(AppConfiguration.DataPath, path)); } SpreadsheetDocument template = SpreadsheetDocument.Open(Path.Combine(AppConfiguration.GetModuleWorkspacePath("RPM"), "Template", _fileName), true); SpreadsheetDocument dataStructureFile = SpreadsheetDocument.Create(Path.Combine(AppConfiguration.DataPath, path, filename), template.DocumentType); //dataStructureFile = SpreadsheetDocument.Open(Path.Combine(AppConfiguration.GetModuleWorkspacePath("RPM"), "Template", filename), true); foreach (OpenXmlPart part in template.GetPartsOfType <OpenXmlPart>()) { OpenXmlPart newPart = dataStructureFile.AddPart <OpenXmlPart>(part); } template.Close(); // get worksheet List <StyleIndexStruct> styleIndex = new List <StyleIndexStruct>(); CellFormats cellFormats = dataStructureFile.WorkbookPart.WorkbookStylesPart.Stylesheet.Elements <CellFormats>().First(); //number 0,00 CellFormat cellFormat = new CellFormat() { NumberFormatId = (UInt32Value)2U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)1U, ApplyNumberFormat = true }; cellFormat.Protection = new Protection(); cellFormat.Protection.Locked = false; cellFormats.Append(cellFormat); styleIndex.Add(new StyleIndexStruct() { Name = "Decimal", Index = (uint)cellFormats.Count++, DisplayPattern = null }); //number 0 cellFormat = new CellFormat() { NumberFormatId = (UInt32Value)1U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)1U, ApplyNumberFormat = true }; cellFormat.Protection = new Protection(); cellFormat.Protection.Locked = false; cellFormats.Append(cellFormat); styleIndex.Add(new StyleIndexStruct() { Name = "Number", Index = (uint)cellFormats.Count++, DisplayPattern = null }); //text cellFormat = new CellFormat() { NumberFormatId = (UInt32Value)49U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)1U, ApplyNumberFormat = true }; cellFormat.Protection = new Protection(); cellFormat.Protection.Locked = false; cellFormats.Append(cellFormat); styleIndex.Add(new StyleIndexStruct() { Name = "Text", Index = (uint)cellFormats.Count++, DisplayPattern = null }); //DateTime cellFormat = new CellFormat() { NumberFormatId = (UInt32Value)22U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)1U, ApplyNumberFormat = true }; cellFormat.Protection = new Protection(); cellFormat.Protection.Locked = false; cellFormats.Append(cellFormat); styleIndex.Add(new StyleIndexStruct() { Name = "DateTime", Index = (uint)cellFormats.Count++, DisplayPattern = DataTypeDisplayPattern.Pattern.Where(p => p.Systemtype.Equals(DataTypeCode.DateTime) && p.Name.Equals("DateTime")).FirstOrDefault() }); //Date cellFormat = new CellFormat() { NumberFormatId = (UInt32Value)14U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)1U, ApplyNumberFormat = true }; cellFormat.Protection = new Protection(); cellFormat.Protection.Locked = false; cellFormats.Append(cellFormat); styleIndex.Add(new StyleIndexStruct() { Name = "Date", Index = (uint)cellFormats.Count++, DisplayPattern = DataTypeDisplayPattern.Pattern.Where(p => p.Systemtype.Equals(DataTypeCode.DateTime) && p.Name.Equals("Date")).FirstOrDefault() }); //Time cellFormat = new CellFormat() { NumberFormatId = (UInt32Value)21U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)1U, ApplyNumberFormat = true }; cellFormat.Protection = new Protection(); cellFormat.Protection.Locked = false; cellFormats.Append(cellFormat); styleIndex.Add(new StyleIndexStruct() { Name = "Time", Index = (uint)cellFormats.Count++, DisplayPattern = DataTypeDisplayPattern.Pattern.Where(p => p.Systemtype.Equals(DataTypeCode.DateTime) && p.Name.Equals("Time")).FirstOrDefault() }); Worksheet worksheet = dataStructureFile.WorkbookPart.WorksheetParts.First().Worksheet; List <Row> rows = GetRows(worksheet, 1, 11); foreach (Variable var in variables) { DataContainerManager CM = new DataContainerManager(); DataAttribute dataAttribute = CM.DataAttributeRepo.Get(var.DataAttribute.Id); int indexVar = variables.ToList().IndexOf(var) + 1; string columnIndex = GetClomunIndex(indexVar); string cellRef = columnIndex + 1; Cell cell = new Cell() { CellReference = cellRef, StyleIndex = (UInt32Value)4U, DataType = CellValues.String, CellValue = new CellValue(var.Label) }; rows.ElementAt(0).AppendChild(cell); cellRef = columnIndex + 2; cell = new Cell() { CellReference = cellRef, DataType = CellValues.String, StyleIndex = getExcelStyleIndex(dataAttribute.DataType, styleIndex), CellValue = new CellValue("") }; rows.ElementAt(1).AppendChild(cell); cellRef = columnIndex + 3; cell = new Cell() { CellReference = cellRef, StyleIndex = (UInt32Value)4U, DataType = CellValues.String, CellValue = new CellValue(var.Id.ToString()) }; rows.ElementAt(2).AppendChild(cell); cellRef = columnIndex + 4; cell = new Cell() { CellReference = cellRef, StyleIndex = (UInt32Value)4U, DataType = CellValues.String, CellValue = new CellValue(dataAttribute.ShortName) }; rows.ElementAt(3).AppendChild(cell); // description from variable // if not then from attribute string description = ""; description = String.IsNullOrEmpty(var.Description) ? dataAttribute.Description : var.Description; cellRef = columnIndex + 5; cell = new Cell() { CellReference = cellRef, StyleIndex = (UInt32Value)4U, DataType = CellValues.String, CellValue = new CellValue(description) }; rows.ElementAt(4).AppendChild(cell); string classification = ""; if (dataAttribute.Classification != null) { classification = dataAttribute.Classification.Name; } cellRef = columnIndex + 6; cell = new Cell() { CellReference = cellRef, StyleIndex = (UInt32Value)4U, DataType = CellValues.String, CellValue = new CellValue(classification) }; rows.ElementAt(5).AppendChild(cell); string unit = ""; if (var.Unit != null) { unit = var.Unit.Name; } cellRef = columnIndex + 7; cell = new Cell() { CellReference = cellRef, StyleIndex = (UInt32Value)4U, DataType = CellValues.String, CellValue = new CellValue(unit) }; rows.ElementAt(6).AppendChild(cell); string dataType = ""; if (dataAttribute.DataType != null) { dataType = dataAttribute.DataType.Name; } cellRef = columnIndex + 8; cell = new Cell() { CellReference = cellRef, StyleIndex = (UInt32Value)4U, DataType = CellValues.String, CellValue = new CellValue(dataType) }; rows.ElementAt(7).AppendChild(cell); cellRef = columnIndex + 9; cell = new Cell() { CellReference = cellRef, StyleIndex = (UInt32Value)4U, DataType = CellValues.String, CellValue = new CellValue(var.IsValueOptional.ToString()) }; rows.ElementAt(8).AppendChild(cell); cellRef = columnIndex + 10; cell = new Cell() { CellReference = cellRef, StyleIndex = (UInt32Value)4U, DataType = CellValues.String, CellValue = new CellValue(dataAttribute.IsMultiValue.ToString()) }; rows.ElementAt(9).AppendChild(cell); } foreach (DefinedName name in dataStructureFile.WorkbookPart.Workbook.GetFirstChild <DefinedNames>()) { if (name.Name == "Data" || name.Name == "VariableIdentifiers") { string[] tempArr = name.InnerText.Split('$'); string temp = ""; tempArr[tempArr.Count() - 2] = GetClomunIndex(variables.Count()); foreach (string t in tempArr) { if (t == tempArr.First()) { temp = temp + t; } else { temp = temp + "$" + t; } } name.Text = temp; } } //WorkbookPart workbookPart = spreadsheetDocument.WorkbookPart; //WorksheetPart worksheetPart = workbookPart.WorksheetParts.First(); dataStructureFile.WorkbookPart.Workbook.Save(); dataStructureFile.Close(); return(dataStructureFile); }
public WorkQUpdation(String strUrl) { Url = strUrl; ResponsePath = AppConfiguration.GetValueFromAppConfig("Paths_JsonReqResponse", ""); InputPath = AppConfiguration.GetValueFromAppConfig("Paths_SampleData", ""); }
private static string GetAddress() { var app = new AppConfiguration(); return(app.Address); }
public CommentBuilder(AppConfiguration appConfiguration, IUserWikiEditor userWikiEditor) { _appConfiguration = appConfiguration; _userWikiEditor = userWikiEditor; }
public SqlLiteService(AppConfiguration config) { this._config = config; }
public static void RegisterMailDelivery(this Container container) { // mail delivery is separated into 2 distinct sets of services: // the first is actual MAIL delivery, which deals with objects // like MailMessage and SmtpClient in the system.net namespace. // the second set is EMAIL delivery, which deals with the // EmailMessage application entity, and tracks delivery status. // the app should consume IDeliverEmailMessage, whose implementations // will consume network delivery & status tracking internally #region Mail Delivery var appConfiguration = new AppConfiguration(new ConfigurationManagerReader()); var mailDeliveryMethod = appConfiguration.MailDeliveryMethod; #if DEBUG if (mailDeliveryMethod != SmtpDeliveryMethod.Network) { // register the pickup directory implementation container.Register<IDeliverMailMessage, PickupDirectoryMailMessageDelivery>(); } else { // register the smtp delivery implementation container.Register<IDeliverMailMessage, SmtpMailMessageDelivery>(); } #else if (mailDeliveryMethod != SmtpDeliveryMethod.Network) throw new InvalidOperationException(string.Format( "Configuration setting system.net/mailSettings/smtp deliveryMethod '{0}' is not valid for release configuration.", mailDeliveryMethod)); // register the smtp delivery implementation container.Register<IDeliverMailMessage, SmtpMailMessageDelivery>(); #endif // retry sending mail container.RegisterDecorator( typeof(IDeliverMailMessage), typeof(RetryDeliverMailDecorator) ); #if DEBUG // when sending over the network in debug mode, intercept mail if (mailDeliveryMethod == SmtpDeliveryMethod.Network) { container.RegisterDecorator( typeof(IDeliverMailMessage), typeof(InterceptMailDeliveryDecorator) ); } #endif #endregion #region EmailMessage Delivery // send email in a new thread container.Register<IDeliverEmailMessage, ActiveEmailMessageDelivery>(); container.RegisterDecorator( typeof(IDeliverEmailMessage), typeof(DeliverEmailAsynchronouslyDecorator) ); // respond to email delivery result in a new thread container.Register<IDeliveredEmailMessage, OnEmailMessageDelivery>(); container.RegisterDecorator( typeof(IDeliveredEmailMessage), typeof(DeliveredEmailAsynchronouslyDecorator) ); #endregion }
public static async Task <RenderToStringResult> BuildPrerender(this HttpRequest Request, AppConfiguration appSettings) { var nodeServices = Request.HttpContext.RequestServices.GetRequiredService <INodeServices>(); var hostEnv = Request.HttpContext.RequestServices.GetRequiredService <IHostingEnvironment>(); var applicationBasePath = hostEnv.ContentRootPath; var requestFeature = Request.HttpContext.Features.Get <IHttpRequestFeature>(); var unencodedPathAndQuery = requestFeature.RawTarget; var unencodedAbsoluteUrl = $"{Request.Scheme}://{Request.Host}{unencodedPathAndQuery}"; // ** TransferData concept ** // Here we can pass any Custom Data we want ! // By default we're passing down Cookies, Headers, Host from the Request object here TransferData transferData = new TransferData(); transferData.request = Request.AbstractRequestInfo(); //if (!Debugger.IsAttached) //{ transferData.appInsightsId = appSettings.AppInsightsId; //} //Prerender now needs CancellationToken System.Threading.CancellationTokenSource cancelSource = new System.Threading.CancellationTokenSource(); System.Threading.CancellationToken cancelToken = cancelSource.Token; // Prerender / Serialize application (with Universal) return(await Prerenderer.RenderToString( "/", nodeServices, cancelToken, new JavaScriptModuleExport(applicationBasePath + "/ClientApp/dist/main-server"), unencodedAbsoluteUrl, unencodedPathAndQuery, transferData, // Our simplified Request object & any other CustommData you want to send! 30000, Request.PathBase.ToString() )); }
/// <summary> /// 初始化 /// </summary> private void OnCmdInitialize() { new Thread((ThreadStart)delegate() { Application.Current.Dispatcher.Invoke(new Action(() => { #region 获取应用程序配置 SQLiteAccessor accessor = SQLiteAccessor.Instance; AppConfiguration appConfig = null; if (accessor != null) { appConfig = accessor.LoadAppConfig(); } if (appConfig == null) { appConfig = new AppConfiguration(); } _globalParams.AppConfig = appConfig; #endregion #region 加载语言 string lang = appConfig.LangFlag; LoadLanguage(lang); #endregion string msg = ""; CommonStaticMethod.GetLanguageString("正在初始化...", "Lang_StartUp_Initialize", out msg); LoadingMsg = msg; CustomTransform.Delay(200, 10); #region 关闭调节小软件 KillBrightAdjustToolProc(ConstValue.BRIGHT_ADJUST_TOOL_PROC_NAME); #endregion #region 重新启动服务 CommonStaticMethod.GetLanguageString("正在启动服务...", "Lang_StartUp_StartServer", out msg); LoadingMsg = msg; CustomTransform.Delay(200, 10); RestartServerProc(SERVER_PATH); #endregion #region 启动定时调节小软件 CommonStaticMethod.GetLanguageString("正在启动亮度调节软件...", "Lang_StartUp_StartBright", out msg); LoadingMsg = msg; CustomTransform.Delay(200, 10); StartBrightAdjustToolProc(ConstValue.BRIGHT_ADJUST_TOOL_PROC_NAME, ConstValue.BRIGHT_ADJUST_TOOL_START_FILE); #endregion #region 获取本地数据 //res = CustomTransform.LoadScanProFile(ConstValue.SCANNER_PAGE_CONFIG_FILE, ref _globalParams.ScanBdProp); //MonitorSysData data; //MonitorSettingFileCreator.LoadConfigFile(_newMonitorFileName, out data); //_globalParams.MonitorSetting = data; CommonStaticMethod.GetLanguageString("正在获取数据...", "Lang_StartUp_GetData", out msg); LoadingMsg = msg; CustomTransform.Delay(200, 10); LoadColorTempMapping(); //加载 LoadRecentProjectFile(); LoadScanFileLib(); LoadSenderFileLib(); LoadSenderAndPortPicFile(); #endregion #region 注册服务 CommonStaticMethod.GetLanguageString("正在注册服务...", "Lang_StartUp_RegistServer", out msg); LoadingMsg = msg; CustomTransform.Delay(200, 10); InitalizeServerProxy(SystemType.Synchronized); bool res = RegisterToServer(SystemType.Synchronized); if (!res) { _registToServerTimer.Start(); } #endregion })); }).Start(); }
/// <summary> /// load static Caetgory.xml file /// </summary> private static void LoadXml() { XmlReader xr = XmlReader.Create(AppConfiguration.GetModuleWorkspacePath("DDM") + "/DummyData/Category.xml"); _source.Load(xr); }
public GeoFencing(IOptions <AppConfiguration> config) { _config = config.Value; }
private void InitializeAppConfig() { //获取应用程序配置 SQLiteAccessor accessor = SQLiteAccessor.Instance; AppConfiguration appConfig = null; if (accessor != null) { appConfig = accessor.LoadAppConfig(); } if (appConfig == null) { appConfig = new AppConfiguration(); } _globalParams.AppConfig = appConfig; //加载语言 string lang = appConfig.LangFlag; LoadLanguage(lang); LoadingMessage = GetLocalizationMessage("正在初始化...", "Lang_StartUp_Initialize"); }