//表查找函数 private string Fun_Table(List <StorageUnit> list, StoragePool pool) { switch (list.Count) { case 1: string szArg0 = Ly.ZBox.StorageUnit.GetStringValue(list[0], pool); if (gTab.SystemTables.GetDataByText(szArg0)) { //如只有一个表,则附带默认表功能 if (gbTable) { gnTable = 0; } else { gnTable = (int)gTab.SystemTables.Structure.ID; gbTable = true; } return("[" + gTab.SystemTables.Structure.Name + "]"); } else { throw new Exception("未找到表\"" + szArg0 + "\"。"); } default: throw new Exception("参数数量不正确,未找到" + list.Count + "参数的定义。"); } }
protected override void OnStartup(object sender, StartupEventArgs e) { if (!mutex.WaitOne(TimeSpan.FromSeconds(1), false)) { System.Windows.Application.Current.Shutdown(); } ResultObject <object> ro = new ResultObject <object>(true); try { Storage db = _container.GetInstance <PerstStorageFactory>().OpenConnection(PerstStorageFactory.MAIN_DATABASE_NAME); StoragePool sp = _container.GetInstance <StoragePool>(); sp.Add(PerstStorageFactory.MAIN_DATABASE_NAME, db); var vm = _container.GetInstance <MainWindowViewModel>(); _container.BuildUp(vm); _container.GetInstance <IWindowManager>().ShowWindow(vm); } catch (StorageError ex) { ro = new ResultObject <object>(false); ro.AddMessage("Nelze načíst Vaše data."); } catch (Exception ex) { ro = new ResultObject <object>(false); ro.AddMessage("Při spouštění aplikace došlo k neočekávané chybě"); } if (!ro.Success) { StartupErrorWindowViewModel errw = _container.GetInstance <StartupErrorWindowViewModel>(); errw.Text = ro.GetLastMessage().Text; _container.GetInstance <IWindowManager>().ShowDialog(errw); } }
//用户信息查找函数 private string Fun_User(List <StorageUnit> list, StoragePool pool) { switch (list.Count) { case 1: string szArg0 = Ly.ZBox.StorageUnit.GetStringValue(list[0], pool); switch (szArg0.ToLower()) { case "id": return(gParent.UserInfo.ID.ToString()); case "department": return(gParent.UserInfo.Department.ToString()); case "auth": return(gParent.AuthorizeID.ToString()); default: throw new Exception("未找到登录用户的\"" + szArg0 + "\"属性。"); } default: throw new Exception("参数数量不正确,未找到" + list.Count + "参数的定义。"); } }
//字段查找函数 private string Fun_TableColumn(List <StorageUnit> list, StoragePool pool) { switch (list.Count) { case 2: string szArg0 = Ly.ZBox.StorageUnit.GetStringValue(list[0], pool);; string szArg1 = Ly.ZBox.StorageUnit.GetStringValue(list[1], pool);; if (gTab.SystemTables.GetDataByText(szArg0)) { if (gTab.SystemColumns.GetDataByParentIDAndText(gTab.SystemTables.Structure.ID, szArg1)) { return("[" + gTab.SystemTables.Structure.Name + "].[" + gTab.SystemColumns.Structure.Name + "]"); } else { throw new Exception("未在表中找到\"" + szArg0 + "\"字段。"); } } else { throw new Exception("未找到表\"" + szArg0 + "\"。"); } default: throw new Exception("参数数量不正确,未找到" + list.Count + "参数的定义。"); } }
//当前表单信息查找函数 private string Fun_Form(List <StorageUnit> list, StoragePool pool) { switch (list.Count) { case 1: string szArg0 = Ly.ZBox.StorageUnit.GetStringValue(list[0], pool); return(gJson[szArg0].Value); case 2: int nStep = 0; try { nStep++; szArg0 = Ly.ZBox.StorageUnit.GetStringValue(list[0], pool); nStep++; string szArg1 = Ly.ZBox.StorageUnit.GetStringValue(list[1], pool); nStep++; gJson[szArg0].Value = szArg1; nStep++; return(gJson[szArg0].Value); } catch (Exception ex) { throw new Exception(ex.Message + "\r\n[0]:" + list[0].Type + ",[1]:" + list[1].Type + ",Pool:" + pool + ",Step:" + nStep); } default: throw new Exception("参数数量不正确,未找到" + list.Count + "参数的定义。"); } }
public virtual StorApiStatus GetDrivePool(Drive drive, ref SpacesPool pool) { StorApiStatus storApiStatus = StorApiStatusEnum.STOR_NO_ERROR; SpacesApiError spacesApiError = SpacesApiError.Success; if (drive == null) { return(StorApiStatusEnum.STOR_INVALID_PARAM); } StoragePool storagePool = null; spacesApiError = SpacesApi.SpacesApi.GetPhysicalDiskPool(drive.Id, ref storagePool); if (spacesApiError == SpacesApiError.Success && storagePool != null) { foreach (SpacesPool spacesPool in this.pools) { if (string.Equals(spacesPool.Id, storagePool.ObjectId, StringComparison.OrdinalIgnoreCase)) { pool = spacesPool; break; } } } return(SpacesUtil.ToStorApiStatus(spacesApiError)); }
public int InstallTestSuite(string name, string packageName, Stream package, string description) { var extractNode = ExtractPackage(packageName, package, StoragePool); var version = GetTestSuiteVersion(extractNode); if (!CheckTestSuiteVersion(version)) { extractNode.DeleteNode(); throw new NotSupportedException($"PTMService only supports version {TestSuiteConsts.SupportedMinVersion} or above version, you could try use PTMGUI to run previous versions"); } using var instance = ScopedServiceFactory.GetInstance(); var pool = instance.ScopedServiceInstance; var repo = pool.Get <TestSuiteInstallation>(); var testSuiteInstallation = new TestSuiteInstallation { Name = name, InstallMethod = TestSuiteInstallMethod.UploadPackage, Description = description, Version = version }; try { repo.Insert(testSuiteInstallation); pool.Save().Wait(); int id = testSuiteInstallation.Id; var testSuiteNode = StoragePool.GetKnownNode(KnownStorageNodeNames.TestSuite).CreateNode(id.ToString()); testSuiteNode.CopyFromNode(extractNode, true); testSuiteInstallation.Path = testSuiteNode.AbsolutePath; var testSuite = TestSuite.Create(Options.TestEnginePath, testSuiteInstallation, testSuiteNode); repo.Update(testSuiteInstallation); pool.Save().Wait(); TestSuitePool.AddOrUpdate(id, _ => testSuite, (_, _) => testSuite); return(id); } catch { repo.Remove(testSuiteInstallation); pool.Save().Wait(); throw; } }
public SpacesPool MakePool(StoragePool d) { return(new SpacesPool(d.ObjectId, this) { Name = d.FriendlyName, IsPrimordial = d.IsPrimordial, Health = d.HealthStatus, OperationalStatuses = d.OperationalStatus, Size = d.Size, AllocatedSize = d.AllocatedSize }); }
private void AssertStoragePoolsAreSame(StoragePool expected, StoragePool found) { if (expected == null) { Assert.Null(found); } else { Assert.True(FabricCommon.ResourceAreSame(expected, found)); Assert.Equal(expected.SizeGB, found.SizeGB); } }
//当前表单信息查找函数 private string Fun_Request(List <StorageUnit> list, StoragePool pool) { switch (list.Count) { case 1: string szArg0 = Ly.ZBox.StorageUnit.GetStringValue(list[0], pool); return(gParent[szArg0]); default: throw new Exception("参数数量不正确,未找到" + list.Count + "参数的定义。"); } }
//当前表单信息查找函数 private string Fun_NumRequest(List <StorageUnit> list, StoragePool pool) { switch (list.Count) { case 1: string szArg0 = Ly.ZBox.StorageUnit.GetStringValue(list[0], pool); double res = 0; double.TryParse(gParent[szArg0], out res); return(res.ToString()); default: throw new Exception("参数数量不正确,未找到" + list.Count + "参数的定义。"); } }
protected override void OnStartup(object sender, StartupEventArgs e) { StoragePool sp = _container.GetInstance <StoragePool>(); Storage db = _container.GetInstance <prjt.Services.Persistence.StorageFactory>().OpenConnection(prjt.Services.Persistence.StorageFactory.MAIN_DATABASE_NAME); sp.Add(prjt.Services.Persistence.StorageFactory.MAIN_DATABASE_NAME, db); //GeneratePersons(db); MainViewModel mvm = _container.GetInstance <MainViewModel>(); _container.BuildUp(mvm); _container.GetInstance <IWindowManager>().ShowWindow(mvm); }
//执行SQL语句并返回首行的第一个值 private string Fun_Char(List <StorageUnit> list, StoragePool pool) { switch (list.Count) { case 1: int szArg0 = Ly.ZBox.StorageUnit.GetIntegerValue(list[0], pool); string res = ""; res += (char)szArg0; return(res); default: throw new Exception("参数数量不正确,未找到" + list.Count + "参数的定义。"); } }
private string CreateProfile(ProfileExportRequest request) { List <TestCase> testCases = new List <TestCase>(); var configurationNode = StoragePool.GetKnownNode(KnownStorageNodeNames.Configuration); var testSuite = GetTestSuite(request.TestSuiteId); using (ProfileUtil profile = ProfileUtil.CreateProfile( request.FileName, testSuite.Name, testSuite.Version)) { string configBasePath = GetConfigurationsPath(request.ConfigurationId, configurationNode.AbsolutePath); string profileSourceFile = Path.Combine(configBasePath, ConfigurationConsts.Profile); ProfileUtil.FileToStream(profileSourceFile, profile.ProfileStream); string ptfConfigSourceDir = GetPtfConfigBasePath(request.ConfigurationId, configurationNode.AbsolutePath); string[] ptfConfigFiles = Directory.GetFiles(ptfConfigSourceDir, "*.ptfconfig", SearchOption.TopDirectoryOnly); foreach (string settingsConfigFile in ptfConfigFiles) { profile.AddPtfCfg(settingsConfigFile); } if (request.SelectedTestCases != null) { foreach (var testCaseName in request.SelectedTestCases) { var testCase = new TestCase() { FullName = testCaseName, IsChecked = true }; testCases.Add(testCase); } } ExportPlaylist(profile.PlaylistStream, true, request.TestResultId, testCases); } return(request.FileName); }
//执行SQL语句并返回首行的第一个值 private string Fun_AutoNum(List <StorageUnit> list, StoragePool pool) { switch (list.Count) { case 1: string szArg0 = Ly.ZBox.StorageUnit.GetStringValue(list[0], pool); string res = ""; using (Ly.DB.Dream.SystemAutomatic.ExecutionExp st = new Ly.DB.Dream.SystemAutomatic.ExecutionExp(gszConnString)) { res = st.GetNewAutomatic(szArg0).ToString(); } return(res); default: throw new Exception("参数数量不正确,未找到" + list.Count + "参数的定义。"); } }
//执行SQL语句并返回首行的第一个值 private string Fun_SqlExecute(List <StorageUnit> list, StoragePool pool) { switch (list.Count) { case 1: string szArg0 = Ly.ZBox.StorageUnit.GetStringValue(list[0], pool); string res = ""; using (Ly.Data.SQLClient Conn = new Ly.Data.SQLClient(gszConnString)) { Conn.ExecuteNonQuery(szArg0); } return(res); default: throw new Exception("参数数量不正确,未找到" + list.Count + "参数的定义。"); } }
//字段查找函数 private string Fun_Column(List <StorageUnit> list, StoragePool pool) { switch (list.Count) { case 1: string szArg0 = Ly.ZBox.StorageUnit.GetStringValue(list[0], pool); if (gnTable > 0) { if (gTab.SystemColumns.GetDataByParentIDAndText(gnTable, szArg0)) { return(gTab.SystemColumns.Structure.Name); } else { throw new Exception("未在表中找到\"" + szArg0 + "\"字段。"); } } else { throw new Exception("多表情况下,查询字段必须加上表名称参数。"); } case 2: int nArg0 = Ly.ZBox.StorageUnit.GetIntegerValue(list[0], pool);; string szArg1 = Ly.ZBox.StorageUnit.GetStringValue(list[1], pool);; if (gTab.SystemColumns.GetDataByParentIDAndText(nArg0, szArg1)) { return(gTab.SystemColumns.Structure.Name); } else { throw new Exception("未在表中找到\"" + szArg1 + "\"字段。"); } default: throw new Exception("参数数量不正确,未找到" + list.Count + "参数的定义。"); } }
public virtual StorApiStatus IsDriveConfiguredForSpaces(Drive drive, ref bool configured) { StorApiStatus storApiStatus = StorApiStatusEnum.STOR_NO_ERROR; if (drive == null) { return(StorApiStatusEnum.STOR_INVALID_PARAM); } StoragePool storagePool = null; SpacesApiError physicalDiskPool = SpacesApi.SpacesApi.GetPhysicalDiskPool(drive.Id, ref storagePool); if (physicalDiskPool == SpacesApiError.Success) { if (storagePool == null) { configured = false; } else { configured = !storagePool.IsPrimordial; } } return(SpacesUtil.ToStorApiStatus(physicalDiskPool)); }
private void ValidateStoragePool(StoragePool instance) { FabricCommon.ValidateResource(instance); Assert.NotNull(instance.SizeGB); }
public SettingFacade(StoragePool db, IBackupImport backupImport) : base(db) { _backupImport = backupImport; }
public PersonFacade(StoragePool storagePool) : base(storagePool) { }
public BackupImport(StoragePool storagePool, PerstStorageFactory storageFactory) { _storagePool = storagePool; _storageFactory = storageFactory; }
/// <summary> /// Loads the configurations from a saved profile. /// </summary> /// <param name="request">Profile request.</param> public void LoadProfileSettings(ProfileRequest request) { string filenameWithoutExtension = Path.GetFileNameWithoutExtension(request.FileName); var baseNode = StoragePool.GetKnownNode(KnownStorageNodeNames.TestSuite); if (baseNode.NodeExists(filenameWithoutExtension)) { baseNode.RemoveNode(filenameWithoutExtension); } var profileNode = baseNode.CreateNode(filenameWithoutExtension); profileNode.CreateFile(request.FileName, request.Stream); string fullName = Path.Combine(profileNode.AbsolutePath, request.FileName); var configurationNode = StoragePool.GetKnownNode(KnownStorageNodeNames.Configuration); var testSuite = GetTestSuite(request.TestSuiteId); using (ProfileUtil profile = ProfileUtil.LoadProfile(fullName)) { if (!profile.VerifyVersion(testSuite.Version)) { if (profile.Info != null) { throw new InvalidDataException(string.Format ( StringMessages.ProfileNotMatchError, profile.Info.TestSuiteName, profile.Info.Version, testSuite.Name, testSuite.Version ) ); } else { throw new InvalidDataException(StringMessages.InvalidProfile); } } string configBaseNode = GetConfigurationsPath(request.ConfigurationId, configurationNode.AbsolutePath); if (!configurationNode.NodeExists(configBaseNode)) { configurationNode.CreateNode(configBaseNode); } string profileDestinationPath = Path.Combine(configBaseNode, ConfigurationConsts.Profile); string playlistDestinationPath = Path.Combine(configBaseNode, ConfigurationConsts.PlayList); configurationNode.RemoveFile(profileDestinationPath); configurationNode.RemoveFile(playlistDestinationPath); configurationNode.CreateFile(profileDestinationPath, profile.ProfileStream); configurationNode.CreateFile(playlistDestinationPath, profile.PlaylistStream); string ptfConfigsDestinationDir = GetPtfConfigBasePath(request.ConfigurationId, configurationNode.AbsolutePath); profile.SavePtfCfgTo(ptfConfigsDestinationDir); } }
/// <summary> /// Get the list of all storages under the vault. /// </summary> /// <param name='serverId'> /// Required. Server Id. /// </param> /// <param name='customRequestHeaders'> /// Optional. Request header parameters. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> /// <returns> /// The response model for the list storage operation. /// </returns> public async Task <StorageListResponse> ListAsync(string serverId, CustomRequestHeaders customRequestHeaders, CancellationToken cancellationToken) { // Validate if (serverId == null) { throw new ArgumentNullException("serverId"); } // Tracing bool shouldTrace = TracingAdapter.IsEnabled; string invocationId = null; if (shouldTrace) { invocationId = TracingAdapter.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("serverId", serverId); tracingParameters.Add("customRequestHeaders", customRequestHeaders); TracingAdapter.Enter(invocationId, this, "ListAsync", tracingParameters); } // Construct URL string url = ""; if (this.Client.Credentials.SubscriptionId != null) { url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); } url = url + "/cloudservices/"; url = url + Uri.EscapeDataString(this.Client.CloudServiceName); url = url + "/resources/"; url = url + "WAHyperVRecoveryManager"; url = url + "/~/"; url = url + "HyperVRecoveryManagerVault"; url = url + "/"; url = url + Uri.EscapeDataString(this.Client.ResourceName); url = url + "/Storages"; List <string> queryParameters = new List <string>(); queryParameters.Add("api-version=2015-04-10"); queryParameters.Add("ServerId=" + Uri.EscapeDataString(serverId)); if (queryParameters.Count > 0) { url = url + "?" + string.Join("&", queryParameters); } string baseUrl = this.Client.BaseUri.AbsoluteUri; // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl[baseUrl.Length - 1] == '/') { baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); } if (url[0] == '/') { url = url.Substring(1); } url = baseUrl + "/" + url; url = url.Replace(" ", "%20"); // Create HTTP transport objects HttpRequestMessage httpRequest = null; try { httpRequest = new HttpRequestMessage(); httpRequest.Method = HttpMethod.Get; httpRequest.RequestUri = new Uri(url); // Set Headers httpRequest.Headers.Add("Accept", "application/xml"); httpRequest.Headers.Add("x-ms-client-request-id", customRequestHeaders.ClientRequestId); httpRequest.Headers.Add("x-ms-version", "2013-03-01"); // Set Credentials cancellationToken.ThrowIfCancellationRequested(); await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); // Send Request HttpResponseMessage httpResponse = null; try { if (shouldTrace) { TracingAdapter.SendRequest(invocationId, httpRequest); } cancellationToken.ThrowIfCancellationRequested(); httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); if (shouldTrace) { TracingAdapter.ReceiveResponse(invocationId, httpResponse); } HttpStatusCode statusCode = httpResponse.StatusCode; if (statusCode != HttpStatusCode.OK) { cancellationToken.ThrowIfCancellationRequested(); CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); if (shouldTrace) { TracingAdapter.Error(invocationId, ex); } throw ex; } // Create Result StorageListResponse result = null; // Deserialize Response if (statusCode == HttpStatusCode.OK) { cancellationToken.ThrowIfCancellationRequested(); string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); result = new StorageListResponse(); XDocument responseDoc = XDocument.Parse(responseContent); XElement arrayOfStorageSequenceElement = responseDoc.Element(XName.Get("ArrayOfStorage", "http://schemas.microsoft.com/windowsazure")); if (arrayOfStorageSequenceElement != null) { foreach (XElement arrayOfStorageElement in arrayOfStorageSequenceElement.Elements(XName.Get("Storage", "http://schemas.microsoft.com/windowsazure"))) { AsrStorage storageInstance = new AsrStorage(); result.Storages.Add(storageInstance); XElement typeElement = arrayOfStorageElement.Element(XName.Get("Type", "http://schemas.microsoft.com/windowsazure")); if (typeElement != null) { string typeInstance = typeElement.Value; storageInstance.Type = typeInstance; } XElement fabricObjectIDElement = arrayOfStorageElement.Element(XName.Get("FabricObjectID", "http://schemas.microsoft.com/windowsazure")); if (fabricObjectIDElement != null) { string fabricObjectIDInstance = fabricObjectIDElement.Value; storageInstance.FabricObjectID = fabricObjectIDInstance; } XElement fabricTypeElement = arrayOfStorageElement.Element(XName.Get("FabricType", "http://schemas.microsoft.com/windowsazure")); if (fabricTypeElement != null) { string fabricTypeInstance = fabricTypeElement.Value; storageInstance.FabricType = fabricTypeInstance; } XElement serverIDElement = arrayOfStorageElement.Element(XName.Get("ServerID", "http://schemas.microsoft.com/windowsazure")); if (serverIDElement != null) { string serverIDInstance = serverIDElement.Value; storageInstance.ServerID = serverIDInstance; } XElement storagePoolsSequenceElement = arrayOfStorageElement.Element(XName.Get("StoragePools", "http://schemas.microsoft.com/windowsazure")); if (storagePoolsSequenceElement != null) { foreach (XElement storagePoolsElement in storagePoolsSequenceElement.Elements(XName.Get("StoragePool", "http://schemas.microsoft.com/windowsazure"))) { StoragePool storagePoolInstance = new StoragePool(); storageInstance.StoragePools.Add(storagePoolInstance); XElement idElement = storagePoolsElement.Element(XName.Get("ID", "http://schemas.microsoft.com/windowsazure")); if (idElement != null) { string idInstance = idElement.Value; storagePoolInstance.ID = idInstance; } XElement nameElement = storagePoolsElement.Element(XName.Get("Name", "http://schemas.microsoft.com/windowsazure")); if (nameElement != null) { string nameInstance = nameElement.Value; storagePoolInstance.Name = nameInstance; } } } XElement nameElement2 = arrayOfStorageElement.Element(XName.Get("Name", "http://schemas.microsoft.com/windowsazure")); if (nameElement2 != null) { string nameInstance2 = nameElement2.Value; storageInstance.Name = nameInstance2; } XElement idElement2 = arrayOfStorageElement.Element(XName.Get("ID", "http://schemas.microsoft.com/windowsazure")); if (idElement2 != null) { string idInstance2 = idElement2.Value; storageInstance.ID = idInstance2; } } } } result.StatusCode = statusCode; if (httpResponse.Headers.Contains("x-ms-request-id")) { result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); } if (shouldTrace) { TracingAdapter.Exit(invocationId, result); } return(result); } finally { if (httpResponse != null) { httpResponse.Dispose(); } } } finally { if (httpRequest != null) { httpRequest.Dispose(); } } }
public ListingFactory(StoragePool storagePool) { _storagePool = storagePool; }
public EmployerFactory(StoragePool storagePool) { _storagePool = storagePool; }
public BaseFacade(StoragePool storagePool) { _storagePool = storagePool; }
public EmployerFacade(StoragePool db) : base(db) { }
public ListingFacade(StoragePool db) : base(db) { }