Ejemplo n.º 1
0
        /// <summary>
        /// Exports a single Partner.
        /// </summary>
        /// <param name="APartnerKey">Partner Key of the Partner.</param>
        /// <param name="APartnerClass">Class of partner for the specified key</param>
        /// <param name="ASiteKey">SiteKey of the Location.</param>
        /// <param name="ALocationKey">LocationKey of the Location.</param>
        /// <param name="AOldPetraFormat">Set to true if old format should be used.</param>
        public static void ExportSinglePartner(Int64 APartnerKey, String APartnerClass, Int64 ASiteKey, int ALocationKey, Boolean AOldPetraFormat)
        {
            bool          Result = false;
            String        ExtFormattedDocument;
            String        PartnerShortName;
            TPartnerClass PartnerClass;

            // prepare suggestion for file name: Partner short name
            TRemote.MPartner.Partner.ServerLookups.WebConnectors.GetPartnerShortName(APartnerKey, out PartnerShortName, out PartnerClass);
            PartnerShortName = "p_" + PartnerShortName;

            string FileName = TImportExportDialogs.GetExportFilename(Catalog.GetString("Save Partners into File"), PartnerShortName);

            if (FileName.Length > 0)
            {
                if (FileName.EndsWith("ext"))
                {
                    bool ExportFamiliesPersons = false;

                    if (string.Compare(APartnerClass, TPartnerClass.FAMILY.ToString(), true) == 0)
                    {
                        if (MessageBox.Show(
                                Catalog.GetString("Do you want to also export all PERSON records associated with this FAMILY?"),
                                Catalog.GetString("Export Partner"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            ExportFamiliesPersons = true;
                        }
                    }

                    ExtFormattedDocument = TRemote.MPartner.ImportExport.WebConnectors.ExportSinglePartnerExt(APartnerKey,
                                                                                                              ExportFamiliesPersons,
                                                                                                              AOldPetraFormat);

                    Result = TImportExportDialogs.ExportTofile(ExtFormattedDocument, FileName, AOldPetraFormat);

                    if (!Result)
                    {
                        MessageBox.Show(Catalog.GetString("Export of Partner failed!"), Catalog.GetString(
                                            "Export Partner"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        MessageBox.Show(Catalog.GetString("Export of Partner finished"), Catalog.GetString(
                                            "Export Partner"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show(Catalog.GetString("Export with this format is not yet supported!"), Catalog.GetString(
                                        "Export Partner"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 2
0
        /// export partners into file
        public static void ExportPartners(Form AParentForm)
        {
            String FileName = TImportExportDialogs.GetExportFilename(Catalog.GetString("Save Partners into File"));

            if (FileName.Length > 0)
            {
                if (FileName.EndsWith("ext"))
                {
                    String doc = TRemote.MPartner.ImportExport.WebConnectors.ExportAllPartnersExt();
                    TImportExportDialogs.ExportTofile(doc, FileName);
                }
                else
                {
                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(TRemote.MPartner.ImportExport.WebConnectors.ExportPartners());
                    TImportExportDialogs.ExportTofile(doc, FileName);
                }
            }
        }
        /// <summary>
        /// export all partners in selected extract
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <returns></returns>
        public bool ExportPartnersInExtract(System.Object sender, EventArgs e)
        {
            Boolean Result = false;

            if (!WarnIfNotSingleSelection(Catalog.GetString("Export Partners in Extract")) &&
                (GetSelectedDetailRow() != null))
            {
                String FileName = TImportExportDialogs.GetExportFilename(Catalog.GetString("Save Partners into File"));

                if (FileName.Length > 0)
                {
                    if (FileName.EndsWith("ext"))
                    {
                        String doc = TRemote.MPartner.ImportExport.WebConnectors.ExportExtractPartnersExt(GetSelectedDetailRow().ExtractId, false);
                        Result = TImportExportDialogs.ExportTofile(doc, FileName);

                        if (!Result)
                        {
                            MessageBox.Show(Catalog.GetString("Export of Partners in Extract failed!"), Catalog.GetString(
                                                "Export Partners"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            MessageBox.Show(Catalog.GetString("Export of Partners in Extract finished"), Catalog.GetString(
                                                "Export Partners"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    else
                    {
                        // XmlDocument doc = new XmlDocument();
                        MessageBox.Show(Catalog.GetString("Export with this format is not yet supported!"), Catalog.GetString(
                                            "Export Partners"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                        // doc.LoadXml(TRemote.MPartner.ImportExport.WebConnectors.ExportExtractPartners(GetSelectedDetailRow().ExtractId, false));
                        // Result = TImportExportDialogs.ExportTofile(doc, FileName);
                    }
                }

                return(Result);
            }

            return(false);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Exports a single Partner.
        /// </summary>
        /// <param name="APartnerKey">Partner Key of the Partner.</param>
        /// <param name="ASiteKey">SiteKey of the Location.</param>
        /// <param name="ALocationKey">LocationKey of the Location.</param>
        public static void ExportSinglePartner(Int64 APartnerKey, Int64 ASiteKey, int ALocationKey)
        {
            bool             Result = false;
            StringCollection ASpecificBuildingInfo = null;
            String           ExtFormattedDocument;

            string FileName = TImportExportDialogs.GetExportFilename(Catalog.GetString("Save Partners into File"));

            if (FileName.Length > 0)
            {
                if (FileName.EndsWith("ext"))
                {
                    ExtFormattedDocument = TRemote.MPartner.ImportExport.WebConnectors.GetExtFileHeader();

                    ExtFormattedDocument += TRemote.MPartner.ImportExport.WebConnectors.ExportPartnerExt(
                        APartnerKey, ASiteKey, ALocationKey, false, ASpecificBuildingInfo);

                    ExtFormattedDocument += TRemote.MPartner.ImportExport.WebConnectors.GetExtFileFooter();

                    Result = TImportExportDialogs.ExportTofile(ExtFormattedDocument, FileName);

                    if (!Result)
                    {
                        MessageBox.Show(Catalog.GetString("Export of Partner failed!"), Catalog.GetString(
                                            "Export Partner"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        MessageBox.Show(Catalog.GetString("Export of Partner finished"), Catalog.GetString(
                                            "Export Partner"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show(Catalog.GetString("Export with this format is not yet supported!"), Catalog.GetString(
                                        "Export Partner"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Export Partners from an Extract.
        /// </summary>
        /// <param name="AExtractId">Extract Identifier.</param>
        /// <param name="AOldPetraFormat">Set to true if old format should be used.</param>
        public static Boolean ExportPartnersInExtract(int AExtractId, Boolean AOldPetraFormat)
        {
            String  SuggestedFileName = "";
            Boolean Result            = false;

            // prepare suggestion for file name: Extract name
            SuggestedFileName = "p_" + TRemote.MPartner.Partner.WebConnectors.GetExtractName(AExtractId);

            String FileName = TImportExportDialogs.GetExportFilename(Catalog.GetString("Save Partners into File"), SuggestedFileName);

            if (AExtractId < 0)
            {
                return(false);
            }

            if (FileName.Length > 0)
            {
                bool ExportFamiliesPersons = false;
                bool ContainsFamily        = TRemote.MPartner.ImportExport.WebConnectors.CheckExtractContainsFamily(AExtractId);

                if (ContainsFamily)
                {
                    if (MessageBox.Show(
                            Catalog.GetString("When exporting a FAMILY record do you want to also export all associated PERSON records?"),
                            Catalog.GetString("Export Partners"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        ExportFamiliesPersons = true;
                    }
                }

                if (FileName.EndsWith("ext"))
                {
                    string Doc = string.Empty;

                    // run in thread so we can have Progress Dialog
                    Thread t = new Thread(() => ExportExtractToString(AExtractId, ExportFamiliesPersons, ref Doc, AOldPetraFormat));

                    using (TProgressDialog dialog = new TProgressDialog(t))
                    {
                        dialog.ShowDialog();
                    }

                    // null if the user cancelled the operation
                    if (Doc == null)
                    {
                        MessageBox.Show(Catalog.GetString("Export cancelled."), Catalog.GetString(
                                            "Export Partners"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return(false);
                    }

                    Result = TImportExportDialogs.ExportTofile(Doc, FileName, AOldPetraFormat);

                    if (!Result)
                    {
                        MessageBox.Show(Catalog.GetString("Export of Partners in Extract failed!"), Catalog.GetString(
                                            "Export Partners"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        MessageBox.Show(Catalog.GetString("Export of Partners in Extract finished."), Catalog.GetString(
                                            "Export Partners"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    // XmlDocument doc = new XmlDocument();
                    MessageBox.Show(Catalog.GetString("Export with this format is not yet supported!"), Catalog.GetString(
                                        "Export Partners"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    // doc.LoadXml(TRemote.MPartner.ImportExport.WebConnectors.ExportExtractPartners(GetSelectedDetailRow().ExtractId, false));
                    // Result = TImportExportDialogs.ExportTofile(doc, FileName);
                }

                return(Result);
            }

            return(false);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// export all partners in selected extract
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <returns></returns>
        public bool ExportPartnersInExtract(System.Object sender, EventArgs e)
        {
            Boolean Result = false;

            if (!WarnIfNotSingleSelection(Catalog.GetString("Export Partners in Extract")) &&
                (GetSelectedDetailRow() != null))
            {
                String FileName = TImportExportDialogs.GetExportFilename(Catalog.GetString("Save Partners into File"));

                if (FileName.Length > 0)
                {
                    bool ExportFamiliesPersons = false;

                    bool ContainsFamily = TRemote.MPartner.ImportExport.WebConnectors.CheckExtractContainsFamily(GetSelectedDetailRow().ExtractId);

                    if (ContainsFamily)
                    {
                        if (MessageBox.Show(
                                Catalog.GetString("When exporting a FAMILY record do you want to also export all associated PERSON records?"),
                                Catalog.GetString("Export Partners"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            ExportFamiliesPersons = true;
                        }
                    }

                    this.Cursor = Cursors.WaitCursor;

                    if (FileName.EndsWith("ext"))
                    {
                        string Doc = string.Empty;

                        // run in thread so we can have Progress Dialog
                        Thread t = new Thread(() => ExportToFile(ExportFamiliesPersons, ref Doc));

                        using (TProgressDialog dialog = new TProgressDialog(t))
                        {
                            dialog.ShowDialog();
                        }

                        // null if the user cancelled the operation
                        if (Doc == null)
                        {
                            MessageBox.Show(Catalog.GetString("Export cancelled."), Catalog.GetString(
                                                "Export Partners"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.Cursor = Cursors.Default;
                            return(false);
                        }

                        Result = TImportExportDialogs.ExportTofile(Doc, FileName);

                        if (!Result)
                        {
                            MessageBox.Show(Catalog.GetString("Export of Partners in Extract failed!"), Catalog.GetString(
                                                "Export Partners"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            MessageBox.Show(Catalog.GetString("Export of Partners in Extract finished"), Catalog.GetString(
                                                "Export Partners"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    else
                    {
                        // XmlDocument doc = new XmlDocument();
                        MessageBox.Show(Catalog.GetString("Export with this format is not yet supported!"), Catalog.GetString(
                                            "Export Partners"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                        // doc.LoadXml(TRemote.MPartner.ImportExport.WebConnectors.ExportExtractPartners(GetSelectedDetailRow().ExtractId, false));
                        // Result = TImportExportDialogs.ExportTofile(doc, FileName);
                    }

                    this.Cursor = Cursors.Default;
                }

                return(Result);
            }

            return(false);
        }