Example #1
0
        private bool mcmMain_GetDocumentIdByFilePath(string sFileName, int iValidateWithChkl,
                                                     ref int iProjectNo, ref int iDocumentNo)
        {
            bool bRetVal = false;

            Guid[] docGuids  = new Guid[1];
            int    iNumGuids = 0;

            try
            {
                IntPtr pGuid = IntPtr.Zero;

                int iRetVal = PWWrapper.aaApi_GetGuidsFromFileName(ref pGuid, ref iNumGuids, sFileName, iValidateWithChkl);

                if (iNumGuids == 1)
                {
                    Guid docGuid = (Guid)System.Runtime.InteropServices.Marshal.PtrToStructure(pGuid, typeof(Guid));

                    if (1 == PWWrapper.aaApi_GUIDSelectDocument(ref docGuid))
                    {
                        bRetVal = true;

                        iProjectNo =
                            PWWrapper.aaApi_GetDocumentNumericProperty(PWWrapper.DocumentProperty.ProjectID, 0);
                        iDocumentNo =
                            PWWrapper.aaApi_GetDocumentNumericProperty(PWWrapper.DocumentProperty.ID, 0);
                    }
                }
            }
            catch (Exception ex)
            {
                BPSUtilities.WriteLog($"Error: {ex.Message}\n{ex.StackTrace}");
            }

            return(bRetVal);
        }
Example #2
0
        public static void UpdatePWEnvVars(int lProjectNo, int lDocumentNo)
        {
            if (1 == PWWrapper.aaApi_SelectDocument(lProjectNo, lDocumentNo))
            {
                Bentley.DgnPlatformNET.ConfigurationVariableLevel level = Bentley.DgnPlatformNET.ConfigurationVariableLevel.Application;

                Bentley.DgnPlatformNET.ConfigurationManager.DefineVariable("PWVAR_VAULTID", $"{lProjectNo}", level);
                Bentley.DgnPlatformNET.ConfigurationManager.DefineVariable("PWVAR_DOCID", $"{lDocumentNo}", level);
                Bentley.DgnPlatformNET.ConfigurationManager.DefineVariable("PWVAR_ORIGINALNO",
                                                                           $"{PWWrapper.aaApi_GetDocumentNumericProperty(PWWrapper.DocumentProperty.OriginalNumber, 0)}", level);
                Bentley.DgnPlatformNET.ConfigurationManager.DefineVariable("PWVAR_DOCNAME",
                                                                           $"{PWWrapper.aaApi_GetDocumentStringProperty(PWWrapper.DocumentProperty.Name, 0)}", level);
                Bentley.DgnPlatformNET.ConfigurationManager.DefineVariable("PWVAR_FILENAME",
                                                                           $"{PWWrapper.aaApi_GetDocumentStringProperty(PWWrapper.DocumentProperty.FileName, 0)}", level);
                Bentley.DgnPlatformNET.ConfigurationManager.DefineVariable("PWVAR_DOCDESC",
                                                                           $"{PWWrapper.aaApi_GetDocumentStringProperty(PWWrapper.DocumentProperty.Desc, 0)}", level);
                Bentley.DgnPlatformNET.ConfigurationManager.DefineVariable("PWVAR_DOCVERSION",
                                                                           $"{PWWrapper.aaApi_GetDocumentStringProperty(PWWrapper.DocumentProperty.Version, 0)}", level);
                Bentley.DgnPlatformNET.ConfigurationManager.DefineVariable("PWVAR_DOCCREATETIME",
                                                                           $"{PWWrapper.aaApi_GetDocumentStringProperty(PWWrapper.DocumentProperty.CreateTime, 0)}", level);
                Bentley.DgnPlatformNET.ConfigurationManager.DefineVariable("PWVAR_DOCUPDATETIME",
                                                                           $"{PWWrapper.aaApi_GetDocumentStringProperty(PWWrapper.DocumentProperty.UpdateTime, 0)}", level);
                Bentley.DgnPlatformNET.ConfigurationManager.DefineVariable("PWVAR_DOCFILEUPDATETIME",
                                                                           $"{PWWrapper.aaApi_GetDocumentStringProperty(PWWrapper.DocumentProperty.FileUpdateTime, 0)}", level);
                Bentley.DgnPlatformNET.ConfigurationManager.DefineVariable("PWVAR_DOCLASTRTLOCKTIME",
                                                                           $"{PWWrapper.aaApi_GetDocumentStringProperty(PWWrapper.DocumentProperty.LastRtLockTime, 0)}", level);
                Bentley.DgnPlatformNET.ConfigurationManager.DefineVariable("PWVAR_DOCWORKFLOW",
                                                                           $"{PWWrapper.GetWorkflowName(PWWrapper.aaApi_GetDocumentNumericProperty(PWWrapper.DocumentProperty.WorkFlowID, 0))}", level);
                Bentley.DgnPlatformNET.ConfigurationManager.DefineVariable("PWVAR_DOCWORKFLOWSTATE",
                                                                           $"{PWWrapper.GetStateName(PWWrapper.aaApi_GetDocumentNumericProperty(PWWrapper.DocumentProperty.StateID, 0))}", level);
                Bentley.DgnPlatformNET.ConfigurationManager.DefineVariable("PWVAR_VAULTPATHNAME",
                                                                           $"{PWWrapper.GetProjectNamePath2(lProjectNo)}", level);
                Bentley.DgnPlatformNET.ConfigurationManager.DefineVariable("PWVAR_FULLFILEPATHNAME",
                                                                           $"{PWWrapper.GetDocumentNamePath(lProjectNo, lDocumentNo)}", level);
                Bentley.DgnPlatformNET.ConfigurationManager.DefineVariable("PWVAR_DOCGUID",
                                                                           $"{PWWrapper.GetGuidStringFromIds(lProjectNo, lDocumentNo)}", level);
                Bentley.DgnPlatformNET.ConfigurationManager.DefineVariable("PWVAR_DOCLINK",
                                                                           $"{PWWrapper.GetDocumentURL(lProjectNo, lDocumentNo)}", level);

                if (1 == PWWrapper.aaApi_SelectProject(lProjectNo))
                {
                    Bentley.DgnPlatformNET.ConfigurationManager.DefineVariable("PWVAR_VAULTNAME",
                                                                               $"{PWWrapper.aaApi_GetProjectStringProperty(PWWrapper.ProjectProperty.Name, 0)}", level);
                    Bentley.DgnPlatformNET.ConfigurationManager.DefineVariable("PWVAR_VAULTDESC",
                                                                               $"{PWWrapper.aaApi_GetProjectStringProperty(PWWrapper.ProjectProperty.Desc, 0)}", level);
                }

                System.Collections.Generic.SortedList <string, string> slProps = PWWrapper.GetProjectPropertyValuesInList(lProjectNo);

                foreach (System.Collections.Generic.KeyValuePair <string, string> kvp in slProps)
                {
                    Bentley.DgnPlatformNET.ConfigurationManager.DefineVariable($"PWVAR_PROJPROP_{kvp.Key.ToUpper().Replace(" ", "_")}",
                                                                               kvp.Value, level);
                }

                System.Collections.Generic.SortedList <string, string> slAttrs = PWWrapper.GetAllAttributeColumnValuesInList(lProjectNo, lDocumentNo);

                foreach (System.Collections.Generic.KeyValuePair <string, string> kvp in slAttrs)
                {
                    Bentley.DgnPlatformNET.ConfigurationManager.DefineVariable($"PWVAR_ATTR_{kvp.Key.ToUpper().Replace(" ", "_")}",
                                                                               kvp.Value, level);
                }
            } // document selected
            else
            {
                BPSUtilities.WriteLog("Could not select document.");
            }
        }