예제 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            //// TODO: Remove
            //this.Close(); this.DialogResult = System.Windows.Forms.DialogResult.OK;  return;

            Uri server = null;

            if (Uri.TryCreate(textBox3.Text, UriKind.Absolute, out server) == false)
            {
                MessageBox.Show("Please enter a valid server URL!");
                return;
            }

            if (_isDummy)
            {
                DClient           = new DOCQRclient(textBox3.Text);
                DClient.IsDummy   = true;
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
                return;
            }


            string username = textBox1.Text;               // get the user name and password from the user form
            string password = textBox2.Text;

            if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
            {
                try
                {
                    DClient = new DOCQRclient(textBox3.Text);
                    DClient.SignIn(username, password);
                    _LastUser         = username; // store it.
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                MessageBox.Show("Please enter a valid username/password combination!");
            }
        }
예제 #2
0
파일: LogInFrm.cs 프로젝트: DOCQR/revit
        private void button1_Click(object sender, EventArgs e)
        {
            //// TODO: Remove
            //this.Close(); this.DialogResult = System.Windows.Forms.DialogResult.OK;  return;

            Uri server = null;
            if (Uri.TryCreate(textBox3.Text, UriKind.Absolute, out server) == false)
            {
                MessageBox.Show("Please enter a valid server URL!");
                return;
            }

            if (_isDummy)
            {
                DClient = new DOCQRclient(textBox3.Text);
                DClient.IsDummy = true;
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
                return;
            }

               string username = textBox1.Text;                // get the user name and password from the user form
            string password = textBox2.Text;

            if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
            {
                try
                {
                    DClient = new DOCQRclient(textBox3.Text);
                    DClient.SignIn(username, password);
                    _LastUser = username; // store it.
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                MessageBox.Show("Please enter a valid username/password combination!");
            }
        }
예제 #3
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            _uiApp = commandData.Application;
            Document   doc   = _uiApp.ActiveUIDocument.Document;
            UIDocument uidoc = _uiApp.ActiveUIDocument;

            // take care of AppDomain load issues
            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

            Transaction trans = null;

            try
            {
                if (uidoc.ActiveGraphicalView.ViewType != ViewType.ThreeD)
                {
                    throw new ApplicationException("Please run this command from a 3D View!");
                }

                string WebURL = "http://128.8.215.91";
                //DOCQRclient client = new DOCQRclient(WebURL);

                LogInFrm loginForm = new LogInFrm(WebURL, false);



                if (loginForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    DOCQRclient client = loginForm.DClient;

                    WebURL = client.Server;
                    ProjectSelectFrm ProjectSelectFrm = new ProjectSelectFrm(client);
                    if (ProjectSelectFrm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        List <SheetInfo> sheets        = GetSheetViewInfo(doc);
                        List <ElementId> ViewsToDelete = new List <ElementId>();
                        ViewNames        names         = new ViewNames();
                        client.GetModelID(ProjectSelectFrm.SelectedProject.id);

                        ProgressForm progress = new ProgressForm(_viewCount * 3);
                        progress.Show();

                        trans = new Transaction(doc, "QR");
                        trans.Start();

                        // go through all the sheets and then views
                        // make a 3d view
                        // save each 3d view json file
                        foreach (SheetInfo sheet in sheets)
                        {
                            foreach (ViewPortInfo vpInfo in sheet.ViewPorts)
                            {
                                Spectacles.RevitExporter.Command cmd = new Spectacles.RevitExporter.Command();
                                string tempFile = System.IO.Path.Combine(System.IO.Path.GetTempPath(), doc.Title + vpInfo.view.Id + ".json");

                                if (progress.IsCancelled)
                                {
                                    throw new ApplicationException("DOCQR Cancelled...");
                                }
                                progress.SetStatus("Exporting View: " + vpInfo.view.Name + " to Spectacles...");
                                System.Diagnostics.Debug.WriteLine("Exporting View " + vpInfo.view.Name + " to Spectacles...");
                                View3D temp3dView = vpInfo.view.GetMatching3DView(doc);
                                cmd.ExportEntireModel(temp3dView, tempFile);
                                ViewsToDelete.Add(temp3dView.Id);

                                if (progress.IsCancelled)
                                {
                                    throw new ApplicationException("DOCQR Cancelled...");
                                }
                                progress.Step();
                                progress.SetStatus("Sending View: " + vpInfo.view.Name + " to DOCQR...");
                                vpInfo.docQRid = client.SendModelInfo(ProjectSelectFrm.SelectedProject, tempFile);            // send the model and view info to the web server
                                names.Views.Add(new ViewName()
                                {
                                    Name = vpInfo.view.Name, ID = vpInfo.docQRid
                                });
                                progress.Step();
                            }
                        }

                        //client.SendViewInfo(names);

                        progress.SetStatus("Adding QR Codes...");
                        foreach (SheetInfo sheet in sheets)
                        {
                            if (progress.IsCancelled)
                            {
                                throw new ApplicationException("DOCQR Cancelled...");
                            }
                            progress.Step();
                            RevitQR QR = new RevitQR(doc, sheet, true, WebURL);                                                   // create QR codes
                        }

                        progress.Close();

                        doc.Delete(ViewsToDelete);

                        trans.Commit();
                        trans.Dispose();

                        TaskDialog.Show("DOCQR", "QR Codes added to " + _viewCount + " viewports!");
                    }
                }
            }
            catch (ApplicationException aex)
            {
                TaskDialog.Show("DOCQR", aex.Message);
                if ((trans != null) && (trans.HasStarted()))
                {
                    trans.RollBack();
                }
                return(Result.Cancelled);
            }
            catch (Exception ex)
            {
                TaskDialog td = new TaskDialog("Unexpected Issue");
                td.MainInstruction = ex.GetType().Name + ": " + ex.Message;
                string expanded = "";
                if (ex.InnerException != null)
                {
                    expanded += Environment.NewLine + "Inner: " + ex.InnerException.GetType().Name + ": " + ex.InnerException.Message;
                }
                expanded          += Environment.NewLine + "Stack: " + ex.StackTrace;
                td.ExpandedContent = expanded;
                td.Show();
                //TaskDialog.Show("Unexpected Error", ex.GetType().Name + ": " + ex.Message);
                if ((trans != null) && (trans.HasStarted()))
                {
                    trans.RollBack();
                }
                return(Result.Failed);
            }

            //try

            // {

            //}
            //catch (System.Exception ex)
            //{
            //    return Result.Failed;
            //}

            //doc.Regenerate();

            return(Result.Succeeded);
        }
예제 #4
0
 public ProjectSelectFrm(DOCQRclient Client)
 {
     InitializeComponent();
     client = Client;
 }
예제 #5
0
 public ProjectSelectFrm(DOCQRclient Client)
 {
     InitializeComponent();
     client = Client;
 }