public ActionResult Agent() { var liveChatModel = new LiveChatModel(); liveChatModel.SignalRPath = GetSignalRAppPath(); return(View("~/Plugins/Widgets.LiveChat/Views/LiveChat/Agent.cshtml", liveChatModel)); }
public ActionResult PublicInfo(string widgetZone) { var liveChatModel = new LiveChatModel(); liveChatModel.ReCaptchaPublicKey = _captchaSettings.ReCaptchaPublicKey; liveChatModel.ReCaptchaTheme = _captchaSettings.ReCaptchaTheme; liveChatModel.SignalRPath = GetSignalRAppPath(); return(View("~/Plugins/Widgets.LiveChat/Views/LiveChat/PublicInfo.cshtml", liveChatModel)); }
public LinkedList <LiveChatModel> GetLiveCommentsByChatId(string liveChatId) { var comments = new LinkedList <LiveChatModel>(); try { var requestList = "id,snippet,authorDetails"; var request = _service.LiveChatMessages.List(liveChatId, requestList); request.MaxResults = 500; //Acceptable values are 200 to 2000, inclusive. The default value is 500. var nextPage = ""; while (nextPage != null) { request.PageToken = nextPage; var response = request.Execute(); if (response.Items.Count == 0) { nextPage = null; break; } foreach (var item in response.Items) { var comment = new LiveChatModel { MessageId = item.Id, PublishedAt = item.Snippet.PublishedAt?.ToString() ?? "", AuthorChannelUrl = item.AuthorDetails.ChannelUrl, DisplayMessage = item.Snippet.DisplayMessage, AuthorDisplayName = item.AuthorDetails.DisplayName, IsVerified = item.AuthorDetails.IsVerified ?? false, IsChatModerator = item.AuthorDetails.IsChatModerator ?? false, IsChatOwner = item.AuthorDetails.IsChatOwner ?? false, IsChatSponsor = item.AuthorDetails.IsChatSponsor ?? false }; comments.AddLast(comment); } nextPage = response.NextPageToken; } } catch (Exception ex) { } return(comments); }
public ActionResult Configure() { LiveChatModel liveChatModel = new LiveChatModel(); liveChatModel.EmailAccounts = this._emailAccountService.GetAllEmailAccounts().Select ( ea => new EmailAccount() { Id = ea.Id, Name = ea.DisplayName } ).ToList(); liveChatModel.SignalRPort = this._liveChatSettings.SignalRPort; return(View("~/Plugins/Widgets.LiveChat/Views/LiveChat/Configure.cshtml", liveChatModel)); }
public ActionResult Configure(LiveChatModel model) { if (!ModelState.IsValid) { return(Configure()); } //save settings _liveChatSettings.SelectedEmailAccountId = model.SelectedEmailAccountId; _liveChatSettings.SignalRPort = model.SignalRPort; _settingService.SaveSetting(_liveChatSettings); string path = _liveChatService.GetSignaRStartPath(); SignalRSelfHost.SetUrl(path); SignalRSelfHost.Restart(); //redisplay the form return(Configure()); }
/// <summary> /// LiveChat mesajlarını al /// </summary> /// <param name="liveChatId"></param> /// <param name="videoId"></param> /// <param name="cancellationToken"></param> /// <param name="progress"></param> /// <returns></returns> public async Task GetLiveChatsAsync(string liveChatId, string videoId, CancellationToken cancellationToken, IProgress <ReportChatModel> progress) { try { var isOnline = true; while (isOnline) { var nextPage = ""; var requestList = "id,snippet,authorDetails"; while (nextPage != null) { var report = new ReportChatModel(); var output = new LinkedList <LiveChatModel>(); var request = _service.LiveChatMessages.List(liveChatId, requestList); request.MaxResults = 1000; request.PageToken = nextPage; var response = await request.ExecuteAsync(cancellationToken); foreach (LiveChatMessage item in response.Items) { try { cancellationToken.ThrowIfCancellationRequested(); } catch (OperationCanceledException e) { //MessageBox.Show(e.Message); } var chat = new LiveChatModel { MessageId = item.Id, PublishedAt = item.Snippet.PublishedAt?.ToString() ?? "", PublishedTime = item.Snippet.PublishedAt, AuthorChannelUrl = item.AuthorDetails.ChannelUrl, DisplayMessage = item.Snippet.DisplayMessage, AuthorDisplayName = item.AuthorDetails.DisplayName, IsVerified = item.AuthorDetails.IsVerified ?? false, IsChatModerator = item.AuthorDetails.IsChatModerator ?? false, IsChatOwner = item.AuthorDetails.IsChatOwner ?? false, IsChatSponsor = item.AuthorDetails.IsChatSponsor ?? false, AuthorChannelId = item.Snippet.AuthorChannelId, LiveChatId = item.Snippet.LiveChatId, VideoId = videoId }; output.AddLast(chat); } report.LiveChats = output; report.PollingIntervalMillis = response.PollingIntervalMillis; progress.Report(report); nextPage = response.NextPageToken; isOnline = !response.OfflineAt.HasValue; var wait = Convert.ToInt32(response.PollingIntervalMillis ?? 10000); await Task.Delay(wait, cancellationToken); } } } catch (Exception ex) { if (!ex.Message.Contains("iptal")) { MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }