private bool IsValidAzureStorageAcctPresent() { bool valid = true; try { Tuple <bool, Exception> tuple = AzureBlobConfigUpdate.IsValidAccount(this.formAzureAccount.AzureAccountName, this.formAzureAccount.AzureAccountKey); if (!tuple.Item1) { throw tuple.Item2; } } catch (Exception ex) { logger.ErrorException("Failed to validate the azure storage account", ex); outputBox.Text += "Failed to validate the azure storage account" + ex + "\r\n"; valid = false; } return(valid); }
private void UpdateConfigsForSelectedHubs() { for (int i = 0; i < HubConfigUpdatePanelList.Count; ++i) { HubConfigUpdatePanelRowItem panelRowItem = this.HubConfigUpdatePanelList[i]; if (panelRowItem.IsChecked()) { string zipPath_desired = this.configDataCache.GetDesiredConfigLocalFolderPath( (string)this.currentOrgItem, (string)this.currentStudyItem, panelRowItem.hubId); string zipPath_actual = this.configDataCache.GetActualConfigFolderPath((string)this.currentOrgItem, (string)this.currentStudyItem, panelRowItem.hubId); string currentVersionFilename = zipPath_actual + "\\" + PackagerHelper.ConfigPackagerHelper.CurrentVersionFileName; string parentVersionFilename = zipPath_desired + "\\" + PackagerHelper.ConfigPackagerHelper.ParentVersionFileName; if (File.Exists(currentVersionFilename)) { string s = string.Format("Copying {0} to {1} ", currentVersionFilename, parentVersionFilename); logger.Info(s, 1); outputBox.Text += s + "\n"; PackagerHelper.PackagerHelper.CopyFile(currentVersionFilename, parentVersionFilename); } else { string s1 = string.Format("Writing version of config in {0} to {1} ", zipPath_actual, parentVersionFilename); logger.Info(s1, 1); outputBox.Text += s1 + "\n"; PackagerHelper.ConfigPackagerHelper.UpdateVersionFile(PackagerHelper.ConfigPackagerHelper.GetConfigVersion(zipPath_actual), parentVersionFilename); } string currentVersionFilenameDesired = zipPath_desired + "\\" + PackagerHelper.ConfigPackagerHelper.CurrentVersionFileName; string s3 = string.Format("Writing version of config in {0} to {1} ", zipPath_desired, currentVersionFilenameDesired); logger.Info(s3, 1); outputBox.Text += s3 + "\n"; Dictionary <string, string> currentVersion_desired = PackagerHelper.ConfigPackagerHelper.GetConfigVersion(zipPath_desired); PackagerHelper.ConfigPackagerHelper.UpdateVersionFile(currentVersion_desired, currentVersionFilenameDesired); string zipFilePathDesiredLocal = this.configDataCache.GetDesiredConfigLocalZipFilePath((string)this.currentOrgItem, (string)this.currentStudyItem, panelRowItem.hubId); File.Delete(zipFilePathDesiredLocal); PackagerHelper.PackagerHelper.PackZip(zipPath_desired, zipFilePathDesiredLocal); string s4 = string.Format("Uploading desired config for homeID {0} ", panelRowItem.hubId); logger.Info(s4, 1); outputBox.Text += s4 + "\n"; if (!AzureBlobConfigUpdate.UploadConfig( zipFilePathDesiredLocal, this.formAzureAccount.AzureAccountName, this.formAzureAccount.AzureAccountKey, (string)this.currentOrgItem, (string)this.currentStudyItem, panelRowItem.hubId, PackagerHelper.ConfigPackagerHelper.desiredConfigFileName, logger)) { string s5 = string.Format("WARNING! unable to upload config for homeID: " + panelRowItem.hubId); logger.Warn(s5); outputBox.Text += s5 + "\n"; } } } }
public void BuildCache() { if (this.cacheBuilt) { return; } // get all the orgs Tuple <bool, List <string> > orgListTuple = HomeOS.Hub.Tools.UpdateHelper.AzureBlobConfigUpdate.listOrgs(this.AzureAccount, this.AzureKey); if (!orgListTuple.Item1) { logger.Error(orgListTuple.Item2); return; } foreach (string orgId in orgListTuple.Item2) { this.tripleIdLookUp[orgId] = new Dictionary <string, Dictionary <string, string> >(); bool hubListFailed = false; Tuple <bool, List <string> > studyListTuple = HomeOS.Hub.Tools.UpdateHelper.AzureBlobConfigUpdate.listStudies(this.AzureAccount, this.AzureKey, orgId); if (!orgListTuple.Item1) { logger.Error(orgListTuple.Item2); break; } foreach (string studyId in studyListTuple.Item2) { this.tripleIdLookUp[orgId][studyId] = new Dictionary <string, string>(); Tuple <bool, List <string> > hubListTuple = UpdateHelper.AzureBlobConfigUpdate.listHubs(this.AzureAccount, this.AzureKey, orgId, studyId); if (!studyListTuple.Item1) { logger.Error(studyListTuple.Item2); hubListFailed = true; break; } foreach (string hubId in hubListTuple.Item2) { string tmpFolder = ".\\" + CacheFolder + "\\" + orgId + "\\" + studyId + "\\" + hubId; PackagerHelper.PackagerHelper.CreateFolder(tmpFolder + "\\" + ActualFolder); // deletes existing if present PackagerHelper.PackagerHelper.CreateFolder(tmpFolder + "\\" + DesiredFolder + "\\" + DownloadedFolder); // deletes existing if present PackagerHelper.PackagerHelper.CreateFolder(tmpFolder + "\\" + DesiredFolder + "\\" + LocalFolder, false); // don't delete existing if present string actualZipFilePath = tmpFolder + "\\" + ActualConfigZipName; string desiredDownloadZipFilePath = tmpFolder + "\\" + DesiredConfigDownloadedZipName; string desiredLocalZipFilePath = tmpFolder + "\\" + DesiredConfigLocalZipName; this.tripleIdLookUp[orgId][studyId][hubId] = ""; if (AzureBlobConfigUpdate.DownloadConfig(actualZipFilePath, this.AzureAccount, this.AzureKey, orgId, studyId, hubId, PackagerHelper.ConfigPackagerHelper.actualConfigFileName, this.logger)) { ExtractConfigPackage(orgId, studyId, hubId, tmpFolder + "\\" + ActualFolder, actualZipFilePath, false /*deletePackage*/); this.tripleIdLookUp[orgId][studyId][hubId] = tmpFolder; } if (AzureBlobConfigUpdate.DownloadConfig(desiredDownloadZipFilePath, this.AzureAccount, this.AzureKey, orgId, studyId, hubId, PackagerHelper.ConfigPackagerHelper.desiredConfigFileName, this.logger)) { ExtractConfigPackage(orgId, studyId, hubId, tmpFolder + "\\" + DesiredFolder + "\\" + DownloadedFolder, desiredDownloadZipFilePath, false /*deletePackage*/); this.tripleIdLookUp[orgId][studyId][hubId] = tmpFolder; } } } if (hubListFailed) { break; } } }