Ejemplo n.º 1
0
        public static string CreateDownloadPackage(object ids)
        {
            var itemIds = (Dictionary<string, object>) ids;
            var guid = Guid.NewGuid().ToString();
            var id = Int32.Parse(itemIds["0"].ToString());
            try
            {
                var zipFilePath = String.Format("{0}\\{1}\\",
                                                   ConfigurationManager.AppSettings["DownloadDirectory"],
                                                   guid);
                var zipFileName = String.Format("{0}{1}",
                                                   zipFilePath,
                                                   "package.zip");
                using (var container = new BXC_ContentModelEntities())
                {
                    var family = (from c in container.Items
                                  where c.Id == id
                                  select new
                                             {
                                                 FileName = c.AutodeskFile.Name,
                                                 c.AutodeskFile.TypeCatalogHeader,
                                                 TypeCatalogLine = c.TypeCatalogEntry,
                                                 Owner = c.AutodeskFile.MC_OwnerId
                                             }).FirstOrDefault();

                    if (family != null)
                    {
                        var filePath = String.Format("{0}\\{1}.rfa",
                                                     ConfigurationManager.AppSettings["ContentDirectory"],
                                                     family.FileName);
                        AddtoZip(filePath, family.FileName, zipFileName, zipFilePath);
                    }
                    if (family != null && !String.IsNullOrWhiteSpace(family.TypeCatalogHeader))
                    {
                        var typeCatalogPath = String.Format("{0}\\{1}\\{2}",
                                                               ConfigurationManager.AppSettings["DownloadDirectory"],
                                                               guid,
                                                               family.FileName + ".txt");

                        var sw = File.CreateText(typeCatalogPath);
                        {
                            sw.WriteLine(family.TypeCatalogHeader);
                            foreach (var i in itemIds.Select(id2 => Int32.Parse(id2.Value.ToString())).Select(iD => (from t in container.Items where t.Id == id select t.TypeCatalogEntry).
                                                                                                                        FirstOrDefault()))
                            {
                                sw.WriteLine(i);
                            }
                        }

                        sw.Close();
                        AddtoZip(typeCatalogPath, family.FileName + ".txt", zipFileName, zipFilePath);
                    }
                }
                try
                {
                    using (var container = new BXC_MasterControlEntities())
                    {
                        foreach (var id2 in itemIds)
                        {
                            var download = new Download {DateTime = DateTime.Now, Content_Id = id2.ToString()};
                            var libName = HttpContext.Current.Session["LibraryName"].ToString();
                            var lib =
                                (from l in container.Libraries where l.Name == libName select l).FirstOrDefault();
                            download.Library = lib;
                            var uname = HttpContext.Current.Session["UserName"].ToString();
                            download.User =
                                (from u in container.Users where u.UserName == uname select u).FirstOrDefault();
                            container.SaveChanges();
                        }
                    }
                }
                catch
                {
                }
                return guid;
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
        }
Ejemplo n.º 2
0
        protected void TvDirectoryNodeExpand(object sender, RadTreeNodeEventArgs e)
        {
            int parentId;

            if (Int32.TryParse(e.Node.Value, out parentId))
            {
                using (var container = new BXC_ContentModelEntities())
                {
                    e.Node.Nodes.Clear();
                    var nodes = from n in container.TreeNodes
                                where n.TreeNode1.Id == parentId
                                select new {text = n.Name, value = n.Id, count = n.TreeNodes1.Count};
                    foreach (var n in nodes)
                    {
                        var node = new RadTreeNode
                                       {
                                           Text = n.text,
                                           Value = n.value.ToString(),
                                           ExpandMode =
                                               n.count == 0
                                                   ? TreeNodeExpandMode.ClientSide
                                                   : TreeNodeExpandMode.ServerSide
                                       };
                        e.Node.Nodes.Add(node);
                    }
                }
            }
            e.Node.Expanded = true;
        }
Ejemplo n.º 3
0
        public DataTable GetTypeCatalogData(int familyId)
        {
            string header;
            var rows = new List<string>();
            using (var entities = new BXC_ContentModelEntities())
            {
                header = (from f in entities.AutodeskFiles where f.Id == familyId select f.TypeCatalogHeader).First();
                var types = from t in entities.Items where t.AutodeskFile.Id == familyId select t;
                rows.AddRange(types.Select(type => type.Id + "," + type.TypeCatalogEntry));
            }

            var dtTypeCatalog = new DataTable();
            var paramNames = header.Split(',');
            var index = 0;
            foreach (var splits in paramNames.Select(input => input.Split('#')))
            {
                paramNames[index] = splits[0];
                index++;
            }

            dtTypeCatalog.Columns.Add("ID");
            foreach (var input in paramNames)
            {
                if (input == String.Empty)
                {
                    dtTypeCatalog.Columns.Add("Type");
                }
                else
                {
                    var temp = input.Replace("(", "");
                    temp = temp.Replace(")", "");
                    dtTypeCatalog.Columns.Add(temp);
                }
            }

            foreach (var row in rows)
            {
                try
                {
                    //TODO: extra commas in rows.
                    var rowValues = row.Split(',');
                    dtTypeCatalog.Rows.Add(rowValues);
                }
                catch
                {
                }
            }
            return dtTypeCatalog;
        }
Ejemplo n.º 4
0
        public void LoadData(bool updateLibrary, bool updateSearchNames)
        {
            using (var container = new BXC_ContentModelEntities())
            {
                //Update Tree if Needed
                if (updateLibrary)
                {
                    //Update Tree View
                    var rootnode =
                        (from t in container.TreeNodes
                         where t.ContentLibrary.Name == LibraryName & t.TreeNode1 == null
                         select t).FirstOrDefault();

                    tvDirectory.Nodes.Clear();
                    if (rootnode != null)
                    {
                        var root = new RadTreeNode {Text = rootnode.Name, Value = rootnode.Id.ToString()};
                        NodeId = rootnode.Id;
                        root.ExpandMode = TreeNodeExpandMode.ServerSide;
                        root.Expanded = true;
                        tvDirectory.Nodes.Add(root);
                    }
                    //Update Library Image
                    imgLibrary.ImageUrl = "~/Images/Libraries/" + LibraryName + ".png";
                }

                //Get content in library based on TreeNodes
                var files = from f in container.AutodeskFiles
                                                 where f.AutodeskFileTreeNodes.Any(n => n.TreeNode.Id == NodeId)
                                                 select f;
                var items = from i in container.Items
                                         where files.Any(f => f.Id == i.AutodeskFile.Id)
                                         select i;
                //Update SearchNames if Needed
                if (updateSearchNames)
                {
                    var search =
                        (from s in container.SearchNames
                         where s.Parameters.Any(p => items.Any(i => i.Id == p.Item.Id))
                         select s.Name).Distinct();
                    Session["Fields"] = search.ToList();
                }
                foreach (var filter in Filters)
                {
                    var tempItems = items;
                    var tempFilter = filter;
                    if (filter.Field == "Any Parameter")
                    {
                        items =
                            from i in
                                tempItems.Where(
                                    i => i.Parameters.Any(p => p.SearchValue.Value.Contains(tempFilter.Value)))
                            select i;
                    }
                    else
                    {
                        if (filter.Op == "Contains")
                        {
                            items =
                                from i in
                                    tempItems.Where(
                                        i =>
                                        i.Parameters.Any(
                                            p =>
                                            p.SearchName.Name == tempFilter.Field &&
                                            p.SearchValue.Value.Contains(tempFilter.Value)))
                                select i;
                        }
                        else
                        {
                            items =
                                from i in
                                    tempItems.Where(
                                        i =>
                                        i.Parameters.Any(
                                            p =>
                                            p.SearchName.Name == tempFilter.Field &&
                                            p.SearchValue.Value == tempFilter.Value))
                                select i;
                        }
                    }
                }
                items = items.OrderBy(i => i.Id);
                //Paging for repeater
                var gridItems = items.Skip(Skip).Take(Take).ToList();
                var finalItems = from g in gridItems
                                 select new
                                            {
                                                g.Id,
                                                g.Name,
                                                g.AutodeskFile, I = g.AutodeskFile.Id,
                                                g.TypeCatalogEntry,
                                                Parameters = g.Parameters.Where(p => p.Featured),
                                            };
                grdItems.VirtualItemCount = items.Count();
                grdItems.DataSource = finalItems;
                grdItems.DataBind();
            }
        }