Пример #1
0
        /// <summary>
        /// 获取摘要信息中的自定义属性个数
        /// </summary>
        /// <param name="db">数据库对象</param>
        /// <returns>返回自定义属性个数</returns>
        public static int NumCustomProperties(this Database db)
        {
            DatabaseSummaryInfo info = db.SummaryInfo; //获取数据库摘要信息

            //获取摘要信息中的自定义属性集合
            System.Collections.IDictionaryEnumerator props = info.CustomProperties;
            int count = 0;           //计数器,用于统计自定义属性个数

            while (props.MoveNext()) //遍历自定义属性
            {
                count++;             //计数器累加
            }
            return(count);           //返回自定义属性个数
        }
Пример #2
0
        /// <summary>
        /// 判断图形中是否存在指定的自定义属性
        /// </summary>
        /// <param name="db">数据库对象</param>
        /// <param name="key">自定义属性的名称</param>
        /// <returns>如果存在指定的自定义属性,返回true,否则返回false</returns>
        public static bool HasCustomProperty(this Database db, string key)
        {
            DatabaseSummaryInfo info = db.SummaryInfo; //获取数据库摘要信息

            //获取摘要信息中的自定义属性集合
            System.Collections.IDictionaryEnumerator props = info.CustomProperties;
            while (props.MoveNext())//遍历自定义属性
            {
                //如果存在指定的自定义属性,返回true
                if (props.Key.ToString().ToUpper() == key.ToUpper())
                {
                    return(true);
                }
            }
            return(false);//不存在指定的自定义属性,返回false
        }
Пример #3
0
        /// <summary>
        /// 判断图形中是否存在摘要信息
        /// </summary>
        /// <param name="db">数据库对象</param>
        /// <returns>如果存在摘要信息,返回true,否则返回false</returns>
        public static bool HasSummaryInfo(this Database db)
        {
            //如果存在自定义属性,则说明肯定有摘要信息
            if (db.NumCustomProperties() > 0)
            {
                return(true);
            }
            DatabaseSummaryInfo info = db.SummaryInfo;//数据库的摘要信息

            //如果存在摘要信息,则返回true
            if (!info.Author.IsNullOrWhiteSpace() && !info.Comments.IsNullOrWhiteSpace() &&
                !info.HyperlinkBase.IsNullOrWhiteSpace() && !info.Keywords.IsNullOrWhiteSpace() &&
                !info.RevisionNumber.IsNullOrWhiteSpace() &&
                !info.Subject.IsNullOrWhiteSpace() && !info.Title.IsNullOrWhiteSpace())
            {
                return(true);
            }
            return(false);//不存在摘要信息,返回false
        }
Пример #4
0
        private string QueryBuilder(string variable, string column, string value)
        {
            int    AL  = 2;
            string sql = "";

            Document            acDoc     = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument; //Valitaan avoinna oleva dokumentti
            Database            acCurDb   = acDoc.Database;
            DatabaseSummaryInfo dbSumInfo = acCurDb.SummaryInfo;

            System.Collections.IDictionaryEnumerator info = dbSumInfo.CustomProperties;

            acDoc.Editor.WriteMessage("\nBuilding query for " + variable + "\n");

            while (info.MoveNext())
            {
                if (info.Key.Equals("IPIIRI"))
                {
                    AL = 0; break;
                }
                else if (info.Key.Equals("SPIIRI"))
                {
                    AL = 1; break;
                }
                else if (info.Key.Equals("DB") && DbConnection == null)
                {
                    string prop = String.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Persist Security Info = False; ", info.Value.ToString());
                    DbConnection = new OleDbConnection(prop);
                    DbConnection.Open();
                }
            }

            acDoc.Editor.WriteMessage(AL + "\n");

            info.Reset();
            while (info.MoveNext())
            {
                if (!info.Key.ToString().Contains("@"))
                {
                    IdentifierPairs.Add(
                        info.Key.ToString(),
                        info.Value.ToString());
                    acDoc.Editor.WriteMessage(info.Key.ToString() + " was added\n");
                }
                if (info.Key.ToString().Contains(variable) && !info.Key.ToString().Contains("@"))
                {
                    sql = "ID = " + info.Value;
                }
                else if (info.Key.ToString().Contains(variable))
                {
                    switch (info.Value.ToString().Substring(0, 1))
                    {
                    case "L":
                        break;

                    case "E":
                        break;

                    case "R":
                        sql = "UPDATE IKYTKENTA SET " + column + "='" + value + "' WHERE RIVITUNN = '" + info.Value.ToString().Substring(2, info.Value.ToString().Length - 3) + "' ";
                        string val;
                        IdentifierPairs.TryGetValue(info.Key.ToString().Substring(info.Key.ToString().IndexOf("@") + 1), out val);
                        sql = sql + "AND LAITE_KIR = '" + val.Substring(2, val.ToString().Length - 3) + "' AND ";
                        break;

                    case "T":
                        break;

                    case "P":
                        break;

                    case "V":
                        break;

                    case "A":
                        break;

                    case "S":
                        break;

                    case "K":
                        break;

                    case "O":
                        break;

                    case "F":
                        break;

                    case "M":
                        break;

                    case "C":
                        break;
                    }
                    break;
                }
            }

            IdentifierPairs.Clear();

            if (AL == 0)
            {
                sql = sql + "POSITIO = (SELECT POSITIO FROM IPIIRI WHERE TMALLI = '" + Path.GetFileNameWithoutExtension(acDoc.Name) + "')";
            }
            else if (AL == 1)
            {
            }

            acDoc.Editor.WriteMessage(sql + "\n");

            return(sql);
        }
