private static async Task ReceiveMessage(HttpContext context, dynamic obj) { var uid = context.LoginId(); int id = int.Parse(obj.id.ToString()); var msg = obj.message.ToString(); using (var c = new WebChat()) { var conv = c.Conversations .Include(co => co.ConversationParticipants) .SingleOrDefault(co => co.Id == id); if (conv != null && conv.ConversationParticipants.Any(cp => cp.UserId == uid)) { var msgObject = new Messages { Conversation = conv, Text = MessageUtils.Reformat(msg), UserId = context.LoginId() }; c.Add(msgObject); c.SaveChanges(); await BroadcastMessage(c, msgObject, uid); } } }
public JsonResult GetConversationMessages(int id) { if (HttpContext.LoginId() > 0) { using (var c = new WebChat()) { var messages = c.Messages .Where(m => m.ConversationId == id) .OrderBy(m => m.Timestamp); var js = new JsonResult(new { messages = messages.Select(m => new { id = m.Id, from = m.User.Nickname, text = m.Text }).ToArray() }); var conv = c.ConversationParticipants.SingleOrDefault(cp => cp.ConversationId == id && cp.UserId == HttpContext.LoginId()); if (conv != null) { conv.SeenMessage = messages.LastOrDefault()?.Id ?? 0; c.SaveChanges(); } return(js); } } return(new JsonResult("")); }
/// <summary> /// Inserta en ChatEMailMessageBE /// </summary> /// <param name="pChatEMailMessageBE">Entidad a insertar</param> /// <returns></returns> public static bool InsertChatEmailMessage(WebChat.Common.BE.ChatEmailMessageBE pChatEMailMessageBE) { ChatUser wChatUser = new ChatUser(); Database database = null; int newId = 0; //try //{ database = DatabaseFactory.CreateDatabase("EpironChat_LogsConnectionString"); using (DbCommand cmd = database.GetStoredProcCommand("[Chat].[ChatEmailMessage_i]")) { database.AddOutParameter(cmd, "ChatEmailMessageId", DbType.Int32, sizeof(Int32)); database.AddInParameter(cmd, "ChatRoomId", DbType.Int32, pChatEMailMessageBE.ChatRoomId); database.AddInParameter(cmd, "EmailFrom", DbType.String, pChatEMailMessageBE.EmailFrom); database.AddInParameter(cmd, "DeliveredTo", DbType.String, pChatEMailMessageBE.DeliveredTo); database.AddInParameter(cmd, "Body", DbType.String, pChatEMailMessageBE.Body); database.AddInParameter(cmd, "ErrorMessage", DbType.String, pChatEMailMessageBE.ErrorMessage); database.AddInParameter(cmd, "Subject", DbType.String, pChatEMailMessageBE.Subject); database.AddInParameter(cmd, "ChatDescription", DbType.String, pChatEMailMessageBE.ChatDescription); database.ExecuteNonQuery(cmd); newId = (int)database.GetParameterValue(cmd, "ChatEmailMessageId"); if (newId > 0) return true; else return false; } //} //catch (Exception ex) //{ // throw SecPortalException.ProcessException(ex, typeof(EpironChatDAC), "EpironChatConnectionString"); //} }
public static async Task BroadcastLogIn(int id) { using (var c = new WebChat()) { var user = c.Users.Single(u => u.Id == id); foreach (var ws in LoginMiddleware.WebSockets.Where(a => a.Value.State == WebSocketState.Open)) { var isFriend = c.Users .Include(u => u.FriendsFriend1Navigation) .Include(u => u.FriendsFriend2Navigation) .First(u => u.Id == ws.Key) .IsFriendWith(user); var msg = JsonConvert.SerializeObject( new { id = user.Id, type = "login", user = user.Nickname, avatar = Convert.ToBase64String(user.Avatar ?? Startup.DefaultAvatar), friend = isFriend }); await ws.Value.SendAsync(Encoding.UTF8.GetBytes(msg), WebSocketMessageType.Text, true, CancellationToken.None); } } }
public async void SetAvatar(IFormFile file) { if (HttpContext.LoginId() > 0) { if (file == null) { return; } if (file.Length > 2097152) { return; } byte[] avatar; using (var stream = new MemoryStream()) { await file.CopyToAsync(stream); avatar = stream.ToArray(); } using (var c = new WebChat()) { var user = c.Users.First(u => u.Id == HttpContext.LoginId()); user.Avatar = avatar; c.SaveChanges(); Console.WriteLine("AVATAR SET"); } } }
public Message(WebChat.Data.tblMessagePool message,HttpContext session) { Talker = message.tblTalker.tblSession.UserAlias; MessageData = message.message; SendTime = message.SendTime; IsFriend = (message.tblTalker.tblSession.SessionID != session.Session.SessionID); }
public RoomTalker(WebChat.Data.tblTalker talker, HttpContext context) { TalkerAlias = talker.tblSession.UserAlias; TalkerIP = talker.tblSession.IP; TalkerSession = talker.tblSession.SessionID; IsFriend = (TalkerSession != context.Session.SessionID); }
public void WebChat_does_not_match_excluded_exact_URL() { _model.PageUrl = new Uri("/contactus/apply/default.htm", UriKind.Relative); var feature = new WebChat() { WebChatSettings = _model }; Assert.False(feature.IsRequired()); }
public void ExactUrlIsMatched() { _model.PageUrl = new Uri("/roadsandtransport/roads/default.htm", UriKind.Relative); var feature = new WebChat() { WebChatSettings = _model }; Assert.IsTrue(feature.IsRequired()); }
public void ExcludedExactUrlIsNotMatched() { _model.PageUrl = new Uri("/contactus/apply/default.htm", UriKind.Relative); var feature = new WebChat() { WebChatSettings = _model }; Assert.IsFalse(feature.IsRequired()); }
public void FolderUrlIsMatched() { _model.PageUrl = new Uri("/contactus/some-section/default.htm", UriKind.Relative); var feature = new WebChat() { WebChatSettings = _model }; Assert.IsTrue(feature.IsRequired()); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected new void Page_Load(object sender, EventArgs e) { // Configure remote master page var httpClientProvider = new HttpClientProvider(new ConfigurationProxyProvider()); var masterPageSettings = new RemoteMasterPageSettingsFromConfig(); var forceCacheRefresh = (Page.Request.QueryString["ForceCacheRefresh"] == "1"); // Provide a way to force an immediate update of the cache var remoteMasterPageClient = new RemoteMasterPageHtmlProvider(masterPageSettings.MasterPageControlUrl(), httpClientProvider, Request.UserAgent, new RemoteMasterPageMemoryCacheProvider { CacheDuration = TimeSpan.FromMinutes(masterPageSettings.CacheTimeout()) }, forceCacheRefresh); this.htmlTag.HtmlControlProvider = remoteMasterPageClient; this.metadataFullScreen.HtmlControlProvider = remoteMasterPageClient; if (this.headerFullScreen != null) { this.headerFullScreen.HtmlControlProvider = remoteMasterPageClient; } this.scriptsFullScreen.HtmlControlProvider = remoteMasterPageClient; // Support web fonts required by the current skin if (Skin != null) { var fontsHtml = new StringBuilder(); foreach (var font in Skin.RequiresGoogleFonts()) { fontsHtml.Append("<link href=\"").Append(font.FontUrl).Append("\" rel=\"stylesheet\" type=\"text/css\" />"); } this.fonts.Text = fontsHtml.ToString(); AddClientDependencies(Skin); } // Support web chat var context = new HostingEnvironmentContext(HttpContext.Current.Request.Url); if (context.WebChatSettingsUrl != null) { var webChat = new WebChat(); var webChatApiSettings = Options.Create(new WebChatApiSettings { WebChatSettingsUrl = context.WebChatSettingsUrl, CacheMinutes = context.WebChatSettingsCacheDuration }); webChat.WebChatSettings = new WebChatSettingsFromApi(webChatApiSettings, httpClientProvider, new ApplicationCacheStrategy <WebChatSettings>()).ReadWebChatSettings().Result; webChat.WebChatSettings.PageUrl = new Uri(Request.Url.AbsolutePath, UriKind.Relative); if (webChat.IsRequired()) { AddClientDependencies(webChat); } } // Run the base method as well base.Page_Load(sender, e); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected new void Page_Load(object sender, EventArgs e) { // Apply selected text size to page var textSize = new TextSize(Request.Cookies, Request.QueryString); int baseTextSize = textSize.CurrentTextSize(); if (baseTextSize > 1) { // Add a space if there are other classes, then add to body tag this.bodyclass.Controls.Add(new LiteralControl(" size" + baseTextSize.ToString(CultureInfo.InvariantCulture))); } // Support web fonts required by the current skin if (Skin != null) { var fontsHtml = new StringBuilder(); foreach (var font in Skin.RequiresGoogleFonts()) { fontsHtml.Append("<link href=\"").Append(font.FontUrl).Append("\" rel=\"stylesheet\" type=\"text/css\" />"); } if (Skin.RequiresTypekitFonts().Any()) { foreach (var font in Skin.RequiresTypekitFonts()) { fontsHtml.Append("<script src=\"").Append(font.TypekitUrl).Append("\"></script>"); } this.Typekit.Visible = true; } this.fonts.Text = fontsHtml.ToString(); AddClientDependencies(Skin); } // Support web chat var context = new HostingEnvironmentContext(); if (context.WebChatSettingsUrl != null) { var webChat = new WebChat(); webChat.WebChatSettings = new WebChatSettingsFromApi(context.WebChatSettingsUrl, new ConfigurationProxyProvider(), new ApplicationCacheStrategy <WebChatSettings>(TimeSpan.FromMinutes(context.WebChatSettingsCacheDuration))).ReadWebChatSettings(); webChat.WebChatSettings.PageUrl = new Uri(Request.Url.AbsolutePath, UriKind.Relative); if (webChat.IsRequired()) { AddClientDependencies(webChat); } } // Run the base method as well base.Page_Load(sender, e); }
private void ChatLogTextBoxKeyDown(Object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.Enter: { if (ChatLogTextBox.Text.Length > 0) { String prefix = ""; if (ChatLogPrefixBox.Text != @"[Blank]") { prefix = ChatLogPrefixBox.Text; } String name = prefix.Replace(":", "").Trim(); String message = String.Format("{0} {1}", prefix, ChatLogTextBox.Text).Trim(); Program.ServerForm.ChatLog.WriteMessage(message, Color.MediumVioletRed); if (name != "") { WebChat.QueueWebChatMessage(new WebChat.WebChatMessage(name, ChatLogTextBox.Text, 2, 0, DateTime.Now.GetUnixTime())); for (Int32 i = 0; i < PlayerManager.Players.Count; i++) { Network.Send(PlayerManager.Players[i], GamePacket.Outgoing.System.DirectTextMessage(PlayerManager.Players[i], message)); } } else { for (Int32 i = 0; i < PlayerManager.Players.Count; i++) { Network.Send(PlayerManager.Players[i], GamePacket.Outgoing.System.DirectTextMessage(PlayerManager.Players[i], String.Format("{0}", message))); } } ChatLogTextBox.Text = ""; } e.Handled = true; e.SuppressKeyPress = true; break; } } }
public JsonResult GetConversationUsers(int id) { if (HttpContext.LoginId() > 0) { using (var c = new WebChat()) { var conv = c.ConversationParticipants.Where(cp => cp.ConversationId == id); var nicknames = conv.Select(cp => cp.User.Nickname); return(new JsonResult(new { nicknames = nicknames.ToArray(), seen = conv.First(cp => cp.UserId == HttpContext.LoginId()).SeenMessage })); } } return(new JsonResult("")); }
public JsonResult GetUserConversation(int id) { if (HttpContext.LoginId() > 0) { using (var c = new WebChat()) { var conv = c.GetConversationBetween( c.Users .Where(u => u.Id == id || u.Id == HttpContext.LoginId() ) ); if (conv == null) { conv = new Conversations(); var p1 = new ConversationParticipants { UserId = HttpContext.LoginId() }; conv.ConversationParticipants.Add(p1); var p2 = new ConversationParticipants { UserId = id }; conv.ConversationParticipants.Add(p2); c.Add(conv); c.SaveChanges(); conv = c.GetConversationBetween( c.Users .Where(u => u.Id == id || u.Id == HttpContext.LoginId() ) ); } return(new JsonResult(new { id = conv.Id })); } } return(new JsonResult("")); }
public JsonResult TryLogin(string name, string password) { using (var c = new WebChat()) { var toLogin = c .Users .Where(u => u.Login.Equals(name) && BCrypt.Net.BCrypt.Verify(password, u.Password) ); if (toLogin.Count() != 1) { return(new JsonResult(new { isLogged = false })); } return(new JsonResult(new { isLogged = HttpContext.LoginId() == 0 && LoginMiddleware.LogUser(HttpContext, toLogin.Single().Id) })); } }
public void Disconnect(WebChat webChat, ChatServices.DisconnectReason reason) { try { var chatId = webChat.ChatId; var connectionId = webChat.ConnectionId; var participantId = webChat.ParticipantId; var previousConnectionIds = webChat.PreviousConnectionIds; if (ChatController.EnableKeepOpenOnDisconnectAndStartNew() && webChat.DateAnswered.HasValue) { if (webChat.Messages.Any() && !ChatServices.DisconnectedWebChats.Any( d => d.ConnectionId == webChat.ConnectionId && (d.PreviousConnectionIds != null && d.PreviousConnectionIds.Contains(webChat.ConnectionId)))) { ChatServices.DisconnectedWebChats.Add(webChat); } } ChatServices.WebChats.Remove(webChat); ChatServices.Disconnect(connectionId, reason); if (previousConnectionIds != null) { foreach (var previousConnectionId in previousConnectionIds) { ChatServices.Disconnect(previousConnectionId, reason, "", true, true); } } ChatServices.EndChat(participantId); var repository = new Repository(); var chat = repository.Chats.Find(chatId); if (chat != null) { chat.DateEnded = DateTime.Now; repository.SaveChanges(); } } catch (Exception e) { } }
public JsonResult AddUserAsFriend(int id) { if (HttpContext.LoginId() > 0) { using (var c = new WebChat()) { var u1 = c.Users.FirstOrDefault(u => u.Id == HttpContext.LoginId()); var u2 = c.Users.FirstOrDefault(u => u.Id == id); if (u1 != null && u2 != null) { int count = 0; foreach (Friends f in c.Friends) { var friendOne = f.Friend1 == u1.Id && f.Friend2 == u2.Id; var friendTwo = f.Friend1 == u2.Id && f.Friend2 == u1.Id; if (friendOne || friendTwo) { count++; } } if (count == 0) { var friendLink = new Friends { Friend1Navigation = u1, Friend2Navigation = u2 }; c.Add(friendLink); c.SaveChanges(); return(new JsonResult(new { added = true })); } } return(new JsonResult(new { added = false })); } } return(new JsonResult("")); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected new void Page_Load(object sender, EventArgs e) { // Support web fonts required by the current skin if (Skin != null) { var fontsHtml = new StringBuilder(); foreach (var font in Skin.RequiresGoogleFonts()) { fontsHtml.Append("<link href=\"").Append(font.FontUrl).Append("\" rel=\"stylesheet\" type=\"text/css\" />"); } if (Skin.RequiresTypekitFonts().Any()) { foreach (var font in Skin.RequiresTypekitFonts()) { fontsHtml.Append("<script src=\"").Append(font.TypekitUrl).Append("\"></script>"); } this.Typekit.Visible = true; } this.fonts.Text = fontsHtml.ToString(); AddClientDependencies(Skin); } // Support web chat var context = new HostingEnvironmentContext(); if (context.WebChatSettingsUrl != null) { var webChat = new WebChat(); webChat.WebChatSettings = new WebChatSettingsFromApi(context.WebChatSettingsUrl, new ConfigurationProxyProvider(), new ApplicationCacheStrategy <WebChatSettings>(TimeSpan.FromMinutes(context.WebChatSettingsCacheDuration))).ReadWebChatSettings(); webChat.WebChatSettings.PageUrl = new Uri(Request.Url.AbsolutePath, UriKind.Relative); if (webChat.IsRequired()) { AddClientDependencies(webChat); } } // Run the base method as well base.Page_Load(sender, e); }
public JsonResult BlockUser(int id) { if (HttpContext.LoginId() > 0) { using (var c = new WebChat()) { var u1 = c.Users.FirstOrDefault(u => u.Id == HttpContext.LoginId()); var u2 = c.Users.FirstOrDefault(u => u.Id == id); if (u1 != null && u2 != null) { int count = 0; foreach (Blocks f in c.Blocks) { var blockOne = f.Block1 == u1.Id && f.Block2 == u2.Id; var blockTwo = f.Block1 == u2.Id && f.Block2 == u1.Id; if (blockOne || blockTwo) { count++; } } if (count == 0) { var blockLink = new Blocks { Block1Navigation = u1, Block2Navigation = u2 }; c.Add(blockLink); c.SaveChanges(); return(new JsonResult(new { added = true })); } } return(new JsonResult(new { added = false })); } } return(new JsonResult("")); }
public void SetProperty(string type, string value) { if (HttpContext.LoginId() > 0) { if (type == null) { return; } if (value == null) { return; } using (var c = new WebChat()) { var user = c.Users.First(u => u.Id == HttpContext.LoginId()); switch (type) { case "password": user.Password = BCrypt.Net.BCrypt.HashPassword(value); break; case "email": user.Email = value; break; case "nickname": user.Nickname = value; break; case "phone": user.Phone = value; break; } c.SaveChanges(); Console.WriteLine($"PROPERTY {type} SET"); } } }
public JsonResult TryRegister(string login, string password, string name, string email, string phone) { if (HttpContext.LoginId() == 0) { using (var c = new WebChat()) { var toLogin = c .Users .Where(u => u.Login.Equals(login)); if (toLogin.Count() != 0) { return(new JsonResult(new { isLogged = false })); } var user = new Users { CreationDate = DateTime.Now, Login = login, Password = BCrypt.Net.BCrypt.HashPassword(password), Nickname = name, Email = email, Phone = phone }; c.Users.Add(user); c.SaveChanges(); } using (var c = new WebChat()) { var user = c.Users.First(u => u.Login.Equals(login)); return(new JsonResult(new { isLogged = LoginMiddleware.LogUser(HttpContext, user.Id) })); } } return(new JsonResult(new { isLogged = false })); }
private static async Task BroadcastMessage(WebChat c, Messages msgObject, int uid) { var user = c.Users.Single(u => u.Id == uid); var msg = JsonConvert.SerializeObject( new { from = user.Nickname, type = "message", id = msgObject.ConversationId, text = msgObject.Text }); var userIds = msgObject.Conversation.ConversationParticipants.Select(cp => cp.UserId).ToList(); foreach (var ws in LoginMiddleware.WebSockets.Where(a => userIds.Contains(a.Key) && a.Value.State == WebSocketState.Open) ) { msgObject.Conversation.ConversationParticipants.Single(cp => cp.UserId == ws.Key).SeenMessage = msgObject.Id; await ws.Value.SendAsync(Encoding.UTF8.GetBytes(msg), WebSocketMessageType.Text, true, CancellationToken.None); } c.SaveChanges(); }
void PollChat(WebChat webChat) { if (webChat.State == ChatState.Disconnected) { Disconnect(webChat, ChatServices.DisconnectReason.UserDisconnect); return; } if (webChat.State == ChatState.Paused || (ChatController.KeepQueuedChatsAlive && webChat.State == ChatState.Queued && webChat.IsMinimized)) { if (webChat.DatePaused.HasValue) { var elapsed = DateTime.Now.Subtract(webChat.DatePaused.Value); var elapsedSeconds = Convert.ToInt32(elapsed.TotalSeconds); var continueChatTimeout = ChatController.ContinueChatTimeout(); if (elapsedSeconds > continueChatTimeout) { LoggingService.GetInstance().LogNote(String.Format("Continue Chat timed out for connection: {0}", webChat.ConnectionId)); Disconnect(webChat, ChatServices.DisconnectReason.ContinueChatTimeout); return; } } } if ((webChat.State == ChatState.Connected || webChat.State == ChatState.Paused) && ChatController.EnableInactivityTimeout() && webChat.DateAnswered.HasValue) { if (ChatController.InactivityTimeout() > 0) { var inactiveTimeout = ChatController.InactivityTimeout(); var lastAgent = webChat.Messages.OrderBy(m => m.Order).LastOrDefault(m => m.Direction == "in" && !m.Name.Equals("System", StringComparison.OrdinalIgnoreCase)); var lastUser = webChat.Messages.OrderBy(m => m.Order).LastOrDefault(m => m.Direction == "out" && !m.Name.Equals("System", StringComparison.OrdinalIgnoreCase)); var now = DateTime.Now; var last = now; if (lastAgent != null && lastUser != null) { if (ChatController.EnableInactivityResetOnAgentMessage()) { last = lastAgent.DateSent > lastUser.DateSent ? lastAgent.DateSent : lastUser.DateSent; } else { last = lastUser.DateSent; } } else if (lastAgent != null) { last = lastAgent.DateSent; } if (last != now) { var elapsed = now.Subtract(last); var elapsedSeconds = Convert.ToInt32(elapsed.TotalSeconds); if (elapsedSeconds > inactiveTimeout) { LoggingService.GetInstance().LogNote(String.Format("Inactivity Time Out Occurred: {0}", webChat.ConnectionId)); Disconnect(webChat, ChatServices.DisconnectReason.InactivityTimeout); return; } } } } ChatServices.PollEvents(webChat.ParticipantId, webChat.ConnectionId, webChat.SessionId); }
///// <summary> ///// 作者:Ark ///// 时间:2014-07-31 ///// 描述:用户预订课 ///// </summary> ///// <param name="userId">(学员)用户编号</param> ///// <param name="productLevelId">产品级别编号(当前排课)</param> ///// <param name="arrangeCourseId">排课编号</param> ///// <param name="bookUserId">订课人编号</param> ///// <returns></returns> //public ResultTiper BookCourseByUserId(int userId, int productLevelId, int arrangeCourseId, int bookUserId) //{ // return BookCourseByUserId(userId, productLevelId, arrangeCourseId, bookUserId, false); //} /// <summary> /// 作者:Ark /// 时间:2014-07-31 /// 描述:用户退订课 /// 更新时间:2015-07-06 /// 作者:kylin /// 描述:添加微信提醒 /// </summary> /// <param name="bookRecordId"></param> /// <param name="unBookUserId"></param> /// <param name="unBookReason"></param> /// <returns></returns> public string UnBookCourseByUserId(string unbookCourseParams) { var nextBookSuccessStudentIds = new List<int>(); var sendWebChatMsgFlag = false; var unbookCourseModel = JsonHelper.FromJson<UnbookCourseModel>(unbookCourseParams); var ret = StudyBLL.UnBookRecord(unbookCourseModel.BookRecordId, unbookCourseModel.UnBookUserId, unbookCourseModel.UnBookReason, unbookCourseModel.IsForce, ref nextBookSuccessStudentIds, ConvertEnum.BookSourceForEmeMini); // false默认不强制退订 if (ret.Status == 100 && nextBookSuccessStudentIds.Any()) { var bookRecordInfo = StudyBLL.GetBookRecordById(unbookCourseModel.BookRecordId); var arrangeCourseInfo = StudyBLL.GetArrangeCourseById(bookRecordInfo.ArrangeCourseId); var classroomName = string.Empty; //课程 var currCourse = string.Format("{0} {1}", arrangeCourseInfo.ProductLevelCourseTypeCourse.ProductLevelCourseType.ProductLevel.EName, arrangeCourseInfo.ProductLevelCourseTypeCourse.Course.CName); //上课时间 var openCourseTime = string.Format("{0} {1} {2}-{3}", arrangeCourseInfo.BeginTime.ToString("MM-dd"), Eme.Utility.DateTimeHelper.GetCnWeekByDateTime(arrangeCourseInfo.BeginTime), arrangeCourseInfo.BeginTime.ToString("HH:mm"), arrangeCourseInfo.EndTime.ToString("HH:mm")); //教师 var teachInfo = string.Empty; foreach (var tr in arrangeCourseInfo.TeachRecord.Where(p => p.Status == ConvertEnum.StatusTypeForActive)) { foreach (var tu in tr.Teacher.User.UserInfo) { teachInfo = string.Format("{0} {1}", tu.EName, tu.CName == tu.EName ? "" : tu.CName).Trim().Split(' ')[0]; } } //教室 if (!string.IsNullOrWhiteSpace(arrangeCourseInfo.Classroom.ClassroomName)) { classroomName = arrangeCourseInfo.Classroom.ClassroomName; } else { classroomName = "网络课程"; } foreach (var bookStudentId in nextBookSuccessStudentIds) { var userInfo = UserBLL.GetUserInfoByStudentId(bookStudentId); var studentInfo = StudentBLL.GetStudentById(bookStudentId); var sendMsg = string.Format("亲,您排队预定的课程已经预定成功。课程:{0} 时间:{1} 教师:{2} 教室:{3}。我们的老师将会等候您的到来,记得要准时出席哦!", currCourse, openCourseTime, teachInfo, classroomName); #region 添加webChat 提醒功能! sendWebChatMsgFlag = false; var userBranchIds = UserBLL.GetUserBranch(userInfo.UserId); foreach (var branchId in userBranchIds) { if (Global.WebChatServiceBranchIds.Contains(CommonHelper.To<string>(branchId.BranchId))) { sendWebChatMsgFlag = true; break; } } if (sendWebChatMsgFlag) //针对试点中心尝试方式 服务号提醒 { var webChatApi = new WebChat<Dictionary<string, string>>(); var sendParam = JsonHelper.ToJson(new { // SERVICE_NAME_JSON = "BusiWXSendWechatMassage", UserPhone = userInfo.Mobile.Trim(), Content = sendMsg, KEY = Global.WebChatServiceKey }); var sendWebChatMsgResult = webChatApi.Send(Global.WebChatServiceUrl, sendParam); if (sendWebChatMsgResult["ResultCode"] == "Fale") { sendWebChatMsgFlag = false; } SysLogHelper.LogInfo("SendWebChatMessage_Start"); SysLogHelper.LogInfo(sendParam); SysLogHelper.LogInfo("Result:" + sendWebChatMsgResult["ResultMessage"]); SysLogHelper.LogInfo("SendWebChatMessage_End"); } #endregion } } return JsonHelper.ToJson(new { ResultCode = ret.Status == 100 ? "000000" : string.Format("000{0}", ret.Status), ResultMessage = string.Format("msg:{0} alertRes:{1}", ret.Msg, sendWebChatMsgFlag ? "微信通知成功" : "微信通知成功") }); }
///// <summary> ///// 作者:Ark ///// 时间:2014-07-31 ///// 描述:用户预订课 ///// </summary> ///// <param name="userId">(学员)用户编号</param> ///// <param name="productLevelId">产品级别编号(当前排课)</param> ///// <param name="arrangeCourseId">排课编号</param> ///// <param name="bookUserId">订课人编号</param> ///// <returns></returns> //public ResultTiper BookCourseByUserId(int userId, int productLevelId, int arrangeCourseId, int bookUserId) //{ // return BookCourseByUserId(userId, productLevelId, arrangeCourseId, bookUserId, false); //} /// <summary> /// 作者:Ark /// 时间:2014-07-31 /// 描述:用户退订课 /// 更新时间:2015-07-06 /// 作者:kylin /// 描述:添加微信提醒 /// </summary> /// <param name="bookRecordId"></param> /// <param name="unBookUserId"></param> /// <param name="unBookReason"></param> /// <returns></returns> public string UnBookCourseByUserId(string unbookCourseParams) { try { var nextBookSuccessStudentIds = new List<int>(); var sendWebChatMsgFlag = true; var unbookCourseModel = JsonHelper.FromJson<UnbookCourseModel>(unbookCourseParams); var ret = StudyBLL.UnBookRecord(unbookCourseModel.BookRecordId, unbookCourseModel.UnBookUserId, unbookCourseModel.UnBookReason, unbookCourseModel.IsForce, ref nextBookSuccessStudentIds, ConvertEnum.BookSourceForEmeMini); // false默认不强制退订 if (ret.Status == 100 && nextBookSuccessStudentIds.Any()) { var bookRecordInfo = StudyBLL.GetBookRecordById(unbookCourseModel.BookRecordId); var arrangeCourseInfo = StudyBLL.GetArrangeCourseById(bookRecordInfo.ArrangeCourseId); var classroomName = string.Empty; //课程 var currCourse = string.Format("{0} {1}", arrangeCourseInfo.ProductLevelCourseTypeCourse.ProductLevelCourseType.ProductLevel.EName, arrangeCourseInfo.ProductLevelCourseTypeCourse.Course.CName); //上课时间 var openCourseTime = string.Format("{0} {1} {2}-{3}", arrangeCourseInfo.BeginTime.ToString("MM-dd"), Eme.Utility.DateTimeHelper.GetCnWeekByDateTime(arrangeCourseInfo.BeginTime), arrangeCourseInfo.BeginTime.ToString("HH:mm"), arrangeCourseInfo.EndTime.ToString("HH:mm")); //教师 var teachInfo = string.Empty; foreach (var tr in arrangeCourseInfo.TeachRecord.Where(p => p.Status == ConvertEnum.StatusTypeForActive)) { foreach (var tu in tr.Teacher.User.UserInfo) { teachInfo = string.Format("{0} {1}", tu.EName, tu.CName == tu.EName ? "" : tu.CName).Trim().Split(' ')[0]; } } //教室 if (!string.IsNullOrWhiteSpace(arrangeCourseInfo.Classroom.ClassroomName)) { classroomName = arrangeCourseInfo.Classroom.ClassroomName; } else { classroomName = "网络课程"; } foreach (var bookStudentId in nextBookSuccessStudentIds) { var userInfo = UserBLL.GetUserInfoByStudentId(bookStudentId); var studentInfo = StudentBLL.GetStudentById(bookStudentId); var sendMsg = string.Format("亲,您排队预定的课程已经预定成功。课程:{0} 时间:{1} 教师:{2} 教室:{3}。我们的老师将会等候您的到来,记得要准时出席哦!", currCourse, openCourseTime, teachInfo, classroomName); #region 添加webChat 提醒功能! //微信服务号提醒 var webChatApi = new WebChat<Dictionary<string, string>>(); var sendParam = JsonHelper.ToJson(new { // SERVICE_NAME_JSON = "BusiWXSendWechatMassage", UserPhone = userInfo.Mobile.Trim(), Content = sendMsg, KEY = Global.WebChatServiceKey }); var sendWebChatMsgResult = webChatApi.Send(Global.WebChatServiceUrl, sendParam); if (sendWebChatMsgResult["ResultCode"].Equals("false", StringComparison.CurrentCultureIgnoreCase)) { sendWebChatMsgFlag = false; } SysLogHelper.LogInfo("SendWebChatMessage_Start"); SysLogHelper.LogInfo(sendParam); SysLogHelper.LogInfo("Result:" + sendWebChatMsgResult["ResultMessage"]); SysLogHelper.LogInfo("SendWebChatMessage_End"); #endregion } } return JsonHelper.ToJson(new { ResultCode = ret.Status == 100 ? "000000" : string.Format("000{0}", ret.Status), ResultMessage = string.Format("{0} {1}", ret.Msg, (sendWebChatMsgFlag && ret.Status == 100) ? "微信通知成功" : "微信通知失败") }); } catch (Exception ex) { SysLogHelper.LogInfo("eme系统异常========Start:>"); SysLogHelper.LogInfo("Erro Request Params:>"); SysLogHelper.LogInfo(unbookCourseParams); SysLogHelper.LogInfo("Erro Message:>"); SysLogHelper.LogInfo(ex.Message); SysLogHelper.LogInfo("InnerException:>"); SysLogHelper.LogInfo(ex.Message); SysLogHelper.LogInfo("StackTrace:>"); SysLogHelper.LogInfo(ex.StackTrace); return JsonHelper.ToJson(new { ResultCode = string.Format("000111"), ResultMessage = string.Format("eme系统异常,Message:{0};InnerException:{1};StackTrace:{2}", ex.Message, ex.InnerException, ex.StackTrace) }); } }
public JsonResult UnBookRecord(FormCollection fc) { var nextBookSuccessStudentIds = new List<int>(); var bookRecordId = Utility.CommonHelper.To<int>(fc["UnBookRecordId"]); var unbookReason = fc["UnBookRecordReason"]; var result = StudyBLL.UnBookRecord(bookRecordId, LoginUserManager.CurrLoginUser.UserId, unbookReason, false, ref nextBookSuccessStudentIds); //发送排队学员订课成功短信 if (result.Status == 100 && nextBookSuccessStudentIds.Any()) { var bookRecordInfo = StudyBLL.GetBookRecordById(bookRecordId); var arrangeCourseInfo = StudyBLL.GetArrangeCourseById(bookRecordInfo.ArrangeCourseId); var classroomName = string.Empty; //课程 var currCourse = string.Format("{0} {1}", arrangeCourseInfo.ProductLevelCourseTypeCourse.ProductLevelCourseType.ProductLevel.EName, arrangeCourseInfo.ProductLevelCourseTypeCourse.Course.CName); //上课时间 var openCourseTime = string.Format("{0} {1} {2}-{3}", arrangeCourseInfo.BeginTime.ToString("MM-dd"), Eme.Utility.DateTimeHelper.GetCnWeekByDateTime(arrangeCourseInfo.BeginTime), arrangeCourseInfo.BeginTime.ToString("HH:mm"), arrangeCourseInfo.EndTime.ToString("HH:mm")); //教师 var teachInfo = string.Empty; foreach (var tr in arrangeCourseInfo.TeachRecord.Where(p => p.Status == ConvertEnum.StatusTypeForActive)) { foreach (var tu in tr.Teacher.User.UserInfo) { teachInfo = string.Format("{0} {1}", tu.EName, tu.CName == tu.EName ? "" : tu.CName).Trim().Split(' ')[0]; } } //教室 if (!string.IsNullOrWhiteSpace(arrangeCourseInfo.Classroom.ClassroomName)) { classroomName = arrangeCourseInfo.Classroom.ClassroomName; } else { classroomName = "网络课程"; } foreach (var bookStudentId in nextBookSuccessStudentIds) { var userInfo = UserBLL.GetUserInfoByStudentId(bookStudentId); var studentInfo = StudentBLL.GetStudentById(bookStudentId); //开始发送站内消息 if (studentInfo.SA != null) { EmeBLL.CreateMessageForQueueBooking(bookRecordId, userInfo.Mobile.Trim(), studentInfo.SA, bookStudentId); } else { EmeBLL.CreateMessageForQueueBooking(bookRecordId, userInfo.Mobile.Trim(), studentInfo.CC, bookStudentId); } var sendMsg = string.Format("亲,您排队预定的课程已经预定成功。课程:{0} 时间:{1} 教师:{2} 教室:{3}。我们的老师将会等候您的到来,记得要准时出席哦!", currCourse, openCourseTime, teachInfo, classroomName); #region 添加webChat 提醒功能! var sendWebChatMsgFlag = true; var webChatApi = new WebChat<Dictionary<string, string>>(); var sendParam = JsonHelper.ToJson(new { // SERVICE_NAME_JSON = "BusiWXSendWechatMassage", UserPhone = userInfo.Mobile.Trim(), Content = sendMsg, KEY = Global.WebChatServiceKey }); var sendWebChatMsgResult = webChatApi.Send(Global.WebChatServiceUrl, sendParam); if (sendWebChatMsgResult["ResultCode"].Equals("false", StringComparison.CurrentCultureIgnoreCase)) { sendWebChatMsgFlag = false; } SysLogHelper.LogInfo("SendWebChatMessage_Start"); SysLogHelper.LogInfo(sendParam); SysLogHelper.LogInfo("Result:" + sendWebChatMsgResult["ResultMessage"] + " send webchat flag:" + sendWebChatMsgFlag); SysLogHelper.LogInfo("SendWebChatMessage_End"); #endregion //if (!sendWebChatMsgFlag) { List<SmsModel> smsList = new List<SmsModel>(); smsList.Add(new SmsModel { SystemCode = "EME", RecordId = bookRecordId.ToString(), Mobile = userInfo.Mobile.Trim(), Serial = "890", Message = sendMsg, SmsId = DateTime.Now.Ticks }); ISmsApi sms = new SmsApi(); SmsResult ret = sms.Send(smsList); var logmsg = JsonHelper.ToJson(smsList); //增加日志 SysLogHelper.LogInfo("SendSms_Start"); SysLogHelper.LogInfo(logmsg); SysLogHelper.LogInfo("Result:" + ret.Msg); SysLogHelper.LogInfo("SendSms_End"); } ////开始发送短信 //if (!string.IsNullOrWhiteSpace(userInfo.Mobile)) //{ // List<SmsModel> smsList = new List<SmsModel>(); // smsList.Add(new SmsModel // { // SystemCode = "EME", // RecordId = bookRecordId.ToString(), // Mobile = userInfo.Mobile.Trim(), // Serial = "890", // Message = "亲,您排队预定的课程已经预定成功。课程:" + currCourse + // " 时间:" + openCourseTime + " 教师:" + teachInfo + " 教室:" + classroomName + // "。我们的老师将会等候您的到来,记得要准时出席哦!", // SmsId = DateTime.Now.Ticks // }); //ISmsApi sms = new SmsApi(); //SmsResult ret = sms.Send(smsList); ////增加日志 //var logmsg = JsonHelper.ToJson(smsList); //SysLogHelper.LogInfo("SendSms_Start"); //SysLogHelper.LogInfo(logmsg); //SysLogHelper.LogInfo("Result:" + ret.Msg); //SysLogHelper.LogInfo("SendSms_End"); //} } } return Json(new { status = result.Status == 100 }, JsonRequestBehavior.DenyGet); }
private void Button_Click(object sender, RoutedEventArgs e) { WebChat chat = new WebChat(); MessageBox.Show(chat.GetUserInfo("109147935")); }
private void StartLogin() { WebChat chat = new WebChat(); chat.Login(Global.ACCOUNT, Global.PASSWORD); }
internal static void ChatRoom_UpdateStatus(int chatRoomId, int recordId, WebChat.Common.Enumerations.ChatRoomStatus status) { ChatRoomDAC.Update(chatRoomId, recordId, (int)status); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected new void Page_Load(object sender, EventArgs e) { // Configure remote master page var httpClientProvider = new HttpClientProvider(new ConfigurationProxyProvider()); var masterPageSettings = new RemoteMasterPageSettingsFromConfig(); var forceCacheRefresh = (Page.Request.QueryString["ForceCacheRefresh"] == "1"); // Provide a way to force an immediate update of the cache var remoteMasterPageClient = new RemoteMasterPageHtmlProvider(masterPageSettings.MasterPageControlUrl(), httpClientProvider, Request.UserAgent, new RemoteMasterPageMemoryCacheProvider { CacheDuration = TimeSpan.FromMinutes(masterPageSettings.CacheTimeout()) }, forceCacheRefresh); this.htmlTag.HtmlControlProvider = remoteMasterPageClient; this.metadataDesktop.HtmlControlProvider = remoteMasterPageClient; this.aboveHeaderDesktop.HtmlControlProvider = remoteMasterPageClient; if (this.headerDesktop != null) { this.headerDesktop.HtmlControlProvider = remoteMasterPageClient; } if (this.footerDesktop != null) { this.footerDesktop.HtmlControlProvider = remoteMasterPageClient; } this.scriptsDesktop.HtmlControlProvider = remoteMasterPageClient; // Apply selected text size to page var textSize = new TextSize(Request.Cookies?["textsize"]?.Value, Request.QueryString); int baseTextSize = textSize.CurrentTextSize(); if (baseTextSize > 1) { // Add a space if there are other classes, then add to body tag this.bodyclass.Controls.Add(new LiteralControl(" size" + baseTextSize.ToString(CultureInfo.InvariantCulture))); } // Support web fonts required by the current skin if (Skin != null) { var fontsHtml = new StringBuilder(); foreach (var font in Skin.RequiresGoogleFonts()) { fontsHtml.Append("<link href=\"").Append(font.FontUrl).Append("\" rel=\"stylesheet\" type=\"text/css\" />"); } this.fonts.Text = fontsHtml.ToString(); AddClientDependencies(Skin); } // Support web chat var context = new HostingEnvironmentContext(HttpContext.Current.Request.Url); if (context.WebChatSettingsUrl != null) { var webChat = new WebChat(); var webChatApiSettings = Options.Create(new WebChatApiSettings { WebChatSettingsUrl = context.WebChatSettingsUrl, CacheMinutes = context.WebChatSettingsCacheDuration }); webChat.WebChatSettings = new WebChatSettingsFromApi(webChatApiSettings, httpClientProvider, new ApplicationCacheStrategy <WebChatSettings>()).ReadWebChatSettings().Result; webChat.WebChatSettings.PageUrl = new Uri(Request.Url.AbsolutePath, UriKind.Relative); if (webChat.IsRequired()) { AddClientDependencies(webChat); } } // Run the base method as well base.Page_Load(sender, e); }