Esempio n. 1
0
        private async void Button_Tapped(object sender, TappedRoutedEventArgs e)
        {
            string NewUserName = UserNameInput.Text;
            var    NewPassword = PasswordInput.Password;
            Users  newUser     = new Users();
            bool   userexist   = false;

            var CheckUserAvailable = await UserSource.GetUsersAsync();

            foreach (var item in CheckUserAvailable)
            {
                if (item.Brukernavn == NewUserName)
                {
                    ErrorMessage.Text = "Brukernavn eksisterer i databasen";
                    userexist         = true;
                }
                else
                {
                    newUser.Brukernavn = NewUserName;
                    newUser.Passord    = NewPassword;
                }
            }
            if (userexist == false)
            {
                await UserSource.AddUserAsync(newUser);

                this.Frame.Navigate(typeof(FrontPage));
            }
        }
Esempio n. 2
0
        private static void Listener()
        {
            double currTmr = 0;

            MQManager.RegisterConnectionStatusEvent(new ConnectionStatus());
            UserSource us = new UserSource();
            int        i  = 1;

            MQManager.ReceiveGroupMessage((messageType, fromUserId, groupId, messageBytes) =>
            {
                if (!string.IsNullOrEmpty(groupId) && messageBytes != null && messageBytes.Length > 0)
                {
                    DateTime beforDT = System.DateTime.Now;

                    var userQueueSymbols = us.GetUserQueueSymbolList(fromUserId, groupId);
                    MQManager.SendMessage(userQueueSymbols, messageBytes);

                    DateTime afterDT = System.DateTime.Now;
                    TimeSpan ts      = afterDT.Subtract(beforDT);
                    currTmr         += ts.TotalMilliseconds;
                    Console.WriteLine(i + " current " + ts.TotalMilliseconds + " ms,total " + currTmr + " ms");
                }
                i++;
            }, (error) =>
            {
                Console.WriteLine(error);
            });
        }
Esempio n. 3
0
        public void ExecuteDeleteCommand(string nsName)
        {
            DistributionVM delDistribution = FindByNsName(nsName);

            UserSource.Add(new User(delDistribution.UserID, delDistribution.UserFio));
            CompSource.Add(new Computer(delDistribution.ComputerID, delDistribution.NsName));
            sourceDistr.Remove(delDistribution);
        }
 public MockLegacyRepository()
 {
     _users = new List <User>()
     {
         ValidLegacyUser.AsUser(),
             InvalidLegacyUser.AsUser()
     };
     SourceSystem = UserSource.Legacy;
 }
Esempio n. 5
0
        //public User(string name, Sid sid, string loginType, string userType)
        //{
        //    m_Sid = sid;
        //    m_Name = name;
        //    m_LoginType = loginType;
        //    m_UserType = userType;
        //    m_UserSource = UserSource.Unknown;
        //    m_isVerified = false;
        //}

        public User(string name, Sid sid, string loginType, UserSource source)
        {
            m_Sid       = sid;
            m_Name      = name;
            m_LoginType = loginType;
            //m_UserType = "";
            m_UserSource = source;
            m_isVerified = false;
        }
 /// <summary>
 /// 实体数据消息接收
 /// </summary>
 /// <param name="message"></param>
 public void Handle(Message <User> message)
 {
     if (message.Name == "ViewToViewModel")
     {
         //进行一些操作
         UserSource.Add(message.Value);
         this.ShowMessage($"ViewModel:刚刚收到View发过来的User类型的通知!\r\n消息内容为:{message.Value.Name},并添加到了GridView里");
     }
 }
 public MockUserRepository()
 {
     _users = new List <User>()
     {
         ValidUser.AsUser(),
             InvalidUser.AsUser()
     };
     SourceSystem = UserSource.New;
 }
        private void OnDeleteStudentAsync()
        {
            if (UserSource.Count == 0)
            {
                return;
            }
            var lastStudent = UserSource.Last();

            UserSource.Remove(lastStudent);
        }
        private void OnModifyStudent()
        {
            if (UserSource.Count == 0)
            {
                return;
            }
            var lastStudent = UserSource.Last();

            lastStudent.Remark = $"该同学于{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}被修改了备注";
        }
Esempio n. 10
0
        private void OnAddStudent()
        {
            var num = (UserSource.Count + 1).As <string>();

            UserSource.Add(new User
            {
                Number = num,
                Name   = $"小{num}",
                Remark = "新增的"
            });
        }
