Exemplo n.º 1
0
 public UnitOfWork(ApplicationDbContext context)
 {
     _context   = context;
     Brands     = new BrandsRepository(context);
     Categories = new CategoriesRepository(context);
     Parts      = new PartsRepository(context);
     Suppliers  = new SupplierRepository(context);
 }
Exemplo n.º 2
0
        // -- constructor

        public SimpleDevice()
        {
            Uuid        = Guid.NewGuid().ToString();
            Name        = Const.Device.Name;
            Description = Const.Device.Description;
            Position    = new Vertex(Const.Device.PosX, Const.Device.PosY, Const.Device.PosZ);
            Orientation = new Angle(Const.Antenna.Azimuth, Const.Antenna.Elevation);
            IsActive    = true;

            Parts    = new PartsRepository();
            Controls = new SimpleControls(this);
        }
Exemplo n.º 3
0
 public UnitOfWork(ApplicationDbContext context)
 {
     _context               = context;
     Brands                 = new BrandsRepository(context);
     Categories             = new CategoriesRepository(context);
     Parts                  = new PartsRepository(context);
     Suppliers              = new SupplierRepository(context);
     PartsWithdrawHistories = new PartsWithdrawHistoryRepository(context);
     PartsPurchaseRecords   = new PartsPurchaseRecordsReposiroty(context);
     Inventory              = new InventoryRepository(context);
     Addresses              = new AddressRepository(context);
 }
        public BHEUnitOfWork(BrownsAppDBEntities1 bheDBContext)
        {
            _bheDBContext = bheDBContext;

            PartsRepository        = new PartsRepository(_bheDBContext);
            UserRepository         = new UserRepository(_bheDBContext);
            CompanyRepository      = new CompanyRepository(_bheDBContext);
            LogsRepository         = new LogsRepository(_bheDBContext);
            CustomerRepository     = new CustomerRepository(_bheDBContext);
            InvoiceRepository      = new InvoiceRepository(_bheDBContext);
            InvoiceItemsRepository = new InvoiceItemsRepository(_bheDBContext);
            InvoiceLaborRepository = new InvoiceLaborRepository(_bheDBContext);
            RepairRepository       = new RepairRepository(_bheDBContext);
        }
Exemplo n.º 5
0
        private static int AddPartToProject(PipingProject prjpart, string strSpec, ObjectId partId, PartRep.SpecPart specPart)
        {
            Autodesk.ProcessPower.DataObjects.PnPDatabase db = prjpart.DataLinksManager.GetPnPDatabase();
            PartsRepository rep = PartsRepository.AttachedRepository(db, false);

            // Create new part in project
            Autodesk.ProcessPower.PartsRepository.Part part = rep.NewPart(specPart.PartType);
            rep.AutoAccept = false;

            // Assign property values in project
            StringCollection props = specPart.PropertyNames;

            for (int i = 0; i < props.Count; ++i)
            {
                PartProperty prop = rep.GetPartProperty(specPart.PartType, props[i], false);
                if (prop == null || prop.IsExpression)
                {
                    continue;   // can't be assigned
                }
                try
                {
                    part[props[i]] = specPart[props[i]];
                }
                catch (Autodesk.AutoCAD.Runtime.Exception ex)
                {
                    // display exception on the command line
                    Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
                    ed.WriteMessage(ex.ToString());
                }
            }

            // assign special spec property
            //
            try
            {
                part["Spec"] = strSpec;
            }
            catch (Autodesk.AutoCAD.Runtime.Exception ex)
            {
                // display exception on the command line
                Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
                ed.WriteMessage(ex.ToString());
            }

            // add reference to spec record only if it is not set yet
            //
            try
            {
                if (part["SpecRecordId"] == System.DBNull.Value)
                {
                    part["SpecRecordId"] = specPart.PartId;
                }
            }
            catch (Autodesk.AutoCAD.Runtime.Exception ex)
            {
                // display exception on the command line
                Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
                ed.WriteMessage(ex.ToString());
            }


            // Ok now deal with the ports
            //
            Autodesk.ProcessPower.PartsRepository.PortCollection ports          = specPart.Ports;
            Autodesk.ProcessPower.PartsRepository.Port           principal_port = ports[0];

            foreach (Autodesk.ProcessPower.PartsRepository.Port port in ports)
            {
                System.Guid sizeRecId = System.Guid.Empty;
                if (string.Compare(port.Name, principal_port.Name) != 0)
                {
                    sizeRecId = (System.Guid)port["SizeRecordId"];
                }

                Autodesk.ProcessPower.PartsRepository.Port newPort = null;
                bool bNew        = true;
                bool bNeedAccept = false;

                // Principal port is embedded.
                //
                if (sizeRecId != System.Guid.Empty)
                {
                    newPort     = part.NewPortBySizeRecordId(port.Name, sizeRecId.ToString(), out bNew);
                    bNeedAccept = true;
                }
                else
                {
                    newPort = part.NewPort(port.Name);
                }

                if (bNew)
                {
                    foreach (string prop in port.PropertyNames)
                    {
                        if (string.Compare(prop, "PortName", true) == 0)
                        {
                            continue;   // dont copy port name
                        }
                        try
                        {
                            newPort[prop] = port[prop];
                        }
                        catch (Autodesk.AutoCAD.Runtime.Exception ex)
                        {
                            // display exception on the command line
                            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
                            ed.WriteMessage(ex.ToString());
                        }
                    }

                    if (bNeedAccept)
                    {
                        try
                        {
                            rep.CommitPort(newPort);
                        }
                        catch (Autodesk.AutoCAD.Runtime.Exception ex)
                        {
                            // display exception on the command line
                            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
                            ed.WriteMessage(ex.ToString());
                        }
                    }
                }

                part.Ports.Add(newPort);
            }

            // Add new part to the project database
            rep.AddPart(part);

            // Transform properties sentitive to current project's unit settings
            switch (prjpart.ProjectUnitsType)
            {
            case ProjectUnitsType.eMetric:
                part.TransformPropertiesToUnits(Units.Mm, Units.Mm);
                break;

            case ProjectUnitsType.eMixedMetric:
                part.TransformPropertiesToUnits(Units.Mm, Units.Inch);
                break;

            case ProjectUnitsType.eImperial:
                part.TransformPropertiesToUnits(Units.Inch, Units.Inch);
                break;
            }

            int cacheId = part.PartId;

            // Finally now we can link entity to row in project
            if (cacheId != -1)
            {
                Autodesk.ProcessPower.DataLinks.DataLinksManager dlm = prjpart.DataLinksManager;
                try
                {
                    dlm.Link(partId, cacheId);
                }
                catch
                {
                    cacheId = -1;;
                }
            }

            return(cacheId); // -1 for error
        }