当前位置: 首页>>代码示例>>C#>>正文


C# Common.ResultObject类代码示例

本文整理汇总了C#中WebsitePanel.Providers.Common.ResultObject的典型用法代码示例。如果您正苦于以下问题:C# ResultObject类的具体用法?C# ResultObject怎么用?C# ResultObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ResultObject类属于WebsitePanel.Providers.Common命名空间,在下文中一共展示了ResultObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetReplicaInfoForService

        public static ReplicationServerInfo GetReplicaInfoForService(int serviceId, ref ResultObject result)
        {
            // Get service id of replica server
            StringDictionary vsSesstings = ServerController.GetServiceSettings(serviceId);
            string replicaServiceId = vsSesstings["ReplicaServerId"];

            if (string.IsNullOrEmpty(replicaServiceId))
            {
                result.ErrorCodes.Add(VirtualizationErrorCodes.NO_REPLICA_SERVER_ERROR);
                return null;
            }

            // get replica server info for replica service id
            VirtualizationServer2012 vsReplica = VirtualizationHelper.GetVirtualizationProxy(Convert.ToInt32(replicaServiceId));
            StringDictionary vsReplicaSesstings = ServerController.GetServiceSettings(Convert.ToInt32(replicaServiceId));
            string computerName = vsReplicaSesstings["ServerName"];
            var replicaServerInfo = vsReplica.GetReplicaServer(computerName);

            if (!replicaServerInfo.Enabled)
            {
                result.ErrorCodes.Add(VirtualizationErrorCodes.NO_REPLICA_SERVER_ERROR);
                return null;
            }

            return replicaServerInfo;
        }
开发者ID:lwhitelock,项目名称:Websitepanel,代码行数:26,代码来源:ReplicationHelper.cs

示例2: gvStorageSpaces_RowCommand

        protected void gvStorageSpaces_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "DeleteItem")
            {
                int id;
                bool hasValue = int.TryParse(e.CommandArgument.ToString(), out id);

                ResultObject result = new ResultObject();
                result.IsSuccess = false;

                if (hasValue)
                {
                    result = ES.Services.StorageSpaces.RemoveStorageSpace(id);
                }

                messageBox.ShowMessage(result, "STORAGE_SPACES_LEVEL_REMOVE", null);

                if (!result.IsSuccess)
                {
                    return;
                }

                gvStorageSpaces.DataBind();
            }
            else if (e.CommandName == "EditStorageSpace")
            {
                EditStorageSpace(e.CommandArgument.ToString());
            }
        }
开发者ID:lwhitelock,项目名称:Websitepanel,代码行数:29,代码来源:StorageSpacesList.ascx.cs

示例3: CheckReplicationQuota

        public static void CheckReplicationQuota(int packageId, ref ResultObject result)
        {
            List<string> quotaResults = new List<string>();
            PackageContext cntx = PackageController.GetPackageContext(packageId);

            QuotaHelper.CheckBooleanQuota(cntx, quotaResults, Quotas.VPS2012_REPLICATION_ENABLED, true, VirtualizationErrorCodes.QUOTA_REPLICATION_ENABLED);

            if (quotaResults.Count > 0)
                result.ErrorCodes.AddRange(quotaResults);
        }
开发者ID:lwhitelock,项目名称:Websitepanel,代码行数:10,代码来源:ReplicationHelper.cs

示例4: GetReplicaForService

        public static VirtualizationServer2012 GetReplicaForService(int serviceId, ref ResultObject result)
        {
            // Get service id of replica server
            StringDictionary vsSesstings = ServerController.GetServiceSettings(serviceId);
            string replicaServiceId = vsSesstings["ReplicaServerId"];

            if (string.IsNullOrEmpty(replicaServiceId))
            {
                result.ErrorCodes.Add(VirtualizationErrorCodes.NO_REPLICA_SERVER_ERROR);
                return null;
            }

            // get replica server for replica service id
            return VirtualizationHelper.GetVirtualizationProxy(Convert.ToInt32(replicaServiceId));
        }
开发者ID:lwhitelock,项目名称:Websitepanel,代码行数:15,代码来源:ReplicationHelper.cs