Esempio n. 11
0
        /// <summary>
        /// Sourceの変換
        /// </summary>
        /// <param name="source">JValueのsource</param>
        /// <returns>SourceBaseのsource</returns>
        private static SourceBase ConvertSource(JObject source)
        {
            Trace.TraceInformation("Start");

            string sourceType = source["type"].Value <string>();

            Trace.TraceInformation("Source Type is " + sourceType);
            switch (sourceType)
            {
            // グループ
            case "group":
                // TODO 未確認
                GroupSource groupSource = new GroupSource()
                {
                    groupId = source["groupId"]?.Value <string>(),
                    userId  = source["userId"]?.Value <string>()
                };
                Trace.TraceInformation("Group Id is " + groupSource.groupId);
                Trace.TraceInformation("User Id is " + groupSource.userId);
                Trace.TraceInformation("End");
                return(groupSource);

            // トークルーム
            case "room":
                // TODO 未確認
                RoomSource roomSource = new RoomSource()
                {
                    roomId = source["roomId"]?.Value <string>(),
                    userId = source["userId"]?.Value <string>()
                };
                Trace.TraceInformation("Room Id is " + roomSource.roomId);
                Trace.TraceInformation("User Id is " + roomSource.userId);
                Trace.TraceInformation("End");
                return(roomSource);

            // ユーザ
            case "user":
                UserSource userSource = new UserSource()
                {
                    userId = source["userId"]?.Value <string>()
                };
                Trace.TraceInformation("User Id is " + userSource.userId);
                Trace.TraceInformation("End");
                return(userSource);

            default:
                // TODO 未確認
                Trace.TraceWarning("Don't Convert Source");
                Trace.TraceInformation("End");
                return(null);
            }
        }
Esempio n. 12
0
        public User(string firstname, string lastname, string username,
                    string emailAddress, UserStatus userStatus,
                    string password, UserSource source)
        {
            FirstName    = firstname;
            LastName     = lastname;
            Username     = username;
            EmailAddress = emailAddress;
            UserStatus   = userStatus;
            Source       = source;

            SetPassword(password);
        }
Esempio n. 13
0
        public ActionResult <IEnumerable <User> > Get()
        {
            Log.Information("GET request for all users");
            List <User> _users = new List <User>();

            if (UserSource.GetAll(out _users))
            {
                Log.Debug("returned {0} users", _users.Count);
                return(Ok(_users));
            }
            else
            {
                Log.Information("User not found");
                return(NotFound());
            }
        }
Esempio n. 14
0
        /// <summary>
        /// 获取表的最新数据
        /// </summary>
        private async void Refresh()
        {
            var result = await CustomDataApi.GetCustomDataListAsync(_tableName);

            if (!result.IsOk)
            {
                return;
            }
            UserSource.Clear();
            var records = result.GetRecords();

            foreach (var record in records)
            {
                UserSource.Add(record.As <User>());
            }
        }
Esempio n. 15
0
        private async void OnDeleteData()
        {
            if (UserSource.Count == 0)
            {
                return;
            }
            var lastUser = UserSource.Last();
            var result   = await CustomDataApi.DeleteCustomDataAsync(_tableName, new[] { lastUser._id });

            if (!result.IsOk)
            {
                Mg.Get <IMgDialog>().ShowDesktopAlert("删除最后一个学生数据失败", result.Message);
                return;
            }
            Refresh();
        }
Esempio n. 16
0
        public void AddDistribution(DistributionVM newDistribution, object currentComp, object currentUser)
        {
            User     cu = currentUser as User;
            Computer cc = currentComp as Computer;

            newDistribution.Id         = -1;
            newDistribution.ComputerID = cc.Id;
            newDistribution.NsName     = cc.NsName;
            newDistribution.UserFio    = cu.UserFio;
            newDistribution.UserID     = cu.Id;

            SourceDistr.Add(newDistribution);


            UserSource.Remove(cu);
            CompSource.Remove(cc);
        }
Esempio n. 17
0
        public void SourceDown(string UserId, int SourceId)
        {
            var UserSourceId = db.UserSource.FirstOrDefault(us => us.UserId == UserId && us.SourceId == SourceId);

            if (UserSourceId != null)
            {
                UserSourceId.Rating = -1;
            }
            else
            {
                UserSource us = new UserSource();
                us.UserId   = UserId;
                us.SourceId = SourceId;
                us.Rating   = -1;
                db.UserSource.Add(us);
            }

            db.SaveChanges();
        }
