Example #1
0
        /// <summary>
        /// 根据 entityType , 返回对应的有关系的 FBEntity的集合, 
        /// </summary>
        /// <param name="fbEntity"></param>
        /// <param name="entityType">有关系的对象集合类型</param>
        /// <returns>如果不存在,将会创建相应的集合</returns>
        private ObservableCollection<FBEntity> GetRelationFBEntities(FBEntity fbEntity, string entityType)
        {
            ObservableCollection<FBEntity> listFBEntities = null;
            try
            {
                RelationManyEntity rmEntity = fbEntity.CollectionEntity.FirstOrDefault(item =>
                {
                    return item.EntityType == entityType;
                });

                if (rmEntity == null)
                {
                    rmEntity = new RelationManyEntity();
                    rmEntity.EntityType = entityType;
                    rmEntity.FBEntities = new ObservableCollection<FBEntity>();
                    fbEntity.CollectionEntity.Add(rmEntity);
                }
                listFBEntities = rmEntity.FBEntities;
            }
            catch (Exception ex)
            {

            }
            return listFBEntities;
        }
Example #2
0
        /// <summary>
        /// 根据 entityType , 返回对应的有关系的 FBEntity的集合,
        /// </summary>
        /// <param name="fbEntity"></param>
        /// <param name="entityType">有关系的对象集合类型</param>
        /// <returns>如果不存在,将会创建相应的集合</returns>
        private ObservableCollection <FBEntity> GetRelationFBEntities(FBEntity fbEntity, string entityType)
        {
            ObservableCollection <FBEntity> listFBEntities = null;

            try
            {
                RelationManyEntity rmEntity = fbEntity.CollectionEntity.FirstOrDefault(item =>
                {
                    return(item.EntityType == entityType);
                });

                if (rmEntity == null)
                {
                    rmEntity            = new RelationManyEntity();
                    rmEntity.EntityType = entityType;
                    rmEntity.FBEntities = new ObservableCollection <FBEntity>();
                    fbEntity.CollectionEntity.Add(rmEntity);
                }
                listFBEntities = rmEntity.FBEntities;
            }
            catch (Exception ex)
            {
            }
            return(listFBEntities);
        }
Example #3
0
        public FBEntity GetModifiedFBEntity()
        {
            FBEntity newEntity = this.Entity.ToFBEntity();

            newEntity.FBEntityState = this.FBEntity.FBEntityState;

            if (newEntity.FBEntityState != FBEntityState.Unchanged)
            {
                newEntity.SetObjValue(EntityFieldName.UpdateUserID, this.LoginUser.Value);
                //if (newEntity.FBEntityState == FBCommonWS.FBEntityState.Added)
                //{
                //    newEntity.Entity.EntityKey = null;
                //}
            }

            foreach (RelationManyEntity rme in this.CollectionEntity)
            {
                RelationManyEntity rmeNew = new RelationManyEntity();
                rmeNew.EntityType = rme.EntityType;
                rmeNew.FBEntities = new ObservableCollection <FBEntity>();
                rme.FBEntities.ToList().ForEach(item =>
                {
                    if (item.FBEntityState != FBEntityState.Unchanged)
                    {
                        if (item.FBEntityState == FBEntityState.Added)
                        {
                            item.SetObjValue("Entity.CREATEUSERID", this.GetObjValue("Entity.CREATEUSERID"));
                            item.SetObjValue("Entity.CREATEDATE", this.GetObjValue("Entity.CREATEDATE"));
                            // item.Entity.EntityKey = null;
                        }

                        item.SetObjValue("Entity.UPDATEUSERID", this.GetObjValue("Entity.UPDATEUSERID"));
                        item.SetObjValue("Entity.UPDATEDATE", this.GetObjValue("Entity.UPDATEDATE"));

                        FBEntity fbEntityDetail      = item.Entity.ToFBEntity();
                        fbEntityDetail.FBEntityState = item.FBEntityState;
                        rmeNew.FBEntities.Add(fbEntityDetail);
                    }
                });

                newEntity.CollectionEntity.Add(rmeNew);
            }

            if (entityHelper.DeleteList.Count > 0)
            {
                RelationManyEntity rmeDel = new RelationManyEntity();
                rmeDel.EntityType = Args.DELETE_ENTITYTYPE;
                rmeDel.FBEntities = this.entityHelper.DeleteList;
                newEntity.CollectionEntity.Add(rmeDel);
            }

            return(newEntity);
        }
