/// <summary> /// 执行加载 /// </summary> /// <param name="pDataRow">ETCL数据项</param> /// <param name="pUserInfo">用户信息</param> /// <param name="oResult">抽取结果详情</param> /// <param name="pTran">数据库事务</param> /// <returns>TRUE:抽取成功,FALSE:抽取失败。</returns> public bool Process(IETCLDataItem[] pDataRow, BasicUserInfo pUserInfo, out IETCLResultItem[] oResult, IDbTransaction pTran) { bool isPass = true; List <ETCLCommonResultItem> lstDuplicateCell = new List <ETCLCommonResultItem>(); CommonExcelDataItem[] excelDataItems = (CommonExcelDataItem[])pDataRow; foreach (var entityItem in excelDataItems) { try { object oQueryResult = Reflection.DynamicReflectionHandler.CreateEntity(entityItem.Table, new object[] { pUserInfo }, entityItem.Entity, pTran); } catch (Exception ex) { Loggers.Exception(new ExceptionLogInfo(ex)); isPass = false; ETCLCommonResultItem result = new ETCLCommonResultItem(); result.OPType = OperationType.CreateEntity; result.TableIndex = entityItem.Table.Index.Value; result.RowIndex = entityItem.Index.Value; result.Message = string.Format("[实体创建失败(添加到数据库表).]."); lstDuplicateCell.Add(result); } } oResult = lstDuplicateCell.ToArray(); return(isPass); }
public async void ShowInfo() { StorageFolder storageFolder = ApplicationData.Current.LocalFolder; StorageFile sampleFile = await storageFolder.GetFileAsync("CurrentUser.txt"); string jsonCurrentUser = await FileIO.ReadTextAsync(sampleFile); BasicUserInfo currentUser = JsonConvert.DeserializeObject <BasicUserInfo>(jsonCurrentUser); if (currentUser != null) { HttpClient httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", currentUser.token); var response = httpClient.GetAsync(Sevices.Link.API_GET_INFO); var contents = await response.Result.Content.ReadAsStringAsync(); Member memberInfo = JsonConvert.DeserializeObject <Member>(contents); UserName.Text = memberInfo.firstName + " " + memberInfo.lastName; UserEmail.Text = memberInfo.email; UserAddress.Text = memberInfo.address; UserBirthday.Text = memberInfo.birthday; UserPhone.Text = memberInfo.phone; Uri avatarUri = new Uri(memberInfo.avatar, UriKind.Absolute); BitmapImage bmImage = new BitmapImage(avatarUri); UserAvatar.Source = bmImage; //UserGender.Text = memberInfo.gender.ToString(); UserIntroduction.Text = memberInfo.introduction; } }
/// <summary> /// 添加需要缓存的对象() /// </summary> /// <param name="pUserInfo">用户信息</param> /// <param name="pKey">缓存项的键值</param> /// <param name="pCachedItem">被缓存的对象</param> public void AddOrReplace(BasicUserInfo pUserInfo, string pKey, object pCachedObject) { CACHE_PROVIDER.Set(pKey, pCachedObject, new CacheItemPolicy() { Priority = CacheItemPriority.Default, AbsoluteExpiration = DateTimeOffset.Now.AddMinutes(5), SlidingExpiration = TimeSpan.Zero }); }
public virtual ReturnInfo <IList <string> > Upload(BasicUserInfo <int> currUser = null, params AttachmentStreamInfo[] attachmentStream) { // 以当前年月为目录 string yearMonthDic = $"{DateTime.Now.ToCompactShortYM()}/"; string dic = $"{FileRoot}{yearMonthDic}"; lock (syncCreateRoot) { dic.CreateNotExistsDirectory(); } ReturnInfo <IList <string> > returnInfo = new ReturnInfo <IList <string> >(); returnInfo.Data = new List <string>(attachmentStream.Length); try { foreach (var attStream in attachmentStream) { string expandName = attStream.FileName.FileExpandName(); string newFileName = $"{StringUtil.NewShortGuid()}{expandName}"; $"{dic}{newFileName}".WriteFile(attStream.Stream); returnInfo.Data.Add($"{AppConfig["Attachment:DownloadRoot"]}{yearMonthDic}{newFileName}"); } } catch (Exception ex) { Log.ErrorAsync(ex.Message, ex, this.GetType().FullName); returnInfo.SetFailureMsg(ex.Message, ex.StackTrace, ex); } return(returnInfo); }
/// <summary> /// 添加用户角色 /// </summary> /// <param name="model">模型</param> /// <param name="connectionId">连接ID</param> /// <param name="currUser">当前用户</param> private void AddUserRoles(UserInfo model, string connectionId = null, BasicUserInfo currUser = null) { if (model.OwnRoles.IsNullOrCount0()) { return; } IList <UserRoleInfo> userRoles = new List <UserRoleInfo>(model.OwnRoles.Count); foreach (RoleInfo r in model.OwnRoles) { UserRoleInfo ur = new UserRoleInfo() { UserId = model.Id, RoleId = r.Id }; ur.SetCreateInfo(currUser); userRoles.Add(ur); } if (userRoles.IsNullOrCount0()) { return; } UserRolePersistence.Insert(userRoles, connectionId); }
internal async Task <Activity> GetActivity(AuditRecord audit, ApplicationUser user) { var avatar = user.Avatar; if (!GenericAvatarConstructor.IsGenericAvatar(avatar) && _s3Service.CheckIfPresignedUrlIsExpired(avatar)) { avatar = await _s3Service.GetPresignedUrlAsync(avatar); } var userInfo = new BasicUserInfo { UserId = audit.UserId, UserAvatar = avatar, UserName = user.FullName, }; var activityInfo = new BasicActivityInfo() { Id = audit.Id, Date = audit.Date, Type = (ActivityType)Enum.Parse(typeof(ActivityType), audit.EntityType, true), JsonEntity = await _activityService.GetEntityAsJson(audit), Seen = audit.Seen }; return(new Activity(userInfo, activityInfo)); }
public static async Task <string> CreateSfsSession(LoginContext loginContext, string ipAddress, string userAccessToken) { using (var connection = GetMysqlConnection()) { var userLoginId = loginContext.GenerateAppScopedLoginId(); User matchedExistingUser = await GetUser(userLoginId); if (matchedExistingUser == null || !matchedExistingUser.BasicUserInfo.IsRecent()) { var userInfoFacebook = await Facebook.GetUserProfileInfo(loginContext.UserId, userAccessToken); var basicUserInfo = BasicUserInfo.CreateFromUserProfileInfo(userInfoFacebook); await UpdateBasicUserInfo(basicUserInfo, userLoginId, userAccessToken, matchedExistingUser == null); } string cmdText = $"INSERT INTO user_sessions (user_login_id, session_token, ip_address, date_created) VALUES (@userLoginId, @sessionToken, @ipAddress, @dateCreated)"; var cmd = new MySqlCommand(cmdText, connection); cmd.Parameters.AddWithValue("@userLoginId", userLoginId); var sessionToken = Guid.NewGuid().ToString(); cmd.Parameters.AddWithValue("@sessionToken", sessionToken); cmd.Parameters.AddWithValue("@ipAddress", ipAddress); cmd.Parameters.AddWithValue("@dateCreated", Utilities.GetSQLFormattedDateTime(DateTime.Now)); var affectedRows = await cmd.ExecuteNonQueryAsync(); if (affectedRows == 0) { throw new Exception("Could not create a game session. Please try again."); } return(sessionToken); } }
public static async Task UpdateBasicUserInfo(BasicUserInfo basicUserInfo, string userLoginId, string userAccessToken, bool isNewUser) { using (var connection = GetMysqlConnection()) { string cmdText = null; if (isNewUser) { cmdText = $"INSERT INTO users (user_login_id, country, email_id, profile_pic_url, display_name, user_access_token, info_updated_date) VALUES (@userLoginId, @country, @emailId, @profilePicUrl, @displayName, @userAccessToken, @infoUpdatedDate)"; } else { cmdText = $"UPDATE users SET country = @country, email_id = @emailId, profile_pic_url = @profilePicUrl, display_name = @displayName, user_access_token = @userAccessToken, info_updated_date = @infoUpdatedDate WHERE user_login_id = @userLoginId"; } var cmd = new MySqlCommand(cmdText, connection); cmd.Parameters.AddWithValue("@userLoginId", userLoginId); cmd.Parameters.AddWithValue("@country", basicUserInfo.Country); cmd.Parameters.AddWithValue("@emailId", basicUserInfo.EmailId); cmd.Parameters.AddWithValue("@profilePicUrl", basicUserInfo.ProfilePicUrl); cmd.Parameters.AddWithValue("@displayName", basicUserInfo.DisplayName); cmd.Parameters.AddWithValue("@userAccessToken", userAccessToken); cmd.Parameters.AddWithValue("@infoUpdatedDate", Utilities.GetSQLFormattedDateTime(DateTime.Now)); var affectedRows = await cmd.ExecuteNonQueryAsync(); if (affectedRows == 0) { throw new Exception("Could not update user's basic info in database."); } } }
public static async Task <string> CreateGuestSfsSession(LoginContext loginContext, string ipAddress) { using (var connection = GetMysqlConnection()) { var userLoginId = loginContext.GenerateAppScopedLoginId(); var basicUserInfo = BasicUserInfo.CreateGuestBasicUserInfo(); await UpdateBasicUserInfo(basicUserInfo, userLoginId, string.Empty, true); string cmdText = $"INSERT INTO user_sessions (user_login_id, session_token, ip_address, date_created) VALUES (@userLoginId, @sessionToken, @ipAddress, @dateCreated)"; var cmd = new MySqlCommand(cmdText, connection); cmd.Parameters.AddWithValue("@userLoginId", userLoginId); var sessionToken = Guid.NewGuid().ToString(); cmd.Parameters.AddWithValue("@sessionToken", sessionToken); cmd.Parameters.AddWithValue("@ipAddress", ipAddress); cmd.Parameters.AddWithValue("@dateCreated", Utilities.GetSQLFormattedDateTime(DateTime.Now)); var affectedRows = await cmd.ExecuteNonQueryAsync(); if (affectedRows == 0) { throw new Exception("Could not create a game session. Please try again."); } return(sessionToken); } }
private void LoadAvaliableRealExts(ObjectItem parentItem, string parentID) { try { WebRequest webRequest = new WebRequest(); webRequest.Session = CurrentApp.Session; webRequest.Code = (int)S1101Codes.GetControlRealExtensionInfoList; webRequest.ListData.Add(CurrentApp.Session.UserID.ToString()); webRequest.ListData.Add(parentID); //Service11011Client client = new Service11011Client(); Service11011Client client = new Service11011Client( WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress( CurrentApp.Session.AppServerInfo, "Service11011")); WebHelper.SetServiceClient(client); WebReturn webReturn = client.DoOperation(webRequest); client.Close(); if (!webReturn.Result) { ShowException(string.Format("InitControlExtension 1 Fail.\t{0}\t{1}", webReturn.Code, webReturn.Message)); return; } if (webReturn.ListData == null) { ShowException(string.Format("Fail.\tListData is null")); return; } //List<ObjectItem> listChild = new List<ObjectItem>(); for (int i = 0; i < webReturn.ListData.Count; i++) { OperationReturn optReturn = XMLHelper.DeserializeObject <BasicUserInfo>(webReturn.ListData[i]); if (!optReturn.Result) { ShowException(string.Format("InitControlExtension Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message)); return; } BasicUserInfo ExtensionInfo = optReturn.Data as BasicUserInfo; if (ExtensionInfo.IsDeleted == "0") { ObjectItem item = new ObjectItem(); item.ObjType = S1101Consts.OBJTYPE_REALEXTENSION; item.ObjID = ExtensionInfo.UserID; item.Icon = "Images/RealExtension.ico"; item.Name = ExtensionInfo.Account; item.FullName = ExtensionInfo.FullName; item.Description = ExtensionInfo.FullName; item.Data = ExtensionInfo; //listChild.Add(item); Dispatcher.Invoke(new Action(() => parentItem.AddChild(item))); mListObjectItems.Add(item); } } } catch (Exception ex) { ShowException(ex.Message); } }
// GET: /Pusher/Auth public ContentResult Auth(string username) { // Connect to Pusher REST API var provider = new PusherProvider(SETTING_PUSHER_APPID, SETTING_PUSHER_KEY, SETTING_PUSHER_SECRET); string result = null; // Gather channel name and socket id string channel_name = Request.Form["channel_name"]; string socket_id = Request.Form["socket_id"]; // If presence channel if (channel_name.StartsWith("presence-")) { var userInfo = new BasicUserInfo(); userInfo.name = username; result = provider.Authenticate(channel_name, socket_id, new PusherRESTDotNet.Authentication.PresenceChannelData() { user_id = socket_id, user_info = userInfo }); } // If private channel else if (channel_name.StartsWith("private-")) { result = provider.Authenticate(channel_name, socket_id); } return(new ContentResult() { Content = result }); }
/// <summary> /// 异常日志信息 /// </summary> /// <param name="pUserInfo">当前用户信息</param> /// <param name="pException">异常信息</param> public ExceptionLogInfo(BasicUserInfo pUserInfo, Exception pException) { if (pUserInfo != null) { this.ClientID = pUserInfo.ClientID; this.UserID = pUserInfo.UserID; } this.Init(pException); }
public BasicUserInfo GetUserInfo() { BasicUserInfo user = new BasicUserInfo() { ClientID = this.ClientID, UserID = this.UserID }; return(user); }
private string GetEventAppliesSql2(string EventID) { BasicUserInfo pUserInfo = new BasicUserInfo(); string sql = ""; sql += "SELECT distinct a.userId ,a.eventId " + " into #tmp FROM WEventUserMapping a " + " where a.IsDelete='0' and a.EventID = '" + EventID + "' "; return(sql); }
public async Task <ActionResult <UpdateUserResponse> > UpdateUser(BasicUserInfo userData) { string currentUserId = HttpContext.User.Claims.FirstOrDefault(x => x.Type == JwtRegisteredClaimNames.Sub)?.Value; if (userData.Id != currentUserId) { return(Unauthorized()); } return(await _userService.UpdateUserAsync(userData)); }
private string GetEventAppliesSql(string EventID) { BasicUserInfo pUserInfo = new BasicUserInfo(); string sql = ""; sql += "SELECT a.* " + " ,DisplayIndex = row_number() over(order by a.UserName ) " + " into #tmp FROM WEventUserMapping a " + " where a.IsDelete='0' and a.EventID = '" + EventID + "' "; return(sql); }
/// <summary> /// 设置创建信息 /// </summary> /// <typeparam name="IdT">ID类型</typeparam> /// <param name="model">模型</param> /// <param name="currUser">当前用户</param> public static void SetCreateInfo <IdT>(this PersonTimeInfo <IdT> model, BasicUserInfo <IdT> currUser = null) { var user = UserTool <IdT> .GetCurrUser(currUser); if (user == null) { return; } model.CreaterId = model.ModifierId = user.Id; model.Creater = model.Modifier = user.Name; model.CreateTime = model.ModifyTime = DateTime.Now; }
private string GetEventPrizesSql(string EventID) { BasicUserInfo pUserInfo = new BasicUserInfo(); string sql = ""; sql += "SELECT a.* " + " ,DisplayIndexLast = row_number() over(order by a.DisplayIndex ) " + " into #tmp FROM LPrizes a " + " where a.IsDelete='0' and a.EventID = '" + EventID + "' "; //sql += " order by a.DisplayIndex "; return(sql); }
/// <summary> /// 设置修改信息 /// </summary> /// <param name="model">模型</param> /// <param name="currUser">当前用户</param> public static void SetModifyInfo(this PersonTimeInfo model, BasicUserInfo currUser = null) { var user = UserTool.GetCurrUser(currUser); if (user == null) { return; } model.ModifierId = user.Id; model.Modifier = user.Name; model.ModifyTime = DateTime.Now; }
private string GetEventLotteryLogSql(string EventID) { BasicUserInfo pUserInfo = new BasicUserInfo(); string sql = ""; sql += "SELECT a.* " + " ,DisplayIndex = row_number() over(order by a.createTime desc ) " + " ,b.vipName VipName " + " into #tmp FROM LLotteryLog a " + " left join vip b on a.vipId=b.vipId " + " where a.IsDelete='0' and a.EventID = '" + EventID + "' "; return(sql); }
/// <summary> /// 设置会员在线 /// </summary> /// <param name="userInfo"></param> public static void setUserOnline(BasicUserInfo userInfo, int days = 0) { var onlineInfo = getUserOnlineInfo(); if (days > 0) { setKeyExpires(days); } onlineInfo.UserInfo = userInfo; onlineInfo.UserName = userInfo.UserName; onlineInfo.UserId = userInfo.UserId; getOnlineUser = onlineInfo; }
private void LoadUserControledRoles() { if (UserItem == null) { return; } BasicUserInfo userInfo = UserItem.Data as BasicUserInfo; if (userInfo == null) { return; } Dispatcher.Invoke(new Action(() => mUserRoles.Clear())); try { WebRequest webRequest = new WebRequest(); webRequest.Session = CurrentApp.Session; webRequest.Code = (int)S1101Codes.GetUserRoleList; webRequest.ListData.Add("-1"); webRequest.ListData.Add(userInfo.UserID.ToString()); Service11011Client client = new Service11011Client( WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service11011")); WebHelper.SetServiceClient(client); WebReturn webReturn = client.DoOperation(webRequest); client.Close(); if (!webReturn.Result) { ShowException(string.Format("{0}\t{1}", webReturn.Code, webReturn.Message)); return; } for (int i = 0; i < webReturn.ListData.Count; i++) { string roleID = webReturn.ListData[i]; if (string.IsNullOrEmpty(roleID)) { ShowException(string.Format("RoleID invalid.\t{0}", roleID)); return; } mUserRoles.Add(roleID); } } catch (Exception ex) { ShowException(ex.Message); } }
/// <summary> /// 根据用户信息获取数据库连接字符串 /// </summary> /// <param name="pUserInfo">用户信息</param> /// <returns></returns> public string GetConnectionStringBy(BasicUserInfo pUserInfo) { if (pUserInfo == null) { throw new ArgumentNullException("pUserInfo"); } foreach (var item in this.InnerList) { if (item.ClientID == pUserInfo.ClientID) { return(item.Value); } } return(this.DefaultConnection); }
/// <summary> /// 生成序列号 /// </summary> /// <param name="seqType">序列类型</param> /// <param name="noLength">序列号长度</param> /// <param name="increment">增量</param> /// <param name="currUser">当前用户</param> /// <returns>序列号</returns> public string BuilderNo(string seqType, byte noLength, int increment, BasicUserInfo <int> currUser = null) { string dateStr = DateTime.Now.ToCompactFixedShortDate(); StringBuilder result = new StringBuilder($"{seqType}{dateStr}"); int existsLength = result.Length; int length = noLength - existsLength - increment.ToString().Length; for (var i = 0; i < length; i++) { result.Append("0"); } result.Append(increment.ToString()); return(result.ToString()); }
public ActionResult UserBasicInfo(string userName) { var userRegistrationDateTime = UserHelper.GetUserRegistrationDateTime(userName); var memberFor = Submissions.CalcSubmissionAge(userRegistrationDateTime); var scp = Karma.LinkKarma(userName); var ccp = Karma.CommentKarma(userName); var userInfoModel = new BasicUserInfo() { MemberSince = memberFor, Ccp = ccp, Scp = scp }; return(PartialView("~/Views/AjaxViews/_BasicUserInfo.cshtml", userInfoModel)); }
private void LoadControledObject() { Dispatcher.Invoke(new Action(() => mListUserObjects.Clear())); try { if (UserItem == null) { return; } BasicUserInfo userInfo = UserItem.Data as BasicUserInfo; if (userInfo == null) { return; } WebRequest webRequest = new WebRequest(); webRequest.Session = CurrentApp.Session; webRequest.Code = (int)RequestCode.WSGetUserObjList; webRequest.ListData.Add(userInfo.UserID.ToString()); webRequest.ListData.Add("1"); string strType = string.Format("{0}{1}{2}{1}{3}{1}{4}{1}{5}", ConstValue.RESOURCE_ORG, ConstValue.SPLITER_CHAR, ConstValue.RESOURCE_USER, ConstValue.RESOURCE_AGENT, ConstValue.RESOURCE_EXTENSION, ConstValue.RESOURCE_REALEXT); webRequest.ListData.Add(strType); webRequest.ListData.Add(string.Empty); Service11012Client client = new Service11012Client( WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service11012")); WebHelper.SetServiceClient(client); WebReturn webReturn = client.DoOperation(webRequest); client.Close(); if (!webReturn.Result) { ShowException(string.Format("{0}\t{1}", webReturn.Code, webReturn.Message)); return; } for (int i = 0; i < webReturn.ListData.Count; i++) { string objID = webReturn.ListData[i]; mListUserObjects.Add(objID); } } catch (Exception ex) { ShowException(ex.Message); } }
/// <summary> /// 根据归属类型读取附件归属信息 /// </summary> /// <param name="type">归属类型</param> /// <param name="currUser">当前用户</param> /// <returns>附件归属信息</returns> public AttachmentOwnerInfo ReaderByOwnerType(short type, BasicUserInfo currUser = null) { if (dicCache.ContainsKey(type)) { return(dicCache[type]); } AttachmentOwnerInfo AttachmentOwnerInfo = ProtoAttachmentOwnerReader.ReaderByOwnerType(type, currUser); if (AttachmentOwnerInfo == null) { return(null); } Add(type, AttachmentOwnerInfo); return(AttachmentOwnerInfo); }
//// GET: subverse basic info used for V2 sets layout //public ActionResult SubverseBasicInfo(int setId, string subverseName) //{ // var userSetDefinition = _db.UserSetLists.FirstOrDefault(s => s.UserSetID == setId && s.Subverse.Equals(subverseName, StringComparison.OrdinalIgnoreCase)); // return PartialView("~/Views/AjaxViews/_SubverseInfo.cshtml", userSetDefinition); //} // GET: basic info about a user //[OutputCache(Duration = 600, VaryByParam = "*")] public ActionResult UserBasicInfo(string userName) { //acceptable constructor call var userData = new Domain.UserData(userName); var info = userData.Information; var memberFor = Age.ToRelative(info.RegistrationDate); var scp = info.SubmissionPoints.Sum; var ccp = info.CommentPoints.Sum; var userInfoModel = new BasicUserInfo() { MemberSince = memberFor, Ccp = ccp, Scp = scp, Bio = info.Bio }; return(PartialView("~/Views/AjaxViews/_BasicUserInfo.cshtml", userInfoModel)); }
/// <summary> /// 移除 /// </summary> /// <param name="currUser">当前用户</param> /// <param name="fileAddress">文件地址</param> /// <returns>返回信息</returns> public virtual ReturnInfo <bool> Remove(BasicUserInfo <int> currUser = null, params string[] fileAddress) { ReturnInfo <bool> returnInfo = new ReturnInfo <bool>(); try { foreach (string f in fileAddress) { // 替换虚拟路径 string newF = f.Replace(AppConfig["Attachment:DownloadRoot"], null); $"{FileRoot}{newF}".DeleteFile(); } } catch (Exception ex) { Log.ErrorAsync(ex.Message, ex, this.GetType().FullName); returnInfo.SetFailureMsg(ex.Message, ex.StackTrace, ex); } return(returnInfo); }
public BaseCPOSDAO(LoggingSessionInfo userInfo) : base(userInfo, new DirectConnectionStringManager(null)) { bool pIsLoggingTSQL = true; // Base.ConfigInfo.IsLoggingTSQL; BasicUserInfo pUserInfo = new BasicUserInfo(); pUserInfo.ClientID = null; pUserInfo.UserID = null; var connectionString = userInfo.CurrentLoggingManager.Connection_String; var sqlHelper = new DefaultSQLHelper(connectionString); sqlHelper.CurrentUserInfo = pUserInfo; this.SQLHelper = sqlHelper; if (pIsLoggingTSQL) { //给数据访问助手挂载执行完毕事件,以记录所有执行的SQL this.SQLHelper.OnExecuted += new EventHandler <SqlCommandExecutionEventArgs>(SQLHelper_OnExecuted); } }