コード例 #1
0
        /// <summary>
        /// ReadPNote is read Note in general, can be from database, can be from dwg depends on current situation.
        /// If dwgPNote is opened, is active or not, is modified or not (can't check whether or not it is modied), refer to read from DWG and updateDatabase.
        /// If dwgPNote is Not open check date, if if equals, read from database.
        /// Else: read from file + udpate todatabase.
        /// FK IT, JUST FOUND DOWN THE INTEROPT SHIT
        /// </summary>
        /// <param name="connection"></param>
        /// <returns></returns>
        public static NODEDWG ReadDataPNode(SQLiteConnection connection)
        {
            NODEDWG note = null;

            string notePath = GoodiesPath.GetNotePathFromADwgPath(Application.DocumentManager.MdiActiveDocument.Name, connection);

            if (!string.IsNullOrEmpty(notePath))
            {
                if (Goodies.GetListOfDocumentOpening().Contains(notePath))
                {
                    Document doc = Goodies.GetDocumentFromDwgpath(notePath);

                    if (doc == null)
                    {
                        Application.ShowAlertDialog("ReadDwgNoteFile -> There is no Document, weird!");
                        return(null);
                    }

                    AcadDocument acadDoct = (AcadDocument)doc.GetAcadDocument();
                    if (acadDoct.Saved && GoodiesPath.IsDateTheSame(notePath, connection))
                    {
                        note = ReadFromDatabase(connection);
                    }
                    else
                    {
                        using (Database db = doc.Database)
                        {
                            note = GetData(db, connection);
                        }
                    }
                }
                else
                {
                    Database db = new Database();
                    try
                    {
                        if (GoodiesPath.IsDateTheSame(notePath, connection))
                        {
                            note = ReadFromDatabase(connection);
                        }
                        else
                        {
                            db.ReadDwgFile(notePath, FileOpenMode.OpenForReadAndAllShare, false, "");
                            note = GetData(db, connection);
                        }
                    }catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                }
            }

            return(note);
        }