Esempio n. 18
0
        private async void OnButtonClick()
        {
            IsBusy = true;
            await Task.Delay(5000);//延迟5秒

            UserSource.AddRange(new[] {
                new User {
                    Number = "1", Name = "小茗", Remark = "-"
                },
                new User {
                    Number = "2", Name = "冷冷", Remark = "-"
                },
                new User {
                    Number = "3", Name = "暖暖", Remark = "-"
                }
            });
            _bakUserSource.AddRange(UserSource);
            IsBusy = false;
        }
Esempio n. 19
0
        private async void OnUpdateData()
        {
            if (UserSource.Count == 0)
            {
                return;
            }
            var lastUser = UserSource.Last();
            var record   = lastUser.AsDictionary().As <DynamicRecord>();

            record["Remark"] = $"于{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}被修改了备注信息";
            var data = new List <IRecord> {
                record
            };
            var result = await CustomDataApi.UpdateCustomDataAsync(_tableName, data.ToArray());

            if (!result.IsOk)
            {
                Mg.Get <IMgDialog>().ShowDesktopAlert("修改最后一个学生的备注信息失败", result.Message);
                return;
            }
            Refresh();
        }
Esempio n. 20
0
 public ActionResult <string> Get(int userId)
 {
     Log.Information("GET request by id = {0}", userId);
     try
     {
         User _user = UserSource.GetUserById(userId);
         if (_user.UserId == 0)
         {
             Log.Information("User not found");
             return(NotFound());
         }
         else
         {
             Log.Information("Found user: {0} {1} {2}", _user.UserId, _user.SecondName, _user.FirstName);
             return(Ok(_user));
         }
     }
     catch (Exception e)
     {
         Log.Error("GET byID request error: {0}", e.Message);
         return(StatusCode((int)HttpStatusCode.InternalServerError, e));
     }
 }
Esempio n. 21
0
        /// <summary>
        /// 获取表的最新数据
        /// </summary>
        private async void Refresh()
        {
            var result = await CustomDataApi.GetCustomDataListAsync(_tableName);

            if (!result.IsOk)
            {
                return;
            }
            UserSource.Clear();
            var records = result.GetRecords();

            foreach (var record in records)
            {
                //UserSource.Add(record.As<User>());
                UserSource.Add(new User
                {
                    _id    = record["_id"].As <Id>(),
                    Number = record["Number"].As <string>(),
                    Name   = record["Name"].As <string>(),
                    Remark = record["Remark"].As <string>()
                });
            }
        }
Esempio n. 22
0
        private async void userAuthentication()
        {
            // var b = await DataSource.GetReiserAsync();

            //foreach (var item in b)
            //{
            //    var a = new ListViewItem();
            //    a.Tag = item;
            //    a.Content = item.Dato + "        " + item.Navn +"        " + item.Fra + "        " + item.Til;
            //    SqlList2.Items.Add(a);
            //}

            string uN = UserName.Text;
            var    pW = Password.Password;

            var userCheck = await UserSource.GetUsersAsync();

            foreach (var item in userCheck)
            {
                if (item.Brukernavn == uN)
                {
                    if (item.Passord == pW)
                    {
                        this.Frame.Navigate(typeof(MainPage));
                    }
                    else
                    {
                        LoginErrorText.Text = "Feil Brukernavn / Passord";
                    }
                }
                else
                {
                    LoginErrorText.Text = "Feil Brukernavn / Passord";
                }
            }
        }
        private void Registration(object parameter)
        {
            bool        exists            = false;
            PasswordBox passwordBox       = parameter as PasswordBox;
            string      clearTextPassword = passwordBox.Password;

            db.User.Load();
            UserSource = db.User.Local;


            foreach (User p in UserSource)
            {
                if (p.Login == Username)
                {
                    exists = true;
                }
            }
            if (exists)
            {
                MessageBox.Show("Выбранный вами логин уже существует!");
            }
            else
            {
                User newUser = new User();
                newUser.Login    = Username;
                newUser.Password = clearTextPassword;
                db.User.Add(newUser);
                db.SaveChanges();
                db.User.Load();
                UserSource = db.User.Local;
                MessageBox.Show("Добро пожаловать, " + UserSource[UserSource.IndexOf(newUser)].Login + "!");
                Window2 h = new Window2(UserSource[UserSource.IndexOf(newUser)].Id, db);
                WindowManager.CloseWindow(ViewID);
                h.Show();
            }
        }
 private void btnLast_Click(object sender, EventArgs e)
 {
     UserSource.MoveLast();
     OnChangeDataSelect();
 }
