internal CmdBimServerLogin(BimServerLoginForm form, UIDocument uidoc)
        {
            Form  = form;
            UIDoc = uidoc;

            //if (form.SimpleForm) ReadProjectsXml();	// creates and fills the projects dict
        }
示例#2
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIDocument uidoc = commandData.Application.ActiveUIDocument;

            try
            {
                if (string.IsNullOrEmpty(uidoc.Document.PathName))
                {
                    throw new IcnException("The project must be saved before it can be exported to a BIMserver", 10, "QuickExport");
                }
                if (uidoc.Document.PathName.EndsWith(".rfa", StringComparison.InvariantCultureIgnoreCase))
                {
                    throw new IcnException("Revit Families can not be exported to a BIMserver", 10, "QuickExport");
                }

                BimServerExportForm form = new BimServerExportForm(uidoc);
                // check if there is a connection to a BIMserver configured, if not keep asking the user till he creates one or gives up
                while (!form.Cmd.BimServerExport.CheckLogin())
                {
                    BimServerLoginForm login = new BimServerLoginForm(uidoc, form.Data);
                    if (DialogResult.Cancel == login.ShowDialog())
                    {
                        return(Result.Cancelled);
                    }

                    form.Data.CopyFrom(login.Data);
                    break;
                }
                // at this point we have a valid connection to the BIMserver.

                KnownProjects kp = new KnownProjects();
                //if (string.IsNullOrEmpty(form.Data.ProjectName) || !kp.ContainsKey(uidoc.Document.PathName ?? string.Empty))
                if (!form.Cmd.BimServerExport.CheckProject(kp))
                {
                    MessageBox.Show(@"This Revit project is not yet linked to a project on the BIMserver. Use the Projects tool do to so before uploading", @"BIMserver Export");
                    return(Result.Cancelled);
                }

                // initialise the form controls with the settings from form.Data
                form.Cmd.BimServerExport.Init();
                form.Show();                                    // <-- making this form modeless means that errors are no longer caught in the command
            }
            catch (IcnException iex)
            {
                iex.Display(@"Exception in BIMserver Export");
            }
            catch (Exception ex)
            {
                string mssg = ex.Message;
                MessageBox.Show(mssg, @"Exception in BIMserver Export");
            }

            // autocancel for now
            return(Result.Cancelled);
        }
示例#3
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIDocument uidoc = commandData.Application.ActiveUIDocument;

            if (string.IsNullOrEmpty(uidoc.Document.PathName))
            {
                throw new IcnException("The project must be saved before it can be exported to a BIMserver", 10, "QuickExport");
            }
            if (uidoc.Document.PathName.EndsWith(".rfa", StringComparison.InvariantCultureIgnoreCase))
            {
                throw new IcnException("Revit Families can not be exported to a BIMserver", 10, "QuickExport");
            }

            try
            {
                BimServerExchangeForm form = new BimServerExchangeForm(uidoc);
                form.Cmd.BimServerExchange.Init();
                while (!form.Cmd.BimServerExchange.CheckLogin())
                {
                    BimServerLoginForm login = new BimServerLoginForm(uidoc, form.Data, false);
                    if (DialogResult.Cancel == login.ShowDialog())
                    {
                        return(Result.Cancelled);
                    }

                    form.Data.CopyFrom(login.Data);
                    break;
                }

                // show the export/import dialog (now it is connected to a BimServer that we can query)
                form.InitialiseProjects();
                form.PreselectProject(uidoc.Document?.PathName);
                form.ShowDialog();
            }
            catch (IcnException iex)
            {
                iex.Display(@"Exception in BIMserver Export");
            }
            catch (Exception ex)
            {
                string mssg = ex.Message;
                MessageBox.Show(mssg, @"Exception in BIMserver Export");
            }

            // autocancel for now
            return(Result.Cancelled);
        }
        internal void LoginEvent()
        {
            if (Form.Connected)
            {
                Form.Cmd.ServerInterface.Logout(Form.Data);
                Form.Connected         = false;
                Form.ExportBtn.Enabled = false;
            }

            BimServerLoginForm form = new BimServerLoginForm(UIDoc, Form.Data);

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

            Form.Data.CopyFrom(form.Data);
            Form.Cmd.ShowResult("Successfully connected to the BIMserver" /*Data.Token*/);
            Form.ExportBtn.Enabled = true;     // if we have a connection we can enable the action buttons (upload)
            Form.Connected         = true;     // mark as connected
        }