示例#1
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;
     }
 }
示例#2
0
        public DCThumbnail CreateNewThumbnailFromFile(DCFile file)
        {
            PLMPackEntities db = new PLMPackEntities();
            Thumbnail       tb = Thumbnail.CreateNew(db, file.Guid);

            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
                }
            });
        }
示例#3
0
        public string FileToDocType(DCFile f)
        {
            switch (f.Extension.Trim('.').ToLower())
            {
            case "doc": return("DT_WORD");

            case "xls": return("DT_EXCEL");

            case "dll": return("COMPONENT");

            case "des": return("DT_PICGEOM");

            case "des3": return("DT_PICADOR3D");

            case "pdf": return("DT_ACROBAT");

            case "ai": return("DT_ILLUSTRATOR");

            case "dxf": return("DT_ACAD");

            case "dwg": return("DT_ACAD");

            case "sxw": return("DT_WRITER");

            case "stw": return("DT_WRITER");

            case "sxc": return("DT_CALC");

            case "stc": return("DT_CALC");

            case "ard": return("DT_ARTIOS");

            case "cf2": return("DT_CCF2");

            case "png": return("DT_IMAGE");

            case "bmp": return("DT_IMAGE");

            case "jpg": return("DT_IMAGE");

            case "jpeg": return("DT_IMAGE");

            default: return("DT_UNKNOWN");
            }
        }
示例#4
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;
            }
        }
示例#5
0
 public string FileToDocType(DCFile f)
 {
     switch (f.Extension.Trim('.').ToLower())
     {
         case "doc": return "DT_WORD";
         case "xls": return "DT_EXCEL";
         case "dll": return "COMPONENT";
         case "des": return "DT_PICGEOM";
         case "des3": return "DT_PICADOR3D";
         case "pdf": return "DT_ACROBAT";
         case "ai": return "DT_ILLUSTRATOR";
         case "dxf": return "DT_ACAD";
         case "dwg": return "DT_ACAD";
         case "sxw": return "DT_WRITER";
         case "stw": return "DT_WRITER";
         case "sxc": return "DT_CALC";
         case "stc": return "DT_CALC";
         case "ard": return "DT_ARTIOS";
         case "cf2": return "DT_CCF2";
         case "png": return "DT_IMAGE";
         case "bmp": return "DT_IMAGE";
         case "jpg": return "DT_IMAGE";
         case "jpeg": return "DT_IMAGE";
         default: return "DT_UNKNOWN";
     }
 }
示例#6
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;
            }
        }
示例#7
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;
     }
 }
示例#8
0
 public DCThumbnail CreateNewThumbnailFromFile(DCFile file)
 {
     PLMPackEntities db = new PLMPackEntities();
     Thumbnail tb = Thumbnail.CreateNew(db, file.Guid);
     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 }
     };
 }