コード例 #1
0
        public void DeleteFromRepository(ExecutableProgram executableProgram)
        {
            if (_repositoryContext.GetEntityDescriptor(executableProgram) != null)
            {//if it exists in the db delete it from the db
                MenuSecurityEntities context = new MenuSecurityEntities(_rootUri);
                context.MergeOption = MergeOption.AppendOnly;
                context.IgnoreResourceNotFoundException = true;
                ExecutableProgram deletedExecutableProgram = (from q in context.ExecutablePrograms
                                                              where q.ExecutableProgramID == executableProgram.ExecutableProgramID
                                                              select q).FirstOrDefault();
                if (deletedExecutableProgram != null)
                {
                    context.DeleteObject(deletedExecutableProgram);
                    context.SaveChanges();
                }
                context = null;

                _repositoryContext.MergeOption = MergeOption.AppendOnly;
                //if it is being tracked remove it...
                if (GetExecutableProgramEntityState(executableProgram) != EntityStates.Detached)
                {
                    _repositoryContext.Detach(executableProgram);
                }
            }
        }
コード例 #2
0
        public static List <Temp> GetMetaData(this ExecutableProgram entityObject)
        {
            XERP.Server.DAL.MenuSecurityDAL.DALUtility dalUtility = new DALUtility();
            List <Temp> tempList = new List <Temp>();
            int         id       = 0;

            using (MenuSecurityEntities ctx = new MenuSecurityEntities(dalUtility.EntityConectionString))
            {
                var c            = ctx.ExecutablePrograms.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);
        }
コード例 #3
0
 private void ChangeKeyLogic()
 {
     if (!string.IsNullOrEmpty(SelectedExecutableProgram.ExecutableProgramID))
     {//check to see if key is part of the current companylist...
         ExecutableProgram query = ExecutableProgramList.Where(company => company.ExecutableProgramID == SelectedExecutableProgram.ExecutableProgramID &&
                                                               company.AutoID != SelectedExecutableProgram.AutoID).FirstOrDefault();
         if (query != null)
         {//revert it back
             SelectedExecutableProgram.ExecutableProgramID = SelectedExecutableProgramMirror.ExecutableProgramID;
             //change to the newly selected company...
             SelectedExecutableProgram = query;
             return;
         }
         //it is not part of the existing list try to fetch it from the db...
         ExecutableProgramList = GetExecutableProgramByID(SelectedExecutableProgram.ExecutableProgramID, XERP.Client.ClientSessionSingleton.Instance.CompanyID);
         if (ExecutableProgramList.Count == 0)//it was not found do new record required logic...
         {
             NotifyNewRecordNeeded("Record " + SelectedExecutableProgram.ExecutableProgramID + " Does Not Exist.  Create A New Record?");
         }
         else
         {
             SelectedExecutableProgram = ExecutableProgramList.FirstOrDefault();
         }
     }
     else
     {
         string errorMessage = "ID Is Required.";
         NotifyMessage(errorMessage);
         //revert back to the value it was before it was changed...
         if (SelectedExecutableProgram.ExecutableProgramID != SelectedExecutableProgramMirror.ExecutableProgramID)
         {
             SelectedExecutableProgram.ExecutableProgramID = SelectedExecutableProgramMirror.ExecutableProgramID;
         }
     }
 }
コード例 #4
0
        //ExecutableProgram Object Scope Validation check the entire object for validity...
        private byte ExecutableProgramIsValid(ExecutableProgram item, out string errorMessage)
        {   //validate key
            errorMessage = "";
            if (string.IsNullOrEmpty(item.ExecutableProgramID))
            {
                errorMessage = "ID Is Required.";
                return(1);
            }
            EntityStates entityState = GetExecutableProgramState(item);

            if (entityState == EntityStates.Added && ExecutableProgramExists(item.ExecutableProgramID))
            {
                errorMessage = "Item All Ready Exists.";
                return(1);
            }
            //check cached list for duplicates...
            int count = ExecutableProgramList.Count(q => q.ExecutableProgramID == item.ExecutableProgramID);

            if (count > 1)
            {
                errorMessage = "Item All Ready Exists.";
                return(1);
            }
            //validate Description
            if (string.IsNullOrEmpty(item.Name))
            {
                errorMessage = "Name Is Required.";
                return(1);
            }
            //a value of 2 is pending changes...
            //On Commit we will give it a value of 0...
            return(2);
        }
