Пример #1
0
        private bool CreateProfileSync(string scenario, out string profileResourceId)
        {
            //1. CreateProfile, create a new profile and return its resource id.
            MsnServiceState serviceState   = new MsnServiceState(scenario, "CreateProfile", false);
            StorageService  storageService = (StorageService)CreateService(MsnServiceType.Storage, serviceState);

            CreateProfileRequestType createRequest = new CreateProfileRequestType();

            createRequest.profile = new CreateProfileRequestTypeProfile();
            createRequest.profile.ExpressionProfile = new ExpressionProfile();
            createRequest.profile.ExpressionProfile.PersonalStatus     = "";
            createRequest.profile.ExpressionProfile.RoleDefinitionName = "ExpressionProfileDefault";

            try
            {
                ChangeCacheKeyAndPreferredHostForSpecifiedMethod(storageService, MsnServiceType.Storage, serviceState, createRequest);
                CreateProfileResponse createResponse = storageService.CreateProfile(createRequest);
                profileResourceId = createResponse.CreateProfileResult;
                NSMessageHandler.ContactService.Deltas.Profile.ResourceID = profileResourceId;
                NSMessageHandler.ContactService.Deltas.Save(true);
            }
            catch (Exception ex)
            {
                OnServiceOperationFailed(storageService, new ServiceOperationFailedEventArgs("CreateProfile", ex));
                Trace.WriteLineIf(Settings.TraceSwitch.TraceError, "CreateProfile error: " + ex.Message, GetType().Name);
                profileResourceId = string.Empty;

                return(false);
            }

            return(true);
        }
Пример #2
0
        public ManagedObjectReference CreateProfile(ProfileCreateSpec createSpec)
        {
            ManagedObjectReference result;

            try
            {
                VersionUtils.RequiresVersion(this.Client, VimVersion.Vim4);
                CreateProfileRequestType createProfileRequestType = new CreateProfileRequestType();
                createProfileRequestType._this      = (VimApi_65.ManagedObjectReference)VIConvert.ToWsdlType(this.MoRef);
                createProfileRequestType.createSpec = (VimApi_65.ProfileCreateSpec)VIConvert.ToWsdlType(createSpec);
                result = (ManagedObjectReference)VIConvert.ToVim(this.VimServiceProxy.CreateProfile(new CreateProfileRequest(createProfileRequestType)).CreateProfileResponse.returnval);
            }
            catch (FaultException ex)
            {
                throw FaultUtility.HandleFault(ex);
            }
            return(result);
        }
Пример #3
0
        private bool CreateProfileSync(string scenario, out string profileResourceId)
        {
            //1. CreateProfile, create a new profile and return its resource id.
            MsnServiceState serviceState = new MsnServiceState(scenario, "CreateProfile", false);
            StorageService storageService = (StorageService)CreateService(MsnServiceType.Storage, serviceState);

            CreateProfileRequestType createRequest = new CreateProfileRequestType();
            createRequest.profile = new CreateProfileRequestTypeProfile();
            createRequest.profile.ExpressionProfile = new ExpressionProfile();
            createRequest.profile.ExpressionProfile.PersonalStatus = "";
            createRequest.profile.ExpressionProfile.RoleDefinitionName = "ExpressionProfileDefault";

            try
            {
                ChangeCacheKeyAndPreferredHostForSpecifiedMethod(storageService, MsnServiceType.Storage, serviceState, createRequest);
                CreateProfileResponse createResponse = storageService.CreateProfile(createRequest);
                profileResourceId = createResponse.CreateProfileResult;
                NSMessageHandler.ContactService.Deltas.Profile.ResourceID = profileResourceId;
                NSMessageHandler.ContactService.Deltas.Save(true);
            }
            catch (Exception ex)
            {
                OnServiceOperationFailed(storageService, new ServiceOperationFailedEventArgs("CreateProfile", ex));
                Trace.WriteLineIf(Settings.TraceSwitch.TraceError, "CreateProfile error: " + ex.Message, GetType().Name);
                profileResourceId = string.Empty;

                return false;
            }

            return true;
        }