Пример #1
0
        public bool HandleDrop(IServerConnection conn, string file, string folderId)
        {
            try
            {
                if (!MessageService.AskQuestion(Strings.ConfirmLoadPackage, Strings.Confirm))
                    return false;

                var wb = Workbench.Instance;
                var exp = wb.ActiveSiteExplorer;
                var optDiag = new PackageUploadOptionDialog();
                optDiag.ShowDialog();
                DialogResult res;
                if (optDiag.Method == PackageUploadMethod.Transactional)
                {
                    res = PackageProgress.UploadPackage(wb, conn, file);
                }
                else
                {
                    res = PackageProgress.StartNonTransactionalUploadLoop(wb, conn, file);
                }
                if (res == System.Windows.Forms.DialogResult.OK)
                {
                    exp.RefreshModel(conn.DisplayName);
                }
                return false; //Already refreshed if successful
            }
            catch (Exception ex)
            {
                ErrorDialog.Show(ex);
                return false;
            }
        }
        /// <summary>
        /// Lets the user choose a file to upload, and then transfers it
        /// </summary>
        /// <param name="owner">The owner form</param>
        /// <param name="con">The connection to use</param>
        /// <returns>A DialogResult object that indicates the upload result</returns>
        public static DialogResult UploadPackage(Form owner, IServerConnection con)
        {
            OpenFileDialog dlg = DialogFactory.OpenFile();
            //Mono does NOT like this one
            //dlg.AutoUpgradeEnabled = true;
            dlg.CheckFileExists = true;
            dlg.CheckPathExists = true;
            dlg.DefaultExt = ".mgp"; //NOXLATE
            dlg.Filter = string.Format(OSGeo.MapGuide.MaestroAPI.Strings.GenericFilter, OSGeo.MapGuide.MaestroAPI.Strings.PickMgp, "mgp") + "|" + //NOXLATE
                         string.Format(OSGeo.MapGuide.MaestroAPI.Strings.GenericFilter, OSGeo.MapGuide.MaestroAPI.Strings.PickZip, "zip") + "|" + //NOXLATE
                         StringConstants.AllFilesFilter;
            dlg.FilterIndex = 0;
            dlg.Multiselect = false;
            dlg.ValidateNames = true;
            dlg.Title = Strings.UploadPackageDialogTitle;

            if (dlg.ShowDialog(owner) == DialogResult.OK)
            {
                var optDiag = new PackageUploadOptionDialog();
                optDiag.ShowDialog();
                if (optDiag.Method == PackageUploadMethod.Transactional)
                {
                    return UploadPackage(owner, con, dlg.FileName);
                }
                else
                {
                    return StartNonTransactionalUploadLoop(owner, con, dlg.FileName);
                }
            }
            else
                return DialogResult.Cancel;
        }
Пример #3
0
        public override void Run()
        {
            var wb = Workbench.Instance;
            var exp = wb.ActiveSiteExplorer;
            var connMgr = ServiceRegistry.GetService<ServerConnectionManager>();
            var conn = connMgr.GetConnection(exp.ConnectionName);

            using (var open = DialogFactory.OpenFile())
            {
                open.Filter = string.Format(OSGeo.MapGuide.MaestroAPI.Strings.GenericFilter, OSGeo.MapGuide.MaestroAPI.Strings.PickMgp, "mgp"); //NOXLATE
                if (open.ShowDialog(wb) == System.Windows.Forms.DialogResult.OK)
                {
                    var optDiag = new PackageUploadOptionDialog();
                    optDiag.ShowDialog();
                    DialogResult res;
                    if (optDiag.Method == PackageUploadMethod.Transactional)
                    {
                        res = PackageProgress.UploadPackage(wb,
                                                            conn,
                                                            open.FileName);
                    }
                    else
                    {
                        res = PackageProgress.StartNonTransactionalUploadLoop(wb, conn, open.FileName);
                    }
                    if (res == System.Windows.Forms.DialogResult.OK)
                    {
                        exp.RefreshModel(conn.DisplayName);
                    }
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Lets the user choose a file to upload, and then transfers it
        /// </summary>
        /// <param name="owner">The owner form</param>
        /// <param name="con">The connection to use</param>
        /// <returns>A DialogResult object that indicates the upload result</returns>
        public static DialogResult UploadPackage(Form owner, IServerConnection con)
        {
            OpenFileDialog dlg = Maestro.Shared.UI.DialogFactory.OpenFile();
            //Mono does NOT like this one
            //dlg.AutoUpgradeEnabled = true;
            dlg.CheckFileExists = true;
            dlg.CheckPathExists = true;
            dlg.DefaultExt = ".mgp"; //NOXLATE
            dlg.Filter = string.Format(OSGeo.MapGuide.MaestroAPI.Strings.GenericFilter, OSGeo.MapGuide.MaestroAPI.Strings.PickMgp, "mgp") + "|" + //NOXLATE
                         string.Format(OSGeo.MapGuide.MaestroAPI.Strings.GenericFilter, OSGeo.MapGuide.MaestroAPI.Strings.PickZip, "zip") + "|" + //NOXLATE
                         StringConstants.AllFilesFilter;
            dlg.FilterIndex = 0;
            dlg.Multiselect = false;
            dlg.ValidateNames = true;
            dlg.Title = Strings.UploadPackageDialogTitle;

            if (dlg.ShowDialog(owner) == DialogResult.OK)
            {
                var optDiag = new PackageUploadOptionDialog();
                optDiag.ShowDialog();
                if (optDiag.Method == PackageUploadMethod.Transactional)
                {
                    return UploadPackage(owner, con, dlg.FileName);
                }
                else
                {
                    return StartNonTransactionalUploadLoop(owner, con, dlg.FileName);
                }
            }
            else
                return DialogResult.Cancel;
        }