コード例 #1
0
 private void SetAsEmptyItemSelection()
 {
     SelectedUdListItem     = new UdListItem();
     AllowEditUdListItem    = false;
     AllowDeleteUdListItem  = false;
     AllowRowCopyUdListItem = false;
 }
コード例 #2
0
        public void ConvertNestedObject(object obj, out UdList udListout, out UdListItem udListItemout)
        {
            string type = obj.GetType().Name;

            udListout            = new UdList();
            udListItemout        = new UdListItem();
            UdListItemIsSelected = false;
            switch (type)
            {
            case "UdList":
                udListout     = (UdList)obj;
                udListItemout = udListout.UdListItems.FirstOrDefault();
                break;

            case "UdListItem":
                UdListItemIsSelected = true;
                udListItemout        = (UdListItem)obj;
                UdListItem item = (UdListItem)obj;
                udListout = (from q in UdListList
                             where q.UdListID == item.UdListID &&
                             q.CompanyID == item.CompanyID
                             select q).FirstOrDefault();
                break;

            default:
                break;
            }
        }
コード例 #3
0
        public static List <Temp> GetMetaData(this UdListItem entityObject)
        {
            XERP.Server.DAL.UdListDAL.DALUtility dalUtility = new DALUtility();
            List <Temp> tempList = new List <Temp>();
            int         id       = 0;

            using (UdListEntities ctx = new UdListEntities(dalUtility.EntityConectionString))
            {
                var c            = ctx.Companies.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);
        }
コード例 #4
0
        //UdList Object Scope Validation validate entire object...
        private byte UdListItemIsValid(UdListItem udListItem, out string errorMessage)
        {
            //validate key
            errorMessage = "";
            if (string.IsNullOrEmpty(udListItem.UdListItemID))
            {
                errorMessage = "ID Is Required.";
                return(1);
            }

            var count = UdListList.
                        Where(q => q.UdListID == udListItem.UdListID).Single().
                        UdListItems.
                        Where(x => x.UdListItemID == udListItem.UdListItemID).Count();

            if (count > 1)
            {
                errorMessage = "UdListItem ID " + udListItem.UdListItemID + " Allready Exists...";
                return(1);
            }

            if (UdListItemExists(udListItem.UdListID, udListItem.UdListItemID.ToString(), (int)udListItem.AutoID))
            {
                errorMessage = "UdListItem ID " + udListItem.UdListItemID + " Allready Exists...";
                return(1);
            }

            //validate Description
            if (string.IsNullOrEmpty(udListItem.Description))
            {
                errorMessage = "Description Is Required.";
                return(1);
            }
            return(0);
        }
コード例 #5
0
        public void DeleteFromRepository(UdListItem udListItem)
        {
            if (_repositoryContext.GetEntityDescriptor(udListItem) != null)
            {
                //if it exists in the db delete it from the db
                UdListEntities context = new UdListEntities(_rootUri);
                context.MergeOption = MergeOption.AppendOnly;
                context.IgnoreResourceNotFoundException = true;
                UdListItem deletequery = (from q in context.UdListItems
                                          where q.UdListItemID == udListItem.UdListItemID &&
                                          q.CompanyID == udListItem.CompanyID
                                          select q).FirstOrDefault();
                if (deletequery != null)
                {
                    context.DeleteObject(deletequery);
                    context.SaveChanges();
                }
                context = null;

                _repositoryContext.MergeOption = MergeOption.AppendOnly;
                //if it is being tracked remove it...
                if (GetUdListItemEntityState(udListItem) != EntityStates.Detached)
                {
                    _repositoryContext.Detach(udListItem);
                }
            }
        }
コード例 #6
0
        public static void SetPropertyValue(this UdListItem myObj, object propertyName, object propertyValue)
        {
            var propInfo = typeof(UdListItem).GetProperty((string)propertyName);

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

            if (propInfo != null)
            {
                return(propInfo.GetValue(myObj, null));
            }
            else
            {
                return(string.Empty);
            }
        }
コード例 #10
0
        public static string GetPropertyType(this UdListItem myObj, string propertyName)
        {
            var propInfo = typeof(UdListItem).GetProperty(propertyName);

            if (propInfo != null)
            {
                return(propInfo.PropertyType.Name.ToString());
            }
            else
            {
                return(null);
            }
        }
コード例 #11
0
 //udpate merely updates the repository a commit is required
 //to commit it to the db...
 private bool Update(UdListItem udListItem)
 {
     _serviceAgent.UpdateUdListRepository(udListItem);
     Dirty = true;
     if (CommitIsAllowed())
     {
         AllowCommit = true;
     }
     else
     {
         AllowCommit = false;
     }
     return(AllowCommit);
 }