Пример #5
0
        static int Main(string[] args)
        {
            int nRes = 0; // Return value for main

            /**********************************************************************/
            /* Set command line defaults                                          */
            /**********************************************************************/
            SaveType   fileType    = SaveType.Save12;
            DwgVersion outVer      = DwgVersion.AC1021;
            bool       disableWait = false;

            /**********************************************************************/
            /* Initialize Teigha                                                  */
            /**********************************************************************/
            using (Services svcs = new Services())
            {
                /**********************************************************************/
                /* Display the Product and Version that created the executable        */
                /**********************************************************************/
                Console.WriteLine("\nOdWriteEx developed using %ls ver %ls");

                /**********************************************************************/
                /* Parse Command Line inputs                                          */
                /**********************************************************************/
                bool bInvalidArgs = (args.Length < 2);
                if (bInvalidArgs)
                {
                    bInvalidArgs = true;
                    nRes         = 1;
                }

                /**********************************************************************/
                /* Set file version                                                   */
                /**********************************************************************/
                if (args.Length >= 2)
                {
                    string argv2 = args[1];
                    switch (argv2)
                    {
                    case "ACAD12":
                        outVer = DwgVersion.vAC12;
                        break;

                    case "ACAD13":
                        outVer = DwgVersion.vAC13;
                        break;

                    case "ACAD14":
                        outVer = DwgVersion.vAC14;
                        break;

                    case "ACAD2000":
                        outVer = DwgVersion.vAC15;
                        break;

                    case "ACAD2004":
                        outVer = DwgVersion.vAC18;
                        break;

                    case "ACAD2007":
                        outVer = DwgVersion.vAC21;
                        break;

                    case "ACAD2010":
                        outVer = DwgVersion.vAC24;
                        break;

                    default:
                        bInvalidArgs = true;
                        nRes         = 1;
                        break;
                    }
                }

                /**********************************************************************/
                /* Set file type                                                      */
                /**********************************************************************/
                if (args.Length >= 3)
                {
                    string argv3 = args[2];
                    switch (argv3)
                    {
                    case "DWG":
                        fileType = SaveType.Save12;
                        break;

                    case "DXF":
                        fileType = SaveType.Save13;
                        break;

                    default:
                        bInvalidArgs = true;
                        nRes         = 1;
                        break;
                    }
                }

                /**********************************************************************/
                /* Disable prompt of pressing ENTER                                   */
                /**********************************************************************/
                if (args.Length >= 4)
                {
                    string argv4 = args[3];
                    if (argv4 == "-NoWait")
                    {
                        disableWait = true;
                    }
                }

                if (bInvalidArgs)
                {
                    Console.WriteLine("\n\n\tusage: OdWriteEx <filename> [OutVer] [OutType] [-NoWait]");
                    Console.WriteLine("\n\tOutVer can be any of ACAD12, ACAD13, ACAD14, ACAD2000, ACAD2004, ACAD2007, ACAD2010\n");
                    Console.WriteLine("\n\tOutType can be any of DWG, DXF\n");
                    Console.WriteLine("\n\t-NoWait disables prompt of pressing ENTER at the end of execution.\n");
                    return(nRes);
                }

                /**********************************************************************/
                /* Load and Release RecomputeDimBlock                                 */
                /**********************************************************************/
                //::odrxDynamicLinker()->loadApp(TD_T("RecomputeDimBlock")).release();
                //::odrxDynamicLinker()->loadApp(TD_T("ExFieldEvaluator")).release();

                /**********************************************************************/
                /* Find the folder of the output file                                 */
                /**********************************************************************/
                string outputFolder = args[0];
                outputFolder = Path.GetDirectoryName(outputFolder);
                FileStreamBuf fileBuf = new FileStreamBuf(args[0], false, FileShareMode.DenyNo, FileCreationDisposition.CreateAlways);

                try
                {
                    /********************************************************************/
                    /* Create a default OdDbDatabase object                             */
                    /********************************************************************/
                    using (Database pDb = new Database())
                    {
                        DatabaseSummaryInfo        pSumInfo = pDb.SummaryInfo;
                        DatabaseSummaryInfoBuilder builder  = new DatabaseSummaryInfoBuilder(pSumInfo);
                        builder.Title    = "Title";
                        builder.Author   = "Author";
                        builder.Comments = "Comments";
                        builder.Comments = "File was created by OdWriteEx";
                        pDb.SummaryInfo  = builder.ToDatabaseSummaryInfo();

                        /********************************************************************/
                        /* Fill the database                                                */
                        /********************************************************************/
                        HostApplicationServices.WorkingDatabase = pDb;
                        DbFiller filler = new DbFiller();
                        filler.fillDatabase(pDb);

                        /********************************************************************/
                        /* Audit the database                                               */
                        /********************************************************************/
                        using (AuditInfo aiAppAudit = new CustomAuditInfo(outputFolder + "AuditReport.txt"))
                        {
                            aiAppAudit.FixErrors = true;
                            Console.WriteLine("\n\n");
                            pDb.Audit(aiAppAudit);
                        }
                        #region TODO block
                        //{
                        //  OdSecurityParams securityParams;
                        //  securityParams.password = "******";
                        //  securityParams.nFlags = 1;
                        //  securityParams.nProvType = 0xd;

                        //  // L"Microsoft Base DSS and Diffie-Hellman Cryptographic Provider"
                        //  static wchar_t pn[] =
                        //  {
                        //    0x4D, 0x69, 0x63, 0x72, 0x6F,
                        //    0x73, 0x6F, 0x66, 0x74, 0x20,
                        //    0x42, 0x61, 0x73, 0x65, 0x20,
                        //    0x44, 0x53, 0x53, 0x20, 0x61,
                        //    0x6E, 0x64, 0x20, 0x44, 0x69,
                        //    0x66, 0x66, 0x69, 0x65, 0x2D,
                        //    0x48, 0x65, 0x6C, 0x6C, 0x6D,
                        //    0x61, 0x6E, 0x20, 0x43, 0x72,
                        //    0x79, 0x70, 0x74, 0x6F, 0x67,
                        //    0x72, 0x61, 0x70, 0x68, 0x69,
                        //    0x63, 0x20, 0x50, 0x72, 0x6F,
                        //    0x76, 0x69, 0x64, 0x65, 0x72,
                        //    0x00
                        //  };
                        //  securityParams.provName = pn;

                        //  /************************************************************************/
                        //  /* Uncomment the following line to add the password TD_T("Teigha") to the  */
                        //  /* R18+ file to be created                                              */
                        //  /************************************************************************/
                        //  //pDb->setSecurityParams(securityParams);
                        //}
                        #endregion
                        /********************************************************************/
                        /* Write the database                                               */
                        /********************************************************************/
                        pDb.SaveAs(fileBuf, fileType, outVer, true, 16);

                        /*if (SaveType.Save12 == fileType)
                         * {
                         * pDb.SaveAs(args[0], outVer);
                         * }
                         * else
                         * pDb.DxfOut(args[0], 16, outVer);//16 - default*/
                        Console.WriteLine("\nDatabase has been saved as {0}", pDb.Filename);
                    }
                }
                catch (System.Exception e)
                {
                    Console.WriteLine("\n\nError: {0}", e.Message);
                    nRes = -1;
                }
            }

            if (nRes != 0)
            {
                Console.WriteLine("\n\nPress ENTER to continue...");
                if (!disableWait)
                {
                    Console.ReadLine();
                }
            }
            Console.WriteLine("\n\n");
            return(nRes);
        }