internal new SocketGuildUser Clone() { var clone = MemberwiseClone() as SocketGuildUser; clone.GlobalUser = GlobalUser.Clone(); return(clone); }
public IActionResult Authorize(string username, string pass) { if (username != null && pass != null) { // Comon.Global.DetectSettingAbosulute(); GlobalUser user = new GlobalUser(); int resulf = user.DetectAuthorised(username.Replace("'", "").Trim(), pass.Replace("'", "").Trim()); if (resulf != 0) { if (string.IsNullOrEmpty(HttpContext.Session.GetString(Global.UserID))) { HttpContext.Session.SetInt32(Global.UserID, resulf); } //return RedirectToAction("Index", "ServiceDetail", new { Type = 27 }); return(RedirectToAction("Index", "SaleMain")); } else { string Status = "Tên đăng nhập hoặc mật khẩu không đúng"; ViewBag.Status = Status; return(View("~/Views/Admin/Login/Login.cshtml")); } } else { return(View()); } }
public ErrorInfo FileDel(ref ErrorInfo err, ApiRequesEntityBean <ErrorInfo> inEnt) { GlobalUser gu = Global.GetUser(inEnt.authToken); if (gu == null) { err.IsError = true; err.Message = "登录超时"; return(null); } ErrorInfo reEnt = new ErrorInfo(); using (DBEntities db = new DBEntities()) { var file = db.fa_files.SingleOrDefault(x => x.ID == inEnt.id); if (file == null) { err.IsError = true; err.Message = "文件对象不存在"; return(null); } db.fa_files.Remove(file); if (Fun.DBEntitiesCommit(db, ref err)) { var allPath = Fun.UrlToAllPath(file.URL); if (System.IO.File.Exists(allPath)) { System.IO.File.Delete(allPath); } reEnt.IsError = false; } } return(reEnt); }
public ActionResult GetUserImage(string tkn = "") { string filepath = ""; string ImagePath = string.Empty; if (!string.IsNullOrEmpty(tkn)) { if (tkn == "loggedinUser") { var currentUserId = GlobalUser.getGlobalUser().UserId; var user = _userBusiness.GetListWT(c => c.UserId == currentUserId).FirstOrDefault(); ImagePath = "~/ProfileImage/" + user.ProfileImage; } else { var user = _userBusiness.GetListWT(c => c.TokenKey == tkn).FirstOrDefault(); ImagePath = "~/ProfileImage/" + user.ProfileImage; } filepath = !System.IO.File.Exists(Server.MapPath(ImagePath)) ? Server.MapPath("~/Content/Admin/Images/icon-user-default.png") : Server.MapPath(ImagePath); } else { filepath = Server.MapPath("~/Content/Admin/Images/icon-user-default.png"); } return(File(filepath, "image/jpg/gif/png")); }
public static async Task <GlobalUser> GetGlobalUser(this DiscordUser user, BotContext botContext = null) { if (user.IsBot) { throw new Exception("Can't get bot GlobalUser"); } botContext ??= new BotContext(); var globalUser = await botContext.GlobalUsers.FirstOrDefaultAsync(g => g.DiscordUser == user.Id); if (globalUser == null) { globalUser = new GlobalUser { DiscordUser = user.Id, Money = 0, Reputation = 0, GlobalRank = null }; await botContext.GlobalUsers.AddAsync(globalUser); await botContext.SaveChangesAsync(); } return(globalUser); }
/* 2017-5-6 22:57:48 */ public FaUserInfo UserInfoSingle(ref ErrorInfo err, ApiRequesEntityBean <FaUserInfo> inEnt) { GlobalUser gu = Global.GetUser(inEnt.authToken); if (gu == null) { err.IsError = true; err.Message = "登录超时"; return(null); } using (DBEntities db = new DBEntities()) { ApiRequesEntityBean <TUser> userEnt = Fun.ClassToCopy <ApiRequesEntityBean <FaUserInfo>, ApiRequesEntityBean <TUser> >(inEnt); var user = api.UserApi.UserSingle(db, inEnt.authToken, ref err, userEnt); if (user == null) { return(null); } var userInfo = db.fa_user_info.FirstOrDefault(x => x.ID == user.ID); if (userInfo == null) { return(Mapper.Map <FaUserInfo>(user)); } var reEnt = Mapper.Map <FaUserInfo>(user); reEnt = Mapper.Map(userInfo, reEnt); return(reEnt); } }
/* 2017-5-7 23:34:16 */ public FaUserInfo UserInfoAddFriend(ref ErrorInfo err, ApiRequesSaveEntityBean <FaUserInfo> inEnt) { GlobalUser gu = Global.GetUser(inEnt.authToken); if (gu == null) { err.IsError = true; err.Message = "登录超时"; return(null); } var userInfo = UserInfoSave(ref err, inEnt); if (err.IsError) { return(null); } using (DBEntities db = new DBEntities()) { var info = db.fa_user_info.SingleOrDefault(x => x.ID == userInfo.ID); if (info == null) { err.IsError = true; err.Message = "保存数据错误"; return(null); } info.fa_user1.Add(db.fa_user.SingleOrDefault(x => x.ID == gu.UserId)); Fun.DBEntitiesCommit(db, ref err); return(userInfo); } }
private void DialogHost_OnDialogClosing(object sender, DialogClosingEventArgs eventArgs) { //Console.WriteLine("SAMPLE 1: Closing dialog with parameter: " + (eventArgs.Parameter ?? "")); //you can cancel the dialog close: //eventArgs.Cancel(); if (!Equals(eventArgs.Parameter, true)) { return; } GlobalUser.AudioCleanUp(); //关闭音频播放 ButtonAutomationPeer peer = new ButtonAutomationPeer(CloseBtn); IInvokeProvider invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider; invokeProv.Invoke(); //CloseBtn.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.Button.ClickEvent)); }
/// <summary> /// 开始考试 生成考试号 服务端 /// </summary> private bool BeginExamApi() { var ml = new BeginExamModel() { exam_id = GlobalUser.SelectPaperNumber.Split('#')[0] }; var result1 = WebProxy(ml, ApiType.BeginExam, GlobalUser.USER.Token); if (result1.retCode == 4001 && result1.retMsg.ToLower().Contains("token")) { //回到登录 GlobalUser.CleanUp(); Messenger.Default.Send(new ExamScoreNavigateMessage(), "LoginFailure"); return(false); } if (result1.retCode == 40400) { Messenger.Default.Send(new MainDialogMessage(result1.retMsg), "MainMessageDialog"); return(false); } GlobalUser.AttendPaperItemId = result1.retData.exam_attend_id; GlobalUser.SelectExamAttendResult = ""; return(true); }
public void GlobalUser_GetUser() { GlobalUser oNewUser; List <GlobalUser> oUsers; WebCallResult res = GlobalUser.GetUsers(_connectionServer, out oUsers, 1, 10); Assert.IsTrue(res.Success, "Failed to fetch global users"); Assert.IsTrue(oUsers.Count > 0, "No global users returned on fetch"); //GetUser res = GlobalUser.GetUser(out oNewUser, _connectionServer, ""); Assert.IsFalse(res.Success, "Fetching user with static method with empty objectId did not fail"); res = GlobalUser.GetUser(out oNewUser, null, "bogus"); Assert.IsFalse(res.Success, "Fetching user with static method with null Connection server did not fail"); res = GlobalUser.GetUser(out oNewUser, _connectionServer, "bogus"); Assert.IsFalse(res.Success, "Fetching user with static method with invalid objectId did not fail"); res = GlobalUser.GetUser(out oNewUser, _connectionServer, oUsers[0].ObjectId); Assert.IsTrue(res.Success, "Failed to fetch a user by valid ObjectId:" + res); res = GlobalUser.GetUser(out oNewUser, _connectionServer, "", oUsers[0].Alias); Assert.IsTrue(res.Success, "Failed to fetch a user by valid Alias:" + res); }
public void GlobalUser_GetUsers() { //static method calls List <GlobalUser> oNewUsers; List <GlobalUser> oUsers; WebCallResult res = GlobalUser.GetUsers(_connectionServer, out oUsers, 1, 10); Assert.IsTrue(res.Success, "Failed to fetch global users"); Assert.IsTrue(oUsers.Count > 0, "No global users returned on fetch"); //exercise dump calls Console.WriteLine(oUsers[0].ToString()); Console.WriteLine(oUsers[0].DumpAllProps()); //GetUsers res = GlobalUser.GetUsers(null, out oNewUsers); Assert.IsFalse(res.Success, "Fetching users via static method with null ConnectionServerRest did not fail"); res = GlobalUser.GetUsers(_connectionServer, out oNewUsers, "query=(bogus)", "", "sort=(bogus)"); Assert.IsFalse(res.Success, "Fetching users via static method with invalid query construction did not fail"); string strQuery = string.Format("query=(Alias is {0})", oUsers[0].Alias); res = GlobalUser.GetUsers(_connectionServer, out oNewUsers, strQuery); Assert.IsTrue(res.Success, "Fetching users via static method with valid alias query construction failed"); Assert.IsTrue(oNewUsers.Count == 1, "Fetching users by alias construction did not return single match"); res = GlobalUser.GetUsers(_connectionServer, out oUsers, 1, 20, "query=(ObjectId is Bogus)"); Assert.IsTrue(res.Success, "fetching users with invalid query should not fail:" + res); Assert.IsTrue(oUsers.Count == 0, "Invalid query string should return an empty user list:" + oUsers.Count); }
public string GetPassword(Guid UserID) { //using (var dataContext = new WorkersInMotionDB()) //{ // return (from p in dataContext.GlobalUsers // where p.UserGUID == UserID // select p.Password).FirstOrDefault(); //} SqlParameter[] Param = new SqlParameter[1]; Param[0] = new SqlParameter("@pUserGUID", SqlDbType.UniqueIdentifier); Param[0].Value = UserID; GlobalUser user = context.Database.SqlQuery <GlobalUser>("Select * from GlobalUsers where UserGUID=@pUserGUID", Param).FirstOrDefault(); if (user != null) { return(user.Password); } else { return(string.Empty); } }
public IActionResult Login(string username, string pass) { if (username != null && pass != null) { // Comon.Global.DetectSettingAbosulute(); GlobalUser user = new GlobalUser(); int resulf = user.DetectAuthorisedClient(username.Replace("'", "").Trim(), pass.Replace("'", "").Trim()); if (resulf != 0) { if (string.IsNullOrEmpty(HttpContext.Session.GetString(GlobalClient.CustomerID))) { HttpContext.Session.SetInt32(GlobalClient.CustomerID, resulf); } //return RedirectToAction("Index", "ServiceDetail", new { Type = 27 }); return(RedirectToAction("Index", "Main")); } else { //string Status = "Wrong username password"; //ViewBag.Status = Status; return(View("~/Views/Clients/SignIn/SignInView.cshtml")); } } return(View()); }
public void GetUser_Alias_Failure() { GlobalUser oGlobalUser; var res = GlobalUser.GetUser(out oGlobalUser, _mockServer, "", "bogus alias"); Assert.IsFalse(res.Success, "Calling GetUser with invalid alias did not fail:"); }
internal override void Update(PresenceModel model) { Presence ??= new SocketPresence(); Presence.Update(model); GlobalUser.Update(model); }
public void GetUser_EmptyAliasAndObjectId_Failure() { GlobalUser oGlobalUser; var res = GlobalUser.GetUser(out oGlobalUser, _mockServer, ""); Assert.IsFalse(res.Success, "Calling GetUser with empty alias and ObjectId server should fail"); }
public void GetUser_NullConnectionServer_Failure() { GlobalUser oGlobalUser; var res = GlobalUser.GetUser(out oGlobalUser, null, "ObjectId", "Alias"); Assert.IsFalse(res.Success, "Calling GetUser with null Connection server should fail"); }
public void GetUsers_NullConnectionServer_EmptyClause_Failure() { List <GlobalUser> oUsers; var res = GlobalUser.GetUsers(null, out oUsers, 1, 10, ""); Assert.IsFalse(res.Success, "Calling GetUsers with null Connection server should fail"); }
public void Constructor_Success() { GlobalUser oTest = new GlobalUser(_mockServer); Console.WriteLine(oTest.ToString()); Console.WriteLine(oTest.DumpAllProps()); }
public void GetUser_ObjectId_Success() { Reset(); GlobalUser oGlobalUser; var res = GlobalUser.GetUser(out oGlobalUser, _mockServer, Guid.NewGuid().ToString()); Assert.IsTrue(res.Success, "Calling GetUser with objectId failed:" + res); }
public void Create(GlobalUser user) { using (var db = new GlobalUserContext()) { db.Add(user); db.SaveChanges(); } }
private void TestRetrieveExistingGlobalUser(GlobalUser expectedUser) { Assert.True(globalUserRepository.ExistsById(expectedUser.Id)); var actualUser = globalUserRepository.GetById(expectedUser.Id); Assert.AreEqual(expectedUser.Reputation, actualUser.Reputation); }
private void TestCreateNonExistentGlobalUser(GlobalUser newUser) { Assert.False(globalUserRepository.ExistsById(newUser.Id)); globalUserRepository.Create(newUser); Assert.True(globalUserRepository.ExistsById(newUser.Id)); }
// // GET: /Cart/ public ActionResult Index() { var productList = _productBusiness.GetListWT(); var assignedProductList = new List <AddToCart>(); var currentUserId = Convert.ToInt32(GlobalUser.getGlobalUser().UserId); if (currentUserId > 0) { assignedProductList = _AddToCartBusiness.GetListWT(c => c.UserId == currentUserId); } else { CookieStore mycookie = new CookieStore(); var products = mycookie.GetCookie(Enumerator.CustomerAction.AddToCart.ToString()); if (!string.IsNullOrEmpty(products)) { assignedProductList = (from p in products.Split(',') select new AddToCart { ProductId = Convert.ToInt32(p.Split('~')[0]), Quantity = Convert.ToInt32(p.Split('~')[1]), Size = Convert.ToInt32(p.Split('~')[2]), Attributes = p.Split('~')[3] }).ToList(); } } var imgList = _ImageBusiness.GetListWT(); var vmProductList = (from c in productList join ap in assignedProductList on c.ProductID equals ap.ProductId select new CartWishlistViewModel { ProductID = c.ProductID, ProductCode = c.ProductCode, ProductName = c.ProductName, TokenKey = c.TokenKey, ShortDescription = c.ShortDescription, Price = _productBusiness.GetSelectedPrice(c.ProductID, ap.Size.Value, ap.Attributes), DiscountPercent = c.DiscountPercent, DiscountedPrice = Math.Round(_productBusiness.GetSelectedPrice(c.ProductID, ap.Size.Value, ap.Attributes) - Decimal.Divide(c.DiscountPercent ?? 0, 100) * _productBusiness.GetSelectedPrice(c.ProductID, ap.Size.Value, ap.Attributes)), SizeId = ap.Size.Value, Size = _productBusiness.GetSizeName(c.ProductID, ap.Size.Value), AttributeId = ap.Attributes, Attributes = _productBusiness.GetAttributes(c.ProductID, ap.Attributes), quantity = ap.Quantity, ImageList = (from il in imgList where (il.ProductId == c.ProductID) select new ImageViewModel { ProductId = c.ProductID, Images = "/ProductImage/" + il.Images }).ToList() }).ToList(); return(View(vmProductList)); }
public void GlobalUser_Test() { _errorString = ""; List <GlobalUser> oGlobalUsers; var res = GlobalUser.GetUsers(_connectionServer, out oGlobalUsers, 1, 2); Assert.IsTrue(res.Success, "Failed to fetch global users:" + res); Assert.IsTrue(string.IsNullOrEmpty(_errorString), "Error parsing Json for global users:" + _errorString); }
//public void DeleteGlobalUserByOrganizationGUID(Guid OrganizationGUID) //{ // List<OrganizationUsersMap> OrganizationUserMapList = new List<OrganizationUsersMap>(); // using (var dataContext = new WorkersInMotionDB()) // { // OrganizationUserMapList = (from p in dataContext.OrganizationUsersMaps // where p.OrganizationGUID == OrganizationGUID // select p).ToList(); // if (OrganizationUserMapList != null) // { // foreach (OrganizationUsersMap item in OrganizationUserMapList) // { // var GlobalUser = (from p in dataContext.GlobalUsers // where p.UserGUID == item.UserGUID // select p).FirstOrDefault(); // if (GlobalUser != null) // { // dataContext.GlobalUsers.Remove(GlobalUser); // dataContext.SaveChanges(); // } // } // } // } //} public int UpdateGlobalUser(GlobalUser globaluser) { //context.Entry(globaluser).State = EntityState.Modified; //using (var dataContext = new WorkersInMotionDB()) //{ // // var qry = from p in dataContext.MasterLogin where p.UserGUID == globaluser.UserGUID select p; // // if (qry != null && qry.Count() > 0) // // { // // var item = qry.Single(); // // item.UserType = GetRole(globaluser.Role_Id).UserType; // // item.RegionGUID = globaluser.RegionGUID; // // item.TerritoryGUID = globaluser.TerritoryGUID; // // item.GroupGUID = globaluser.GroupGUID; // // dataContext.SaveChanges(); // // } //} SqlParameter[] Param = new SqlParameter[16]; Param[0] = new SqlParameter("@pUserGUID", SqlDbType.UniqueIdentifier); Param[0].Value = globaluser.UserGUID; Param[1] = new SqlParameter("@pUserName", SqlDbType.NVarChar, -1); Param[1].Value = globaluser.UserName; Param[2] = new SqlParameter("@pPassword", SqlDbType.NVarChar, -1); Param[2].Value = globaluser.Password; Param[3] = new SqlParameter("@pRole_Id", SqlDbType.NVarChar, 128); Param[3].Value = (object)globaluser.Role_Id ?? DBNull.Value; Param[4] = new SqlParameter("@pIsActive", SqlDbType.Bit); Param[4].Value = (object)globaluser.IsActive ?? DBNull.Value; Param[5] = new SqlParameter("@pReportingPlaceType", SqlDbType.Int); Param[5].Value = (object)globaluser.ReportingPlaceType ?? DBNull.Value; Param[6] = new SqlParameter("@pReportPlaceGUID", SqlDbType.UniqueIdentifier); Param[6].Value = (object)globaluser.ReportPlaceGUID ?? DBNull.Value; Param[7] = new SqlParameter("@pIsExempt", SqlDbType.Bit); Param[7].Value = (object)globaluser.IsExempt ?? DBNull.Value; Param[8] = new SqlParameter("@pIsDelete", SqlDbType.Bit); Param[8].Value = (object)globaluser.IsDelete ?? DBNull.Value; Param[9] = new SqlParameter("@pLatitude", SqlDbType.Float); Param[9].Value = (object)globaluser.Latitude ?? DBNull.Value; Param[10] = new SqlParameter("@pLongitude", SqlDbType.Float); Param[10].Value = (object)globaluser.Longitude ?? DBNull.Value; Param[11] = new SqlParameter("@pCreateDate", SqlDbType.DateTime); Param[11].Value = (object)globaluser.CreateDate ?? DBNull.Value; Param[12] = new SqlParameter("@pCreateBy", SqlDbType.UniqueIdentifier); Param[12].Value = (object)globaluser.CreateBy ?? DBNull.Value; Param[13] = new SqlParameter("@pLastModifiedDate", SqlDbType.DateTime); Param[13].Value = (object)globaluser.LastModifiedDate ?? DBNull.Value; Param[14] = new SqlParameter("@pLastModifiedBy", SqlDbType.UniqueIdentifier); Param[14].Value = (object)globaluser.LastModifiedBy ?? DBNull.Value; Param[15] = new SqlParameter("@pUSERID", SqlDbType.NVarChar, 50); Param[15].Value = (object)globaluser.USERID ?? DBNull.Value; return(context.Database.ExecuteSqlCommand("Update GlobalUsers set UserName=@pUserName,Password=@pPassword,Role_Id=@pRole_Id,IsActive=@pIsActive,ReportingPlaceType=@pReportingPlaceType,ReportPlaceGUID=@pReportPlaceGUID," + "IsExempt=@pIsExempt,IsDelete=@pIsDelete,Latitude=@pLatitude,Longitude=@pLongitude,CreateDate=@pCreateDate,CreateBy=@pCreateBy,LastModifiedDate=@pLastModifiedDate,LastModifiedBy=@pLastModifiedBy,USERID=@pUSERID where UserGUID=@pUserGUID", Param)); }
public FaUserInfoRelative UserInfoRelative(ref ErrorInfo err, ApiRequesEntityBean <FaUserInfoRelative> inEnt) { GlobalUser gu = Global.GetUser(inEnt.authToken); if (gu == null) { err.IsError = true; err.Message = "登录超时"; return(null); } FaUserInfoRelative reEnt = new FaUserInfoRelative(); using (DBEntities db = new DBEntities()) { var userInfo = db.fa_user_info.SingleOrDefault(x => x.ID == inEnt.id); if (userInfo == null) { err.IsError = true; err.Message = "用户ID有误"; return(null); } var tmpXY = AddSonItem(reEnt.ItemList, userInfo, 1, 6, new XYZ { X = 0, Y = 0, Z = 0 }); var nowInfo = InfoToItem(userInfo, (tmpXY[0] + tmpXY[1]) / 2, 0); reEnt.ItemList.Add(nowInfo); AddFatherItem(reEnt.ItemList, userInfo, 1, 2, new XYZ { X = nowInfo.x, Y = nowInfo.y, Z = userInfo.fa_user_info1.Count() }, tmpXY[0], tmpXY[1]); var minX = reEnt.ItemList.Min(x => x.x); var minY = reEnt.ItemList.Max(x => x.y); minY = -minY; if (minX > 0) { minX = 0; } if (minY > 0) { minY = 0; } foreach (var item in reEnt.ItemList) { item.y = -item.y; item.y = item.y - minY; item.x = item.x - minX; } reEnt.RelativeList = reEnt.ItemList.Where(x => x.FatherId != null).Select(x => new KV { K = x.Id.ToString(), V = x.FatherId.ToString() }).ToList(); return(reEnt); } }
public void RetrieveTestUserFromTestDatabase() { var expectedUser = new GlobalUser { Id = TestConstants.TestUserId, Reputation = 28 }; TestRetrieveExistingGlobalUser(expectedUser); }
public void CreateAndRetrieveGlobalUserTest() { var expectedUser = new GlobalUser { Id = 100, Reputation = 456 }; TestCreateNonExistentGlobalUser(expectedUser); TestRetrieveExistingGlobalUser(expectedUser); }
public ErrorInfo UserInfoDelete(ref ErrorInfo err, ApiRequesEntityBean <ErrorInfo> inEnt) { GlobalUser gu = Global.GetUser(inEnt.authToken); if (gu == null) { err.IsError = true; err.Message = "登录超时"; return(null); } if (inEnt.id == 0) { err.IsError = true; err.Message = "参数有误"; return(null); } //调用用户保存 using (DBEntities db = new DBEntities()) { var userInfo = db.fa_user_info.SingleOrDefault(x => x.ID == inEnt.id); if (userInfo == null) { err.IsError = true; err.Message = "用户不存在"; return(null); } if (userInfo.fa_user_info1.Count() > 0) { err.IsError = true; err.Message = "该用户已有子女,不能删除"; return(null); } if (userInfo.fa_user != null) { userInfo.fa_user.fa_district1.Clear(); userInfo.fa_user.fa_module.Clear(); userInfo.fa_user.fa_role.Clear(); userInfo.fa_user.fa_user_info1.Clear(); db.fa_user.Remove(userInfo.fa_user); } userInfo.fa_user1.Clear(); foreach (var t in userInfo.fa_user_event.ToList()) { db.fa_user_event.Remove(t); } db.fa_user_info.Remove(userInfo); Fun.DBEntitiesCommit(db, ref err); return(err); } }