/// <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);
         }
     }
 }
Beispiel #2
0
        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;
            }
        }
 /// <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 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);
         }
     }
 }
Beispiel #5
0
        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;
                    }
                }
            }
        }