Esempio n. 1
0
        public void RemoveCardboardFormat(DCCardboadFormat cbFormat)
        {
            PLMPackEntities db = new PLMPackEntities();
            CardboardFormat cf = CardboardFormat.GetById(db, cbFormat.ID);

            cf.Delete(db);
        }
 /// <summary>
 /// copy cardboard formats from dbFrom to dbTo
 /// </summary>
 public static void CopyCardboardFormats(PPDataContext dbFrom, PPDataContext dbTo)
 {
     foreach (CardboardFormat cf in dbFrom.CardboardFormats)
     {
         CardboardFormat.CreateNew(dbTo, cf.Name, cf.Description, cf.Length, cf.Width);
     }
 }
Esempio n. 3
0
        public bool CardboardFormatExists(string name)
        {
            PLMPackEntities db   = new PLMPackEntities();
            AspNetUser      user = AspNetUser.GetByUserName(db, UserName);

            return(CardboardFormat.Exists(db, user.CurrentGroup(db), name));
        }
Esempio n. 4
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);
        }
Esempio n. 5
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
            });
        }
Esempio n. 6
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
            });
        }
Esempio n. 7
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
            });
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            XmlConfigurator.Configure();

            try
            {
                PLMPackLibDb db = new PLMPackLibDb();
                #region Cardboad formats
                // create formats
                CardboardFormat cbf = null;
                if (!CardboardFormat.Exists(db, "F1"))
                {
                    cbf = CardboardFormat.CreateNew(db, "F1", "Form1", 1000.0f, 1000.0f);
                }
                if (!CardboardFormat.Exists(db, "F2"))
                {
                    cbf = CardboardFormat.CreateNew(db, "F2", "Form2", 2000.0f, 2000.0f);
                }
                if (!CardboardFormat.Exists(db, "F3"))
                {
                    cbf = CardboardFormat.CreateNew(db, "F3", "Form3", 3000.0f, 3000.0f);
                }
                // get list of formats
                foreach (CardboardFormat f in CardboardFormat.GetAll(db))
                {
                    _log.Info(f.ToString());
                }
                #endregion

                #region Cardboard profile
                CardboardProfile cbp = null;
                if (!CardboardProfile.Exists(db, "P1"))
                {
                    cbp = CardboardProfile.CreateNew(db, "P1", "Profile 1", 1.0f);
                }
                #endregion
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }
 public static void MergeCardboardFormats(PPDataContext dbFrom, PPDataContext dbTo, IProcessingCallback callback)
 {
     foreach (CardboardFormat cf in dbFrom.CardboardFormats)
     {
         if (CardboardFormat.HasByName(dbTo, cf.Name))
         {
             if (null != callback)
             {
                 callback.Info(string.Format("Cardboard format {0} already exists. Skipping...", cf.Name));
             }
         }
         else
         {
             if (null != callback)
             {
                 callback.Info(string.Format("Creating carboard format {0}...", cf.Name));
             }
             CardboardFormat.CreateNew(dbTo, cf.Name, cf.Description, cf.Length, cf.Width);
         }
     }
 }
Esempio n. 10
0
        public DCCardboadFormat[] GetAllCardboardFormats()
        {
            PLMPackEntities db   = new PLMPackEntities();
            AspNetUser      user = AspNetUser.GetByUserName(db, UserName);

            CardboardFormat[]       cardboardFormats    = CardboardFormat.GetAll(db, user.CurrentGroup(db));
            List <DCCardboadFormat> listCardboardFormat = new List <DCCardboadFormat>();

            foreach (CardboardFormat cf in cardboardFormats)
            {
                listCardboardFormat.Add(new DCCardboadFormat()
                {
                    ID          = cf.Id,
                    Name        = cf.Name,
                    Description = cf.Description,
                    Length      = cf.Length,
                    Width       = cf.Width
                }
                                        );
            }
            return(listCardboardFormat.ToArray());
        }
 private void OnCardboardFormatChanged()
 {
     _cardboardFormat = cbCardboardFormat.SelectedItem as CardboardFormat;
 }
 public ImpositionToolCardboardFormat(IEntityContainer container, CardboardFormat cardboardFormat)
     : base(container)
 {
     _cardboardFormat = cardboardFormat;
 }
