private static int GetIconIndex(RepositoryItemType type)
        {
            switch (type)
            {
            case RepositoryItemType.TmsRoot:
                return((int)RepositoryIcon.TmsRoot);

            case RepositoryItemType.TmsSource:
                return((int)RepositoryIcon.TmsItem);

            case RepositoryItemType.FileSystem:
                return((int)RepositoryIcon.FileSystem);

            case RepositoryItemType.Folder:
            case RepositoryItemType.Group:
                return((int)RepositoryIcon.Folder);

            case RepositoryItemType.Vector:
            case RepositoryItemType.DatabaseLayer:
                return((int)RepositoryIcon.Geometry);

            case RepositoryItemType.Image:
                return((int)RepositoryIcon.Raster);

            case RepositoryItemType.Databases:
                return((int)RepositoryIcon.Databases);

            case RepositoryItemType.Database:
            case RepositoryItemType.Server:
                return((int)RepositoryIcon.Database);
            }

            throw new ApplicationException("Unexpected repository item type.");
        }
 private static TreeNodeAdv CreateNode(RepositoryItemType type)
 {
     return(new TreeNodeAdv
     {
         Tag = type,
         LeftImageIndices = new[] { GetIconIndex(type) }
     });
 }
Example #3
0
        public IGroupItem GetGroup(RepositoryItemType rootType, Guid groupId)
        {
            var root = GetSpecialItem(rootType);

            if (root == null)
            {
                return(null);
            }
            return(root.SubItems.OfType <IGroupItem>().FirstOrDefault(g => g.Group.Guid == groupId));
        }
        public IRepositoryItem AddItem(RepositoryItemType type)
        {
            if (type == RepositoryItemType.Folder || type == RepositoryItemType.Vector)
            {
                throw new InvalidOperationException("Use specific methods to create item of this type.");
            }

            var node = CreateNode(type);

            node.Text = type.EnumToString();
            return(AddNode(node));
        }
        private IFileItem CreateFileItem(string filename, RepositoryItemType itemType)
        {
            var node = CreateNode(itemType);

            node.TagObject    = new FileItemMetadata(filename);
            node.ExpandedOnce = true;
            node.Text         = Path.GetFileName(filename);

            AssignCustomFileIcons(node, filename, itemType);

            return(AddNode(node) as IFileItem);
        }
 public liteBaseCommunityFile()
 {
     isPersonal         = false;
     isDeleted          = false;
     isVisible          = true;
     IsDownloadable     = true;
     CreatedOn          = DateTime.Now;
     UniqueID           = System.Guid.NewGuid();
     CloneUniqueID      = System.Guid.Empty;
     Description        = "";
     Downloads          = 0;
     FilePath           = "";
     AllowUpload        = false;
     RepositoryItemType = RepositoryItemType.FileStandard;
 }
Example #7
0
        public static CommandIcon GetDefaultIcon(RepositoryItemType type)
        {
            switch (type)
            {
            case RepositoryItemType.VideoStreaming:
            case RepositoryItemType.Multimedia:
                return(CommandIcon.PlayMultimediaItem);

            case RepositoryItemType.ScormPackage:
                return(CommandIcon.PlayScormItem);

            case RepositoryItemType.FileStandard:
                return(CommandIcon.Document);

            default:
                return(CommandIcon.None);
            }
        }
        private void AssignCustomFileIcons(TreeNodeAdv node, string filename, RepositoryItemType itemType)
        {
            if (itemType == RepositoryItemType.Vector && filename.ToLower().EndsWith(".shp"))
            {
                var type = ShapefileHelper.GetGeometryType(filename);
                node.LeftImageIndices = new[] { GetVectorIcon(type) };
            }

            if (filename.ToLower().EndsWith(".vrt"))
            {
                node.LeftImageIndices = new[] { (int)RepositoryIcon.VrtFile };
            }

            if (filename.ToLower().EndsWith(".sqlite"))
            {
                node.LeftImageIndices = new[] { (int)RepositoryIcon.Sqlite };
            }
        }