示例5: CleanUpReplicaServer

        public static void CleanUpReplicaServer(VirtualMachine originalVm)
        {
            try
            {
                ResultObject result = new ResultObject();

                // Get replica server
                var replicaServer = GetReplicaForService(originalVm.ServiceId, ref result);

                // Clean up replica server
                var replicaVm = replicaServer.GetVirtualMachines().FirstOrDefault(m => m.Name == originalVm.Name);
                if (replicaVm != null)
                {
                    replicaServer.DisableVmReplication(replicaVm.VirtualMachineId);
                    replicaServer.ShutDownVirtualMachine(replicaVm.VirtualMachineId, true, "ReplicaDelete");
                    replicaServer.DeleteVirtualMachine(replicaVm.VirtualMachineId);
                }
            }
            catch { /* skip */ }
        }
开发者ID:lwhitelock,项目名称:Websitepanel,代码行数:20,代码来源:ReplicationHelper.cs

示例6: SetMailBoxRetentionPolicyAndArchiving

        private static void SetMailBoxRetentionPolicyAndArchiving(int itemId, int mailboxPlanId, int retentionPolicyId, string accountName, ExchangeServer exchange, string orgId, ResultObject result, bool EnableArchiving)
        {

            long archiveQuotaKB = 0;
            long archiveWarningQuotaKB = 0;
            string RetentionPolicy = "";

            ExchangeMailboxPlan mailboxPlan = GetExchangeMailboxPlan(itemId, mailboxPlanId);
            if ( mailboxPlan != null)
            {
                archiveQuotaKB = mailboxPlan.ArchiveSizeMB != -1 ? ((long)mailboxPlan.ArchiveSizeMB * 1024) : -1;
                archiveWarningQuotaKB = mailboxPlan.ArchiveSizeMB != -1 ? (((long)mailboxPlan.ArchiveWarningPct * (long) mailboxPlan.ArchiveSizeMB * 1024) / 100) : -1;
            }


            if (retentionPolicyId > 0)
            {
                ExchangeMailboxPlan retentionPolicy = GetExchangeMailboxPlan(itemId, retentionPolicyId);
                if (retentionPolicy != null)
                {
                    UpdateExchangeRetentionPolicy(itemId, retentionPolicyId, result);
                }

            }
            ResultObject res = exchange.SetMailBoxArchiving(orgId, accountName, EnableArchiving, archiveQuotaKB, archiveWarningQuotaKB, RetentionPolicy);
            if (res != null)
            {
                result.ErrorCodes.AddRange(res.ErrorCodes);
                result.IsSuccess = result.IsSuccess && res.IsSuccess;
            }
        }
开发者ID:JohnyBuchar,项目名称:Websitepanel,代码行数:31,代码来源:ExchangeServerController.cs

示例7: CreateMailbox


