예제 #1
0
        private static void SaveEntityStaticData(DiskModel model, Entity item, ModelManagement.Entity.configuration node)
        {
            if (item.StaticDatum.Count == 0)
            {
                return;
            }

            var nodeData = new nHydrate.ModelManagement.StaticData.configuration();

            nodeData.id   = item.Id.ToString();
            nodeData.type = "entity.staticdata";

            var nodeDataItems = new List <ModelManagement.StaticData.configurationData>();

            foreach (var data in item.StaticDatum)
            {
                var nodeDataItem = new ModelManagement.StaticData.configurationData();
                nodeDataItems.Add(nodeDataItem);
                nodeDataItem.columnkey = data.ColumnKey.ToString();
                nodeDataItem.orderkey  = data.OrderKey;
                nodeDataItem.value     = data.Value;
            }
            nodeData.data = nodeDataItems.ToArray();
            model.StaticData.Add(nodeData);
        }
예제 #2
0
    //随机获取一种空闲飞碟,如果飞碟不足则新建一个实例
    public DiskModel getDisk()
    {
        //随机从三种预制中选择一个飞碟外观
        int       type = Random.Range(0, 3);
        DiskModel disk;

        //尝试获取已经被创建但目前处于空闲态的飞碟
        for (int i = 0; i < size[type]; i++)
        {
            if (diskStatus[type, i] == false)
            {
                diskStatus[type, i] = true;
                disks[type][i].disk.SetActive(true);
                disk = disks[type][i];
                disk.setDiskID(diskID);
                diskID++;
                //取出时飞碟不能够有爆炸特效
                disk.disk.GetComponent <ParticleSystem>().Stop();
                return(disk);
            }
        }

        //当前没有可用的空闲飞碟,需要创建
        disk = new DiskModel(type, diskID);
        diskID++;
        disks[type].Add(disk);
        diskStatus[type, size[type]] = true;
        size[type]++;
        disk.disk.GetComponent <ParticleSystem>().Stop();
        return(disk);
    }
예제 #3
0
        private static void SaveEntityIndexes(DiskModel model, Entity item, ModelManagement.Entity.configuration node)
        {
            var root = new ModelManagement.Index.configuration();

            model.Indexes.Add(root);
            root.id   = item.Id.ToString();
            root.type = "entity.indexes";

            var nodeFields = new List <ModelManagement.Index.configurationIndex>();

            foreach (var index in item.Indexes)
            {
                var nodeField = new ModelManagement.Index.configurationIndex();
                nodeFields.Add(nodeField);
                nodeField.clustered    = index.Clustered.ToByte();
                nodeField.id           = index.Id.ToString();
                nodeField.importedname = index.ImportedName;
                nodeField.indextype    = (byte)index.IndexType;
                nodeField.isunique     = index.IsUnique.ToByte();
                nodeField.summary      = index.Summary;

                var nodeIndexColumns = new List <ModelManagement.Index.configurationIndexColumn>();
                foreach (var indexColumn in index.IndexColumns)
                {
                    var nodeIndexColumn = new ModelManagement.Index.configurationIndexColumn();
                    nodeIndexColumns.Add(nodeIndexColumn);
                    nodeIndexColumn.ascending = indexColumn.Ascending.ToByte();
                    nodeIndexColumn.fieldid   = indexColumn.FieldID.ToString();
                    nodeIndexColumn.id        = indexColumn.Id.ToString();
                    nodeIndexColumn.sortorder = indexColumn.SortOrder;
                }
                nodeField.indexcolumnset = nodeIndexColumns.ToArray();
            }
        }
