public GitAPI InsertToDatabase(List <Issue> issues, BasicCRUD dal) { foreach (var issue in issues) { dal.AddOrUpdate <Issue>(issue, c => c.CreateAt == issue.CreateAt, Basic.ToDictionary <Issue>(issue)); } return(this); }
public GitAPI InsertToDatabase(List <Commit> commits, BasicCRUD dal, string githubUrl) { foreach (var commit in commits) { commit.GitHubUrl = githubUrl; dal.AddOrUpdate <Commit>(commit, c => c.CreateAt == commit.CreateAt, Basic.ToDictionary <Commit>(commit)); } return(this); }
public CodeHelper InsertToDatabase(List <Code> codes, BasicCRUD dal) { if (codes != null) { foreach (var item in codes) { item.SyncDate = DateTime.UtcNow; //dal.Add<Code>(item); dal.AddOrUpdate <Code>(item, c => c.GitHubUrl == item.GitHubUrl, Basic.ToDictionary <Code>(item)); } } return(this); }
public static IssuePageView ConvertIssueToIssueView(List <Issue> issues, BasicCRUD dal, int total) { IssuePageView pageview = new IssuePageView(); pageview.Total = total; List <getIssueView_Result> views = new List <getIssueView_Result>(); foreach (var item in issues) { getIssueView_Result view = new getIssueView_Result(); view.id = item.id; view.Title = item.Title; view.CreateAt = item.CreateAt; view.Number = item.Number; view.Url = item.Url; view.UnicodeId = item.UnicodeId; view.Replies = item.Replies; view.Author = item.Author; view.CodeID = item.CodeID; view.Type = item.Type; var aliasEntity = dal.GetEntities <CodeOwnership>(c => c.FkId == item.id && c.Type == "issue").OrderByDescending(p => p.LogAt).FirstOrDefault(); if (aliasEntity != null) { view.alias = aliasEntity.support_alias; } var uts = dal.GetEntities <UTLog>(c => c.FkId == item.id && c.Type == "issue"); int?utValue = 0; foreach (var ut in uts) { utValue += ut.UT; } view.UT = utValue; var process = dal.GetEntities <IssueStatusLog>(c => c.IssueID == item.id).OrderByDescending(c => c.LogAt).FirstOrDefault(); // DALProcessLog.GetLatestIssueProcess(item.id); if (process != null) { view.process = dal.GetEntities <IssueStatu>(c => c.id == process.IssueStatusID).First().name; } else { view.process = "New Issue"; } views.Add(view); } pageview.Views = views; return(pageview); }
public static List <CommitView> ConvertCommitToCommitView(List <Commit> issues, BasicCRUD dal) { List <CommitView> views = new List <CommitView>(); foreach (var item in issues) { CommitView view = new CommitView(); view.id = item.id; view.CreateAt = item.CreateAt; view.Author = item.Author; view.CodeID = item.CodeID; view.GitHubUrl = item.GitHubUrl; view.id = item.id; view.IsNew = item.IsNew; view.Message = item.Message; var process = dal.GetEntities <ProcessLog>(c => c.FkId == item.id && c.Type == "commit").OrderByDescending(c => c.LogAT).FirstOrDefault(); if (process != null) { view.Process = dal.GetEntities <Process>(c => c.id == process.ProcessID).First().name; } view.PSha = item.PSha; view.Sha = item.Sha; view.Type = item.Author; view.URL = item.URL; var uts = dal.GetEntities <UTLog>(c => c.FkId == item.id && c.Type == "commit");// context.UTLogs.Where(c => c.FkId == item.id && c.Type == "commit"); int?utValue = 0; foreach (var ut in uts) { utValue += ut.UT; } view.UT = utValue; var aliasEntity = dal.GetEntities <CodeOwnership>(c => c.FkId == item.id && c.Type == "commit").OrderByDescending(p => p.LogAt).FirstOrDefault(); if (aliasEntity != null) { view.Alias = aliasEntity.support_alias; } views.Add(view); } return(views); }