public string bundleUpload(IXenConnection connection, Session session, string uploadToken, System.Threading.CancellationToken cancel)
        {
            // Collect the server status report and generate zip file to upload.
            XenServerHealthCheckBugTool bugTool = new XenServerHealthCheckBugTool();
            try
            {
                bugTool.RunBugtool(connection, session);
            }
            catch (Exception e)
            {
                if (session != null)
                    session.logout();
                session = null;
                log.Error(e, e);
                return "";
            }

            string bundleToUpload = bugTool.outputFile;
            if(string.IsNullOrEmpty(bundleToUpload) || !File.Exists(bundleToUpload))
            {
                log.ErrorFormat("Server Status Report is NOT collected");
                return "";
            }

            // Upload the zip file to CIS uploading server.
            string upload_url = Registry.HealthCheckUploadDomainName;
            log.InfoFormat("Upload report to {0}", upload_url);
            XenServerHealthCheckUpload upload = new XenServerHealthCheckUpload(uploadToken, VERBOSITY_LEVEL, upload_url, connection);

            string upload_uuid = "";
            try
            {
                upload_uuid = upload.UploadZip(bundleToUpload, null, cancel);
            }
            catch (Exception e)
            {
                if (session != null)
                    session.logout();
                session = null;
                log.Error(e, e);
                return "";
            }

            if (File.Exists(bundleToUpload))
                File.Delete(bundleToUpload);

            // Return the uuid of upload.
            if(string.IsNullOrEmpty(upload_uuid))
            {
                // Fail to upload the zip to CIS server.
                log.ErrorFormat("Fail to upload the Server Status Report {0} to CIS server", bundleToUpload);
                return "";
            }

            return upload_uuid;
        }
        public string bundleUpload(IXenConnection connection, Session session, string uploadToken, System.Threading.CancellationToken cancel)
        {
            // Collect the server status report and generate zip file to upload.
            XenServerHealthCheckBugTool bugTool = new XenServerHealthCheckBugTool();

            try
            {
                bugTool.RunBugtool(connection, session);
            }
            catch (Exception e)
            {
                if (session != null)
                {
                    session.logout();
                }
                session = null;
                log.Error(e, e);
                return("");
            }

            string bundleToUpload = bugTool.outputFile;

            if (string.IsNullOrEmpty(bundleToUpload) || !File.Exists(bundleToUpload))
            {
                log.ErrorFormat("Server Status Report is NOT collected");
                return("");
            }

            // Upload the zip file to CIS uploading server.
            XenServerHealthCheckUpload upload = new XenServerHealthCheckUpload(uploadToken, VERBOSITY_LEVEL,
                                                                               Properties.Settings.Default.UPLOAD_URL);
            string upload_uuid = upload.UploadZip(bundleToUpload, cancel);

            if (File.Exists(bundleToUpload))
            {
                File.Delete(bundleToUpload);
            }

            // Return the uuid of upload.
            if (string.IsNullOrEmpty(upload_uuid))
            {
                // Fail to upload the zip to CIS server.
                log.ErrorFormat("Fail to upload the Server Status Report {0} to CIS server", bundleToUpload);
                return("");
            }

            return(upload_uuid);
        }