예제 #4
0
        private static void LoadEntityIndexes(Entity entity, DiskModel diskModel)
        {
            foreach (var indexNode in diskModel.Indexes.Where(x => new Guid(x.id) == entity.Id).SelectMany(x => x.index))
            {
                var id       = new Guid(indexNode.id);
                var newIndex = entity.Indexes.FirstOrDefault(x => x.Id == id);
                if (newIndex == null)
                {
                    newIndex = new Index(entity.Partition, new PropertyAssignment[] { new PropertyAssignment(ElementFactory.IdPropertyAssignment, id) });
                    entity.Indexes.Add(newIndex);
                }
                newIndex.Clustered    = indexNode.clustered != 0;
                newIndex.ImportedName = indexNode.importedname;
                newIndex.IndexType    = (IndexTypeConstants)indexNode.indextype;
                newIndex.IsUnique     = indexNode.isunique != 0;

                foreach (var indexColumnNode in indexNode.indexcolumnset)
                {
                    id = new Guid(indexColumnNode.id);
                    var newIndexColumn = newIndex.IndexColumns.FirstOrDefault(x => x.Id == id);
                    if (newIndexColumn == null)
                    {
                        newIndexColumn = new IndexColumn(entity.Partition, new PropertyAssignment[] { new PropertyAssignment(ElementFactory.IdPropertyAssignment, id) });
                        newIndex.IndexColumns.Add(newIndexColumn);
                    }
                    newIndexColumn.Ascending  = indexColumnNode.ascending != 0;
                    newIndexColumn.FieldID    = new Guid(indexColumnNode.fieldid);
                    newIndexColumn.SortOrder  = indexColumnNode.sortorder;
                    newIndexColumn.IsInternal = true;
                }
            }
        }
예제 #5
0
        private static void LoadEntityRelations(Entity entity, DiskModel diskModel)
        {
            foreach (var relationNode in diskModel.Relations.Where(x => new Guid(x.id) == entity.Id).SelectMany(x => x.relation))
            {
                var childid = new Guid(relationNode.childid);
                var child   = entity.nHydrateModel.Entities.FirstOrDefault(x => x.Id == childid);
                if (child != null)
                {
                    entity.ChildEntities.Add(child);
                    var connection = entity.Store.CurrentContext.Partitions.First().Value.ElementDirectory.AllElements.Last() as EntityHasEntities;
                    connection.InternalId   = new Guid(relationNode.id);
                    connection.IsEnforced   = relationNode.isenforced != 0;
                    connection.DeleteAction = (DeleteActionConstants)Enum.Parse(typeof(DeleteActionConstants), relationNode.deleteaction);
                    connection.RoleName     = relationNode.rolename;

                    foreach (var relationFieldNode in relationNode.relationfieldset)
                    {
                        var sourceFieldID = new Guid(relationFieldNode.sourcefieldid);
                        var targetFieldID = new Guid(relationFieldNode.targetfieldid);
                        var sourceField   = entity.Fields.FirstOrDefault(x => x.Id == sourceFieldID);
                        var targetField   = entity.nHydrateModel.Entities.SelectMany(x => x.Fields).FirstOrDefault(x => x.Id == targetFieldID);
                        if ((sourceField != null) && (targetField != null))
                        {
                            var id = new Guid(relationFieldNode.id);
                            var newRelationField = new RelationField(entity.Partition, new PropertyAssignment[] { new PropertyAssignment(ElementFactory.IdPropertyAssignment, id) });
                            newRelationField.SourceFieldId = sourceFieldID;
                            newRelationField.TargetFieldId = targetFieldID;
                            newRelationField.RelationID    = connection.Id;
                            entity.nHydrateModel.RelationFields.Add(newRelationField);
                        }
                    }
                }
            }
        }
예제 #6
0
        private static void SaveRelations(DiskModel model, Entity item, ModelManagement.Entity.configuration node)
        {
            var nodeData = new nHydrate.ModelManagement.Relation.configuration();

            nodeData.id   = item.Id.ToString();
            nodeData.type = "entity.relations";

            var nodeRelations = new List <ModelManagement.Relation.configurationRelation>();

            foreach (var relation in item.RelationshipList)
            {
                var nodeRelationItem = new ModelManagement.Relation.configurationRelation();
                nodeRelations.Add(nodeRelationItem);
                nodeRelationItem.childid      = relation.ChildEntity.Id.ToString();
                nodeRelationItem.deleteaction = relation.DeleteAction.ToString();
                nodeRelationItem.id           = relation.InternalId.ToString();
                nodeRelationItem.isenforced   = relation.IsEnforced.ToByte();
                nodeRelationItem.rolename     = relation.RoleName;
                nodeRelationItem.summary      = relation.Summary;

                var nodeRelationFields = new List <ModelManagement.Relation.configurationRelationField>();
                foreach (var relationField in relation.FieldMapList())
                {
                    var nodeRelationField = new ModelManagement.Relation.configurationRelationField();
                    nodeRelationFields.Add(nodeRelationField);
                    nodeRelationField.id            = relationField.Id.ToString();
                    nodeRelationField.sourcefieldid = relationField.SourceFieldId.ToString();
                    nodeRelationField.targetfieldid = relationField.TargetFieldId.ToString();
                }
                nodeRelationItem.relationfieldset = nodeRelationFields.ToArray();
            }
            nodeData.relation = nodeRelations.ToArray();
            model.Relations.Add(nodeData);
        }
예제 #7
0
        /// <summary>
        /// Saves Views to disk
        /// </summary>
        private static void SaveToDisk(DiskModel model, IEnumerable <View> list)
        {
            #region Save other parameter/field information
            foreach (var item in list)
            {
                var node = new nHydrate.ModelManagement.View.configuration();
                model.Views.Add(node);
                node.codefacade             = item.CodeFacade;
                node.generatesdoublederived = item.GeneratesDoubleDerived.ToByte();
                node.id      = item.Id.ToString();
                node.name    = item.Name;
                node.schema  = item.Schema;
                node.summary = item.Summary;
                node.type    = "view";
                #endregion

                var nodeFields = new List <ModelManagement.View.configurationField>();
                foreach (var field in item.Fields.OrderBy(x => x.Name))
                {
                    var nodeField = new ModelManagement.View.configurationField();
                    nodeFields.Add(nodeField);
                    nodeField.codefacade   = field.CodeFacade;
                    nodeField.datatype     = field.DataType.ToString();
                    nodeField.@default     = field.Default;
                    nodeField.id           = field.Id.ToString();
                    nodeField.isprimarykey = field.IsPrimaryKey.ToByte();
                    nodeField.length       = field.Length;
                    nodeField.name         = field.Name;
                    nodeField.nullable     = field.Nullable.ToByte();
                    nodeField.scale        = (byte)field.Scale;
                    nodeField.summary      = field.Summary;
                }
            }
        }
예제 #8
0
    //发送飞碟
    private void sendDisk()
    {
        diskCount++;
        DiskModel disk = diskFactory.getDisk(); //从工厂获取新的飞碟

        currentDisks.Add(disk);                 //将新飞碟加入到当前的列表
        actionManager.UFOFly(disk);             //令飞碟进行移动
    }
예제 #9
0
    //暂停几秒后回收飞碟
    IEnumerator WaitingParticle(float wait_time, DiskFactory diskFactory, DiskModel hitDisk)
    {
        yield return(new WaitForSeconds(wait_time));

        hitDisk.disk.SetActive(false);
        hitDisk.disk.GetComponent <ParticleSystem>().Stop();
        currentDisks.Remove(hitDisk);
        actionManager.freeAction(hitDisk);
        diskFactory.FreeDisk(hitDisk);
        diskCount--;
    }
예제 #10
0
 private static void LoadEntityStaticData(Entity entity, DiskModel diskModel)
 {
     foreach (var dataNode in diskModel.StaticData.Where(x => new Guid(x.id) == entity.Id).SelectMany(x => x.data))
     {
         var newData = new StaticData(entity.Partition);
         entity.StaticDatum.Add(newData);
         newData.OrderKey  = dataNode.orderkey;
         newData.Value     = dataNode.value;
         newData.ColumnKey = new Guid(dataNode.columnkey);
     }
 }
예제 #11
0
 public void freeAction(DiskModel disk)
 {
     for (int i = 0; i < 20; i++)
     {
         //当飞碟不再需要时,actionManager可以简单的将对应的action设为空闲,而非直接删除 action
         if (diskID[i] == disk.getDiskID())
         {
             diskID[i] = -1;
             break;
         }
     }
 }
예제 #12
0
    //回收飞碟
    public void FreeDisk(DiskModel disk)
    {
        int type = disk.getType();
        int ID   = disk.getDiskID();

        for (int i = 0; i < size[type]; i++)
        {
            if (disk.getDiskID() == disks[type][i].getDiskID())
            {
                diskStatus[type, i] = false;
                return;
            }
        }
    }
예제 #13
0
    public void UFOFly(DiskModel disk)
    {
        ruler.setRound(round);
        disk.disk.transform.position = ruler.getStart();//设置飞碟的出现位置
        int index = 0;

        for (; diskID[index] != -1; index++)
        {
            ;                                 //找到空闲的 Action
        }
        actions[index] = FlyAction.GetSSAction(ruler.getAngle(), ruler.getSpeed());
        diskID[index]  = disk.getDiskID();
        this.RunAction(disk.disk, actions[index], this);
    }
예제 #14
0
    public void freeAction(DiskModel disk)
    {
        disk.disk.GetComponent <Rigidbody>().velocity   = Vector3.zero;
        disk.disk.GetComponent <Rigidbody>().useGravity = false;

        for (int i = 0; i < 20; i++)
        {
            //当飞碟不再需要时,actionManager可以简单的将对应的action设为空闲,而非直接删除 action
            if (diskID[i] == disk.getDiskID())
            {
                diskID[i] = -1;
                break;
            }
        }
    }
예제 #15
0
    //暂停几秒后回收飞碟
    IEnumerator WaitingParticle(float wait_time, DiskFactory diskFactory, DiskModel hitDisk)
    {
        yield return(new WaitForSeconds(wait_time));

        if (hitDisk.disk.active == true)
        {
            hitDisk.disk.SetActive(false);
            hitDisk.disk.GetComponent <ParticleSystem>().Stop();
            hitDisk.disk.GetComponent <Rigidbody>().velocity   = Vector3.zero;
            hitDisk.disk.GetComponent <Rigidbody>().useGravity = false;
            currentDisks.Remove(hitDisk);
            actionManager.freeAction(hitDisk);
            diskFactory.FreeDisk(hitDisk);
            diskCount--;
        }
    }
예제 #16
0
    public void UFOFly(DiskModel disk)
    {
        ruler.setRound(round);
        disk.disk.transform.position = ruler.getStart();//设置飞碟的出现位置
        int index = 0;

        for (; diskID[index] != -1; index++)
        {
            ;                                 //找到空闲的 Action
        }
        actions[index] = FlyAction.GetSSAction(ruler.getAngle(), ruler.getSpeed());
        diskID[index]  = disk.getDiskID();
        disk.disk.GetComponent <Rigidbody>().useGravity = false;
        disk.disk.GetComponent <Rigidbody>().velocity   = Vector3.zero;
        this.RunAction(disk.disk, actions[index], this);
    }
예제 #17
0
    public void UFOFly(DiskModel disk)
    {
        ruler.setRound(round);
        disk.disk.transform.position = ruler.getStart();//设置飞碟的出现位置
        int index = 0;

        for (; diskID[index] != -1; index++)
        {
            ;                                 //找到空闲的 Action
        }
        Vector3 angle = Vector3.left;
        int     flag  = Random.Range(0, 2);

        if (flag == 1)
        {
            angle *= -1;
        }

        actions[index] = PhyUFOFlyAction.GetSSAction(angle, ruler.getSpeed());//从ruler中获取初速度和飞行角度,加速度为10
        diskID[index]  = disk.getDiskID();
        this.RunAction(disk.disk, actions[index], this);
    }
예제 #18
0
        public static void SaveToDisk(nHydrateModel model, string rootFolder, string modelName, nHydrateDiagram diagram)
        {
            var diskModel = new DiskModel();

            model.IsSaving = true;
            try
            {
                diskModel.ModelProperties.EmitChangeScripts = model.EmitChangeScripts;
                diskModel.ModelProperties.CompanyName       = model.CompanyName;
                diskModel.ModelProperties.EmitSafetyScripts = model.EmitSafetyScripts;
                diskModel.ModelProperties.DefaultNamespace  = model.DefaultNamespace;
                diskModel.ModelProperties.ProjectName       = model.ProjectName;
                diskModel.ModelProperties.UseUTCTime        = model.UseUTCTime;
                diskModel.ModelProperties.Version           = model.Version;
                diskModel.ModelProperties.Id = model.Id.ToString();
                diskModel.ModelProperties.TenantColumnName           = model.TenantColumnName;
                diskModel.ModelProperties.CreatedByColumnName        = model.CreatedByColumnName;
                diskModel.ModelProperties.CreatedDateColumnName      = model.CreatedDateColumnName;
                diskModel.ModelProperties.ModifiedByColumnName       = model.ModifiedByColumnName;
                diskModel.ModelProperties.ModifiedDateColumnName     = model.ModifiedDateColumnName;
                diskModel.ModelProperties.ConcurrencyCheckColumnName = model.ConcurrencyCheckColumnName;
                diskModel.ModelProperties.GrantExecUser = model.GrantUser;

                var folderName  = modelName.Replace(".nhydrate", ".model");
                var modelFolder = GetModelFolder(rootFolder, folderName);
                nHydrate.Dsl.Custom.SQLFileManagement.SaveToDisk(diskModel, model.Views);
                nHydrate.Dsl.Custom.SQLFileManagement.SaveToDisk(diskModel, model.Entities);
                FileManagement.Save(rootFolder, modelName, diskModel);
                nHydrate.Dsl.Custom.SQLFileManagement.SaveDiagramFiles(modelFolder, diagram);
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                model.IsSaving = false;
            }
        }
예제 #19
0
        static void Main(string[] args)
        {
            {
                Console.WriteLine("sphere");
                var sphere   = new Sphere(1, 40, 80);
                var filename = "sphere.obj_";
                sphere.DumpObjFile(filename, "sphere");
                var          parser = new ObjVNFParser(false);
                ObjVNFResult result = parser.Parse(filename);
                if (result.Error != null)
                {
                    Console.WriteLine("Error: {0}", result.Error);
                }
                else
                {
                    ObjVNFMesh mesh  = result.Mesh;
                    var        model = new ObjVNF(mesh);
                    model.DumpObjFile("vnf" + filename, "sphere");
                }
            }
            {
                Console.WriteLine("prismoid");
                var prismoid = new PrismoidModel(5, 5, 6, 6, 2);
                var filename = "prismoid.obj_";
                prismoid.DumpObjFile(filename, "prismoid");
                var          parser = new ObjVNFParser(false);
                ObjVNFResult result = parser.Parse(filename);
                if (result.Error != null)
                {
                    Console.WriteLine("Error: {0}", result.Error);
                }
                else
                {
                    ObjVNFMesh mesh  = result.Mesh;
                    var        model = new ObjVNF(mesh);
                    model.DumpObjFile("vnf" + filename, "prismoid");
                }
            }
            {
                Console.WriteLine("cylinder");
                var cylinder = new CylinderModel(0.25f, 6, 17);
                var filename = "cylinder.obj_";
                cylinder.DumpObjFile(filename, "cylinder");
                var          parser = new ObjVNFParser(false);
                ObjVNFResult result = parser.Parse(filename);
                if (result.Error != null)
                {
                    Console.WriteLine("Error: {0}", result.Error);
                }
                else
                {
                    ObjVNFMesh mesh  = result.Mesh;
                    var        model = new ObjVNF(mesh);
                    model.DumpObjFile("vnf" + filename, "cylinder");
                }
            }

            {
                Console.WriteLine("annulus");
                var annulus  = new AnnulusModel(0.5f + 0.4f, 0.3f, 17, 17);
                var filename = "annulus.obj_";
                annulus.DumpObjFile(filename, "annulus");
                var          parser = new ObjVNFParser(false);
                ObjVNFResult result = parser.Parse(filename);
                if (result.Error != null)
                {
                    Console.WriteLine("Error: {0}", result.Error);
                }
                else
                {
                    ObjVNFMesh mesh  = result.Mesh;
                    var        model = new ObjVNF(mesh);
                    model.DumpObjFile("vnf" + filename, "annulus");
                }
            }

            {
                Console.WriteLine("disk");
                var disk     = new DiskModel(0.5f + 0.4f, 0.3f, 0.3f, 17, 17);
                var filename = "disk.obj_";
                disk.DumpObjFile(filename, "disk");
                var          parser = new ObjVNFParser(false);
                ObjVNFResult result = parser.Parse(filename);
                if (result.Error != null)
                {
                    Console.WriteLine("Error: {0}", result.Error);
                }
                else
                {
                    ObjVNFMesh mesh  = result.Mesh;
                    var        model = new ObjVNF(mesh);
                    model.DumpObjFile("vnf" + filename, "disk");
                }
            }
            {
                Console.WriteLine("hanoiTower");
                var  list         = HanoiTower.GetDataSource();
                uint nextIndex    = 0;
                var  positionList = new List <vec3>();
                var  indexList    = new List <uint>();
                foreach (var item in list)
                {
                    vec3[] positions = item.model.GetPositions();
                    uint[] indexes   = item.model.GetIndexes();
                    for (int i = 0; i < positions.Length; i++)
                    {
                        positionList.Add(positions[i] + item.position);
                    }
                    for (int i = 0; i < indexes.Length; i++)
                    {
                        indexList.Add(indexes[i] + nextIndex);
                    }

                    nextIndex += (uint)positions.Length;
                }
                var hanoiTower = new TmpModel(positionList.ToArray(), indexList.ToArray());
                var filename   = "HanoiTower.obj_";
                hanoiTower.DumpObjFile(filename, "hanoiTower");
                var          parser = new ObjVNFParser(false);
                ObjVNFResult result = parser.Parse(filename);
                if (result.Error != null)
                {
                    Console.WriteLine("Error: {0}", result.Error);
                }
                else
                {
                    ObjVNFMesh mesh  = result.Mesh;
                    var        model = new ObjVNF(mesh);
                    model.DumpObjFile("vnf" + filename, "hanoiTower");
                }
            }
            Console.WriteLine("done");
        }
예제 #20
0
        /// <summary>
        /// Saves Stored Procedures to disk
        /// </summary>
        private static void SaveToDisk(DiskModel model, IEnumerable <Entity> list)
        {
            #region Save other parameter/field information

            foreach (var item in list)
            {
                var node = new nHydrate.ModelManagement.Entity.configuration();
                model.Entities.Add(node);
                node.allowcreateaudit       = item.AllowCreateAudit.ToByte();
                node.allowmodifyaudit       = item.AllowModifyAudit.ToByte();
                node.allowtimestamp         = item.AllowTimestamp.ToByte();
                node.codefacade             = item.CodeFacade;
                node.generatesdoublederived = item.GeneratesDoubleDerived.ToByte();
                node.id            = item.Id.ToString();
                node.immutable     = item.Immutable.ToByte();
                node.isassociative = item.IsAssociative.ToByte();
                node.isTenant      = item.IsTenant.ToByte();
                node.name          = item.Name;
                node.schema        = item.Schema;
                node.summary       = item.Summary;
                node.type          = "entity";
                node.typedentity   = item.TypedEntity.ToString();

                #region Fields
                var nodeFields = new List <ModelManagement.Entity.configurationField>();
                foreach (var field in item.Fields.OrderBy(x => x.Name))
                {
                    var nodeField = new ModelManagement.Entity.configurationField();
                    nodeFields.Add(nodeField);
                    nodeField.codefacade       = field.CodeFacade;
                    nodeField.dataformatstring = field.DataFormatString;
                    nodeField.datatype         = field.DataType.ToString();
                    nodeField.@default         = field.Default;
                    nodeField.defaultisfunc    = field.DefaultIsFunc.ToByte();
                    nodeField.formula          = field.Formula;
                    nodeField.id           = field.Id.ToString();
                    nodeField.identity     = field.Identity.ToString();
                    nodeField.Iscalculated = field.IsCalculated.ToByte();
                    nodeField.isindexed    = field.IsIndexed.ToByte();
                    nodeField.isprimarykey = field.IsPrimaryKey.ToByte();
                    nodeField.isreadonly   = field.IsReadOnly.ToByte();
                    nodeField.isunique     = field.IsUnique.ToByte();
                    nodeField.length       = (byte)field.Length;
                    nodeField.name         = field.Name;
                    nodeField.nullable     = field.Nullable.ToByte();
                    nodeField.obsolete     = field.Obsolete.ToByte();
                    nodeField.scale        = (byte)field.Scale;
                    nodeField.sortorder    = (byte)field.SortOrder;
                    nodeField.summary      = field.Summary;
                    node.fieldset          = nodeFields.ToArray();
                }
                node.fieldset = nodeFields.ToArray();
                #endregion

                //Save other files
                SaveEntityIndexes(model, item, node);
                SaveRelations(model, item, node);
                SaveEntityStaticData(model, item, node);
            }
            #endregion
        }