コード例 #5
0
        public IEnumerable <ExecutableProgram> GetExecutablePrograms(ExecutableProgram executableProgramQuerryObject, string companyID)
        {
            _repositoryContext             = new MenuSecurityEntities(_rootUri);
            _repositoryContext.MergeOption = MergeOption.AppendOnly;
            _repositoryContext.IgnoreResourceNotFoundException = true;
            var queryResult = from q in _repositoryContext.ExecutablePrograms
                              where q.CompanyID == companyID
                              select q;

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

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

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

            if (!string.IsNullOrEmpty(executableProgramQuerryObject.ExecutableProgramCodeID))
            {
                queryResult = queryResult.Where(q => q.ExecutableProgramCodeID.StartsWith(executableProgramQuerryObject.ExecutableProgramCodeID.ToString()));
            }
            return(queryResult);
        }
コード例 #6
0
        public void DeleteExecutableProgramCommand()
        {
            try
            {
                int i  = 0;
                int ii = 0;
                for (int j = SelectedExecutableProgramList.Count - 1; j >= 0; j--)
                {
                    ExecutableProgram item = (ExecutableProgram)SelectedExecutableProgramList[j];
                    //get Max Index...
                    i = ExecutableProgramList.IndexOf(item);
                    if (i > ii)
                    {
                        ii = i;
                    }
                    Delete(item);
                    ExecutableProgramList.Remove(item);
                }

                if (ExecutableProgramList != null && ExecutableProgramList.Count > 0)
                {
                    //back off one index from the max index...
                    ii = ii - 1;

                    //if they delete the first row...
                    if (ii < 0)
                    {
                        ii = 0;
                    }

                    //make sure it does not exceed the list count...
                    if (ii >= ExecutableProgramList.Count())
                    {
                        ii = ExecutableProgramList.Count - 1;
                    }

                    SelectedExecutableProgram = ExecutableProgramList[ii];
                    //we will only enable committ for dirty validated records...
                    if (Dirty == true)
                    {
                        AllowCommit = CommitIsAllowed();
                    }
                    else
                    {
                        AllowCommit = false;
                    }
                }
                else//only one record, deleting will result in no records...
                {
                    SetAsEmptySelection();
                }
            }//we try catch company delete as it may be used in another table as a key...
            //As well we will force a refresh to sqare up the UI after the botched delete...
            catch
            {
                NotifyMessage("ExecutableProgram/s Can Not Be Deleted.  Contact XERP Admin For More Details.");
                Refresh();
            }
        }
コード例 #7
0
        private BindingList <ExecutableProgram> GetExecutablePrograms(ExecutableProgram item, string companyID)
        {
            BindingList <ExecutableProgram> itemList = new BindingList <ExecutableProgram>(_serviceAgent.GetExecutablePrograms(item, companyID).ToList());

            Dirty       = false;
            AllowCommit = false;
            return(itemList);
        }
コード例 #8
0
 private void SetAsEmptySelection()
 {
     SelectedExecutableProgram = new ExecutableProgram();
     AllowEdit    = false;
     AllowDelete  = false;
     Dirty        = false;
     AllowCommit  = false;
     AllowRowCopy = false;
 }
コード例 #9
0
        public static void SetPropertyValue(this ExecutableProgram myObj, object propertyName, object propertyValue)
        {
            var propInfo = typeof(ExecutableProgram).GetProperty((string)propertyName);

            if (propInfo != null)
            {
                propInfo.SetValue(myObj, propertyValue, null);
            }
        }
コード例 #10
0
 public void UpdateRepository(ExecutableProgram item)
 {
     if (_repositoryContext.GetEntityDescriptor(item) != null)
     {
         item.LastModifiedBy            = XERP.Client.ClientSessionSingleton.Instance.SystemUserID;
         item.LastModifiedByDate        = DateTime.Now;
         _repositoryContext.MergeOption = MergeOption.AppendOnly;
         _repositoryContext.UpdateObject(item);
     }
 }
コード例 #11
0
 public EntityStates GetExecutableProgramEntityState(ExecutableProgram executableProgram)
 {
     if (_repositoryContext.GetEntityDescriptor(executableProgram) != null)
     {
         return(_repositoryContext.GetEntityDescriptor(executableProgram).State);
     }
     else
     {
         return(EntityStates.Detached);
     }
 }
コード例 #12
0
        public static object GetPropertyValue(this ExecutableProgram myObj, string propertyName)
        {
            var propInfo = typeof(ExecutableProgram).GetProperty(propertyName);

            if (propInfo != null)
            {
                return(propInfo.GetValue(myObj, null));
            }
            else
            {
                return(string.Empty);
            }
        }
