Пример #1
0
        public bool UpdateStatus(int id, bool status)
        {
            PropModified <Promotion> modified = new PropModified <Promotion>(new { Status = status });

            using (var db = new EntityDAO <Promotion>(_context))
                return(db.Update(id, modified));
        }
Пример #2
0
        public void FixtureSetUp()
        {
            entityDAO = new EntityDAO();

            // TestDBInit.openConn();
            TestDBInit.openConn();
        }
        public Dictionary <ulong, EtyEntity> GetDataNodeListByServerRootName(string servreRootName)
        {
            EntityDAO dao = new EntityDAO();

//            bool checkLoc = !(LocationKeyHelper.GetInstance().IsOCC);
//            ulong locKey = LocationKeyHelper.GetInstance().LocationKey;

            return(dao.GetAllDataNodesByServerRootName(servreRootName));
        }
        public Dictionary <ulong, EtyEntity> GetDataPointByDNPkey(ulong pkey)
        {
            EntityDAO dao = new EntityDAO();

//            bool checkLoc = !(LocationKeyHelper.GetInstance().IsOCC);
//            ulong locKey = LocationKeyHelper.GetInstance().LocationKey;

            return(dao.GetDataPointByDNPkey(pkey));
        }
Пример #5
0
 public T AddDTO(T newObj)
 {
     if (newObj == null)
     {
         return(default(T));
     }
     using (EntityDAO <V> db = new EntityDAO <V>(_context))
         return(ObjectMapperTo <V, T>(db.Add(ObjectMapperTo <T, V>(newObj))));
 }
Пример #6
0
        public bool UpdateDTO(int id, PromotionDTO promotionDTO, string promDetail)
        {
            var prom = ObjectMapperTo <PromotionDTO, Promotion>(promotionDTO);
            PropModified <Promotion> modifiedProm = new PropModified <Promotion>(prom);
            int typeItem;

            using (var db = new EntityDAO <Promotion>(_context))
            {
                var obj = db.Get(id);
                if (obj == null)
                {
                    return(false);
                }
                typeItem = (int)obj.Type;
                if (!db.Update(id, modifiedProm))
                {
                    return(false);
                }
            }

            switch (typeItem)
            {
            case 1:
            {
                var promProduct = DataHelper.ParserJsonTo <PromProduct>(promDetail);
                PropModified <PromProduct> modifiedProduct = new PropModified <PromProduct>(promProduct);
                if (modifiedProduct.isChanged)
                {
                    using (var db = new EntityDAO <PromProduct>(_context))
                        if (!db.Update(id, modifiedProduct))
                        {
                            return(false);
                        }
                }
                break;
            }

            case 2:
            {
                var promBill = DataHelper.ParserJsonTo <PromBill>(promDetail);
                PropModified <PromBill> modifiedBill = new PropModified <PromBill>(promBill);
                if (modifiedBill.isChanged)
                {
                    using (var db = new EntityDAO <PromBill>(_context))
                        if (!db.Update(id, modifiedBill))
                        {
                            return(false);
                        }
                }
                break;
            }

            default: return(false);
            }
            return(true);
        }
Пример #7
0
 public T GetDTO(int id)
 {
     if (id < 0)
     {
         return(default(T));
     }
     //
     using (EntityDAO <V> db = new EntityDAO <V>(_context))
         return(ObjectMapperTo <V, T>(db.Get(id)));
 }
Пример #8
0
        public ProductDetailDTO GetDetailDTO(string productId)
        {
            if (DataHelper.IsEmptyString(productId))
            {
                return(null);
            }
            var detailId = DataHelper.GetDetailId(productId);

            using (EntityDAO <ProductDetail> db = new EntityDAO <ProductDetail>(_context))
                return(ObjectMapperTo <ProductDetail, ProductDetailDTO>(db.Get(detailId)));
        }
Пример #9
0
 public bool RemoveDTO(int id)
 {
     if (id < 0)
     {
         return(false);
     }
     //
     using (EntityDAO <V> db = new EntityDAO <V>(_context))
     {
         return(db.Remove(id));
     }
 }
Пример #10
0
        public bool RemoveDTO(string productId)
        {
            if (DataHelper.IsEmptyString(productId))
            {
                return(false);
            }
            var detailId = DataHelper.GetDetailId(productId);
            PropModified <ProductDetail> modified = new PropModified <ProductDetail>(new { isDel = true });

            using (EntityDAO <ProductDetail> db = new EntityDAO <ProductDetail>(_context))
                return(db.Update(detailId, modified));
        }
