• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# XenRef类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Run

        protected override void Run()
        {
            try
            {
                Description = string.Format(Messages.ARCHIVING_SNAPSHOT_X, _snapshot.Name);
                RelatedTask=new XenRef<Task>(VMPP.archive_now(Session, _snapshot.opaque_ref));
                PollToCompletion();
                Description = string.Format(Messages.ARCHIVED_SNAPSHOT_X, _snapshot.Name);
            }
            catch (Exception e)
            {
                Failure f = e as Failure;
                if (f != null)
                {
                    string msg = "";
                    if (f.ErrorDescription.Count > 3)
                    {
                        msg = XenAPI.Message.FriendlyName(f.ErrorDescription[3]);
                    }

                    throw new Exception(msg);

                }
                throw;
            }
        }
开发者ID:huizh,项目名称:xenadmin,代码行数:26,代码来源:ArchiveNowAction.cs


示例2: EvacuateHostPlanAction

 public EvacuateHostPlanAction(Host host)
     : base(host.Connection, string.Format(Messages.PLANACTION_VMS_MIGRATING, host.Name))
 {
     base.TitlePlan = string.Format(Messages.MIGRATE_VMS_OFF_SERVER, host.Name);
     this._host = new XenRef<Host>(host);
     currentHost = host;
 }
开发者ID:huizh,项目名称:xenadmin,代码行数:7,代码来源:EvacuateHostPlanAction.cs


示例3: BringBabiesBackAction

 public BringBabiesBackAction(List<XenRef<VM>> vms, Host host,bool enableOnly)
     : base(host.Connection, string.Format(Messages.UPDATES_WIZARD_EXITING_MAINTENANCE_MODE,host.Name))
 {
     base.TitlePlan = string.Format(Messages.EXIT_SERVER_FROM_MAINTENANCE_MODE,host.Name);
     this._host = new XenRef<Host>(host);
     this._vms = vms;
     this._enableOnly = enableOnly;
     currentHost = host;
 }
开发者ID:ChrisH4rding,项目名称:xenadmin,代码行数:9,代码来源:BringBabiesBackAction.cs


示例4: MeddlingAction

 public MeddlingAction(Task task)
     : base(ActionType.Meddling, task.MeddlingActionTitle ?? task.Title, task.Description, false, false)
 {
     RelatedTask = new XenRef<Task>(task.opaque_ref);
     Started = (task.created + task.Connection.ServerTimeOffset).ToLocalTime();
     SetAppliesToData(task);
     VM = VMFromAppliesTo(task);
     Connection = task.Connection;
     Update(task, false);
 }
开发者ID:ChrisH4rding,项目名称:xenadmin,代码行数:10,代码来源:MeddlingAction.cs


示例5: Run

 protected override void Run()
 {
     Description = string.Format(Messages.CREATING_VM_APPLIANCE, _record.Name);
     RelatedTask = VM_appliance.async_create(Session, _record);
     PollToCompletion();
     var vmApplianceRef = new XenRef<VM_appliance>(Result);
     Connection.WaitForCache(vmApplianceRef);
     foreach (var selectedVM in _vms)
     {
         VM.set_appliance(Session, selectedVM.opaque_ref, vmApplianceRef.opaque_ref);
     }
     Description = string.Format(Messages.CREATED_VM_APPLIANCE, _record.Name);
     PercentComplete = 100;
 }
开发者ID:huizh,项目名称:xenadmin,代码行数:14,代码来源:CreateVMApplianceAction.cs


示例6: MeddlingAction

        public MeddlingAction(Task task)
            : base(task.MeddlingActionTitle ?? task.Title, task.Description, false, false)
        {
            RelatedTask = new XenRef<Task>(task.opaque_ref);

            this.Host = task.Connection.Resolve(task.resident_on);

            if (this.Host == null)
                this.Host = Helpers.GetMaster(task.Connection);

            Started = (task.created + task.Connection.ServerTimeOffset).ToLocalTime();
            SetAppliesToData(task);
            VM = VMFromAppliesTo(task);
            Connection = task.Connection;
            Update(task, false);
        }