Example #4
0
        /// <summary>
        /// FBEntity.CollectionEntity 的集合变化事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void CollectionEntity_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                for (int i = 0; i < e.NewItems.Count; i++)
                {
                    RelationManyEntity rme = e.NewItems[i] as RelationManyEntity;
                    rme.FBEntities.CollectionChanged += new NotifyCollectionChangedEventHandler(FBEntities_CollectionChanged);

                    foreach (FBEntity entity in rme.FBEntities)
                    {
                        RegisterFBEntity(entity);
                    }
                }
            }
            this.OnEntityPropertyChanged();
        }
Example #5
0
        public List <FBEntity> GetCompany(QueryExpression qe)
        {
            //string strType=qe.QueryType;
            //switch (strType)
            //{
            //    case "T_FB_SUBJECTDEPTMENT":
            //        listC = InnerGetCompany(qe);
            //        break;
            //    case "T_FB_SUBJECTCOMPANY":
            //        listC = InnerGetCompany(qe);
            //        break;
            //    case "T_FB_SUBJECTPOST":
            //        listC = InnerGetCompany(qe);
            //        break;
            //    case "T_FB_SUBJECTCOMPANYSET":
            //        listC = InnerGetCompany(qe);
            //        break;
            //    default:
            //        break;
            //}
            List <VirtualCompany> listC      = InnerGetCompany(qe);
            List <FBEntity>       listResult = listC.ToFBEntityList();

            listResult.ForEach(company =>
            {
                VirtualCompany vcCompany       = company.Entity as VirtualCompany;
                List <FBEntity> listDepartMent = vcCompany.DepartmentCollection.ToFBEntityList();
                RelationManyEntity rme         = new RelationManyEntity();
                rme.EntityType = typeof(VirtualDepartment).Name;
                rme.FBEntities = listDepartMent;
                company.CollectionEntity.Add(rme);

                listDepartMent.ForEach(department =>
                {
                    VirtualDepartment virtualDepartment = department.Entity as VirtualDepartment;
                    List <FBEntity> listPost            = virtualDepartment.PostCollection.ToFBEntityList();
                    RelationManyEntity rmePost          = new RelationManyEntity();
                    rmePost.EntityType = typeof(VirtualPost).Name;
                    rmePost.FBEntities = listPost;
                    department.CollectionEntity.Add(rmePost);
                });
            });
            return(listResult);
        }
Example #6
0
File: Common.cs Project: jjg0519/OA
        /// <summary>
        /// 根据 entityType , 返回对应的有关系的 FBEntity的集合,
        /// </summary>
        /// <param name="fbEntity"></param>
        /// <param name="entityType">有关系的对象集合类型</param>
        /// <returns>如果不存在,将会创建相应的集合</returns>
        public static List <FBEntity> GetRelationFBEntities(this FBEntity fbEntity, string entityType)
        {
            List <FBEntity> listFBEntities = null;

            RelationManyEntity rmEntity = fbEntity.CollectionEntity.FirstOrDefault(item =>
            {
                return(item.EntityType == entityType);
            });

            if (rmEntity == null)
            {
                rmEntity            = new RelationManyEntity();
                rmEntity.EntityType = entityType;
                rmEntity.FBEntities = new List <FBEntity>();
                fbEntity.CollectionEntity.Add(rmEntity);
            }
            listFBEntities = rmEntity.FBEntities;
            return(listFBEntities);
        }
Example #7
0
        private FBEntity GetModifiedFBEntity(FBEntity fbEntity)
        {
            FBEntity newEntity = ToFBEntity(fbEntity.Entity);

            newEntity.FBEntityState = fbEntity.FBEntityState;

            foreach (RelationManyEntity rme in fbEntity.CollectionEntity)
            {
                RelationManyEntity rmeNew = new RelationManyEntity();
                rmeNew.EntityType = rme.EntityType;
                rmeNew.FBEntities = new ObservableCollection <FBEntity>();
                rme.FBEntities.ToList().ForEach(item =>
                {
                    if (item.FBEntityState != FBEntityState.Unchanged)
                    {
                        if (item.FBEntityState == FBEntityState.Added)
                        {
                            this.ExtensionalOrderFBEntity.CopyTo(item, "Entity.CREATEUSERID");
                        }
                        this.ExtensionalOrderFBEntity.CopyTo(item, "Entity.UPDATEUSERID");

                        rmeNew.FBEntities.Add(item);
                    }
                });

                newEntity.CollectionEntity.Add(rmeNew);
            }

            if (DeleteList.Count > 0)
            {
                RelationManyEntity rmeDel = new RelationManyEntity();
                rmeDel.EntityType = "DELETE_ENTITYTYPE";
                rmeDel.FBEntities = DeleteList;
                newEntity.CollectionEntity.Add(rmeDel);
            }
            return(newEntity);
        }
