コード例 #1
0
 public void ParseFriendshipInvitations(GetStateResponse response, IUserDatabase userDatabase, IInternalLocalUser localUser, out IList <IInternalIncomingFriendInvitation> incomingFriendInvitations, out IList <IInternalOutgoingFriendInvitation> outgoingFriendInvitations)
 {
     incomingFriendInvitations = new List <IInternalIncomingFriendInvitation>();
     outgoingFriendInvitations = new List <IInternalOutgoingFriendInvitation>();
     if (response.FriendshipInvitations != null)
     {
         foreach (FriendshipInvitation invitation in response.FriendshipInvitations)
         {
             List <User>       users     = response.Users;
             Func <User, bool> predicate = (User user) => user.DisplayName == invitation.FriendDisplayName;
             string            firstName = users.FirstOrDefault(predicate)?.FirstName;
             if (invitation.IsInviter.Value)
             {
                 IInternalUnidentifiedUser invitee = RemoteUserFactory.CreateUnidentifiedUser(invitation.FriendDisplayName, firstName, userDatabase);
                 OutgoingFriendInvitation  outgoingFriendInvitation = new OutgoingFriendInvitation(localUser, invitee, invitation.IsTrusted.Value);
                 outgoingFriendInvitation.SendComplete(invitation.FriendshipInvitationId.Value);
                 outgoingFriendInvitations.Add(outgoingFriendInvitation);
             }
             else
             {
                 IInternalUnidentifiedUser inviter = RemoteUserFactory.CreateUnidentifiedUser(invitation.FriendDisplayName, firstName, userDatabase);
                 IncomingFriendInvitation  incomingFriendInvitation = new IncomingFriendInvitation(inviter, localUser, invitation.IsTrusted.Value);
                 incomingFriendInvitation.SendComplete(invitation.FriendshipInvitationId.Value);
                 incomingFriendInvitations.Add(incomingFriendInvitation);
             }
         }
     }
 }
コード例 #2
0
        private static void HandleAlertAdded(IInternalLocalUser localUser, IUserDatabase userDatabase, AbstractAddAlertNotificationEventArgs e)
        {
            Alert alert = new Alert(e.Notification.Alert);

            userDatabase.AddAlert(alert);
            localUser.DispatchOnAlertsAdded(alert);
        }
コード例 #3
0
        //author: Michael Kath (n9293833)
        public FindViewModel(IDialogService dialog, IUserDatabase locationsDatabase, string currentUser)
        {
            this.dialog        = dialog;
            this.currentUser   = currentUser;
            User               = new ObservableCollection <Employees>();
            this.UsersDatabase = locationsDatabase;

            ListOutStandingReq = new ObservableCollection <AddRequest>();
            RetrieveRequests();
            RetrieveEmployees();



            SelectLocationCommand = new MvxCommand <Employees>(selectedLocation =>
            {
                SelectUserFromSearch(selectedLocation, dialog);
                SearchTerm = string.Empty;
                RaisePropertyChanged(() => SearchTerm);
            });

            // if a request item on the list is pressed (USED FOR TESTING ATM)
            SelectReqCommand = new  MvxCommand <AddRequest> (req =>
            {
                UsersDatabase.DeleteRequest(req.UserNameReq, currentUser);
                RetrieveRequests();
            });
        }
コード例 #4
0
    private static void HandleFriendshipInvitationRemoved(IUserDatabase userDatabase, IInternalLocalUser localUser, AbstractRemoveFriendshipInvitationNotificationEventArgs e)
    {
        long value = e.Notification.InvitationId.Value;

        userDatabase.DeleteFriendInvitation(value);
        localUser.RemoveFriendshipInvitation(value);
    }
