//All senior tables(Companies, Parts, Orders, ect...) tend to have a generic table called TableNameTypes
        //i.e. SystemUserTypes PartTypes, OrderTypes...
        //So this will constitute the meta data for that Type table...
        //Xerp attempts to use generic naming where possible to allow for cloning...
        public static List <Temp> GetMetaData(this SystemUserType entityObject)
        {
            XERP.Server.DAL.SystemUserDAL.DALUtility dalUtility = new DALUtility();
            List <Temp> tempList = new List <Temp>();
            int         id       = 0;

            using (SystemUserEntities ctx = new SystemUserEntities(dalUtility.EntityConectionString))
            {
                var c            = ctx.SystemUserTypes.FirstOrDefault();
                var queryResults = from meta in ctx.MetadataWorkspace.GetItems(DataSpace.CSpace)
                                   .Where(m => m.BuiltInTypeKind == BuiltInTypeKind.EntityType)
                                   from query in (meta as EntityType).Properties
                                   .Where(p => p.DeclaringType.Name == entityObject.GetType().Name)
                                   select query;

                if (queryResults.Count() > 0)
                {
                    foreach (var queryResult in queryResults.ToList())
                    {
                        Temp temp = new Temp();
                        temp.ID          = id;
                        temp.Name        = queryResult.Name.ToString();
                        temp.ShortChar_1 = queryResult.TypeUsage.EdmType.Name;
                        if (queryResult.TypeUsage.EdmType.Name == "String")
                        {
                            temp.Int_1 = Convert.ToInt32(queryResult.TypeUsage.Facets["MaxLength"].Value);
                        }
                        temp.Bool_1 = false; //we use this as a error trigger false = not an error...
                        tempList.Add(temp);
                        id++;
                    }
                }
            }
            return(tempList);
        }
Exemplo n.º 2
0
        //Upsert(Add and Update) SecurityGroup to the SystemUserSecurity table...
        public void AddAllSystemUserSecurities(string systemUserID, string companyID)
        {   //remove them all then we will add them all...
            RemoveAllSystemUserSecurities(systemUserID, companyID);
            //declare a different context as to not disturb the repostitory context that is tracking SystemUsers
            SystemUserEntities context = new SystemUserEntities(_rootUri);

            //get Security Groups...
            context.MergeOption = MergeOption.AppendOnly;
            context.IgnoreResourceNotFoundException = true;
            var queryResult = from q in context.SecurityGroups
                              where q.CompanyID == companyID
                              select q;

            foreach (SecurityGroup item in queryResult.ToList())
            {
                SystemUserSecurity systemUserSecurity = new SystemUserSecurity();
                systemUserSecurity.CompanyID       = companyID;
                systemUserSecurity.SystemUserID    = systemUserID;
                systemUserSecurity.SecurityGroupID = item.SecurityGroupID;
                context.MergeOption = MergeOption.NoTracking;
                context.AddToSystemUserSecurities(systemUserSecurity);
                context.SaveChanges();
            }
            context = null;
        }
Exemplo n.º 3
0
        //Upsert(Add and Update) SecurityGroup to the UserSecurity table...
        public void AddSystemUserSecurity(string systemUserID, string securityGroupID, string companyID)
        {//declare a different context as to not disturb the repostitory context that is tracking SystemUsers
            SystemUserEntities context = new SystemUserEntities(_rootUri);

            //make sure it does not exist all ready...
            context.MergeOption = MergeOption.AppendOnly;
            context.IgnoreResourceNotFoundException = true;
            var queryResult = from q in context.SystemUserSecurities
                              where q.CompanyID == companyID &&
                              q.SystemUserID == systemUserID &&
                              q.SecurityGroupID == securityGroupID
                              select q;

            if (queryResult.ToList().Count() == 0)
            {//it does not exist add it...
                SystemUserSecurity systemUserSecurity = new SystemUserSecurity();
                systemUserSecurity.CompanyID       = companyID;
                systemUserSecurity.SystemUserID    = systemUserID;
                systemUserSecurity.SecurityGroupID = securityGroupID;
                context.MergeOption = MergeOption.NoTracking;
                context.AddToSystemUserSecurities(systemUserSecurity);
                context.SaveChanges();
            }
            context = null;
        }
        public IEnumerable <SystemUserCode> GetSystemUserCodes(SystemUserCode itemCodeQuerryObject)
        {
            _repositoryContext             = new SystemUserEntities(_rootUri);
            _repositoryContext.MergeOption = MergeOption.AppendOnly;
            _repositoryContext.IgnoreResourceNotFoundException = true;
            var queryResult = from q in _repositoryContext.SystemUserCodes
                              select q;

            if (!string.IsNullOrEmpty(itemCodeQuerryObject.Code))
            {
                queryResult = queryResult.Where(q => q.Code.StartsWith(itemCodeQuerryObject.Code.ToString()));
            }

            if (!string.IsNullOrEmpty(itemCodeQuerryObject.Description))
            {
                queryResult = queryResult.Where(q => q.Description.StartsWith(itemCodeQuerryObject.Description.ToString()));
            }

            if (!string.IsNullOrEmpty(itemCodeQuerryObject.SystemUserCodeID))
            {
                queryResult = queryResult.Where(q => q.Description.StartsWith(itemCodeQuerryObject.SystemUserCodeID.ToString()));
            }

            return(queryResult);
        }
        public void DeleteFromRepository(SystemUserCode itemCode)
        {
            if (_repositoryContext.GetEntityDescriptor(itemCode) != null)
            {//if it exists in the db delete it from the db
                SystemUserEntities context = new SystemUserEntities(_rootUri);
                context.MergeOption = MergeOption.AppendOnly;
                context.IgnoreResourceNotFoundException = true;
                SystemUserCode deletedSystemUserCode = (from q in context.SystemUserCodes
                                                        where q.SystemUserCodeID == itemCode.SystemUserCodeID
                                                        select q).FirstOrDefault();
                if (deletedSystemUserCode != null)
                {
                    context.DeleteObject(deletedSystemUserCode);
                    context.SaveChanges();
                }
                context = null;

                _repositoryContext.MergeOption = MergeOption.AppendOnly;
                //if it is being tracked remove it...
                if (GetSystemUserCodeEntityState(itemCode) != EntityStates.Detached)
                {
                    _repositoryContext.Detach(itemCode);
                }
            }
        }
        private SystemUserCodeSingletonRepository()
        {
            ServiceUtility serviceUtility = new ServiceUtility();

            _rootUri           = serviceUtility.BaseUri;
            _repositoryContext = new SystemUserEntities(_rootUri);
        }