Example #9
0
        public IRepositoryItem GetSpecialItem(RepositoryItemType type)
        {
            var root = Items.FirstOrDefault(item => item.Type == type);

            if (root != null)
            {
                return(root);
            }

            // let's seek the second level as well; currently we don't need a full blown recursion here
            foreach (var item in Items)
            {
                root = item.SubItems.FirstOrDefault(subItem => subItem.Type == type);
                if (root != null)
                {
                    return(root);
                }
            }

            return(null);
        }
        private void LoadFiles(Community community, List <long> selectedFiles, Boolean loadIntoTree, Boolean showHiddenItems, Boolean forAdminPurpose, Boolean disableWaitingFiles, RepositoryItemType type)
        {
            List <CommunityFile> files = new List <CommunityFile>();
            dtoFileFolder        rep   = new dtoFileFolder()
            {
                Id = 0, Name = "", isVisible = true
            };
            Person person = CurrentManager.GetPerson(UserContext.CurrentUserID);

            files = Service.GetCommunityItems(community, person, 0, showHiddenItems, forAdminPurpose);

            foreach (CommunityFile folder in  files.Where(f => f.isFile == false).OrderBy(f => f.Name).ToList())
            {
                dtoFileFolder dFolder = new dtoFileFolder()
                {
                    Id = folder.Id, Name = folder.Name, isVisible = folder.isVisible
                };
                RecursivelyCreateFolder(dFolder, community, person, selectedFiles, loadIntoTree, showHiddenItems, forAdminPurpose, disableWaitingFiles, type);
                if (type == RepositoryItemType.None || (type != RepositoryItemType.None && dFolder.HasFiles))
                {
                    rep.SubFolders.Add(dFolder);
                }
            }
            List <long> idWaitingFiles = Service.GetIdWaitingFiles(files.Where(f => f.RepositoryItemType == RepositoryItemType.ScormPackage || f.RepositoryItemType == RepositoryItemType.Multimedia).Select(f => f.Id).ToList());

            rep.Files = files.Where(f => (type == RepositoryItemType.None || f.RepositoryItemType == type) && (loadIntoTree || (!loadIntoTree && !selectedFiles.Contains(f.Id))) && f.isFile).OrderBy(f => f.DisplayName).Select(
                f => new dtoGenericFile()
            {
                Extension = f.Extension, Id = f.Id, Name = f.Name, isVisible = f.isVisible, Selected = selectedFiles.Contains(f.Id), Selectable = (!disableWaitingFiles || (disableWaitingFiles && !idWaitingFiles.Contains(f.Id)))
            }).ToList();
            View.LoadTree(rep);
        }
 public void InitView(Int32 idCommunity, List <long> selectedFiles, Boolean loadIntoTree, Boolean showHiddenItems, Boolean forAdminPurpose, Boolean disableWaitingFiles, RepositoryItemType type)
 {
     if (UserContext.isAnonymous)
     {
         View.DisplayNoFilesFound();
     }
     else
     {
         Community community = CurrentManager.GetCommunity(idCommunity);
         if (community == null && idCommunity > 0)
         {
             View.DisplayNoFilesFound();
         }
         else
         {
             LoadFiles(community, selectedFiles, loadIntoTree, showHiddenItems, forAdminPurpose, disableWaitingFiles, type);
         }
     }
 }
Example #12
0
 public static string RenderSpan(String title, RepositoryItemType type, IconSize size, String cssClass)
 {
     return(RenderSpan(title, GetDefaultIcon(type), size, cssClass));
 }
Example #13
0
 public dtoBaseGenericFile()
 {
     Type = RepositoryItemType.FileStandard;
 }