コード例 #13
0
 public void OnChangeExecutablePrograms(ExecutableProgram executableProgram, UpdateOperations operations)
 {
     if (operations == UpdateOperations.Delete)
     {//update a null to any place the item was used by its parent record...
         XERP.Server.DAL.MenuSecurityDAL.DALUtility dalUtility = new DALUtility();
         var context = new MenuSecurityEntities(dalUtility.EntityConectionString);
         context.ExecutablePrograms.MergeOption = System.Data.Objects.MergeOption.NoTracking;
         string companyID           = executableProgram.CompanyID;
         string executableProgramID = executableProgram.ExecutableProgramID;
         string sqlstring           = "UPDATE MenuItems SET ExecutableProgramID = null WHERE CompanyID = '" + companyID + "' and ExecutableProgramID = '" + executableProgramID + "'";
         context.ExecuteStoreCommand(sqlstring);
     }
 }
コード例 #14
0
        public static string GetPropertyType(this ExecutableProgram myObj, string propertyName)
        {
            var propInfo = typeof(ExecutableProgram).GetProperty(propertyName);

            if (propInfo != null)
            {
                return(propInfo.PropertyType.Name.ToString());
            }
            else
            {
                return(null);
            }
        }
コード例 #15
0
 //udpate merely updates the repository a commit is required
 //to commit it to the db...
 private bool Update(ExecutableProgram item)
 {
     _serviceAgent.UpdateExecutableProgramRepository(item);
     Dirty = true;
     if (CommitIsAllowed())
     {
         AllowCommit = true;
     }
     else
     {
         AllowCommit = false;
     }
     return(AllowCommit);
 }
コード例 #16
0
        public IQueryable <Temp> GetMetaData(string tableName)
        {
            switch (tableName)
            {
            case "MenuItems":
                MenuItem menuItem = new MenuItem();
                return(menuItem.GetMetaData().AsQueryable());

            case "MenuItemTypes":
                MenuItemType menuItemType = new MenuItemType();
                return(menuItemType.GetMetaData().AsQueryable());

            case "MenuItemCodes":
                MenuItemCode menuItemCode = new MenuItemCode();
                return(menuItemCode.GetMetaData().AsQueryable());

            case "ExecutablePrograms":
                ExecutableProgram executablePrograms = new ExecutableProgram();
                return(executablePrograms.GetMetaData().AsQueryable());

            case "ExecutableProgramTypes":
                ExecutableProgramType executableProgramType = new ExecutableProgramType();
                return(executableProgramType.GetMetaData().AsQueryable());

            case "ExecutableProgramCodes":
                ExecutableProgramCode executableProgramCode = new ExecutableProgramCode();
                return(executableProgramCode.GetMetaData().AsQueryable());

            case "MenuSecurities":
                MenuSecurity menuSecurity = new MenuSecurity();
                return(menuSecurity.GetMetaData().AsQueryable());

            case "SecurityGroups":
                SecurityGroup securityGroup = new SecurityGroup();
                return(securityGroup.GetMetaData().AsQueryable());

            default:     //no table exists for the given tablename given...
                List <Temp> tempList = new List <Temp>();
                Temp        temp     = new Temp();
                temp.ID          = 0;
                temp.Int_1       = 0;
                temp.Bool_1      = true; //bool_1 will flag it as an error...
                temp.Name        = "Error";
                temp.ShortChar_1 = "Table " + tableName + " Is Not A Valid Table Within The Given Entity Collection, Or Meta Data Is Not Publc For The Given Table Name";
                tempList.Add(temp);
                return(tempList.AsQueryable());
            }
        }
コード例 #17
0
        public MainSearchViewModel(IExecutableProgramServiceAgent serviceAgent)
        {
            this._serviceAgent        = serviceAgent;
            ExecutableProgramTypeList = GetExecutableProgramTypes();
            ExecutableProgramCodeList = GetExecutableProgramCodes();

            SearchObject = new ExecutableProgram();
            ResultList   = new BindingList <ExecutableProgram>();
            SelectedList = new BindingList <ExecutableProgram>();
            //make sure of session authentication...
            if (ClientSessionSingleton.Instance.SessionIsAuthentic) //make sure user has rights to UI...
            {
                DoFormsAuthentication();
            }
            else
            {//User is not authenticated...
                RegisterToReceiveMessages <bool>(MessageTokens.StartUpLogInToken.ToString(), OnStartUpLogIn);
                FormIsEnabled = false;
            }
        }