开发者ID:robhoes,项目名称:xenadmin,代码行数:16,代码来源:MeddlingAction.cs


示例7: Run

 protected override void Run()
 {
     Description = string.Format(Messages.CREATING_VMPP, _record.Name);
     RelatedTask = VMPP.async_create(Session, _record);
     PollToCompletion();
     var vmppref = new XenRef<VMPP>(Result);
     Connection.WaitForCache(vmppref);
     foreach (var selectedVM in _vms)
     {
         VM.set_protection_policy(Session, selectedVM.opaque_ref, vmppref.opaque_ref);
     }
     Description = string.Format(Messages.CREATED_VMPP, _record.Name);
     PercentComplete = 60;
     if (_runNow)
         VMPP.protect_now(Session, vmppref);
     PercentComplete = 100;
 }
开发者ID:huizh,项目名称:xenadmin,代码行数:17,代码来源:CreateVMPP.cs


示例8: LoadPoolMetadata

        private void LoadPoolMetadata(VDI vdi)
        {
            Session metadataSession = null;
            try
            {
                VdiLoadMetadataAction action = new VdiLoadMetadataAction(Connection, vdi);
                ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee);
                dialog.ShowDialog(this); //Will block until dialog closes, action completed

                if (action.Succeeded && action.MetadataSession != null)
                {
                    metadataSession = action.MetadataSession;
                    XenRef<VDI> vdiRef = new XenRef<VDI>(vdi);
                    if (action.PoolMetadata != null && !allPoolMetadata.ContainsKey(vdiRef))
                    {
                        allPoolMetadata.Add(vdiRef, action.PoolMetadata);
                    }
                }

            }
            finally
            {
                if (metadataSession != null)
                    metadataSession.logout();
            }
        }
开发者ID:huizh,项目名称:xenadmin,代码行数:26,代码来源:DRFailoverWizardStoragePage.cs


示例9: PollTaskForResult

        private static String PollTaskForResult(IXenConnection connection, ref Session session,
            HTTP.FuncBool cancellingDelegate, XenRef<Task> task)
        {
            //Program.AssertOffEventThread();

            task_status_type status;

            do
            {
                if (cancellingDelegate != null && cancellingDelegate())
                    throw new XenAdmin.CancelledException();

                System.Threading.Thread.Sleep(500);

                status = (task_status_type)Task.DoWithSessionRetry(connection, ref session,
                    (Task.TaskStatusOp)Task.get_status, task.opaque_ref);
            }
            while (status == task_status_type.pending || status == task_status_type.cancelling);

            if (cancellingDelegate != null && cancellingDelegate())
                throw new XenAdmin.CancelledException();

            if (status == task_status_type.failure)
            {
                throw new Failure(Task.get_error_info(session, task));
            }
            else
            {
                return Task.get_result(session, task);
            }
        }
开发者ID:ChrisH4rding,项目名称:xenadmin,代码行数:31,代码来源:HTTPHelper.cs


