Exemplo n.º 1
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);
        }
Exemplo n.º 2
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;
 }
Exemplo n.º 3
0
        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;
            }
        }