public DefectBase startEvent(int ttid, string disp, int hrs, string date) { CurrentContext.Validate(); DateTime dt = DateTime.ParseExact(date, IdBasedObject.defDateFormat, CultureInfo.InvariantCulture); int id = Defect.GetIDbyTT(ttid); DefectEvent.AddEventByTask(id, DefectEvent.Eventtype.worked, CurrentContext.TTUSERID, "I have worked on this task", hrs, -1, dt); NotifyHub.NotifyDefectChange(id); return ChangeDispo(ttid, disp); }
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 List <DefectAttach> GetAttachsByTask(int ttid) { List <DefectAttach> res = new List <DefectAttach>(); int taksid = Defect.GetIDbyTT(ttid); int repid = Defect.GetRepRecByTTID(taksid); foreach (int i in EnumRecords(_Tabl, _ID, new string[] { _Rid }, new object[] { repid })) { res.Add(new DefectAttach(i)); } return(res); }
public static List <DefectBuild> EnumData(int from, int to, int ttid = -1) { List <DefectBuild> res = new List <DefectBuild>(); string ttfilter = ttid < 0 ? "" : $" WHERE {_par} = {Defect.GetIDbyTT(ttid)} "; string sql = $"SELECT * FROM (SELECT {_pid}, ROW_NUMBER() OVER (ORDER BY {_pid} DESC) ROWN FROM {_Tabl} {ttfilter}) TABL WHERE ROWN >= {from} AND ROWN <= {to} ORDER BY {_pid} desc"; foreach (DataRow r in DBHelper.GetRows(sql)) { res.Add(new DefectBuild(Convert.ToInt32(r[_pid]))); } return(res); }
public static void SendVersionAlarm() { string details = ""; string version = ""; Git git = new Git(Settings.CurrentSettings.TEMPGIT); foreach (var f in git.GetTopCommit().EnumFiles()) { if (f.Name.ToLower().Contains("changelog.txt")) { foreach (var d in f.Diff) { if (d.StartsWith("+")) { string line = d.Substring(1).Replace("<", "<").Replace(">", ">").Trim(); if (line.StartsWith("==")) { version = line.Replace("=", "").Trim(); } else { if (line.StartsWith("TT")) { if (line.EndsWith("@nolog", StringComparison.OrdinalIgnoreCase)) { continue; } Match m = Regex.Match(line, "TT[0-9]+"); if (m.Success) { string ttid = m.Value.Replace("TT", ""); line = string.Format("<a href='{0}{1}{2}'>{3}</a>", Settings.CurrentSettings.GLOBALSITEURL, StaticSettings.DefectUrl, ttid, line.Substring(0, Math.Min(line.Length, 120))); int id; if (Defect.GetIDbyTT(int.Parse(ttid), out id)) { DefectEvent.AddEventByTask(id, DefectEvent.Eventtype.versionIncluded, CurrentContext.TTUSERID, version, -1, -1, null); } } } details += line + Environment.NewLine; } } } } } details = details.Trim(); if (!string.IsNullOrEmpty(details)) { SendAlarm(string.Format("📢<a href='{3}versionchanges.aspx'>{0}</a> has been setup.{1}List of changes:{1}{2}{1}The build will be started as soon as possible." + $"👤:{CurrentContext.UserLogin()}", version, Environment.NewLine, details, Settings.CurrentSettings.GLOBALSITEURL)); } DefectPlan.UpdateEDD(); }
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); }
public static void CancelRequestByTask(int ttid) { string sql = $"UPDATE {_Tabl} SET {_stat} = {(int)BuildStatus.cancelled} WHERE {_par} = {Defect.GetIDbyTT(ttid)} AND ({_stat} = {(int)BuildStatus.progress} OR {_stat} = {(int)BuildStatus.notstarted} OR {_stat} IS NULL)"; SQLExecute(sql); }
public static List <DefectHistory> GetHisotoryByTask(int ttid) { List <DefectHistory> res = new List <DefectHistory>(); foreach (int i in EnumRecords(_Tabl, _ID, new string[] { _ParentID }, new object[] { Defect.GetIDbyTT(ttid) })) { res.Add(new DefectHistory(i)); } res.Sort( delegate(DefectHistory h1, DefectHistory h2) { return(Convert.ToDateTime(h1[_Dat]).CompareTo(Convert.ToDateTime(h2[_Dat]))); } ); return(res); }
public static List <DefectEvent> GetEventsByTask(int ttid) { List <DefectEvent> res = new List <DefectEvent>(); foreach (int i in EnumRecords(_Tabl, _ID, new string[] { _ParentID }, new object[] { Defect.GetIDbyTT(ttid) })) { res.Add(new DefectEvent(i)); } return(res); }
public static int New(string summary) { lock (_lockobject) { string sql = $@" INSERT INTO {_Tabl} ( {_PrjID}, {_idRec}, {_Created}, {_CreaBy}, {_ModDate}, {_ModBy}, {_ID}, {_Summ}, {_Stat}, {_StatI}, {_Type}, {_Prod}, {_idEntr}, {_Disp}, {_Prio}, {_Comp}, {_Seve}, {_Date}, {_AdLoc}) values ( 1 , (SELECT MAX(T1.{_idRec}) + 1 FROM {_Tabl} T1) , GETUTCDATE() , {CurrentContext.TTUSERID} , GETUTCDATE() , {CurrentContext.TTUSERID} , (SELECT MAX(T1.{_ID}) + 1 FROM {_Tabl} T1) , ? , 1 , 1 , {DefectDefaults.CurrentDefaults.TYPE} , {DefectDefaults.CurrentDefaults.PRODUCT} , {CurrentContext.TTUSERID} , {DefectDefaults.CurrentDefaults.DISP} , {DefectDefaults.CurrentDefaults.PRIO} , {DefectDefaults.CurrentDefaults.COMP} , {DefectDefaults.CurrentDefaults.SEVR} , GETUTCDATE() , 1 )" ; SQLExecute(sql, new object[] { summary }); string sqlid = string.Format("SELECT TOP 1 {0} FROM {1} WHERE {2} = {3} ORDER BY {0} DESC", _ID, _Tabl, _CreaBy, CurrentContext.TTUSERID); int ttid = Convert.ToInt32(GetValue(sqlid)); int recid = Defect.GetIDbyTT(ttid); string sqlrep = string.Format(@" INSERT INTO {0}(IDRECORD, PROJECTID, IDFOUNDBY, DATEFOUND, ORDERNUM, IDREPROD, TSTCONTYPE, IDCONFIG, IDDEFREC) VALUES((SELECT MAX(R2.IDRECORD) + 1 FROM {0} R2), 1, {1}, GETUTCDATE(), 1, 0, 1, 4294967293, {2}) " , _RepTable, CurrentContext.TTUSERID, recid); SQLExecute(sqlrep); return(ttid); } }
public DefectBase versionChange(int ttid, string version) { int id = Defect.GetIDbyTT(ttid); DefectEvent.AddEventByTask(id, DefectEvent.Eventtype.versionIncluded, CurrentContext.TTUSERID, version, -1, -1, null); return new DefectBase(ttid); }