示例10: Run

        protected override void Run()
        {
            log.Debug("Running SR Reconfigure Action");
            log.DebugFormat("SR uuid = '{0}'", sr.uuid);
            log.DebugFormat("name = '{0}'", name);
            log.DebugFormat("description = '{0}'", description);

            Description = Messages.ACTION_SR_ATTACHING;

            // Repair the SR with new PBDs for each host in the pool
            PBD pbdTemplate = new PBD();
            pbdTemplate.currently_attached = false;
            pbdTemplate.device_config = dconf;
            pbdTemplate.SR = new XenRef<SR>(sr.opaque_ref);

            int delta = 100 / (Connection.Cache.HostCount * 2);
            foreach (Host host in Connection.Cache.Hosts)
            {
                // Create the PBD
                log.DebugFormat("Creating PBD for host {0}", host.Name);
                this.Description = String.Format(Messages.ACTION_SR_REPAIR_CREATE_PBD, Helpers.GetName(host));
                pbdTemplate.host = new XenRef<Host>(host.opaque_ref);
                RelatedTask = PBD.async_create(this.Session, pbdTemplate);
                PollToCompletion(PercentComplete, PercentComplete + delta);
                XenRef<PBD> pbdRef = new XenRef<PBD>(this.Result);

                // Now plug the PBD
                log.DebugFormat("Plugging PBD for host {0}", host.Name);
                this.Description = String.Format(Messages.ACTION_SR_REPAIR_PLUGGING_PBD, Helpers.GetName(host));
                RelatedTask = PBD.async_plug(this.Session, pbdRef);
                PollToCompletion(PercentComplete, PercentComplete + delta);
            }

            // Update the name and description of the SR
            XenAPI.SR.set_name_label(Session, sr.opaque_ref, name);
            XenAPI.SR.set_name_description(Session, sr.opaque_ref, description);

            Description = Messages.ACTION_SR_ATTACH_SUCCESSFUL;
        }
开发者ID:ushamandya,项目名称:xenadmin,代码行数:39,代码来源:SrReattachAction.cs