예제 #21
0
        private static void LoadFromDisk(IEnumerable <View> list, nHydrateModel model, DiskModel diskModel)
        {
            #region Load other parameter/field information

            foreach (var view in diskModel.Views)
            {
                var item = list.FirstOrDefault(x => x.Id == new Guid(view.id));
                if (item == null)
                {
                    item = new View(model.Partition, new PropertyAssignment[] { new PropertyAssignment(ElementFactory.IdPropertyAssignment, new Guid(view.id)) });
                    model.Views.Add(item);
                }

                System.Windows.Forms.Application.DoEvents();

                item.Name                   = view.name;
                item.CodeFacade             = view.codefacade;
                item.Schema                 = view.schema;
                item.GeneratesDoubleDerived = view.generatesdoublederived != 0;
                item.Summary                = view.summary;
                item.SQL = view.sql;

                var nameList = new List <string>();
                foreach (var fieldNode in view.fieldset)
                {
                    var subItemID = new Guid(fieldNode.id);
                    var field     = item.Fields.FirstOrDefault(x => x.Id == subItemID);
                    if (field == null)
                    {
                        field = new ViewField(item.Partition, new PropertyAssignment[] { new PropertyAssignment(ElementFactory.IdPropertyAssignment, subItemID) });
                        item.Fields.Add(field);
                    }

                    field.Name       = fieldNode.name;
                    field.CodeFacade = fieldNode.codefacade;
                    nameList.Add(field.Name.ToLower());
                    field.Nullable = fieldNode.nullable != 0;
                    if (Enum.TryParse <DataTypeConstants>(fieldNode.datatype, true, out var dt))
                    {
                        field.DataType = dt;
                    }
                    field.Default      = fieldNode.@default;
                    field.Length       = fieldNode.length;
                    field.Scale        = fieldNode.scale;
                    field.Summary      = fieldNode.summary;
                    field.IsPrimaryKey = fieldNode.isprimarykey != 0;
                }
                if (item.Fields.Remove(x => !nameList.Contains(x.Name.ToLower())) > 0)
                {
                    item.nHydrateModel.IsDirty = true;
                }
            }

            #endregion
        }
예제 #22
0
        private static void LoadFromDisk(IEnumerable <Entity> list, nHydrateModel model, DiskModel diskModel)
        {
            #region Load other parameter/field information
            foreach (var entity in diskModel.Entities)
            {
                var itemID = new Guid(entity.id);
                var item   = list.FirstOrDefault(x => x.Id == itemID);
                if (item == null)
                {
                    item = new Entity(model.Partition, new PropertyAssignment[] { new PropertyAssignment(ElementFactory.IdPropertyAssignment, itemID) });
                    model.Entities.Add(item);
                }

                System.Windows.Forms.Application.DoEvents();

                #region Properties

                item.Name                   = entity.name;
                item.AllowCreateAudit       = entity.allowcreateaudit != 0;
                item.AllowModifyAudit       = entity.allowmodifyaudit != 0;
                item.AllowTimestamp         = entity.allowtimestamp != 0;
                item.CodeFacade             = entity.codefacade;
                item.Immutable              = entity.immutable != 0;
                item.IsAssociative          = entity.isassociative != 0;
                item.GeneratesDoubleDerived = entity.generatesdoublederived != 0;
                item.IsTenant               = entity.isTenant != 0;

                if (Enum.TryParse <TypedEntityConstants>(entity.typedentity, true, out var te))
                {
                    item.TypedEntity = te;
                }

                item.Schema  = entity.schema;
                item.Summary = entity.summary;

                #endregion

                #region Fields

                var nameList = new List <string>();
                foreach (var fieldNode in entity.fieldset)
                {
                    var subItemID = new Guid(fieldNode.id);
                    var field     = item.Fields.FirstOrDefault(x => x.Id == subItemID);
                    if (field == null)
                    {
                        field = new Field(item.Partition, new PropertyAssignment[] { new PropertyAssignment(ElementFactory.IdPropertyAssignment, subItemID) });
                        item.Fields.Add(field);
                    }
                    field.Name       = fieldNode.name;
                    field.CodeFacade = fieldNode.codefacade;
                    nameList.Add(field.Name.ToLower());
                    field.Nullable = fieldNode.nullable != 0;

                    if (Enum.TryParse <DataTypeConstants>(fieldNode.datatype, true, out var dt))
                    {
                        field.DataType = dt;
                    }

                    if (Enum.TryParse <IdentityTypeConstants>(fieldNode.identity, true, out var it))
                    {
                        field.Identity = it;
                    }

                    field.DataFormatString = fieldNode.dataformatstring;
                    field.Default          = fieldNode.@default;
                    field.DefaultIsFunc    = fieldNode.defaultisfunc != 0;
                    field.Formula          = fieldNode.formula;
                    field.IsIndexed        = fieldNode.isindexed != 0;
                    field.IsPrimaryKey     = fieldNode.isprimarykey != 0;
                    field.IsCalculated     = fieldNode.Iscalculated != 0;
                    field.IsUnique         = fieldNode.isunique != 0;
                    field.Length           = fieldNode.length;
                    field.Scale            = fieldNode.scale;
                    field.SortOrder        = fieldNode.sortorder;
                    field.IsReadOnly       = fieldNode.isreadonly != 0;
                    field.Obsolete         = fieldNode.obsolete != 0;
                    field.Summary          = fieldNode.summary;
                }
                if (item.Fields.Remove(x => !nameList.Contains(x.Name.ToLower())) > 0)
                {
                    item.nHydrateModel.IsDirty = true;
                }

                #endregion

                LoadEntityIndexes(item, diskModel);

                //Order fields (skip for model that did not have sort order when saved)
                var fc = new FieldOrderComparer();
                if (item.Fields.Count(x => x.SortOrder > 0) > 0)
                {
                    item.Fields.Sort(fc.Compare);
                }
            }

            //Must load relations AFTER ALL entities are loaded
            foreach (var item in model.Entities)
            {
                LoadEntityRelations(item, diskModel);
                LoadEntityStaticData(item, diskModel);
            }

            #endregion
        }