コード例 #12
0
        public void DeleteUdListItemCommand()
        {
            int i  = 0; //temp index
            int ii = 0; //calculated index

            for (int j = SelectedUdListItemList.Count - 1; j >= 0; j--)
            {
                UdListItem udListItem = (UdListItem)SelectedUdListItemList[j];
                //get Max Index...
                i = SelectedUdList.UdListItems.IndexOf(udListItem);
                if (i > ii)
                {
                    ii = i;
                }
                Delete(udListItem);
                UdListList.Where(q => q.AutoID == SelectedUdList.AutoID).FirstOrDefault().UdListItems.Remove(udListItem);
            }

            if (UdListList != null && SelectedUdList != null && SelectedUdList.UdListItems.Count > 0)
            {
                //back off one index from the max index...
                ii = ii - 1;
                //if they delete the first row...
                if (ii < 0)
                {
                    ii = 0;
                }

                //need some work on this...
                //make sure it does not exceed the list count...
                if (ii >= SelectedUdList.UdListItems.Count)
                {
                    ii = SelectedUdList.UdListItems.Count - 1;
                }
                //only allow commit for dirty validated records...
                SelectedUdListItem = SelectedUdList.UdListItems[ii];
                if (Dirty)
                {
                    AllowCommit = CommitIsAllowed();
                }
                else
                {
                    AllowCommit = false;
                }
            }
            else//only one record, deleting will result in no records...
            {
                SetAsEmptySelection();
            }
        }
コード例 #13
0
        private bool NewUdListItem(string udListItemID)
        {
            UdListItem udListItem = new UdListItem();

            _newUdListItemAutoId       = _newUdListItemAutoId - 1;
            udListItem.AutoID          = _newUdListItemAutoId;
            udListItem.UdListID        = SelectedUdList.UdListID;
            udListItem.UdListItemID    = udListItemID;
            udListItem.IsValid         = 1;
            udListItem.NotValidMessage = "New Record Key Field/s Required.";
            udListItem.CompanyID       = ClientSessionSingleton.Instance.CompanyID;
            UdListList.Where(q => q.AutoID == SelectedUdList.AutoID).FirstOrDefault().UdListItems.Add(udListItem);
            _serviceAgent.AddToUdListRepository(udListItem);
            SelectedUdListItem  = SelectedUdList.UdListItems.LastOrDefault();
            AllowEditUdListItem = true;
            return(true);
        }
コード例 #14
0
        //UdListItem Object.Property Scope Validation...
        private bool UdListItemIsValid(UdListItem udListItem, _udListItemValidationProperties validationProperties, out string errorMessage)
        {
            errorMessage = "";
            switch (validationProperties)
            {
            case _udListItemValidationProperties.UdListItemID:
                //validate key
                if (string.IsNullOrEmpty(udListItem.UdListItemID))
                {
                    errorMessage = "ID Is Required.";
                    return(false);
                }

                var count = UdListList.
                            Where(q => q.UdListID == udListItem.UdListID).Single().
                            UdListItems.
                            Where(x => x.UdListItemID == udListItem.UdListItemID).Count();
                if (count > 1)
                {
                    errorMessage = "UdListItem ID " + udListItem.UdListItemID + " Allready Exists...";
                    return(false);
                }

                if (UdListItemExists(udListItem.UdListID, udListItem.UdListItemID.ToString(), (int)udListItem.AutoID))
                {
                    errorMessage = "UdListItem ID " + udListItem.UdListItemID + " Allready Exists...";
                    return(false);
                }

                break;

            case _udListItemValidationProperties.Description:
                //validate Description
                if (string.IsNullOrEmpty(udListItem.Description))
                {
                    errorMessage = "Description Is Required.";
                    return(false);
                }
                break;
            }
            return(true);
        }
コード例 #15
0
        public IQueryable <Temp> GetMetaData(string tableName)
        {
            switch (tableName)
            {
            case "UdLists":
                UdList udList = new UdList();
                return(udList.GetMetaData().AsQueryable());

            case "UdListItems":
                UdListItem udListItem = new UdListItem();
                return(udListItem.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 Was Not Defined For The Given Table Name";
                tempList.Add(temp);
                return(tempList.AsQueryable());
            }
        }
コード例 #16
0
 public void UpdateUdListRepository(UdListItem udListItem)
 {//make sure client only fields are never updated to the db...
     UdListSingletonRepository.Instance.UpdateRepository(udListItem);
 }
コード例 #17
0
 public void DeleteFromUdListRepository(UdListItem udListItem)
 {
     UdListSingletonRepository.Instance.DeleteFromRepository(udListItem);
 }
コード例 #18
0
 public EntityStates GetUdListItemEntityState(UdListItem udListItem)
 {
     return(UdListSingletonRepository.Instance.GetUdListItemEntityState(udListItem));
 }
コード例 #19
0
 public void AddToRepository(UdListItem udListItem)
 {
     udListItem.CompanyID           = XERP.Client.ClientSessionSingleton.Instance.CompanyID;
     _repositoryContext.MergeOption = MergeOption.AppendOnly;
     _repositoryContext.AddToUdListItems(udListItem);
 }
コード例 #20
0
 private bool Delete(UdListItem udListItem)
 {//deletes are done indenpendently of the repository as a delete will not commit
     //dirty records it will simply just delete the record...
     _serviceAgent.DeleteFromUdListRepository(udListItem);
     return(true);
 }
コード例 #21
0
 public void AddToUdListRepository(UdListItem udListItem)
 {
     UdListSingletonRepository.Instance.AddToRepository(udListItem);
 }
コード例 #22
0
 private EntityStates GetUdListItemState(UdListItem udListItem)
 {
     return(_serviceAgent.GetUdListItemEntityState(udListItem));
 }