Пример #11
0
        public bool UpdateStatusDTO(string productId, bool status)
        {
            if (DataHelper.IsEmptyString(productId))
            {
                return(false);
            }
            var detailId = DataHelper.GetDetailId(productId);
            PropModified <ProductDetail> modified = new PropModified <ProductDetail>(new { isShow = status });

            using (EntityDAO <ProductDetail> db = new EntityDAO <ProductDetail>(_context))
                return(db.Update(detailId, modified));
        }
        /// <summary>
        /// Get Trainee
        /// Order By Number of Tasks and Minimum Number of Days
        /// </summary>
        /// <returns>List of Trainee</returns>
        public List <Trainee> GetData()
        {
            List <Trainee> list_trainee = EntityDAO.GetData().Cast <Trainee>().ToList();

            /// Read Tasks
            foreach (Trainee trainne in list_trainee)
            {
                TaskTraineeBLO taskTraineeBLO = new TaskTraineeBLO(trainne.FileName);
                trainne.NumberOfDaysJob = taskTraineeBLO.GetNumberOfDaysJob();
                trainne.NumberOfTask    = taskTraineeBLO.GetNumberOfTask();
            }
            return(list_trainee.OrderByDescending(t => t.NumberOfTask).ToList());
        }
Пример #13
0
        public bool UpdateDTO(string productId, ProductDetailDTO productDetailDTO)
        {
            if (DataHelper.IsEmptyString(productId))
            {
                return(false);
            }
            var detailId = DataHelper.GetDetailId(productId);
            var prod     = ObjectMapperTo <ProductDetailDTO, ProductDetail>(productDetailDTO);
            PropModified <ProductDetail> modified = new PropModified <ProductDetail>(prod);

            using (EntityDAO <ProductDetail> db = new EntityDAO <ProductDetail>(_context))
                return(db.Update(detailId, modified));
        }
        private void InitIsOCC()
        {
            //if the location key eqals to OCC location key ,return true; else return false
            EntityDAO entityDAO = new EntityDAO();
            ulong     occLocKey = entityDAO.GetLocationKeyByEtyName(DAOHelper.OCC_LOCATIONNAME);

            if (occLocKey == m_LocationKey)
            {
                m_isOCC = true;
            }
            else
            {
                m_isOCC = false;
            }
        }
        private void InitLocationKeyByHostName()
        {
            string Function_Name = "InitLocationKeyByHostName";

            if (m_HostName != "")
            {
                EntityDAO entityDAO = new EntityDAO();
                m_LocationKey = entityDAO.GetLocationKeyByEtyName(m_HostName);
                STEE.ISCS.Log.LogHelper.Info(CLASS_NAME, Function_Name, "Current location key is: " + m_LocationKey);
            }
            else
            {
                STEE.ISCS.Log.LogHelper.Error(CLASS_NAME, Function_Name, "Can't find Location Key because host name is empty.");
            }
        }
Пример #16
0
        /// <summary>
        /// Gets DAO for the given entity.
        /// </summary>
        /// <param name="entity">Entity which the returned DAO will work with.</param>
        /// <param name="conn">Connection context the DAO will use. If null, default DAO settings are used.</param>
        /// <returns>IEntityDAO implementation.</returns>
        public IEntityDAO GetEntityDAO(IEntity entity, IConnectionProvider conn)
        {
            IEntityDAO dao;
            IEntityDAO selfServicedEntity = entity as IEntityDAO;
            if (selfServicedEntity != null)
                dao = selfServicedEntity;
            else if (entity.Table.EntityDaoCreationStrategy != null)
                dao = entity.Table.EntityDaoCreationStrategy.GetEntityDAO(entity, conn);
            else
                dao = new EntityDAO(entity);

            if (conn != null)
                dao.ConnectionProvider = conn;

            return dao;
        }
        /*public int GetTotalDataPointCount(string opcServerName, string filterString)
         * {
         *  return OPCNodeNDataPointDAO.GetInstance().GetOPCDataPointCount(opcServerName, filterString);
         * }*/

        /// <summary>
        /// Get all the DataNode from the Database of specified server root (Parent Entity)name .
        /// </summary>
        /// <param name="serverRootName">Root entity name</param>
        /// <param name="opcServerName">Server name</param>
        /// <returns>DataNode Entity List</returns>

        /*public List<EtyOPCDataNode> GetAllOPCDataNodes(string serverRootName, string opcServerName)
         * {
         *  return OPCNodeNDataPointDAO.GetInstance().GetAllOPCDataNode(serverRootName, opcServerName);
         * }*/

        public List <EtyOPCDataNode> GetAllOPCDataNodes(string serverRootName, string opcServerName)
        {
            List <EtyOPCDataNode>         etyDataNodeList = new List <EtyOPCDataNode>();
            EntityDAO                     entityDao       = new EntityDAO();
            Dictionary <ulong, EtyEntity> dataNodelist    = entityDao.GetAllDataNodesByServerRootName(serverRootName);

            foreach (KeyValuePair <ulong, EtyEntity> pair in dataNodelist)
            {
                EtyOPCDataNode etyDataNode = new EtyOPCDataNode();
                etyDataNode.OPCDataNodeId = pair.Key;
                EtyEntity etyEntity = pair.Value;
                etyDataNode.OPCDataNodeName = etyEntity.Name;
                etyDataNode.OPCDataNodeDesc = etyEntity.Description;
                etyDataNodeList.Add(etyDataNode);
            }
            return(etyDataNodeList);
        }
        public ulong GetEntityKeyByName(string entityName)
        {
            string etyNameWithoutSuffix = entityName;

            EntityDAO entityDAO = new EntityDAO();

            //if this dpname
            if (entityName.Contains(".Value"))
            {
                etyNameWithoutSuffix = entityName.Remove(entityName.Length - 6);
            }
            //use long, so if there is no entity found, return 0.
            //There is no entity which (pkey=0 and type is DataPoint)
            ulong entityKey = entityDAO.FindDataPointEtyKeyByName(etyNameWithoutSuffix);

            return(entityKey); //if not found in entity table, pkey=0
        }
