public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication            uiapp         = commandData.Application;
            UIDocument               uidoc         = uiapp.ActiveUIDocument;
            Document                 doc           = uidoc.Document;
            FilteredElementCollector roomCollector = RoomIntial.
                                                     RoomCollector(doc);
            DataTable dt = RoomIntial.CreateRoomExcelTitle();

            //这里有问题MMP
            RoomIntial.RoomElementExcelPara(doc, roomCollector, dt);
            TaskDialog.Show("EXCEL放置位置", excelPath.ToString());
            LChuDemo.dataTableToCsv(dt, excelPath);
            System.Diagnostics.Process.Start(excelPath);

            //这里是倒进数据库
            dt           = RoomIntial.CreateRoomMySQLTitle();
            dt.TableName = "RoomTable";
            RoomIntial.RoomElementMySQLPara(doc, roomCollector, dt);
            string connStr = "server=localhost;database=mytest;uid=root;pwd=123456";
            var    result  = MySQLIntial.BulkInsert(connStr, dt, 4);

            if (result != 0.0)
            {
                TaskDialog.Show("导出到MYSQL中成功", "数据已经存入" + "数据库mytest" + dt.TableName + "中");
            }
            return(Result.Succeeded);
        }
 public static void RoomElementExcelPara(Document doc, FilteredElementCollector roomCollector, DataTable dt)
 {
     foreach (Element ele in roomCollector)
     {
         Room  room  = ele as Room;
         Level level = doc.GetElement(room.LevelId) as Level;
         if (room != null)
         {
             string number       = null;
             string name         = null;
             double area         = 0.0;
             double tpoffset     = 0.0;
             double bottomoffset = 0.0;
             foreach (Parameter param in room.Parameters)
             {
                 InternalDefinition definition = param.Definition as InternalDefinition;
                 if (null == definition)
                 {
                     continue;
                 }
                 if (BuiltInParameter.ROOM_NUMBER == definition.BuiltInParameter)
                 {
                     number = param.AsString();
                 }
                 if (BuiltInParameter.ROOM_NAME == definition.BuiltInParameter)
                 {
                     name = param.AsString();
                 }
                 if (BuiltInParameter.ROOM_AREA == definition.BuiltInParameter)
                 {
                     area = param.AsDouble();
                 }
                 if (BuiltInParameter.ROOM_LOWER_OFFSET == definition.BuiltInParameter)
                 {
                     bottomoffset = param.AsDouble();
                 }
                 if (BuiltInParameter.ROOM_UPPER_OFFSET == definition.BuiltInParameter)
                 {
                     tpoffset = param.AsDouble();
                 }
             }
             //怎么 又是这里有问题MMP
             RoomIntial.
             CreateRoomExcelRow(dt, number, name, level.Name, FeetTomm(bottomoffset), FeetTomm(area)
                                , FeetTomm(tpoffset));
         }
     }
 }