You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
using CircleSDK.Model; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using CircleViewer.Models; using Newtonsoft.Json; using Syncfusion.Windows.Forms; using System.Net.Http; using CDPShared;
namespace CircleViewer.Dialogs { public partial class ActivityDlgDefault : Form { CDPWorker _cdp; List<CircleInfo> _CircleMeta; public ActivityDlgDefault(CDPWorker cdp) { _cdp = cdp; InitializeComponent(); }
private async void ActivityDlg_Load(object sender, EventArgs e) { LoadActivity(); await Task.Run(async () => { CircleInfo ci = await _cdp.GetCircle(Properties.Settings.Default.DefaultCircleId); this.BeginInvoke((MethodInvoker)delegate { this.Text = $"User Group Activity - {ci.CircleName}"; }); }); } private async Task<List<ActivityRow>> LoadCircleActivity() { List<ActivityRow> lar = new List<ActivityRow>(); GetMessagesReply gmReply = await _cdp.GetCircleViewwMessages();
#if FALSE // I only want to display recent events. (making a video)
foreach (MessageInfo mi in gmReply.Messages) { ActivityRow ar = new ActivityRow(mi); if ((DateTime.Now - ar.EventTime).TotalMinutes < 15) lar.Add(new ActivityRow(mi)); } #else
foreach (MessageInfo mi in gmReply.Messages) lar.Add(new ActivityRow(mi)); #endif
return lar; } private async Task<List<ActivityRow>> LoadCloudActivity() { List<ActivityRow> retList = new List<ActivityRow>();
var url = "https://circlecloudfuncstaging.azurewebsites.net/api/GetCircleEvents?circleId=" + Properties.Settings.Default.DefaultCircleId;
HttpClient client = new HttpClient(); var response = await client.GetAsync(url); response.EnsureSuccessStatusCode(); string result = await response.Content.ReadAsStringAsync();
List<CircleViewEventRecord> lrecs = JsonConvert.DeserializeObject<List<CircleViewEventRecord>>(result); foreach (CircleViewEventRecord rec in lrecs) { retList.Add(new ActivityRow(rec)); }
return retList; }
private async void LoadActivity() { GetMessagesReply gmReply = await _cdp.GetCircleViewwMessages(); List<ActivityRow> lar = new List<ActivityRow>(); List<ActivityRow> lCircleAR = await LoadCircleActivity(); lar.AddRange(lCircleAR);
Dictionary<string, string> _fileIdToName = new Dictionary<string, string>(); Dictionary<string, string> _userIdToName = new Dictionary<string, string>(); foreach (ActivityRow ar in lar) { switch ((CircleViewMessages)ar.MessageType) { case CircleViewMessages.FileEncrypted: { string fileId = ar.GetValue("File Id"); if (!string.IsNullOrEmpty(fileId)) { _fileIdToName[fileId] = ar.GetValue("Filename"); }
string viewerId = ar.GetValue("Sender Id"); if (!string.IsNullOrEmpty(viewerId)) { _userIdToName[viewerId] = ar.GetValue("Sender"); } break; } case CircleViewMessages.FileViewed: { string fileId = ar.GetValue("File Id"); if (!string.IsNullOrEmpty(fileId)) { _fileIdToName[fileId] = ar.GetValue("Filename"); }
string viewerId = ar.GetValue("Viewer Id"); if (!string.IsNullOrEmpty(viewerId)) { _userIdToName[viewerId] = ar.GetValue("Viewer"); } break; } default: break; } }
List<ActivityRow> lCloudAR = await LoadCloudActivity(); foreach (ActivityRow ar in lCloudAR) { string fileId = ar.GetValue("File Id"); if (_fileIdToName.ContainsKey(fileId)) { ar.AddValue("Filename*", _fileIdToName[fileId]); }
string senderId = ar.GetValue("Sender Id"); if (_userIdToName.ContainsKey(senderId)) { ar.AddValue("Sender*", _userIdToName[senderId]); } }
lar.AddRange(lCloudAR);
sfgActivity.DataSource = lar.OrderBy(r => r.EventTime).ToList(); }
private void sfgActivity_CellDoubleClick(object sender, Syncfusion.WinForms.DataGrid.Events.CellClickEventArgs e) { ActivityRow ar = (ActivityRow)e.DataRow.RowData; ViewMetaDlg dlg = new ViewMetaDlg(ar); dlg.ShowDialog(); } } }
|