示例11: Process

        public void Process(Session xenSession, EnvelopeType ovfObj, string pathToOvf, string passcode)
        {
            if (xenSession == null)
                throw new InvalidOperationException(Messages.ERROR_NOT_CONNECTED);

            string ovfname = Guid.NewGuid().ToString();

            vifDeviceIndex = 0;
            string encryptionVersion = null;

            #region CHECK ENCRYPTION
            if (OVF.HasEncryption(ovfObj))
            {
                if (passcode == null)
                {
                    throw new InvalidDataException(Messages.ERROR_NO_PASSWORD);
                }
                string fileuuids = null;
                SecuritySection_Type[] securitysection = OVF.FindSections<SecuritySection_Type>((ovfObj).Sections);
                if (securitysection != null && securitysection.Length >= 0)
                {
                    foreach (Security_Type securitytype in securitysection[0].Security)
                    {
                        if (securitytype.ReferenceList.Items != null && securitytype.ReferenceList.Items.Length > 0)
                        {
                            foreach (XenOvf.Definitions.XENC.ReferenceType dataref in securitytype.ReferenceList.Items)
                            {
                                if (dataref is DataReference)
                                {
                                    fileuuids += ":" + ((DataReference)dataref).ValueType;
                                }
                            }
                        }
                        if (securitytype.EncryptionMethod != null && securitytype.EncryptionMethod.Algorithm != null)
                        {
                            string algoname = (securitytype.EncryptionMethod.Algorithm.Split(new char[] { '#' }))[1].ToLower().Replace('-', '_');
                            object x = OVF.AlgorithmMap(algoname);
                            if (x != null)
                            {
                                EncryptionClass = (string)x;
                                EncryptionKeySize = Convert.ToInt32(securitytype.EncryptionMethod.KeySize);
                            }
                        }

                        if (!string.IsNullOrEmpty(securitytype.version))
                        {
                            encryptionVersion = securitytype.version;
                        }
                    }
                }
            }
            #endregion

            #region FIND DEFAULT SR
            Dictionary<XenRef<Pool>, Pool> pools = Pool.get_all_records(xenSession);
            foreach (XenRef<Pool> pool in pools.Keys)
            {
                DefaultSRUUID = pools[pool].default_SR;
                break;
            }
            #endregion

            //
            // So the process is the same below, change this
            //
            if (ovfObj.Item is VirtualSystem_Type)
            {
                VirtualSystem_Type vstemp = (VirtualSystem_Type)ovfObj.Item;
                ovfObj.Item = new VirtualSystemCollection_Type();
                ((VirtualSystemCollection_Type)ovfObj.Item).Content = new Content_Type[] { vstemp };
            }

            #region Create appliance

            XenRef<VM_appliance> applRef = null;
            if (ApplianceName != null)
            {
                var vmAppliance = new VM_appliance {name_label = ApplianceName, Connection = xenSession.Connection};
                applRef = VM_appliance.create(xenSession, vmAppliance);
            }

            #endregion

            foreach (VirtualSystem_Type vSystem in ((VirtualSystemCollection_Type)ovfObj.Item).Content)
            {
               //FIND/SET THE NAME OF THE VM
                ovfname = OVF.FindSystemName(ovfObj, vSystem.id);
                auditLog.DebugFormat("Import: {0}, {1}", ovfname, pathToOvf);

                VirtualHardwareSection_Type vhs = OVF.FindVirtualHardwareSectionByAffinity(ovfObj, vSystem.id, "xen");

                XenRef<VM> vmRef = DefineSystem(xenSession, vhs, ovfname);
                if (vmRef == null)
                {
                    log.Error(Messages.ERROR_CREATE_VM_FAILED);
                    throw new ImportException(Messages.ERROR_CREATE_VM_FAILED);
                }

                HideSystem(xenSession, vmRef);
                log.DebugFormat("OVF.Import.Process: DefineSystem completed ({0})", VM.get_name_label(xenSession, vmRef));
//.........这里部分代码省略.........
开发者ID:ushamandya,项目名称:xenadmin,代码行数:101,代码来源:Import.cs


示例12: AddResourceSettingData

        private void AddResourceSettingData(Session xenSession, XenRef<VM> vmRef, RASD_Type rasd, string pathToOvf, string filename, string compression, string version, string passcode)
        {
            switch (rasd.ResourceType.Value)
            {
                case 3: // Processor: Already set in DefineSystem
                case 4: // Memory: Already set in DefineSystem
                case 5: // Internal Disk Controller of one type or another.
                case 6:
                case 7:
                case 8:
                case 9:
                    {
                        // For Xen really nothing to do here, does not support the different
                        // controller types, therefore we must ensure
                        // via positional on controllers.
                        // IDE - #1
                        // SCSI - #2
                        // IDE 0 Disk  0 Goes to Xen: userdevice=0
                        // IDE 0 Disk  1 Goes to Xen: userdevice=1
                        // IDE 1 Disk  0 Goes to Xen: userdevice=2
                        // IDE 1 CDDVD 1 Goes to Xen: userdevice=3
                        // SCSI 0 Disk 0 Goes to Xen: userdevice=4
                        // SCSI 0 Disk 1 Goes to Xen: userdevice=5
                        // and so forth.
                        break;
                    }
                case 10: // Network
                    {
                        XenRef<Network> net = null;
                        XenRef<Network> netDefault = null;
                        string netuuid = null;

                        #region SELECT NETWORK
                        Dictionary<XenRef<Network>, Network> networks = Network.get_all_records(xenSession);
                        if (rasd.Connection != null && rasd.Connection.Length > 0)
                        {
                            if (!string.IsNullOrEmpty(rasd.Connection[0].Value))
                            {
                                // Ignore the NetworkSection/Network
                                // During Network Selection the UUID for Network was set in Connection Field
                                // Makes data self contained here.

                                if (rasd.Connection[0].Value.Contains(Properties.Settings.Default.xenNetworkKey) ||
                                    rasd.Connection[0].Value.Contains(Properties.Settings.Default.xenNetworkUuidKey))
                                {
                                    string[] s = rasd.Connection[0].Value.Split(new char[] { ',' });
                                    for (int i = 0; i < s.Length; i++)
                                    {
                                        if (s[i].StartsWith(Properties.Settings.Default.xenNetworkKey) ||
                                            s[i].StartsWith(Properties.Settings.Default.xenNetworkUuidKey))
                                        {
                                            string[] s1 = s[i].Split(new char[] { '=' } );
                                            netuuid = s1[1];
                                        }
                                    }
                                }
                                foreach (XenRef<Network> netRef in networks.Keys)
                                {
                                    // if its a UUID and we find it... use it..
                                    if (net == null && netuuid != null &&
                                        netuuid.Equals(networks[netRef].uuid))
                                    {
                                        net = netRef;
                                    }
                                    // Ok second is to match it as a NAME_LABEL
                                    else if (net == null && netuuid != null &&
                                        networks[netRef].name_label.ToLower().Contains(netuuid))
                                    {
                                        net = netRef;
                                    }
                                    // hhmm neither... is it a BRIDGE name?
                                    else if (net == null && netuuid != null &&
                                        networks[netRef].bridge.ToLower().Contains(netuuid))
                                    {
                                        net = netRef;
                                    }
                                    // ok find the default.
                                    if (networks[netRef].bridge.ToLower().Contains(Properties.Settings.Default.xenDefaultNetwork))
                                    {
                                        netDefault = netRef;
                                    }
                                }
                                if (net == null)
                                {
                                    net = netDefault;
                                }
                            }
                        }
                        #endregion

                        #region ATTACH NETWORK TO VM
                        Hashtable vifHash = new Hashtable();
                        // This is MAC address if available use it.
                        // needs to be in form:  00:00:00:00:00:00
                        if (Tools.ValidateProperty("Address", rasd))
                        {
                            StringBuilder networkAddress = new StringBuilder();
                            if (!rasd.Address.Value.Contains(":"))
                            {
                                for (int i = 0; i < rasd.Address.Value.Length; i++)
//.........这里部分代码省略.........
开发者ID:ushamandya,项目名称:xenadmin,代码行数:101,代码来源:Import.cs


示例13: ShowSystem

 private void ShowSystem(Session xenSession, XenRef<VM> vmRef)
 {
     VM.remove_from_other_config(xenSession, vmRef, "HideFromXenCenter");
 }
开发者ID:ushamandya,项目名称:xenadmin,代码行数:4,代码来源:Import.cs


示例14: RemoveSystem

 private void RemoveSystem(Session xenSession, XenRef<VM> vm)
 {
     try
     {
         VM.destroy(xenSession, vm);
     }
     catch (Exception ex)
     {
         log.ErrorFormat("{0} {1}", Messages.ERROR_REMOVE_VM_FAILED, ex.Message);
         throw new Exception(Messages.ERROR_REMOVE_VM_FAILED, ex);
     }
     return;
 }
开发者ID:ushamandya,项目名称:xenadmin,代码行数:13,代码来源:Import.cs


示例15: HideSystem

 private void HideSystem(Session xenSession, XenRef<VM> vmRef)
 {
     VM.add_to_other_config(xenSession, vmRef, "HideFromXenCenter", "true");
 }
开发者ID:ushamandya,项目名称:xenadmin,代码行数:4,代码来源:Import.cs


示例16: ConfigureForXenServer

        private void ConfigureForXenServer(Session xenSession, XenRef<VM> vm)
        {
            // Ensure the new VM is down.
            if (VM.get_power_state(xenSession, vm) != vm_power_state.Halted)
                VM.hard_shutdown(xenSession, vm);

            while (VM.get_power_state(xenSession, vm) != vm_power_state.Halted)
                Thread.Sleep(Properties.Settings.Default.FixupPollTimeAsMs);

            // Save its original memory configuration.
            long staticMemoryMin  = VM.get_memory_static_min(xenSession, vm);
            long staticMemoryMax  = VM.get_memory_static_max(xenSession, vm);
            long dynamicMemoryMin = VM.get_memory_dynamic_min(xenSession, vm);
            long dynamicMemoryMax = VM.get_memory_dynamic_max(xenSession, vm);

            // Minimize the memory capacity for the fixup OS.
            long fixupMemorySize = Properties.Settings.Default.FixupOsMemorySizeAsMB * MB;

            VM.set_memory_limits(xenSession, vm, fixupMemorySize, fixupMemorySize, fixupMemorySize, fixupMemorySize);

            // Run the fixup OS on the VM.
            InstallSectionStartVirtualMachine(xenSession, vm, Properties.Settings.Default.FixupDurationAsSeconds);

            // Restore the original memory configuration.
            VM.set_memory_limits(xenSession, vm, staticMemoryMin, staticMemoryMax, dynamicMemoryMin, dynamicMemoryMax);

            // Eject the fixupOS CD.
            List<XenRef<VBD>> vbdList = VM.get_VBDs(xenSession, vm);
            foreach (XenRef<VBD> vbd in vbdList)
            {
                if (VBD.get_type(xenSession, vbd) == vbd_type.CD)
                    VBD.eject(xenSession, vbd);

                // Note that the original code did not destroy the VBD representing the CD drive.
            }

            // Restore the boot order.
            Dictionary<string, string> bootParameters = new Dictionary<string, string>();
            bootParameters.Add("order", "cnd");
            VM.set_HVM_boot_params(xenSession, vm, bootParameters);
        }
开发者ID:ushamandya,项目名称:xenadmin,代码行数:41,代码来源:Import.cs


示例17: SetupMocks

        private void SetupMocks(List<XenServerPatch> xenServerPatches, List<XenServerVersion> xenServerVersions)
        {
            Mock<Host>  master = mom.NewXenObject<Host>(id);
            Mock<Pool> pool = mom.NewXenObject<Pool>(id);
            XenRef<Host> masterRef = new XenRef<Host>("ref");
            pool.Setup(p => p.master).Returns(masterRef);
            mom.MockCacheFor(id).Setup(c => c.Resolve(It.IsAny<XenRef<Pool>>())).Returns(pool.Object);
            mom.MockConnectionFor(id).Setup(c => c.Resolve(masterRef)).Returns(master.Object);
            master.Setup(h => h.software_version).Returns(new Dictionary<string, string>());
            master.Setup(h => h.ProductVersion).Returns(ServerVersion);
            master.Setup(h => h.AppliedPatches()).Returns(GenerateMockPoolPatches(xenServerPatches));

            //Currently build number will be referenced first so if it's present hook it up
            string buildNumber = xenServerVersions.First(v => v.Version.ToString() == ServerVersion).BuildNumber;
            master.Setup(h=>h.BuildNumberRaw).Returns(buildNumber);
        }
开发者ID:ChrisH4rding,项目名称:xenadmin,代码行数:16,代码来源:CFUValidator.cs


示例18: HandleInstallSection

        private void HandleInstallSection(Session xenSession, XenRef<VM> vm, InstallSection_Type installsection)
        {
            // Configure for XenServer as requested by OVF.SetRunOnceBootCDROM() with the presence of a post install operation that is specific to XenServer.
            if (installsection.PostInstallOperations != null)
                ConfigureForXenServer(xenSession, vm);

            // Run the VM for the requested duration if this appliance had its own install section -- one not added to fixup for XenServer.
            if (((installsection.Info == null)) ||
                ((installsection.Info != null) && (installsection.Info.Value.CompareTo("ConfigureForXenServer") != 0)))
                InstallSectionStartVirtualMachine(xenSession, vm, installsection.initialBootStopDelay);
        }
开发者ID:ushamandya,项目名称:xenadmin,代码行数:11,代码来源:Import.cs


示例19: InstallSectionStartVirtualMachine

        private void InstallSectionStartVirtualMachine(Session xenSession, XenRef<VM> vm, int initialBootStopDelayAsSeconds)
        {
            // Start the VM.
            if (VM.get_power_state(xenSession, vm) != vm_power_state.Running)
                VM.start(xenSession, vm, false, true);

            // Finish early if requested to stop on its own.
            if (initialBootStopDelayAsSeconds == 0)
                return;

            // Wait for it to start.
            while (VM.get_power_state(xenSession, vm) != vm_power_state.Running)
                Thread.Sleep(Properties.Settings.Default.FixupPollTimeAsMs);

            // Let it run for the requested duration.
            int bootStopDelayAsMs = initialBootStopDelayAsSeconds * 1000;
            int msRunning = 0;

            while (VM.get_power_state(xenSession, vm) == vm_power_state.Running)
            {
                Thread.Sleep(Properties.Settings.Default.FixupPollTimeAsMs);
                msRunning += Properties.Settings.Default.FixupPollTimeAsMs;

                if (msRunning > bootStopDelayAsMs)
                    break;
            }

            // Ensure it is off.
            if (VM.get_power_state(xenSession, vm) != vm_power_state.Halted)
                VM.hard_shutdown(xenSession, vm);
        }
开发者ID:ushamandya,项目名称:xenadmin,代码行数:31,代码来源:Import.cs


示例20: Get

        public static String Get(HTTP.UpdateProgressDelegate progressDelegate, HTTP.FuncBool cancellingDelegate, bool timeout,
            HTTP.DataCopiedDelegate dataRxDelegate, IXenConnection connection, XenRef<Task> task, ref Session session, string path,
            string hostname, Delegate f, params object[] p)
        {
            log.DebugFormat("HTTP GETTING file from {0} to {1}", hostname, path);

            // Cannot use ref param in anonymous method, so save it here and restore it later
            Session _session = session;

            HTTP.DataCopiedDelegate dataCopiedDelegate = delegate(long bytes)
            {
                if (progressDelegate != null)
                {
                    int progress = (int)(100 * (double)Task.DoWithSessionRetry(connection, ref _session,
                        (Task.TaskProgressOp)Task.get_progress, task.opaque_ref));

                    progressDelegate(progress);
                }

                if (dataRxDelegate != null)
                    dataRxDelegate(bytes);
            };

            HTTP.FuncBool cancellingDelegate2 = (HTTP.FuncBool)delegate()
            {
                return (XenAdminConfigManager.Provider.ForcedExiting ||
                    cancellingDelegate != null && cancellingDelegate());
            };

            try
            {
                List<object> args = new List<object>();
                args.Add(dataCopiedDelegate);
                args.Add(cancellingDelegate2);
                args.Add(XenAdminConfigManager.Provider.GetProxyTimeout(timeout));
                args.Add(hostname);
                args.Add(XenAdminConfigManager.Provider.GetProxyFromSettings(connection));
                args.Add(path);
                args.Add(task.opaque_ref);  // task_id
                args.AddRange(p);
                f.DynamicInvoke(args.ToArray());
            }
            catch (Exception e)
            {
                log.DebugFormat("Caught exception doing HTTP GET from {0} to {1}", hostname, path);
                log.Debug(e, e);

                if (e is WebException && e.InnerException is IOException && Win32.GetHResult(e.InnerException as IOException) == Win32.ERROR_DISK_FULL)
                    throw e.InnerException;
                else if (e is CancelledException || e.InnerException is CancelledException)
                    throw new XenAdmin.CancelledException();
                else if (e.InnerException.Message == "Received error code HTTP/1.1 403 Forbidden\r\n from the server")
                {
                    // RBAC Failure
                    List<Role> roles = connection.Session.Roles;
                    roles.Sort();
                    throw new Exception(String.Format(Messages.RBAC_HTTP_FAILURE, roles[0].FriendlyName), e);
                }
                else
                    throw e.InnerException;
            }

            return PollTaskForResult(connection, ref session, cancellingDelegate2, task);
        }
开发者ID:robhoes,项目名称:xenadmin,代码行数:64,代码来源:HTTPHelper.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# XhtmlMobileTextWriter类代码示例发布时间:2022-05-24
下一篇:
C# XenAPI类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap