示例#1
0
        public void AddObject(ItemViewModel obj)
        {
            //try to find object type TOC entry
            TocViewModel tocTypeEntry  = null;
            string       objectTypeUid = UidHelpers.GetObjectTypeGroupUid(ProjectUid, obj.Type);

            if (this.tocObjectTypesLevel.ContainsKey(objectTypeUid))
            {
                tocTypeEntry = this.tocObjectTypesLevel[objectTypeUid];
            }
            else
            {
                tocTypeEntry       = new TocViewModel();
                tocTypeEntry.Uid   = objectTypeUid;
                tocTypeEntry.Name  = obj.Type + "s";
                tocTypeEntry.Items = new List <TocViewModel>();
                TOCRoot.Items.Add(tocTypeEntry);
                tocObjectTypesLevel.Add(tocTypeEntry.Uid, tocTypeEntry);
            }

            TocViewModel tocDocElement = new TocViewModel();

            tocDocElement.Uid  = obj.Uid;
            tocDocElement.Name = obj.Name;
            tocTypeEntry.Items.Add(tocDocElement);

            objectCache.Add(obj.Uid, obj);
        }
示例#2
0
        protected void AddObjectToLinkCache(ApplicationObject appObject)
        {
            IElement        rootElement = appObject.RootElement;
            ObjectLinkCache objLink     = new ObjectLinkCache();

            objLink.Type = appObject.ElementTypeInfo.Name;
            objLink.Id   = objLink.Type + rootElement.Id.ToString();
            objLink.Uid  = UidHelpers.GetObjectUid(this.ProjectUid, objLink.Type, objLink.Id);
            objLink.Name = rootElement.GetStringProperty(PropertyType.Name);
            objectLinks.Add(objLink.Id, objLink);
        }
示例#3
0
        protected void ExportObjectDocumentation(string destFolderName, ApplicationObject appObject)
        {
            IElement rootElement = appObject.RootElement;
            IEnumerable <IElement> codeElementList = rootElement.GetSubElements(ElementType.Procedure);

            string objectName = rootElement.GetStringProperty(PropertyType.Name);
            string objectType = appObject.ElementTypeInfo.Name;
            int    objectId   = rootElement.Id;

            PageViewModel doc = new PageViewModel();

            doc.Items = new List <ItemViewModel>();

            ItemViewModel obj = new ItemViewModel();

            obj.Id       = objectType + objectId.ToString();
            obj.Uid      = UidHelpers.GetObjectUid(this.ProjectUid, objectType, obj.Id);
            obj.Name     = objectName;
            obj.Type     = objectType;
            obj.ObjectId = objectId;
            obj.ItemType = ItemType.Object;
            doc.Items.Add(obj);

            //write object documentation


            //write table fields and keys
            if (objectType == "Table")
            {
                obj.Fields = new List <FieldViewModel>();
                IEnumerable <IElement> fieldList = rootElement.GetSubElements(ElementType.Field);
                foreach (IElement fieldElement in fieldList)
                {
                    AddFieldDocumentation(doc, obj, fieldElement);
                }

                obj.Keys = new List <KeyViewModel>();
                IEnumerable <IElement> keyList = rootElement.GetSubElements(ElementType.Key);
                bool primaryKey = true;
                foreach (IElement keyElement in keyList)
                {
                    AddKeyDocumentation(doc, obj, keyElement, primaryKey);
                    primaryKey = false;
                }
            }

            if (objectType == "Page")
            {
                string sourceTable = rootElement.GetStringProperty(PropertyType.SourceTable);
                if (!String.IsNullOrWhiteSpace(sourceTable))
                {
                    sourceTable       = sourceTable.Replace("Table", "");
                    obj.SourceTableId = sourceTable;

                    ObjectLinkCache sourceTableLink = GetDataTypeLink("Table", sourceTable);
                    if (sourceTableLink != null)
                    {
                        obj.SourceTableName = sourceTableLink.Name;
                        obj.SourceTableUid  = sourceTableLink.Uid;
                    }
                    ;

                    if (String.IsNullOrEmpty(obj.SourceTableName))
                    {
                        obj.SourceTableName = "Table " + sourceTable;
                    }
                }


                obj.Fields = new List <FieldViewModel>();
                IEnumerable <IElement> fieldList = rootElement.GetSubElements(ElementType.Control);
                foreach (IElement fieldElement in fieldList)
                {
                    AddPageFieldDocumentation(doc, obj, fieldElement);
                }
            }

            //write procedures
            foreach (IElement element in codeElementList)
            {
                AddProcedureDocumentation(doc, obj, element);
            }

            //export document
            YamlHelper.ExportDocument(Path.Combine(destFolderName, obj.Uid + ".yml"), "ClassicDynamicsNavReference", doc);

            //add object to TOC
            TOCBuilder.AddObject(obj);
        }