Exemplo n.º 1
0
        /// <summary>
        /// 关联
        /// </summary>
        /// <param name="actionContext"></param>
        /// <param name="httpContext"></param>
        public void AssociateAction(ActionContext actionContext, HttpContext httpContext)
        {
            string otherUnid = httpContext.Request.Params["otherUnid"];
            string userUnids = httpContext.Request.Params["userUnids"];
            string otherType = httpContext.Request.Params["otherType"];

            string[] unids = userUnids.Split(',');

            if (!(string.IsNullOrEmpty(otherUnid) || string.IsNullOrEmpty(otherType) || unids == null || unids.Length == 0))
            {
                foreach (string userUnid in unids)
                {
                    RelationShip rs = this.relationShipService.Get(otherUnid, userUnid);
                    if (rs == null)
                    {
                        rs                  = new RelationShip();
                        rs.ParentType       = otherType;
                        rs.ParentUnid       = otherUnid;
                        rs.ChildType        = User.RELATIONSHIP_CODE;
                        rs.ChildUnid        = userUnid;
                        rs.RelationShipType = rs.ParentType + "." + rs.ChildType;
                        this.relationShipService.Save(rs);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void StoreRelation(IfDataStrategy DataReader, MainDataSet dataset)
        {
            RelationShip newRelation;

            if (this.procedure != null)
            {
                //Procedure
                newRelation = new RelationShip(this.Name, this.Type, this.procedure.Name, this.procedure.Type, "BelongTo", "1");
                DataReader.InsertRelationShip(newRelation);
            }
            if (this.nextStep != null)
            {
                //NextStep
                newRelation = new RelationShip(this.Name, this.Type, this.nextStep.Name, this.nextStep.Type, "Next", "1");
                DataReader.InsertRelationShip(newRelation);
            }
            if (this.preStep != null)
            {
                //PreviousStep
                newRelation = new RelationShip(this.Name, this.Type, this.preStep.Name, this.preStep.Type, "Previous", "1");
                DataReader.InsertRelationShip(newRelation);
            }
            if (this.IsFeedback == true)
            {
                return;
            }
            if (this.handleRole != null)
            {
                //HandleRole
                newRelation = new RelationShip(this.Name, this.Type, this.handleRole.Name, this.handleRole.Type, "HandleBy", "1");
                DataReader.InsertRelationShip(newRelation);
            }
        }
            public async Task <bool> Handle(AddRelationShipCommand request, CancellationToken cancellationToken)
            {
                bool userExist;

                ApplicationUser invitedUser = await _context.ApplicationUsers.FirstOrDefaultAsync(x => x.UserName == request.UserName);

                ApplicationUser invitingUser = await _context.ApplicationUsers.FirstOrDefaultAsync(x => x.Id == request.CurrentUserId);

                if (invitedUser != null)
                {
                    RelationShip relationShip = new RelationShip()
                    {
                        InvitedUserId  = invitedUser.Id,
                        InvitingUserId = invitingUser.Id,
                        IsAccepted     = false
                    };

                    await _context.RelationShips.AddAsync(relationShip);

                    await _context.SaveChangesAsync();

                    userExist = true;
                }
                else
                {
                    userExist = false;
                }

                return(userExist);
            }
        public async Task Should_change_relationShip_isAccepted_to_true()
        {
            //Arrange
            ApplicationUser invitedUser  = new ApplicationUser();
            ApplicationUser invitingUser = new ApplicationUser();

            await _context.ApplicationUsers.AddAsync(invitedUser);

            await _context.ApplicationUsers.AddAsync(invitingUser);

            RelationShip relationShip = new RelationShip
            {
                IsAccepted     = false,
                InvitedUserId  = invitedUser.Id,
                InvitingUserId = invitingUser.Id,
            };

            await _context.RelationShips.AddAsync(relationShip);

            await _context.SaveChangesAsync();

            var handler = new AcceptFriendRequestCommandHandler(_context);

            //Act
            var result = await handler.Handle(new AcceptFriendRequestCommand
            {
                InvitedUserId  = invitedUser.Id,
                InvitingUserId = invitingUser.Id
            }, CancellationToken.None);


            //Assert
            _context.RelationShips.Find(relationShip.Id).IsAccepted.Should().BeTrue();
        }
Exemplo n.º 5
0
        public void StoreRelation(IfDataStrategy DataReader, MainDataSet dataset)
        {
            RelationShip newRelation;

            if (this.usrGroups.Count > 0)
            {
                //UserRoles[1:n]
                foreach (UserGroup curGroup in this.usrGroups)
                {
                    newRelation = new RelationShip(this.Name, this.Type, curGroup.Name, curGroup.Type, "BelongTo", "1");
                    DataReader.InsertRelationShip(newRelation);
                }
            }
            if (this.taskSubmit.Count > 0)
            {
                //SubmitTasks[1:n]
                foreach (IfTask curTask in this.taskSubmit)
                {
                    newRelation = new RelationShip(this.Name, this.Type, curTask.Name, curTask.Type, "Submit", "1");
                    DataReader.InsertRelationShip(newRelation);
                }
            }
            if (this.taskHandle.Count > 0)
            {
                //HandleTasks[1:n]
                foreach (IfTask curTask in this.taskHandle)
                {
                    newRelation = new RelationShip(this.Name, this.Type, curTask.Name, curTask.Type, "Handle", "1");
                    DataReader.InsertRelationShip(newRelation);
                }
            }
        }
Exemplo n.º 6
0
        public ActionResult AddFriend(int id)
        {
            var user = SessionSet <User> .Get("Login");

            RelationShip rs = new RelationShip()
            {
                User1ID      = user.ID,
                User2ID      = id,
                CreatedDate  = DateTime.Now,
                ActionUserID = user.ID,
                StatusID     = 1
            };

            _br.AddModel(rs);
            Notification notify = new Notification()
            {
                UserID      = user.ID,
                ActionID    = 1,
                PostUserID  = id,
                IsShow      = true,
                NotifyText  = user.Name + " wants to add you as a friend.",
                CreatedDate = DateTime.Now
            };

            _db.Notifications.Add(notify);
            _db.SaveChanges();

            return(RedirectToAction("Home", "Home"));
        }
Exemplo n.º 7
0
        /// <summary>
        /// 绑定
        /// </summary>
        /// <param name="account"></param>
        /// <param name="parentId">父母 Id</param>
        /// <param name="relationShip"></param>
        /// <returns></returns>
        public bool Binding(string account, int parentId, RelationShip relationShip)
        {
            var user = from u in _myContext.Users
                       where u.Account == account
                       select u;

            if (user.FirstOrDefault() == null)
            {
                return(false);
            }
            else
            {
                var      userone  = user.FirstOrDefault();
                Children children = new Children
                {
                    Account      = account,
                    SonId        = userone.Id,
                    ParentId     = parentId,
                    Name         = userone.Name,
                    RelationShip = relationShip
                };
                _myContext.Children.Add(children);
                return(true);
            }
        }
Exemplo n.º 8
0
    static public void buildRelationShip(GameObject p1, GameObject p2, float dis)
    {
        Person pp1 = p1.GetComponent <PersonMono>().m_person;
        Person pp2 = p2.GetComponent <PersonMono>().m_person;

        RelationShip R = new RelationShip();

        R.p1       = pp1;
        R.p2       = pp2;
        R.Distance = dis;

        if (p1.name == "Player")
        {
            p2.transform.localPosition = Vector3.Normalize(p2.transform.localPosition - p1.transform.localPosition) * dis;
        }

        R.LineRender = new GameObject();
        R.LineRender.AddComponent <LineRenderer>();
        LineRenderer lr = R.LineRender.GetComponent <LineRenderer>();

        R.LineRender.layer = 5;
        lr.material        = Resources.Load <Material>("Line");

        p1.GetComponent <PersonMono>().m_person.friendList.Add(R);
        p2.GetComponent <PersonMono>().m_person.friendList.Add(R);
        relationShips.Add(R);
    }
        public async Task ShouldReturnApplicationUsers()
        {
            //Arrage
            ApplicationUser currentUser = new ApplicationUser();
            ApplicationUser friendUser  = new ApplicationUser();

            await _context.ApplicationUsers.AddAsync(currentUser);

            await _context.ApplicationUsers.AddAsync(friendUser);

            RelationShip relationShip = new RelationShip
            {
                InvitingUserId = currentUser.Id,
                InvitedUserId  = friendUser.Id
            };

            await _context.RelationShips.AddAsync(relationShip);

            await _context.SaveChangesAsync();

            IQueryable <RelationShip> relationShips = _context.RelationShips;

            var handler = new GetFriendsByUserIdAndRelationShipsQueryHandler();

            //Act
            List <ApplicationUser> friends = await handler.Handle(new GetFriendsByUserIdAndRelationShipsQuery
            {
                Id            = currentUser.Id,
                RelationShips = relationShips
            }, CancellationToken.None);

            //Assert
            friends.Should().NotBeNull();
            friends.FirstOrDefault(x => x.Id == friendUser.Id).Should().NotBeNull();
        }
Exemplo n.º 10
0
    //方法
    public void UpdateRelationShip()
    {
        //自动增长技能
        for (int i = 0; i < Skills.Count; ++i)
        {
            Skill sk   = Skills[i];
            float comu = 0;
            foreach (var relation in friendList)
            {
                if (relation.Distance < 320)
                {
                    comu += getSkill(sk.skillName);
                }
            }
            sk.skill += comu;
            Skills[i] = sk;
        }

        //距离疏远
        for (int i = 0; i < friendList.Count; ++i)
        {
            RelationShip r = friendList[i];
            r.Distance   += Mathf.Pow(r.Distance * 0.2f * 0.01f, 2) * 100.0f;
            friendList[i] = r;
        }
    }
Exemplo n.º 11
0
    public int Add()
    {
        int NewID = 0;

        try
        {
            NewID = Convert.ToInt32(

                DBUtil.DBOp("ConnDB",
                            "exec dbo.usp_CaseUser_xAddContactRelationShip {0},{1},{2},{3},{4}  ",
                            new string[] {
                CaseID.ToString()
                , RelationShip.ToString()
                , ContactCaseID.ToString()
                , (IsMain?"1":"0")
                , AuthServer.GetLoginUser().ID.ToString()
            },
                            NSDBUtil.CmdOpType.ExecuteScalar));
        }
        catch (Exception ex)
        {
            throw ex;
        }
        return(NewID);
    }
Exemplo n.º 12
0
        public async Task ShouldReturnRelationShip()
        {
            //Arrange
            ApplicationUser currentUser = new ApplicationUser();
            ApplicationUser friendUser  = new ApplicationUser();

            await _context.ApplicationUsers.AddAsync(currentUser);

            await _context.ApplicationUsers.AddAsync(friendUser);

            RelationShip relationShip = new RelationShip
            {
                IsAccepted     = true,
                InvitedUserId  = currentUser.Id,
                InvitingUserId = friendUser.Id,
            };

            await _context.RelationShips.AddAsync(relationShip);

            await _context.SaveChangesAsync();

            var handler = new GetRelationShipIdByUserIdAndFriendIdQueryHandler(_context);

            //Act
            int relationShipId = await handler.Handle(new GetRelationShipIdByUserIdAndFriendIdQuery
            {
                CurrentUserId = currentUser.Id,
                FriendId      = friendUser.Id
            }, CancellationToken.None);

            //Assert
            relationShipId.GetType().Should().Be(typeof(int));
            relationShipId.Should().Be(relationShip.Id);
        }
Exemplo n.º 13
0
        public void StoreRelation(IfDataStrategy DataReader, MainDataSet dataset)
        {
            RelationShip newRelation;

            if (this.task.BusinessType != null)
            {
                //TaskType[1:1]
                newRelation = new RelationShip(this.Name, this.Type, this.task.BusinessType.Name, this.task.BusinessType.Type, "SetType", "1");
                DataReader.InsertRelationShip(newRelation);
            }
            if (this.task.Submitter != null)
            {
                //Sumitter[1:1]
                newRelation = new RelationShip(this.Name, this.Type, this.task.Submitter.Name, this.task.Submitter.Type, "Submitter", "1");
                DataReader.InsertRelationShip(newRelation);
            }
            if (this.task.Handler != null)
            {
                //Handler[1:1]
                newRelation = new RelationShip(this.Name, this.Type, this.task.Handler.Name, this.task.Handler.Type, "Handler", "1");
                DataReader.InsertRelationShip(newRelation);
            }
            if (this.task.QLevel != null)
            {
                //Priority[1:1]
                newRelation = new RelationShip(this.Name, this.Type, this.task.QLevel.Name, this.task.QLevel.Type, "SetPriority", "1");
                DataReader.InsertRelationShip(newRelation);
            }
            if (this.curStep != null)
            {
                //CurrentStep[1:1]
                newRelation = new RelationShip(this.Name, this.Type, this.curStep.Name, this.curStep.Type, "CurrentStep", "1");
                DataReader.InsertRelationShip(newRelation);
            }
        }
Exemplo n.º 14
0
 public void Handle(RelationShipUpdated e)
 {
     using (var db = new CoreDbContext())
     {
         var temp = db.RelationShips.FirstOrDefault(i => i.FromId == e.OldFromId &&
                                                    i.ToId == e.OldToId);
         if (temp == null)
         {
             temp               = new RelationShip();
             temp.FromId        = e.FromId;
             temp.ToId          = e.ToId;
             temp.FromTableName = e.FromTableName;
             temp.ToTableName   = e.ToTableName;
             temp.DisplayOrder  = e.DisplayOrder;
             db.RelationShips.Add(temp);
             db.SaveChanges();
         }
         else
         {
             temp.FromId        = e.FromId;
             temp.ToId          = e.ToId;
             temp.FromTableName = e.FromTableName;
             temp.ToTableName   = e.ToTableName;
             temp.DisplayOrder  = e.DisplayOrder;
             db.SaveChanges();
         }
     }
 }
Exemplo n.º 15
0
        public int GetHashCode(RelationShip <TSource, TTarget, TValue> obj)
        {
            var a = checkSource ? 101 * obj.Source.GetHashCode() : 0;
            var b = checkTarget ? 127 * obj.Target.GetHashCode() : 0;
            var c = checkValue ? 181 * obj.Value.GetHashCode() : 0;

            return(a + b + c);
        }
Exemplo n.º 16
0
        public void Test1()
        {
            Diff d = new Diff();

            Assert.True(d.RelationShips.Count == 0, "you must start empty");
            var e1 = new Entity {
                Id = "0", Type = "Type1"
            };
            var e2 = new Entity {
                Id = "1", Type = "Type2"
            };
            var r1 = new RelationShip <Entity, Entity, RelationShipDescriptor>(
                e1,
                e1,
                new RelationShipDescriptor {
                Name = "Prop1"
            }
                );
            var r2 = new RelationShip <Entity, Entity, RelationShipDescriptor>(
                e1,
                e1,
                new RelationShipDescriptor {
                Name = "Prop1"
            }
                );

            d.RelationShips.Add(r1);
            d.RelationShips.Add(r1);
            d.RelationShips.Add(r2);
            var a1 = d.Print();

            Assert.True(d.RelationShips.Count == 1, "you cant add the the relationship twice");
            var r3 = new RelationShip <Entity, Entity, RelationShipDescriptor>(
                e1,
                e2,
                new RelationShipDescriptor {
                Name = "Prop1"
            }
                );

            d.RelationShips.Add(r3);

            Assert.True(d.RelationShips.Count == 1, "you cant add the the relationship twice");
            Assert.True(d.RelationShips.First().Target == e2, "the relation ship should be updated");
            var r4 = new RelationShip <Entity, Entity, RelationShipDescriptor>(
                e1,
                e2,
                new RelationShipDescriptor {
                Name = "Prop2"
            }
                );

            d.RelationShips.Add(r4);
            var a2 = d.Print();

            Assert.True(d.RelationShips.Count == 2, "the relationship should be added");
        }
Exemplo n.º 17
0
    /**
     * Function that adds a <inverse> RelationShip of this point with another <point>
     * @returns the added Relationship instance
     * */
    public RelationShip addInverseRelationWith(MapPoint point, string inverse)
    {
        RelationShip relation = new RelationShip(this, point, "");

        relation.setInverse(inverse);
        this.relations.Add(relation);

        return(relation);
    }
Exemplo n.º 18
0
 /// <summary>
 /// Relations the exists.
 /// </summary>
 /// <param name="relation">The relation.</param>
 /// <returns></returns>
 private bool RelationExists(RelationShip relation)
 {
     return(relation.Source == relation.Target ||
            _relations.Exists(delegate(RelationShip rel)
     {
         return rel.Source.Id == relation.Source.Id &&
         (rel.Target != null && rel.Target.Id == relation.Target.Id) ||
         (rel.Target == null && rel.TargetAsString == relation.TargetAsString);
     }));
 }
Exemplo n.º 19
0
 public void hideRelationsPerPoint(MapPoint point)
 {
     //Debug.Log("llamando a HIDE relations per point");
     if (relationsPerPoint.ContainsKey(point))
     {
         RelationShip relation = relationsPerPoint[point];
         relation.hide();
         center.hideClusterRelations(point);
     }
 }
Exemplo n.º 20
0
    public static void InitializeRelations()
    {
        print("RELATIONS INITIALIZED");
        factionRelationships = new Dictionary <string, RelationShip>();

        foreach (string faction in FactionsManager.factions.Keys)
        {
            factionRelationships[faction] = new RelationShip();
        }
    }
Exemplo n.º 21
0
        public override void Execute(string pDataFilePath)
        {
            logger.Debug("开始导入岗位");
            IList <string> list = TextHelper.ReadTextByReadLine(pDataFilePath);

            foreach (string str in list)
            {
                string[] values = str.Split(';');
                Group    info   = new Group();
                info.ID            = -1;
                info.IsInner       = Constants.YESNO_YES;
                info.GroupStatus   = GroupStatuses.Enable;
                info.Name          = values[0];
                info.Code          = values[1];
                info.IsCanDispatch = values[3];
                info.IsInner       = values[5];
                foreach (OUInfo ouInfo in ouInfoList)
                {
                    if (ouInfo.Code.Equals(values[2], StringComparison.OrdinalIgnoreCase))
                    {
                        info.OUCode     = ouInfo.Code;
                        info.OUFullName = ouInfo.FullName;
                        info.OUFullCode = ouInfo.FullCode;
                        info.OUName     = ouInfo.Name;
                        info.OUUnid     = ouInfo.Unid;
                        break;
                    }
                }

                if (values.Length > 4)
                {
                    string   relation = Group.RELATIONSHIP_CODE + "." + Role.RELATIONSHIP_CODE;
                    string[] roles    = System.Text.RegularExpressions.Regex.Split(values[4], ",");
                    foreach (string roleCode in roles)
                    {
                        foreach (Role role in roleList)
                        {
                            if (roleCode.Equals(role.Code, StringComparison.OrdinalIgnoreCase))
                            {
                                RelationShip relationShip = new RelationShip(info.Unid, Group.RELATIONSHIP_CODE, role.Unid, Role.RELATIONSHIP_CODE, relation);
                                relationShipService.Save(relationShip);
                                //TSCommon_Core.Organize.Domain.RelationShip relationship = new TSCommon_Core.Organize.Domain.RelationShip();
                                //relationship.ParentUnid = info.Unid;
                                //relationship.ParentType = Group.RELATIONSHIP_CODE;
                                //relationship.ChildUnid = role.Unid;
                                //relationship.ChildType = Role.RELATIONSHIP_CODE;
                                //relationship.RelationShipType = "group.role";
                                //this.relationShipService.Save(relationship);
                            }
                        }
                    }
                }
                groupDao.Save(info);
            }
        }
Exemplo n.º 22
0
        private void BuildUserGroup()
        {
            UserGroup newGroup;

            newGroup = new UserGroup("客户", "权限:提交维修单,查看自己提交的维修单。");
            DataReader.InsertRecord(new Record(newGroup.Name, newGroup.Type, newGroup.XMLSerialize()));
            newGroup = new UserGroup("客服人员", "权限:审核维修单,查看自己处理的维修单。");
            DataReader.InsertRecord(new Record(newGroup.Name, newGroup.Type, newGroup.XMLSerialize()));
            newGroup = new UserGroup("客服经理", "权限:收集维修单,查看自己处理的维修单,查看自己下属的维修单。");
            DataReader.InsertRecord(new Record(newGroup.Name, newGroup.Type, newGroup.XMLSerialize()));
            newGroup = new UserGroup("维修工程师", "权限:处理维修单,查看自己处理的维修单。");
            DataReader.InsertRecord(new Record(newGroup.Name, newGroup.Type, newGroup.XMLSerialize()));

            //newRelation = new RelationShip("", "UserGroup", "", "ProcedureStep", "InCharge", "1");
            //newRelation = new RelationShip("", "ProcedureStep", "", "UserGroup", "HandleBy", "1");
            RelationShip newRelation;

            newRelation = new RelationShip("客户", "UserGroup", "报修_问题提交", "ProcedureStep", "InCharge", "1");
            DataReader.InsertRelationShip(newRelation);
            newRelation = new RelationShip("报修_问题提交", "ProcedureStep", "客户", "UserGroup", "HandleBy", "1");
            DataReader.InsertRelationShip(newRelation);
            newRelation = new RelationShip("客服人员", "UserGroup", "报修_问题审核", "ProcedureStep", "InCharge", "1");
            DataReader.InsertRelationShip(newRelation);
            newRelation = new RelationShip("报修_问题审核", "ProcedureStep", "客服人员", "UserGroup", "HandleBy", "1");
            DataReader.InsertRelationShip(newRelation);
            newRelation = new RelationShip("客服经理", "UserGroup", "报修_维修单分配", "ProcedureStep", "InCharge", "1");
            DataReader.InsertRelationShip(newRelation);
            newRelation = new RelationShip("报修_维修单分配", "ProcedureStep", "客服经理", "UserGroup", "HandleBy", "1");
            DataReader.InsertRelationShip(newRelation);
            newRelation = new RelationShip("维修工程师", "UserGroup", "报修_维修单处理", "ProcedureStep", "InCharge", "1");
            DataReader.InsertRelationShip(newRelation);
            newRelation = new RelationShip("报修_维修单处理", "ProcedureStep", "维修工程师", "UserGroup", "HandleBy", "1");
            DataReader.InsertRelationShip(newRelation);
            newRelation = new RelationShip("客户", "UserGroup", "报修_维修结果反馈", "ProcedureStep", "InCharge", "1");
            DataReader.InsertRelationShip(newRelation);
            newRelation = new RelationShip("报修_维修结果反馈", "ProcedureStep", "客户", "UserGroup", "HandleBy", "1");
            DataReader.InsertRelationShip(newRelation);


            newRelation = new RelationShip("客户", "UserGroup", "咨询_问题提交", "ProcedureStep", "InCharge", "1");
            DataReader.InsertRelationShip(newRelation);
            newRelation = new RelationShip("咨询_问题提交", "ProcedureStep", "客户", "UserGroup", "HandleBy", "1");
            DataReader.InsertRelationShip(newRelation);
            newRelation = new RelationShip("客服人员", "UserGroup", "咨询_问题回复", "ProcedureStep", "InCharge", "1");
            DataReader.InsertRelationShip(newRelation);
            newRelation = new RelationShip("咨询_问题回复", "ProcedureStep", "客服人员", "UserGroup", "HandleBy", "1");
            DataReader.InsertRelationShip(newRelation);
            newRelation = new RelationShip("客户", "UserGroup", "咨询_咨询结果反馈", "ProcedureStep", "InCharge", "1");
            DataReader.InsertRelationShip(newRelation);
            newRelation = new RelationShip("咨询_咨询结果反馈", "ProcedureStep", "客户", "UserGroup", "HandleBy", "1");
            DataReader.InsertRelationShip(newRelation);

            DataReader.AcceptModification();
        }
Exemplo n.º 23
0
    public RelationShip getRelationPerPoint(MapPoint point)
    {
        RelationShip relation = null;

        if (relationsPerPoint.ContainsKey(point))
        {
            relation = relationsPerPoint[point];
        }

        return(relation);
    }
Exemplo n.º 24
0
        public void StoreRelation(IfDataStrategy DataReader, MainDataSet dataset)
        {
            RelationShip newRelation;

            if (this.IsUseProcedure == false)
            {
                return;
            }
            //Procedure
            newRelation = new RelationShip(this.Name, this.Type, this.procedure.Name, this.procedure.Type, "Assign", "1");
            DataReader.InsertRelationShip(newRelation);
        }
Exemplo n.º 25
0
    public void showRelationsPerPoint(MapPoint point)
    {
        //Debug.Log("llamando a SHOW relations per point");
        if (relationsPerPoint.ContainsKey(point))
        {
            RelationShip relation = relationsPerPoint[point];

            relation.show();

            center.showClusterRelations(point);
        }
    }
		public void RelADD()
		{
			var prueba = new string[] { "one", "two" };
			var e = new RelationShip<int, char>();
			for (var f = 0; f < prueba.Length; f++)
				e.AddRangeA(f, prueba[f].ToCharArray());
			for (var f = 0; f < prueba.Length; f++)
				Assert.AreEqual(new string(e.GetBs(f).ToArray()), prueba[f]);
			Assert.IsTrue(e.GetAs('o').SequenceEqual(new[]{ 0, 1 }));
			Assert.IsTrue(e.GetAs('n').SequenceEqual(new int[] { 0 }));
			Assert.IsTrue(e.GetAs('e').SequenceEqual(new int[] { 0 }));
		}
Exemplo n.º 27
0
        public override void Save(Group group)
        {
            if (!this.groupDao.IsUnique(group))
            {
                throw new ResourceException("GROUP.EXCEPTION.HAD_EXIST", new string[] { group.Name, group.Code });
            }

            // 保存与角色之间的关联关系
            IList  roleUnids     = group.RoleUnidLists;
            IList  relationShips = new ArrayList();
            string relation      = Group.RELATIONSHIP_CODE + "." + Role.RELATIONSHIP_CODE;

            if (null != roleUnids && roleUnids.Count > 0)
            {
                foreach (string role in roleUnids)
                {
                    RelationShip relationShip = new RelationShip(group.Unid, Group.RELATIONSHIP_CODE, role, Role.RELATIONSHIP_CODE,
                                                                 relation);
                    relationShips.Add(relationShip);
                }
            }
            this.relationShipService.UpdateRelationByParent(group.Unid, relation, relationShips);

            // 保存与人员之间的关联关系
            IList UserInfoUnids = group.UserInfoUnidLists;

            relationShips = new ArrayList();
            relation      = Group.RELATIONSHIP_CODE + "." + User.RELATIONSHIP_CODE;
            if (null != UserInfoUnids && UserInfoUnids.Count > 0)
            {
                foreach (string userUnid in UserInfoUnids)
                {
                    RelationShip relationShip = new RelationShip(group.Unid, Group.RELATIONSHIP_CODE, userUnid, User.RELATIONSHIP_CODE,
                                                                 relation);
                    relationShips.Add(relationShip);
                }
            }
            this.relationShipService.UpdateRelationByParent(group.Unid, relation, relationShips);

            // 同步上级单位的信息
            OUInfo ouInfo = this.ouInfoService.Load(group.OUUnid);

            if (null != ouInfo)
            {
                group.OUName     = ouInfo.Name;
                group.OUCode     = ouInfo.Code;
                group.OUFullName = ouInfo.FullName;
                group.OUFullCode = ouInfo.FullCode;
            }
            this.groupDao.Save(group);
        }
Exemplo n.º 28
0
 public void SetRelationShip(Group fromGroup, Group toGroup, RelationShip relation)
 {
     uint key = ((uint) fromGroup << 16 | (uint) toGroup);
     if (_relationTable.ContainsKey(key))
     {
         _relationTable[key].RelationShip = relation;
     }
     else
     {
         var groupInfo = new RelatedGroupInfo();
         groupInfo.RelationShip = relation;
         _relationTable.Add(key, groupInfo);
     }
 }
Exemplo n.º 29
0
    /**
     * Function that add a RelationShip named <name> fromt this point with <point>
     * @returns the added RelationShip instance
     * */
    public RelationShip addRelationWith(MapPoint point, string name)
    {
        RelationShip relation = null;

        if (!this.hasRelationShipWith(point, name))
        {
            relation = new RelationShip(this, point, name);
            this.relations.Add(relation);
            RelationShip inverseRelation = point.addInverseRelationWith(this, name);
            inverseRelation.hide();
        }

        return(relation);
    }
Exemplo n.º 30
0
        public void StoreRelation(IfDataStrategy DataReader, MainDataSet dataset)
        {
            this.user.StoreRelation(DataReader, dataset);
            RelationShip newRelation;

            if (this.uInferiors.Count > 0)
            {
                //InferiorUsers[1:n]
                foreach (IfUser curUser in this.uInferiors)
                {
                    newRelation = new RelationShip(this.Name, this.Type, curUser.Name, curUser.Type, "Inferior", "1");
                    DataReader.InsertRelationShip(newRelation);
                }
            }
        }
Exemplo n.º 31
0
    public void addRelationsPerPoint(MapPoint point, List <GridCluster> relatedClusters)
    {
        if (!relationsPerPoint.ContainsKey(point))
        {
            List <MapPoint> clusterCenters = new List <MapPoint>();
            foreach (GridCluster cluster in relatedClusters)
            {
                clusterCenters.Add(cluster.getCenter());
            }
            RelationShip relation = new RelationShip(this.getCenter(), clusterCenters, point.getLabel());
            relationsPerPoint.Add(point, relation);

            propagateRelationWith(point, relatedClusters);
        }
    }
Exemplo n.º 32
0
            public async Task <Unit> Handle(AcceptFriendRequestCommand request, CancellationToken cancellationToken)
            {
                RelationShip relationShip = await _context.RelationShips.FirstOrDefaultAsync(
                    x => x.InvitedUserId == request.InvitedUserId &&
                    x.InvitingUserId == request.InvitingUserId
                    );

                if (relationShip != null)
                {
                    relationShip.IsAccepted = true;
                    await _context.SaveChangesAsync();
                }

                return(Unit.Value);
            }