/*-----------------------------------------------------------------------------*/ /// <summary> /// calls the check method on the close file event. /// </summary> /// <param name="sender">the class that originated the event</param> /// <param name="eventArgs">the arguments to the event. this will be the /// time (bfore or after)</param> /*-----------------------------------------------------------------------------*/ internal static void BVSchemFileEventHandler(Bentley.MicroStation.AddIn sender, NewDesignFileEventArgs eventArgs) { if ((eventArgs.WhenCode == NewDesignFileEventArgs.When.BeforeDesignFileClose) && (!s_runningTraverse)) { KeyinCommands.BVSchemaCheckerCommand("FROM_HOOK"); } }
/*-----------------------------------------------------------------------------*/ /// <summary> /// the button for starting the processing of one or more selected folders. /// sends the project id, a flag to process all the models in each file /// Silently sends a flag to turn off the message box /// </summary> /// <param name="sender">the object that initiated the event.</param> /// <param name="e">the parameters for the event.</param> /*-----------------------------------------------------------------------------*/ private void btnRun_Click(object sender, EventArgs e) { foreach (ListBoxEntry lbEntry in source) { if (lbEntry.processFile) { string projectId = string.Format("{0}", lbEntry.folderID); string procAll = ""; if (lbEntry.processAllModels) { procAll = "ALL"; } else { procAll = "ONE"; } KeyinCommands.BVSchemaCheckerTraverseRepository( string.Format("-p:{0} -m:{1} -s:TRUE", projectId, procAll)); } } }
/*-----------------------------------------------------------------------------*/ /// <summary> /// Processes the contents of a directory. /// Checks out each file and tests for presence of embeded schema /// </summary> /// <param name="iProjectID">The PW Project ID</param> /*-----------------------------------------------------------------------------*/ public static void BVSchemaCheckerProcessDocuments(int iProjectID) { int docCount = PWAPI.dmscli.aaApi_SelectDocumentsByProjectId(iProjectID); if (docCount <= 0) { return; } //docCount = PWAPI.dmscli.aaApi_GetDocumentCount(iProjectID); for (int i = 0; i < docCount; ++i) { PWAPI.dmscli.aaApi_SelectDocumentsByProjectId(iProjectID); int did = PWAPI.dmscli.aaApi_GetDocumentId(i); //appidd can be different on different installations... need to make this better. if (ProcessDocument(iProjectID, did)) { StringBuilder sbWorkingFileName = new StringBuilder(512); if (did > 0) { if (PWAPI.dmscli.aaApi_CopyOutDocument(iProjectID, did, null, sbWorkingFileName, 512)) { //this opens the file BVSchemaChecker.ComApp.OpenDesignFile( sbWorkingFileName.ToString(), true, BCOM.MsdV7Action.Workmode); //this will loop through the models in the file if (!s_processAllModels) { CleanOffRefFiles(); KeyinCommands.BVSchemaCheckerCommand(""); } else { foreach (BCOM.ModelReference oModel in BVSchemaChecker.ComApp.ActiveDesignFile.Models) { oModel.Activate(); //this is to remove the reference files CleanOffRefFiles(); //this checks the schema KeyinCommands.BVSchemaCheckerCommand(""); } } iFileCount++; //the file has been checked. PWAPI.dmscli.aaApi_CheckInDocument(iProjectID, did); } else { string errMessage = PWAPI.dmsgen.aaApi_GetLastErrorMessage(); string errDetail = PWAPI.dmsgen.aaApi_GetLastErrorDetail(); BVSchemaChecker.ComApp.MessageCenter.AddMessage( errMessage, errDetail, BCOM.MsdMessageCenterPriority.Info, false); } } } } }