public Product(ProductConfig config) { Id = config.Id; Name = config.Name; ProductType = config.Type; ProductSubType = config.SubType; }
private List <ProductConfig> CreateRequestProductInfos() { List <ProductConfig> productInfos = new List <ProductConfig>(); ProductConfig productInfo = new ProductConfig() { BasePortocalFilterInfo = new BasePortocalFilterInfo() { BeginMark = new byte[] { }, EndMark = new byte[] { }, ProtoType = ProtoType.ShortMessage, Size = 0, Terminator = new byte[] { } }, ProductOID = Guid.NewGuid().ToString() }; productInfos.Add(productInfo); productInfo = new ProductConfig() { BasePortocalFilterInfo = new BasePortocalFilterInfo() { BeginMark = new byte[] { }, EndMark = new byte[] { }, ProtoType = ProtoType.ShortMessage, Size = 10, Terminator = new byte[] { } }, ProductOID = Guid.NewGuid().ToString() }; productInfos.Add(productInfo); return(productInfos); }
private void button_configure_product_Click(object sender, RoutedEventArgs e) { ProductConfig config = new ProductConfig(CrudProduct); config.Closed += ProductConfigClosed; config.ShowDialog(); }
public static void LoadConfiguration() { var configPath = System.AppDomain.CurrentDomain.BaseDirectory + @"Product.config"; var productConfig = XmlSerialization.ReadFromXmlFile <ProductConfig>(configPath); _productConfig = productConfig; }
public void PurchaseWithCorrectChange() { var acceptedCoins = new List <Coin>() { CoinConfig.GetDime(), CoinConfig.GetNickel(), CoinConfig.GetQuarter() }; var productsToStock = new List <Product>() { ProductConfig.GetCandy(), ProductConfig.GetChips(), ProductConfig.GetCola() }; var change = new List <Coin>(); change.AddRange(BulkAddChange(10, CoinConfig.GetQuarter())); change.AddRange(BulkAddChange(10, CoinConfig.GetNickel())); var vendineMachine = SetUpMachine(acceptedCoins, productsToStock, change); var coin = new KeyValuePair <decimal, decimal>(CoinConfig.GetQuarter().Weight, CoinConfig.GetQuarter().Width); var currency = new List <KeyValuePair <decimal, decimal> >(); currency.Add(coin); currency.Add(coin); vendineMachine.AcceptCurrency(currency); vendineMachine.MakeSelection(ProductConfig.GetChips()); }
public void ShouldNotCreateApprovalRequiredOrSubscriptionsLimitIfSubscriptionRequiredIsFalse() { // arrange ProductTemplateCreator productTemplateCreator = ProductTemplateCreatorFactory.GenerateProductTemplateCreator(); CreatorConfig creatorConfig = new CreatorConfig() { products = new List <ProductConfig>() }; ProductConfig product = new ProductConfig() { DisplayName = "displayName", Description = "description", Terms = "terms", SubscriptionRequired = false, ApprovalRequired = true, SubscriptionsLimit = 1, State = "state" }; creatorConfig.products.Add(product); // act var productTemplate = productTemplateCreator.CreateProductTemplate(creatorConfig); ProductsTemplateResource productsTemplateResource = (ProductsTemplateResource)productTemplate.Resources[0]; // assert Assert.Equal($"[concat(parameters('{ParameterNames.ApimServiceName}'), '/{product.Name}')]", productsTemplateResource.Name); Assert.Equal(product.DisplayName, productsTemplateResource.Properties.DisplayName); Assert.Equal(product.Description, productsTemplateResource.Properties.Description); Assert.Equal(product.Terms, productsTemplateResource.Properties.Terms); Assert.Equal(product.SubscriptionRequired, productsTemplateResource.Properties.SubscriptionRequired); Assert.Null(productsTemplateResource.Properties.SubscriptionsLimit); Assert.Null(productsTemplateResource.Properties.ApprovalRequired); Assert.Equal(product.State, productsTemplateResource.Properties.State); }
public void ShouldCreateProductFromCreatorConfig() { // arrange ProductTemplateCreator productTemplateCreator = ProductTemplateCreatorFactory.GenerateProductTemplateCreator(); CreatorConfig creatorConfig = new CreatorConfig() { products = new List <ProductConfig>() }; ProductConfig product = new ProductConfig() { displayName = "displayName", description = "description", terms = "terms", subscriptionRequired = true, approvalRequired = true, subscriptionsLimit = 1, state = "state" }; creatorConfig.products.Add(product); // act Template productTemplate = productTemplateCreator.CreateProductTemplate(creatorConfig); ProductsTemplateResource productsTemplateResource = (ProductsTemplateResource)productTemplate.resources[0]; // assert Assert.Equal($"[concat(parameters('ApimServiceName'), '/{product.displayName}')]", productsTemplateResource.name); Assert.Equal(product.displayName, productsTemplateResource.properties.displayName); Assert.Equal(product.description, productsTemplateResource.properties.description); Assert.Equal(product.terms, productsTemplateResource.properties.terms); Assert.Equal(product.subscriptionsLimit, productsTemplateResource.properties.subscriptionsLimit); Assert.Equal(product.subscriptionRequired, productsTemplateResource.properties.subscriptionRequired); Assert.Equal(product.approvalRequired, productsTemplateResource.properties.approvalRequired); Assert.Equal(product.state, productsTemplateResource.properties.state); }
public PolicyTemplateResource CreateProductPolicyTemplateResource(ProductConfig product, string[] dependsOn) { if (string.IsNullOrEmpty(product.Name)) { product.Name = product.DisplayName; } Uri uriResult; bool isUrl = Uri.TryCreate(product.policy, UriKind.Absolute, out uriResult) && (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps); // create policy resource with properties PolicyTemplateResource policyTemplateResource = new PolicyTemplateResource() { Name = $"[concat(parameters('{ParameterNames.ApimServiceName}'), '/{product.Name}/policy')]", Type = ResourceTypeConstants.ProductPolicy, ApiVersion = GlobalConstants.ApiVersion, Properties = new PolicyTemplateProperties() { // if policy is a url inline the url, if it is a local file inline the file contents Format = isUrl ? "rawxml-link" : "rawxml", PolicyContent = isUrl ? product.policy : this.fileReader.RetrieveLocalFileContents(product.policy) }, DependsOn = dependsOn }; return(policyTemplateResource); }
public MSIInstaller(string productName, ProductConfig productConfig, string installerPath, string logsPath) { this.ProductName = productName; this.ProductConfig = productConfig; this.InstallerPath = installerPath; this.LogsPath = logsPath; }
public IActionResult SaveChange(ProductConfig model) { string note = AppGlobal.InitString; int result = 0; if (model.Id > 0) { model.Initialization(InitType.Update, RequestUserID); result = _productConfigResposistory.Update(model.Id, model); if (result > 0) { note = AppGlobal.Success + " - " + AppGlobal.EditSuccess; } else { note = AppGlobal.Success + " - " + AppGlobal.EditFail; } } else { model.Initialization(InitType.Insert, RequestUserID); result = _productConfigResposistory.Create(model); if (result > 0) { note = AppGlobal.Success + " - " + AppGlobal.CreateSuccess; } else { note = AppGlobal.Success + " - " + AppGlobal.CreateFail; } } return(Json(note)); }
public void ShouldCreateProductPolicyTemplateResourceFromCreatorConfigWithCorrectContent() { // arrange PolicyTemplateCreator policyTemplateCreator = PolicyTemplateCreatorFactory.GeneratePolicyTemplateCreator(); CreatorConfig creatorConfig = new CreatorConfig() { products = new List <ProductConfig>() }; ProductConfig product = new ProductConfig() { displayName = "displayName", description = "description", terms = "terms", subscriptionRequired = true, approvalRequired = true, subscriptionsLimit = 1, state = "state", policy = "http://someurl.com" }; creatorConfig.products.Add(product); string[] dependsOn = new string[] { "dependsOn" }; // act PolicyTemplateResource policyTemplateResource = policyTemplateCreator.CreateProductPolicyTemplateResource(product, dependsOn); // assert Assert.Equal($"[concat(parameters('apimServiceName'), '/{product.displayName}/policy')]", policyTemplateResource.name); Assert.Equal("rawxml-link", policyTemplateResource.properties.format); Assert.Equal(product.policy, policyTemplateResource.properties.value); Assert.Equal(dependsOn, policyTemplateResource.dependsOn); }
public ProductRepository(ILogger log, IConfig store) { _log = log; _store = store; //SQL Azure etc connectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; config = store.ProductConfig; }
protected override void OnModelCreating(ModelBuilder modelBuilder) { CustomerConfig.SetEntityBuilder(modelBuilder.Entity <Customer>()); OrderConfig.SetEntityBuilder(modelBuilder.Entity <Order>()); OrderProductsConfig.SetEntityBuilder(modelBuilder.Entity <Order2Product>()); ProductConfig.SetEntityBuilder(modelBuilder.Entity <Product>()); base.OnModelCreating(modelBuilder); }
public ApplicationConfig() { Logging = new Logging(); Database = new DatabaseConfig(); Document = new DocumentConfig(); Product = new ProductConfig(); Insurer = new InsurerConfig(); Authentication = new AuthenticationConfig(); }
public ActionResult <ProductConfig> Post([FromBody] ProductConfig productConfig) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var addedConfig = ProductConfigRepository.AddDocument(productConfig).GetAwaiter().GetResult(); return(Ok(addedConfig)); }
public void ShouldCreateProductSubscriptionTemplateResourceFromCreatorConfigWithCorrectContent() { // arrange SubscriptionTemplateCreator subscriptionTemplateCreator = new SubscriptionTemplateCreator(); CreatorConfig creatorConfig = new CreatorConfig() { products = new List <ProductConfig>() }; ProductConfig product = new ProductConfig() { name = "productName", displayName = "displayName", description = "description", terms = "terms", subscriptionRequired = true, approvalRequired = true, subscriptionsLimit = 1, state = "state", }; SubscriptionConfig subscription = new SubscriptionConfig() { name = "subscriptionName", ownerId = "user/ownerId", displayName = "displayName", primaryKey = "primaryKey", secondaryKey = "secondaryKey", state = "active", allowTracing = true, }; product.subscriptions = new List <SubscriptionConfig>(); product.subscriptions.Add(subscription); creatorConfig.products.Add(product); var dependsOn = new[] { $"[resourceId('Microsoft.ApiManagement/service/products', parameters('ApimServiceName'), '{product.name}')]" }; // act var subscriptionsTemplateResources = subscriptionTemplateCreator.CreateSubscriptionsTemplateResources(product, dependsOn); // assert var subscriptionsTemplateResource = subscriptionsTemplateResources[0]; Assert.Equal($"/products/{product.name}", subscriptionsTemplateResource.properties.scope); Assert.Equal(subscription.displayName, subscriptionsTemplateResource.properties.displayName); Assert.Equal(subscription.primaryKey, subscriptionsTemplateResource.properties.primaryKey); Assert.Equal(subscription.secondaryKey, subscriptionsTemplateResource.properties.secondaryKey); Assert.Equal(subscription.state, subscriptionsTemplateResource.properties.state); Assert.Equal(subscription.allowTracing, subscriptionsTemplateResource.properties.allowTracing); }
/// <summary> /// 启动 /// </summary> /// <param name="product">产品</param> /// <param name="devices">设备</param> /// <param name="daqService">采集服务</param> /// <returns></returns> public int Startup(ProductConfig product, ConcurrentDictionary <string, DAQDevice> devices, DAQService daqService) { int rtn = 1; this._productConfig = product; this._devices = devices; this._dAQService = daqService; foreach (DAQDevice dev in _devices.Values) { _devsSN.TryAdd(dev.SN, dev); } return(rtn); }
public List <GroupTemplateResource> CreateProductGroupTemplateResources(ProductConfig product, string[] dependsOn) { // create a products/apis association resource for each product provided in the config file List <GroupTemplateResource> productGroupTemplates = new List <GroupTemplateResource>(); // products is comma separated list of productIds string[] groupNames = product.groups.Split(", "); foreach (string groupName in groupNames) { GroupTemplateResource productAPITemplate = this.CreateProductGroupTemplateResource(groupName, product.Name, dependsOn); productGroupTemplates.Add(productAPITemplate); } return(productGroupTemplates); }
/// <summary> /// 加载商品配置 /// </summary> /// <param name="fileName">商品配置文件路径</param> /// <returns></returns> public ProductConfig LoadProductConfig(string fileName) { LogHelper.Logger.Info(String.Format("Loading ProductConfig @[{0}]", fileName)); if (!File.Exists(fileName)) { throw new ArgumentException(string.Format("not exist file path [{0}]", fileName)); } ProductConfig config = XmlHelper.LoadXmlFile <ProductConfig>(fileName); if ((config != null) && (config.Products != null)) { LogHelper.Logger.Info(String.Format("Loading ProductConfig Completed. Loaded Products Count is [{0}]", config.Products.Count.ToString())); } return(config); }
public ActionResult <string> SaveChange(ProductConfig model) { Result routeResult; int result = 0; if (model.Id > 0) { model.Initialization(InitType.Update, RequestUserID); result = _productConfigResposistory.Update(model.Id, model); if (result > 0) { routeResult = new Result() .setResultType(ResultType.Success) .setMessage(AppGlobal.EditSuccess); } else { routeResult = new Result() .setResultType(ResultType.Error) .setErrorType(ErrorType.EditError) .setMessage(AppGlobal.EditFail); } } else { model.Initialization(InitType.Insert, RequestUserID); result = _productConfigResposistory.Create(model); if (result > 0) { routeResult = new Result() .setResultType(ResultType.Success) .setMessage(AppGlobal.CreateSuccess); } else { routeResult = new Result() .setResultType(ResultType.Error) .setErrorType(ErrorType.InsertError) .setMessage(AppGlobal.CreateFail); } } return(ObjectToJson(routeResult)); }
public IActionResult Create(ProductConfig model) { string note = AppGlobal.InitString; model.Initialization(InitType.Insert, RequestUserID); int result = _productConfigResposistory.Create(model); if (result > 0) { note = AppGlobal.Success + " - " + AppGlobal.CreateSuccess; } else { note = AppGlobal.Success + " - " + AppGlobal.CreateFail; } return(Json(note)); }
public static IProduct CreateInstance() { var builder = new ConfigurationBuilder() //.SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddEnvironmentVariables(); IConfigurationRoot configuration = builder.Build(); ProductConfig productConfig = new ProductConfig(); configuration.GetSection("ProductCollection").Bind(productConfig); var prodFullName = $"{productConfig.ProductPrimay.AssemblyName}.{productConfig.ProductPrimay.ProductName}"; var type = Type.GetType(prodFullName); return((IProduct)Activator.CreateInstance(type)); }
public void ShouldCreateCorrectNumberOfProductGroupTemplateResourcesFromCreatorConfig() { // arrange ProductGroupTemplateCreator productgroupTemplateCreator = new ProductGroupTemplateCreator(); ProductConfig config = new ProductConfig() { groups = "1, 2, 3" }; int count = 3; string[] dependsOn = new string[] { "dependsOn" }; // act List <ProductGroupsValue> productAPITemplateResources = productgroupTemplateCreator.CreateProductGroupTemplateResources(config, dependsOn); // assert Assert.Equal(count, productAPITemplateResources.Count); }
static IEnumerable Installers() { foreach (string productName in BuildConfig.ProductNames) { ProductConfig productConfig = BuildConfig.Products[productName]; IEnumerable <string> installerPaths = Directory .EnumerateFiles(pathsProvider.OutDir, $"{productName}-*.msi", SearchOption.AllDirectories) .Where(filename => new Regex(@$ "{productName}-\d.*\.msi").IsMatch(filename)); foreach (string installerPath in installerPaths) { MSIInstaller installer = new MSIInstaller(productName, productConfig, installerPath, pathsProvider.TestLogsDir); TestCaseData td = new TestCaseData(installer); td.SetName($"{productName} ({installerPath})"); yield return(td); } } }
public IHttpActionResult Get(int accountId, int campaignId, int documentId) { var config = new ProductConfig { AccountId = accountId, CampaignId = campaignId, DocumentId = documentId, Dials = new List <Dial> { new Dial { DialName = "RetailPrice", ControlType = ControlType.Text }, new Dial { DialName = "GrowerAddress", ControlType = ControlType.Text } } }; return(Json(config)); }
private static void EditCapacity(string path, string targetName, ProductConfig product) { var projPath = PBXProject.GetPBXProjectPath(path); var cap = new ProjectCapabilityManager(projPath, product.EntitlementFile, targetName); cap.AddInAppPurchase(); cap.AddKeychainSharing(new[] { product.KeyChainGroup }); var links = product.UniversalLinks; if (links != null && links.Count > 0) { cap.AddAssociatedDomains(links.ToArray()); } cap.WriteToFile(); }
public IActionResult SaveFiles(Product model) { if (Request.Form.Files.Count > 0) { List <ProductConfig> list = new List <ProductConfig>(); for (int i = 0; i < Request.Form.Files.Count; i++) { var file = Request.Form.Files[i]; if (file != null) { string fileExtension = Path.GetExtension(file.FileName); string fileName = Path.GetFileNameWithoutExtension(file.FileName); fileName = AppGlobal.SetName(fileName); fileName = model.ID + "-" + fileName + "-" + AppGlobal.DateTimeCode + fileExtension; var physicalPath = Path.Combine(_hostingEnvironment.WebRootPath, AppGlobal.URLProduct, fileName); using (var stream = new FileStream(physicalPath, FileMode.Create)) { file.CopyTo(stream); ProductConfig productConfig = new ProductConfig(); productConfig.Initialization(InitType.Insert, RequestUserID); productConfig.ParentID = model.ID; productConfig.Title = model.Title; productConfig.FileName = fileName; productConfig.URL = AppGlobal.Domain + AppGlobal.URLProduct + "/" + fileName; productConfig.Note = fileExtension; try { _productConfigRepository.Create(productConfig); } catch (Exception e) { string mes = e.Message; } } } } } return(RedirectToAction("DetailFiles", "Product", new { ID = model.ID })); }
public void Purchase() { var acceptedCoins = new List <Coin>() { CoinConfig.GetDime(), CoinConfig.GetNickel(), CoinConfig.GetQuarter() }; var productsToStock = new List <Product>() { ProductConfig.GetCandy(), ProductConfig.GetChips(), ProductConfig.GetCola() }; var change = new List <Coin>(); change.AddRange(BulkAddChange(10, CoinConfig.GetQuarter())); change.AddRange(BulkAddChange(10, CoinConfig.GetNickel())); var vendineMachine = SetUpMachine(acceptedCoins, productsToStock, change); }
public static Order BuildOrderFromInput(InputOrder inputOrder) { UiEmulator.WriteInputOrder(inputOrder); var order = new Order(new OrderConfig { Id = inputOrder.Id, AgentId = inputOrder.AgentId }); var productConfig = new ProductConfig { Id = inputOrder.ProductId, Name = inputOrder.ProductName, Type = inputOrder.ProductType, SubType = inputOrder.ProductSubType }; var product = new Product(productConfig); order.SetProduct(product); return(order); }
public void ShouldCreateProductAPIFromCreatorConfig() { // arrange ProductAPITemplateCreator productAPITemplateCreator = new ProductAPITemplateCreator(new TemplateBuilder()); CreatorConfig creatorConfig = new CreatorConfig() { products = new List <ProductConfig>(), apis = new List <APIConfig>() }; ProductConfig product = new ProductConfig() { Name = "productName", DisplayName = "display name", Description = "description", Terms = "terms", SubscriptionRequired = true, ApprovalRequired = true, SubscriptionsLimit = 1, State = "state" }; creatorConfig.products.Add(product); APIConfig api = new APIConfig() { name = "apiName", apiVersion = "apiVersion", apiVersionDescription = "apiVersionDescription", apiVersionSetId = "apiVersionSetId", apiRevision = "revision", apiRevisionDescription = "revisionDescription", suffix = "suffix", products = "productName", subscriptionRequired = true, authenticationSettings = new APITemplateAuthenticationSettings() { OAuth2 = new APITemplateOAuth2() { AuthorizationServerId = "", Scope = "" }, Openid = new APITemplateOpenID() { OpenIdProviderId = "", BearerTokenSendingMethods = new string[] { } }, SubscriptionKeyRequired = true }, openApiSpec = "https://petstore.swagger.io/v2/swagger.json", protocols = "https", isCurrent = true, type = "http" }; creatorConfig.apis.Add(api); // act Template productAPITemplate = productAPITemplateCreator.CreateProductAPITemplate(creatorConfig); ProductApiTemplateResource productAPITemplateResource = (ProductApiTemplateResource)productAPITemplate.Resources[0]; // assert Assert.Equal($"[concat(parameters('{ParameterNames.ApimServiceName}'), '/{product.Name}/{api.name}')]", productAPITemplateResource.Name); }