static void Main(string[] args) { CommonFunctions.LogInConsole("Customer Service Started"); try { CommonFunctions.LogInConsole("Reading from Queue01..."); string nextFromQueue01 = AzureProvider.ReadNextFromQueue01(); CommonFunctions.LogInConsole("Next message from Queue01 : " + nextFromQueue01); string custNum = CommonFunctions.GetCustNumFromMessage(nextFromQueue01); if (!string.IsNullOrEmpty(custNum)) { var customer = CRMData.GetCustomerByCustNum(custNum); var custJson = CommonFunctions.Serialize(customer); CommonFunctions.LogInConsole(custJson); AzureProvider.PublishCustomerDataToTopic("Customer", custJson, _customerTopicName); CommonFunctions.LogInConsole("Customer data published in Topic : " + _customerTopicName); } else { CommonFunctions.LogInConsole("Customer Number not found"); } } catch (Exception ex) { CommonFunctions.LogInConsole(ex.Message); //CommonFunctions.LogInConsole(ex.StackTrace); CommonFunctions.LogInConsole("Next message from Queue01 Not Available"); } finally { CommonFunctions.LogInConsole("Customer Service Ended"); } }
static void Main(string[] args) { Console.WriteLine("Start - GeoPosition comparison"); string bingKey = " "; string azureKey = " "; string googleKey = " "; string argisKey = " "; List <SourceAddress> addressList = DataTest.GetAddress(); IReport reportComparer = new ReportComparer(); AzureMapsGeocodeMethodType azureMapsGeocodeMethodType = AzureMapsGeocodeMethodType.GeocodeSearchAddress; BingMapsGeocodeMethodType bingMapsGeocodeMethodType = BingMapsGeocodeMethodType.GeocodeFindLocationByQuery; GoogleGeocodeMethodType googleGeocodeMethodType = GoogleGeocodeMethodType.AddressAndComponentsWithPostalCode; AzureProvider azureMapsGeocoder = new AzureProvider(azureKey, azureMapsGeocodeMethodType, reportComparer); BingProvider bingMapsGeocoder = new BingProvider(bingKey, bingMapsGeocodeMethodType, reportComparer); GoogleProvider googleGeocoder = new GoogleProvider(googleKey, googleGeocodeMethodType, reportComparer); CartociudadProvider cartociudadGeocoder = new CartociudadProvider(reportComparer); ArcGisProvider arcGisProvider = new ArcGisProvider(argisKey, reportComparer); foreach (var address in addressList) { azureMapsGeocoder.GeocodeAsync(address).Wait(); bingMapsGeocoder.GeocodeAsync(address).Wait(); googleGeocoder.GeocodeAsync(address).Wait(); cartociudadGeocoder.GeocodeAsync(address).Wait(); arcGisProvider.GeocodeAsync(address).Wait(); } Console.WriteLine("End"); Console.ReadLine(); }
static void Main(string[] args) { try { CommonFunctions.LogInConsole("POC CRM App Started"); FileInfo fi = new FileInfo("C:\\MyWork\\SharedRepository\\Customer.csv"); var path = fi.FullName; var data = CommonFunctions.LoadDataFromCSV(path, sheetname); CRMData.LoadDataInCrmTable(data); AzureProvider.WriteBatchToQueue01(data.Select().ToList().Select(c => "CustNum=" + c["CustNum"].ToString()).ToList()); CommonFunctions.LogInConsole("Azure Queue notified with customer data update"); CommonFunctions.LogInConsole("POC CRM App Ended"); } catch (MessagingException mex) { CommonFunctions.LogInConsole(mex.Message); CommonFunctions.LogInConsole("Service Bus not available"); } catch (Exception ex) { CommonFunctions.LogInConsole(ex.Message); CommonFunctions.LogInConsole(ex.StackTrace); } }
private string SelectRegion(AzurePrepInputs inputs) { Console.WriteLine("Retrieving a list of Locations..."); string[] regions = AzureProvider.GetRegions(inputs.Credentials); int regionsCount = regions.Length; Console.WriteLine("Available locations: "); for (int currentRegion = 1; currentRegion <= regionsCount; ++currentRegion) { Console.WriteLine(currentRegion + ": " + regions[currentRegion - 1]); } for ( ;;) { Console.WriteLine("Please select Location from list: "); string answer = Console.ReadLine( ); int selection = 0; if (!int.TryParse(answer, out selection) || selection > regionsCount || selection < 1) { Console.WriteLine("Incorrect Location number."); continue; } if (ConsoleHelper.Confirm("Are you sure you want to select location " + regions[selection - 1] + "?")) { return(regions[selection - 1]); } } }
private string SelectResourceGroup(AzurePrepInputs inputs) { Console.WriteLine("Retrieving a list of Resource Groups..."); ResourceGroupExtended[] groups = AzureProvider.GetResourceGroups(inputs.Credentials); int count = groups.Length; Console.WriteLine("Available Resource Groups: "); for (int current = 1; current <= count; ++current) { Console.WriteLine(current + ": " + groups[current - 1].Name); } for ( ;;) { Console.WriteLine("Please select Resource Group from list: "); string answer = Console.ReadLine( ); int selection = 0; if (!int.TryParse(answer, out selection) || selection > count || selection < 1) { Console.WriteLine("Incorrect Resource Group number."); continue; } if (ConsoleHelper.Confirm("Are you sure you want to select Resource Group " + groups[selection - 1].Name + "?")) { return(groups[selection - 1].Name); } } }
static void Main(string[] args) { CommonFunctions.LogInConsole("Customer Service Started"); try { CommonFunctions.LogInConsole("Reading from Queue01..."); string nextFromQueue01 = AzureProvider.ReadNextFromQueue01(); CommonFunctions.LogInConsole("Next message from Queue01 : " + nextFromQueue01); string custNum = CommonFunctions.GetCustNumFromMessage(nextFromQueue01); if (!string.IsNullOrEmpty(custNum)) { var custJson = CommonFunctions.GetCustomerJson(custNum); CommonFunctions.LogInConsole(custJson); } else { CommonFunctions.LogInConsole("Customer Number not found"); } } catch (Exception ex) { CommonFunctions.LogInConsole(ex.Message); //CommonFunctions.LogInConsole(ex.StackTrace); CommonFunctions.LogInConsole("Next message from Queue01 Not Available"); } finally { CommonFunctions.LogInConsole("Customer Service Ended"); } }
private string SelectResourceGroup(AzurePrepInputs inputs) { Console.WriteLine("Retrieving a list of Resource Groups..."); ResourceGroupExtended[] groups = AzureProvider.GetResourceGroups(inputs.Credentials); int count = groups.Length; Console.WriteLine("Available Resource Groups: "); Console.WriteLine("0: Create new Resource Group."); for (int current = 1; current <= count; ++current) { Console.WriteLine(current + ": " + groups[current - 1].Name); } for ( ;;) { Console.WriteLine("Please select Resource Group from list: "); string answer = Console.ReadLine( ); int selection = 0; if (!int.TryParse(answer, out selection) || selection > count || selection < 0) { Console.WriteLine("Incorrect Resource Group number."); continue; } if (selection == 0) { if (ConsoleHelper.Confirm("Are you sure you want to create new Resource Group?")) { string resourceGroupName; for ( ;;) { Console.WriteLine("Enter a name for Resource Group (only letters and digits, less than 17 chars long)."); Console.WriteLine("(Note that fully qualified path may also be subject to further length restrictions.)"); resourceGroupName = Console.ReadLine( ); if (string.IsNullOrEmpty(resourceGroupName) || !CheckNamePrefix(resourceGroupName)) { Console.WriteLine("Namespace prefix should contain only letters and digits and have length less than 17."); continue; } if (ConsoleHelper.Confirm("Are you sure you want to create a Resource Group called " + resourceGroupName + "?")) { break; } } AzureProvider.CreateResourceGroup(inputs.Credentials, resourceGroupName, inputs.Location); return(resourceGroupName); } } else { if (ConsoleHelper.Confirm("Are you sure you want to select Resource Group " + groups[selection - 1].Name + "?")) { return(groups[selection - 1].Name); } } } }
public async Task <bool> DeleteDocument(BlobUploadModel documentData) { if (IsActiveProfile) { return(await AzureProvider.DeleteBlobAsync(documentData.FileUrl)); } return(false); }
public static IDataProvider GetProvider() //I'd pass parameters if I had more than 1. { Connection connection = new Connection(); //this is why I broke DI. IConnection iConnection = (IConnection)connection; AzureProvider azureProvider = new AzureProvider(iConnection); IDataProvider iDataProvider = (IDataProvider)azureProvider; return(iDataProvider); }
/// <summary> /// Update method implmentation /// </summary> public void Load(PSHost host) { ManagementService.Initialize(host, true); MFAConfig cfg = ManagementService.Config; AzureProvider otp = cfg.AzureProvider; this.IsDirty = cfg.IsDirty; this.TenantId = otp.TenantId; this.ThumbPrint = otp.ThumbPrint; this.PinRequired = otp.PinRequired; }
/// <summary> /// Update method implmentation /// </summary> public void Update(PSHost host) { ManagementService.Initialize(host, true); MFAConfig cfg = ManagementService.Config; AzureProvider otp = cfg.AzureProvider; cfg.IsDirty = true; otp.TenantId = this.TenantId; otp.ThumbPrint = this.ThumbPrint; otp.PinRequired = this.PinRequired; ManagementService.ADFSManager.WriteConfiguration(host); }
public async Task <string> UploadInspectionDocumnets(List <BlobUploadModel> documentData) { if (IsActiveProfile) { foreach (var document in documentData) { string fileUrl = await AzureProvider.UploadFilestoblobAsync(document.FileData, document.FileName.Split('.')[1], document.FileName); return(fileUrl); } } return(""); }
public ActionResult Index(AzureCredentialsModel model) { if (!ModelState.IsValid) { return(View(model)); } if (!AzureProvider.GetInstance(model.AccountName, model.AccountKey).AzureClientExists()) { model.CustomErrorMessage = "Invalid credentials."; return(View(model)); } SetCredentialsCookie(model.AccountName, model.AccountKey); return(RedirectToAction("Index", "Rules")); }
/// <summary> /// Update method implmentation /// </summary> public override void Update(PSHost host) { ManagementService.Initialize(host, true); MFAConfig cfg = ManagementService.Config; AzureProvider otp = cfg.AzureProvider; cfg.IsDirty = true; CheckUpdates(host); otp.Enabled = Enabled; otp.EnrollWizard = false; otp.ForceWizard = ForceWizardMode.Disabled; otp.PinRequired = false; otp.TenantId = this.TenantId; otp.ThumbPrint = this.ThumbPrint; otp.PinRequired = this.PinRequired; ManagementService.ADFSManager.WriteConfiguration(host); }
public void OneTimeSetup() { config = new ConfigurationBuilder() .AddJsonFile(Path.Combine(Environment.CurrentDirectory, "appsettings.test.json")) .Build(); testFile = Path.Combine(Environment.CurrentDirectory, "test.txt"); AppSettings appSettings = new AppSettings() { ConnectionString = config["ConnectionString"] }; appSettingsMoq = new Mock <IOptions <AppSettings> >(); appSettingsMoq.Setup(p => p.Value).Returns(appSettings); provider = new AzureProvider(appSettingsMoq.Object); provider.Initialize(); }
static void Main(string[] args) { Console.WriteLine("Start - GeoPosition comparison"); string bingKey = "bing-key"; string azureKey = "azure-key"; List <string> addressList = DataTest.GetAddress(); IReport reportComparer = new ReportComparer(); AzureProvider azureMaps = new AzureProvider(azureKey, reportComparer); BingProvider bingMaps = new BingProvider(bingKey, reportComparer); foreach (string address in addressList) { azureMaps.GeoPositionAsync(address).Wait(); bingMaps.GeoPositionAsync(address).Wait(); } Console.WriteLine("End"); Console.ReadLine(); }
static void Main(string[] args) { try { var custDataJson = AzureProvider.GetCustomerDataFromSubscription(_topicName, _subscriptionName); CommonFunctions.LogInConsole(custDataJson); var customer = CommonFunctions.Deserialize <CustomerDto>(custDataJson); var rows = CRMData.InsertCustomerInDestination02(customer); if (rows > 0) { CommonFunctions.LogInConsole("Customer data id#" + customer.Id + " process!"); } else { CommonFunctions.LogInConsole("Customer data id#" + customer.Id + " could not be processed!"); } } catch (Exception ex) { CommonFunctions.LogInConsole(ex.Message); CommonFunctions.LogInConsole(ex.StackTrace); } }
private string SelectRegion(AzurePrepInputs inputs) { Console.WriteLine("Retrieving a list of Locations..."); string[] regions = AzureProvider.GetRegions(inputs.Credentials); int regionsCount = regions.Length; Console.WriteLine("Available locations: "); for (int currentRegion = 1; currentRegion <= regionsCount; ++currentRegion) { string suffixMessage = string.Empty; if (regions[currentRegion - 1] == "East US") { //see https://github.com/MSOpenTech/connectthedots/issues/168 suffixMessage = " (creating new Resource Group is not supported)"; } Console.WriteLine(currentRegion + ": " + regions[currentRegion - 1] + suffixMessage); } for ( ;;) { Console.WriteLine("Please select Location from list: "); string answer = Console.ReadLine( ); int selection = 0; if (!int.TryParse(answer, out selection) || selection > regionsCount || selection < 1) { Console.WriteLine("Incorrect Location number."); continue; } if (ConsoleHelper.Confirm("Are you sure you want to select location " + regions[selection - 1] + "?")) { return(regions[selection - 1]); } } }
public void start(string args) { string callbackId = ""; try { JArray parameters = JArray.Parse(args); string parameter = (string)parameters[0]; callbackId = (string)parameters[1]; if (MessageProviderFactory.Instance.HasProvider(MessageProvider.AzureName)) { Logger.Info("The Azure Service Bus (ASB) notification plugin has already been started"); DispatchCommandResult(new PluginResult(PluginResult.Status.OK), callbackId); return; } Logger.Info("Will start Azure Service Bus (ASB) notification plugin"); string serviceBusHostname = null; string serviceNamespace = null; string sasKeyName = null; string sasKey = null; string brokerType = null; bool autoCreate = true; if (parameter == null) { StreamResourceInfo streamInfo = Application.GetResourceStream(new Uri("config.xml", UriKind.Relative)); if (streamInfo != null) { StreamReader reader = new StreamReader(streamInfo.Stream); XDocument document = XDocument.Parse(reader.ReadToEnd()); var preferences = from results in document.Descendants() where results.Name.LocalName == "preference" select new { name = (string)results.Attribute("name"), value = (string)results.Attribute("value") }; foreach (var preference in preferences) { if (preference.name == "sbHostName") { serviceBusHostname = preference.value; } else if (preference.name == "serviceNamespace") { serviceNamespace = preference.value; } else if (preference.name == "sasKeyName") { sasKeyName = preference.value; } else if (preference.name == "sasKey") { sasKey = preference.value; } else if (preference.name == "brokerType") { brokerType = preference.value; } else if (preference.name == "brokerAutoCreate") { autoCreate = bool.Parse(preference.value); } } } } else { JObject options = JObject.Parse(parameter); serviceBusHostname = (string)options["sbHostName"]; serviceNamespace = (string)options["serviceNamespace"]; sasKeyName = (string)options["sasKeyName"]; sasKey = (string)options["sasKey"]; JToken brokerTypeToken; if (options.TryGetValue("brokerType", out brokerTypeToken)) { brokerType = (string)brokerTypeToken; } JToken autoCreateToken; if (options.TryGetValue("brokerAutoCreate", out autoCreateToken)) { autoCreate = (bool)autoCreateToken; } } MessageProvider provider = new AzureProvider(Logger, serviceBusHostname, serviceNamespace, new AzureProvider.SharedAccessProperties(sasKeyName, sasKey), autoCreate, brokerType); MessageProviderFactory.Instance.AddProvider(provider); provider.SendAllPendingMessages(); DispatchCommandResult(new PluginResult(PluginResult.Status.OK), callbackId); } catch (Exception e) { Logger.WarnFormat("Cannot start Azure Service Bus notification plugin: {0}", e.Message); DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, e.Message), callbackId); } }
protected override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); _azureProvider = new AzureProvider(_accountName, _accountKey); }