void import_ProgressUpdated(object sender, SPDeploymentEventArgs e) { if (ProgressUpdated != null) { ProgressUpdated(this, e); } }
void import_Completed(object sender, SPDeploymentEventArgs e) { if (Completed != null) { Completed(this, e); } }
/// <summary> /// Called when [site import started]. /// </summary> /// <param name="sender">The sender.</param> /// <param name="args">The <see cref="Microsoft.SharePoint.Deployment.SPDeploymentEventArgs"/> instance containing the event data.</param> private void OnSiteImportStarted(object sender, SPDeploymentEventArgs args) { SPImportObjectCollection rootObjects = args.RootObjects; if (rootObjects.Count != 0) { if (rootObjects.Count != 1) { for (int i = 0; i < rootObjects.Count; i++) { if (rootObjects[i].Type == SPDeploymentObjectType.Web) { rootObjects[i].TargetParentUrl = m_webParentUrl; rootObjects[i].TargetName = m_webName; return; } } } else { rootObjects[0].TargetParentUrl = m_webParentUrl; rootObjects[0].TargetName = m_webName; } } }
void import_Started(object sender, SPDeploymentEventArgs e) { if (Started != null) { Started(this, e); } }
void wizardDeployment_ProgressUpdated(object sender, SPDeploymentEventArgs e) { if (e.ObjectsTotal == -1) { // this condition indicates we are importing.. if (!f_quiet) { Console.WriteLine(string.Format("Imported {0} objects. Continuing..", e.ObjectsProcessed)); } } else { if (!f_quiet) { Console.WriteLine(string.Format("Exported {0} objects from a total of {1}. Continuing..", e.ObjectsProcessed, e.ObjectsTotal)); } } }
private void OnStarted(object sender, SPDeploymentEventArgs args) { SPImportObjectCollection rootObjects = args.RootObjects; if (rootObjects.Count != 0) { if (rootObjects.Count == 1) { if (rootObjects[0].Type == SPDeploymentObjectType.Web) { rootObjects[0].TargetParentUrl = this.m_webParentUrl; rootObjects[0].TargetName = this.m_webName; } else { rootObjects[0].TargetParentUrl = this.m_webParentUrl + this.m_webName; } } else { bool rootFound = false; for (int i = 0; i < rootObjects.Count; i++) { rootObjects[i].TargetParentUrl = this.m_webParentUrl; if (rootObjects[i].Type == SPDeploymentObjectType.Web) { if (rootFound) { throw new SPException(SPResource.GetString("ImportOperationMultipleRoots", new object[0])); } rootFound = true; rootObjects[i].TargetName = this.m_webName; return; } } } } }
/// <summary> /// Called when [site import started]. /// </summary> /// <param name="sender">The sender.</param> /// <param name="args">The <see cref="Microsoft.SharePoint.Deployment.SPDeploymentEventArgs"/> instance containing the event data.</param> private void OnSiteImportStarted(object sender, SPDeploymentEventArgs args) { SPImportObjectCollection rootObjects = args.RootObjects; if (rootObjects.Count != 0) { if (rootObjects.Count != 1) { for (int i = 0; i < rootObjects.Count; i++) { if (rootObjects[i].Type == SPDeploymentObjectType.Web) { rootObjects[i].TargetParentUrl = m_webParentUrl; rootObjects[i].TargetName = m_webName; return; } } } else { rootObjects[0].TargetParentUrl = m_webParentUrl; rootObjects[0].TargetName = m_webName; } } }
void wizardDeployment_ProgressUpdated(object sender, SPDeploymentEventArgs e) { if (e.ObjectsTotal == -1) { // this condition indicates we are importing.. if (!f_quiet) { Console.WriteLine(string.Format("Imported {0} objects. Continuing..", e.ObjectsProcessed)); } } else { if (!f_quiet) { Console.WriteLine(string.Format("Exported {0} objects from a total of {1}. Continuing..", e.ObjectsProcessed, e.ObjectsTotal)); } } }
private void setImportStarted(ProgressBar prgBar, SPDeploymentEventArgs e, object data) { if (prgBar.InvokeRequired) { if (f_traceSwitch.TraceInfo) { f_traceHelper.TraceInfo(string.Format("setImportStarted: Invoke was required on progress bar named '{0}', " + "about to invoke delegate.", prgBar.Name)); } // COB 21 Mar 2010 - introduced try/catch here for strange threading bug.. try { updateProgressOnDeployment delSetValue = new updateProgressOnDeployment(setImportStarted); this.Invoke(delSetValue, new object[] { prgBar, e, data }); } catch (Exception) { } } else { if (prgBar.Enabled == false) { if (f_traceSwitch.TraceInfo) { f_traceHelper.TraceInfo(string.Format("** setImportStarted: Progress bar named '{0}', " + "is currently disabled (indicating not yet been updated), about to enable and set Max Value to '{1}'.", prgBar.Name, e.ObjectsTotal)); } prgBar.Enabled = true; } if (f_traceSwitch.TraceInfo) { f_traceHelper.TraceInfo(string.Format("** setImportStarted: About to update progress bar named '{0}' " + "to value = '10' to indicate import started.", prgBar.Name)); } // patch by Alex Angas (@alexangas): Check if importing to list.. SPImportSettings importSettings = (SPImportSettings)data; string webUrl = Microsoft.SharePoint.Utilities.SPEncode.UrlDecodeAsUrl(importSettings.WebUrl); if (webUrl.EndsWith("/")) { webUrl = webUrl.Remove(webUrl.Length - 1, 1); } using (SPSite site = new SPSite(importSettings.SiteUrl)) using (SPWeb web = site.OpenWeb(webUrl)) { SPList importList = null; try { importList = web.GetList(webUrl); } catch (FileNotFoundException) { } if (importList != null) { // From Stefan Gossner: http://blogs.technet.com/stefan_gossner/archive/2007/08/30/deep-dive-into-the-sharepoint-content-deployment-and-migration-api-part-3.aspx SPImportObjectCollection rootObjects = e.RootObjects; foreach (SPImportObject io in rootObjects) { if (io.Type == SPDeploymentObjectType.ListItem) { io.TargetParentUrl = importList.RootFolder.ServerRelativeUrl; } if (io.Type == SPDeploymentObjectType.Folder) { io.TargetParentUrl = importList.RootFolder.ServerRelativeUrl; } if (io.Type == SPDeploymentObjectType.List) { io.TargetParentUrl = web.ServerRelativeUrl; } } importSettings.WebUrl = importList.ParentWebUrl; } } // end patch.. prgBar.Minimum = 0; // since ObjectsTotal value doesn't seem to get correctly updated by Content Deployment framework, // we'll leave at default of 100 of ObjectsTotal is still -1.. if (e.ObjectsTotal != -1) { prgBar.Maximum = e.ObjectsTotal; } prgBar.Value = 10; } }
void import_Completed(object sender, SPDeploymentEventArgs e) { if (Completed != null) { Completed(this, e); } }
void import_ProgressUpdated(object sender, SPDeploymentEventArgs e) { if (ProgressUpdated != null) { ProgressUpdated(this, e); } }
void import_Started(object sender, SPDeploymentEventArgs e) { if (Started != null) { Started(this, e); } }
private void setProgress(ProgressBar prgBar, SPDeploymentEventArgs e, object data) { if (f_traceSwitch.TraceVerbose) { f_traceHelper.TraceVerbose(string.Format("setProgress: Entered setProgress with progress bar named '{0}', " + "items processed '{1}'. Thread ID is '{2}'.", prgBar.Name, e.ObjectsProcessed, Thread.CurrentThread.ManagedThreadId)); } if (prgBar.InvokeRequired) { if (f_traceSwitch.TraceInfo) { f_traceHelper.TraceInfo(string.Format("setProgress: Invoke was required on progress bar named '{0}', " + "about to invoke delegate.", prgBar.Name)); } updateProgressOnDeployment delSetValue = new updateProgressOnDeployment(setProgress); this.Invoke(delSetValue, new object[] { prgBar, e, data }); } else { if (prgBar.Enabled == false) { if (f_traceSwitch.TraceInfo) { f_traceHelper.TraceInfo(string.Format("setProgress: Progress bar named '{0}', " + "is currently disabled (indicating not yet been updated), about to enable and set Max Value to '{1}'.", prgBar.Name, e.ObjectsTotal)); } prgBar.Enabled = true; prgBar.Visible = true; prgBar.Minimum = 0; // since ObjectsTotal value doesn't seem to get correctly updated by Content Deployment framework, // we'll leave at default of 100 if ObjectsTotal is still -1.. if (e.ObjectsTotal != -1) { prgBar.Maximum = e.ObjectsTotal; } if (e.ObjectsTotal < prgBar.Step) { prgBar.Step = Convert.ToInt32(e.ObjectsTotal / 10); } } // if progress updated event has fired but ObjectsProcessed count is still 0, // move the progress bar one step otherwise looks like jobs has failed to start properly.. if (e.ObjectsProcessed == 0) { prgBar.Value = prgBar.Step; } else { // since ObjectsTotal value doesn't seem to get correctly updated by Content Deployment framework, // we'll leave at default of 100 of ObjectsTotal is still -1.. if (e.ObjectsTotal != -1) { prgBar.Maximum = e.ObjectsTotal; } /* also need to increase maximum value of ProgressBar here if we've gone past default of 100.. * this happens because the Microsoft API has a bug where ObjectsTotal is -1 for imports.. */ if (e.ObjectsProcessed > prgBar.Maximum) { prgBar.Maximum = e.ObjectsProcessed; } int iCheck = e.RootObjects.Count; prgBar.Value = e.ObjectsProcessed; } if (f_traceSwitch.TraceInfo) { f_traceHelper.TraceInfo(string.Format("setProgress: Updated value on progress bar named '{0}', " + "to '{1}'.", prgBar.Name, e.ObjectsProcessed)); } } if (f_traceSwitch.TraceVerbose) { f_traceHelper.TraceVerbose("setProgress: Exiting setProgress."); } }
void export_Completed(object sender, SPDeploymentEventArgs e) { setOperationCompleted(prgExport, this.wizardControl1); }
void export_ProgressUpdated(object sender, SPDeploymentEventArgs e) { if (f_traceSwitch.TraceVerbose) { f_traceHelper.TraceVerbose("export_ProgressUpdated: Entered ProgressUpdated event handler."); } setProgress(prgExport, e, null); if (f_traceSwitch.TraceVerbose) { f_traceHelper.TraceVerbose("export_ProgressUpdated: Exiting ProgressUpdated event handler."); } }
private void OnStarted(object sender, SPDeploymentEventArgs args) { SPImportObjectCollection rootObjects = args.RootObjects; if (rootObjects.Count != 0) { if (rootObjects.Count == 1) { if (rootObjects[0].Type == SPDeploymentObjectType.Web) { rootObjects[0].TargetParentUrl = this.m_webParentUrl; rootObjects[0].TargetName = this.m_webName; } else { rootObjects[0].TargetParentUrl = this.m_webParentUrl + this.m_webName; } } else { bool rootFound = false; for (int i = 0; i < rootObjects.Count; i++) { rootObjects[i].TargetParentUrl = this.m_webParentUrl; if (rootObjects[i].Type == SPDeploymentObjectType.Web) { if (rootFound) { throw new SPException(SPResource.GetString("ImportOperationMultipleRoots", new object[0])); } rootFound = true; rootObjects[i].TargetName = this.m_webName; return; } } } } }
void import_Started(object sender, SPDeploymentEventArgs e) { setImportStarted(prgImport, e, ((WizardDeployment)sender).ImportSettings); }