예제 #1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public static Member FromCreateFabMember(CreateFabMember pApi)
        {
            var dom = new Member();

            FromCreateFabMember(dom, pApi);
            return(dom);
        }
예제 #2
0
 ////////////////////////////////////////////////////////////////////////////////////////////////
 /*--------------------------------------------------------------------------------------------*/
 public FabricRequest <FabResponse <FabMember> > Request(CreateFabMember Data, SessionType UseSessionType = SessionType.Default)
 {
     return(new FabricRequest <FabResponse <FabMember> >("POST", Uri,
                                                         null,
                                                         "Data=" + Data.ToJson()
                                                         ));
 }
예제 #3
0
        public void AddMemberDefinedByUser()
        {
            var dom = new Member {
                MemberType = (byte)MemberType.Id.Staff,
                Timestamp  = 94394393349,
            };

            var cre = new CreateFabMember {
                DefinedByUserId = 36236234,
                DefinedByAppId  = 1236234623
            };

            TestAddEdge(
                x => vTasks.AddMemberDefinedByUser(x, dom, cre, GetAddVertexAlias <Member>()),
                cre.DefinedByUserId,
                DbName.Edge.MemberDefinedByUserName,
                DbName.Edge.UserDefinesMemberName,
                new[] {
                DbName.Edge.UserDefinesMember.Timestamp,
                DbName.Edge.UserDefinesMember.MemberType,
                DbName.Edge.UserDefinesMember.AppId
            },
                new object[] {
                dom.Timestamp,
                dom.MemberType,
                cre.DefinedByAppId
            }
                );
        }
예제 #4
0
 /*--------------------------------------------------------------------------------------------*/
 private static void FromCreateFabMember(Member pDomain, CreateFabMember pApi)
 {
     FromCreateFabVertex(pDomain, pApi);
     pDomain.MemberType            = pApi.Type;
     pDomain.OauthScopeAllow       = pApi.OauthScopeAllow;
     pDomain.OauthGrantRedirectUri = ToLowerCase(pApi.OauthGrantRedirectUri);
     pDomain.OauthGrantCode        = pApi.OauthGrantCode;
     pDomain.OauthGrantExpires     = pApi.OauthGrantExpires;
 }
예제 #5
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        protected override void TestSetUp()
        {
            base.TestSetUp();

            vCreateMember = new CreateFabMember();
            vCreateMember.DefinedByAppId  = (long)SetupAppId.Bookmarker;
            vCreateMember.DefinedByUserId = (long)SetupUserId.FabData;
            vCreateMember.Type            = (byte)MemberType.Id.Invite;
        }
        /*--------------------------------------------------------------------------------------------*/
        private Result ExecuteSession()
        {
            long appId = vOpCtx.GetSharpflakeId <Vertex>();
            long memId = vOpCtx.GetSharpflakeId <Vertex>();

            var appCre = new CreateFabApp();

            appCre.Name              = vName;
            appCre.Secret            = vOpCtx.Code32;
            appCre.CreatedByMemberId = vCreatorMemberId;

            var memCre = new CreateFabMember();

            memCre.Type            = (byte)MemberType.Id.DataProv;
            memCre.DefinedByAppId  = appId;
            memCre.DefinedByUserId = vUserId;

            ////

            var appOp = new CreateAppOperation();

            appOp.SetExecuteData(vOpCtx, vBuild, vTasks, appCre, appId, vDataAcc, false);

            var memOp = new CreateMemberOperation();

            memOp.SetExecuteData(vOpCtx, vBuild, vTasks, memCre, memId, vDataAcc, false);

            ////

            vBuild.StartSession();
            appOp.CheckAndAddVertex();
            memOp.CheckAndAddVertex();
            appOp.AddEdges();
            memOp.AddEdges();
            vBuild.CommitAndCloseSession();

            ////

            IDataResult res = vDataAcc.Execute(GetType().Name);

            vBuild.PerformChecks(res);

            int appCmdI = res.GetCommandIndexByCmdId(appOp.AddVertexCommandId);
            int memCmdI = res.GetCommandIndexByCmdId(memOp.AddVertexCommandId);

            return(new Result {
                Status = ResultStatus.Success,
                NewApp = res.ToElementAt <App>(appCmdI, 0),
                NewMember = res.ToElementAt <Member>(memCmdI, 0)
            });
        }
예제 #7
0
        /*--------------------------------------------------------------------------------------------*/
        public virtual void AddMemberDefinedByUser(ICreateOperationBuilder pCreCtx,
                                                   Member pNewDom, CreateFabMember pNewCre, IWeaverVarAlias <Member> pAlias)
        {
            var a = AddEdge <Member, MemberDefinedByUser, User>(
                pCreCtx, pAlias, pNewCre.DefinedByUserId);

            var udmEdge = new UserDefinesMember();

            udmEdge.Timestamp  = pNewDom.Timestamp;
            udmEdge.MemberType = pNewDom.MemberType;
            udmEdge.AppId      = pNewCre.DefinedByAppId;

            AddReverseEdge(pCreCtx, a, udmEdge, pAlias);
        }
