/*-----------------------------------------------------------------------------*/
        /// <summary>
        /// This tries to remove the reference files so they are not loaded in the process.
        /// </summary>
/*-----------------------------------------------------------------------------*/
        public static void CleanOffRefFiles()
        {
            BCOM.ModelReference oModel = BVSchemaChecker.ComApp.ActiveModelReference;
            int iAttachmentCount       = oModel.Attachments.Count;

            for (int i = iAttachmentCount; i > 0; --i)
            {
                BCOM.Attachment oAtt = oModel.Attachments[i];
                oModel.Attachments.Remove(oAtt);
            }

            return;
        }
예제 #2
0
        public void changeSelection(IEnumerable <DataRow> selection)
        {
            selectionTranCon_?.Reset();

            foreach (DataRow taskRow in selection)
            {
                PenetrVueTask task = rowsToTasks_[taskRow];

                BCOM.ModelReference modelRef = task.ModelRef;
                BCOM.View           view     = ViewHelper.getActiveView();

                var taskUOR   = new UOR(task.ModelRef);
                var activeUOR = new UOR(App.ActiveModelReference);

                List <long> itemsIds = new List <long> {
                    task.elemId
                };
                // добавляем фланцы:
                foreach (PenetrTaskFlange flangeTask in task.FlangesGeom)
                {
                    itemsIds.Add(flangeTask.elemId);
                }

                foreach (long id in itemsIds)
                {
                    BCOM.Element temp = modelRef.GetElementByID(id).Clone();
                    temp.Color      = 2; // зелёный
                    temp.LineWeight = 5;

            #if CONNECT
                    // для версии CONNECT требуется поправка
                    // в V8i возмоно она производится автоматически
                    BCOM.Attachment attachment = task.getAttachment();
                    if (attachment != null)
                    {
                        temp.Transform(attachment.GetReferenceToMasterTransform());
                    }
            #endif

                    selectionTranCon_.AppendCopyOfElement(temp);
                }
            }
        }
예제 #3
0
/*-----------------------------------------------------------------------------*/
        /// <summary>
        /// The command to process the active file.  It will attempt to create a session
        /// and open the connection to the active model.
        /// If the connection cannot be opened it will error out.
        /// The findEmbeded method to look at the file for embedded schemas
        /// </summary>
        /// <param name="unparsed">not used.</param>
/*-----------------------------------------------------------------------------*/
        public static void BVSchemaCheckerCommand(System.String unparsed)
        {
            string        errMessage = "ERROR";
            List <string> schemaList = new List <string>();

            //set to silent mode
            m_silentMode = false;
            if (1 == BVSchemaChecker.mdlSystem_startedAsAutomationServer() && ((null != unparsed) && unparsed == "FROM_HOOK"))
            {
                return;
            }
            //if an unparsed string is sent in then set silent to true
            if (1 != BVSchemaChecker.mdlSystem_startedAsAutomationServer() && ((null != unparsed) && (unparsed.Length > 0)))
            {
                m_silentMode = true;
            }
            //see if it is an imodel if so then don't check.
            if (1 == BVSchemaChecker.IsIModel(BVSchemaChecker.ComApp.ActiveModelReference.MdlModelRefP()))
            {
                BVSchemaChecker.ComApp.MessageCenter.AddMessage("this is an i-model", "i-models are not processed", BCOM.MsdMessageCenterPriority.Info, false);
                return;
            }
            //if there are references then we process special.
            if (BVSchemaChecker.ComApp.ActiveModelReference.Attachments.Count > 0)
            {//if the references are imodels then notify the users.
                if (BVSchemaChecker.HasIModelReference(BVSchemaChecker.ComApp.ActiveModelReference))
                {
                    BVSchemaChecker.ComApp.MessageCenter.AddMessage("Has IModel Attached",
                                                                    "This file has an imodel in the attachment set",
                                                                    BCOM.MsdMessageCenterPriority.Info, false);
                }

                BCOM.DesignFile workFile = BVSchemaChecker.ComApp.OpenDesignFileForProgram(
                    BVSchemaChecker.ComApp.ActiveDesignFile.FullName, true);
                //create a model in the file that has no references
                //proces the new model.  this will avoid using the references as part
                //of the ec repository.
                //delete the model after the processing.
                try
                {
                    BCOM.ModelReference workModel = workFile.Models.Add(
                        workFile.DefaultModelReference,
                        "working", "working",
                        BCOM.MsdModelType.Normal, true);

                    int iAttachmentCount = workModel.Attachments.Count;
                    for (int i = iAttachmentCount; i > 0; --i)
                    {
                        BCOM.Attachment oAtt = workModel.Attachments[i];
                        workModel.Attachments.Remove(oAtt);
                    }

                    BVSchemaChecker.ProcessModel(workModel);
                    workFile.Models.Delete(workModel);
                }
                catch (Exception e)
                {
                    Console.WriteLine("unable to wrtie to file");
                }
                workFile.Close();
                return;
            }

            //if I am a simple file with normal dgn references
            ECSR.RepositoryConnection connection = null;
            CSVReporter.CreateReport(string.Format("SC_{0}.csv", DateTime.Now.ToString("yyyy-dd-MM")));
            if (m_debugMode)
            {
                BVSchemaChecker.ComApp.MessageCenter.AddMessage("created csv file",
                                                                string.Format("created report file at {0}", CSVReporter.FileName),
                                                                BCOM.MsdMessageCenterPriority.Info, m_debugMode);
            }

            if (m_usesSelector)
            {
                m_selectorForm.SetMessage("Processing File " + BVSchemaChecker.ComApp.ActiveDesignFile.Name);
            }

            try
            {
                ECSS.ECSession ecSession = ECSS.SessionManager.CreateSession(true);
                connection = BVSchemaChecker.OpenConnectionToActiveModel(ecSession);

                if (BVSchemaChecker.FindEmbededSchemas(connection, schemaList))
                {
                    BVSchemaChecker.ComApp.MessageCenter.AddMessage("Found schema in this file. \n Please contact the Bentley Execution team with the Schema list provided on the following dialog box. \n Select Ok to get a list of the schema you will need to provide",
                                                                    "Found Schema",
                                                                    BCOM.MsdMessageCenterPriority.Error,
                                                                    m_silentMode);
                    BVSchemaChecker.iSchemaFoundCount++;
                    //show the list...
                    if (m_silentMode)
                    {
                        SchemaListForm sform = new SchemaListForm();
                        sform.SetSchemaNames(schemaList);
                        sform.ShowDialog();
                    }
                }
                else
                {
                    BVSchemaChecker.ComApp.MessageCenter.AddMessage("no schema in the file",
                                                                    "nothing found",
                                                                    BCOM.MsdMessageCenterPriority.Info,
                                                                    (unparsed != "FROM_HOOK"));
                }
            }
            catch (Exception e)
            {
                BVSchemaChecker.ComApp.MessageCenter.AddMessage(e.Message, e.Message,
                                                                BCOM.MsdMessageCenterPriority.Error,
                                                                !BVSchemaChecker.bUseLogFile);
                errMessage = e.Message;
            }
            finally
            {
                if (null == connection)
                {
                    CSVReporter.writeLine(BVSchemaChecker.strCurrentProjectName,
                                          BVSchemaChecker.ComApp.ActiveDesignFile.Name,
                                          BVSchemaChecker.ComApp.ActiveModelReference.Name,
                                          errMessage, false);
                }
                else
                {
                    BVSchemaChecker.CloseConnection(connection);
                }

                CSVReporter.close();
            }
        }