コード例 #18
0
        //Object.Property Scope Validation...
        private bool ExecutableProgramIsValid(ExecutableProgram item, _executableProgramValidationProperties validationProperties, out string errorMessage)
        {
            errorMessage = "";
            switch (validationProperties)
            {
            case _executableProgramValidationProperties.ExecutableProgramID:
                //validate key
                if (string.IsNullOrEmpty(item.ExecutableProgramID))
                {
                    errorMessage = "ID Is Required.";
                    return(false);
                }
                EntityStates entityState = GetExecutableProgramState(item);
                if (entityState == EntityStates.Added && ExecutableProgramExists(item.ExecutableProgramID))
                {
                    errorMessage = "Item All Ready Exists...";
                    return(false);
                }
                //check cached list for duplicates...
                int count = ExecutableProgramList.Count(q => q.ExecutableProgramID == item.ExecutableProgramID);
                if (count > 1)
                {
                    errorMessage = "Item All Ready Exists...";
                    return(false);
                }
                break;

            case _executableProgramValidationProperties.Name:
                //validate Description
                if (string.IsNullOrEmpty(item.Name))
                {
                    errorMessage = "Description Is Required.";
                    return(false);
                }
                break;
            }
            return(true);
        }
コード例 #19
0
        private bool NewExecutableProgram(string itemID)
        {
            ExecutableProgram newItem = new ExecutableProgram();

            //all new records will be give a negative int autoid...
            //when they are updated then sql will generate one for them overiding this set value...
            //it will allow us to give uniqueness to the tempory new records...
            //Before they are updated to the entity and given an autoid...
            //we use a negative number and keep subtracting by 1 for each new item added...
            //This will allow it to alwasy be unique and never interfere with SQL's positive autoid...
            _newExecutableProgramAutoId = _newExecutableProgramAutoId - 1;
            newItem.AutoID = _newExecutableProgramAutoId;
            newItem.ExecutableProgramID = itemID;
            newItem.CompanyID           = ClientSessionSingleton.Instance.CompanyID;
            newItem.IsValid             = 1;
            newItem.NotValidMessage     = "New Record Key Field/s Are Required.";
            ExecutableProgramList.Add(newItem);
            _serviceAgent.AddToExecutableProgramRepository(newItem);
            SelectedExecutableProgram = ExecutableProgramList.LastOrDefault();

            AllowEdit = true;
            Dirty     = false;
            return(true);
        }
コード例 #20
0
 private EntityStates GetExecutableProgramState(ExecutableProgram item)
 {
     return(_serviceAgent.GetExecutableProgramEntityState(item));
 }
コード例 #21
0
 public void AddToRepository(ExecutableProgram executableProgram)
 {
     executableProgram.CompanyID    = XERP.Client.ClientSessionSingleton.Instance.CompanyID;
     _repositoryContext.MergeOption = MergeOption.AppendOnly;
     _repositoryContext.AddToExecutablePrograms(executableProgram);
 }
コード例 #22
0
 private bool Delete(ExecutableProgram item)
 {//deletes are done indenpendently of the repository as a delete will not commit
     //dirty records it will simply just delete the record...
     _serviceAgent.DeleteFromExecutableProgramRepository(item);
     return(true);
 }
コード例 #23
0
 public EntityStates GetExecutableProgramEntityState(ExecutableProgram executableProgram)
 {
     return(ExecutableProgramSingletonRepository.Instance.GetExecutableProgramEntityState(executableProgram));
 }
コード例 #24
0
 public void DeleteFromExecutableProgramRepository(ExecutableProgram executableProgram)
 {
     ExecutableProgramSingletonRepository.Instance.DeleteFromRepository(executableProgram);
 }
コード例 #25
0
 public void AddToExecutableProgramRepository(ExecutableProgram executableProgram)
 {
     ExecutableProgramSingletonRepository.Instance.AddToRepository(executableProgram);
 }
コード例 #26
0
 public void UpdateExecutableProgramRepository(ExecutableProgram executableProgram)
 {
     ExecutableProgramSingletonRepository.Instance.UpdateRepository(executableProgram);
 }
コード例 #27
0
 public IEnumerable <ExecutableProgram> GetExecutablePrograms(ExecutableProgram executableProgramQuerryObject, string companyID)
 {
     return(ExecutableProgramSingletonRepository.Instance.GetExecutablePrograms(executableProgramQuerryObject, companyID));
 }
コード例 #28
0
 private BindingList <ExecutableProgram> GetExecutablePrograms(ExecutableProgram itemQueryObject, string companyID)
 {//note this get is to the singleton repository...
     return(new BindingList <ExecutableProgram>(_serviceAgent.GetExecutablePrograms(itemQueryObject, companyID).ToList()));
 }