Example #8
0
        private void AttachRelationManyEntity(FBEntity entity, IRelatedEnd re)
        {
            Type t     = re.GetType();
            Type eType = t.GetGenericArguments()[0];

            if (!re.IsLoaded)
            {
                re.Load();
            }

            RelationManyEntity rManyE = new RelationManyEntity();

            rManyE.EntityType       = eType.Name;
            rManyE.RelationshipName = re.RelationshipName;
            rManyE.PropertyName     = re.TargetRoleName;
            entity.CollectionEntity.Add(rManyE);

            foreach (var item in re)
            {
                FBEntity tempEntity = new FBEntity();

                tempEntity.Entity = item as EntityObject;
                rManyE.FBEntities.Add(tempEntity);
            }
            //rManyE.FBEntities.ForEach(item =>
            //    {
            //        try
            //        {
            //            IEntityWithRelationships ie = item.Entity as IEntityWithRelationships;
            //            re.Remove(ie);
            //        }
            //        catch (Exception ex)
            //        {
            //        }
            //    });
        }
Example #9
0
        void WpService_GetTripSubjectCompleted(object sender, GetTripSubjectCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                if (e.Result == null)
                {
                    OnQueryCompleted(null);
                    return;
                }

                if (e.Result.Count == 0)
                {
                    OnQueryCompleted(null);
                    return;
                }
                T_FB_EXTENSIONALORDER Extentity = new T_FB_EXTENSIONALORDER();
                Extentity.T_FB_EXTENSIONORDERDETAIL = new ObservableCollection <T_FB_EXTENSIONORDERDETAIL>();
                //特殊科目出差报销业务差旅费
                RelationManyEntity TravelEntity = new RelationManyEntity();
                TravelEntity.FBEntities = new ObservableCollection <FBEntity>();
                TravelEntity.EntityType = "T_FB_EXTENSIONORDERDETAIL_Travel";
                //其他在报销控件里面选择的费用科目
                RelationManyEntity chargeEntity = new RelationManyEntity();
                chargeEntity.FBEntities = new ObservableCollection <FBEntity>();
                chargeEntity.EntityType = "T_FB_EXTENSIONORDERDETAIL";
                foreach (var item in e.Result)
                {
                    T_FB_EXTENSIONORDERDETAIL detail = new T_FB_EXTENSIONORDERDETAIL();
                    detail.EXTENSIONORDERDETAILID = Guid.NewGuid().ToString();
                    SMT.Saas.Tools.FBServiceWS.T_FB_SUBJECT subject = new SMT.Saas.Tools.FBServiceWS.T_FB_SUBJECT();
                    if (string.IsNullOrEmpty(item.NormID))
                    {
                        MessageBox.Show("工作计划获取科目Id失败,请联系管理员!");
                    }
                    subject.SUBJECTID         = item.NormID;
                    subject.SUBJECTCODE       = item.SubjectCode;
                    subject.SUBJECTNAME       = item.SubjectName;
                    subject.OWNERID           = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID;
                    subject.OWNERPOSTID       = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].PostID;
                    subject.OWNERDEPARTMENTID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].DepartmentID;
                    subject.OWNERCOMPANYID    = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].CompanyID;
                    detail.T_FB_SUBJECT       = subject;
                    detail.USABLEMONEY        = item.UseMoney;
                    detail.APPLIEDMONEY       = item.PaidMoney;
                    detail.REMARK             = item.NormName;
                    Extentity.T_FB_EXTENSIONORDERDETAIL.Add(detail);

                    if (item.SubjectName == "业务差旅费")
                    {
                        TravelEntity.FBEntities.Add(ToFBEntity(detail));
                    }
                    else
                    {
                        chargeEntity.FBEntities.Add(ToFBEntity(detail));
                    }
                    //detail.T_F
                }

                FBEntity queryEntity = new FBEntity();
                queryEntity = ToFBEntity(Extentity);
                queryEntity.CollectionEntity.Add(TravelEntity);
                queryEntity.CollectionEntity.Add(chargeEntity);

                OnQueryCompleted(queryEntity);
            }
            else
            {
                ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("TIPS"), e.Error.Message.ToString(), Utility.GetResourceStr("CONFIRM"), MessageIcon.Exclamation);
                return;
            }
        }
