/// <summary> /// Serializes the DTS package as an XML file. /// </summary> /// <param name="oPackage">The DTS package object.</param> /// <param name="filename">The XML doc filename.</param> private static void SerializePackageAsXMLFile(DTSPackage2 oPackage, string filename) { try { if (!ErrorFlag && debugflag) { DialogResult retval = MessageBox.Show("Save DTS Package: " + oPackage.Name + " as XML file: " + filename, "DEBUG HELP", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (retval == DialogResult.Yes) { oPackage.Save(filename); } } else { oPackage.Save(filename); } } catch(Exception ex) { if (!ErrorFlag) { logger.Error("XML Serializer Error is: " + ex.Message); //MessageBox.Show("XML Serializer Error is: " + ex.Message, "SERIALIZER ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
/// <summary> /// Loads the DTS package from DTS structured storage file into the DTS Package object class. /// </summary> /// <param name="oPackage">The DTS package object.</param> /// <param name="DTSfileName">Name of the DTS file.</param> /// <param name="XMLFileName">Name of the XML doc file.</param> /// <param name="encryptPass">The DTS encrypt password.</param> /// <param name="packageGUID">The DTS package GUID.</param> /// <param name="versionGUID">The DTS version GUID.</param> private static void LoadPackageFromDTSFile(DTSPackage2 oPackage, string DTSfileName, string XMLFileName, string encryptPass, string packageGUID, string versionGUID) { try { if (!ErrorFlag && debugflag) { DialogResult retval = MessageBox.Show("Convert DTS File: [" + DTSfileName + "] to the XML File: [" + XMLFileName + "]?", "DEBUG HELP", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (retval == DialogResult.Yes) { // read DTS file oPackage.Load(DTSfileName, encryptPass, packageGUID, versionGUID); // save package to XML file oPackage.Save(XMLFileName); if (!ErrorFlag && debugflag) { logger.Debug("Successfully converted DTS Package: " + oPackage.Name + ", from the DTS file: " + DTSfileName + "] to the XML File: [" + XMLFileName + "]"); //MessageBox.Show("Successfully converted DTS Package: " + oPackage.Name + ", from the DTS file: " + DTSfileName + "] to the XML File: [" + XMLFileName + "]", "DEBUG HELP", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } else { // read DTS file oPackage.Load(DTSfileName, encryptPass, packageGUID, versionGUID); // save package to XML file oPackage.Save(XMLFileName); } } catch(Exception ex) { if (!ErrorFlag) { logger.Error("Package conversion error: " + ex.Message); //MessageBox.Show("Package conversion error: " + ex.Message, "PACKAGE ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
/// <summary> /// Loads the DTS package from SQL server into the DTS Package object class. /// </summary> /// <param name="oPackage">The DTS package object.</param> /// <param name="encryptPass">The DTS encrypt password.</param> /// <param name="packGUID">The DTS packackage GUID.</param> /// <param name="verGUID">The DTS version GUID.</param> private static void LoadPackageFromSQLServer(DTSPackage2 oPackage, string encryptPass, string packGUID, string verGUID) { try { oPackage.Load(gsComputername, vuser, vpass, encryptPass, packGUID, verGUID); if (!ErrorFlag && debugflag) { logger.Debug("Loaded DTS Package: " + oPackage.Name); //MessageBox.Show("Loaded DTS Package: " + oPackage.Name, "DEBUG HELP", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch(Exception ex) { if (!ErrorFlag) { logger.Error("Package load error: " + ex.Message); //MessageBox.Show("Package load error: " + ex.Message, "PACKAGE ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
/// <summary> /// Loads the DTS package from DTS structured storage file into the DTS Package object class. /// </summary> /// <param name="oPackage">The DTS package object.</param> /// <param name="fileName">Name of the DTS structured storage file.</param> /// <param name="encryptPass">The encrypt password.</param> /// <param name="packageGUID">The DTS package GUID.</param> /// <param name="versionGUID">The DTS version GUID.</param> private static void LoadPackageFromDTSFile(DTSPackage2 oPackage, string fileName, string encryptPass, string packageGUID, string versionGUID) { try { if (!ErrorFlag && debugflag) { DialogResult retval = MessageBox.Show("Load DTS File: [" + fileName + "] to the SQL server: [" + gsComputername + "]?", "DEBUG HELP", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (retval == DialogResult.Yes) { // read DTS file oPackage.Load(fileName, encryptPass, packageGUID, versionGUID); // save package to SQL server oPackage.Save(gsComputername, vuser, vpass, encryptPass); if (!ErrorFlag && debugflag) { logger.Debug("Loaded DTS Package: " + oPackage.Name + ", from the DTS file: " + fileName); //MessageBox.Show("Loaded DTS Package: " + oPackage.Name + ", from the DTS file: " + fileName, "DEBUG HELP", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } else { // read DTS file oPackage.Load(fileName, encryptPass, packageGUID, versionGUID); // save package to SQL server oPackage.Save(gsComputername, vuser, vpass, encryptPass); } } catch(Exception ex) { if (!ErrorFlag) { logger.Error("Package load error: " + ex.Message); //MessageBox.Show("Package load error: " + ex.Message, "PACKAGE ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
/// <summary> /// Removes the DTS package from SQL server. /// </summary> /// <param name="oPackage">The DTS package object.</param> /// <param name="packGUID">The DTS package GUID.</param> /// <param name="verGUID">The DTS version GUID.</param> private static void RemovePackageFromSQLServer(DTSPackage2 oPackage, string packGUID, string verGUID) { try { if (!ErrorFlag && debugflag) { string msgstr = null; if (packGUID != null && verGUID != null) { msgstr = "Remove all versions of the DTS Package: "; } else { msgstr = "Remove version " + verGUID + " of the DTS Package: "; } DialogResult retval = MessageBox.Show("Remove DTS Package: " + oPackage.Name , "DEBUG HELP", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (retval == DialogResult.Yes) { oPackage.Remove(gsComputername, vuser, vpass, packGUID, verGUID); } } else { oPackage.Remove(gsComputername, vuser, vpass, packGUID, verGUID); } } catch(Exception ex) { if (!ErrorFlag) { logger.Error("Package remove error: " + ex.Message); //MessageBox.Show("Package remove error: " + ex.Message, "PACKAGE ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
/// <summary> /// Initializes the DTS package. /// </summary> /// <param name="name">The DTS package name.</param> /// <param name="logfile">The DTS logfile name.</param> /// <param name="description">The DTS package description.</param> /// <returns></returns> private static DTSPackage2 InitializeDTSPackage(string name, string logfile, string description) { DTSPackage2 oPackage = null; try { oPackage = new DTSPackage2(name, logfile, description); } catch(Exception ex) { if (!ErrorFlag) { logger.Error("Package Error is:" + ex.Message); //MessageBox.Show("Package Error is:" + ex.Message, "PACKAGE ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } return oPackage; }
private void SerializePackageAsXML(string PackageName, string LogFileName, string Description, string packGUID, string verGUID) { Cursor.Current = Cursors.WaitCursor; try { DTSPackage2 oPackage = new DTSPackage2(PackageName, LogFileName, Description); // set the DTS package authentication type if (_UID != null && _PWD != null) { oPackage.Authentication = DTSPackage2.authTypeFlags.Default; } else { oPackage.Authentication = DTSPackage2.authTypeFlags.Trusted; } string SQLserver = this.TabText; // load the package from SQL server into the persisted object oPackage.Load(SQLserver, _UID, _PWD, null, packGUID, verGUID); m_DialogTitle = "Save DTS XML Package File as..."; m_DialogTypeFilter = "XML files (*.xml)|*.xml|All files (*.*)|*.*"; ArrayList arl = ShowSaveFileDialog(PackageName, m_DialogTitle, m_DialogTypeFilter); DialogResult dr = (DialogResult)arl[0]; if (dr == DialogResult.OK) { // save package from persisted object onto the HD as a file FileName = (string)arl[1]; // TODO: may want to do this async for bigger DTS packages oPackage.Save(FileName); // show xml XMLDoc xmlDoc = new XMLDoc(); xmlDoc.RightToLeftLayout = RightToLeftLayout; FileInfo fi = new FileInfo(FileName); xmlDoc.TabText = fi.Name; xmlDoc.Text = fi.Name; xmlDoc.ToolTipText = fi.Name; xmlDoc.FileName = FileName; xmlDoc.Show(this.DockPanel); } } catch(Exception ex) { Cursor.Current = Cursors.Default; MessageBox.Show("XML Serializer Error is: " + ex.Message, "SERIALIZER ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { Cursor.Current = Cursors.Default; } }
public void ReHydrateDTS(string[] servers) { if (IsDTSPackage) { string PackageName = null; string Logfile = null; string PackageDescription = null; string _UID = null; string _PWD = null; string _SQLServer = null; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(txtEditCtl.Text); XmlNodeList xNodeList = xmlDoc.SelectNodes("/DTS_File/Package/Name"); PackageName = xNodeList.Count > 0 ? ((XmlNode)xNodeList.Item(0)).InnerText : ""; xNodeList = xmlDoc.SelectNodes("/DTS_File/Package/Description"); PackageDescription = xNodeList.Count > 0 ? ((XmlNode)xNodeList.Item(0)).InnerText : ""; xNodeList = xmlDoc.SelectNodes("/DTS_File/Package/LogFileName"); Logfile = xNodeList.Count > 0 ? ((XmlNode)xNodeList.Item(0)).InnerText : ""; xNodeList = null; xmlDoc = null; // create new DTS package object in memory DTSPackage2 oPackage = new DTSPackage2(PackageName, Logfile, PackageDescription); SQLSecuritySettings sss = new SQLSecuritySettings(servers); if (servers != null && servers.Length > 0) { sss.SetServerName(servers[0]); } DialogResult dr = sss.ShowDialog(this); if (dr == DialogResult.OK) { try { _UID = sss.User; _PWD = sss.PWD; _SQLServer = sss.SelectedSQLServer; // set up the DTS package authentication type if (sss.SecurityMode() == Lewis.SST.SQLMethods.SecurityType.Mixed) { oPackage.Authentication = DTSPackage2.authTypeFlags.Default; } else { oPackage.Authentication = DTSPackage2.authTypeFlags.Trusted; } // TODO: make this an async operation for larger dts files Cursor.Current = Cursors.WaitCursor; oPackage.Load(FileName); oPackage.Save(_SQLServer, _UID, _PWD, null); } catch (Exception ex) { Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message); } finally { oPackage = null; Cursor.Current = Cursors.Default; } } } }