public List <IssueEntry> ProjectList() { IDbConnection conn = null; IDbCommand cmd = null; IDataReader reader = null; List <IssueEntry> objProjectList = new List <IssueEntry>(); IssueEntry ProjectList = null; using (conn = DataFactory.CreateConnection()) { conn.Open(); cmd = conn.CreateCommand(); using (cmd = DataFactory.CreateCommand("Sp_ListProject", conn)) { cmd.CommandType = CommandType.StoredProcedure; reader = cmd.ExecuteReader(); while (reader.Read()) { ProjectList = new IssueEntry(); ProjectList.ProjectName = DBNull.Value.Equals(reader["ProductName"]) ? string.Empty : Convert.ToString(reader["ProductName"]); ProjectList.ProjectId = DBNull.Value.Equals(reader["ProductID"]) ? 0 : Convert.ToInt32(reader["ProductID"]); objProjectList.Add(ProjectList); } reader.Close(); } return(objProjectList); } }
private static string FormatIssueTable(IEnumerable <KeyValuePair <DataModelIssue, TimeSpan?> > issues) { StringBuilder text = new StringBuilder(); text.AppendLine("<table>"); text.AppendLine(" <tr>"); text.AppendLine(" <th>Issue #</th>"); text.AppendLine(" <th>Days since last comment</th>"); text.AppendLine(" <th>Title</th>"); text.AppendLine(" <th>Assigned To</th>"); text.AppendLine(" </tr>"); foreach (var pair in issues) { IssueEntry entry = new IssueEntry(pair.Key); text.AppendLine(" <tr>"); text.AppendLine($" <td>{entry.IssueId}</td>"); text.AppendLine($" <td>{pair.Value.Value.Days}</td>"); text.AppendLine(" <td>"); text.AppendLine($" {HttpUtility.HtmlEncode(entry.Title)}"); if (entry.LabelsText != null) { text.AppendLine($" <br/><div class=\"labels\">Labels: {entry.LabelsText}</div>"); } text.AppendLine(" </td>"); text.AppendLine($" <td>{entry.AssignedToText}</td>"); text.AppendLine(" </tr>"); } text.AppendLine("</table>"); return(text.ToString()); }
private static string FormatIssueTable(Dictionary <DataModelIssue, ExpressionUntriaged.Flags> issuesMap) { StringBuilder text = new StringBuilder(); text.AppendLine("<table>"); text.AppendLine(" <tr>"); text.AppendLine(" <th>Issue #</th>"); text.AppendLine(" <th>Problem</th>"); text.AppendLine(" <th>Title</th>"); text.AppendLine(" <th>Assigned To</th>"); text.AppendLine(" <th>Milestone</th>"); text.AppendLine(" </tr>"); foreach (KeyValuePair <DataModelIssue, ExpressionUntriaged.Flags> mapEntry in issuesMap) { IssueEntry issue = new IssueEntry(mapEntry.Key); text.AppendLine(" <tr>"); text.AppendLine($" <td>{issue.IssueId}</td>"); text.AppendLine($" <td>{UntriagedTypeToString(mapEntry.Value)}</td>"); text.AppendLine(" <td>"); text.AppendLine($" {HttpUtility.HtmlEncode(issue.Title)}"); if (issue.LabelsText != null) { text.AppendLine($" <br/><div class=\"labels\">Labels: {issue.LabelsText}</div>"); } text.AppendLine(" </td>"); text.AppendLine($" <td>{issue.AssignedToText}</td>"); text.AppendLine($" <td>{issue.MilestoneText}</td>"); text.AppendLine(" </tr>"); } text.AppendLine("</table>"); return(text.ToString()); }
public static bool UpdateBCFParameters(Document doc, ElementProperties ep, IssueEntry issue, Comment comment) { bool result = false; try { foreach (BCFParameters param in Enum.GetValues(typeof(BCFParameters))) { switch (param) { case BCFParameters.BCF_Action: result = UpdateBCFParameter(doc, ep, BCFParameters.BCF_Action, ep.Action); break; case BCFParameters.BCF_Author: if (null != comment) { result = UpdateBCFParameter(doc, ep, BCFParameters.BCF_Author, comment.Author); } break; case BCFParameters.BCF_Comment: if (null != comment) { result = UpdateBCFParameter(doc, ep, BCFParameters.BCF_Comment, comment.Comment1); } break; case BCFParameters.BCF_Date: if (null != comment) { result = UpdateBCFParameter(doc, ep, BCFParameters.BCF_Date, comment.Date.ToString()); } break; case BCFParameters.BCF_IssueNumber: break; case BCFParameters.BCF_Name: result = UpdateBCFParameter(doc, ep, BCFParameters.BCF_Name, issue.BCFName); break; case BCFParameters.BCF_Responsibility: result = UpdateBCFParameter(doc, ep, BCFParameters.BCF_Responsibility, ep.ResponsibleParty); break; case BCFParameters.BCF_Topic: result = UpdateBCFParameter(doc, ep, BCFParameters.BCF_Topic, issue.IssueTopic); break; } } } catch (Exception ex) { MessageBox.Show("Failed to update BCF Parameter." + ex.Message, "Update BCF Parameters", MessageBoxButton.OK, MessageBoxImage.Warning); } return(result); }
public List <IssueEntry> MainGrid(Int32 PageNo, Int32 RowsPerPage, String SearchText, Int64 UserID) { IDbCommand cmd = null; IDbConnection con = null; IDataReader reader; Int64 TotalRecords = 0; List <IssueEntry> issuelist = new List <IssueEntry>(); IssueEntry objissue = null; using (con = DataFactory.CreateConnection()) { con.Open(); using (cmd = DataFactory.CreateCommand("Sp_IssueEntryActiveMain", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(DataFactory.CreateParameter("@PageNo", PageNo)); cmd.Parameters.Add(DataFactory.CreateParameter("@RowsPerPage", RowsPerPage)); cmd.Parameters.Add(DataFactory.CreateParameter("@SearchText", SearchText)); cmd.Parameters.Add(DataFactory.CreateParameter("@UserID", UserID)); reader = cmd.ExecuteReader(); while (reader.Read()) { TotalRecords = Convert.ToInt64(reader["TotalRecords"]); } if (reader.NextResult()) { while (reader.Read()) { objissue = new IssueEntry(); objissue.IssueEntryID = Convert.ToInt64(reader["IssueEntryID"]); objissue.ProjectId = Convert.ToInt64(reader["ProjectId"]); objissue.ModuleId = Convert.ToInt64(reader["ModuleId"]); objissue.AssignedToId = DBNull.Value.Equals(reader["AssignedToId"]) ? 0 : Convert.ToInt64(reader["AssignedToId"]); objissue.AssignedToName = DBNull.Value.Equals(reader["AssignedToName"]) ? string.Empty : Convert.ToString(reader["AssignedToName"]); objissue.IssueDate = DBNull.Value.Equals(reader["IssueDate"]) ? string.Empty : Convert.ToString(reader["IssueDate"]); objissue.IssueTime = DBNull.Value.Equals(reader["IssueTime"]) ? 0 : Convert.ToDecimal(reader["IssueTime"]); objissue.StatusFlag = DBNull.Value.Equals(reader["StatusFlag"]) ? 0 : Convert.ToInt16(reader["StatusFlag"]); objissue.IssueDescription = DBNull.Value.Equals(reader["IssueDescription"]) ? string.Empty : Convert.ToString(reader["IssueDescription"]); objissue.AssignedByName = DBNull.Value.Equals(reader["AssignedByName"]) ? string.Empty : Convert.ToString(reader["AssignedByName"]); objissue.AssignedById = DBNull.Value.Equals(reader["AssignedById"]) ? 0 : Convert.ToInt64(reader["AssignedById"]); objissue.ModuleName = DBNull.Value.Equals(reader["ModuleTypeName"]) ? string.Empty : Convert.ToString(reader["ModuleTypeName"]); objissue.AssignedToName = DBNull.Value.Equals(reader["AssignedToName"]) ? string.Empty : Convert.ToString(reader["AssignedToName"]); objissue.ProjectName = DBNull.Value.Equals(reader["ProductName"]) ? string.Empty : Convert.ToString(reader["ProductName"]); objissue.IssueClosedDate = DBNull.Value.Equals(reader["IssueClosedDate"]) ? string.Empty : Convert.ToString(reader["IssueClosedDate"]); objissue.ActualTime = DBNull.Value.Equals(reader["ActualTime"]) ? string.Empty : Convert.ToString(reader["ActualTime"]); objissue.ResolvedDescription = DBNull.Value.Equals(reader["ResolvedDescription"]) ? string.Empty : Convert.ToString(reader["ResolvedDescription"]); objissue.StatusName = DBNull.Value.Equals(reader["StatusName"]) ? string.Empty : Convert.ToString(reader["StatusName"]); objissue.TotalRecords = TotalRecords; issuelist.Add(objissue); } } reader.Close(); return(issuelist); } } }
//public string Issuesave(IssueEntry IssueObj) //{ // IDbConnection con = null; // IDbCommand cmd = null; // int RecordAffected = 0; // using (con = DataFactory.CreateConnection()) // { // con.Open(); // cmd = con.CreateCommand(); // using (cmd = DataFactory.CreateCommand("sp_CreateIssueEntry", con)) // { // cmd.CommandType = CommandType.StoredProcedure; // cmd.Parameters.Add(DataFactory.CreateParameter("IsSave", true)); // cmd.Parameters.Add(DataFactory.CreateParameter("IssueEntryID", DBNull.Value)); // cmd.Parameters.Add(DataFactory.CreateParameter("ProjectId", IssueObj.ProjectId)); // cmd.Parameters.Add(DataFactory.CreateParameter("ModuleId", IssueObj.ModuleId)); // cmd.Parameters.Add(DataFactory.CreateParameter("AssignedToId", IssueObj.AssignedToId)); // cmd.Parameters.Add(DataFactory.CreateParameter("Createdby", IssueObj.CreatedBy)); // cmd.Parameters.Add(DataFactory.CreateParameter("AssignedToName", IssueObj.AssignedToName)); // cmd.Parameters.Add(DataFactory.CreateParameter("IssueDate", IssueObj.IssueDate)); // cmd.Parameters.Add(DataFactory.CreateParameter("IssueTime", IssueObj.IssueTime)); // cmd.Parameters.Add(DataFactory.CreateParameter("StatusFlag", IssueObj.StatusFlag)); // cmd.Parameters.Add(DataFactory.CreateParameter("IssueDescription", IssueObj.IssueDescription)); // cmd.Parameters.Add(DataFactory.CreateParameter("AssignedByName", IssueObj.AssignedByName)); // cmd.Parameters.Add(DataFactory.CreateParameter("AssignedById", IssueObj.AssignedById)); // IDbDataParameter param = DataFactory.CreateParameter("@@Guid", DBNull.Value); // param.DbType = DbType.Int64; // param.Direction = ParameterDirection.Output; // cmd.Parameters.Add(param); // RecordAffected = cmd.ExecuteNonQuery(); // IssueObj.IssueEntryID = Convert.ToInt64(param.Value); // } // } // if (RecordAffected > 0) // return Convert.ToString(IssueObj.IssueEntryID); // else // return "error"; //} public string IssueUpdate(IssueEntry IssueObj) { IDbConnection con = null; IDbCommand cmd = null; int RecordAffected = 0; try { using (con = DataFactory.CreateConnection()) { con.Open(); cmd = con.CreateCommand(); using (cmd = DataFactory.CreateCommand("sp_CreateIssueEntry", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(DataFactory.CreateParameter("IsSave", "0")); cmd.Parameters.Add(DataFactory.CreateParameter("IssueEntryID", IssueObj.IssueEntryID)); cmd.Parameters.Add(DataFactory.CreateParameter("StatusFlag", IssueObj.StatusFlag)); cmd.Parameters.Add(DataFactory.CreateParameter("ProjectId", IssueObj.ProjectId)); cmd.Parameters.Add(DataFactory.CreateParameter("ModuleId", IssueObj.ModuleId)); cmd.Parameters.Add(DataFactory.CreateParameter("AssignedById", IssueObj.AssignedById)); cmd.Parameters.Add(DataFactory.CreateParameter("AssignedToId", IssueObj.AssignedToId)); cmd.Parameters.Add(DataFactory.CreateParameter("IssueDate", IssueObj.IssueDate)); cmd.Parameters.Add(DataFactory.CreateParameter("IssueTime", IssueObj.IssueTime)); cmd.Parameters.Add(DataFactory.CreateParameter("AssignedToName", IssueObj.AssignedToName)); cmd.Parameters.Add(DataFactory.CreateParameter("AssignedByName", IssueObj.AssignedByName)); cmd.Parameters.Add(DataFactory.CreateParameter("IssueDescription", IssueObj.IssueDescription)); // cmd.Parameters.Add(DataFactory.CreateParameter("StatusFlag", IssueObj.ProjectName)); cmd.Parameters.Add(DataFactory.CreateParameter("CreatedBy", IssueObj.CreatedBy)); cmd.Parameters.Add(DataFactory.CreateParameter("IssueClosedDate", IssueObj.IssueClosedDate)); cmd.Parameters.Add(DataFactory.CreateParameter("ActualTime", IssueObj.ActualTime)); cmd.Parameters.Add(DataFactory.CreateParameter("ResolvedDescription", IssueObj.ResolvedDescription)); IDbDataParameter param = DataFactory.CreateParameter("@@Guid", DBNull.Value); param.DbType = DbType.Int64; param.Direction = ParameterDirection.Output; cmd.Parameters.Add(param); RecordAffected = cmd.ExecuteNonQuery(); } } if (RecordAffected > 0) { return(Convert.ToString(IssueObj.IssueEntryID)); } else { return("error"); } } catch (Exception Ex) { string m = Ex.Message; } return(null); }
public ActionResult CreateIssueOnProject(EditIssueOnProjectViewModel createIssueOnProjectViewModel) { if (ModelState.IsValid) { IssueEntry issueentry = new IssueEntry(); BugTrackerUser authoringUser = (from user in db.BugTrackerUsers where (String.Compare(user.UserName, User.Identity.Name) == 0) select user).Single(); issueentry.CreatedBy = authoringUser.UserName; issueentry.AssignedTo = createIssueOnProjectViewModel.AssignedTo; issueentry.Description = createIssueOnProjectViewModel.Description; issueentry.Title = createIssueOnProjectViewModel.Title; issueentry.IsSolved = createIssueOnProjectViewModel.IsSolved; issueentry.IssueEntryId = Guid.NewGuid(); string selectedProject = createIssueOnProjectViewModel.SelectedProject; string selectedPriority = createIssueOnProjectViewModel.SelectedPriority; issueentry.Project = db.Projects.Find(Convert.ToInt32(selectedProject)); issueentry.Project.IssueEntries.Add(issueentry); BugTrackerUser assignedToUser = (from user in db.BugTrackerUsers where user.UserName.Equals(issueentry.AssignedTo) select user).SingleOrDefault(); issueentry.IssuePriority = db.IssuePriorities.Find(Convert.ToInt32(selectedPriority)); issueentry.IssuePriority.IssueEntries.Add(issueentry); if (assignedToUser != null) assignedToUser.IssueEntries.Add(issueentry); try { db.IssueEntries.Add(issueentry); db.SaveChanges(); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { System.Diagnostics.Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } } return RedirectToAction("IssuesByProject", new { projectId = createIssueOnProjectViewModel.ProjectId } ); } return View(createIssueOnProjectViewModel); }
private void comboBoxIssue_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { if (null != comboBoxIssue.SelectedItem) { IssueEntry issueEntry = comboBoxIssue.SelectedItem as IssueEntry; string issueId = issueEntry.IssueId; if (null != selectedBCF) { selectedIssue = bcfDictionary[selectedBCF.MarkupFileId][issueId]; imageIssue.Source = selectedIssue.Snapshot; labelIssueTopic.Content = selectedIssue.IssueTopic; List <Comment> comments = selectedIssue.CommentDictionary.Values.ToList(); comments = comments.OrderBy(o => o.Comment1).ToList(); dataGridComments.ItemsSource = null; dataGridComments.ItemsSource = comments; if (comments.Count > 0) { dataGridComments.SelectedIndex = 0; } } elementList = selectedIssue.ElementDictionary.Values.ToList(); if (isFilterOn) { elementList = ApplyCategoryFilter(elementList); } currentIndex = 0; UpdateElementParameters(); selElementProperties = null; UpdateIndex(); DisplayElement(currentIndex); UpdateViews(); } } catch (Exception ex) { MessageBox.Show("Failed to trigger the evnet of selection changed for Issue.\n" + ex.Message, "comboBoxIssue SelectionChanged", MessageBoxButton.OK, MessageBoxImage.Warning); } }
private bool ModifyAssigningBasedOnIssue(string assignedToNew, IssueEntry issueEntry) { BugTrackerUser oldAssignedUser = (from user in db.BugTrackerUsers where user.UserName.Equals(issueEntry.AssignedTo) select user).SingleOrDefault(); bool assigningChanged = false; if (!issueEntry.AssignedTo.Equals(assignedToNew)) { assigningChanged = true; if (oldAssignedUser != null) { /** Remove old reference to issue entry */ oldAssignedUser.IssueEntries.Remove(issueEntry); } } else { BugTrackerUser assignedTo = oldAssignedUser; /** Issue is marked as solved so remove the entry */ if (issueEntry.IsSolved) { oldAssignedUser.IssueEntries.Remove(issueEntry); } /** Issue is marked as not solved so add entry */ else { oldAssignedUser.IssueEntries.Add(issueEntry); } } if (assigningChanged && issueEntry.IsSolved == false) { issueEntry.AssignedTo = assignedToNew; /** Get new user from database for assigning */ BugTrackerUser assignedToNewUser = (from user in db.BugTrackerUsers where user.UserName.Equals(issueEntry.AssignedTo) select user).SingleOrDefault(); if (assignedToNewUser != null) assignedToNewUser.IssueEntries.Add(issueEntry); } return assigningChanged; }
public ActionResult Edit(IssueEntry issueentry) { if (ModelState.IsValid) { db.Entry(issueentry).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(issueentry); }
private Dictionary <string, IssueEntry> GetBCFIssueInfo(Document doc, LinkedBcfFileInfo bcfFileInfo) { Dictionary <string, IssueEntry> issueDictionary = new Dictionary <string, IssueEntry>(); try { issueDictionary = FileManager.ReadIssues(bcfFileInfo); List <string> issueIds = issueDictionary.Keys.ToList(); progressWindow.SetMaximum(issueIds.Count); double progressValue = 0; foreach (string issueId in issueIds) { if (AbortFlag.GetAbortFlag()) { progressWindow.Close(); return(new Dictionary <string, IssueEntry>()); } progressValue++; progressWindow.SetProgressValue(progressValue); IssueEntry issueEntry = issueDictionary[issueId]; List <int> elementIds = issueEntry.ElementDictionary.Keys.ToList(); foreach (int elementId in elementIds) { ElementProperties property = issueEntry.ElementDictionary[elementId]; Element element = m_doc.GetElement(new ElementId(elementId)); if (null != element) { if (null != element.Category) { if (!categoryNames.Contains(element.Category.Name)) { categoryNames.Add(element.Category.Name); } if (element.Category.AllowsBoundParameters) { int categoryId = element.Category.Id.IntegerValue; if (!catDictionary.ContainsKey(categoryId)) { BuiltInCategory bltCategory = (BuiltInCategory)categoryId; if (bltCategory != BuiltInCategory.INVALID) { catDictionary.Add(categoryId, bltCategory); } } } } ElementProperties ep = new ElementProperties(element); ep.IssueId = property.IssueId; ep.Action = property.Action; ep.ResponsibleParty = property.ResponsibleParty; ep.CellEntries = property.CellEntries; issueDictionary[issueId].ElementDictionary.Remove(elementId); issueDictionary[issueId].ElementDictionary.Add(elementId, ep); } } issueDictionary[issueId].NumElements = issueDictionary[issueId].ElementDictionary.Count; if (null == issueDictionary[issueId].Snapshot) { if (bcfFileInfo.SharedLinkId == bcfProjectId && null != googleFolders) { issueDictionary[issueId].Snapshot = FileManager.DownloadImage(issueId, googleFolders.ActiveImgFolder.Id); } else if (bcfFileInfo.SharedLinkId == bcfProjectId) { googleFolders = FileManager.FindGoogleFolders(bcfProjectId); if (null != googleFolders) { issueDictionary[issueId].Snapshot = FileManager.DownloadImage(issueId, googleFolders.ActiveImgFolder.Id); } } else { FolderHolders tempFolders = FileManager.FindGoogleFolders(bcfFileInfo.SharedLinkId); if (null != tempFolders) { issueDictionary[issueId].Snapshot = FileManager.DownloadImage(issueId, tempFolders.ActiveImgFolder.Id); } } } } if (bcfDictionary.ContainsKey(bcfFileInfo.MarkupFileId)) { bcfDictionary.Remove(bcfFileInfo.MarkupFileId); } bcfDictionary.Add(bcfFileInfo.MarkupFileId, issueDictionary); } catch (Exception ex) { MessageBox.Show("Failed to add issue items into BCF dictionary.\n" + ex.Message, "Add BCF to Dictionary", MessageBoxButton.OK, MessageBoxImage.Warning); } return(issueDictionary); }
public async Task SendSyncResponse() { var pageSize = 1000; var tasks = new List <Task>(); using (var context = new ShipHubContext()) { var dsp = context.PrepareSync( _user.UserId, pageSize, _versions.RepoVersions.Select(x => new VersionTableType() { ItemId = x.Key, RowVersion = x.Value, }), _versions.OrgVersions.Select(x => new VersionTableType() { ItemId = x.Key, RowVersion = x.Value, }), _selectiveSyncEnabled, _versions.QueriesVersion ); var entries = new List <SyncLogEntry>(); var sentLogs = 0; SyncSpiderProgress spiderProgress = null; using (var reader = await dsp.ExecuteReaderAsync()) { dynamic ddr = reader; /* ************************************************************************************************************ * Basic User Info * ***********************************************************************************************************/ long?userId = null; Common.GitHub.GitHubRateLimit rateLimit = null; if (reader.Read()) { userId = (long)ddr.UserId; rateLimit = new Common.GitHub.GitHubRateLimit( null, ddr.RateLimit, ddr.RateLimitRemaining, ddr.RateLimitReset); } if (userId == null || userId != _user.UserId) { await _connection.CloseAsync(); return; } if (rateLimit?.IsExceeded == true) { // HACK: to quiet modal dialogs in some clients var limitUntil = rateLimit.Reset; var now = DateTimeOffset.UtcNow; var thirtyMinutes = new DateTimeOffset(now.Year, now.Month, now.Day, now.Hour, 0, 0, now.Offset); thirtyMinutes = thirtyMinutes.AddMinutes(((now.Minute / 30) + 1) * 30); if (limitUntil < thirtyMinutes) { limitUntil = thirtyMinutes; } tasks.Add(_connection.SendJsonAsync(new RateLimitResponse() { Until = limitUntil, })); } /* ************************************************************************************************************ * Spider Progress * ************************************************************************************************************/ reader.NextResult(); spiderProgress = ReadSpiderProgress(reader); /* ************************************************************************************************************ * Deleted orgs and repos (permission removed or deleted) * ***********************************************************************************************************/ // Removed Repos reader.NextResult(); while (reader.Read()) { long repoId = ddr.RepositoryId; entries.Add(new SyncLogEntry() { Action = SyncLogAction.Delete, Entity = SyncEntityType.Repository, Data = new DeletedEntry(repoId), }); _versions.RepoVersions.Remove(repoId); } // Removed Orgs reader.NextResult(); while (reader.Read()) { long orgId = ddr.OrganizationId; // Don't delete the org entries.Add(new SyncLogEntry() { Action = SyncLogAction.Set, Entity = SyncEntityType.Organization, Data = new OrganizationEntry() { Identifier = orgId, Login = ddr.Login ?? "Sync Corruption: 0x2695", Users = Array.Empty <long>() }, }); _versions.OrgVersions.Remove(orgId); } if (entries.Any()) { tasks.Add(_connection.SendJsonAsync(new SyncResponse() { Logs = entries, Remaining = 0, Versions = VersionDetails, SpiderProgress = spiderProgress })); entries = new List <SyncLogEntry>(); } /* ************************************************************************************************************ * New/Updated Orgs * ***********************************************************************************************************/ var orgAccounts = new Dictionary <long, OrganizationEntry>(); var orgMembers = new Dictionary <long, List <long> >(); // Orgs reader.NextResult(); while (reader.Read()) { var org = new OrganizationEntry() { Identifier = ddr.Id, Login = ddr.Login, Name = ddr.Name, ShipNeedsWebhookHelp = !(ddr.HasHook || ddr.Admin), // Users set later }; orgAccounts.Add(org.Identifier, org); } // Org Membership reader.NextResult(); while (reader.Read()) { orgMembers.Valn((long)ddr.OrganizationId).Add((long)ddr.UserId); } // Fixup foreach (var kv in orgMembers) { orgAccounts[kv.Key].Users = kv.Value; } entries.AddRange(orgAccounts.Values.Select(x => new SyncLogEntry() { Action = SyncLogAction.Set, Entity = SyncEntityType.Organization, Data = x, })); // Can't update versions just yet. Have to make sure we send the account entities first. if (entries.Any()) { tasks.Add(_connection.SendJsonAsync(new SyncResponse() { Logs = entries, Remaining = 0, // Orgs are sent as a single batch Versions = VersionDetails, SpiderProgress = spiderProgress })); entries = new List <SyncLogEntry>(); } /* ************************************************************************************************************ * Added/Updated/Deleted Queries (non-paginated) * ***********************************************************************************************************/ reader.NextResult(); // Only process these if the client supports queries if (_querySyncEnabled) { long maxRowVersion = 0; while (reader.Read()) { var entry = new SyncLogEntry() { Action = (bool)ddr.Delete ? SyncLogAction.Delete : SyncLogAction.Set, Entity = SyncEntityType.Query, }; if (entry.Action == SyncLogAction.Set) { entry.Data = new QueryEntry() { Id = ddr.Id, Author = new AccountEntry() { Identifier = ddr.AuthorId, Name = ddr.AuthorName, Login = ddr.AuthorLogin }, Title = ddr.Title, Predicate = ddr.Predicate }; } else { entry.Data = new DeletedGuidEntry(ddr.Id); } entries.Add(entry); maxRowVersion = Math.Max(maxRowVersion, ddr.RowVersion); } if (entries.Any()) { _versions.QueriesVersion = maxRowVersion; tasks.Add(_connection.SendJsonAsync(new SyncResponse() { Logs = entries, Remaining = 0, // Queries are sent as a single batch Versions = VersionDetails, SpiderProgress = spiderProgress })); } } /* ************************************************************************************************************ * New/Updated entites (paginated) * ***********************************************************************************************************/ // Total logs reader.NextResult(); reader.Read(); var totalLogs = (long)ddr.TotalEntries; // Pagination Loop while (reader.NextResult()) { entries = new List <SyncLogEntry>(); // Accounts // Orgs sent here will have null members, which the client ignores. while (reader.Read()) { var type = (string)ddr.Type == "user" ? SyncEntityType.User : SyncEntityType.Organization; var accountId = (long)ddr.Id; if (type == SyncEntityType.Organization && orgAccounts.ContainsKey(accountId)) { // We've already sent that information --totalLogs; } else { entries.Add(new SyncLogEntry() { Action = SyncLogAction.Set, Entity = type, Data = new AccountEntry() { Identifier = accountId, Login = ddr.Login, Name = ddr.Name, }, }); } } // Commit Comments reader.NextResult(); while (reader.Read()) { var entry = new SyncLogEntry() { Action = (bool)ddr.Delete ? SyncLogAction.Delete : SyncLogAction.Set, Entity = SyncEntityType.CommitComment, }; if (entry.Action == SyncLogAction.Set) { entry.Data = new CommitCommentEntry() { Body = ddr.Body, CommitId = ddr.CommitId, CreatedAt = ddr.CreatedAt, Identifier = ddr.Id, Line = ddr.Line, Path = ddr.Path, Position = ddr.Position, Repository = ddr.RepositoryId, UpdatedAt = ddr.UpdatedAt, User = ddr.UserId, }; } else { entry.Data = new DeletedEntry(ddr.Id); } entries.Add(entry); } // Issue Comments reader.NextResult(); while (reader.Read()) { var entry = new SyncLogEntry() { Action = (bool)ddr.Delete ? SyncLogAction.Delete : SyncLogAction.Set, Entity = SyncEntityType.IssueComment, }; if (entry.Action == SyncLogAction.Set) { entry.Data = new IssueCommentEntry() { Body = ddr.Body, CreatedAt = ddr.CreatedAt, Identifier = ddr.Id, Issue = ddr.IssueId, Repository = ddr.RepositoryId, UpdatedAt = ddr.UpdatedAt, User = ddr.UserId, }; } else { entry.Data = new DeletedEntry(ddr.Id); } entries.Add(entry); } // Events reader.NextResult(); while (reader.Read()) { var entry = new SyncLogEntry() { Action = (bool)ddr.Delete ? SyncLogAction.Delete : SyncLogAction.Set, Entity = SyncEntityType.Event, }; if (entry.Action == SyncLogAction.Set) { var data = new IssueEventEntry() { Actor = ddr.ActorId, CreatedAt = ddr.CreatedAt, Event = ddr.Event, ExtensionData = ddr.ExtensionData, Identifier = ddr.Id, Issue = ddr.IssueId, Repository = ddr.RepositoryId, }; if (ddr.Restricted) { // closed event is special if (data.Event == "closed") { // strip all extra info // See https://realartists.slack.com/archives/general/p1470075341001004 data.ExtensionDataDictionary.Clear(); } else { // Account for missing logs in progress reports --totalLogs; continue; } } entry.Data = data; } else { entry.Data = new DeletedEntry(ddr.Id); } entries.Add(entry); } // Milestones (can be deleted) reader.NextResult(); while (reader.Read()) { var entry = new SyncLogEntry() { Action = (bool)ddr.Delete ? SyncLogAction.Delete : SyncLogAction.Set, Entity = SyncEntityType.Milestone, }; if (entry.Action == SyncLogAction.Set) { entry.Data = new MilestoneEntry() { ClosedAt = ddr.ClosedAt, CreatedAt = ddr.CreatedAt, Description = ddr.Description, DueOn = ddr.DueOn, Identifier = ddr.Id, Number = ddr.Number, Repository = ddr.RepositoryId, State = ddr.State, Title = ddr.Title, UpdatedAt = ddr.UpdatedAt, }; } else { entry.Data = new DeletedEntry(ddr.Id); } entries.Add(entry); } // Projects (can be deleted) reader.NextResult(); while (reader.Read()) { var entry = new SyncLogEntry() { Action = (bool)ddr.Delete ? SyncLogAction.Delete : SyncLogAction.Set, Entity = SyncEntityType.Project, }; if (entry.Action == SyncLogAction.Set) { entry.Data = new ProjectEntry() { Identifier = ddr.Id, Name = ddr.Name, Number = ddr.Number, Body = ddr.Body, CreatedAt = ddr.CreatedAt, UpdatedAt = ddr.UpdatedAt, Creator = ddr.CreatorId, Organization = ddr.OrganizationId, Repository = ddr.RepositoryId }; } else { entry.Data = new DeletedEntry(ddr.Id); } entries.Add(entry); } // Reactions (can be deleted) reader.NextResult(); while (reader.Read()) { var entry = new SyncLogEntry() { Action = (bool)ddr.Delete ? SyncLogAction.Delete : SyncLogAction.Set, Entity = SyncEntityType.Reaction, }; if (entry.Action == SyncLogAction.Set) { entry.Data = new ReactionEntry() { Comment = ddr.CommentId, Content = ddr.Content, CreatedAt = ddr.CreatedAt, Identifier = ddr.Id, Issue = ddr.IssueId, PullRequestComment = ddr.PullRequestCommentId, CommitComment = ddr.CommitCommentId, User = ddr.UserId, }; } else { entry.Data = new DeletedEntry(ddr.Id); } entries.Add(entry); } // Labels reader.NextResult(); while (reader.Read()) { var entry = new SyncLogEntry() { Action = (bool)ddr.Delete ? SyncLogAction.Delete : SyncLogAction.Set, Entity = SyncEntityType.Label, }; if (entry.Action == SyncLogAction.Set) { entry.Data = new LabelEntry() { Color = ddr.Color, Identifier = ddr.Id, Name = ddr.Name, Repository = ddr.RepositoryId, }; } else { entry.Data = new DeletedEntry(ddr.Id); } entries.Add(entry); } // Issue Labels var issueLabels = new Dictionary <long, List <long> >(); reader.NextResult(); while (reader.Read()) { issueLabels .Valn((long)ddr.IssueId) .Add((long)ddr.LabelId); } // Issue Assignees var issueAssignees = new Dictionary <long, List <long> >(); reader.NextResult(); while (reader.Read()) { issueAssignees .Valn((long)ddr.IssueId) .Add((long)ddr.UserId); } // Pull Request Reviewers var prReviewers = new Dictionary <long, List <long> >(); reader.NextResult(); while (reader.Read()) { prReviewers .Valn((long)ddr.IssueId) .Add((long)ddr.UserId); } // Issue Mentions var issueMentions = new Dictionary <long, List <long> >(); reader.NextResult(); while (reader.Read()) { issueMentions .Valn((long)ddr.IssueId) .Add((long)ddr.UserId); } // Issues (can be deleted) reader.NextResult(); while (reader.Read()) { var entry = new SyncLogEntry() { Action = (bool)ddr.Delete ? SyncLogAction.Delete : SyncLogAction.Set, Entity = SyncEntityType.Issue, }; if (entry.Action == SyncLogAction.Set) { var issueEntry = new IssueEntry() { Assignees = issueAssignees.Val((long)ddr.Id, () => new List <long>()), Body = ddr.Body, ClosedAt = ddr.ClosedAt, ClosedBy = ddr.ClosedById, CreatedAt = ddr.CreatedAt, Identifier = ddr.Id, Labels = issueLabels.Val((long)ddr.Id, () => new List <long>()), Locked = ddr.Locked, Mentions = issueMentions.Val((long)ddr.Id, () => new List <long>()), Milestone = ddr.MilestoneId, Number = ddr.Number, // This is hack that works until GitHub changes their version ShipReactionSummary = ((string)ddr.Reactions).DeserializeObject <ReactionSummary>(), Repository = ddr.RepositoryId, State = ddr.State, Title = ddr.Title, UpdatedAt = ddr.UpdatedAt, PullRequest = ddr.PullRequest, User = ddr.UserId, }; entry.Data = issueEntry; } else { entry.Data = new DeletedEntry(ddr.Id); } entries.Add(entry); } // Pull Requests reader.NextResult(); while (reader.Read()) { var prEntry = new PullRequestEntry() { Identifier = ddr.Id, Issue = ddr.IssueId, CreatedAt = ddr.CreatedAt, UpdatedAt = ddr.UpdatedAt, MergeCommitSha = ddr.MergeCommitSha, MergedAt = ddr.MergedAt, Base = ((string)ddr.BaseJson).DeserializeObject <JToken>(), Head = ((string)ddr.HeadJson).DeserializeObject <JToken>(), Additions = ddr.Additions, ChangedFiles = ddr.ChangedFiles, Commits = ddr.Commits, Deletions = ddr.Deletions, MaintainerCanModify = ddr.MaintainerCanModify, Mergeable = ddr.Mergeable, MergeableState = ddr.MergeableState, MergedBy = ddr.MergedById, Rebaseable = ddr.Rebaseable, RequestedReviewers = prReviewers.Val((long)ddr.IssueId, () => new List <long>()), }; entries.Add(new SyncLogEntry() { Action = SyncLogAction.Set, Entity = SyncEntityType.PullRequest, Data = prEntry, }); } // Repository Assignable Users var repoAssignable = new Dictionary <long, List <long> >(); reader.NextResult(); while (reader.Read()) { repoAssignable .Valn((long)ddr.RepositoryId) .Add((long)ddr.AccountId); } // Repositories reader.NextResult(); while (reader.Read()) { entries.Add(new SyncLogEntry() { Action = SyncLogAction.Set, Entity = SyncEntityType.Repository, Data = new RepositoryEntry() { Assignees = repoAssignable.Val((long)ddr.Id, () => new List <long>()), Owner = ddr.AccountId, FullName = ddr.FullName, Identifier = ddr.Id, Name = ddr.Name, Private = ddr.Private, ShipNeedsWebhookHelp = !(ddr.HasHook || ddr.Admin), IssueTemplate = ddr.IssueTemplate, PullRequestTemplate = ddr.PullRequestTemplate, HasIssues = ddr.HasIssues, Disabled = ddr.Disabled, AllowMergeCommit = ddr.AllowMergeCommit, AllowRebaseMerge = ddr.AllowRebaseMerge, AllowSquashMerge = ddr.AllowSquashMerge, }, }); } // Pull Request Reviews reader.NextResult(); while (reader.Read()) { if (ddr.Restricted) { // Account for missing logs in progress reports --totalLogs; continue; } var entry = new SyncLogEntry() { Action = (bool)ddr.Delete ? SyncLogAction.Delete : SyncLogAction.Set, Entity = SyncEntityType.Review, }; if (entry.Action == SyncLogAction.Set) { entry.Data = new ReviewEntry() { Body = ddr.Body, CommitId = ddr.CommitId, Identifier = ddr.Id, Issue = ddr.IssueId, State = ddr.State, SubmittedAt = ddr.SubmittedAt, User = ddr.UserId, }; } else { entry.Data = new DeletedEntry(ddr.Id); } entries.Add(entry); } // Pull Request Comments reader.NextResult(); while (reader.Read()) { if (ddr.Restricted) { // Account for missing logs in progress reports --totalLogs; continue; } var entry = new SyncLogEntry() { Action = (bool)ddr.Delete ? SyncLogAction.Delete : SyncLogAction.Set, Entity = SyncEntityType.PullRequestComment, }; if (entry.Action == SyncLogAction.Set) { entry.Data = new PullRequestCommentEntry() { Body = ddr.Body, CommitId = ddr.CommitId, CreatedAt = ddr.CreatedAt, DiffHunk = ddr.DiffHunk, Identifier = ddr.Id, Issue = ddr.IssueId, OriginalCommitId = ddr.OriginalCommitId, OriginalPosition = ddr.OriginalPosition, Path = ddr.Path, Position = ddr.Position, Repository = ddr.RepositoryId, Review = ddr.PullRequestReviewId, UpdatedAt = ddr.UpdatedAt, User = ddr.UserId, }; } else { entry.Data = new DeletedEntry(ddr.Id); } entries.Add(entry); } // Commit Statuses reader.NextResult(); while (reader.Read()) { entries.Add(new SyncLogEntry() { Action = SyncLogAction.Set, Entity = SyncEntityType.CommitStatus, Data = new CommitStatusEntry() { Context = ddr.Context, CreatedAt = ddr.CreatedAt, Description = ddr.Description, Identifier = ddr.Id, Reference = ddr.Reference, Repository = ddr.RepositoryId, State = ddr.State, TargetUrl = ddr.TargetUrl, UpdatedAt = ddr.UpdatedAt, }, }); } // Protected Branches reader.NextResult(); while (reader.Read()) { var entry = new SyncLogEntry() { Action = (bool)ddr.Delete ? SyncLogAction.Delete : SyncLogAction.Set, Entity = SyncEntityType.ProtectedBranch }; if (entry.Action == SyncLogAction.Set) { entry.Data = new ProtectedBranchEntry() { Repository = ddr.RepositoryId, Identifier = ddr.Id, Name = ddr.Name, ExtensionData = ddr.Protection }; } else { entry.Data = new DeletedEntry(ddr.Id); } entries.Add(entry); } // Versions reader.NextResult(); while (reader.Read()) { switch ((string)ddr.OwnerType) { case "org": _versions.OrgVersions[(long)ddr.OwnerId] = (long)ddr.RowVersion; break; case "repo": _versions.RepoVersions[(long)ddr.OwnerId] = (long)ddr.RowVersion; break; default: throw new Exception($"Unknown OwnerType {ddr.OwnerType}"); } } // Send page sentLogs += entries.Count(); tasks.Add(_connection.SendJsonAsync(new SyncResponse() { Logs = entries, Remaining = totalLogs - sentLogs, Versions = VersionDetails, SpiderProgress = spiderProgress })); } } await Task.WhenAll(tasks); } }
public string IssueUpdate(IssueEntry IssueObj) { IssueActiveDbo objIssueActiveDbo = new IssueActiveDbo(); return(objIssueActiveDbo.IssueUpdate(IssueObj)); }
public string Issuesave(IssueEntry IssueObj) { IssueEntryDbo objIssueEntryDbo = new IssueEntryDbo(); return(objIssueEntryDbo.Issuesave(IssueObj)); }