Пример #19
0
        public bool UpdateDTO(int idSrc, T objVM, string[] ignore = null)
        {
            if (idSrc < 0 || objVM == null)
            {
                return(false);
            }
            V obj = ObjectMapperTo <T, V>(objVM);
            PropModified <V> modifieds = new PropModified <V>(obj, ignore);

            if (!modifieds.isChanged)
            {
                return(false);
            }
            //
            using (EntityDAO <V> db = new EntityDAO <V>(_context))
                return(db.Update(idSrc, modifieds));
        }
        /// <summary>
        /// Returns all Child Datanode of the specified parent Datanode
        /// </summary>
        /// <param name="parentNode">parent datanode name</param>
        /// <param name="opcServerName">server name</param>
        /// <returns>Datanode entity List</returns>
        public List <EtyOPCDataNode> GetChildOPCDataNodes(string parentNode, string opcServerName)
        {
            // return OPCNodeNDataPointDAO.GetInstance().GetChildOPCDataNode(parentNode, opcServerName);
            ulong parentkey = Convert.ToUInt64(parentNode);
            List <EtyOPCDataNode>         etyDataNodeList = new List <EtyOPCDataNode>();
            EntityDAO                     entityDao       = new EntityDAO();
            Dictionary <ulong, EtyEntity> dataNodelist    = entityDao.GetDataNodeChildrenByPkey(parentkey);

            foreach (KeyValuePair <ulong, EtyEntity> pair in dataNodelist)
            {
                EtyOPCDataNode etyDataNode = new EtyOPCDataNode();
                etyDataNode.OPCDataNodeId = pair.Key;
                EtyEntity etyEntity = pair.Value;
                etyDataNode.OPCDataNodeName = etyEntity.Name;
                etyDataNode.OPCDataNodeDesc = etyEntity.Description;
                etyDataNodeList.Add(etyDataNode);
            }

            return(etyDataNodeList);
        }
        public bool CheckStationGrp(string dataPoint, string currentGrpLocation)
        {
            bool bConfigured = true;

            if (currentGrpLocation.ToUpper() != DAOHelper.OCC_LOCATIONNAME)
            {
                if (dataPoint.Contains(".Value"))
                {
                    dataPoint = dataPoint.Remove(dataPoint.Length - 6);
                }
                EntityDAO entityDAO    = new EntityDAO();
                double    locationkey  = entityDAO.GetLocationKeyByEtyName(dataPoint);
                string    locationName = entityDAO.GetLocationNameFromKey(locationkey);
                if (locationName.ToUpper() != currentGrpLocation.ToUpper())
                {
                    bConfigured = false;
                }
            }
            return(bConfigured);
        }
Пример #22
0
        // public bool UpdateForOrder(List<OrderDetailDTO> orderDetailDTOs)
        // {
        //     using (ProductDAO db = new ProductDAO(_context))
        //     {
        //         foreach (var item in orderDetailDTOs)
        //         {
        //             int itemId = DataHelper.GetAttrlId(item.ProductId);
        //             db.SubTractQuanity(itemId, (int)item.Quantity);
        //         }
        //     }
        //     return true;
        // }


        //Product Detail
        public ProductDetailDTO AddDTOs(int cateId, ProductDetailDTO productDetailDTO)
        {
            if (cateId <= 0)
            {
                return(null);
            }
            var prod = ObjectMapperTo <ProductDetailDTO, ProductDetail>(productDetailDTO);

            prod.CategoryId = cateId;
            using (EntityDAO <ProductDetail> db = new EntityDAO <ProductDetail>(_context))
            {
                var result = ObjectMapperTo <ProductDetail, ProductDetailDTO>(db.Add(prod));
                if (result == null)
                {
                    return(null);
                }
                this.AddAttrDTOs(result.Id, new ProductDTO {
                    Name = "Unknown", Color = "N/A", Images = "[]"
                });
                return(result);
            }
        }
Пример #23
0
        public void TestCreateEntityDAO01()
        {
            EntityDAO entityDAO = CreateEntityDAO01();

            Assert.IsNotNull(entityDAO);
        }
Пример #24
0
        public static EntityDAO CreateEntityDAO01()
        {
            EntityDAO entityDAO = new EntityDAO();

            return(entityDAO);
        }
Пример #25
0
 public List <T> GetListDTOs()
 {
     using (EntityDAO <V> db = new EntityDAO <V>(_context))
         return(LsObjectMapperTo <V, T>(db.GetList()));
 }