예제 #23
0
        static void Main(string[] args)
        {
            {
                Console.WriteLine("prismoid");
                var prismoid = new PrismoidModel(5, 5, 6, 6, 2);
                var filename = "prismoid.obj";
                prismoid.DumpObjFile(filename, "prismoid");
                var          parser = new ObjVNFParser(false);
                ObjVNFResult result = parser.Parse(filename);
                if (result.Error != null)
                {
                    Console.WriteLine("Error: {0}", result.Error);
                }
                else
                {
                    ObjVNFMesh mesh  = result.Mesh;
                    var        model = new ObjVNF(mesh);
                    model.DumpObjFile("vnf" + filename, "prismoid");
                }
            }
            {
                Console.WriteLine("cylinder");
                var cylinder = new CylinderModel(0.25f, 6, 17);
                var filename = "cylinder.obj";
                cylinder.DumpObjFile(filename, "cylinder");
                var          parser = new ObjVNFParser(false);
                ObjVNFResult result = parser.Parse(filename);
                if (result.Error != null)
                {
                    Console.WriteLine("Error: {0}", result.Error);
                }
                else
                {
                    ObjVNFMesh mesh  = result.Mesh;
                    var        model = new ObjVNF(mesh);
                    model.DumpObjFile("vnf" + filename, "cylinder");
                }
            }

            {
                Console.WriteLine("annulus");
                var annulus  = new AnnulusModel(0.5f + 0.4f, 0.3f, 17, 17);
                var filename = "annulus.obj";
                annulus.DumpObjFile(filename, "annulus");
                var          parser = new ObjVNFParser(false);
                ObjVNFResult result = parser.Parse(filename);
                if (result.Error != null)
                {
                    Console.WriteLine("Error: {0}", result.Error);
                }
                else
                {
                    ObjVNFMesh mesh  = result.Mesh;
                    var        model = new ObjVNF(mesh);
                    model.DumpObjFile("vnf" + filename, "annulus");
                }
            }

            {
                Console.WriteLine("disk");
                var disk     = new DiskModel(0.5f + 0.4f, 0.3f, 0.3f, 17, 17);
                var filename = "disk.obj";
                disk.DumpObjFile(filename, "disk");
                var          parser = new ObjVNFParser(false);
                ObjVNFResult result = parser.Parse(filename);
                if (result.Error != null)
                {
                    Console.WriteLine("Error: {0}", result.Error);
                }
                else
                {
                    ObjVNFMesh mesh  = result.Mesh;
                    var        model = new ObjVNF(mesh);
                    model.DumpObjFile("vnf" + filename, "disk");
                }
            }
            Console.WriteLine("done");
        }