public static DataTable FindByNumDoc(string text) { ProviderData DProvider = new ProviderData(); DProvider.FindText = text; return(DProvider.FindByNumDoc(DProvider)); }
public static DataTable FindByBusinessName(string text) { ProviderData DProvider = new ProviderData(); DProvider.FindText = text; return(DProvider.FindByBusinessName(DProvider)); }
private static object CreateProvider(ProviderData prov) { Type type = Type.GetType(prov.Type); if (type == null) { throw new RemotingException("Type '" + prov.Type + "' not found"); } object[] args = new object[] { prov.CustomProperties, prov.CustomData }; object result; try { result = Activator.CreateInstance(type, args); } catch (Exception innerException) { if (innerException is TargetInvocationException) { innerException = ((TargetInvocationException)innerException).InnerException; } throw new RemotingException(string.Concat(new object[] { "An instance of provider '", type, "' could not be created: ", innerException.Message })); } return(result); }
/// <summary> /// Creates policy given the provider data /// </summary> /// <returns>Created policy object as returned by the service</returns> public ProtectionPolicyResource CreatePolicy() { string vaultName = (string)ProviderData[VaultParams.VaultName]; string resourceGroupName = (string)ProviderData[VaultParams.ResourceGroupName]; string policyName = (string)ProviderData[PolicyParams.PolicyName]; CmdletModel.WorkloadType workloadType = (CmdletModel.WorkloadType)ProviderData[PolicyParams.WorkloadType]; RetentionPolicyBase retentionPolicy = ProviderData.ContainsKey(PolicyParams.RetentionPolicy) ? (RetentionPolicyBase)ProviderData[PolicyParams.RetentionPolicy] : null; ValidateAzureSqlWorkloadType(workloadType); // validate RetentionPolicy ValidateAzureSqlRetentionPolicy(retentionPolicy); Logger.Instance.WriteDebug("Validation of Retention policy is successful"); // construct Hydra policy request ProtectionPolicyResource protectionPolicyResource = new ProtectionPolicyResource() { Properties = new AzureSqlProtectionPolicy() { RetentionPolicy = PolicyHelpers.GetServiceClientSimpleRetentionPolicy( (CmdletModel.SimpleRetentionPolicy)retentionPolicy) } }; return(ServiceClientAdapter.CreateOrUpdateProtectionPolicy( policyName, protectionPolicyResource, vaultName: vaultName, resourceGroupName: resourceGroupName).Body); }
public static string Delete(int idPro) { ProviderData DProvider = new ProviderData(); DProvider.IdProvider = idPro; return(DProvider.Delete(DProvider)); }
private static ProviderData ParseAttributes(IList <UnityProviderAttribute> attributes) { var data = new ProviderData(); for (int i = 0; i < attributes.Count; i++) { var attribute = attributes[i]; var provides = AsProvidesAttribute(attribute); if (provides != null) { data.Tag = provides.Tag; data.IsValid = true; continue; } var isSingleton = IsSingleton(attribute); if (isSingleton) { data.IsSingleton = true; continue; } var isInstance = IsInstance(attribute); if (isInstance) { data.IsInstance = true; continue; } } return(data); }
public RestAzureNS.AzureOperationResponse DisableProtectionWithDeleteData() { string vaultName = (string)ProviderData[VaultParams.VaultName]; string vaultResourceGroupName = (string)ProviderData[VaultParams.ResourceGroupName]; bool deleteBackupData = ProviderData.ContainsKey(ItemParams.DeleteBackupData) ? (bool)ProviderData[ItemParams.DeleteBackupData] : false; ItemBase itemBase = (ItemBase)ProviderData[ItemParams.Item]; AzureWorkloadSQLDatabaseProtectedItem item = (AzureWorkloadSQLDatabaseProtectedItem)ProviderData[ItemParams.Item]; string containerUri = ""; string protectedItemUri = ""; AzureVmWorkloadSQLDatabaseProtectedItem properties = new AzureVmWorkloadSQLDatabaseProtectedItem(); ValidateAzureWorkloadSQLDatabaseDisableProtectionRequest(itemBase); Dictionary <UriEnums, string> keyValueDict = HelperUtils.ParseUri(item.Id); containerUri = HelperUtils.GetContainerUri(keyValueDict, item.Id); protectedItemUri = HelperUtils.GetProtectedItemUri(keyValueDict, item.Id); return(ServiceClientAdapter.DeleteProtectedItem( containerUri, protectedItemUri, vaultName: vaultName, resourceGroupName: vaultResourceGroupName)); }
/// <summary> /// Triggers the disable protection operation for the given item /// </summary> /// <returns>The job response returned from the service</returns> public RestAzureNS.AzureOperationResponse DisableProtection() { string vaultName = (string)ProviderData[VaultParams.VaultName]; string vaultResourceGroupName = (string)ProviderData[VaultParams.ResourceGroupName]; bool deleteBackupData = ProviderData.ContainsKey(ItemParams.DeleteBackupData) ? (bool)ProviderData[ItemParams.DeleteBackupData] : false; ItemBase itemBase = (ItemBase)ProviderData[ItemParams.Item]; AzureFileShareItem item = (AzureFileShareItem)ProviderData[ItemParams.Item]; string containerUri = ""; string protectedItemUri = ""; AzureFileshareProtectedItem properties = new AzureFileshareProtectedItem(); if (deleteBackupData) { //Disable protection and delete backup data ValidateAzureFileShareDisableProtectionRequest(itemBase); Dictionary <UriEnums, string> keyValueDict = HelperUtils.ParseUri(item.Id); containerUri = HelperUtils.GetContainerUri(keyValueDict, item.Id); protectedItemUri = HelperUtils.GetProtectedItemUri(keyValueDict, item.Id); return(ServiceClientAdapter.DeleteProtectedItem( containerUri, protectedItemUri, vaultName: vaultName, resourceGroupName: vaultResourceGroupName)); } else { return(EnableOrModifyProtection(disableWithRetentionData: true)); } }
internal static ProviderListResult DeserializeProviderListResult(JsonElement element) { Optional <IReadOnlyList <ProviderData> > value = default; Optional <string> nextLink = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } List <ProviderData> array = new List <ProviderData>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(ProviderData.DeserializeProviderData(item)); } value = array; continue; } if (property.NameEquals("nextLink")) { nextLink = property.Value.GetString(); continue; } } return(new ProviderListResult(Optional.ToList(value), nextLink.Value)); }
public void CharacterizationTest(ProviderData receivedData, ProviderData existedData) { using (ApprovalResults.ForScenario(TestContext.CurrentContext.Test.Name)) { var res = processor.ProcessProviderData(receivedData, existedData); var s = res + "\n" + string.Join("\n", memoryAppender.GetEvents().Select(e => e.RenderedMessage)); Approvals.Verify(s); } }
public void Fail_IfDataNotExists() { var providerData = new ProviderData(); var serializedData = JsonConvert.SerializeObject(providerData); var processReport = providerProcessor.ProcessProviderData(serializedData); Approvals.Verify(processReport); }
public async Task <IActionResult> Put([FromBody] ProviderData providerData) { if (providerData is null) { throw new ArgumentNullException(nameof(providerData)); } var validation = new ProviderDataValidator().Validate(providerData); if (!validation.IsValid) { return(ErrorResult .BadRequest(validation) .ActionResult()); } var provider = await providersRepository .GetAsync(ProviderId) .ConfigureAwait(false); if (provider is null) { return(ErrorResult .NotFound($"A Provider with the ID '{ProviderId}' could not be found in this TeamCloud Instance") .ActionResult()); } var oldProviderData = await providerDataRepository .GetAsync(providerData.Id) .ConfigureAwait(false); if (oldProviderData is null) { return(ErrorResult .NotFound($"The Provider Data '{providerData.Id}' could not be found..") .ActionResult()); } var newProviderData = new ProviderDataDocument { ProviderId = provider.Id, Scope = ProviderDataScope.System }; newProviderData.PopulateFromExternalModel(providerData); var updateResult = await orchestrator .UpdateAsync(newProviderData) .ConfigureAwait(false); var returnUpdateResult = updateResult.PopulateExternalModel(); return(DataResult <ProviderData> .Ok(returnUpdateResult) .ActionResult()); }
private ProviderData GetProviderData() { var providerData = new ProviderData(); GetProviderName(ref providerData); GetRoles(ref providerData); GetRegion(ref providerData); GetWhiteListIps(ref providerData); return(providerData); }
public ProcessReport ProcessProviderData(ProviderData data, ProviderData existingData) { if (existingData != null && data.Timestamp < existingData.Timestamp) { log.InfoFormat("Outdated provider data. ProviderId {0} Received timestamp: {1} database timestamp {2}", data.ProviderId, data.Timestamp, existingData.Timestamp); return(new ProcessReport(false, "Outdated data")); } //before refactoring //var errors = ValidateNames(data.Products) // .Concat(data.Products.SelectMany(ValidatePricesAndMeasureUnitCodes)) // .ToArray(); //incorrect refactoring //var errors = data.Products // .SelectMany(p => productValidator.ValidateProduct(p)) // .ToArray(); //correct refactoring var errors = data.Products .SelectMany(p => productValidator.ValidateProduct(p)) .OrderByDescending(validationResult => validationResult.Severity) .ToArray(); if (errors.Any()) { return(new ProcessReport(false, "Product validation errors", errors)); } if (existingData == null) { repo.Save(data); } else if (data.ReplaceData) { log.InfoFormat("Provider {0} products replaced. Deleted: {1} Added: {2}", data.ProviderId, existingData.Products.Length, data.Products.Length); repo.RemoveById(existingData.Id); repo.Save(data); } else { var actualProducts = existingData.Products.Where(p => data.Products.All(d => d.Id != p.Id)).ToList(); var updatedCount = existingData.Products.Length - actualProducts.Count; var newCount = data.Products.Length - updatedCount; log.InfoFormat("Provider {0} products update. New: {1} Updated: {2}", data.ProviderId, newCount, updatedCount); existingData.Products = actualProducts.Concat(data.Products).ToArray(); repo.Update(existingData); } log.InfoFormat("New data {0}, Existing data {1}", FormatData(data), FormatData(existingData)); return(new ProcessReport(true, "OK")); }
/// <summary> /// Creates policy given the provider data /// </summary> /// <returns>Created policy object as returned by the service</returns> public ProtectionPolicyResponse CreatePolicy() { string policyName = (string)ProviderData[PolicyParams.PolicyName]; Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.WorkloadType workloadType = (Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.WorkloadType)ProviderData[PolicyParams.WorkloadType]; RetentionPolicyBase retentionPolicy = ProviderData.ContainsKey(PolicyParams.RetentionPolicy) ? (RetentionPolicyBase)ProviderData[PolicyParams.RetentionPolicy] : null; SchedulePolicyBase schedulePolicy = ProviderData.ContainsKey(PolicyParams.SchedulePolicy) ? (SchedulePolicyBase)ProviderData[PolicyParams.SchedulePolicy] : null; // do validations ValidateAzureVMWorkloadType(workloadType); ValidateAzureVMSchedulePolicy(schedulePolicy); Logger.Instance.WriteDebug("Validation of Schedule policy is successful"); // validate RetentionPolicy ValidateAzureVMRetentionPolicy(retentionPolicy); Logger.Instance.WriteDebug("Validation of Retention policy is successful"); // update the retention times from backupSchedule to retentionPolicy after converting to UTC CopyScheduleTimeToRetentionTimes((CmdletModel.LongTermRetentionPolicy)retentionPolicy, (CmdletModel.SimpleSchedulePolicy)schedulePolicy); Logger.Instance.WriteDebug("Copy of RetentionTime from with SchedulePolicy to RetentionPolicy is successful"); // Now validate both RetentionPolicy and SchedulePolicy together PolicyHelpers.ValidateLongTermRetentionPolicyWithSimpleRetentionPolicy( (CmdletModel.LongTermRetentionPolicy)retentionPolicy, (CmdletModel.SimpleSchedulePolicy)schedulePolicy); Logger.Instance.WriteDebug("Validation of Retention policy with Schedule policy is successful"); // construct Service Client policy request ProtectionPolicyRequest serviceClientRequest = new ProtectionPolicyRequest() { Item = new ProtectionPolicyResource() { Properties = new AzureIaaSVMProtectionPolicy() { RetentionPolicy = PolicyHelpers.GetServiceClientLongTermRetentionPolicy( (CmdletModel.LongTermRetentionPolicy)retentionPolicy), SchedulePolicy = PolicyHelpers.GetServiceClientSimpleSchedulePolicy( (CmdletModel.SimpleSchedulePolicy)schedulePolicy) } } }; return(ServiceClientAdapter.CreateOrUpdateProtectionPolicy( policyName, serviceClientRequest)); }
public void ProcessProviderData_ProviderUpdateMustHaveHappened_WhenCorrectData() { var providerData = new ProviderData { Products = new[] { new ProductData() } }; var message = JsonConvert.SerializeObject(providerData); A.CallTo(() => provider.FindByProviderId(A <Guid> ._)).Returns(providerData); processor.ProcessProviderData(message); A.CallTo(() => provider.Update(A <ProviderData> ._)).MustHaveHappened(); }
public ProviderEditorForm() { providerData = new ProviderData(); InitializeComponent(); this.wizard.PageIndex = 0; ipClient = new WOSI.NET.inTELIPhone.inTELIPhoneClient(5064, 1, WOSI.NET.inTELIPhone.NATTraversalType.None); ipClient.ProfileRegistered += new WOSI.NET.inTELIPhone.SIPProfileEventHandler(ipClient_ProfileRegistered); ipClient.ProfileRegistrationError += new WOSI.NET.inTELIPhone.SIPProfileEventHandler(ipClient_ProfileRegistrationError); }
private ProcessReport Verify(string measureCode, string name, decimal price, ProviderData dataOnServer, int?code, MeasureUnit measureUnit, DateTime timestamp) { data.Timestamp = timestamp; data.Products = new[] { new ProductData() { Id = new Guid(), MeasureUnitCode = measureCode, Name = name, Price = price } }; dataSerialized = JsonConvert.SerializeObject(data); A.CallTo(() => repository.FindByProviderId(A <Guid> .Ignored)).Returns(dataOnServer); A.CallTo(() => productsReference.FindCodeByName(A <string> .Ignored)).Returns(code); A.CallTo(() => measureUnitsReference.FindByCode(A <string> .Ignored)).Returns(measureUnit); return(new ProviderProcessor(productsReference, measureUnitsReference, repository).ProcessProviderData(dataSerialized)); }
internal void Setup() { NetshFirewallRuleNameAvailable = MockRepository.GenerateMock <INetshFirewallRuleNameAvailable>(); Logger = MockRepository.GenerateMock <ILogger>(); ExecutableProcessQueue = MockRepository.GenerateMock <IExecutableProcessQueue>(); ExecutableProcessQueue.Stub(x => x.Enqueue(Arg <string> .Is.Anything, Arg <string> .Is.Anything)).Return( ExecutableProcessQueue); SetProviderData = new SetProviderData(ExecutableProcessQueue, NetshFirewallRuleNameAvailable, Logger); ProviderData = GetProviderDataWithFakeRoles(); }
public void Handle(ITracingContext tracingContext, Object Provider) { if (Provider is Dictionary <string, object> ProviderData) { var MethodName = ProviderData["MethodName"].ToString(); ProviderData.Remove("MethodName"); var Parameters = ProviderData.ToJson(); var Partial = tracingContext.CreateLocalPartialContext(MethodName); Partial.Context.Component = "MethodInvoke"; Partial.Context.LayerType = ChannelLayerType.Method; Partial.Context.Add("Method", MethodName); Partial.Context.Add("Parameters", Parameters); } }
public static ICustomMemberProvider GetCsvRowMemberProvider(object objectToDisplay) { var objectType = objectToDisplay.GetType(); if (!IsSupportedType(objectType)) return null; ProviderData providerData; if (!ProvidersDataCache.TryGetValue(objectType, out providerData)) { providerData = GetProviderData(objectType); ProvidersDataCache.Add(objectType, providerData); } return new CsvRowMemberProvider(objectToDisplay, providerData); }
public RestAzureNS.AzureOperationResponse <ProtectedItemResource> DisableProtection() { string vaultName = (string)ProviderData[VaultParams.VaultName]; string vaultResourceGroupName = (string)ProviderData[VaultParams.ResourceGroupName]; bool deleteBackupData = ProviderData.ContainsKey(ItemParams.DeleteBackupData) ? (bool)ProviderData[ItemParams.DeleteBackupData] : false; ItemBase itemBase = (ItemBase)ProviderData[ItemParams.Item]; AzureWorkloadSQLDatabaseProtectedItem item = (AzureWorkloadSQLDatabaseProtectedItem)ProviderData[ItemParams.Item]; AzureVmWorkloadSQLDatabaseProtectedItem properties = new AzureVmWorkloadSQLDatabaseProtectedItem(); return(EnableOrModifyProtection(disableWithRetentionData: true)); }
public void Return_Commande_With_BadgeId() { var options = new DbContextOptionsBuilder <CommandeContext>() .UseInMemoryDatabase(databaseName: "Return_Commande_With_BadgeId") .Options; using (var context = new CommandeContext(options)) { var providerData = new ProviderData(context); var commandes = new List <Commande>() { new Commande { Boisson = Boisson.Chocolat, BadgeId = 111, Mug = false }, new Commande { Boisson = Boisson.The, BadgeId = 222, Mug = true }, new Commande { Boisson = Boisson.Chocolat, BadgeId = 333, Mug = true } }; foreach (Commande cmd in commandes) { providerData.SaveCommande(cmd); } Check.That(context.Commandes.Count()).IsEqualTo(4); var result = context.Commandes.FirstOrDefault(p => p.BadgeId == 222); Check.That(result).IsNotNull(); result = context.Commandes.FirstOrDefault(p => p.BadgeId == 999); Check.That(result).IsNull(); } }
public void FailsWithMessageAboutError_WhenWarningsAndErrors() { var providerRepository = A.Fake <ProviderRepository>(); var productValidator = A.Fake <ProductValidator>(); var processor = A.Fake <ProviderProcessor>( opt => opt.WithArgumentsForConstructor( new object[] { providerRepository, productValidator })); //Пусть existingData не задана. A.CallTo(() => providerRepository.FindByProviderId(A.Dummy <Guid>())) .WithAnyArguments().Returns(null); //Если в данных содержится 2 продукта, var data = new ProviderData { ProviderId = Guid.NewGuid(), Products = new[] { new ProductData { Id = Guid.NewGuid() }, new ProductData { Id = Guid.NewGuid() } } }; var message = JsonConvert.SerializeObject(data); //причем у одного из них неверная цена, var product0 = data.Products[0]; var validationResult0 = new ProductValidationResult( product0, "Bad price", ProductValidationSeverity.Warning); A.CallTo(() => productValidator.ValidateProduct(product0)) .Returns(new[] { validationResult0 }); //а у другого продукта неизвестное имя, var product1 = data.Products[1]; var validationResult1 = new ProductValidationResult( product1, "Unknown product name", ProductValidationSeverity.Error); A.CallTo(() => productValidator.ValidateProduct(product1)) .Returns(new[] { validationResult1 }); //то протокол операции должен содержать сообщение о неизвестном имени продукта. processor.ProcessProviderData(message).ToString() .Should().Contain("Unknown product name"); }
public void ProcessProviderData_ReportFail_WhenIncorrectProduct() { var providerData1 = new ProviderData { Products = new[] { new ProductData() } }; var validationResult = new ProductValidationResult(); var message = JsonConvert.SerializeObject(providerData1); A.CallTo(() => productValidator.ValidateProductData(new [] { A <ProductData> ._ })).Returns(validationResult); var result = processor.ProcessProviderData(message); Approvals.Verify(result); }
private static IProvider GetInstantiatingProvider(Type type, ProviderData data) { if (data.IsSingleton) { return(new SingletonProvider(type, data.Tag)); } else if (data.IsInstance) { return(new InstanceProvider(type, data.Tag)); } else { return(null); } }
public frmDataProvider(string action, frmProviders owner) { InitializeComponent(); flag = 0; flag2 = 0; P = new Provider(); PD = new ProviderData(); L = new Log(); Action = action; provId = 0; telephoneId = 0; addressId = 0; mailId = 0; _owner = owner; }
public async Task <IActionResult> Post([FromBody] ProviderData providerData) { if (providerData is null) { throw new ArgumentNullException(nameof(providerData)); } var validation = new ProviderDataValidator().Validate(providerData); if (!validation.IsValid) { return(ErrorResult .BadRequest(validation) .ActionResult()); } var provider = await providersRepository .GetAsync(ProviderId) .ConfigureAwait(false); if (provider is null) { return(ErrorResult .NotFound($"A Provider with the ID '{ProviderId}' could not be found in this TeamCloud Instance") .ActionResult()); } var newProviderData = new ProviderDataDocument { ProviderId = provider.Id, Scope = ProviderDataScope.System }; newProviderData.PopulateFromExternalModel(providerData); var addResult = await orchestrator .AddAsync(newProviderData) .ConfigureAwait(false); var baseUrl = HttpContext.GetApplicationBaseUrl(); var location = new Uri(baseUrl, $"api/providers/{provider.Id}/data/{addResult.Id}").ToString(); var returnAddResult = addResult.PopulateExternalModel(); return(DataResult <ProviderData> .Created(returnAddResult, location) .ActionResult()); }
public void ProcessProviderData_ReportFail_WhenOutdatedTimestamp() { var providerData1 = new ProviderData { Timestamp = new DateTime(2020, 12, 15) }; var providerData2 = new ProviderData { Timestamp = new DateTime(2020, 12, 25) }; var message = JsonConvert.SerializeObject(providerData1); A.CallTo(() => provider.FindByProviderId(A <Guid> ._)).Returns(providerData2); var result = processor.ProcessProviderData(message); Approvals.Verify(result); }
private bool CheckRoleNameMatch(ProviderData providerData) { var result = false; var configFirewallRoles = GetFirewallRoles(); foreach (var roleName in providerData.roles) { if (configFirewallRoles.Any(configRoleName => string.Equals(roleName, configRoleName, StringComparison.OrdinalIgnoreCase))) { result = true; } } return(result); }
public static string NumProvider() { DataTable dtResutl = new ProviderData().NumProvider(); string numProvider; if (dtResutl.Rows.Count == 0) { numProvider = "00"; } else { numProvider = dtResutl.Rows[0][0].ToString(); numProvider = (numProvider.Length == 1) ? "0" + numProvider : numProvider; } return(numProvider); }
protected static ProviderData GetProviderData(Type objectType) { var data = new ProviderData() { properties = objectType.GetProperties().Where(IsMemberVisible).ToList(), fields = objectType.GetFields().Where(IsMemberVisible).ToList(), }; var param = Expression.Parameter(typeof(object)); data.valuesGet = Expression.Lambda<Func<object,object[]>>( Expression.NewArrayInit( typeof(object), Enumerable.Concat( data.properties.Select(pi => Expression.Property( Expression.TypeAs(param, objectType), pi)), data.fields.Select(fi => Expression.Field( Expression.TypeAs(param, objectType), fi)) ) ) , param).Compile(); return data; }
public MockTransformer(ProviderData providerData, ConfigurationContext context) { this.context = context; this.providerData = providerData; }
protected CsvRowMemberProvider(object objectToDisplay, ProviderData providerData) { this.objectToDisplay = objectToDisplay; this.providerData = providerData; }