Example #14
0
        private static void SeedTemplateItems(ProcurementContext db, UnitOfWorkProcurement unit)
        {
            //Half couplimg



            //Cross
            //45º lateral
            //Flange

            //Para quase todos eles vale a seguinte lista de atributos:
            //            Code(UNSPSC)
            //Description
            //Reference standard(e.g.ASME B 16.4)
            //Diameter ou NPS(no caso das reduções são dois diâmetros)
            //Rating class (e.g. 150 lbs)
            //Material Specification
            //Grade
            //Endings
            //Thickness
            IRepositoryItemType          repItemType          = new RepositoryItemType(db, unit);
            IRepositoryTemplateItem      repTemplateItem      = new RepositoryTemplateItem(db, unit);
            IRepositoryTemplateAttribute repTemplateAttribute = new RepositoryTemplateAttribute(db, unit);
            IRepositoryItem           repItem           = new RepositoryItem(db, unit);
            IRepositoryAttributeValue repAttributeValue = new RepositoryAttributeValue(db, unit);


            SeedPipe(unit, repItem, repItemType, repTemplateItem, repTemplateAttribute, repAttributeValue);

            #region Elbow
            ItemType itemType = new ItemType()
            {
                Name = "Elbow"
            };
            repItemType.Insert(itemType);
            List <TemplateAttribute> attributes = new List <TemplateAttribute>()
            {
                new TemplateAttribute()
                {
                    Name = "Reference standard", Order = 1
                },
                new TemplateAttribute()
                {
                    Name = "NPS", Order = 2
                },
                new TemplateAttribute()
                {
                    Name = "Rating class", Order = 3
                },
                new TemplateAttribute()
                {
                    Name = "Material Specification", Order = 4
                },
                new TemplateAttribute()
                {
                    Name = "Grade", Order = 5
                },
                new TemplateAttribute()
                {
                    Name = "Endings", Order = 6
                },
                new TemplateAttribute()
                {
                    Name = "Thickness", Order = 7
                },
            };
            repTemplateAttribute.InsertRange(attributes);
            TemplateItem templateItem = new TemplateItem()
            {
                Name = "Elbow 90°", ItemType = itemType, ModelAttributes = attributes
            };
            repTemplateItem.Insert(templateItem);

            attributes = new List <TemplateAttribute>()
            {
                new TemplateAttribute()
                {
                    Name = "Reference standard", Order = 1
                },
                new TemplateAttribute()
                {
                    Name = "NPS", Order = 2
                },
                new TemplateAttribute()
                {
                    Name = "Rating class", Order = 3
                },
                new TemplateAttribute()
                {
                    Name = "Material Specification", Order = 4
                },
                new TemplateAttribute()
                {
                    Name = "Grade", Order = 5
                },
                new TemplateAttribute()
                {
                    Name = "Endings", Order = 6
                },
                new TemplateAttribute()
                {
                    Name = "Thickness", Order = 7
                },
            };
            repTemplateAttribute.InsertRange(attributes);
            templateItem = new TemplateItem()
            {
                Name = "Elbow 90º Long Radius", ItemType = itemType, ModelAttributes = attributes
            };
            repTemplateItem.Insert(templateItem);


            attributes = new List <TemplateAttribute>()
            {
                new TemplateAttribute()
                {
                    Name = "Reference standard", Order = 1
                },
                new TemplateAttribute()
                {
                    Name = "NPS", Order = 2
                },
                new TemplateAttribute()
                {
                    Name = "Rating class", Order = 3
                },
                new TemplateAttribute()
                {
                    Name = "Material Specification", Order = 4
                },
                new TemplateAttribute()
                {
                    Name = "Grade", Order = 5
                },
                new TemplateAttribute()
                {
                    Name = "Endings", Order = 6
                },
                new TemplateAttribute()
                {
                    Name = "Thickness", Order = 7
                },
            };
            repTemplateAttribute.InsertRange(attributes);
            templateItem = new TemplateItem()
            {
                Name = "Elbow 45º", ItemType = itemType, ModelAttributes = attributes
            };
            repTemplateItem.Insert(templateItem);



            #endregion

            #region Tee
            itemType = new ItemType()
            {
                Name = "Tee"
            };
            repItemType.Insert(itemType);
            attributes = new List <TemplateAttribute>()
            {
                new TemplateAttribute()
                {
                    Name = "Reference standard", Order = 1
                },
                new TemplateAttribute()
                {
                    Name = "NPS", Order = 2
                },
                new TemplateAttribute()
                {
                    Name = "Rating class", Order = 3
                },
                new TemplateAttribute()
                {
                    Name = "Material Specification", Order = 4
                },
                new TemplateAttribute()
                {
                    Name = "Grade", Order = 5
                },
                new TemplateAttribute()
                {
                    Name = "Endings", Order = 6
                },
                new TemplateAttribute()
                {
                    Name = "Thickness", Order = 7
                },
            };
            repTemplateAttribute.InsertRange(attributes);
            templateItem = new TemplateItem()
            {
                Name = "Tee", ItemType = itemType, ModelAttributes = attributes
            };
            repTemplateItem.Insert(templateItem);
            #endregion

            #region Reducer
            itemType = new ItemType()
            {
                Name = "Reducer"
            };
            repItemType.Insert(itemType);
            attributes = new List <TemplateAttribute>()
            {
                new TemplateAttribute()
                {
                    Name = "Reference standard", Order = 1
                },
                new TemplateAttribute()
                {
                    Name = "NPS", Order = 2
                },
                new TemplateAttribute()
                {
                    Name = "Rating class", Order = 3
                },
                new TemplateAttribute()
                {
                    Name = "Material Specification", Order = 4
                },
                new TemplateAttribute()
                {
                    Name = "Grade", Order = 5
                },
                new TemplateAttribute()
                {
                    Name = "Endings", Order = 6
                },
                new TemplateAttribute()
                {
                    Name = "Thickness", Order = 7
                },
            };
            repTemplateAttribute.InsertRange(attributes);
            templateItem = new TemplateItem()
            {
                Name = "Reducer Concentric", ItemType = itemType, ModelAttributes = attributes
            };
            repTemplateItem.Insert(templateItem);


            attributes = new List <TemplateAttribute>()
            {
                new TemplateAttribute()
                {
                    Name = "Reference standard", Order = 1
                },
                new TemplateAttribute()
                {
                    Name = "NPS", Order = 2
                },
                new TemplateAttribute()
                {
                    Name = "Rating class", Order = 3
                },
                new TemplateAttribute()
                {
                    Name = "Material Specification", Order = 4
                },
                new TemplateAttribute()
                {
                    Name = "Grade", Order = 5
                },
                new TemplateAttribute()
                {
                    Name = "Endings", Order = 6
                },
                new TemplateAttribute()
                {
                    Name = "Thickness", Order = 7
                },
            };
            repTemplateAttribute.InsertRange(attributes);
            templateItem = new TemplateItem()
            {
                Name = "Reducer Eccentric", ItemType = itemType, ModelAttributes = attributes
            };
            repTemplateItem.Insert(templateItem);


            #endregion

            #region Flange
            itemType = new ItemType()
            {
                Name = "Flange"
            };
            repItemType.Insert(itemType);
            attributes = new List <TemplateAttribute>()
            {
                new TemplateAttribute()
                {
                    Name = "Reference standard", Order = 1
                },
                new TemplateAttribute()
                {
                    Name = "NPS", Order = 2
                },
                new TemplateAttribute()
                {
                    Name = "Rating class", Order = 3
                },
                new TemplateAttribute()
                {
                    Name = "Material Specification", Order = 4
                },
                new TemplateAttribute()
                {
                    Name = "Grade", Order = 5
                },
                new TemplateAttribute()
                {
                    Name = "Endings", Order = 6
                },
                new TemplateAttribute()
                {
                    Name = "Thickness", Order = 7
                },
            };
            repTemplateAttribute.InsertRange(attributes);
            templateItem = new TemplateItem()
            {
                Name = "Flange", ItemType = itemType, ModelAttributes = attributes
            };
            repTemplateItem.Insert(templateItem);
            #endregion
        }