private async void UnlikeTopic(object sender, RoutedEventArgs e) { this.loadingBar.Visibility = System.Windows.Visibility.Visible; Task <bool> likeTopicTask = new Task <bool>(() => { string topicName = this.messageView.Argument["TopicName"] as string; string groupID = this.messageView.Argument["GroupID"] as string; GorillaWebAPI client = Utils.GetGorillaClient(); client.RemoveFavouriteTopic(topicName, groupID); bool isLiked = client.IsFavouriteTopic(topicName, groupID); return(isLiked); }); likeTopicTask.Start(); bool isliked = await likeTopicTask; if (!isliked) { this.ActionBtn.Content = "Add to Favourite"; this.ActionBtn.Click += LikeTopic; this.ActionBtn.Click -= UnlikeTopic; } this.loadingBar.Visibility = System.Windows.Visibility.Hidden; }
void LoadTopicActionBtn() { this.Dispatcher.Invoke((Action)(() => { this.loadingBar.Visibility = System.Windows.Visibility.Visible; GorillaWebAPI client = Utils.GetGorillaClient(); string topicName = this.messageView.Argument["TopicName"] as string; string groupID = this.messageView.Argument["GroupID"] as string; bool isFavourite = client.IsFavouriteTopic(topicName, groupID); if (isFavourite) { this.ActionBtn.Content = "Remove from Favourite"; this.ActionBtn.Click += UnlikeTopic; } else { this.ActionBtn.Content = "Add to Favourite"; this.ActionBtn.Click += LikeTopic; } this.ActionBtn.Visibility = System.Windows.Visibility.Visible; this.loadingBar.Visibility = System.Windows.Visibility.Hidden; })); }
public YahooStockReporter() { _client = new GorillaWebAPI("stockrobot", "User@123"); // Create data collecting timer _dataCollectTimer = new Timer(); _dataCollectTimer.Elapsed += new ElapsedEventHandler(OnDataCollectTimedEvent); _dataCollectTimer.AutoReset = true; // Create data posting timer _dataPostTimer = new Timer(); _dataPostTimer.Elapsed += new ElapsedEventHandler(OnDataPostTimedEvent); _dataPostTimer.AutoReset = true; }
void LoadJoinedGroup() { this.Dispatcher.Invoke((Action)(() => { this.loadingBar.Visibility = System.Windows.Visibility.Visible; GorillaWebAPI client = Utils.GetGorillaClient(); List <DisplayMembership> groups = client.GetJoinedGroup(); GroupComboBox.ItemsSource = groups; GroupComboBox.SelectedItem = groups[0]; ComboxBoxPanel.Visibility = System.Windows.Visibility.Visible; this.loadingBar.Visibility = System.Windows.Visibility.Hidden; })); }
///Content/Images/default_avatar.jpg ///null ////api/attachment/download?attachmentID=2916634;251997257652336_f77eebcc-fb69-4775-83aa-75bde32afb78.jpg static ThumbnailRetriever() { _client = Utils.GetGorillaClient(); //System.Reflection.Assembly assemble = System.Reflection.Assembly.GetEntryAssembly(); _folderPath = Path.Combine( Directory.GetCurrentDirectory(), "msgorilla_cache"); if (!Directory.Exists(_folderPath)) { Directory.CreateDirectory(_folderPath); } _defaultAvatarPath = Path.Combine(_folderPath, "default_avatar.jpg"); if (!File.Exists(_defaultAvatarPath)) { WebClient client = new WebClient(); client.DownloadFile("https://msgorilla.cloudapp.net/Content/Images/default_avatar.jpg", _defaultAvatarPath); } }
protected override void OnStart(string[] args) { // Create a timer to periodically trigger an action serviceTimer = new Timer(); // Hook up the Elapsed event for the timer. serviceTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent); serviceTimer.AutoReset = true; serviceTimer.Interval = 10000; serviceTimer.Start(); client = new GorillaWebAPI("WossTablemonitor", "User@123"); execDataset = client.QueryMetricDataSet( ExceptionProvider.FunctionName.Execute.ToString(), Counter, Category, GroupID); retriveDataset = client.QueryMetricDataSet( ExceptionProvider.FunctionName.ExecuteRetriveOperation.ToString(), Counter, Category, GroupID); queryDataset = client.QueryMetricDataSet( ExceptionProvider.FunctionName.ExecuteQuery.ToString(), Counter, Category, GroupID); querySegmentedDataset = client.QueryMetricDataSet( ExceptionProvider.FunctionName.ExecuteQuerySegmented.ToString(), Counter, Category, GroupID); Logger.Info("Service start."); base.OnStart(args); }
DisplayMessagePagination LoadMessageFromGorilla() { GorillaWebAPI client = Utils.GetGorillaClient(); if (Type == MessageViewType.Home) { return(client.HomeLine(this.Argument["UserID"] as string, this.Argument["GroupID"] as string, 10, this.token)); } else if (Type == MessageViewType.Owner) { return(client.OwnerLine(this.Argument["UserID"] as string, 10, this.token)); } else if (Type == MessageViewType.Mention) { return(client.AtLine(this.Argument["UserID"] as string, 10, this.token)); } else if (Type == MessageViewType.Topic) { return(client.TopicLine(this.Argument["TopicName"] as string, 10, this.Argument["GroupID"] as string, this.token)); } else if (Type == MessageViewType.User) { return(client.UserLine(this.Argument["UserID"] as string, this.Argument["GroupID"] as string, 10, this.token)); } return(new DisplayMessagePagination()); }
public static void OnTimedEvent(object obj, ElapsedEventArgs args) { //Set run interval as 10 minutes serviceTimer.Interval = 600000; Logger.WriteInfo("OnTime event, start query active reviews"); try { _initMonitorUserList(); bool isNew = false; ReviewServiceClient client = new ReviewServiceClient(); GorillaWebAPI webapi = new GorillaWebAPI("CFMonitor", "User@123"); foreach (string username in _userlist) { if (!_MonitoredReviewDict.Keys.Contains(username)) { _MonitoredReviewDict.Add(username, new Dictionary <string, int>()); isNew = true; } //get all active reviews CodeReviewSummary[] reviews = client.GetActiveReviewsForAuthor(username); if (reviews != null) { //scan each review foreach (var codeReviewSummary in reviews) { _cfTrendStatus.AddReviewCount(codeReviewSummary.Author.Name); CodeReview r = client.GetReview(codeReviewSummary.Key); if (!_MonitoredReviewDict[username].Keys.Contains(r.Key)) { _MonitoredReviewDict[username].Add(r.Key, 0); //A new submit, add to today's total Review count _cfTrendStatus.AddReviewCount(r.Author.Name); isNew = true; } if (_MonitoredReviewDict[username][r.Key] < r.codePackages.Length) { isNew = true; } if (isNew) { for (int i = _MonitoredReviewDict[username][r.Key]; i < r.codePackages.Length; i++) { CodePackage pkg = r.codePackages[i]; #region Generate review string StringBuilder reviewers = new StringBuilder("<table><tr style=\"border: 1px solid; border-top: none; border-left: none;border-right: none;\"><td width=\"40%\"><b>Reviewer</b></td><td width=\"30%\"><b>Type</b></td><td width=\"30%\"><b>Status</b></td></tr>"); StringBuilder reviewerstr = new StringBuilder(); foreach (var reviewer in r.reviewers) { reviewers.Append(string.Format("<tr><td><b>{3}</b>({0})</td><td>{1}</td><td>{2}</td></tr>", reviewer.Name, reviewer.Required ? "<b>Required</b>" : "Optional", reviewer.Status == ReviewerStatus.SignedOff ? "<font color=\"green\">SignedOff</font>" : reviewer.Status.ToString(), reviewer.DisplayName)); reviewerstr.Append(string.Format(" @{0},", reviewer.Name.Substring(reviewer.Name.IndexOf('\\') + 1))); } reviewers.Append("</table>"); #endregion #region Generate changed file StringBuilder changedfiles = new StringBuilder("<table><tr style=\"border: 1px solid; border-top: none; border-left: none;border-right: none;\"><td width=\"50px\"><b>Change</b></td><td width=\"30%\"><b>Type</b></td><td><b>FilePath</b></td></tr>"); foreach (var file in pkg.FileChanges) { changedfiles.Append(string.Format("<tr><td><b>{0}</b></td><td>{1}</td></tr>", file.ChangeType, file.DepotFilePath)); } changedfiles.Append("</table>"); string description = pkg.Description; string newDescription = description; string pat = @"(\d{4,})"; #endregion #region replace tfs number with topic // Instantiate the regular expression object. Regex reg = new Regex(pat, RegexOptions.IgnoreCase); // Match the regular expression pattern against a text string. Match m = reg.Match(description); List <string> replacedValueList = new List <string>(); while (m.Success) { //Console.WriteLine("Match" + (++matchCount)); if (!replacedValueList.Contains(m.Value)) { newDescription = newDescription.Replace(m.Value, string.Format(" #WOSS TFS {0}# ", m.Value)); replacedValueList.Add(m.Value); } m = m.NextMatch(); } #endregion string title = string.Format("Code Review: ({0}){1}", pkg.Author.Substring(pkg.Author.IndexOf('\\') + 1), r.Name); #region Iteration Title string iteration = ""; if (i == 0) { iteration = "New review submitted"; } else if (string.IsNullOrEmpty(r.CompletionMessage)) { iteration = "Author started new iteration"; } else { iteration = "Review completed"; } #endregion string link = "http://codeflow/Client/CodeFlow2010.application?server=http://codeflow/Services/DiscoveryService.svc&review=" + codeReviewSummary.Key; string richMessage = string.Format("<h3>{0}</h3><br/><h4><b>{1}</b></h4><br/><b>Open in: [<a href=\"{2}\">CodeFlow</a>]</b><br/><b>Author: {3}</b><br/>{4}<br/><b>Description:</b><br/>{5}<br/><h4><b>Affected Files</b></h4>{6}", title, iteration, link, pkg.Author, reviewers.ToString(), pkg.Description.Trim(), changedfiles.ToString()); string message = string.Format("#WOSS Codeflow# {0}\nIteration {2} {4}\nAuthor: {1}\nReviewer: {3}\n#WOSS Change {5}#\nReview: {6}", newDescription.Trim(), pkg.Author.Substring(pkg.Author.IndexOf('\\') + 1), pkg.Revision, reviewerstr.ToString().TrimEnd(new char[] { ',' }), pkg.IterationComment, pkg.SourceInfo.SourceName, link); Logger.WriteInfo(message); webapi.PostMessage(message, null, "none", r.Key, new string[] { "WOSS Codeflow" }, new string[] { pkg.Author.Substring(pkg.Author.IndexOf('\\') + 1) }, new string[] { }, richMessage); } _MonitoredReviewDict[username][r.Key] = r.codePackages.Length; } else { Logger.WriteInfo("no new reviews for user " + username); } } } } } catch (Exception e) { Logger.WriteInfo("Exception happened, try get the codeflow info in next run"); Logger.WriteInfo(e.Message); } //Check wether it's time to send trend data if (DateTime.Now.TimeOfDay > new TimeSpan(23, 30, 0)) { if (!_isTrendStatusSend) { GorillaWebAPI webapi = new GorillaWebAPI("CFMonitor", "User@123"); if (DateTime.Now.DayOfWeek == DayOfWeek.Friday) { var winner = _cfTrendStatus.ReviewCountPeople.OrderByDescending(p => p.Value).First(); string winnerThisWeek = string.Format("This Week's CodeFlow winner is @{0}, who submitted {1} CodeReviews!!!", winner.Key, winner.Value); webapi.PostMessage(winnerThisWeek, null, "none", "none", new string[] { "WOSS CodeFlow" }); } StringBuilder dailyTrendValue = new StringBuilder(); foreach (var value in _cfTrendStatus.ReviewCountHistory.OrderBy(t => t.Key).Select(t => t.Value)) { dailyTrendValue.AppendFormat("{0},", value); } string dTrendValue = dailyTrendValue.ToString().TrimEnd(','); StringBuilder dailyTrendDate = new StringBuilder(); foreach (var value in _cfTrendStatus.ReviewCountHistory.OrderBy(t => t.Key).Select(t => t.Key)) { dailyTrendDate.AppendFormat("'{0}',", value.ToShortDateString()); } string dTrendDate = dailyTrendDate.ToString().TrimEnd(','); string dailyTrend = string.Format("{{title:'WOSS Daily New CodeReview Number',legend:['New CodeRview Number'],xAxis:[{0}],yAxis:[{{name:'New CodeRview Number',type:'line',data:[{1}]}}]}}", dTrendDate, dTrendValue); webapi.PostMessage(dailyTrend, null, "chart-axis-singleaxis", "none", new string[] { "WOSS CodeFlow" }); _isTrendStatusSend = true; } } if (DateTime.Now.TimeOfDay < new TimeSpan(23, 00, 0)) { _isTrendStatusSend = false; } _recordMonitorStatus(); }
public MSGorillaEmailReporter(string username, string password) { _client = new GorillaWebAPI(username, password); }
public MSGorillaStatusReporter() : base() { _client = new GorillaWebAPI("MSGorillaStatusReporter", "*******"); }
public GorillaStatusHelper(string userid) { _client = new GorillaWebAPI("ShareAccount", "********"); this.Userid = userid; }
public MSGorillaEmailReplier(string mailAddress, string mailPassword, string gorillaUserid, string gorillaPassword) { _userid = gorillaUserid; _client = new GorillaWebAPI(gorillaUserid, gorillaPassword); _replySender = new EmailManager(mailAddress, mailPassword); }
public static GorillaWebAPI GetGorillaClient() { GorillaWebAPI client = new GorillaWebAPI("ShareAccount_" + GetCurrentUserID(), "********"); return(client); }
public static void GetWOSSTableBugsLatestUpdated(DateTime lastCheckTime) { string bugLinkTemplate = "https://microsoft.visualstudio.com/DefaultCollection/WSSC/_workitems"; string bugLinkDataTemplate = "#_a=edit&id={0}&triage=true"; string[] monitoredFields = new string[] { "Title", "Work Item Type", "Issue Type", "Severity", "State", "Reason", "Resolved By", "Iteration Path", "Assigned To", "Activated By", "Priority", "Found In", "Task Type", "Triage", "ID", "SD Changelist", "Repro Steps" }; string fieldChangeTemplate = "<div class=\"tfs-collapsible-content\" style=\"display: block;\">" + "<div class=\"container\">" + "<table class=MsoNormalTable border=1 cellspacing=0 cellpadding=0 width=\"100%\" style='width:1000px;mso-cellspacing:0cm;border:solid green 1.5pt;mso-yfti-tbllook:1184;mso-padding-alt:0cm 0cm 0cm 0cm'>" + "<tbody>" + "<tr style=\"background-color: rgb(134, 202, 247); mso-yfti-irow: 0; mso-yfti-firstrow: yes; color: black; font-family: \"sans-serif\"; font-size: 9pt\"><td>Field</td><td>New value</td><td>Old Value</td></tr>" + "fieldChangeRows" + "</tbody>" + "</table>" + "</div>" + "</div>"; if (tpc == null) { tpc = new TfsTeamProjectCollection(new Uri("https://microsoft.visualstudio.com/defaultcollection"), new UICredentialsProvider()); tpc.EnsureAuthenticated(); } if (tpc != null) { try { WorkItemStore workItemStore = tpc.GetService <WorkItemStore>(); var workItems = workItemStore.Query(String.Format(@" Select [Title] From WorkItems Where [Work Item Type] = 'Bug' AND [Area Path] Under 'WSSC\WSSC-Windows Server and System Center\FSC-File Server and Clustering\WOSS' AND [Issue Type] = 'Code Defect' AND [Changed Date] > '{0}'", lastCheckTime.Date.AddDays(-1.0f))); // Update existing work item if (workItems.Count > 0) { foreach (WorkItem wi in workItems) { if (wi.ChangedDate.CompareTo(lastCheckTime) < 0) { continue; } string message = ""; int id = wi.Id; string owner = DisplayName2Alias(wi.CreatedBy); string title = wi.Title; string issueType = (string)wi.Fields["Issue Type"].Value; string assignTo = DisplayName2Alias((string)wi.Fields["Assigned To"].Value); string build = (string)wi.Fields["Found In"].Value; string changeBy = DisplayName2Alias(wi.ChangedBy); string closeBy = DisplayName2Alias((string)wi.Fields["Closed By"].Value); string resolveBy = DisplayName2Alias((string)wi.Fields["Resolved By"].Value); if (wi.Revision == 1)// new created { message = string.Format("#WOSS TFS Created# #WOSS TFS {0}# Created by @{1}\n", id, owner); message += "Bug Title: " + title + "\n"; message += "Bug Assigned to @" + assignTo + "\n"; if (!string.IsNullOrEmpty(build)) { message += "Bug found in build #WOSS Build " + build + "#\n"; } } else if (wi.ChangedBy == "Payload Tracking (microsoft)") // resolved by SD check-in { message = string.Format("#WOSS TFS Checkin# #WOSS TFS {0}# has check-in #WOSS Change {1}# by @{2}\n", id, wi.Fields["SD Changelist"].Value, wi.Fields["SD User"].Value); } else if (wi.State != (string)(wi.Fields["State"].OriginalValue)) // State Changes { if (wi.State == "Active") { message = string.Format("#WOSS TFS Activated# #WOSS TFS {0}# Activated by @{1}\n", id, wi.Fields["Activated By"].Value); } else if (wi.State == "Closed") { message = string.Format("#WOSS TFS Closed# #WOSS TFS {0}# Closed by @{1}\n", id, closeBy); } else { message = string.Format("#WOSS TFS Resolved# #WOSS TFS {0}# Resolved by @{1}\n", id, resolveBy); } } else // Other changes { message = string.Format("#WOSS TFS Changed# #WOSS TFS {0}# changed by @{1} ({2})\n", wi.Id, changeBy, wi.ChangedBy); } StringBuilder richMessage = new StringBuilder(); var revLatest = wi.Revisions[wi.Revision - 1]; foreach (var fieldName in monitoredFields) { if (revLatest.Fields[fieldName].Value != null && revLatest.Fields[fieldName].Value != revLatest.Fields[fieldName].OriginalValue) { if (revLatest.Fields[fieldName].Value.GetType() == typeof(System.Int32)) { var cV = (int)revLatest.Fields[fieldName].Value; var oV = (int)(revLatest.Fields[fieldName].OriginalValue == null ? 0 : revLatest.Fields[fieldName].OriginalValue); if (cV == oV) { continue; } } string oriValue = (string)revLatest.Fields[fieldName].OriginalValue; if (string.IsNullOrEmpty(oriValue)) { oriValue = "(null)"; } richMessage.Append(string.Format("<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>", revLatest.Fields[fieldName].Name, revLatest.Fields[fieldName].Value, oriValue)); } } //message += "Bug link: " + bugLinkTemplate + Uri.EscapeDataString(string.Format(bugLinkDataTemplate, id)); message += "Bug link: " + bugLinkTemplate + string.Format(bugLinkDataTemplate, id); Console.WriteLine(message); // twitter message try { GorillaWebAPI webAPI = new GorillaWebAPI("WossTFSMonitor", "User@123"); webAPI.PostMessage(message, null, "none", id.ToString(), new string[] { "WOSS TFS" }, new string[] { owner }, new string[] { assignTo, resolveBy, closeBy, changeBy }, fieldChangeTemplate.Replace("fieldChangeRows", richMessage.ToString())); } catch (Exception e) { Console.WriteLine("Exception happen when twittering: " + e); } } } } catch (Exception e) { Console.WriteLine("Exception throw: " + e); return; } } }