コード例 #1
0
        public void SetCurrentGroup(string grpId)
        {
            PLMPackEntities db   = new PLMPackEntities();
            AspNetUser      user = AspNetUser.GetByUserName(db, UserName);

            user.SetCurrentGroup(db, Group.GetById(db, grpId));
        }
コード例 #2
0
        public void ShareEveryone(DCTreeNode dcNode)
        {
            PLMPackEntities db   = new PLMPackEntities();
            TreeNode        node = TreeNode.GetById(db, dcNode.ID);

            node.Share(db, AspNetUser.GetByUserName(db, UserName));
        }
コード例 #3
0
        public void RemoveCardboardProfile(DCCardboardProfile cbProfile)
        {
            PLMPackEntities  db = new PLMPackEntities();
            CardboardProfile cp = CardboardProfile.GetByID(db, cbProfile.ID);

            cp.Delete(db);
        }
コード例 #4
0
        public bool CardboardProfileExists(string name)
        {
            PLMPackEntities db   = new PLMPackEntities();
            AspNetUser      user = AspNetUser.GetByUserName(db, UserName);

            return(CardboardProfile.Exists(db, user.CurrentGroup(db), name));
        }
コード例 #5
0
        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());
        }
コード例 #6
0
        public void RemoveCardboardFormat(DCCardboadFormat cbFormat)
        {
            PLMPackEntities db = new PLMPackEntities();
            CardboardFormat cf = CardboardFormat.GetById(db, cbFormat.ID);

            cf.Delete(db);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        public DCGroup GetCurrentGroup()
        {
            PLMPackEntities db    = new PLMPackEntities();
            AspNetUser      user  = AspNetUser.GetByUserName(db, UserName);
            Group           grp   = Group.GetById(db, user.GroupId);
            List <DCUser>   users = new List <DCUser>();

            foreach (AspNetUser u in grp.AspNetUsers)
            {
                users.Add(
                    new DCUser()
                {
                    ID      = u.Id,
                    Name    = u.UserName,
                    Phone   = u.PhoneNumber,
                    Email   = u.Email,
                    GroupID = grp.Id
                }
                    );
            }
            return(new DCGroup()
            {
                ID = grp.Id,
                Name = grp.GroupName,
                Description = grp.GroupDesc,
                Members = users.ToArray()
            });
        }
コード例 #9
0
        public void DisConnect()
        {
            // save connection in database
            PLMPackEntities db         = new PLMPackEntities();
            AspNetUser      aspNetUser = AspNetUser.GetByUserName(db, UserName);

            aspNetUser.Disconnect(db);
        }
コード例 #10
0
        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));
        }
コード例 #11
0
        public void RemoveInterest(string grpId)
        {
            PLMPackEntities db   = new PLMPackEntities();
            AspNetUser      user = AspNetUser.GetByUserName(db, UserName);
            Group           grp  = Group.GetById(db, grpId);

            user.RemoveGroupOfInterest(db, grp);
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        public DCGroup GetGroupEveryone()
        {
            PLMPackEntities db  = new PLMPackEntities();
            Group           grp = Group.GetByName(db, "Everyone");

            return(new DCGroup()
            {
                ID = grp.Id, Name = grp.GroupName, Description = grp.GroupDesc
            });
        }
コード例 #14
0
        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);
        }
コード例 #15
0
        public DCCardboadFormat CreateNewCardboardFormat(string name, string description, double length, double width)
        {
            PLMPackEntities db   = new PLMPackEntities();
            AspNetUser      user = AspNetUser.GetByUserName(db, UserName);
            Group           gp   = Group.GetById(db, user.GroupId);
            CardboardFormat cf   = CardboardFormat.CreateNew(db, gp, name, description, length, width);

            return(new DCCardboadFormat()
            {
                ID = cf.Id, Name = cf.Name, Description = cf.Description, Length = cf.Length, Width = cf.Width
            });
        }
コード例 #16
0
        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
            });
        }
コード例 #17
0
        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);
        }
コード例 #18
0
        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);
        }
コード例 #19
0
        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);
            }
        }
コード例 #20
0
        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());
        }
コード例 #21
0
        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
            });
        }
コード例 #22
0
        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()
            });
        }
コード例 #23
0
        public DCCardboadFormat GetCardboardFormatByID(int id)
        {
            PLMPackEntities db   = new PLMPackEntities();
            AspNetUser      user = AspNetUser.GetByUserName(db, UserName);
            CardboardFormat cf   = CardboardFormat.GetById(db, id);

            return(new DCCardboadFormat()
            {
                ID = cf.Id,
                Name = cf.Name,
                Description = cf.Description,
                Length = cf.Length,
                Width = cf.Width
            });
        }
コード例 #24
0
        public DCCardboadFormat GetCardboardFormatByName(string name)
        {
            PLMPackEntities db   = new PLMPackEntities();
            AspNetUser      user = AspNetUser.GetByUserName(db, UserName);
            CardboardFormat cf   = CardboardFormat.GetByName(db, user.CurrentGroup(db), name);

            return(new DCCardboadFormat()
            {
                ID = cf.Id,
                Name = cf.Name,
                Description = cf.Description,
                Length = cf.Length,
                Width = cf.Width
            });
        }
コード例 #25
0
        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
            });
        }
コード例 #26
0
        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
            });
        }
コード例 #27
0
        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
            });
        }
コード例 #28
0
 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;
     }
 }
コード例 #29
0
        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
            });
        }
コード例 #30
0
 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;
     }
 }