Exemple #1
0
        private List <MfProjectModel> GetPartModel(MfModelDicts dicts, ModelLists list, TraceSource ts, string url)
        {
            var ms    = new List <MfProjectModel>();
            var m     = (ProjectModel)_model;
            var group = MfProjectModel.GroupArrays(m.Elements, MaxCount);

            ts.TraceInformation("分组个数:" + group.Count);
            foreach (var g in group)
            {
                ts.TraceInformation("每组个数:" + g.Count);
                var pModel = new MfProjectModel {
                    Dicts = dicts, ModelUrl = url
                };
                FillModelProps(pModel);
                var mm = new ProjectModel {
                    Id = m.Id, Name = m.Name, Project = m.Project
                };
                mm.Elements.AddRange(g);
                pModel.Model = mm;
                pModel.Lists = list;
                ms.Add(pModel);
            }

            return(ms);
        }
Exemple #2
0
        private void FillModelProps(MfProjectModel model)
        {
            var modelAt = _aliases.PdDict[PD.ModelUnitAt];
            var floorAt = _aliases.PdDict[PD.FloorAt];
            var discAt  = _aliases.PdDict[PD.DiscAt];
            var props   = _vault.ObjectPropertyOperations.GetProperties(_obj.ObjVer);

            if (modelAt != -1)
            {
                var modelPV = props.SearchForPropertyEx(modelAt, true);
                if (modelPV != null && !modelPV.Value.IsNULL())
                {
                    model.UnitId = modelPV.Value.GetLookupID();
                }
            }
            if (floorAt != -1)
            {
                var floorPV = props.SearchForPropertyEx(floorAt, true);
                if (floorPV != null && !floorPV.Value.IsNULL())
                {
                    model.FloorId = floorPV.Value.GetLookupID();
                }
            }
            if (discAt != -1)
            {
                var discPV = props.SearchForPropertyEx(discAt, true);
                if (discPV != null && !discPV.Value.IsNULL())
                {
                    model.DiscId = discPV.Value.GetLookupID();
                }
            }
        }
Exemple #3
0
        private void OperateProjectModel()
        {
            if (!_model.IsProject)
            {
                throw new Exception("必须是项目模型");
            }
            var model       = (ProjectModel)_model;
            var url         = GetModelUrl();
            var mfProjModel = new MfProjectModel {
                Model = model, ModelUrl = url
            };

            FillModelProps(mfProjModel);
            mfProjModel.Run(_aliases);
        }
Exemple #4
0
        private MfProjectModel GetBasicModel(ModelLists list, string url)
        {
            var m      = (ProjectModel)_model;
            var pModel = new MfProjectModel {
                ModelUrl = url
            };

            FillModelProps(pModel);
            var mm = new ProjectModel();

            mm.Categories.AddRange(m.Categories);
            mm.Families.AddRange(m.Families);
            mm.Id = m.Id;
            mm.Levels.AddRange(m.Levels);
            mm.Materials.AddRange(m.Materials);
            mm.Name    = m.Name;
            mm.Project = m.Project;
            mm.Types.AddRange(m.Types);
            mm.Views.AddRange(m.Views);
            pModel.Model = mm;
            pModel.Lists = list;
            return(pModel);
        }
