public static TreeNode CreateNew(PLMPackEntities db, string grpId , string parentNodeId , string name, string description , int thumbId) { if (!string.IsNullOrEmpty(parentNodeId)) { TreeNode tnParent = TreeNode.GetById(db, new Guid(parentNodeId)); if (null != tnParent) { if (tnParent.HasChildWithName(name)) { throw new ModelException(string.Format("Node {0} ({1}) already has child named {1}", parentNodeId, tnParent.Name, name)); } } } TreeNode tn = new TreeNode(); tn.Id = Guid.NewGuid().ToString(); tn.GroupId = grpId; tn.ParentNodeId = parentNodeId; tn.Name = name; tn.Description = description; tn.ThumbnailId = thumbId; db.TreeNodes.Add(tn); db.SaveChanges(); return(db.TreeNodes.Single(n => n.Id == tn.Id)); }
public List <Group> AllGroups(PLMPackEntities db) { List <Group> grps = new List <Group>(Groups); grps.Add(Group.Everyone(db)); return(grps); }
public void DisConnect() { // save connection in database PLMPackEntities db = new PLMPackEntities(); AspNetUser aspNetUser = AspNetUser.GetByUserName(db, UserName); aspNetUser.Disconnect(db); }
public Dictionary <string, double> GetParamDefaultValues(PLMPackEntities db, string grpId) { if (db.ParamDefaultComponents.Count(pdc => (pdc.GroupId == grpId) && (pdc.ComponentGuid == this.Guid)) == 0) { // get component group string compGrpId = this.Document.Group.Id; // get param default components var paramDefaults1 = db.ParamDefaultComponents.Where(pdc => (pdc.GroupId == grpId) && (pdc.ComponentGuid == this.Guid)); foreach (ParamDefaultComponent pdc in paramDefaults1) { db.ParamDefaultComponents.Add( new ParamDefaultComponent() { ComponentGuid = this.Guid, GroupId = pdc.GroupId, Name = pdc.Name, Value = pdc.Value } ); } db.SaveChanges(); } Dictionary <string, double> defaultParamValues = new Dictionary <string, double>(); var paramDefaults2 = this.ParamDefaultComponents.Where( pdc => (pdc.GroupId == grpId) && (pdc.ComponentGuid == this.Guid) ); foreach (ParamDefaultComponent pdc in paramDefaults2) { defaultParamValues.Add(pdc.Name, pdc.Value); } return(defaultParamValues); }
public void Delete(PLMPackEntities db, AspNetUser user) { if (!user.Groups.Contains(Group)) { throw new ModelException(string.Format("User {0} is not allowed to perform this operation.", user.UserName)); } // remove childrens List <TreeNode> childList = new List <TreeNode>(Childrens); childList.ForEach(tn => tn.Delete(db, user)); // remove TreeNodeDocument List <TreeNodeDocument> lTreeNodeDocs = new List <TreeNodeDocument>(db.TreeNodeDocuments.Where(tnd => tnd.TreeNodeId == Id).ToArray()); lTreeNodeDocs.ForEach(tnd => tnd.Delete(db)); int thumbnailId = this.ThumbnailId; // remove while (TreeNodeGroupShare.Count() > 0) { TreeNodeGroupShare tnGpShare = TreeNodeGroupShare.First(); db.TreeNodeGroupShares.Remove(tnGpShare); } db.SaveChanges(); // actually remove node db.TreeNodes.Remove(this); db.SaveChanges(); // delete thubnail Thumbnail.DeleteIfNotRefered(db, thumbnailId); }
public TreeNode InsertBranch(PLMPackEntities db, string grpId , string name, string description , Thumbnail thumb) { // group validity if (grpId != GroupId) { throw new ModelException(string.Format("User not allowed to insert under node {0}", GetPath(db))); } // name validity if (HasChildWithName(name)) { throw new ModelException(string.Format("Node {0} ({1}) already has child named {1}", Id, Name, name)); } // create treenode TreeNode tn = new TreeNode(); tn.Id = Guid.NewGuid().ToString(); tn.GroupId = grpId; tn.ParentNodeId = Id; tn.Name = name; tn.Description = description; tn.ThumbnailId = thumb.Id; db.TreeNodes.Add(tn); db.SaveChanges(); return(TreeNode.GetById(db, Guid.Parse(tn.Id))); }
public void UpdateMajorationSet(PLMPackEntities db, CardboardProfile cp, Dictionary <string, double> majorations) { // create majoration set if it does not exists if (db.MajorationSets.Count(mjs => (mjs.ComponentGuid == this.Guid) && (mjs.CardboardProfileId == cp.Id)) == 0) { db.MajorationSets.Add(new MajorationSet() { Id = System.Guid.NewGuid().ToString(), ComponentGuid = this.Guid, CardboardProfileId = cp.Id }); db.SaveChanges(); } // retrieve majoration set MajorationSet majoSet = db.MajorationSets.Single(mjs => (mjs.ComponentGuid == this.Guid) && (mjs.CardboardProfileId == cp.Id)); // delete any existing majorations foreach (Majoration majo in db.Majorations.Where(m => m.MajorationSetId == majoSet.Id)) { db.Majorations.Remove(majo); } db.SaveChanges(); // (re)create majorations foreach (KeyValuePair <string, double> entry in majorations) { majoSet.Majorations.Add(new Majoration() { Name = entry.Key, Value = entry.Value }); } db.SaveChanges(); }
public void Delete(PLMPackEntities db) { // remove all cardboard qualities that use this cardboard db.CardboardQualities.RemoveRange(CardboardQualities); // remove cardboard profile itself db.CardboardProfiles.Remove(this); db.SaveChanges(); }
public void RemoveGroupOfInterest(PLMPackEntities db, Group gp) { if (HasGroupOfInterest(gp)) { GroupsOfInterest.Remove(gp); db.SaveChanges(); } }
public void AddGroupOfInterest(PLMPackEntities db, Group gp) { if (!HasGroupOfInterest(gp)) { GroupsOfInterest.Add(gp); db.SaveChanges(); } }
public Group CurrentGroup(PLMPackEntities db) { if (string.IsNullOrEmpty(GroupId)) { return(null); } return(db.Groups.Single(grp => grp.Id == GroupId)); }
public static TreeNode GetById(PLMPackEntities db , Guid id) { if (Guid.Empty == id) { throw new ModelException("TreeNode.GetById() cannot handle NULL TreeNode Id"); } return(db.TreeNodes.Single(tn => tn.Id == id.ToString())); }
public void Disconnect(PLMPackEntities db) { UserConnection uConnect = db.UserConnections.Where(uc => uc.UserId == Id) .OrderByDescending(uc => uc.DateConnectIN) .FirstOrDefault(); uConnect.DateConnectOUT = DateTime.Now; db.SaveChanges(); }
public static void Initialize(PLMPackEntities db) { if (0 == db.Thumbnails.Count()) { foreach (KeyValuePair <string, string> entry in _tbDictionary) { Thumbnail.CreateNew(db, new Guid(entry.Value), "png"); } } }
public static void PrintAll(PLMPackEntities db, Group gp) { Console.WriteLine(string.Format("### Cardboard formats of Group {0}", gp.GroupName)); var cfs = db.CardboardFormats.Where(c => c.GroupId == gp.Id); foreach (CardboardFormat cf in cfs) { cf.Print(); } }
public static void PrintAll(PLMPackEntities db, Group gp) { Console.WriteLine("Cardboard qualities"); var cqs = db.CardboardQualities.Where(cp => cp.CardboardProfile.GroupId == gp.Id); foreach (CardboardQuality cp in cqs) { cp.Print(); } }
public void Delete(PLMPackEntities db, string grpId) { foreach (MajorationSet majoSet in db.MajorationSets.Where(ms => ms.ComponentGuid == Guid)) { foreach (Majoration majo in db.Majorations.Where(m => m.MajorationSetId == majoSet.Id)) { db.Majorations.Remove(majo); } db.MajorationSets.Remove(majoSet); } }
public bool IsShared(PLMPackEntities db, AspNetUser user) { foreach (Group gp in user.AllGroups(db)) { if (IsShared(gp)) { return(true); } } return(false); }
public static AspNetUser GetByUserName(PLMPackEntities db, string userName) { try { return(db.AspNetUsers.Single(usr => usr.UserName == userName)); } catch (Exception ex) { string message = ex.ToString(); throw ex; } }
public void Connect(PLMPackEntities db) { // initialize user InitializeUser(db); // create user connection UserConnection uConnect = new UserConnection(); uConnect.UserId = Id; uConnect.DateConnectIN = DateTime.Now; uConnect.DateConnectOUT = null; db.UserConnections.Add(uConnect); db.SaveChanges(); }
public DCUser GetUser() { PLMPackEntities db = new PLMPackEntities(); AspNetUser user = AspNetUser.GetByUserName( db, OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.Name ); return new DCUser() { ID = user.Id, Name = user.UserName, Email = user.Email, Phone = user.PhoneNumber, GroupID = user.GroupId }; }
public Component FirstComponent(PLMPackEntities db) { Document doc = FirstDocument(db); if (null != doc) { return(db.Components.Single(comp => comp.DocumentId == doc.Id)); } else { return(null); } }
public TreeNode[] ChildrensByUser(PLMPackEntities db, AspNetUser user) { List <TreeNode> nodes = new List <TreeNode>(); foreach (TreeNode tn in Childrens) { if (tn.IsShared(db, user) && user.HasGroupOfInterest(tn.Group)) { nodes.Add(tn); } } nodes.Sort(); return(nodes.ToArray()); }
public static Thumbnail GetDefaultThumbnail(PLMPackEntities db, string defName) { if (!_tbDictionary.Keys.Contains(defName)) { return(null); } string sGuidThumb = _tbDictionary[defName]; if (db.Thumbnails.Count(tb => string.Equals(sGuidThumb, tb.FileGuid)) != 1) { return(null); } return(db.Thumbnails.Single(tb => string.Equals(sGuidThumb, tb.FileGuid))); }
public static void DeleteIfNotRefered(PLMPackEntities db, int id) { if (0 == db.TreeNodes.Count(tn => tn.ThumbnailId == id)) { Thumbnail thumb = db.Thumbnails.Single(tb => tb.Id == id); // delete thumbnail string fileGuid = thumb.FileGuid; db.Thumbnails.Remove(thumb); db.SaveChanges(); // delete file File f = File.GetById(db, Guid.Parse(fileGuid)); f.Delete(db); } }
public static File CreateNew(PLMPackEntities db, Guid g, string extension) { string sGuid = g.ToString(); // create file File fn = new File(); fn.Guid = sGuid; fn.Extension = extension; fn.DateCreated = DateTime.Now; db.Files.Add(fn); db.SaveChanges(); // return file return(db.Files.Single(f => f.Guid == sGuid)); }
public void Delete(PLMPackEntities db) { string documentId = this.DocumentId; // remove TreeNodeDocuments db.TreeNodeDocuments.Remove(this); db.SaveChanges(); // delete document Document doc = Document.GetByID(db, documentId); if (null != doc) { doc.Delete(db); } }
public static Component CreateNew(PLMPackEntities db, string grpId , string name, string description , Guid fileGuid, Guid compGuid) { Document doc = Document.CreateNew(db, grpId, "DT_COMPONENT", name, description, fileGuid, "dll"); Component cp = new Component() { DocumentId = doc.Id, Guid = compGuid.ToString() }; db.Components.Add(cp); db.SaveChanges(); return(GetByGuid(db, compGuid)); }
public static Thumbnail CreateNew(PLMPackEntities db, Guid fileGuid) { File f = File.GetById(db, fileGuid); Thumbnail tb = new Thumbnail() { Width = 150, Height = 150, FileGuid = fileGuid.ToString(), MimeType = Ext2MimeType(f.Extension) }; db.Thumbnails.Add(tb); db.SaveChanges(); int tid = tb.Id; return(db.Thumbnails.Single(t => t.Id == tid)); }
public void Print(PLMPackEntities db, AspNetUser user, string offset) { // node not shared with user or user has no interest in group that created node if (!IsShared(db, user) || !user.HasGroupOfInterest(Group)) { return; } // actually show node Console.WriteLine(string.Format("{0}->{1}", offset, Name)); // show childrens foreach (TreeNode tn in Childrens) { tn.Print(db, user, offset + " "); } }
public static Thumbnail CreateNew(PLMPackEntities db, Guid g, string ext) { // create thumbnail Thumbnail tb = new Thumbnail(); tb.File = File.CreateNew(db, g, ext); tb.Width = 150; tb.Height = 150; tb.MimeType = Ext2MimeType(ext); db.Thumbnails.Add(tb); db.SaveChanges(); int tid = tb.Id; return(db.Thumbnails.Single(t => t.Id == tid)); }
public Document FirstDocument(PLMPackEntities db) { TreeNodeDocument treeNodeDoc = db.TreeNodeDocuments.Single(tnd => tnd.TreeNodeId == this.Id); return(db.Documents.Single(d => d.Id == treeNodeDoc.DocumentId)); /* * get * { * if (TreeNodeDocuments.Count > 0) * return TreeNodeDocuments.First().Document; * else * return null; * } */ }
public DCUser Connect() { // save connection in database PLMPackEntities db = new PLMPackEntities(); AspNetUser aspNetUser = AspNetUser.GetByUserName(db, UserName); if (null == aspNetUser) return null; aspNetUser.Connect(db); return new DCUser() { ID = aspNetUser.Id, Name = aspNetUser.UserName, Email = aspNetUser.Email, Phone = aspNetUser.PhoneNumber, GroupID = aspNetUser.GroupId }; }
public DCCardboardProfile GetCardboardProfileByID(int id) { PLMPackEntities db = new PLMPackEntities(); CardboardProfile cp = CardboardProfile.GetByID(db, id); bool hasMajorationSets = db.MajorationSets.Count(mjs => mjs.CardboardProfileId == cp.Id) > 0; return new DCCardboardProfile() { ID = cp.Id, Name = cp.Name, Description = cp.Description, Code = cp.Code, Thickness = cp.Thickness, HasMajorationSets = hasMajorationSets }; }
public DCTreeNode[] GetTreeNodeChildrens(Guid nodeId) { PLMPackEntities db = new PLMPackEntities(); AspNetUser user = AspNetUser.GetByUserName(db, UserName); TreeNode node = TreeNode.GetById(db, nodeId); List<DCTreeNode> listTreeNode = new List<DCTreeNode>(); foreach (TreeNode tn in node.ChildrensByUser(db, user)) listTreeNode.Add(Db_2_DCTreeNode(db, user, tn)); return listTreeNode.ToArray(); }
public void UpdateParamDefaultValues(Guid g, DCParamDefaultValue[] paramDefaultValue) { PLMPackEntities db = new PLMPackEntities(); AspNetUser user = AspNetUser.GetByUserName(db, UserName); Component c = Component.GetByGuid(db, g); for (int i = 0; i < paramDefaultValue.Length; ++i) { DCParamDefaultValue param = paramDefaultValue[i]; c.InsertParamDefaultValue(db, user.GroupId, param.Name, param.Value); } }
private DCTreeNode Db_2_DCTreeNode(PLMPackEntities db, AspNetUser user, TreeNode tn) { try { DCNodeTypeEnum nodeType = DCNodeTypeEnum.NTBranch; if (tn.IsDocument) nodeType = DCNodeTypeEnum.NTDocument; if (tn.IsComponent) nodeType = DCNodeTypeEnum.NTComponent; Document d = tn.IsDocument ? tn.FirstDocument(db) : null; Component c = tn.IsComponent ? tn.FirstComponent(db) : null; File f = null; if (null != d) { f = File.GetById(db, Guid.Parse(d.FileGuid)); } return new DCTreeNode() { ID = Guid.Parse(tn.Id), ParentNodeID = Guid.Parse(tn.ParentNodeId), Name = tn.Name, Description = tn.Description, NodeType = nodeType, HasChildrens = tn.HasChildrens, Thumbnail = Db_2_DCThumbnail(tn.Thumbnail), Document = Db_2_DCFile(f), Component = Db_2_Component(db, user, c) }; } catch (Exception ex) { string message = ex.ToString(); return null; } }
public void ShareEveryone(DCTreeNode dcNode) { PLMPackEntities db = new PLMPackEntities(); TreeNode node = TreeNode.GetById(db, dcNode.ID); node.Share(db, AspNetUser.GetByUserName(db, UserName)); }
public DCMajorationSet GetMajorationSet(Guid g, DCCardboardProfile profile) { PLMPackEntities db = new PLMPackEntities(); AspNetUser user = AspNetUser.GetByUserName(db, UserName); Component comp = Component.GetByGuid(db, g); CardboardProfile cp = CardboardProfile.GetByID(db, profile.ID); Dictionary<string, double> dict = comp.GetMajorationSet(db, cp); // instantiate majoration set DCMajorationSet majoSet = new DCMajorationSet() { Profile = new DCCardboardProfile() { ID = cp.Id, Name = cp.Name, Description = cp.Description, Code = cp.Code, Thickness = cp.Thickness }, Majorations = new DCMajoration[dict.Count] }; int iCount = 0; foreach (KeyValuePair<string, double> v in dict) { majoSet.Majorations[iCount] = new DCMajoration() { Name = v.Key, Value = v.Value }; ++iCount; } return majoSet; }
public bool CardboardProfileExists(string name) { PLMPackEntities db = new PLMPackEntities(); AspNetUser user = AspNetUser.GetByUserName(db, UserName); return CardboardProfile.Exists(db, user.CurrentGroup(db), name); }
public DCTreeNode CreateNewNodeComponent(DCTreeNode parentNode, string name, string description, DCThumbnail thumb , DCFile compFile, Guid compGuid, DCMajorationSet[] majorationSets, DCParamDefaultValue[] defaultValues) { try { PLMPackEntities db0 = new PLMPackEntities(); AspNetUser user = AspNetUser.GetByUserName(db0, UserName); TreeNode tnParent = TreeNode.GetById(db0, parentNode.ID); TreeNode tnComponent = tnParent.InsertComponent( db0, user.GroupId, name, description, compFile.Guid, compGuid, Thumbnail.GetByID(db0, thumb.ID)); // retrieve component PLMPackEntities db1 = new PLMPackEntities(); Component comp = Component.GetByGuid(db1, compGuid); // insert default parameter values foreach (DCParamDefaultValue pdv in defaultValues) comp.InsertParamDefaultValue(db1, user.GroupId, pdv.Name, pdv.Value); // set majoration set foreach (DCMajorationSet mjset in majorationSets) { CardboardProfile cp = CardboardProfile.GetByID(db0, mjset.Profile.ID); Dictionary<string, double> dictMajorations = new Dictionary<string,double>(); foreach (DCMajoration maj in mjset.Majorations) dictMajorations[maj.Name] = maj.Value; comp.UpdateMajorationSet(db1, cp, dictMajorations); } return Db_2_DCTreeNode(db1, user, tnComponent); } catch (Exception ex) { string message = ex.ToString(); throw ex; } }
public DCCardboardProfile UpdateCardboardProfile(DCCardboardProfile cbProfile) { PLMPackEntities db = new PLMPackEntities(); CardboardProfile cp = CardboardProfile.GetByID(db, cbProfile.ID); cp.Name = cbProfile.Name; cp.Description = cbProfile.Description; cp.Code = cbProfile.Code; cp.Thickness = cbProfile.Thickness; db.SaveChanges(); return cbProfile; }
public DCFile CreateNewFile(Guid g, string ext) { PLMPackEntities db = new PLMPackEntities(); File f = File.CreateNew(db, g, ext.Trim('.')); return new DCFile() { Guid = new Guid(f.Guid), Extension = f.Extension, DateCreated = f.DateCreated }; }
public void RemoveCardboardProfile(DCCardboardProfile cbProfile) { PLMPackEntities db = new PLMPackEntities(); CardboardProfile cp = CardboardProfile.GetByID(db, cbProfile.ID); cp.Delete(db); }
public DCCardboardProfile CreateNewCardboardProfile(string name, string description, string code, double thickness) { PLMPackEntities db = new PLMPackEntities(); AspNetUser user = AspNetUser.GetByUserName(db, UserName); CardboardProfile cf = CardboardProfile.CreateNew(db, user.CurrentGroup(db), name, description, code, thickness); return new DCCardboardProfile() { ID = cf.Id, Name = cf.Name, Description = cf.Description, Code = cf.Code, Thickness = thickness }; }
public DCCardboardProfile GetCardboardProfileByName(string name) { PLMPackEntities db = new PLMPackEntities(); AspNetUser user = AspNetUser.GetByUserName(db, UserName); CardboardProfile cp = CardboardProfile.GetByName(db, user.CurrentGroup(db), name); return new DCCardboardProfile() { ID = cp.Id, Name = cp.Name, Description = cp.Description, Code = cp.Code, Thickness = cp.Thickness }; }
public DCTreeNode CreateNewNodeBranch(DCTreeNode parentNode, string name, string description, DCThumbnail thumb) { try { PLMPackEntities db = new PLMPackEntities(); AspNetUser user = AspNetUser.GetByUserName(db, UserName); TreeNode tnParent = TreeNode.GetById(db, parentNode.ID); TreeNode tnBranch = tnParent.InsertBranch(db, user.GroupId, name, description, Thumbnail.GetByID(db, thumb.ID)); return Db_2_DCTreeNode(db, user, tnBranch); } catch (Exception ex) { string message = ex.ToString(); throw ex; } }
public DCCardboadFormat UpdateCardboardFormat(DCCardboadFormat cbFormat) { PLMPackEntities db = new PLMPackEntities(); CardboardFormat cf = CardboardFormat.GetById(db, cbFormat.ID); cf.Name = cbFormat.Name; cf.Description = cbFormat.Description; cf.Length = cbFormat.Length; cf.Width = cbFormat.Width; db.SaveChanges(); return cbFormat; }
public DCTreeNode CreateNewNodeDocument(DCTreeNode parentNode, string name, string description, DCThumbnail thumb , DCFile dFile) { try { PLMPackEntities db = new PLMPackEntities(); AspNetUser user = AspNetUser.GetByUserName(db, UserName); TreeNode tnParent = TreeNode.GetById(db, parentNode.ID); TreeNode tnDocument = tnParent.InsertDocument(db, user.GroupId, name, description, FileToDocType(dFile), dFile.Guid, dFile.Extension, Thumbnail.GetByID(db, thumb.ID)); return Db_2_DCTreeNode(db, user, tnDocument); } catch (Exception ex) { string message = ex.ToString(); throw ex; } }
public DCThumbnail CreateNewThumbnail(Guid g, string ext) { PLMPackEntities db = new PLMPackEntities(); Thumbnail tb = Thumbnail.CreateNew(db, g, ext); return new DCThumbnail() { ID = tb.Id, MimeType = tb.MimeType, Width = tb.Width, Height = tb.Height, File = new DCFile() { Guid = new Guid(tb.File.Guid), Extension = tb.File.Extension, DateCreated = tb.File.DateCreated } }; }
public void ShareTreeNode(DCTreeNode dcNode, DCGroup dcGroup) { PLMPackEntities db = new PLMPackEntities(); AspNetUser user = AspNetUser.GetByUserName(db, UserName); Group gp = Group.GetById(db, dcGroup.ID); TreeNode node = TreeNode.GetById(db, dcNode.ID); node.Share(db, user, gp); }
public DCThumbnail GetDefaultThumbnail(string defName) { PLMPackEntities db = new PLMPackEntities(); Thumbnail tb = Thumbnail.GetDefaultThumbnail(db, defName); return new DCThumbnail() { ID = tb.Id, MimeType = tb.MimeType, Width = tb.Width, Height = tb.Height, File = new DCFile() { Guid = new Guid(tb.File.Guid), Extension = tb.File.Extension, DateCreated = tb.File.DateCreated } }; }
public DCComponent GetComponentByGuid(Guid g) { PLMPackEntities db = new PLMPackEntities(); AspNetUser user = AspNetUser.GetByUserName(db, UserName); Component c = Component.GetByGuid(db, g); return Db_2_Component(db, user, c); }
public DCThumbnail GetThumbnailById(int thumbnailId) { PLMPackEntities db = new PLMPackEntities(); Thumbnail tb = Thumbnail.GetByID(db, thumbnailId); return new DCThumbnail() { ID = tb.Id, MimeType = tb.MimeType, Width = tb.Width, Height = tb.Height, File = new DCFile() { Guid = new Guid(tb.File.Guid), Extension = tb.File.Extension, DateCreated = tb.File.DateCreated } }; }
public DCParamDefaultValue[] GetParamDefaultValues(Guid g) { PLMPackEntities db = new PLMPackEntities(); AspNetUser user = AspNetUser.GetByUserName(db, UserName); Component c = Component.GetByGuid(db, g); Dictionary<string, double> dictDefaultValues = c.GetParamDefaultValues(db, user.GroupId); DCParamDefaultValue[] paramDefaultValue = new DCParamDefaultValue[dictDefaultValues.Count]; int iCount = 0; foreach (KeyValuePair<string, double> entry in dictDefaultValues) paramDefaultValue[iCount++] = new DCParamDefaultValue() { Name = entry.Key, Value = entry.Value }; return paramDefaultValue; }
public DCTreeNode[] GetRootNodes() { PLMPackEntities db = new PLMPackEntities(); AspNetUser user = AspNetUser.GetByUserName(db, UserName); TreeNode[] rootNodes = TreeNode.GetRootNodes(db, user); List<DCTreeNode> listTreeNode = new List<DCTreeNode>(); foreach (TreeNode tn in rootNodes) { listTreeNode.Add(new DCTreeNode() { ID = new Guid(tn.Id), ParentNodeID = Guid.Empty, Name = tn.Name, Description = tn.Description, NodeType = DCNodeTypeEnum.NTBranch, HasChildrens = tn.HasChildrens } ); } return listTreeNode.ToArray(); }
private DCComponent Db_2_Component(PLMPackEntities db, AspNetUser user, Component c) { // null component if (null == c) return null; // ### component default parameter values List<DCParamDefaultValue> paramDefaults = new List<DCParamDefaultValue>(); Dictionary<string, double> dictParamDefaults = c.GetParamDefaultValues(db, user.GroupId); foreach (KeyValuePair<string, double> entry in dictParamDefaults) { paramDefaults.Add( new DCParamDefaultValue() { Name = entry.Key, Value = entry.Value } ); } // ### component default majorations List<DCMajorationSet> majoSets = new List<DCMajorationSet>(); foreach (MajorationSet mjs in c.MajorationSet) { List<DCMajoration> listMajo = new List<DCMajoration>(); CardboardProfile cp = CardboardProfile.GetByID(db, mjs.CardboardProfileId); majoSets.Add(new DCMajorationSet() { Profile = new DCCardboardProfile() { ID = cp.Id, Name = cp.Name, Description = cp.Description, Code = cp.Code, Thickness = cp.Thickness }, Majorations = listMajo.ToArray() } ); } return new DCComponent() { CGuid = new Guid(c.Guid), File = Db_2_DCFile(c.Document.File), ParamDefaults = paramDefaults.ToArray(), MajoSets = majoSets.ToArray() }; }
public DCTreeNode GetUserRootNode() { PLMPackEntities db = new PLMPackEntities(); AspNetUser user = AspNetUser.GetByUserName(db, UserName); TreeNode tnRoot = TreeNode.GetUserRootNode(db, user); return new DCTreeNode() { ID = new Guid(tnRoot.Id), ParentNodeID = Guid.Empty, Name = tnRoot.Name, Description = tnRoot.Description, NodeType = DCNodeTypeEnum.NTBranch, HasChildrens = tnRoot.HasChildrens }; }
public Guid UploadDefault(string defName, string fileExt) { PLMPackEntities db = new PLMPackEntities(); Guid g = Thumbnail.GetDefaultGuid(defName); if (null == Thumbnail.GetDefaultThumbnail(db, defName)) { File f = File.CreateNew(db, g, fileExt); Thumbnail.CreateNew(db, g); } return g; }
public DCCardboardProfile[] GetAllCardboardProfile() { PLMPackEntities db = new PLMPackEntities(); AspNetUser user = AspNetUser.GetByUserName(db, UserName); CardboardProfile[] cardboardProfiles = CardboardProfile.GetAll(db, user.CurrentGroup(db)); List<DCCardboardProfile> listCardboardProfiles = new List<DCCardboardProfile>(); foreach (CardboardProfile cp in cardboardProfiles) { listCardboardProfiles.Add( new DCCardboardProfile() { ID = cp.Id, Name = cp.Name, Description = cp.Description, Code = cp.Code, Thickness = cp.Thickness } ); } // sort by name return listCardboardProfiles.ToArray(); }