//.........这里部分代码省略.........

                //GetServiceSettings
                StringDictionary primSettings = ServerController.GetServiceSettings(exchangeServiceId);
                PackageContext cntx = PackageController.GetPackageContext(org.PackageId);

                string samAccountName = exchange.CreateMailEnableUser(email, org.OrganizationId, org.DistinguishedName,
                                                org.SecurityGroup, org.DefaultDomain,
                                                accountType, primSettings["mailboxdatabase"],
                                                org.OfflineAddressBook,
                                                org.AddressBookPolicy,
                                                retUser.SamAccountName,
                                                plan.EnablePOP,
                                                plan.EnableIMAP,
                                                plan.EnableOWA,
                                                plan.EnableMAPI,
                                                plan.EnableActiveSync,
                                                plan.MailboxSizeMB != -1 ? (((long)plan.IssueWarningPct * (long)plan.MailboxSizeMB * 1024) / 100) : -1,
                                                plan.MailboxSizeMB != -1 ? (((long)plan.ProhibitSendPct * (long)plan.MailboxSizeMB * 1024) / 100) : -1,
                                                plan.MailboxSizeMB != -1 ? (((long)plan.ProhibitSendReceivePct * (long)plan.MailboxSizeMB * 1024) / 100) : -1,
                                                plan.KeepDeletedItemsDays,
                                                plan.MaxRecipients,
                                                plan.MaxSendMessageSizeKB,
                                                plan.MaxReceiveMessageSizeKB,
                                                plan.HideFromAddressBook,
                                                Convert.ToBoolean(cntx.Quotas[Quotas.EXCHANGE2007_ISCONSUMER].QuotaAllocatedValue),
                                                plan.AllowLitigationHold,
                                                plan.RecoverableItemsSpace != -1 ? (plan.RecoverableItemsSpace * 1024) : -1,
                                                plan.RecoverableItemsSpace != -1 ? (((long)plan.RecoverableItemsWarningPct * (long)plan.RecoverableItemsSpace * 1024) / 100) : -1);

                MailboxManagerActions pmmActions = MailboxManagerActions.GeneralSettings
                    | MailboxManagerActions.MailFlowSettings
                    | MailboxManagerActions.AdvancedSettings
                    | MailboxManagerActions.EmailAddresses;


                UpdateExchangeAccount(accountId, accountName, accountType, displayName, email, false, pmmActions.ToString(), samAccountName, password, mailboxPlanId, archivedPlanId, subscriberNumber, EnableArchiving);

                ResultObject resPolicy = new ResultObject() { IsSuccess = true };
                SetMailBoxRetentionPolicyAndArchiving(itemId, mailboxPlanId, archivedPlanId, accountName, exchange, org.OrganizationId, resPolicy, EnableArchiving);
                if (!resPolicy.IsSuccess)
                {
                    TaskManager.WriteError("Error SetMailBoxRetentionPolicy: " + string.Join(", ", resPolicy.ErrorCodes.ToArray()));
                }
                

                // send setup instructions
                if (sendSetupInstructions)
                {
                    try
                    {
                        // send setup instructions
                        int sendResult = SendMailboxSetupInstructions(itemId, accountId, true, setupInstructionMailAddress, null);
                        if (sendResult < 0)
                            TaskManager.WriteWarning("Setup instructions were not sent. Error code: " + sendResult);
                    }
                    catch (Exception ex)
                    {
                        TaskManager.WriteError(ex);
                    }
                }

                try
                {
                    // update OAB
                    // check if this is the first mailbox within the organization
                    if (GetAccounts(itemId, ExchangeAccountType.Mailbox).Count == 1)
                        exchange.UpdateOrganizationOfflineAddressBook(org.OfflineAddressBook);
                }
                catch (Exception ex)
                {
                    TaskManager.WriteError(ex);
                }

                // Log Extension
                LogExtension.WriteVariables(new {email, samAccountName, accountId});

                return accountId;
            }
            catch (Exception ex)
            {
                //rollback AD user
                if (userCreated)
                {
                    try
                    {
                        OrganizationController.DeleteUser(org.Id, accountId);
                    }
                    catch (Exception rollbackException)
                    {
                        TaskManager.WriteError(rollbackException);
                    }
                }
                throw TaskManager.WriteError(ex);

            }
            finally
            {
                TaskManager.CompleteTask();
            }
        }
开发者ID:JohnyBuchar,项目名称:Websitepanel,代码行数:101,代码来源:ExchangeServerController.cs

示例8: SetPicture

        public override ResultObject SetPicture(string accountName, byte[] picture)
        {
            ExchangeLog.LogStart("SetPicture");

            ResultObject res = new ResultObject() { IsSuccess = true };

            Runspace runSpace = null;
            try
            {
                runSpace = OpenRunspace();
                Command cmd;

                if (picture == null)
                {
                    cmd = new Command("Set-Mailbox");
                    cmd.Parameters.Add("Identity", accountName);
                    cmd.Parameters.Add("RemovePicture", true);
                }
                else
                {
                    cmd = new Command("Import-RecipientDataProperty");
                    cmd.Parameters.Add("Identity", accountName);
                    cmd.Parameters.Add("Picture", true);
                    cmd.Parameters.Add("FileData", picture);
                }
                ExecuteShellCommand(runSpace, cmd, res, true);
            }
            finally
            {
                CloseRunspace(runSpace);
            }
            ExchangeLog.LogEnd("SetPicture");

            return res;
        }
开发者ID:jonwbstr,项目名称:Websitepanel,代码行数:35,代码来源:Exchange2010.cs

