コード例 #1
0
        public string CreateOrUpdateBimInfo(EventHandlerEnvironment env)
        {
            var ts = GetTrace(MethodBase.GetCurrentMethod().Name);

            var vault = env.Vault;

            try
            {
                var model = ModelUtility.FromZippedContent(env.Input, JsonConvert.DeserializeObject <MfProjectModel>);//JsonConvert.DeserializeObject<MfProjectModel>(info);
                ts.TraceInformation("输入信息:" + model.Model.Name);
                ts.TraceInformation("楼层个数: " + model.Model.Levels.Count);
                ts.TraceInformation("材料个数: " + model.Model.Materials.Count);
                ts.TraceInformation("视图个数: " + model.Model.Views.Count);
                ts.TraceInformation("类别个数: " + model.Model.Categories.Count);
                ts.TraceInformation("类型个数: " + model.Model.Types.Count);
                ts.TraceInformation(" 族个数: " + model.Model.Families.Count);
                ts.TraceInformation("构件个数: " + model.Model.Elements.Count);
                try
                {
                    var aliases = VaultAliases.GetAliases(vault);
                    var dict    = model.Run(aliases);
                    return(ModelUtility.GetZippedContent(dict, ToJson));
                }
                catch (Exception ex)
                {
                    ts.TraceEvent(TraceEventType.Error, 0, "运行失败:" + ex.Message + "r\n" + ex.StackTrace);
                    return(ModelUtility.GetZippedContent("运行失败:" + ex.Message, s => s.ToString()));
                }
            }
            catch (Exception ex)
            {
                ts.TraceEvent(TraceEventType.Error, 0, "获取信息失败:" + ex.Message + "r\n" + ex.StackTrace);
                return(ModelUtility.GetZippedContent("获取信息失败:" + ex.Message, s => s.ToString()));
            }
            finally
            {
                ts.Close();
            }
        }