Example #10
0
        protected virtual void OnLoadDataCompleted()
        {
            ObjectList <ReferencedDataInfo>    listRef    = this.OrderInfo.OrderEntity.ReferenceDatas;
            ObjectList <OrderDetailEntityInfo> listDetail = this.OrderInfo.OrderEntity.OrderDetailEntities;

            this.OrderEntity.OrderDetailData.Dictionary = listDetail.Dictionary;

            CheckOrderAction();
            if (this.OrderEntity.FBEntityState == FBEntityState.Added)
            {
                this.OrderEntity.ReferencedData.Dictionary = listRef.Dictionary;
                this.OrderEntity.SetObjValue(EntityFieldName.CreateDate, DateTime.Now);
                this.OrderEntity.SetObjValue(EntityFieldName.EditStates, decimal.Parse(((int)(EditStates.Actived)).ToString()));
                this.OrderEntity.SetObjValue(EntityFieldName.CheckStates, decimal.Parse(((int)(SMT.FB.UI.FBCommonWS.CheckStates.UnSubmit)).ToString()));


                EmployeerData CreateUser = this.OrderEntity.LoginUser;
                this.OrderEntity.SetObjValue(EntityFieldName.CreateUserID, CreateUser.Value);
                this.OrderEntity.SetObjValue("Entity.CREATEUSERNAME", CreateUser.Text);
                this.OrderEntity.SetObjValue("Entity.CREATECOMPANYID", CreateUser.Company.Value);
                this.OrderEntity.SetObjValue("Entity.CREATECOMPANYNAME", CreateUser.Company.Text);

                this.OrderEntity.SetObjValue("Entity.CREATEDEPARTMENTID", CreateUser.Department.Value);
                this.OrderEntity.SetObjValue("Entity.CREATEDEPARTMENTNAME", CreateUser.Department.Text);

                this.OrderEntity.SetObjValue("Entity.CREATEPOSTID", CreateUser.Post.Value);
                this.OrderEntity.SetObjValue("Entity.CREATEPOSTNAME", CreateUser.Post.Text);
            }

            // 初始化 ReferenceData
            for (int i = 0; i < listRef.Count; i++)
            {
                object value = listRef[i].DefaultValue;
                if (this.OrderEntity.FBEntityState != FBEntityState.Added)
                {
                    value = this.OrderEntity.GetObjValue(listRef[i].ReferencedName);
                }
                ITextValueItem item = GetReference(listRef[i].Type, value);
                this.OrderEntity.ReferencedData.Add(listRef[i].ReferencedName, item);
            }

            // 初始化 OrderDetail
            for (int i = 0; i < listDetail.Count; i++)
            {
                RelationManyEntity relationManyEntity = this.OrderEntity.CollectionEntity.FirstOrDefault(item =>
                {
                    return(item.EntityType == listDetail[i].Entity.Type);
                });

                ObservableCollection <FBEntity> listOfEntity = null;
                if (relationManyEntity == null)
                {
                    listOfEntity                  = new ObservableCollection <FBEntity>();
                    relationManyEntity            = new RelationManyEntity();
                    relationManyEntity.EntityType = listDetail[i].Entity.Type;
                    relationManyEntity.FBEntities = listOfEntity;
                    this.OrderEntity.CollectionEntity.Add(relationManyEntity);
                }
                else
                {
                    listOfEntity = relationManyEntity.FBEntities;
                }
                this.OrderEntity.OrderDetailData[listDetail[i].Name] = listOfEntity;
            }

            if (LoadDataComplete != null)
            {
                LoadDataComplete(this, null);
            }
        }