Esempio n. 25
0
 public void DeleteDistribution(DistributionVM deletedItem)
 {
     UserSource.Add(new User(deletedItem.UserID, deletedItem.UserFio));
     CompSource.Add(new Computer(deletedItem.ComputerID, deletedItem.NsName));
     sourceDistr.Remove(deletedItem);
 }
 public ModernUserRepository(IOptions <ConnectionStrings> connectionStrings)
 {
     _db          = new SqlConnection(connectionStrings.Value.ModernUsers);
     SourceSystem = UserSource.New;
 }
Esempio n. 27
0
 private async Task <User> GetUserByExternalInfo(string email, UserSource source, string externalId)
 {
     return(await _userRepository.GetByExternalInfo(email, (int)source, externalId));
 }
Esempio n. 28
0
        public override string OnResponse(string data)
        {
            OldPlayerReq oldPlayerReq = null;

            try
            {
                oldPlayerReq = JsonConvert.DeserializeObject <OldPlayerReq>(data);
            }
            catch (Exception e)
            {
                MySqlService.log.Warn("传入的参数有误:" + data + "\n" + e);
                return(null);
            }

            string oldUid    = oldPlayerReq.old_uid;
            string uid       = oldPlayerReq.uid;
            string from      = oldPlayerReq.from;
            string machineId = oldPlayerReq.machine_id;
            int    connId    = oldPlayerReq.connId;

            if (string.IsNullOrWhiteSpace(uid) || string.IsNullOrWhiteSpace(oldUid) || string.IsNullOrWhiteSpace(machineId))
            {
                MySqlService.log.Warn($"字段有空:{data}");
                return(null);
            }

            JObject response = new JObject();

            response.Add(MyCommon.CONNID, connId);
            response.Add(MyCommon.TAG, Consts.Tag_OldPlayerBind);
            int i;

            try
            {
                i = int.Parse(oldUid);
            }
            catch (Exception e)
            {
                OperatorFail(response, Consts.Code.Code_OldPlayerUidIsNotExist);
                return(response.ToString());
            }

            //先查询machineid
            Log_bind_oldplayer logBindOldplayer = MySqlManager <Log_bind_oldplayer> .Instance.GetOldPlayerByMacId(machineId);

            if (logBindOldplayer != null)
            {
                OperatorFail(response, Consts.Code.Code_ThePhoneIsBindOldUid);
                return(response.ToString());
            }

            UserSource userSource = NhInterSqlServer.NHiMsServerteHelper.GetById(i);

            if (userSource == null)
            {
                OperatorFail(response, Consts.Code.Code_OldPlayerUidIsNotExist);
            }
            else
            {
                Log_bind_oldplayer bindOldplayer = MySqlManager <Log_bind_oldplayer> .Instance.GetByUid(uid);

                if (bindOldplayer == null)
                {
                    bindOldplayer = new Log_bind_oldplayer
                    {
                        Uid          = uid,
                        old_uid      = oldUid,
                        channel_name = from,
                        machine_id   = machineId
                    };
                    if (MySqlManager <Log_bind_oldplayer> .Instance.Add(bindOldplayer))
                    {
                        SendEmailUtil.SendEmail(uid, "老用户特权奖励", "恭喜您已成功绑定老游戏UID,请领取您的奖励", "111:1;110:2;1:6666;107:5");
                        OperatorSuccess(response);
                    }
                    else
                    {
                        OperatorFail(response, Consts.Code.Code_TheOldUidIsUsed);
                    }
                }
                else
                {
                    OperatorFail(response, Consts.Code.Code_TheUidIsBind);
                }
            }

            return(response.ToString());
        }
Esempio n. 29
0
 public LegacyUserRepository(IOptions <ConnectionStrings> connectionStrings)
 {
     _db          = new MySqlConnection(connectionStrings.Value.LegacyUsers);
     SourceSystem = UserSource.Legacy;
 }
Esempio n. 30
0
 public User()
 {
     Avatar = DefaultAvatar;
     Source = UserSource.WebPageRegist;
 }