Exemplo n.º 7
0
        public SystemUserServiceAgent()
        {
            ServiceUtility serviceUtility = new ServiceUtility();

            _rootUri = serviceUtility.BaseUri;
            //this context will be used for read only gets...
            _context             = new SystemUserEntities(_rootUri);
            _context.MergeOption = MergeOption.NoTracking;
        }
        public IEnumerable <SystemUserCode> Refresh(string autoIDs)
        {
            _repositoryContext             = new SystemUserEntities(_rootUri);
            _repositoryContext.MergeOption = MergeOption.AppendOnly;
            _repositoryContext.IgnoreResourceNotFoundException = true;

            var queryResult = _repositoryContext.CreateQuery <SystemUserCode>("RefreshSystemUserCode").AddQueryOption("autoIDs", "'" + autoIDs + "'");

            return(queryResult);
        }
        public IEnumerable <SystemUserCode> GetSystemUserCodes()
        {
            _repositoryContext             = new SystemUserEntities(_rootUri);
            _repositoryContext.MergeOption = MergeOption.AppendOnly;
            _repositoryContext.IgnoreResourceNotFoundException = true;
            var queryResult = (from q in _repositoryContext.SystemUserCodes
                               select q);

            return(queryResult);
        }
        public IEnumerable <SystemUserType> GetSystemUserTypeByID(string itemTypeID)
        {
            _repositoryContext             = new SystemUserEntities(_rootUri);
            _repositoryContext.MergeOption = MergeOption.AppendOnly;
            _repositoryContext.IgnoreResourceNotFoundException = true;
            var queryResult = (from q in _repositoryContext.SystemUserTypes
                               where q.SystemUserTypeID == itemTypeID
                               select q);

            return(queryResult);
        }
Exemplo n.º 11
0
        //delete SecurityGroup from the SystemUserSecurity table...
        public void RemoveAllSystemUserSecurities(string systemUserID, string companyID)
        {//declare a different context as to not disturb the repostitory context that is tracking SystemUsers
            SystemUserEntities context = new SystemUserEntities(_rootUri);

            context.MergeOption = MergeOption.AppendOnly;
            context.IgnoreResourceNotFoundException = true;
            var deleteItems = from q in context.SystemUserSecurities
                              where q.CompanyID == companyID &&
                              q.SystemUserID == systemUserID
                              select q;

            foreach (SystemUserSecurity item in deleteItems.ToList())
            {
                context.DeleteObject(item);
                context.SaveChanges();
            }
            context = null;
        }
Exemplo n.º 12
0
        //delete SecurityGroup from the SystemUserSecurity table...
        public void RemoveSystemUserSecurity(string systemUserID, string securityGroupID, string companyID)
        {//declare a different context as to not disturb the repostitory context that is tracking SystemUsers
            SystemUserEntities context = new SystemUserEntities(_rootUri);

            context.MergeOption = MergeOption.AppendOnly;
            context.IgnoreResourceNotFoundException = true;
            var deleteItem = (from q in context.SystemUserSecurities
                              where q.CompanyID == companyID &&
                              q.SystemUserID == systemUserID &&
                              q.SecurityGroupID == securityGroupID
                              select q).FirstOrDefault();

            if (deleteItem != null)
            {
                context.DeleteObject(deleteItem);
                context.SaveChanges();
            }
            context = null;
        }