Example #11
0
        private FBEntity GetModifiedFBEntity(FBEntity fbEntity)
        {
            FBEntity newEntity = ToFBEntity(fbEntity.Entity);
            newEntity.FBEntityState = fbEntity.FBEntityState;

            foreach (RelationManyEntity rme in fbEntity.CollectionEntity)
            {
                RelationManyEntity rmeNew = new RelationManyEntity();
                rmeNew.EntityType = rme.EntityType;
                rmeNew.FBEntities = new ObservableCollection<FBEntity>();
                rme.FBEntities.ToList().ForEach(item =>
                {
                    if (item.FBEntityState != FBEntityState.Unchanged)
                    {
                        if (item.FBEntityState == FBEntityState.Added)
                        {
                            this.ExtensionalOrderFBEntity.CopyTo(item, "Entity.CREATEUSERID");
                        }
                        this.ExtensionalOrderFBEntity.CopyTo(item, "Entity.UPDATEUSERID");

                        rmeNew.FBEntities.Add(item);
                    }
                });

                newEntity.CollectionEntity.Add(rmeNew);
            }

            if (DeleteList.Count > 0)
            {
                RelationManyEntity rmeDel = new RelationManyEntity();
                rmeDel.EntityType = "DELETE_ENTITYTYPE";
                rmeDel.FBEntities = DeleteList;
                newEntity.CollectionEntity.Add(rmeDel);
            }
            return newEntity;
        }
Example #12
0
        void WpService_GetTripSubjectCompleted(object sender, GetTripSubjectCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                if (e.Result == null)
                {
                    OnQueryCompleted(null);
                    return;
                }

                if (e.Result.Count == 0)
                {
                    OnQueryCompleted(null);
                    return;
                }
                T_FB_EXTENSIONALORDER Extentity = new T_FB_EXTENSIONALORDER();
                Extentity.T_FB_EXTENSIONORDERDETAIL = new ObservableCollection<T_FB_EXTENSIONORDERDETAIL>();  
                //特殊科目出差报销业务差旅费
                RelationManyEntity TravelEntity = new RelationManyEntity();
                TravelEntity.FBEntities = new ObservableCollection<FBEntity>();
                TravelEntity.EntityType = "T_FB_EXTENSIONORDERDETAIL_Travel";
                //其他在报销控件里面选择的费用科目
                RelationManyEntity chargeEntity = new RelationManyEntity();
                chargeEntity.FBEntities = new ObservableCollection<FBEntity>();
                chargeEntity.EntityType = "T_FB_EXTENSIONORDERDETAIL";
                foreach(var item in e.Result)
                {
                    T_FB_EXTENSIONORDERDETAIL detail = new T_FB_EXTENSIONORDERDETAIL();
                    detail.EXTENSIONORDERDETAILID = Guid.NewGuid().ToString();  
                    SMT.Saas.Tools.FBServiceWS.T_FB_SUBJECT subject=new SMT.Saas.Tools.FBServiceWS.T_FB_SUBJECT();
                    if(string.IsNullOrEmpty(item.NormID))
                    {
                        MessageBox.Show("工作计划获取科目Id失败,请联系管理员!");
                    }
                    subject.SUBJECTID = item.NormID;
                    subject.SUBJECTCODE = item.SubjectCode;
                    subject.SUBJECTNAME = item.SubjectName;
                    subject.OWNERID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID;
                    subject.OWNERPOSTID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].PostID;
                    subject.OWNERDEPARTMENTID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].DepartmentID;
                    subject.OWNERCOMPANYID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].CompanyID;
                    detail.T_FB_SUBJECT = subject;
                    detail.USABLEMONEY = item.UseMoney;
                    detail.APPLIEDMONEY = item.PaidMoney;
                    detail.REMARK = item.NormName;
                    Extentity.T_FB_EXTENSIONORDERDETAIL.Add(detail);

                    if(item.SubjectName=="业务差旅费")
                    {                      
                        TravelEntity.FBEntities.Add(ToFBEntity(detail));
                    }else
                    {
                        chargeEntity.FBEntities.Add(ToFBEntity(detail));
                    }
                    //detail.T_F
                }

                FBEntity queryEntity = new FBEntity();
                queryEntity = ToFBEntity(Extentity);
                queryEntity.CollectionEntity.Add(TravelEntity);
                queryEntity.CollectionEntity.Add(chargeEntity);

                OnQueryCompleted(queryEntity);
            }
            else
            {
                ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("TIPS"), e.Error.Message.ToString(), Utility.GetResourceStr("CONFIRM"), MessageIcon.Exclamation);
                return;
            }

        }