示例9: GrantWebManagementAccess

		public static ResultObject GrantWebManagementAccess(int siteItemId, string accountName, string accountPassword)
		{
			ResultObject result = new ResultObject { IsSuccess = true };

			try
			{
				TaskManager.StartTask(LOG_SOURCE_WEB, "GrantWebManagementAccess");
				TaskManager.WriteParameter("SiteItemId", siteItemId);
				
				//
				WebSite item = GetWebSite(siteItemId);
				
				//
				if (item == null)
				{
					TaskManager.WriteError("Web site not found");
					//
					result.AddError("WEBSITE_NOT_FOUND", null);
					result.IsSuccess = false;
					return result;
				}

				//
				int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
				if (accountCheck < 0)
				{
					TaskManager.WriteWarning("Current user is either demo or inactive");
					//
					result.AddError("DEMO_USER", null);
					result.IsSuccess = false;
					return result;
				}

				// check package
				int packageCheck = SecurityContext.CheckPackage(item.PackageId, DemandPackage.IsActive);
				if (packageCheck < 0)
				{
					TaskManager.WriteWarning("Current user is either not allowed to access the package or the package inactive");
					//
					result.AddError("NOT_ALLOWED", null);
					result.IsSuccess = false;
					return result;
				}
				
				//
				WebServer server = GetWebServer(item.ServiceId);

				//
				if (server.CheckWebManagementAccountExists(accountName))
				{
					TaskManager.WriteWarning("Account name specified already exists");
					//
					result.AddError("ACCOUNTNAME_PROHIBITED", null);
					result.IsSuccess = false;
					return result;
				}

				//
				ResultObject passwResult = server.CheckWebManagementPasswordComplexity(accountPassword);
				if (!passwResult.IsSuccess)
				{
					TaskManager.WriteWarning("Account password does not meet complexity requirements");
					//
					result.ErrorCodes.AddRange(passwResult.ErrorCodes);
					result.IsSuccess = false;
					//
					return result;
				}
				
				//
				server.GrantWebManagementAccess(item.SiteId, accountName, accountPassword);
			}
			catch (Exception ex)
			{
				TaskManager.WriteError(ex);
			}
			finally
			{
				TaskManager.CompleteTask();
			}
			//
			return result;
		}
开发者ID:jordan49,项目名称:websitepanel,代码行数:83,代码来源:WebServerController.cs

示例10: GrantWebDeployPublishingAccess

		public static ResultObject GrantWebDeployPublishingAccess(int siteItemId, string accountName, string accountPassword)
		{
			ResultObject result = new ResultObject { IsSuccess = true };

			try
			{
				TaskManager.StartTask(LOG_SOURCE_WEB, "GrantWeDeployPublishingAccess");
				TaskManager.WriteParameter("SiteItemId", siteItemId);

				// load site item
				var item = (WebSite)PackageController.GetPackageItem(siteItemId);

				//
				if (item == null)
				{
					TaskManager.WriteError("Web site not found");
					//
					result.AddError("WEBSITE_NOT_FOUND", null);
					result.IsSuccess = false;
					return result;
				}

				//
				int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
				if (accountCheck < 0)
				{
					TaskManager.WriteWarning("Current user is either demo or inactive");
					//
					result.AddError("DEMO_USER", null);
					result.IsSuccess = false;
					return result;
				}

				// check package
				int packageCheck = SecurityContext.CheckPackage(item.PackageId, DemandPackage.IsActive);
				if (packageCheck < 0)
				{
					TaskManager.WriteWarning("Current user is either not allowed to access the package or the package inactive");
					//
					result.AddError("NOT_ALLOWED", null);
					result.IsSuccess = false;
					return result;
				}

				//
				WebServer server = GetWebServer(item.ServiceId);

				// Most part of the functionality used to enable Web Deploy publishing correspond to those created for Web Management purposes,
				// so we can re-use the existing functionality to deliver seamless development experience.
				if (server.CheckWebManagementAccountExists(accountName))
				{
					TaskManager.WriteWarning("Account name specified already exists");
					//
					result.AddError("ACCOUNTNAME_PROHIBITED", null);
					result.IsSuccess = false;
					return result;
				}

				// Most part of the functionality used to enable Web Deploy publishing correspond to those created for Web Management purposes,
				// so we can re-use the existing functionality to deliver seamless development experience.
				ResultObject passwResult = server.CheckWebManagementPasswordComplexity(accountPassword);
				if (!passwResult.IsSuccess)
				{
					TaskManager.WriteWarning("Account password does not meet complexity requirements");
					//
					result.ErrorCodes.AddRange(passwResult.ErrorCodes);
					result.IsSuccess = false;
					//
					return result;
				}

				// Execute a call to remote server to enable Web Deploy publishing access for the specified user account
				server.GrantWebDeployPublishingAccess(item.SiteId, accountName, accountPassword);
				// Enable Web Deploy flag for the web site
				item.WebDeploySitePublishingEnabled = true;
				// Remember Web Deploy publishing account
				item.WebDeployPublishingAccount = accountName;
				// Remember Web Deploy publishing password
				item.WebDeployPublishingPassword = CryptoUtils.Encrypt(accountPassword);
				// Put changes in effect
				PackageController.UpdatePackageItem(item);
			}
			catch (Exception ex)
			{
				TaskManager.WriteError(ex);
				//
				result.IsSuccess = false;
			}
			finally
			{
				TaskManager.CompleteTask();
			}
			//
			return result;
		}
