コード例 #1
0
        private void bwGenerateGiagrams_DoWork(object sender, DoWorkEventArgs e)
        {
            //transportStopped = false;
            BackgroundWorker worker = sender as BackgroundWorker;

            //Generate Diagrams
            DiagramBuilder db = new DiagramBuilder();
            try
            {
                string filename = db.GenerateDiagram(DGconnectionName, DGentities, environmentStructure, worker, e);
                DiagramGeneratedSuccesfully = true;
            }
            catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault> ex)
            {
                DiagramGeneratedSuccesfully = false;
                toolStripStatusLabel1.Text = "Error.";
                MessageBox.Show("Error:" + ex.Detail.Message + "\n" + ex.Detail.TraceText, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                DiagramGeneratedSuccesfully = false;
                toolStripStatusLabel1.Text = "Error.";
                if (ex.InnerException != null)
                    MessageBox.Show("Error:" + ex.Message + "\n" + ex.InnerException.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                else
                {
                    //Personalise error message if Visio not present on the machine
                    if (ex.Message != null && ex.Message.Contains("REGDB_E_CLASSNOTREG"))
                    {
                        string errorMessage = "Error:" + ex.Message + "\n\n" + "You're probably seen this message because Visio 2010 is not found on this machine. \nYou have to install Visio 2010 before generating diagrams!";
                        MessageBox.Show(errorMessage, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                        MessageBox.Show("Error:" + ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }