コード例 #1
0
        protected override void OnClick()
        {
            if (!BaseClass.init)
            {
                BaseClass.init = Wrappers.aaApi_Initialize(0);
            }

            if (!BaseClass.loggedIn)
            {
                string        title      = "ProjectWise Login";
                StringBuilder dataSource = new StringBuilder("VDOT ProjectWise");
                string        user       = "";
                string        password   = "";
                IntPtr        login      = Wrappers.aaApi_LoginDlgExt(IntPtr.Zero, title, 0, dataSource, dataSource.Length, user, password, null);
                if (login.ToInt32() == 1)
                {
                    BaseClass.loggedIn = true;
                }
            }

            IntPtr        winHandle     = IntPtr.Zero;
            string        openFileTitle = "Open File";
            StringBuilder fileName      = new StringBuilder("\0");
            int           docID         = 0;
            int           prjIDRet      = 0;

            //IntPtr openFile = Wrappers.aaApi_DocumentExtendedSelectDlg(winHandle, openFileTitle, prjID, appPtr, 0, count, ref docInfo, "", IntPtr.Zero);

            //**Puts all files from folder into buffer**
            IntPtr openFile = Wrappers.aaApi_SelectDocumentDlg(winHandle, openFileTitle, 0, ref prjIDRet, ref docID);

            if (openFile.ToInt32() == 1)
            {
                int    docSelect = Wrappers.aaApi_SelectDocument(prjIDRet, docID);
                string docName   = Wrappers.aaApi_GetDocumentStringProperty(Wrappers.DocumentProperty.Name, 0);
                docName = docName.Replace("shp", "");
                string searchName  = docName + "%";
                int    shpFilesCnt = Wrappers.aaApi_SelectDocumentsByNameProp(prjIDRet, null, searchName, null, null);
                string currentShp  = "";

                for (int i = 0; i < shpFilesCnt; i += 1)
                {
                    int    docIDShp   = Wrappers.aaApi_GetDocumentNumericProperty(Wrappers.DocumentProperty.ID, i);
                    string docNameShp = Wrappers.aaApi_GetDocumentStringProperty(Wrappers.DocumentProperty.Name, i);

                    StringBuilder fileNameShp = new StringBuilder(1024);
                    bool          checkOut    = Wrappers.aaApi_CheckOutDocument(prjIDRet, docIDShp, null, fileNameShp, 1024);
                    if (docNameShp.EndsWith(".shp"))
                    {
                        currentShp = docNameShp;
                    }
                    Doc file = new Doc();
                    file.DocID = docIDShp;

                    file.Docpath = fileNameShp.ToString();
                    file.PrjID   = prjIDRet;

                    BaseClass.pwShpFiles.Add(docNameShp, file);
                }


                if (BaseClass.pwShpFiles.Count != 0)
                {
                    foreach (string key in BaseClass.pwShpFiles.Keys.ToList())
                    {
                        if (key == currentShp)
                        {
                            AddLayer(BaseClass.pwShpFiles[key].Docpath);
                        }
                    }
                }

                else
                {
                    ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show($"No Files to Add");
                }
            }

            else if (openFile.ToInt32() == 3)
            {
                ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show($"Error opening Open Dialog Window");
            }
        }