コード例 #5
0
        public CollectionViewModel(
            INotificationCenter notification,
            IUserDatabase userDatabase,
            ICardDatabase cardDatabase,
            IApplicationSettings applicationSettings)
        {
            _notification        = notification;
            _userDatabase        = userDatabase;
            _cardDatabase        = cardDatabase;
            _applicationSettings = applicationSettings;
            Collections          = _userDatabase
                                   .GetAllCollections()
                                   .Select(c => new SingleCollectionViewModell(notification, _userDatabase, _cardDatabase, c));

            ISingleCollectionViewModel loadedCollection = null;

            Task.Factory.StartNew(() =>
            {
                var currentCollectionName = _applicationSettings.GetCurrentCollection();
                var found        = Collections.FirstOrDefault(c => c.CollectionName == currentCollectionName);
                loadedCollection = LoadCollection(found);
            }).ContinueWith((task) =>
            {
                SelectedCollection = loadedCollection;
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
コード例 #6
0
        async void ExecuteSaveUser()
        {
            userDatabase = new UserDatabase();

            if (UserInformation.Password != UserInformation.ConfirmPassword)
            {
                try
                {
                    await _pageDialog.DisplayAlertAsync("Hey There", "Passwords dont match", "Okay");
                }
                catch (Exception ex)
                {
                    await _pageDialog.DisplayAlertAsync($"Hey {UserInformation.Name}", ex.Message, "Ok");
                }

                UserInformation = new UserInformation();
            }
            else
            {
                var navParameters = new NavigationParameters();
                navParameters.Add("user", UserInformation);
                await userDatabase.SaveUser(UserInformation);

                await _pageDialog.DisplayAlertAsync($"Hey {UserInformation.Name}", "You have successfully signed up", "Ok");

                await NavigationService.NavigateAsync("LoginPage", navParameters);
            }
        }
コード例 #7
0
        public Login(IUserDatabase userDatabase)
        {
            Get["/login"] = x =>
            {
                return(View["login"]);
            };

            Post["/login"] = parameters =>
            {
                var userGuid = userDatabase.ValidateUser((string)this.Request.Form.Password);

                if (userGuid == null)
                {
                    return(Response.AsRedirect("/"));
                }

                DateTime?expiry = null;

                return(this.LoginAndRedirect(userGuid.Value, expiry));
            };

            Get["/logout"] = x =>
            {
                return(this.LogoutAndRedirect("~/"));
            };
        }
コード例 #8
0
 public LocalUser(AbstractLogger logger, IDisplayName displayName, string swid, IList <IInternalFriend> friends, AgeBandType ageBandType, IDatabase database, IUserDatabase userDatabase, IInternalRegistrationProfile registrationProfile, IMixWebCallFactory mixWebCallFactory, IGuestControllerClient guestControllerClient, INotificationQueue notificationQueue, IEncryptor encryptor, IEpochTime epochTime)
 {
     DisplayName = displayName;
     FirstName   = registrationProfile.FirstName;
     Swid        = swid;
     Id          = swid;
     this.logger = logger;
     this.registrationProfile   = registrationProfile;
     this.mixWebCallFactory     = mixWebCallFactory;
     this.friends               = friends;
     this.ageBandType           = ageBandType;
     this.database              = database;
     this.userDatabase          = userDatabase;
     incomingFriendInvitations  = new List <IInternalIncomingFriendInvitation>();
     outgoingFriendInvitations  = new List <IInternalOutgoingFriendInvitation>();
     oldInvitationIds           = new List <long>();
     unidentifiedUsers          = new List <IInternalUnidentifiedUser>();
     this.guestControllerClient = guestControllerClient;
     this.notificationQueue     = notificationQueue;
     this.encryptor             = encryptor;
     this.epochTime             = epochTime;
     guestControllerClient.OnLegalMarketingUpdateRequired += delegate(object sender, AbstractLegalMarketingUpdateRequiredEventArgs e)
     {
         this.OnLegalMarketingUpdateRequired(this, e);
     };
 }
コード例 #9
0
 public Session(AbstractLogger logger, IInternalLocalUser localUser, string guestControllerAccessToken, bool pushNotificationsEnabled, INotificationPoller notificationPoller, ICoroutineManager coroutineManager, IDatabase database, IUserDatabase userDatabase, IGuestControllerClient guestControllerClient, IMixWebCallFactory mixWebCallFactory, IEpochTime epochTime, DatabaseCorruptionHandler databaseCorruptionHandler, ISessionStatus sessionStatus, IKeychain keychain, IGetStateResponseParser getStateResponseParser, string clientVersion, INotificationQueue notificationQueue)
 {
     this.logger                                     = logger;
     this.localUser                                  = localUser;
     this.notificationPoller                         = notificationPoller;
     this.coroutineManager                           = coroutineManager;
     this.database                                   = database;
     this.userDatabase                               = userDatabase;
     this.guestControllerClient                      = guestControllerClient;
     this.mixWebCallFactory                          = mixWebCallFactory;
     this.epochTime                                  = epochTime;
     this.databaseCorruptionHandler                  = databaseCorruptionHandler;
     this.sessionStatus                              = sessionStatus;
     this.keychain                                   = keychain;
     this.getStateResponseParser                     = getStateResponseParser;
     this.clientVersion                              = clientVersion;
     this.notificationQueue                          = notificationQueue;
     GuestControllerAccessToken                      = guestControllerAccessToken;
     guestControllerClient.OnAccessTokenChanged     += HandleGuestControllerAccessTokenChanged;
     guestControllerClient.OnAuthenticationLost     += HandleAuthenticationLost;
     mixWebCallFactory.OnAuthenticationLost         += HandleAuthenticationLost;
     localUser.OnPushNotificationsToggled           += HandlePushNotificationsToggled;
     localUser.OnPushNotificationReceived           += HandlePushNotificationReceived;
     localUser.OnDisplayNameUpdated                 += HandleDisplayNameUpdated;
     databaseCorruptionHandler.OnCorruptionDetected += HandleCorruptionDetected;
     updateEnumerator                                = Update();
     coroutineManager.Start(updateEnumerator);
     notificationPoller.OnNotificationsPolled += HandleNotificationsPolled;
     notificationPoller.UsePollIntervals       = !pushNotificationsEnabled;
     this.sessionStatus.IsPaused = true;
     notificationPoller.OnSynchronizationError += HandleNotificationPollerSynchronizationError;
 }
コード例 #10
0
ファイル: Login.cs プロジェクト: uzigula/Nancy.Demo.Samples
        public Login(IUserDatabase userDatabase)
        {

            Get["/login"] = x =>
            {
                return View["login"];
            };

            Post["/login"] = parameters =>
            {
                var userGuid = userDatabase.ValidateUser((string)this.Request.Form.Password);

                if (userGuid == null)
                {
                    return Response.AsRedirect("/");
                }

                DateTime? expiry = null;

                return this.LoginAndRedirect(userGuid.Value, expiry);
            };

            Get["/logout"] = x =>
            {
                return this.LogoutAndRedirect("~/");
            };
        }
コード例 #11
0
 public static void Handle(INotificationDispatcher dispatcher, IUserDatabase userDatabase, IInternalLocalUser localUser, IEpochTime epochTime)
 {
     dispatcher.OnAlertAdded += delegate(object sender, AbstractAddAlertNotificationEventArgs e)
     {
         HandleAlertAdded(localUser, userDatabase, e);
     };
     dispatcher.OnAlertCleared += delegate(object sender, AbstractClearAlertNotificationEventArgs e)
     {
         HandleAlertCleared(localUser, userDatabase, e);
     };
     dispatcher.OnFriendshipRemoved += delegate(object sender, AbstractRemoveFriendshipNotificationEventArgs e)
     {
         HandleFriendshipRemoved(userDatabase, localUser, e);
     };
     dispatcher.OnFriendshipTrustRemoved += delegate(object sender, AbstractRemoveFriendshipTrustNotificationEventArgs e)
     {
         HandleFriendshipTrustRemoved(userDatabase, localUser, e);
     };
     dispatcher.OnFriendshipInvitationAdded += delegate(object sender, AbstractAddFriendshipInvitationNotificationEventArgs e)
     {
         HandleFriendshipInvitationAdded(userDatabase, localUser, e);
     };
     dispatcher.OnFriendshipInvitationRemoved += delegate(object sender, AbstractRemoveFriendshipInvitationNotificationEventArgs e)
     {
         HandleFriendshipInvitationRemoved(userDatabase, localUser, e);
     };
     dispatcher.OnFriendshipAdded += delegate(object sender, AbstractAddFriendshipNotificationEventArgs e)
     {
         HandleFriendshipAdded(userDatabase, localUser, e);
     };
 }
コード例 #12
0
    public IList <IInternalFriend> ParseFriendships(GetStateResponse response, IUserDatabase userDatabase)
    {
        List <IInternalFriend> list  = new List <IInternalFriend>();
        List <User>            users = response.Users;

        if (response.Friendships != null)
        {
            foreach (Friendship friendship in response.Friendships)
            {
                string userId          = friendship.FriendUserId;
                bool   value           = friendship.IsTrusted.Value;
                string displayNameText = string.Empty;
                string firstName       = string.Empty;
                if (users != null)
                {
                    User user = users.FirstOrDefault((User u) => u.UserId == userId);
                    if (user != null)
                    {
                        displayNameText = user.DisplayName;
                        firstName       = user.FirstName;
                    }
                }
                IInternalFriend item = RemoteUserFactory.CreateFriend(userId, value, displayNameText, firstName, userDatabase);
                list.Add(item);
            }
        }
        return(list);
    }
コード例 #13
0
    private static void HandleFriendshipTrustRemoved(IUserDatabase userDatabase, IInternalLocalUser localUser, AbstractRemoveFriendshipTrustNotificationEventArgs e)
    {
        string friendUserId = e.Notification.FriendUserId;

        userDatabase.SetFriendIsTrusted(friendUserId, isTrusted: false);
        localUser.UntrustFriend(e.Notification.FriendUserId);
    }
コード例 #14
0
        public static void PubliserLeveranse(string id, NinRavenDb arkiv, IUserDatabase userDb)
        {
            Log.i("DDL", "Publiser dataleveranse #" + id);

            var dataDelivery = arkiv.HentDataleveranse(id);

            switch (dataDelivery.Publisering)
            {
            case Status.Gjeldende:
                throw new Exception("Leveransen er allerede gjeldende.");

            case Status.Utgått:
                throw new Exception("Leveransen er utgått og kan ikke publiseres.");
            }

            var dataDeliveryMsSql = new Dataleveranse(dataDelivery);

            MapProjection.ConvertGeometry(dataDeliveryMsSql);

            var userInstitution = userDb.GetUserInstitution(dataDelivery.Username);

            foreach (var natureArea in dataDeliveryMsSql.Metadata.NatureAreas)
            {
                natureArea.Institution = userInstitution;
            }

            SqlServer.DeleteDataDelivery(dataDeliveryMsSql.Metadata.UniqueId.LocalId);
            SqlServer.LagreDataleveranse(dataDeliveryMsSql);

            MarkerSistGjeldendeLeveranseSomUtgått(arkiv, dataDelivery);

            dataDelivery.Publisering = Status.Gjeldende;
            arkiv.LagreDataleveranse(dataDelivery);
            arkiv.SaveChanges();
        }
コード例 #15
0
ファイル: Friend.cs プロジェクト: smdx24/CPI-Source-Code
 public Friend(string swid, bool isTrusted, IDisplayName displayName, string firstName, IUserDatabase userDatabase)
 {
     this.userDatabase = userDatabase;
     Swid        = swid;
     IsTrusted   = isTrusted;
     DisplayName = displayName;
     FirstName   = firstName;
 }
コード例 #16
0
 private static IList <IInternalFriend> CreateFriends(IUserDatabase userDatabase)
 {
     return(userDatabase.GetAllFriendDocuments().Select(delegate(FriendDocument friendDoc)
     {
         UserDocument userBySwid = userDatabase.GetUserBySwid(friendDoc.Swid);
         return RemoteUserFactory.CreateFriend(friendDoc.Swid, friendDoc.IsTrusted, userBySwid.DisplayName, userBySwid.FirstName, userDatabase);
     }).ToList());
 }
コード例 #17
0
 private void CreateUser(IUserDatabase userDatabase, int userId, string userName, string userPass)
 {
     userDatabase.Create(new User()
     {
         UserId   = userId,
         UserName = userName,
         UserPass = userPass
     });
 }
コード例 #18
0
        public Login(IUserDatabase userDatabase)
        {
            Get["/login"] = x =>
            {
                return(View["login"]);
            };

            Get["/login/{token}"] = x =>
            {
                var userGuid =
                    new Guid((string)x.token);

                var redirectUrl = (Request.Query.returnUrl.HasValue) ?
                                  (string)Request.Query.returnUrl :
                                  "/";

                return(this.LoginAndRedirect(userGuid, DateTime.MaxValue, redirectUrl));
            };

            Post["login/send"] = x =>
            {
                var emailAdress =
                    Request.Form.email;

                if (emailAdress.HasValue)
                {
                    var identifier =
                        userDatabase.GetIdentifier(emailAdress).ToString();

                    var loginUrl =
                        Request.Url.Clone();

                    loginUrl.Path =
                        string.Concat("/login", "/", identifier.ToString());

                    var template =
                        string.Format("Dear [Your Service] user, click <a href=\'{0}\'>here to login</a>", loginUrl);

                    var email = Email
                                .From("*****@*****.**")
                                .To(emailAdress)
                                .Subject("Your [Your Service] login")
                                .Body(template);

                    email.Send();
                }

                return(Response.AsRedirect("/"));
            };

            Get["/logout"] = x =>
            {
                return(this.LogoutAndRedirect("~/"));
            };
        }
コード例 #19
0
 public LoginAuthenticator(Mode mode)
 {
     if (mode == Mode.Production)
     {
         database = Databases.productionDatabase;
     }
     else if (mode == Mode.Test)
     {
         database = Databases.testDatabase;
     }
 }
コード例 #20
0
 private static void HandleAlertCleared(IInternalLocalUser localUser, IUserDatabase userDatabase, AbstractClearAlertNotificationEventArgs e)
 {
     IInternalAlert[] array = (from a in userDatabase.GetAlerts()
                               where e.Notification.AlertIds.Contains(a.AlertId)
                               select a).ToArray();
     IInternalAlert[] array2 = array;
     foreach (IInternalAlert internalAlert in array2)
     {
         userDatabase.RemoveAlert(internalAlert.AlertId);
     }
     localUser.DispatchOnAlertsCleared(array);
 }
コード例 #21
0
        public SingleCollectionViewModell(
            INotificationCenter notification,
            IUserDatabase userDatabase,
            ICardDatabase cardDatabase,
            MagicCollection databaseCollection)
        {
            _userDatabase       = userDatabase;
            _notification       = notification;
            _cardDatabase       = cardDatabase;
            _databaseCollection = databaseCollection;

            CollectionName = _databaseCollection != null ? _databaseCollection.Name : "";
        }
コード例 #22
0
 public AlchemyWebSocketServer(int port, IPAddress ipAddress, TimeSpan timeout, IUserDatabase userDatabase)
     : base(userDatabase)
 {
     server = new WebSocketServer(port, ipAddress)
                  {
                      TimeOut = timeout,
                      FlashAccessPolicyEnabled = true,
                      OnConnected = OnConnected,
                      OnDisconnect = OnDisconnect,
                      OnReceive = OnReceive,
                      OnSend = OnSend
                  };
 }
コード例 #23
0
        public XmlTaskDatabase(IUserDatabase userDatabase, string filename)
        {
            mUserDatabase = userDatabase;
            mFilename     = filename;

            if (File.Exists(mFilename))
            {
                using (FileStream input = File.OpenRead(mFilename))
                {
                    mTasks = (List <XmlTask>)mSerializer.Deserialize(input);
                }
            }
        }
コード例 #24
0
        public ResponseViewModel(IDialogService dialog, IUserDatabase locationsDatabase, string currentUser)
        {
            this.dialog        = dialog;
            this.currentUser   = currentUser;
            this.UsersDatabase = locationsDatabase;

            ListReceivedReq = new ObservableCollection <ReceivedRequest>();

            RetrieveRequests();
            //dialog messages. Stil yet to be implemented properly
            this.dialog = dialog;
            //database to use azureDB functions
            UsersDatabase = locationsDatabase;
        }
コード例 #25
0
 private void ExecuteCommon(IUserDatabase userDatabase, IPasswordService passwordService)
 {
     userDatabase.DeleteAll();
     CreateUser(userDatabase, 1, "*****@*****.**", String.Empty);
     CreateUser(userDatabase, 2, "*****@*****.**", String.Empty);
     CreateUser(userDatabase, 3, "*****@*****.**", String.Empty);
     CreateUser(userDatabase, 4, "*****@*****.**", String.Empty);
     CreateUser(userDatabase, 5, "*****@*****.**", String.Empty);
     CreateUser(userDatabase, 6, "*****@*****.**", String.Empty);
     CreateUser(userDatabase, 7, "*****@*****.**", String.Empty);
     CreateUser(userDatabase, 8, "*****@*****.**", String.Empty);
     CreateUser(userDatabase, 9, "*****@*****.**", String.Empty);
     passwordService.Save(1, "kdI6%jVbgh(9lkjH7eK(tJ^Knghu#");
     passwordService.Save(2, "password123");
     passwordService.Save(3, "password");
     passwordService.Save(4, "MeowMeowKitty");
     passwordService.Save(5, "aaa");
     passwordService.Save(6, "password");
     passwordService.Save(7, "1234");
     passwordService.Save(8, "password");
     passwordService.Save(9, "Butterscotch");
     Assert.True(passwordService.Verify(1, "kdI6%jVbgh(9lkjH7eK(tJ^Knghu#"));
     Assert.True(passwordService.Verify(2, "password123"));
     Assert.True(passwordService.Verify(3, "password"));
     Assert.True(passwordService.Verify(4, "MeowMeowKitty"));
     Assert.True(passwordService.Verify(5, "aaa"));
     Assert.True(passwordService.Verify(6, "password"));
     Assert.True(passwordService.Verify(7, "1234"));
     Assert.True(passwordService.Verify(8, "password"));
     Assert.True(passwordService.Verify(9, "Butterscotch"));
     Assert.False(passwordService.Verify(1, "BadPassword"));
     Assert.False(passwordService.Verify(2, "BadPassword"));
     Assert.False(passwordService.Verify(3, "BadPassword"));
     Assert.False(passwordService.Verify(4, "BadPassword"));
     Assert.False(passwordService.Verify(5, "BadPassword"));
     Assert.False(passwordService.Verify(6, "BadPassword"));
     Assert.False(passwordService.Verify(7, "BadPassword"));
     Assert.False(passwordService.Verify(8, "BadPassword"));
     Assert.False(passwordService.Verify(9, "BadPassword"));
     Assert.True(passwordService.Verify(3, "password"));
     passwordService.Save(3, "NewPassword");
     Assert.False(passwordService.Verify(3, "password"));
     Assert.True(passwordService.Verify(3, "NewPassword"));
     passwordService.Save(3, "password");
     Assert.False(passwordService.Verify(3, "NewPassword"));
     Assert.True(passwordService.Verify(3, "password"));
 }
コード例 #26
0
        public XmlTaskDatabase(IUserDatabase userdatabase, string filename)
        {
            mUserDatabase = (XmlUserDatabase)userdatabase;
            mFilename     = filename;

            if (File.Exists(mFilename))
            {
                using (FileStream input = File.OpenRead(mFilename))
                {
                    mTasks = (List <XmlTask>)mSerializer.Deserialize(input);
                    foreach (XmlTask xml in mTasks)
                    {
                        xml.AssignedTo = mUserDatabase.GetUser(xml.AssignedToUserName);
                    }
                }
            }
        }
コード例 #27
0
    private static void HandleFriendshipRemoved(IUserDatabase userDatabase, IInternalLocalUser localUser, AbstractRemoveFriendshipNotificationEventArgs e)
    {
        string          swid           = e.Notification.FriendUserId;
        string          displayName    = null;
        IInternalFriend internalFriend = localUser.InternalFriends.FirstOrDefault((IInternalFriend f) => f.Swid == swid);

        if (internalFriend != null)
        {
            displayName = internalFriend.DisplayName.Text;
        }
        else
        {
            UserDocument userBySwid = userDatabase.GetUserBySwid(swid);
            if (userBySwid != null)
            {
                displayName = userBySwid.DisplayName;
            }
        }
        userDatabase.DeleteFriend(swid);
        localUser.RemoveFriend(swid, sendEvent: true);
        if (displayName != null)
        {
            FriendInvitationDocument incomingInvitation = userDatabase.GetFriendInvitationDocuments(isInviter: false).FirstOrDefault((FriendInvitationDocument doc) => doc.DisplayName == displayName);
            if (incomingInvitation != null)
            {
                foreach (IInternalIncomingFriendInvitation item in from i in localUser.InternalIncomingFriendInvitations
                         where i.InvitationId == incomingInvitation.FriendInvitationId
                         select i)
                {
                    localUser.RemoveIncomingFriendInvitation(item);
                }
                userDatabase.DeleteFriendInvitation(incomingInvitation.FriendInvitationId);
            }
            FriendInvitationDocument outgoingInvitation = userDatabase.GetFriendInvitationDocuments(isInviter: true).FirstOrDefault((FriendInvitationDocument doc) => doc.DisplayName == displayName);
            if (outgoingInvitation != null)
            {
                foreach (IInternalOutgoingFriendInvitation item2 in from i in localUser.InternalOutgoingFriendInvitations
                         where i.InvitationId == outgoingInvitation.FriendInvitationId
                         select i)
                {
                    localUser.RemoveOutgoingFriendInvitation(item2);
                }
                userDatabase.DeleteFriendInvitation(outgoingInvitation.FriendInvitationId);
            }
        }
    }
コード例 #28
0
    private static void HandleFriendshipInvitationAdded(IUserDatabase userDatabase, IInternalLocalUser localUser, AbstractAddFriendshipInvitationNotificationEventArgs e)
    {
        AddFriendshipInvitationNotification notification = e.Notification;
        FriendshipInvitation invitation = notification.Invitation;
        User friend = notification.Friend;

        userDatabase.PersistUser(null, null, invitation.FriendDisplayName, friend.FirstName, friend.Status);
        FriendInvitationDocument friendInvitationDocument = new FriendInvitationDocument();

        friendInvitationDocument.FriendInvitationId = invitation.FriendshipInvitationId.Value;
        friendInvitationDocument.IsInviter          = invitation.IsInviter.Value;
        friendInvitationDocument.IsTrusted          = invitation.IsTrusted.Value;
        friendInvitationDocument.DisplayName        = invitation.FriendDisplayName;
        FriendInvitationDocument doc = friendInvitationDocument;

        userDatabase.InsertOrUpdateFriendInvitation(doc);
        localUser.AddFriendshipInvitation(invitation, friend);
    }
コード例 #29
0
    private static void HandleFriendshipAdded(IUserDatabase userDatabase, IInternalLocalUser localUser, AbstractAddFriendshipNotificationEventArgs e)
    {
        AddFriendshipNotification notification = e.Notification;
        User friend = notification.Friend;

        userDatabase.PersistUser(friend.UserId, friend.HashedUserId, friend.DisplayName, friend.FirstName, friend.Status);
        FriendDocument friendDocument = new FriendDocument();

        friendDocument.Swid      = friend.UserId;
        friendDocument.IsTrusted = notification.IsTrusted.Value;
        friendDocument.Nickname  = null;
        FriendDocument doc = friendDocument;

        userDatabase.InsertFriend(doc);
        long value = e.Notification.FriendshipInvitationId.Value;

        userDatabase.DeleteFriendInvitation(value);
        localUser.AddFriend(friend, notification.IsTrusted.Value, value);
    }
コード例 #30
0
        public XmlGroupDatabase(string filename, IUserDatabase UserDb)
        {
            mUserDatabase = (XmlUserDatabase)UserDb;
            mFilename     = filename;

            if (File.Exists(mFilename))
            {
                using (FileStream input = File.OpenRead(mFilename))
                {
                    Groups = (List <XmlGroup>)mSerializer.Deserialize(input);
                    foreach (XmlGroup xml in Groups)
                    {
                        foreach (var kvp in xml.MemberNames)
                        {
                            xml.Members.Add(mUserDatabase.GetUser(kvp.user), kvp.rank);
                        }
                    }
                }
            }
        }
コード例 #31
0
ファイル: Home.cs プロジェクト: grumpydev/Nancy.Demo.Samples
        public Home(IUserDatabase userDatabase)
        {
            Get["/"] = parameters =>
                           {

                               var user = Context.CurrentUser;
                return View["index"];
            };

            Get["/about"] = parameters => {
                return View["about"];
            };

            Get["/login"] = x =>
            {
                return View["login"];
            };

            Post["/login"] = parameters => {
                var userGuid = userDatabase.ValidateUser((string)this.Request.Form.Password);

                if (userGuid == null)
                {
                    //return this.Context.GetRedirect("~/login?error=true&username="******"/");
                }

                DateTime? expiry = null;
                //if (this.Request.Form.RememberMe.HasValue)
                //{
                //    expiry = DateTime.Now.AddDays(7);
                //}

                return this.LoginAndRedirect(userGuid.Value, expiry);
            };

            Get["/logout"] = x => {
                return this.LogoutAndRedirect("~/");
            };
        }
コード例 #32
0
        public RequestsViewModel(IDialogService dialog, IUserDatabase locationsDatabase, string currentUser)
        {
            this.dialog        = dialog;
            this.currentUser   = currentUser;
            this.UsersDatabase = locationsDatabase;

            ListReceivedReq = new ObservableCollection <ReceivedRequest>();

            RetrieveRequests();
            //dialog messages. Stil yet to be implemented properly
            this.dialog = dialog;
            //database to use azureDB functions
            UsersDatabase = locationsDatabase;


            SelectAll = new MvxCommand(() =>
            {
                _isChecked = !_isChecked;

                RaisePropertyChanged(() => _isChecked);
                IsChecked = _isChecked;
                RaisePropertyChanged(() => IsChecked);
            });
        }
コード例 #33
0
        async void ExecuteToMainPage()
        {
            userDatabase = new UserDatabase();
            var users = await userDatabase.GetUsers();

            var user = await userDatabase.GetUserByEmail(Login.Email);


            if (user != null)
            {
                var logInfo = new { Email = user.Email, Password = user.Password };

                var json    = JsonConvert.SerializeObject(logInfo);
                var uri     = "http://10.0.2.2:5000/UserLoginDetails";
                var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");
                var http    = new HttpClient();
                await NavigationService.NavigateAsync("MainPage");

                var post = await http.PostAsync(uri, content);

                try
                {
                    await _pageDialog.DisplayAlertAsync("Hey There", post.ReasonPhrase, "Okay");
                }
                catch (Exception ex)
                {
                    await _pageDialog.DisplayAlertAsync("Hey There", ex.Message, "Ok");
                }
            }
            else
            {
                await _pageDialog.DisplayAlertAsync("Hey There", "Current User doesn't exist", "Ok");

                Login = new Login();
            }
        }
コード例 #34
0
 public GuidUserMapper(IUserDatabase userDatabase)
 {
     this.userDatabase = userDatabase;
 }
コード例 #35
0
 public FleckWebSocketServer(int port, string hostName, TimeSpan timeout, IUserDatabase userDatabase)
     : base(userDatabase)
 {
     FleckLog.Level = LogLevel.Debug;
     server = new WebSocketServer(string.Format("ws://{0}:{1}", hostName, port));
 }