private Boolean CheckForDuplicateHistory(DefectHistory defectHistory) { var checkHistorySql = @"SELECT COUNT(*) FROM TFS_DefectHistory AS DefectHistory WHERE DefectHistory.DefectId = @id AND DefectHistory.History = @history"; DynamicParameters parameters = new DynamicParameters(); parameters.Add("id", defectHistory.DefectId); parameters.Add("history", defectHistory.History); using (var conn = GetOpenConnection()) { int count = conn.ExecuteScalar <int>(checkHistorySql, parameters); if (count >= 1) { return(true); } else { return(false); } } }
private async Task <DefectHistory> GetLatestDefectHistory(int defectId) { DefectHistory res = null; var requestUri = "/APHP/_apis/wit/workitems/" + defectId + "/history?api-version=3.0"; var method = new HttpMethod("GET"); var request = new HttpRequestMessage(method, requestUri) { }; var response = await _client.SendAsync(request); if (response.IsSuccessStatusCode) { string workItem = await response.Content.ReadAsStringAsync(); JObject jo = JObject.Parse(workItem); int count = Convert.ToInt32(jo["count"].ToString()); if (count > 0) { res = new DefectHistory(); res.History = jo["value"][count - 1]["value"].ToString(); res.Timestamp = DateTime.Parse(jo["value"][count - 1]["revisedDate"].ToString()); } } return(res); }
public List <DefectHistory> gettaskhistory(string ttid) { if (string.IsNullOrEmpty(ttid)) { return(null); } return(DefectHistory.GetHisotoryByTask(Convert.ToInt32(ttid))); }
public static void AddAttachByTask(int ttid, string filename, string data) { int taksid = Defect.GetIDbyTT(ttid); int repid = Defect.GetRepRecByTTID(taksid); byte[] filedata = Convert.FromBase64String(data); byte[] filedata4Disk = filedata; int filesize = filedata.Length; if (filedata.Length > 1024 * 1024 * 5) { filedata = new byte[0]; } int key = DefectAttach.AddObject( _FileTabl, new string[] { "idRecord", "ProjectID", "ArchvFile", "FileData" }, new object[] { new Expression(string.Format("(SELECT MAX(IDRECORD) + 1 FROM {0} where IDRECORD < 3000000)", _FileTabl)), 1, new Expression(string.Format("(SELECT CONVERT(VARCHAR(10), MAX(IDRECORD) + 1) + '.DAT' FROM {0} where IDRECORD < 3000000)", _FileTabl)), filedata }, "IDRECORD" ); int attkey = DefectAttach.AddObject( _Tabl, new string[] { _ID, _Proj, _Entit, _AttType, _Rid, _Name, _Mac, _MacCr, _DateC, _Size, _File, _Compr, _InDB }, new object[] { new Expression(string.Format("(SELECT MAX(IDRECORD) + 1 FROM {0} where IDRECORD < 3000000)", _Tabl)), 1, 1684431732, 1, repid, filename, 1061109567, 1061109567, new Expression("GETUTCDATE()"), filesize, string.Format("{0}.DAT", key), 0, 1 }, "IDRECORD" ); if (filedata.Length < 1) { if (!Directory.Exists(Settings.CurrentSettings.DEFECTATTACHDIR)) { Directory.CreateDirectory(Settings.CurrentSettings.DEFECTATTACHDIR); } DefectAttach da = new DefectAttach(attkey); File.WriteAllBytes(da.FileOnDisk, filedata4Disk); } DefectHistory.AddHisotoryByTask(taksid, string.Format("Added attachment: {0}", filename)); }
public static void DeleteAttach(string ttid, int id) { DefectAttach a = new DefectAttach(id); int taksid = Defect.GetIDbyTT(Convert.ToInt32(ttid)); DefectHistory.AddHisotoryByTask(taksid, string.Format("Deleted attachment: {0}", a.FILENAME)); string fname = a.FileOnDisk; if (File.Exists(fname)) { File.Delete(fname); } DeleteObject(_Tabl, id.ToString(), _ID); }
protected override bool RecordServiceHistory() { DefectHistory h = new DefectHistory(); AssignToDefectHistory(h); foreach (DefectDetail d in DefectDetails) { DefectHistoryDetail hd = new DefectHistoryDetail(); AssignDefectDetailsToDefectHistoryDetail(d, hd); hd.ServiceHistorySummary = h; ObjScope.Add(hd); } ObjScope.Add(h); return(true); }
protected override void PostStore() { if (REQUESTRESET) { DefectHistory.DelHisotoryByTask(IDREC); DefectEvent.DelHisotoryByTask(IDREC); _HistoryChanges = "Task was reset."; } if (!string.IsNullOrEmpty(_HistoryChanges)) { DefectHistory.AddHisotoryByTask(IDREC, _HistoryChanges, GetUpdater().TTUSERID.ToString()); _HistoryChanges = ""; } base.PostStore(); }
private async Task <List <DefectHistory> > GetAllDefectHistory(int defectId) { List <DefectHistory> res = null; var requestUri = "/APHP/_apis/wit/workitems/" + defectId + "/history?api-version=3.0"; var method = new HttpMethod("GET"); var request = new HttpRequestMessage(method, requestUri) { }; var response = await _client.SendAsync(request); if (response.IsSuccessStatusCode) { string workItem = await response.Content.ReadAsStringAsync(); JObject jo = JObject.Parse(workItem); int count = Convert.ToInt32(jo["count"].ToString()); if (count > 0) { res = new List <DefectHistory>(); foreach (JToken token in jo["value"]) { DefectHistory currDefectHistory = new DefectHistory { History = token["value"].ToString(), Timestamp = DateTime.Parse(token["revisedDate"].ToString()) }; res.Add(currDefectHistory); } } } return(res); }
public override void InsertAsync(Defect entity) { var sql = @"INSERT OR REPLACE INTO TFS_Defect AS Defect (DefectId, DefectName, DefectSeverity, DefectHistory, Status, AssignedTo, DefectCreateDate, DefectCreatedBy, DiscussionDate, Iteration, DefectType, ApplicationArea, ApplicationProcess, FoundInEnvironment) VALUES (@DefectId, @DefectName, @DefectSeverity, @DefectHistory, @Status, @AssignedTo, @DefectCreateDate, @DefectCreatedBy, @DiscussionDate, @Iteration, @DefectType, @ApplicationArea, @ApplicationProcess, @FoundInEnvironment)"; var historySql = @"INSERT OR REPLACE INTO TFS_DefectHistory AS DefectHistory (DefectId, History, Timestamp) VALUES (@DefectId, @History, @Timestamp)"; var testCaseDefectSql = @"INSERT OR REPLACE INTO MP_TestCaseDefectMap AS TestCaseDefectMap (TestCaseId, DefectId) VALUES (@TestCaseId, @DefectId);"; using (var conn = GetOpenConnection()) { conn.Execute(sql, entity); } if (entity.DefectHistories != null) { DeleteDefectHistoryById(entity.DefectId); foreach (DefectHistory history in entity.DefectHistories) { if (!CheckForDuplicateHistory(history)) { DefectHistory copyHistory = history.CloneJson <DefectHistory>(); copyHistory.DefectId = entity.DefectId; using (var conn = GetOpenConnection()) { conn.Execute(historySql, copyHistory); } } } } if (entity.TestCases != null) { foreach (TestCase testCase in entity.TestCases) { if (!CheckForDuplicateTestCaseDefectMap(entity, testCase)) { TestCaseDefectMap testCaseDefectMap = new TestCaseDefectMap { DefectId = entity.DefectId, TestCaseId = testCase.TestCaseId }; using (var conn = GetOpenConnection()) { conn.Execute(testCaseDefectSql, testCaseDefectMap); } } } } }
protected virtual void AssignToDefectHistory(DefectHistory t) { t.HistoryMainLine = this.HistoryMainLine; t.QtyInspected = this.QtyInspected; }