Exemple #5
0
        public string ServerRun(Func <object, string> toJson, Func <string, MfModelDicts> toDict, string modelUrl)
        {
            var hasExtensionMethod =
                _vault.ExtensionMethodOperations.DoesActiveVaultExtensionMethodExist(VaultExtensionMethodName);

            if (!hasExtensionMethod)
            {
                return("服务器未安装或启用扩展方法:" + VaultExtensionMethodName);
            }
            var log  = MfProjectModel.GetTrace <MfModel>();
            var list = ((ProjectModel)_model).GetLists();  //总的模型数据(元素唯一标识)列表

            //var basicModel = GetBasicModel(list);
            //var basicContent = ModelUtility.GetZippedContent(basicModel, toJson);
            //var basicInfo = _vault.ExtensionMethodOperations.ExecuteVaultExtensionMethod(VaultExtensionMethodName, basicContent);
            //var dict = ModelUtility.FromZippedContent<MfModelDicts>(basicInfo, toDict);

            var basicInfo = String.Empty;
            var partInfo  = String.Empty;
            var basicDict = new MfModelDicts();

            try
            {
                var bms = GetBasicModels(list, log, modelUrl);

                foreach (var bm in bms)
                {
                    var basicContent = ModelUtility.GetZippedContent(bm, toJson);
                    basicInfo = _vault.ExtensionMethodOperations.ExecuteVaultExtensionMethod(VaultExtensionMethodName, basicContent);
                    try
                    {
                        var pDict = ModelUtility.FromZippedContent <MfModelDicts>(basicInfo, toDict);
                        basicDict.AddFrom(pDict);
                    }
                    catch (Exception e)
                    {
                        var err = ModelUtility.FromZippedContent(basicInfo, s => s);
                        log.TraceEvent(TraceEventType.Warning, 0, err + "\r\n" + e.Message);
                        return(err);
                    }
                }


                var partModels = GetPartModel(basicDict, list, log, modelUrl);

                foreach (var partModel in partModels)
                {
                    var partContent = ModelUtility.GetZippedContent(partModel, toJson);
                    partInfo = _vault.ExtensionMethodOperations.ExecuteVaultExtensionMethod(VaultExtensionMethodName, partContent);
                    try
                    {
                        var pDict = ModelUtility.FromZippedContent <MfModelDicts>(partInfo, toDict);
                    }
                    catch (Exception e)
                    {
                        var err = ModelUtility.FromZippedContent(partInfo, s => s);
                        log.TraceEvent(TraceEventType.Warning, 0, err + "\r\n" + e.Message);
                        return(err);
                    }
                }

                return(String.Empty);
            }
            catch (Exception ex)
            {
                var errInfo = basicInfo;
                if (!String.IsNullOrEmpty(partInfo))
                {
                    errInfo = partInfo;
                }
                var err = ModelUtility.FromZippedContent(errInfo, s => s);
                log.TraceEvent(TraceEventType.Warning, 0, err + "\r\n" + ex.Message);
                return(err);
            }
            finally
            {
                log.Close();
            }
        }
Exemple #6
0
        private List <MfProjectModel> GetBasicModels(ModelLists list, TraceSource log, string url)
        {
            var listWithoutParts = new ModelLists();

            listWithoutParts.Cates.AddRange(list.Cates);
            listWithoutParts.Fams.AddRange(list.Fams);
            listWithoutParts.Floors.AddRange(list.Floors);
            listWithoutParts.Mats.AddRange(list.Mats);
            listWithoutParts.Types.AddRange(list.Types);
            listWithoutParts.Views.AddRange(list.Views);
            var m          = (ProjectModel)_model;
            var pModelList = new List <MfProjectModel>();

            if (m.Categories.Count + m.Families.Count + m.Levels.Count + m.Materials.Count + m.Types.Count +
                m.Views.Count < MaxCount)
            {
                var pModel = new MfProjectModel {
                    ModelUrl = url
                };
                FillModelProps(pModel);
                var mm = new ProjectModel {
                    Id = m.Id, Name = m.Name, Project = m.Project
                };
                mm.Categories.AddRange(m.Categories);
                mm.Families.AddRange(m.Families);
                mm.Levels.AddRange(m.Levels);
                mm.Views.AddRange(m.Views);
                mm.Materials.AddRange(m.Materials);
                mm.Types.AddRange(m.Types);
                pModel.Model = mm;
                pModel.Lists = listWithoutParts;
                pModelList.Add(pModel);
            }
            else
            {
                var pModel1 = new MfProjectModel {
                    ModelUrl = url
                };
                FillModelProps(pModel1);
                var mm1 = new ProjectModel {
                    Id = m.Id, Name = m.Name, Project = m.Project
                };
                mm1.Categories.AddRange(m.Categories);
                mm1.Families.AddRange(m.Families);
                mm1.Levels.AddRange(m.Levels);
                mm1.Views.AddRange(m.Views);
                mm1.Materials.AddRange(m.Materials);

                pModel1.Model = mm1;
                pModel1.Lists = listWithoutParts;
                pModelList.Add(pModel1);

                var pModel = new MfProjectModel {
                    ModelUrl = url
                };
                FillModelProps(pModel);
                var mm = new ProjectModel();
                mm.Id      = m.Id;
                mm.Name    = m.Name;
                mm.Project = m.Project;
                mm.Types.AddRange(m.Types);

                pModel.Model = mm;
                pModel.Lists = listWithoutParts;
                pModelList.Add(pModel);
            }

            return(pModelList);
        }