Esempio n. 13
0
 private void OnCardboardFormatChanged()
 {
     _cardboardFormat = cbCardboardFormat.SelectedItem as CardboardFormat;
 }
        static void Main(string[] args)
        {
            // set up a simple configuration that logs on the console.
            XmlConfigurator.Configure();

            bool deleteAll = true;

            try
            {
                // ================================ CardboardFormat
                try
                {
                    PPDataContext   db   = new PPDataContext();
                    CardboardFormat cbf1 = CardboardFormat.CreateNew(db, "F1", "Format 1", 1000.0f, 1000.0f);
                    _log.Info(string.Format("Created new cardboard format with Id = {0}", cbf1.ID));
                    CardboardFormat cbf2 = CardboardFormat.CreateNew(db, "F2", "Format 2", 2000.0f, 2000.0f);
                    _log.Info(string.Format("Created new cardboard format with Id = {0}", cbf2.ID));
                    CardboardFormat cbf3 = CardboardFormat.CreateNew(db, "F3", "Format 3", 3000.0f, 3000.0f);
                    _log.Info(string.Format("Created new cardboard format with Id = {0}", cbf3.ID));

                    foreach (CardboardFormat cbf in CardboardFormat.GetAll(db))
                    {
                        _log.Info(cbf.ToString());
                    }
                }
                catch (System.Exception ex) { _log.Error(ex.Message); }
                // ================================
                // ================================ CardboardProfile
                // get list of existing cardboards
                try
                {
                    PPDataContext db = new PPDataContext();
                    IEnumerable <CardboardProfile> profiles = from cp in db.CardboardProfiles select cp;
                    foreach (CardboardProfile cbp in profiles)
                    {
                        _log.Info(cbp.ToString());
                    }
                    db.Dispose();
                }
                catch (System.Exception ex) { _log.Error(ex.Message); }
                // add first CardboardProfile ->expected to throw exception if already exists
                try
                {
                    PPDataContext    db         = new PPDataContext();
                    CardboardProfile cbprofile1 = CardboardProfile.CreateNew(db, "Profile1", "P1", 0.1f);
                    _log.Info(string.Format("created cardboard profile with Id = {0}", cbprofile1.ID));
                    db.Dispose();
                }
                catch (ExceptionDAL ex) { _log.Debug(ex.Message); }
                catch (Exception ex) { _log.Error(ex.Message); }
                // add second CardboardProfile
                try
                {
                    PPDataContext    db         = new PPDataContext();
                    CardboardProfile cbprofile2 = CardboardProfile.CreateNew(db, "Profile2", "P2", 0.2f);
                    _log.Info(string.Format("created cardboard profile with Id = {0}", cbprofile2.ID));
                    db.Dispose();
                }
                catch (ExceptionDAL ex) { _log.Debug(ex.Message); }
                catch (Exception ex) { _log.Error(ex.Message); }
                // delete CardboardProfile
                {
                    PPDataContext    db      = new PPDataContext();
                    CardboardProfile profile = db.CardboardProfiles.Single <CardboardProfile>(cp => cp.Code == "P2");
                    db.CardboardProfiles.DeleteOnSubmit(profile);
                    db.SubmitChanges();
                }
                // ================================
                // ================================ DocumentType
                // add new DocumentType
                try
                {
                    PPDataContext db      = new PPDataContext();
                    DocumentType  docType = DocumentType.CreateNew(db, "Parametric component", "Parametric component to be used in PicParam", "PicParam");
                    _log.Info(string.Format("created document type with Id = {0}", docType.ID));
                    db.Dispose();
                }
                catch (ExceptionDAL ex) { _log.Debug(ex.Message); }
                catch (Exception ex) { _log.Error(ex.Message); }

                // ================================
                // ================================ TreeNode
                // create new rootNodes
                string imageFilePath = string.Empty;
                try
                {
                    PPDataContext db        = new PPDataContext();
                    TreeNode      rootNode1 = TreeNode.CreateNew(db, "Parametric components", "Parametric component to be used in PicParam", imageFilePath);
                    db.Dispose();
                }
                catch (ExceptionDAL ex) { _log.Debug(ex.Message); }
                catch (Exception ex) { _log.Error(ex.Message); }

                try
                {
                    PPDataContext db        = new PPDataContext();
                    TreeNode      rootNode2 = TreeNode.CreateNew(db, "Drawing files", "Either PicGEOM or Autocad dxf files", imageFilePath);
                }
                catch (ExceptionDAL ex) { _log.Debug(ex.Message); }
                catch (Exception ex) { _log.Error(ex.Message); }

                // create new child treenode
                try
                {
                    PPDataContext db         = new PPDataContext();
                    TreeNode      parentNode = TreeNode.GetRootNodes(db)[0];
                    TreeNode      childNode1 = parentNode.CreateChild(db, "Node1", "Node1", imageFilePath);
                    db.Dispose();
                }
                catch (ExceptionDAL ex) { _log.Debug(ex.Message); }
                catch (Exception ex) { _log.Error(ex.Message); }

                Guid guidComponent = Guid.Empty;

                // ================================
                // ================================ Component
                // create new child node + component
                try
                {
                    PPDataContext db         = new PPDataContext();
                    TreeNode      parentNode = TreeNode.GetRootNodes(db)[0];
                    TreeNode      childNode1 = parentNode.Childrens(db)[0];
                    TreeNode      childNode2 = null;
                    try
                    {
                        childNode2 = childNode1.CreateChild(db, "Node2", "Node2", imageFilePath);
                        _log.Info(string.Format("successfully created Node with ID = {0}", childNode2.ID));
                    }
                    catch (ExceptionDAL ex) { _log.Debug(ex.Message); }
                    if (null == childNode2)
                    {
                        childNode2 = childNode1.Childrens(db)[0];
                    }
                    // insert component
                    string    filePath  = @"K:\Codesion\PicSharp\Pic.Plugin.SimpleRectangle\bin\Release\Pic.Plugin.SimpleRectangle.dll";
                    Component component = childNode2.InsertComponent(db, filePath, Guid.NewGuid(), "Rounded rectangle", "Rounded rectangle", "");
                    guidComponent = component.Guid;
                    // set majorations
                    Dictionary <string, double> majorations = new Dictionary <string, double>();
                    majorations.Add("m1", 1.0);
                    majorations.Add("m2", 2.0);
                    component.InsertNewMajorationSet(db, "Profile1", majorations);
                    db.Dispose();
                }
                catch (ExceptionDAL ex) { _log.Debug(ex.Message); }
                catch (Exception ex) { _log.Error(ex.Message); }
                // ================================
                // ================================ Document
                // create documents
                try
                {
                    PPDataContext db         = new PPDataContext();
                    TreeNode      parentNode = TreeNode.GetRootNodes(db)[0];
                    string        filePath   = @"K:\SVN Projects\PicSharp\Pic.Plugin.SimpleRectangle\bin\Release\Pic.Plugin.SimpleRectangle.dll";
                    parentNode.InsertDocument(db, filePath, "Rounded rectangle", "Rounded Rectangle", "Parametric component", "");
                    db.Dispose();
                }
                catch (ExceptionDAL ex) { _log.Debug(ex.Message); }
                catch (Exception ex) { _log.Error(ex.Message); }

                // ================================
                // ================================ TreeBuilder
                // show document tree
                TreeBuilder builder     = new TreeBuilder();
                TreeConsole treeConsole = new TreeConsole();
                builder.BuildTree(treeConsole);
                // ================================
                // ================================
                try
                {
                    // retrieve component
                    PPDataContext db        = new PPDataContext();
                    Component     component = Component.GetByGuid(db, guidComponent);
                    if (null == component)
                    {
                        throw new ExceptionDAL(string.Format("No component with Guid = {0}", guidComponent));
                    }

                    CardboardProfile profile3 = CardboardProfile.GetByName(db, "P3");
                    if (null == profile3)
                    {
                        profile3 = CardboardProfile.CreateNew(db, "P3", "P3", 3.0f);
                    }
                    Dictionary <string, double> defaultMajorations = Component.GetDefaultMajorations(db, component.ID, profile3, Component.MajoRounding.ROUDING_FIRSTDECIMALNEAREST);
                    component.InsertNewMajorationSet(db, profile3.Name, defaultMajorations);
                    defaultMajorations["m1"] = 100.0;
                    defaultMajorations["m2"] = 100.0;
                    component.UpdateMajorationSet(db, profile3, defaultMajorations);
                    db.Dispose();
                }
                catch (ExceptionDAL ex) { _log.Debug(ex.Message); }
                catch (Exception ex) { _log.Error(ex.Message); }
                // ================================
                // ================================ TreeBuilder
                // show document tree
                builder.BuildTree(treeConsole);
                // ================================
                // ================================ Delete components / documents
                try
                {
                    if (deleteAll)
                    {
                        PPDataContext db = new PPDataContext();
                        Component.DeleteAll(db);
                        _log.Info("Successfully deleted Components...");
                        Document.DeleteAll(db);
                        _log.Info("Successfully deleted Documents...");
                        DocumentType.DeleteAll(db);
                        _log.Info("Successfully deleted DocumentTypes...");
                        TreeNode.DeleteAll(db);
                        _log.Info("Successfully deleted TreeNodes...");
                        CardboardProfile.DeleteAll(db);
                        _log.Info("Successfully deleted CardboardProfile...");
                        CardboardFormat.DeleteAll(db);
                        _log.Info("Successfully deleted Cardboard formats...");
                        db.Dispose();
                    }
                }
                catch (ExceptionDAL ex) { _log.Debug(ex.Message); }
                catch (System.Exception ex) { _log.Error(ex.Message); }
                // ================================
                // ================================ TreeBuilder
                // show document tree
                builder.BuildTree(treeConsole);
                // ================================
            }
            catch (System.Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }