Beispiel #1
0
        protected void btnPasswordUpdate_Click(object sender, EventArgs e)
        {
            if (txtConfirmPassword.Text == txtNewPassword.Text && !(txtConfirmPassword.Text == "" && "" == txtNewPassword.Text))
            {
                AccountConnection account = new AccountConnection();
                Qaelo.Models.ShopOwnerModel.ShopOwner s = (Qaelo.Models.ShopOwnerModel.ShopOwner)Session["SHOPOWNER"];

                //Test password

                if (account.correctShopOwner(s.Email, Secrecy.HashPassword(txtCurrentPassword.Text)) && new ShopConnection().updatePassword(s.Id, Secrecy.HashPassword(txtNewPassword.Text), Secrecy.HashPassword(txtCurrentPassword.Text)))
                {
                    lblSuccess.Text      = "Successfuly Updated Password";
                    lblErrorMessage.Text = "";
                }
                else
                {
                    lblErrorMessage.Text = "Incorrect Current Password";
                    lblSuccess.Text      = "";
                }
            }
            else
            {
                lblErrorMessage.Text = "New password and confirm Password Do not match ";
                lblSuccess.Text      = "";
            }
        }
Beispiel #2
0
        /// <summary>关联一切可以关联的信息,子类可在合适的时机调用此方法,目前包括TeamMember
        /// </summary>
        /// <param name="c"></param>
        protected void AssociateEverything(AccountConnection c)
        {
            if (c == null)
            {
                return;
            }
            var a     = this._accountService.GetAccount(c.AccountId);
            var email = this.ParseEmail(c);

            //HACK:根据email建立关联TeamMember和Account关联
            if (!string.IsNullOrWhiteSpace(email))
            {
                this._teamService.GetUnassociatedTeams(email).ToList().ForEach(o =>
                {
                    try { this._teamService.AssociateMemberAccount(o, o.GetMember(email), a); }
                    catch (Exception e)
                    {
                        this._log.Error(string.Format("为账号#{0}邮箱{1}与团队#{2}|{3}创建关联时异常"
                                                      , c.AccountId
                                                      , email
                                                      , o.ID
                                                      , o.Name)
                                        , e);
                    }
                });
            }
            //其他...
        }
Beispiel #3
0
        public bool ConnectCharacter(Guid worldId, long characterId)
        {
            try
            {
                if (!MSManager.Instance.AuthentificatedClients.Any(s => s.Equals(CurrentClient.ClientId)))
                {
                    return(false);
                }

                //Multiple WorldGroups not yet supported by DAOFactory
                long accountId = DAOFactory.CharacterDAO.LoadById(characterId)?.AccountId ?? 0;

                AccountConnection account = MSManager.Instance.ConnectedAccounts.Find(a => a.AccountId.Equals(accountId) && a.ConnectedWorld.Id.Equals(worldId));
                if (account != null)
                {
                    account.CharacterId = characterId;
                    foreach (WorldServer world in MSManager.Instance.WorldServers?.Where(w => w.WorldGroup.Equals(account.ConnectedWorld?.WorldGroup)))
                    {
                        world.CommunicationServiceClient.GetClientProxy <ICommunicationClient>().CharacterConnected(characterId);
                    }
                    return(true);
                }
                return(false);
            }
            catch
            {
                return(false);
            }
        }
Beispiel #4
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            if (txtConfirmPassword.Text == txtNewPassword.Text && !(txtConfirmPassword.Text == "" && "" == txtNewPassword.Text))
            {
                AccountConnection account = new AccountConnection();

                Manager s = (Manager)(Session["PROPERTYMANAGER"]);

                //Test password

                if (account.correctPropertyManager(s.email, Secrecy.HashPassword(txtCurrentPassword.Text)) && new ManagerConnection().updateManagerPassword(s.id, Secrecy.HashPassword(txtNewPassword.Text), Secrecy.HashPassword(txtCurrentPassword.Text)))
                {
                    lblSuccess.Text      = "Successfuly Updated Password";
                    lblErrorMessage.Text = "";
                }
                else
                {
                    lblErrorMessage.Text = "Incorrect Current Password";
                    lblSuccess.Text      = "";
                }
            }
            else
            {
                lblErrorMessage.Text = "New password and confirm Password Do not match ";
                lblSuccess.Text      = "";
            }
        }
        public bool ConnectCharacter(Guid worldId, long characterId)
        {
            if (!MSManager.Instance.AuthentificatedClients.Any(s => s.Equals(CurrentClient.ClientId)))
            {
                return(false);
            }

            //Multiple WorldGroups not yet supported by DAOFactory
            long accountId = DAOFactory.CharacterDAO.LoadById(characterId)?.AccountId ?? 0;

            AccountConnection account   = MSManager.Instance.ConnectedAccounts.Find(a => a.AccountId.Equals(accountId) && a.ConnectedWorld.Id.Equals(worldId));
            CharacterDTO      character = DAOFactory.CharacterDAO.LoadById(characterId);

            if (account != null || character != null)
            {
                try
                {
                    account.CharacterId = characterId;
                    foreach (WorldServer world in MSManager.Instance.WorldServers.Where(w => w.WorldGroup.Equals(account.ConnectedWorld.WorldGroup)))
                    {
                        world.CommunicationServiceClient.GetClientProxy <ICommunicationClient>().CharacterConnected(characterId);
                    }
                    return(true);
                }
                catch (ObjectDisposedException ex)
                {
                    Logger.LogEventError("NOT_DISPOSED_OBJECT_EXCEPTION", "Error while disposing characters:", ex);
                }
            }
            return(false);
        }
        public void SendMail(MailDTO mail)
        {
            if (!MSManager.Instance.AuthentificatedClients.Any(s => s.Equals(CurrentClient.ClientId)))
            {
                return;
            }

            DAOFactory.MailDAO.InsertOrUpdate(ref mail);

            if (mail.IsSenderCopy)
            {
                AccountConnection account = MSManager.Instance.ConnectedAccounts.Find(a => a.CharacterId.Equals(mail.SenderId));
                if (account?.ConnectedWorld != null)
                {
                    account.ConnectedWorld.MailServiceClient.GetClientProxy <IMailClient>().MailSent(mail);
                }
            }
            else
            {
                AccountConnection account = MSManager.Instance.ConnectedAccounts.Find(a => a.CharacterId.Equals(mail.ReceiverId));
                if (account?.ConnectedWorld != null)
                {
                    account.ConnectedWorld.MailServiceClient.GetClientProxy <IMailClient>().MailSent(mail);
                }
            }
        }
        public string RetrieveRegisteredWorldServers(long sessionId)
        {
            string            lastGroup  = string.Empty;
            byte              worldCount = 0;
            AccountConnection account    = MSManager.Instance.ConnectedAccounts.FirstOrDefault(s => s.SessionId == sessionId);

            if (account == null)
            {
                return(null);
            }
            string channelPacket = $"NsTeST {account.AccountName} {sessionId} ";

            foreach (WorldServer world in MSManager.Instance.WorldServers.OrderBy(w => w.WorldGroup))
            {
                if (lastGroup != world.WorldGroup)
                {
                    worldCount++;
                }
                lastGroup = world.WorldGroup;

                int currentlyConnectedAccounts = MSManager.Instance.ConnectedAccounts.Count(a => a.ConnectedWorld?.ChannelId == world.ChannelId);
                int channelcolor = (int)Math.Round((double)currentlyConnectedAccounts / world.AccountLimit * 20) + 1;

                channelPacket += $"{world.Endpoint.IpAddress}:{world.Endpoint.TcpPort}:{channelcolor}:{worldCount}.{world.ChannelId}.{world.WorldGroup} ";
            }
            channelPacket += "-1:-1:-1:10000.10000.1";
            return(MSManager.Instance.WorldServers.Any() ? channelPacket : null);
        }
        public ActionResult Login(LoginModel model)
        {
            string viewName = "Index";

            if (ModelState.IsValid)
            {
                // Check the user's credentials against the database
                AccountConnection accountConnection = new AccountConnection();
                SignInRequest     request           = new SignInRequest()
                {
                    Username = model.Username,
                    Password = model.Password
                };
                SignInResponse response = accountConnection.SignIn(request);
                if (response.UserId != -1)
                {
                    // Redirect the user to home and store the user id as a session variable. Helps for account tracking.
                    viewName            = "Home";
                    Session["UserId"]   = response.UserId;
                    Session["UserType"] = response.UserType;
                    Session["Username"] = model.Username;
                }
            }

            return(RedirectToAction(viewName));
        }
Beispiel #9
0
        public void SendStaticBonus(long characterId, MallStaticBonus item)
        {
            if (!MSManager.Instance.AuthentificatedClients.Any(s => s.Equals(CurrentClient.ClientId)))
            {
                return;
            }
            StaticBonusDTO dto = DAOFactory.StaticBonusDAO.LoadByCharacterId(characterId).FirstOrDefault(s => s.StaticBonusType == item.StaticBonus);

            if (dto != null)
            {
                dto.DateEnd.AddSeconds(item.Seconds);
            }
            else
            {
                dto = new StaticBonusDTO()
                {
                    CharacterId     = characterId,
                    DateEnd         = DateTime.Now.AddSeconds(item.Seconds),
                    StaticBonusType = item.StaticBonus
                };
            }

            DAOFactory.StaticBonusDAO.InsertOrUpdate(ref dto);
            AccountConnection account = MSManager.Instance.ConnectedAccounts.Find(a => a.CharacterId.Equals(characterId));

            if (account?.ConnectedWorld != null)
            {
                account.ConnectedWorld.CommunicationServiceClient.GetClientProxy <ICommunicationClient>().UpdateStaticBonus(characterId);
            }
        }
Beispiel #10
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            if (txtConfirmPassword.Text == txtNewPassword.Text)
            {
                AccountConnection account           = new AccountConnection();
                Qaelo.Models.SocietyModel.Society s = (Qaelo.Models.SocietyModel.Society)Session["SOCIETY"];

                //Test password

                if (account.correctSociety(s.Email, Secrecy.HashPassword(txtCurrentPassword.Text)) && account.updatePassword(s.Id, Secrecy.HashPassword(txtNewPassword.Text), Secrecy.HashPassword(txtCurrentPassword.Text)))
                {
                    lblSuccess.Text      = "Successfuly Updated Password";
                    lblErrorMessage.Text = "";
                }
                else
                {
                    lblErrorMessage.Text = "Incorrect Current Password";
                    lblSuccess.Text      = "";
                }
            }
            else
            {
                lblErrorMessage.Text = "New password and confirm Password Do not match ";
                lblSuccess.Text      = "";
            }
        }
        public ActionResult Signup()
        {
            SignupModel       model             = new SignupModel();
            AccountConnection accountConnection = new AccountConnection();

            model.UserTypes = accountConnection.GetUserTypes();
            return(View(model));
        }
    public async void ClickVerify()
    {
        _mHandler    = GameObject.FindObjectOfType <MenuHandler>();
        _aConnection = GameObject.FindObjectOfType <AccountConnection>();
        InputField codeInputField = null;
        InputField nameInputField = null;

        var test = GameObject.FindObjectsOfType <InputField>();

        foreach (InputField x in test)
        {
            switch (x.name)
            {
            case nameof(EInputFieldNames.UsernameInputField):
                nameInputField = x;
                break;

            case nameof(EInputFieldNames.PasswordInputField):
                codeInputField = x;
                break;
            }
        }

        try
        {
            _username = nameInputField.text;
            _passcode = codeInputField.text;
        }
        catch (NullReferenceException)
        {
            throw new NullReferenceException("ClickVerify: Use of unassigned InputField.");
        }

        //Now that we have the input field info, we can toggle off the login canvas
        _mHandler.ToggleCanvas(_mHandler.GetLoginCanvas());

        Task <BoolStringResult> verifyAccountTask = _aConnection.VerifyAccountAsync(_username, _passcode);
        var result = await verifyAccountTask;

        Debug.Log(result._successful);
        Task authTask = _aConnection.GrantAuthAsync(result._successful, _username);


        _mHandler.UpdateConfirmationMessageText(result._stringMessage + " Login", result._successful);
        if (result._successful)
        {
            _mHandler.SetPrevCanvas(_mHandler.GetMainMenuCanvas());
        }
        _mHandler.ToggleCanvas(_mHandler.GetLoadingCanvas());
        _mHandler.ToggleCanvas(_mHandler.GetMessageCanvas());

        if (authTask.IsCompleted)
        {
            Debug.Log(UserSessionManager.GetUsername());
            Debug.Log(UserSessionManager.GetID());
        }
    }
Beispiel #13
0
        public void SendItem(long characterId, MallItem item)
        {
            if (!MSManager.Instance.AuthentificatedClients.Any(s => s.Equals(CurrentClient.ClientId)))
            {
                return;
            }

            MailDTO mailDTO = new MailDTO
            {
                AttachmentAmount  = (short)item.Amount,
                AttachmentRarity  = item.Rare,
                AttachmentUpgrade = item.Upgrade,
                AttachmentDesign  = item.Design,
                AttachmentVNum    = item.ItemVNum,
                Date         = DateTime.Now,
                EqPacket     = "",
                IsOpened     = false,
                IsSenderCopy = false,
                Message      = "",
                ReceiverId   = characterId,
                SenderId     = characterId,
                Title        = "ItemMall"
            };

            DAOFactory.MailDAO.InsertOrUpdate(ref mailDTO);

            MailDTO mail = new MailDTO
            {
                AttachmentAmount  = mailDTO.AttachmentAmount,
                AttachmentRarity  = mailDTO.AttachmentRarity,
                AttachmentUpgrade = mailDTO.AttachmentUpgrade,
                AttachmentDesign  = mailDTO.AttachmentDesign,
                AttachmentVNum    = mailDTO.AttachmentVNum,
                Date            = mailDTO.Date,
                EqPacket        = mailDTO.EqPacket,
                IsOpened        = mailDTO.IsOpened,
                IsSenderCopy    = mailDTO.IsSenderCopy,
                MailId          = mailDTO.MailId,
                Message         = mailDTO.Message,
                ReceiverId      = mailDTO.ReceiverId,
                SenderClass     = mailDTO.SenderClass,
                SenderGender    = mailDTO.SenderGender,
                SenderHairColor = mailDTO.SenderHairColor,
                SenderHairStyle = mailDTO.SenderHairStyle,
                SenderId        = mailDTO.SenderId,
                SenderMorphId   = mailDTO.SenderMorphId,
                Title           = mailDTO.Title
            };

            AccountConnection account = MSManager.Instance.ConnectedAccounts.Find(a => a.CharacterId.Equals(mail.ReceiverId));

            if (account?.ConnectedWorld != null)
            {
                account.ConnectedWorld.MailServiceClient.GetClientProxy <IMailClient>().MailSent(mail);
            }
        }
Beispiel #14
0
        /// <summary>
        /// VoIP call.
        /// </summary>
        /// <param name="accountConnection">Account connection configuration.</param>
        public VoIPCall(AccountConnection accountConnection)
        {
            if (accountConnection == null)
            {
                throw new ArgumentNullException(nameof(accountConnection));
            }

            // Create the voip manager.
            _voipManager = new VoIPManager(accountConnection);
        }
Beispiel #15
0
        public SerializableWorldServer GetPreviousChannelByAccountId(long accountId)
        {
            if (!MSManager.Instance.AuthentificatedClients.Any(s => s.Equals(CurrentClient.ClientId)))
            {
                return(null);
            }

            AccountConnection account = MSManager.Instance.ConnectedAccounts.FirstOrDefault(s => s.AccountId.Equals(accountId));

            return(account?.PreviousChannel?.Serializable);
        }
        /*
         * public void CleanupOutdatedSession()
         * {
         *  if (!MSManager.Instance.AuthentificatedClients.Any(s => s.Equals(CurrentClient.ClientId)))
         *  {
         *      return;
         *  }
         *
         *  AccountConnection[] tmp = new AccountConnection[MSManager.Instance.ConnectedAccounts.Count + 20];
         *  lock (MSManager.Instance.ConnectedAccounts)
         *  {
         *      MSManager.Instance.ConnectedAccounts.CopyTo(tmp);
         *  }
         *  foreach (AccountConnection account in tmp.Where(a => a != null && a?.LastPulse.AddMinutes(5) <= DateTime.Now))
         *  {
         *      KickSession(account.AccountId, null);
         *  }
         * }
         */

        public void CleanupOutdatedSession()
        {
            AccountConnection[] tmp = new AccountConnection[MSManager.Instance.ConnectedAccounts.Count + 20];
            lock (MSManager.Instance.ConnectedAccounts)
            {
                MSManager.Instance.ConnectedAccounts.CopyTo(tmp);
            }
            foreach (AccountConnection account in tmp.Where(a => a?.LastPulse.AddMinutes(5) <= DateTime.Now))
            {
                KickSession(account.AccountId, null);
            }
        }
Beispiel #17
0
        /// <summary>
        /// VoIP manager.
        /// </summary>
        /// <param name="accountConnection">Account connection configuration.</param>
        public VoIPManager(AccountConnection accountConnection)
        {
            if (accountConnection == null)
            {
                throw new ArgumentNullException(nameof(accountConnection));
            }

            _account = new Account(accountConnection);

            // Get the media manager.
            _mediaManager = _account.GetMediaManager();
        }
        public void RegisterCrossServerAccountLogin(long accountId, int sessionId)
        {
            if (!MSManager.Instance.AuthentificatedClients.Any(s => s.Equals(CurrentClient.ClientId)))
            {
                return;
            }
            AccountConnection account = MSManager.Instance.ConnectedAccounts.Where(a => a.AccountId.Equals(accountId) && a.SessionId.Equals(sessionId)).FirstOrDefault();

            if (account != null)
            {
                account.CanLoginCrossServer = true;
            }
        }
        public void PulseAccount(long accountId)
        {
            if (!MSManager.Instance.AuthentificatedClients.Any(s => s.Equals(CurrentClient.ClientId)))
            {
                return;
            }
            AccountConnection account = MSManager.Instance.ConnectedAccounts.Find(a => a.AccountId.Equals(accountId));

            if (account != null)
            {
                account.LastPulse = DateTime.Now;
            }
        }
Beispiel #20
0
        /// <summary>
        /// 初始化Account,该方法必须在调用SyncTasks或SyncContacts之前调用
        /// </summary>
        protected void InitializeAccount(AccountConnection connection)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }
            var account = _accountService.GetAccount(connection.AccountId);

            if (account == null)
            {
                throw new Exception(string.Format("账号连接【ID:{0},AccountId:{1}】对应的账号不存在", connection.ID, connection.AccountId));
            }
            _account = account;
        }
    public async void ClickRegister()
    {
        _mHandler    = GameObject.FindObjectOfType <MenuHandler>();
        _aConnection = GameObject.FindObjectOfType <AccountConnection>();

        InputField codeInputField = null;
        InputField nameInputField = null;

        var test = GameObject.FindObjectsOfType <InputField>();

        foreach (InputField x in test)
        {
            switch (x.name)
            {
            case nameof(EInputFieldNames.NewUsernameInputField):
                nameInputField = x;
                break;

            case nameof(EInputFieldNames.NewPasswordInputField):
                codeInputField = x;
                break;
            }
        }

        try
        {
            _username = nameInputField.text;
            _passcode = codeInputField.text;
        }
        catch (NullReferenceException)
        {
            throw new NullReferenceException("ClickRegister: Use of unassigned InputField.");
        }

        //Now that we have the input field info, we can toggle off the reg canvas
        _mHandler.ToggleCanvas(_mHandler.GetRegistrationCanvas());

        Task <BoolStringResult> createAccountTask = _aConnection.CreateAccountAsync(_username, _passcode);
        var result = await createAccountTask;

        _mHandler.UpdateConfirmationMessageText(result._stringMessage + " Registration", result._successful);

        if (result._successful)
        {
            _mHandler.SetPrevCanvas(_mHandler.GetLoginCanvas());
        }

        _mHandler.ToggleCanvas(_mHandler.GetLoadingCanvas());
        _mHandler.ToggleCanvas(_mHandler.GetMessageCanvas());
    }
Beispiel #22
0
        public void RegisterInternalAccountLogin(long accountId, int sessionId)
        {
            if (!MSManager.Instance.AuthentificatedClients.Any(s => s.Equals(CurrentClient.ClientId)))
            {
                return;
            }

            AccountConnection account = MSManager.Instance.ConnectedAccounts.FirstOrDefault(a => a.AccountId.Equals(accountId) && a.SessionId.Equals(sessionId));

            if (account != null)
            {
                account.CanSwitchChannel = true;
            }
        }
        public ActionResult SubmitRegistration(SignupModel model)
        {
            string            viewName          = "Signup";
            AccountConnection accountConnection = new AccountConnection();

            if (ModelState.IsValid)
            {
                SignupRequest request = ConvertSignUpModel(model);
                accountConnection.AddUser(request);
                viewName = "Login";
            }

            return(View(viewName));
        }
Beispiel #24
0
        public void SendMail(Mail mail)
        {
            if (!MSManager.Instance.AuthentificatedClients.Any(s => s.Equals(CurrentClient.ClientId)))
            {
                return;
            }

            MailDTO mailDTO = new MailDTO
            {
                AttachmentAmount  = mail.AttachmentAmount,
                AttachmentRarity  = mail.AttachmentRarity,
                AttachmentUpgrade = mail.AttachmentUpgrade,
                AttachmentVNum    = mail.AttachmentVNum,
                Date            = mail.Date,
                EqPacket        = mail.EqPacket,
                IsOpened        = mail.IsOpened,
                IsSenderCopy    = mail.IsSenderCopy,
                MailId          = mail.MailId,
                Message         = mail.Message,
                ReceiverId      = mail.ReceiverId,
                SenderClass     = mail.SenderClass,
                SenderGender    = mail.SenderGender,
                SenderHairColor = mail.SenderHairColor,
                SenderHairStyle = mail.SenderHairStyle,
                SenderId        = mail.SenderId,
                SenderMorphId   = mail.SenderMorphId,
                Title           = mail.Title
            };

            DAOFactory.MailDAO.InsertOrUpdate(ref mailDTO);
            mail.MailId = mailDTO.MailId;

            if (mail.IsSenderCopy)
            {
                AccountConnection account = MSManager.Instance.ConnectedAccounts.Find(a => a.CharacterId.Equals(mail.SenderId));
                if (account?.ConnectedWorld != null)
                {
                    account.ConnectedWorld.MailServiceClient.GetClientProxy <IMailClient>().MailSent(mail);
                }
            }
            else
            {
                AccountConnection account = MSManager.Instance.ConnectedAccounts.Find(a => a.CharacterId.Equals(mail.ReceiverId));
                if (account?.ConnectedWorld != null)
                {
                    account.ConnectedWorld.MailServiceClient.GetClientProxy <IMailClient>().MailSent(mail);
                }
            }
        }
        public string RetrieveOriginWorld(long accountId)
        {
            if (!MSManager.Instance.AuthentificatedClients.Any(s => s.Equals(CurrentClient.ClientId)))
            {
                return(null);
            }

            AccountConnection account = MSManager.Instance.ConnectedAccounts.Find(s => s.AccountId.Equals(accountId));

            if (account?.OriginWorld != null)
            {
                return($"{account.OriginWorld.Endpoint.IpAddress}:{account.OriginWorld.Endpoint.TcpPort}");
            }
            return(null);
        }
        public bool ConnectAccount(Guid worldId, long accountId, int sessionId)
        {
            if (!MSManager.Instance.AuthentificatedClients.Any(s => s.Equals(CurrentClient.ClientId)))
            {
                return(false);
            }

            AccountConnection account = MSManager.Instance.ConnectedAccounts.Find(a => a.AccountId.Equals(accountId) && a.SessionId.Equals(sessionId));

            if (account != null)
            {
                account.ConnectedWorld = MSManager.Instance.WorldServers.Find(w => w.Id.Equals(worldId));
            }
            return(account.ConnectedWorld != null);
        }
Beispiel #27
0
        public bool ConnectWithUser(int accountId, int targetId)
        {
            if (HasConnected(accountId, targetId))
            {
                return(false);
            }

            var rec = _dbConnectOnCommute.TblConnection.Where(r =>
                                                              (r.AccountId == accountId && r.TargetId == targetId))
                      .FirstOrDefault();

            if (rec == null)
            {
                var con = new AccountConnection()
                {
                    AccountId = accountId,
                    TargetId  = targetId,
                    Timestamp = DateTime.Now
                };
                _dbConnectOnCommute.TblConnection.Add(con);
                _dbConnectOnCommute.SaveChanges();
            }
            var val = HasConnected(accountId, targetId);

            if (val)
            {
                var user   = GetAccountById(accountId);
                var target = GetAccountById(targetId);
                //Tell the other user
                EmitNotification(new AccountNotification()
                {
                    AccountId = targetId,
                    Type      = 1,
                    Dismissed = false,
                    Timestamp = DateTime.Now.ToUniversalTime(),
                    Text      = "Congratulations, you have a new connection! You and " + user.FirstName + " " + user.LastName + " are now connected!"
                });
                EmitNotification(new AccountNotification()
                {
                    AccountId = accountId,
                    Type      = 1,
                    Dismissed = false,
                    Timestamp = DateTime.Now.ToUniversalTime(),
                    Text      = "Congratulations, you have a new connection! You and " + target.FirstName + " " + target.LastName + " are now connected!"
                });
            }
            return(val);
        }
Beispiel #28
0
 public void SendMail(string worldGroup, MailDTO mail)
 {
     if (!IsCharacterConnected(worldGroup, mail.ReceiverId))
     {
         CharacterDTO chara = DAOFactory.CharacterDAO.LoadById(mail.ReceiverId);
         DAOFactory.MailDAO.InsertOrUpdate(ref mail);
     }
     else
     {
         AccountConnection account = MSManager.Instance.ConnectedAccounts.FirstOrDefault(a => a.CharacterId.Equals(mail.ReceiverId));
         if (account != null && account.ConnectedWorld != null)
         {
             account.ConnectedWorld.ServiceClient.GetClientProxy <ICommunicationClient>().SendMail(mail);
         }
     }
 }
Beispiel #29
0
        public void SendItem(long characterId, MallItem item)
        {
            if (!MSManager.Instance.AuthentificatedClients.Any(s => s.Equals(CurrentClient.ClientId)))
            {
                return;
            }
            ItemDTO dto = DAOFactory.ItemDAO.LoadById(item.ItemVNum);

            if (dto != null)
            {
                int limit = 99;

                if (dto.Type == InventoryType.Equipment || dto.Type == InventoryType.Miniland)
                {
                    limit = 1;
                }

                do
                {
                    MailDTO mailDTO = new MailDTO
                    {
                        AttachmentAmount  = (byte)(item.Amount > limit ? limit : item.Amount),
                        AttachmentRarity  = item.Rare,
                        AttachmentUpgrade = item.Upgrade,
                        AttachmentVNum    = item.ItemVNum,
                        Date         = DateTime.Now,
                        EqPacket     = string.Empty,
                        IsOpened     = false,
                        IsSenderCopy = false,
                        Message      = string.Empty,
                        ReceiverId   = characterId,
                        SenderId     = characterId,
                        Title        = "NOSMALL"
                    };

                    DAOFactory.MailDAO.InsertOrUpdate(ref mailDTO);

                    AccountConnection account = MSManager.Instance.ConnectedAccounts.Find(a => a.CharacterId.Equals(mailDTO.ReceiverId));
                    if (account?.ConnectedWorld != null)
                    {
                        account.ConnectedWorld.MailServiceClient.GetClientProxy <IMailClient>().MailSent(mailDTO);
                    }

                    item.Amount -= limit;
                } while (item.Amount > 0);
            }
        }
Beispiel #30
0
        public int?SendMessageToCharacter(ScsCharacterMessage message)
        {
            if (!MsManager.Instance.AuthentificatedClients.Any(s => s.Equals(CurrentClient.ClientId)))
            {
                return(null);
            }

            WorldServer sourceWorld = MsManager.Instance.WorldServers.Find(s => s.Id.Equals(message.SourceWorldId));

            if (message?.Message == null || sourceWorld == null)
            {
                return(null);
            }
            switch (message.Type)
            {
            case MessageType.Family:
            case MessageType.FamilyChat:
                foreach (WorldServer world in MsManager.Instance.WorldServers.Where(w => w.WorldGroup.Equals(sourceWorld.WorldGroup)))
                {
                    world.CommunicationServiceClient.GetClientProxy <ICommunicationClient>().SendMessageToCharacter(message);
                }
                return(-1);

            case MessageType.PrivateChat:
            case MessageType.Whisper:
            case MessageType.WhisperSupport:
            case MessageType.WhisperGm:
                if (message.DestinationCharacterId.HasValue)
                {
                    AccountConnection account = MsManager.Instance.ConnectedAccounts.Find(a => a.CharacterId.Equals(message.DestinationCharacterId.Value));
                    if (account?.ConnectedWorld != null)
                    {
                        account.ConnectedWorld.CommunicationServiceClient.GetClientProxy <ICommunicationClient>().SendMessageToCharacter(message);
                        return(account.ConnectedWorld.ChannelId);
                    }
                }
                break;

            case MessageType.Shout:
                foreach (WorldServer world in MsManager.Instance.WorldServers)
                {
                    world.CommunicationServiceClient.GetClientProxy <ICommunicationClient>().SendMessageToCharacter(message);
                }
                return(-1);
            }
            return(null);
        }
 public void Should_Throw_PreconditionException_If_Connection_String_Null() 
 {
     var accountConnection = new AccountConnection<TestEntity>(null);
 }
 public void Should_Throw_PreconditionException_If_Connection_String_Empty() 
 {
     var accountConnection = new AccountConnection<TestEntity>(string.Empty);
 }
 //HACK:根据ark连接取ali人员信息
 protected override string ParseEmail(AccountConnection c)
 {
     var email = base.ParseEmail(c);
     if (!string.IsNullOrWhiteSpace(email) || !(c is ArkConnection))
         return email;
     var ark = c as ArkConnection;
     var user = this._userHelper.GetUserByUserName(ark.Name);
     return user != null ? user.Email : null;
 }