public override bool Export(PwExportInfo pwExportInfo, Stream sOutput,
                                    IStatusLogger slLogger)
        {
            PwDatabase pd = (pwExportInfo.ContextDatabase ?? new PwDatabase());

            PwObjectList <PwDeletedObject> vDel = null;

            if (pwExportInfo.ExportDeletedObjects == false)
            {
                vDel = pd.DeletedObjects.CloneShallow();
                pd.DeletedObjects.Clear();
            }

            Kdb4File kdb = new Kdb4File(pd);

            kdb.Save(sOutput, pwExportInfo.DataGroup, Kdb4Format.PlainXml, slLogger);

            // Restore deleted objects list
            if (vDel != null)
            {
                pd.DeletedObjects.Add(vDel);
            }

            return(true);
        }
Beispiel #2
0
        public override bool Export(PwExportInfo pwExportInfo, Stream sOutput,
                                    IStatusLogger slLogger)
        {
            Kdb4File kdb4 = new Kdb4File(pwExportInfo.ContextDatabase);

            kdb4.Save(sOutput, pwExportInfo.DataGroup, Kdb4Format.Default, slLogger);
            return(true);
        }
Beispiel #3
0
        public override bool Export(PwExportInfo pwExportInfo, Stream sOutput,
                                    IStatusLogger slLogger)
        {
            string         strFilter = UIUtil.CreateFileTypeFilter("xsl", KPRes.XslFileType, true);
            OpenFileDialog dlgXsl    = UIUtil.CreateOpenFileDialog(KPRes.XslSelectFile,
                                                                   strFilter, 1, "xsl", false, false);

            if (dlgXsl.ShowDialog() != DialogResult.OK)
            {
                return(false);
            }

            string strXslFile        = dlgXsl.FileName;
            XslCompiledTransform xsl = new XslCompiledTransform();

            try { xsl.Load(strXslFile); }
            catch (Exception exXsl)
            {
                throw new NotSupportedException(strXslFile + MessageService.NewParagraph +
                                                KPRes.NoXslFile + MessageService.NewParagraph + exXsl.Message);
            }

            MemoryStream msDataXml = new MemoryStream();

            PwDatabase pd  = (pwExportInfo.ContextDatabase ?? new PwDatabase());
            Kdb4File   kdb = new Kdb4File(pd);

            kdb.Save(msDataXml, pwExportInfo.DataGroup, Kdb4Format.PlainXml, slLogger);

            byte[] pbData = msDataXml.ToArray();
            msDataXml.Close();
            MemoryStream msDataRead    = new MemoryStream(pbData, false);
            XmlReader    xmlDataReader = XmlReader.Create(msDataRead);

            XmlWriterSettings xws = new XmlWriterSettings();

            xws.CheckCharacters    = false;
            xws.Encoding           = new UTF8Encoding(false);
            xws.NewLineChars       = MessageService.NewLine;
            xws.NewLineHandling    = NewLineHandling.None;
            xws.OmitXmlDeclaration = true;
            xws.ConformanceLevel   = ConformanceLevel.Auto;

            XmlWriter xmlWriter = XmlWriter.Create(sOutput, xws);

            xsl.Transform(xmlDataReader, xmlWriter);
            xmlWriter.Close();
            xmlDataReader.Close();
            msDataRead.Close();

            Array.Clear(pbData, 0, pbData.Length);
            return(true);
        }
Beispiel #4
0
        /// <summary>
        /// Save the currently opened database. The file is written to the location
        /// it has been opened from.
        /// </summary>
        /// <param name="slLogger">Logger that recieves status information.</param>
        public void Save(IStatusLogger slLogger)
        {
            bool bMadeUnhidden = UrlUtil.UnhideFile(m_ioSource.Path);

            Stream s = IOConnection.OpenWrite(m_ioSource);

            Kdb4File kdb = new Kdb4File(this);

            kdb.Save(s, null, Kdb4Format.Default, slLogger);

            if (bMadeUnhidden)
            {
                UrlUtil.HideFile(m_ioSource.Path, true);                           // Hide again
            }
            m_pbHashOfLastIO     = kdb.HashOfFileOnDisk;
            m_pbHashOfFileOnDisk = kdb.HashOfFileOnDisk;
            Debug.Assert(m_pbHashOfFileOnDisk != null);

            m_bModified = false;
        }
		/// <summary>
		/// Save the currently opened database. The file is written to the location
		/// it has been opened from.
		/// </summary>
		/// <param name="slLogger">Logger that recieves status information.</param>
		public void Save(IStatusLogger slLogger)
		{
			Debug.Assert(ValidateUuidUniqueness());

			// bool bMadeUnhidden = UrlUtil.UnhideFile(m_ioSource.Path);
			// Stream s = IOConnection.OpenWrite(m_ioSource);

			FileTransactionEx ft = new FileTransactionEx(m_ioSource, m_bUseFileTransactions);
			Stream s = ft.OpenWrite();

			Kdb4File kdb = new Kdb4File(this);
			kdb.Save(s, null, Kdb4Format.Default, slLogger);

			ft.CommitWrite();

			// if(bMadeUnhidden) UrlUtil.HideFile(m_ioSource.Path, true); // Hide again

			m_pbHashOfLastIO = kdb.HashOfFileOnDisk;
			m_pbHashOfFileOnDisk = kdb.HashOfFileOnDisk;
			Debug.Assert(m_pbHashOfFileOnDisk != null);

			m_bModified = false;
		}