Beispiel #1
0
        private void ImportXML(string fileName)
        {
            System.Xml.Serialization.XmlSerializer mySerializer = new System.Xml.Serialization.XmlSerializer(typeof(TemplateExchange));
            // To read the file, create a FileStream.
            System.IO.FileStream myFileStream = new System.IO.FileStream(fileName, System.IO.FileMode.Open);
            // Call the Deserialize method and cast to the object type.
            TemplateExchange tex = (TemplateExchange)mySerializer.Deserialize(myFileStream);

            myFileStream.Close();

            fTemplateVersionTag fVT = new fTemplateVersionTag(tex.trs);
            DialogResult        dr  = fVT.ShowDialog(this);

            if (dr != System.Windows.Forms.DialogResult.OK)
            {
                MessageBox.Show("The Template Import operation was cancelled.", "Import Cancelled", MessageBoxButtons.OK);
            }
            else
            {
                using (fWait fw = new fWait("Importing templates, please wait."))
                {
                    UpdateTemplates(tex);
                }
            }
        }
Beispiel #2
0
        private void Export()
        {
            templateGridEX.CurrentRow.EndEdit();
            templateGridEX.UpdateData();

            appDB.TemplateRow[] selectedTemplates = (appDB.TemplateRow[])AtMng.DB.Template.Select("Export=True");
            if (selectedTemplates.Length == 0)
            {
                MessageBox.Show("You have not selected any templates to export.");
                return;
            }

            fTemplateVersionTag fVT = new fTemplateVersionTag(selectedTemplates);
            DialogResult        dr  = fVT.ShowDialog(this);

            if (dr != System.Windows.Forms.DialogResult.OK)
            {
                MessageBox.Show("The Template Export was cancelled.", "Export Cancelled", MessageBoxButtons.OK);
                return;
            }


            saveFileDialog1.Filter   = "XML files (*.xml)|*.xml|All files (*.*)|*.*";
            saveFileDialog1.FileName = "{0}_templates" + DateTime.Today.ToString("yyyyMMdd") + ".xml";
            if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string saveas = saveFileDialog1.FileName;

                using (fWait fw = new fWait("Exporting templates, please wait."))
                {
                    int iPart            = 1;
                    int iMax             = 30000000;
                    int iCount           = 0;
                    TemplateExchange tex = new TemplateExchange();
                    foreach (appDB.TemplateRow tr in selectedTemplates)
                    {
                        tr.ExportedDate = fVT.ExportDate;
                        tr.Tag          = fVT.TagVersion;
                        if (fVT.ClearFlag)
                        {
                            tr.FlagForExport = false;
                        }

                        tex.trs.ImportRow(tr);
                        if (tex.dcrs.FindByDocId(tr.DocID) == null)
                        {
                            docDB.DocumentRow dr1 = myDM.DB.Document.FindByDocId(tr.DocID);
                            tex.drs.ImportRow(dr1);

                            docDB.DocContentRow dcr1 = myDM.DB.DocContent.FindByDocId(dr1.DocRefId);

                            if (dcr1 == null)
                            {
                                myDM.GetDocContent().Load(dr1.DocRefId, dr1.CurrentVersion); //WI 73696 - added current version
                            }
                            dcr1    = myDM.DB.DocContent.FindByDocId(dr1.DocRefId);
                            iCount += dcr1.Size;
                            tex.dcrs.ImportRow(dcr1);
                        }
                        if (iCount >= iMax)
                        {
                            System.Xml.Serialization.XmlSerializer mySerializer = new System.Xml.Serialization.XmlSerializer(typeof(TemplateExchange));
                            // To write to a file, create a StreamWriter object.
                            System.IO.StreamWriter myWriter = new System.IO.StreamWriter(String.Format(saveas, iPart));
                            mySerializer.Serialize(myWriter, tex);
                            myWriter.Close();
                            Save();

                            iCount = 0;
                            iPart++;
                            tex = new TemplateExchange();
                        }
                    }


                    System.Xml.Serialization.XmlSerializer mySerializer1 = new System.Xml.Serialization.XmlSerializer(typeof(TemplateExchange));
                    // To write to a file, create a StreamWriter object.
                    System.IO.StreamWriter myWriter1 = new System.IO.StreamWriter(String.Format(saveas, iPart));
                    mySerializer1.Serialize(myWriter1, tex);
                    myWriter1.Close();
                    Save();
                }
            }
            else
            {
                MessageBox.Show("The Template Export was cancelled.", "Export Cancelled", MessageBoxButtons.OK);
            }
        }