예제 #8
0
        public void Member()
        {
            var obj = new CreateFabMember();

            obj.DefinedByAppId  = (long)SetupAppId.Bookmarker;
            obj.DefinedByUserId = (long)SetupUserId.FabData;
            obj.Type            = (byte)MemberType.Id.Invite;

            BrowserResponse br     = PostCreate("mod/members", obj);
            FabMember       result = AssertFabResponseData <FabMember>(br);

            Assert.AreEqual(obj.Type, result.Type, "Incorrect result.");

            NewVertexCount = 1;
            NewEdgeCount   = 4;
        }
예제 #9
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public Member AddMember(IOperationContext pOpCtx, CreateMemberOperation pOper,
                                long pAppId, long pUserId)
        {
            var m = new CreateFabMember();

            m.DefinedByAppId  = pAppId;
            m.DefinedByUserId = pUserId;
            m.Type            = (byte)MemberType.Id.Member;

            pOpCtx.Auth.SetFabricActiveMember();
            Member newMem = pOper.Execute(
                pOpCtx, new CreateOperationBuilder(), new CreateOperationTasks(), m);

            pOpCtx.Auth.RemoveFabricActiveMember();
            return(newMem);
        }
예제 #10
0
        public void MemberAfterSessionStart()
        {
            var cre = new CreateFabMember();

            cre.DefinedByAppId  = 123461235;
            cre.DefinedByUserId = 34623463;

            ICreateOperationBuilder build = vMockBuild.Object;

            vMockTasks.Setup(x => x.FindDuplicateMember(
                                 build, cre.DefinedByUserId, cre.DefinedByAppId));

            CreateOperationsCustom.MemberAfterSessionStart(vMockTasks.Object, build, null, cre);

            vMockTasks.Verify(x => x.FindDuplicateMember(
                                  build, cre.DefinedByUserId, cre.DefinedByAppId), Times.Once);
        }
예제 #11
0
 ////////////////////////////////////////////////////////////////////////////////////////////////
 /*--------------------------------------------------------------------------------------------*/
 public static void MemberAfterSessionStart(CreateOperationTasks pTasks,
                                            ICreateOperationBuilder pBuild, Member pNewDom, CreateFabMember pNewCre)
 {
     pTasks.FindDuplicateMember(pBuild, pNewCre.DefinedByUserId, pNewCre.DefinedByAppId);
 }
예제 #12
0
 /*--------------------------------------------------------------------------------------------*/
 public FabResponse <FabMember> Post(CreateFabMember Data, SessionType UseSessionType = SessionType.Default)
 {
     return(Request(Data).Send(vContext, UseSessionType));
 }
예제 #13
0
 ////////////////////////////////////////////////////////////////////////////////////////////////
 /*--------------------------------------------------------------------------------------------*/
 public CreateFabMemberValidator(CreateFabMember pCreateObj) : base(pCreateObj)
 {
     vCreateObj = pCreateObj;
 }
        /*--------------------------------------------------------------------------------------------*/
        private Result ExecuteSession()
        {
            long userId  = vOpCtx.GetSharpflakeId <Vertex>();
            long memId   = vOpCtx.GetSharpflakeId <Vertex>();
            long emailId = vOpCtx.GetSharpflakeId <Vertex>();

            var userCre = new CreateFabUser();

            userCre.Name              = vUsername;
            userCre.Password          = vPassword;
            userCre.CreatedByMemberId = memId;

            var memCre = new CreateFabMember();

            memCre.Type            = (byte)MemberType.Id.Member;
            memCre.DefinedByAppId  = (long)SetupAppId.FabSys;
            memCre.DefinedByUserId = userId;

            var emailCre = new CreateFabEmail();

            emailCre.Address          = vEmail;
            emailCre.Code             = vOpCtx.Code32;
            emailCre.UsedByArtifactId = userId;

            ////

            var userOp = new CreateUserOperation();

            userOp.SetExecuteData(vOpCtx, vBuild, vTasks, userCre, userId, vDataAcc, false);

            var memOp = new CreateMemberOperation();

            memOp.SetExecuteData(vOpCtx, vBuild, vTasks, memCre, memId, vDataAcc, false);

            var emailOp = new CreateEmailOperation();

            emailOp.SetExecuteData(vOpCtx, vBuild, vTasks, emailCre, emailId, vDataAcc, false);

            ////

            vBuild.StartSession();
            userOp.CheckAndAddVertex();
            memOp.CheckAndAddVertex();
            emailOp.CheckAndAddVertex();
            userOp.AddEdges();
            memOp.AddEdges();
            emailOp.AddEdges();
            vBuild.CommitAndCloseSession();

            ////

            IDataResult res = vDataAcc.Execute(GetType().Name);

            vBuild.PerformChecks(res);

            int userCmdI  = res.GetCommandIndexByCmdId(userOp.AddVertexCommandId);
            int memCmdI   = res.GetCommandIndexByCmdId(memOp.AddVertexCommandId);
            int emailCmdI = res.GetCommandIndexByCmdId(emailOp.AddVertexCommandId);

            return(new Result {
                Status = ResultStatus.Success,
                NewUser = res.ToElementAt <User>(userCmdI, 0),
                NewMember = res.ToElementAt <Member>(memCmdI, 0),
                NewEmail = res.ToElementAt <Email>(emailCmdI, 0)
            });
        }