开发者ID:jordan49,项目名称:websitepanel,代码行数:95,代码来源:WebServerController.cs

示例11: CheckWebManagementPasswordComplexity

		public new ResultObject CheckWebManagementPasswordComplexity(string accountPassword)
		{
			// Preserve setting to restore it back
			bool adEnabled = ServerSettings.ADEnabled;
			// !!! Bypass AD for WMSVC as it requires full-qualified username to authenticate user
			// against the web server
			ServerSettings.ADEnabled = false;
			
			//
			ResultObject result = new ResultObject { IsSuccess = true };

			//
			if (IdentityCredentialsMode == "IISMNGR")
			{
				InvalidPasswordReason reason = ManagementAuthentication.IsPasswordStrongEnough(accountPassword);
				//
				if (reason != InvalidPasswordReason.NoError)
				{
					result.IsSuccess = false;
					result.AddError(reason.ToString(), new Exception("Password complexity check failed"));
				}
			}
			// Restore setting back
			ServerSettings.ADEnabled = adEnabled;

			//
			return result;
		}
开发者ID:jordan49,项目名称:websitepanel,代码行数:28,代码来源:IIs70.cs

示例12: AddVirtualMachinePrivateIPAddresses

        public static ResultObject AddVirtualMachinePrivateIPAddresses(int itemId, bool selectRandom, int addressesNumber, string[] addresses, bool provisionKvp)
        {
            // trace info
            Trace.TraceInformation("Entering AddVirtualMachinePrivateIPAddresses()");
            Trace.TraceInformation("Item ID: {0}", itemId);
            Trace.TraceInformation("SelectRandom: {0}", selectRandom);
            Trace.TraceInformation("AddressesNumber: {0}", addressesNumber);

            if (addresses != null)
            {
                foreach(var address in addresses)
                    Trace.TraceInformation("addresses[n]: {0}", address);
            }

            ResultObject res = new ResultObject();

            // load service item
            VirtualMachine vm = (VirtualMachine)PackageController.GetPackageItem(itemId);
            if (vm == null)
            {
                res.ErrorCodes.Add(VirtualizationErrorCodes.CANNOT_FIND_VIRTUAL_MACHINE_META_ITEM);
                return res;
            }

            #region Check account and space statuses
            // check account
            if (!SecurityContext.CheckAccount(res, DemandAccount.NotDemo | DemandAccount.IsActive))
                return res;

            // check package
            if (!SecurityContext.CheckPackage(res, vm.PackageId, DemandPackage.IsActive))
                return res;
            #endregion

            // start task
            res = TaskManager.StartResultTask<ResultObject>("VPS", "ADD_PRIVATE_IP", vm.Id, vm.Name, vm.PackageId);

            try
            {
                // load network adapter
                NetworkAdapterDetails nic = GetPrivateNetworkAdapterDetails(itemId);

                bool wasEmptyList = (nic.IPAddresses.Length == 0);

                if(wasEmptyList)
                    Trace.TraceInformation("NIC IP addresses list is empty");

                // check IP addresses if they are specified
                List<string> checkResults = CheckPrivateIPAddresses(vm.PackageId, addresses);
                if (checkResults.Count > 0)
                {
                    res.ErrorCodes.AddRange(checkResults);
                    res.IsSuccess = false;
                    TaskManager.CompleteResultTask();
                    return res;
                }

                // load all existing private IP addresses
                List<PrivateIPAddress> ips = GetPackagePrivateIPAddresses(vm.PackageId);

                // sort them
                SortedList<IPAddress, string> sortedIps = GetSortedNormalizedIPAddresses(ips, nic.SubnetMask);

                if (selectRandom)
                {
                    // generate N number of IP addresses
                    addresses = new string[addressesNumber];
                    for (int i = 0; i < addressesNumber; i++)
                        addresses[i] = GenerateNextAvailablePrivateIP(sortedIps, nic.SubnetMask, nic.NetworkFormat);
                }

                PackageContext cntx = PackageController.GetPackageContext(vm.PackageId);
                QuotaValueInfo quota = cntx.Quotas[Quotas.VPS2012_PRIVATE_IP_ADDRESSES_NUMBER];
                if (quota.QuotaAllocatedValue != -1)
                {
                    int maxAddresses = quota.QuotaAllocatedValue - nic.IPAddresses.Length;

                    if (addresses.Length > maxAddresses)
                    {
                        TaskManager.CompleteResultTask(res, VirtualizationErrorCodes.QUOTA_EXCEEDED_PRIVATE_ADDRESSES_NUMBER + ":" + maxAddresses);
                        return res;
                    }
                }

                // add addresses to database
                foreach (string address in addresses)
                    DataProvider.AddItemPrivateIPAddress(SecurityContext.User.UserId, itemId, address);

                // set primary IP address
                if (wasEmptyList)
                {
                    nic = GetPrivateNetworkAdapterDetails(itemId);
                    if (nic.IPAddresses.Length > 0)
                        SetVirtualMachinePrimaryPrivateIPAddress(itemId, nic.IPAddresses[0].AddressId, false);
                }

                // send KVP config items
                if(provisionKvp)
                    SendNetworkAdapterKVP(itemId, "Private");
            }
//.........这里部分代码省略.........
开发者ID:lwhitelock,项目名称:Websitepanel,代码行数:101,代码来源:VirtualizationServerController2012.cs

示例13: SetVirtualMachinePrimaryExternalIPAddress

        public static ResultObject SetVirtualMachinePrimaryExternalIPAddress(int itemId, int packageAddressId, bool provisionKvp)
        {
            ResultObject res = new ResultObject();

            // load service item
            VirtualMachine vm = (VirtualMachine)PackageController.GetPackageItem(itemId);
            if (vm == null)
            {
                res.ErrorCodes.Add(VirtualizationErrorCodes.CANNOT_FIND_VIRTUAL_MACHINE_META_ITEM);
                return res;
            }

            #region Check account and space statuses
            // check account
            if (!SecurityContext.CheckAccount(res, DemandAccount.NotDemo | DemandAccount.IsActive))
                return res;

            // check package
            if (!SecurityContext.CheckPackage(res, vm.PackageId, DemandPackage.IsActive))
                return res;
            #endregion

            // start task
            res = TaskManager.StartResultTask<ResultObject>("VPS", "SET_PRIMARY_EXTERNAL_IP", vm.Id, vm.Name, vm.PackageId);

            try
            {
                // call database
                ServerController.SetItemPrimaryIPAddress(itemId, packageAddressId);

                // send KVP config items
                if(provisionKvp)
                    SendNetworkAdapterKVP(itemId, "External");
            }
            catch (Exception ex)
            {
                TaskManager.CompleteResultTask(res, VirtualizationErrorCodes.SET_VIRTUAL_MACHINE_PRIMARY_EXTERNAL_IP_ADDRESS_ERROR, ex);
                return res;
            }

            TaskManager.CompleteResultTask();
            return res;
        }
开发者ID:lwhitelock,项目名称:Websitepanel,代码行数:43,代码来源:VirtualizationServerController2012.cs

示例14: AddVirtualMachineExternalIPAddresses

        public static ResultObject AddVirtualMachineExternalIPAddresses(int itemId, bool selectRandom, int addressesNumber, int[] addressIds, bool provisionKvp)
        {
            if (addressIds == null)
                throw new ArgumentNullException("addressIds");

            ResultObject res = new ResultObject();

            // load service item
            VirtualMachine vm = (VirtualMachine)PackageController.GetPackageItem(itemId);
            if (vm == null)
            {
                res.ErrorCodes.Add(VirtualizationErrorCodes.CANNOT_FIND_VIRTUAL_MACHINE_META_ITEM);
                return res;
            }

            #region Check account and space statuses
            // check account
            if (!SecurityContext.CheckAccount(res, DemandAccount.NotDemo | DemandAccount.IsActive))
                return res;

            // check package
            if (!SecurityContext.CheckPackage(res, vm.PackageId, DemandPackage.IsActive))
                return res;
            #endregion

            // start task
            res = TaskManager.StartResultTask<ResultObject>("VPS", "ADD_EXTERNAL_IP", vm.Id, vm.Name, vm.PackageId);

            try
            {
                if (selectRandom)
                {
                    List<PackageIPAddress> ips = ServerController.GetPackageUnassignedIPAddresses(vm.PackageId, IPAddressPool.VpsExternalNetwork);
                    if (addressesNumber > ips.Count)
                    {
                        TaskManager.CompleteResultTask(res, VirtualizationErrorCodes.NOT_ENOUGH_PACKAGE_IP_ADDRESSES);
                        return res;
                    }

                    // get next N unassigned addresses
                    addressIds = new int[addressesNumber];
                    for (int i = 0; i < addressesNumber; i++)
                        addressIds[i] = ips[i].PackageAddressID;
                }

                // add addresses
                foreach (int addressId in addressIds)
                    ServerController.AddItemIPAddress(itemId, addressId);

                // send KVP config items
                if(provisionKvp)
                    SendNetworkAdapterKVP(itemId, "External");
            }
            catch (Exception ex)
            {
                TaskManager.CompleteResultTask(res, VirtualizationErrorCodes.ADD_VIRTUAL_MACHINE_EXTERNAL_IP_ADDRESS_ERROR, ex);
                return res;
            }

            TaskManager.CompleteResultTask();
            return res;
        }
开发者ID:lwhitelock,项目名称:Websitepanel,代码行数:62,代码来源:VirtualizationServerController2012.cs

示例15: DeleteSnapshotSubtree

        public static ResultObject DeleteSnapshotSubtree(int itemId, string snapshotId)
        {
            ResultObject res = new ResultObject();

            // load service item
            VirtualMachine vm = (VirtualMachine)PackageController.GetPackageItem(itemId);
            if (vm == null)
            {
                res.ErrorCodes.Add(VirtualizationErrorCodes.CANNOT_FIND_VIRTUAL_MACHINE_META_ITEM);
                return res;
            }

            #region Check account and space statuses
            // check account
            if (!SecurityContext.CheckAccount(res, DemandAccount.NotDemo | DemandAccount.IsActive))
                return res;

            // check package
            if (!SecurityContext.CheckPackage(res, vm.PackageId, DemandPackage.IsActive))
                return res;
            #endregion

            // start task
            res = TaskManager.StartResultTask<ResultObject>("VPS", "DELETE_SNAPSHOT_SUBTREE", vm.Id, vm.Name, vm.PackageId);

            try
            {
                // get proxy
                VirtualizationServer2012 vs = GetVirtualizationProxy(vm.ServiceId);

                // take snapshot
                JobResult result = vs.DeleteSnapshotSubtree(snapshotId);
                if (result.ReturnValue != ReturnCode.JobStarted)
                {
                    LogReturnValueResult(res, result);
                    TaskManager.CompleteResultTask(res);
                    return res;
                }

                if (!JobCompleted(vs, result.Job))
                {
                    LogJobResult(res, result.Job);
                    TaskManager.CompleteResultTask(res);
                    return res;
                }
            }
            catch (Exception ex)
            {
                TaskManager.CompleteResultTask(res, VirtualizationErrorCodes.DELETE_SNAPSHOT_SUBTREE_ERROR, ex);
                return res;
            }

            TaskManager.CompleteResultTask();
            return res;
        }
开发者ID:lwhitelock,项目名称:Websitepanel,代码行数:55,代码来源:VirtualizationServerController2012.cs


注:本文中的WebsitePanel.Providers.Common.ResultObject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。