public static string Mount() { CloudStorageAccount storageAccount; if (RoleEnvironment.IsEmulated) { storageAccount = CloudStorageAccount.DevelopmentStorageAccount; } else { storageAccount = CloudStorageAccount.Parse(connectionString); } LocalResource localCache = RoleEnvironment.GetLocalResource("InstanceDriveCache"); CloudDrive.InitializeCache(localCache.RootPath, localCache.MaximumSizeInMegabytes); CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); blobClient.GetContainerReference("drives").CreateIfNotExist(); myCloudDrive = storageAccount.CreateCloudDrive( blobClient .GetContainerReference("drives") .GetPageBlobReference("mysupercooldrive.vhd") .Uri.ToString() ); myCloudDrive.CreateIfNotExist(64); return(myCloudDrive.Mount(25, DriveMountOptions.None)); }
/// <summary> /// Main thread of execution of the Slave worker role instance. /// </summary> public override void Run() { // Initialize and run Slave. string workingDirectory = RoleEnvironment.GetLocalResource("LocalStorage").RootPath; IPEndPoint slaveEndpoint = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints ["Endpoint"].IPEndpoint; IPEndPoint masterEndpoint = RoleEnvironment.Roles["Research.MapReduce.CloudHost.Master" ].Instances[0].InstanceEndpoints["Endpoint"].IPEndpoint; int mapTaskSlotSize = int.Parse(RoleEnvironment.GetConfigurationSettingValue( "MapTaskSlotSize")); int reduceTaskSlotSize = int.Parse(RoleEnvironment.GetConfigurationSettingValue( "ReduceTaskSlotSize")); // Instantiate task tracker. TaskTracker slave = new TaskTracker(RoleEnvironment.CurrentRoleInstance.Id, workingDirectory, masterEndpoint, slaveEndpoint, mapTaskSlotSize, reduceTaskSlotSize, RoleEnvironment.GetConfigurationSettingValue( "StorageConnectionString")); slave.Start(); // Start the tracker. // Wait forever. while (true) { Thread.Sleep(30000); } }
public override bool OnStart() { Trace.WriteLine("WebRole.OnStart", "Error"); CloudStorageAccount storageAccount; try { FUSE.Weld.Azure.Configuration.SetConfigurationSettingPublisher(); storageAccount = Utility.GetStorageAccount(); Trace.WriteLine("WebRole.OnStart: Initializing Cache", "Verbose"); var localCache = RoleEnvironment.GetLocalResource("DriveCache"); CloudDrive.InitializeCache(localCache.RootPath, localCache.MaximumSizeInMegabytes); Trace.WriteLine("WebRole.OnStart: Creating Drive", "Verbose"); drive = new CloudDrive(new Uri(storageAccount.BlobEndpoint + "root/proxy.vhd"), storageAccount.Credentials); drive.CreateIfNotExist(10 * 1000); Trace.WriteLine("WebRole.OnStart: Mounting Drive", "Verbose"); var cloudDriveLetter = drive.Mount(localCache.MaximumSizeInMegabytes, DriveMountOptions.Force); } catch (Exception x) { Trace.TraceError("WebRole.OnStart:\n" + x.ToString()); } return(base.OnStart()); }
public override bool OnStart() { var appPath = RoleEnvironment.GetLocalResource("App").RootPath; var sm = new ServerManager(); sm.Sites[RoleEnvironment.CurrentRoleInstance.Id + "_Web"].Applications.First().VirtualDirectories.First().PhysicalPath = appPath; // Note that this can sometimes throw exceptions under the compute emulator when using multiple instances, // because they're trying to edit applicationHost.config simultaneously. Best to stick to a single instance. sm.CommitChanges(); Configure(); Sync(); RoleEnvironment.Changing += (_, e) => { // any config setting changes that aren't just the polling interval (which requires nothing, since the loop will just pick up the new value next time through) if (e.Changes.OfType <RoleEnvironmentConfigurationSettingChange>().Any(c => c.ConfigurationSettingName != "PollingIntervalInSeconds")) { Configure(); } }; return(base.OnStart()); }
public static ConfigSettings GetConfigSettings() { return(new ConfigSettings( RoleEnvironment.GetConfigurationSettingValue, name => RoleEnvironment.GetLocalResource(name).RootPath )); }
private static ProcessPerfEvents CreateLogFlushJob() { var logDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data", "Logs"); try { if (RoleEnvironment.IsAvailable) { var resource = RoleEnvironment.GetLocalResource("Logs"); if (resource != null) { logDirectory = Path.Combine(resource.RootPath); } } } catch { // Meh, so Azure isn't available... } return(new ProcessPerfEvents( TimeSpan.FromSeconds(10), logDirectory, new[] { "ExternalSearchService" }, timeout: TimeSpan.FromSeconds(10))); }
public override bool OnStart() { // Set the maximum number of concurrent connections ServicePointManager.DefaultConnectionLimit = 512; // Increase disk quota for mbrace filesystem cache. string customTempLocalResourcePath = RoleEnvironment.GetLocalResource("LocalMBraceCache").RootPath; Environment.SetEnvironmentVariable("TMP", customTempLocalResourcePath); Environment.SetEnvironmentVariable("TEMP", customTempLocalResourcePath); bool result = base.OnStart(); _config = Configuration.Default .WithStorageConnectionString(CloudConfigurationManager.GetSetting("MBrace.StorageConnectionString")) .WithServiceBusConnectionString(CloudConfigurationManager.GetSetting("MBrace.ServiceBusConnectionString")); _svc = RoleEnvironment.IsEmulated ? new Service(_config) : // Avoid long service names when using emulator new Service(_config, serviceId: RoleEnvironment.CurrentRoleInstance.Id); _svc.AttachLogger(new CustomLogger(s => Trace.WriteLine(String.Format("{0} : {1}", DateTime.UtcNow, s)))); RoleEnvironment.Changed += RoleEnvironment_Changed; return(result); }
private static string GetLocalPath() { if (!RoleEnvironment.IsAvailable) { var filePath = Path.GetTempPath(); return(filePath); } // Get the local storage information const string localResourceName = "LogStorage"; // Override the file path name with the local resource string localPath = String.Empty; try { var localResource = RoleEnvironment.GetLocalResource(localResourceName); localPath = localResource.RootPath; return(localPath); } catch (Exception) { throw new ArgumentException(localResourceName + " is not a valid Azure package local resource name"); } }
/// <summary> /// Init with a storage account /// </summary> /// <param name="account">Cloud Storage Account</param> public static ElasticsearchServiceSettings FromStorage(CloudStorageAccount account) { var settings = new ElasticsearchServiceSettings() { _StorageAccount = account, _NodeName = RoleEnvironment.CurrentRoleInstance.Id, _UseElasticLocalDataFolder = CloudConfigurationManager.GetSetting("UseElasticLocalDataFolder"), _JavaInstaller = CloudConfigurationManager.GetSetting("JavaInstallerName"), _JavaDownloadURL = CloudConfigurationManager.GetSetting("JavaDownloadURL"), _JavaDownloadType = CloudConfigurationManager.GetSetting("JavaDownloadType"), _ElasticsearchInstaller = CloudConfigurationManager.GetSetting("ElasticsearchZip"), _ElasticsearchDownloadURL = CloudConfigurationManager.GetSetting("ElasticsearchDownloadURL"), _ElasticsearchDownloadType = CloudConfigurationManager.GetSetting("ElasticsearchDownloadType"), _ElasticsearchPluginContainer = CloudConfigurationManager.GetSetting("ElasticsearchPluginContainer"), _DataShareName = CloudConfigurationManager.GetSetting("ShareName"), _DataShareDrive = CloudConfigurationManager.GetSetting("ShareDrive"), _EndpointName = CloudConfigurationManager.GetSetting("EndpointName"), _DownloadDirectory = RoleEnvironment.GetLocalResource("ArchiveRoot").RootPath, _LogDirectory = RoleEnvironment.GetLocalResource("LogRoot").RootPath, _DataDirectory = RoleEnvironment.GetLocalResource("ElasticDataRoot").RootPath, _ElasticsearchDirectory = RoleEnvironment.GetLocalResource("ElasticRoot").RootPath, _RootDirectory = Environment.GetEnvironmentVariable("ROLEROOT"), _TempDirectory = RoleEnvironment.GetLocalResource("CustomTempRoot").RootPath, _DataBootstrapDirectory = RoleEnvironment.GetLocalResource("DataBootstrapDirectory").RootPath, }; bool.TryParse(CloudConfigurationManager.GetSetting("EnableDataBootstrap"), out settings._EnableDataBootstrap); if (string.IsNullOrWhiteSpace(settings._DataBootstrapDirectory) && settings._EnableDataBootstrap) { settings._EnableDataBootstrap = false; } if (!settings._RootDirectory.EndsWith(@"\")) { settings._RootDirectory += @"\"; } //Set root to approot=App directory settings._RootDirectory = Path.Combine(settings._RootDirectory, "approot"); //Emulator does not copy webrole files to approot if (RoleEnvironment.IsEmulated && IsWebRole) { settings._RootDirectory = Path.Combine(settings._RootDirectory, "bin"); } //Calculate heap size MEMORYSTATUSEX memoryStatus = new MEMORYSTATUSEX(); GlobalMemoryStatusEx(memoryStatus); var totalPhycialBytesInMB = memoryStatus.ullTotalPhys / 1024L / 1024L; //TODO: calculate the lost result which could cause this to throw; settings._ComputedHeapSize = Convert.ToInt32(totalPhycialBytesInMB / 2); return(settings); }
private void CreateInputFileFromStreams(Dictionary <string, System.IO.Stream> fileStreams) { if (RoleEnvironment.IsAvailable) { var localStorage = RoleEnvironment.GetLocalResource("OutputStorage"); var rootPath = localStorage.RootPath; this.inputDirectoryPath = rootPath + "input"; } else { this.inputDirectoryPath = "input"; } if (Directory.Exists(this.inputDirectoryPath)) { Directory.Delete(this.inputDirectoryPath, true); } Directory.CreateDirectory(this.inputDirectoryPath); foreach (var inputStream in fileStreams) { if (inputStream.Key != "LogFile") { string path = this.inputDirectoryPath + "\\" + inputStream.Key; using (var fileStream = new FileStream(path, FileMode.Create, FileAccess.Write)) { inputStream.Value.CopyTo(fileStream); } } } }
public static string GetStorageDirectory(string name) { if (RoleEnvironment.IsAvailable) { var res = RoleEnvironment.GetLocalResource(name); return(res.RootPath); } else { var path = System.IO.Path.GetTempPath(); try { var fullPath = System.IO.Path.Combine(path, name); if (!System.IO.Directory.Exists(fullPath)) { var dirInfo = System.IO.Directory.CreateDirectory(fullPath); return(dirInfo.FullName); } } catch (Exception) { } return(path); } }
private AzureBlockStore(AzureBlockStoreConfiguration configuration) { #if BLOCKSTORECACHE _cache = new BlockStoreCache((long)configuration.MemoryCacheInMB * 1024 * 1024, configuration.LocalStorageKey); #else ICache memoryCache = new MemoryCache((long)configuration.MemoryCacheInMB * 1024 * 1024, new LruCacheEvictionPolicy()); if (!String.IsNullOrEmpty(configuration.LocalStorageKey)) { var localDiskResource = RoleEnvironment.GetLocalResource(configuration.LocalStorageKey); ICache diskCache = new DirectoryCache(localDiskResource.RootPath, ((long)localDiskResource.MaximumSizeInMegabytes - 1) * 1024 * 1024, new LruCacheEvictionPolicy()); _cache = new TwoLevelCache(memoryCache, diskCache); } else { _cache = memoryCache; } #endif _highestPageOffsetByPath = new Dictionary <string, long>(); _storageAccount = CloudStorageAccount.Parse(configuration.ConnectionString); _commitList = new ConcurrentQueue <BlockInfo>(); _commitThread = new Thread(RunCommitThread); _commitThread.Start(); _disconnected = configuration.Disconnected; }
public static void Initialize() { //First get a reference to the local file structure. localStorage = RoleEnvironment.GetLocalResource("scratchpad"); //Check to see if we have already grabbed the component files. if (!CloudBackedStore.DirectoryExists(ComponetDir)) { var url = string.Format("http://{0}.blob.core.windows.net/components/", RoleEnvironment.GetConfigurationSettingValue("StorageName")); foreach (var app in OdpiAppRepo.Apps) { if (!string.IsNullOrEmpty(app.PackageName)) { CloudBackedStore.Grab(ComponetDir, "\\" + app.PackageName, "components", url + app.PackageName); } if (!string.IsNullOrEmpty(app.ConfName)) { CloudBackedStore.Grab(ComponetDir, "\\" + app.ConfName, "components", url + app.ConfName); } var req = app.RequiredFiles; if (req != null) { foreach (var file in req) { CloudBackedStore.Grab(ComponetDir, "\\" + file, "components", url + file); } } } } }
/// <summary> /// Gets the valid file path. /// </summary> /// <returns>returns System.String.</returns> public static string GetLocalStorePath() { string filePath = string.Empty; filePath = RoleEnvironment.GetLocalResource("LocalCacheStore").RootPath; return(filePath); }
public string UploadFolder(string containerName, string localStoragePath, string prefixAzureDirectoryName) { try { LocalResource Storage = RoleEnvironment.GetLocalResource("ZYLocalStorage"); string[] filePaths = Directory.GetFiles(localStoragePath); foreach (var item in filePaths) { if (!Path.GetExtension(item).Equals(".zip")) { UploadFile(item, Path.GetFileName(item), prefixAzureDirectoryName); } } var folder = new DirectoryInfo(localStoragePath); var subFolders = folder.GetDirectories(); foreach (var directoryInfo in subFolders) { UploadFolder("zycontainer", Storage.RootPath + directoryInfo.Name, prefixAzureDirectoryName + "/" + directoryInfo.Name); } return("Upload Directory seccussfully."); } catch (Exception e) { return(e.Message); } }
void Application_Start(object sender, EventArgs e) { // Code that runs on application startup BundleConfig.RegisterBundles(BundleTable.Bundles); AuthConfig.RegisterOpenAuth(); if (imageStorePath == null) { ImageStorePath = WebConfigurationManager.AppSettings["ImageStorePath"]; } // initialize storage account configuration setting publisher CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) => { string connectionString = RoleEnvironment.GetConfigurationSettingValue(configName); configSetter(connectionString); }); try { // initialize the local cache for the Azure drive LocalResource cache = RoleEnvironment.GetLocalResource("LocalDriveCache"); CloudDrive.InitializeCache(cache.RootPath + "cache", cache.MaximumSizeInMegabytes); // retrieve storage account CloudStorageAccount account = CloudStorageAccount.FromConfigurationSetting("DataConnectionString"); // retrieve URI for the page blob that contains the cloud drive from configuration settings string imageStoreBlobUri = RoleEnvironment.GetConfigurationSettingValue("ImageStoreBlobUri"); // unmount any previously mounted drive. foreach (var drive in CloudDrive.GetMountedDrives()) { var mountedDrive = new CloudDrive(drive.Value, account.Credentials); mountedDrive.Unmount(); } // create the Windows Azure drive and its associated page blob CloudDrive imageStoreDrive = account.CreateCloudDrive(imageStoreBlobUri); if (CloudDrive.GetMountedDrives().Count == 0) { try { imageStoreDrive.Create(16); } catch (CloudDriveException) { // drive already exists } } // mount the drive and initialize the application with the path to the image store on the Azure drive Global.ImageStorePath = imageStoreDrive.Mount(cache.MaximumSizeInMegabytes / 2, DriveMountOptions.None); } catch (CloudDriveException driveException) { Trace.WriteLine("Error: " + driveException.Message); } }
public override bool OnStart() { try { // Set up temp directory try { var tempResource = RoleEnvironment.GetLocalResource("Temp"); if (tempResource != null) { Environment.SetEnvironmentVariable("TMP", tempResource.RootPath); Environment.SetEnvironmentVariable("TEMP", tempResource.RootPath); } } catch { // Just ignore this. Use the default temp directory } // Initialize the host _host.Initialize(); return(_host.StartAndWait()); } catch (Exception ex) { ServicePlatformEventSource.Log.FatalException(ex); throw; } }
public IAzureLocalResource this[string index] { get { return(new HostedAzureLocalResource(RoleEnvironment.GetLocalResource(index))); } }
public static String GetLocalStoragePath() { //returns the full path of the local storage LocalResource l = RoleEnvironment.GetLocalResource("LocalSoundStore"); return(string.Format(l.RootPath)); }
public Worker(string name) { Name = name; LocalResource azureLocalResource = RoleEnvironment.GetLocalResource("LocalStorage"); WorkDirectoryName = Path.Combine(azureLocalResource.RootPath, "WD" + name); /*** Init ***/ // On instancie un objet de chaque classe héritant de BusinessProcess _employees = new List <IBusinessProcess>(); Object[] args = new object[] { WorkDirectoryName }; foreach (Type instance in typeof(BusinessProcess).Assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(BusinessProcess)))) { _employees.Add(Activator.CreateInstance(instance, args) as IBusinessProcess); } //// TODO : find a good time int maximumTimeToSleepInSeconde; if (!int.TryParse(RoleEnvironment.GetConfigurationSettingValue("MaximumSecondesTimeSleep"), out maximumTimeToSleepInSeconde)) { maximumTimeToSleepInSeconde = 2 * 60 * 60; // 2 heures } CustomSleeper = new Sleeper(2, maximumTimeToSleepInSeconde); CountLoop = 0; }
public override bool OnStart() { try { // Set the maximum number of concurrent connections ServicePointManager.DefaultConnectionLimit = 512; /// Initialize global state for the current process Config.InitWorkerGlobalState(); // Increase disk quota for mbrace filesystem cache. string customTempLocalResourcePath = RoleEnvironment.GetLocalResource("LocalMBraceCache").RootPath; Environment.SetEnvironmentVariable("TMP", customTempLocalResourcePath); Environment.SetEnvironmentVariable("TEMP", customTempLocalResourcePath); bool result = base.OnStart(); _config = new Configuration(CloudConfigurationManager.GetSetting("MBrace.StorageConnectionString"), CloudConfigurationManager.GetSetting("MBrace.ServiceBusConnectionString")); _svc = RoleEnvironment.IsEmulated ? new Service(_config) : // Avoid long service names when using emulator new Service(_config, serviceId: RoleEnvironment.CurrentRoleInstance.Id.Split('.').Last()); _svc.MaxConcurrentWorkItems = Environment.ProcessorCount * 8; RoleEnvironment.Changed += RoleEnvironment_Changed; return(result); } catch (Exception ex) { Trace.TraceError("MBrace Azure Role unhandled exception: {0}", ex); throw; } }
private void CreateTempFolders() { // this guard helps not to throw error when running outside emulator in local if (RoleEnvironment.IsAvailable) { var localStorage = RoleEnvironment.GetLocalResource("OutputStorage"); var rootPath = localStorage.RootPath; this.outputDirectoryPath = rootPath + "output"; this.zipFilePath = rootPath + "output.zip"; } else { this.outputDirectoryPath = "output"; this.zipFilePath = "output.zip"; } if (Directory.Exists(this.outputDirectoryPath)) { Directory.Delete(this.outputDirectoryPath, true); } Directory.CreateDirectory(this.outputDirectoryPath); if (File.Exists(this.zipFilePath)) { File.Delete(this.zipFilePath); } }
protected void Button3_Click(object sender, EventArgs e) { var logPath = Path.Combine(RoleEnvironment.GetLocalResource("DiagnosticStore").RootPath, @"FailedReqLogFiles\W3SVC1"); if (!Directory.Exists(logPath)) { goto Default; } string lastLogFile = Directory.GetFiles(logPath, @"*.xml").OrderBy(f => File.GetLastWriteTime(f)).LastOrDefault(); if (lastLogFile == null) { goto Default; } Response.Clear(); Response.WriteFile(lastLogFile); Response.End(); return; Default: return; }
public WorkerRoleConfig() { _updateFrequencyInSeconds = Convert.ToInt32(RoleEnvironment.GetConfigurationSettingValue("UpdateFrequencyInSeconds")); _applicationRestartCount = Convert.ToInt32(RoleEnvironment.GetConfigurationSettingValue("ApplicationRestartCount")); _storageDataConnectionString = RoleEnvironment.GetConfigurationSettingValue("StorageDataConnectionString"); _currentRoleInstanceLocalStoreDirectory = RoleEnvironment.GetLocalResource("LocalStoreDirectory").RootPath; }
public override bool OnStart() { try { // Increase disk quota for mbrace filesystem cache. string customTempLocalResourcePath = RoleEnvironment.GetLocalResource("LocalMBraceCache").RootPath; string storageConnectionString = CloudConfigurationManager.GetSetting("MBrace.StorageConnectionString"); string serviceBusConnectionString = CloudConfigurationManager.GetSetting("MBrace.ServiceBusConnectionString"); bool result = base.OnStart(); _config = new Configuration(storageConnectionString, serviceBusConnectionString); _svc = RoleEnvironment.IsEmulated ? new WorkerService(_config, String.Format("computeEmulator-{0}", Guid.NewGuid().ToString("N").Substring(0, 30))) : new WorkerService(_config, workerId: Environment.MachineName); _svc.WorkingDirectory = customTempLocalResourcePath; _svc.LogFile = "logs.txt"; _svc.MaxConcurrentWorkItems = Environment.ProcessorCount * 8; Environment.SetEnvironmentVariable("TMP", customTempLocalResourcePath, EnvironmentVariableTarget.Process); Environment.SetEnvironmentVariable("TEMP", customTempLocalResourcePath, EnvironmentVariableTarget.Process); RoleEnvironment.Changed += RoleEnvironment_Changed; return(result); } catch (Exception ex) { Trace.TraceError("MBrace.Azure.WorkerRole OnStart unhandled exception: {0}", ex); throw; } }
private void CreateDirectories(SlicingOptions slicingOptions) { outputPath = Path.Combine(RoleEnvironment.GetLocalResource("output").RootPath, Guid.NewGuid().ToString()); inputPath = Path.Combine(RoleEnvironment.GetLocalResource("input").RootPath, slicingOptions.CloudResultContainer); Directory.CreateDirectory(outputPath); Directory.CreateDirectory(inputPath); }
private string GetLogFile() { DiagnosticsHelper.TraceInformation("Getting log file base path"); var localStorage = RoleEnvironment.GetLocalResource(Settings.LogDirSetting); var logfile = Path.Combine(localStorage.RootPath + @"\", Settings.MongodLogFileName); return("\"" + logfile + "\""); }
public static DirectoryConfiguration GetLogDirectory() { DirectoryConfiguration directory = new DirectoryConfiguration(); directory.Container = "wad-tracefiles"; directory.DirectoryQuotaInMB = 10; directory.Path = RoleEnvironment.GetLocalResource("WCFServiceSurferlite.svclog").RootPath; return directory; }
public override void Run() { try { CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) => { configSetter(RoleEnvironment.GetConfigurationSettingValue(configName)); }); this.storageAccount = CloudStorageAccount.FromConfigurationSetting("ConnectionString"); this.BlobClient = this.storageAccount.CreateCloudBlobClient(); this.LocalStorageRoot = RoleEnvironment.GetLocalResource("LocalStorage").RootPath; var StationsQueue = storageAccount.CreateCloudQueueClient().GetQueueReference("stations"); int NumberOfMessages = Convert.ToInt32(RoleEnvironment.GetConfigurationSettingValue("NumberOfMessages")); DownloadSimulationFiles(); while (true) { Thread.Sleep(10000); Trace.WriteLine(System.DateTime.Now.ToLongTimeString()); var message = StationsQueue.GetMessages(NumberOfMessages, TimeSpan.FromMinutes(20)); if (message.Count() > 0) { try { List <ManualResetEvent> doneEvents = new List <ManualResetEvent>(); DateTime start = System.DateTime.Now; //Trace.WriteLine(message.AsString); // Trace.WriteLine(String.Format("Start : {0}", System.DateTime.Now.ToLongTimeString())); foreach (var item in message) { ManualResetEvent done = new ManualResetEvent(false); doneEvents.Add(done); Simulation sim = new Simulation(item, done, this.LocalStorageRoot, this.storageAccount); ThreadPool.QueueUserWorkItem(sim.ThreadPoolCallback, 0); } WaitHandle.WaitAll(doneEvents.ToArray()); DateTime end = System.DateTime.Now; Trace.WriteLine((String.Format("End : {0}", System.DateTime.Now.ToLongTimeString()))); } catch (Exception) { //if (message.DequeueCount > 1) // StationsQueue.DeleteMessage(message); } } } } catch (Exception x1) { Trace.WriteLine(x1.Message); } }
static List <Tuple <int, string, string> > GetGroupIdWithKeysAndShapeIds() { GroupService grpService = new GroupService(); BlobAccess blobAccess = new BlobAccess(); var container = blobAccess.LoadShapeFiles(); LocalResource myStorage = RoleEnvironment.GetLocalResource("LocalStorageWorkerRole"); List <Tuple <int, string, string> > GrpIdGroupKeyAndShapePaths = new List <Tuple <int, string, string> >(); GroupService.ParentGroup.ForEach(ParentGroup => { if (!String.IsNullOrWhiteSpace(ParentGroup.ShapeFileID) && ParentGroup.NotifySubgroups) // { string shapeIndex = LocalPath(myStorage, ParentGroup.ShapeFileID + ".shx"); string describeFile = LocalPath(myStorage, ParentGroup.ShapeFileID + ".dbf"); string shapeFile = LocalPath(myStorage, ParentGroup.ShapeFileID + ".shp"); string projectionFile = LocalPath(myStorage, ParentGroup.ShapeFileID + ".prj"); if (File.Exists(shapeIndex)) { File.Delete(shapeIndex); } if (File.Exists(describeFile)) { File.Delete(describeFile); } if (File.Exists(shapeFile)) { File.Delete(shapeFile); } if (File.Exists(projectionFile)) { File.Delete(projectionFile); } var ShxBlockBlobReference = container.GetBlockBlobReference(GetPath(FileType.IndexFile, ParentGroup.ShapeFileID)); ShxBlockBlobReference.DownloadToFile(shapeIndex, FileMode.Create); var DescribeBlockBlobReference = container.GetBlockBlobReference(GetPath(FileType.DescribeFile, ParentGroup.ShapeFileID)); DescribeBlockBlobReference.DownloadToFile(describeFile, FileMode.Create); var ShapeBlockBlobReference = container.GetBlockBlobReference(GetPath(FileType.ShapeFile, ParentGroup.ShapeFileID)); ShapeBlockBlobReference.DownloadToFile(shapeFile, FileMode.Create); var BlockBlobReference = container.GetBlockBlobReference(GetPath(FileType.ProjectionFile, ParentGroup.ShapeFileID)); BlockBlobReference.DownloadToFile(projectionFile, FileMode.Create); GrpIdGroupKeyAndShapePaths.Add(new Tuple <int, string, string>(ParentGroup.GroupID, ParentGroup.SubGroupIdentificationKey, Path.Combine(myStorage.RootPath, ParentGroup.ShapeFileID))); } }); return(GrpIdGroupKeyAndShapePaths); }