public void CreateAssets() { if (sandboxProject == null) { sandboxProject = SandboxProject; andre = Instance.Get.MemberByID("Member:1000"); danny = Instance.Get.MemberByID("Member:1005"); epic1 = Instance.Create.Epic("Epic 1", SandboxProject); epic2 = epic1.GenerateChildEpic(); epic2.Name = "Epic 2"; epic2.Save(); story1 = SandboxProject.CreateStory("Story 1"); story2 = SandboxProject.CreateStory("Story 2"); story3 = SandboxProject.CreateStory("Story 3"); defect1 = SandboxProject.CreateDefect("Defect 1"); defect2 = SandboxProject.CreateDefect("Defect 2"); defect3 = SandboxProject.CreateDefect("Defect 3"); story1.Description = "ABCDEFGHIJKJMNOPQRSTUVWXYZ"; story1.Save(); story2.Description = "1234567890"; story2.Save(); story3.Description = "123 ABC"; story3.Save(); story1.Owners.Add(andre); story1.Owners.Add(danny); story3.Owners.Add(andre); defect2.Owners.Add(andre); defect3.Owners.Add(danny); defect1.FoundInBuild = "1.0.0.0"; defect1.ResolvedInBuild = "1.0.0.2"; defect1.Environment = "Windows"; defect1.Estimate = 2.0; defect1.Reference = "123456"; defect1.Save(); defect2.AffectedByDefects.Add(defect1); defect2.FoundInBuild = "1.0.0.0"; defect2.FoundBy = "Joe"; defect2.VerifiedBy = andre; defect2.Environment = "Mac"; defect2.Type.CurrentValue = "Documentation"; defect2.ResolutionReason.CurrentValue = "Duplicate"; defect2.Estimate = 1.0; defect2.Save(); defect3.FoundInBuild = "1.0.0.1"; defect3.FoundBy = "Bob"; defect3.VerifiedBy = danny; defect3.Type.CurrentValue = "Code"; defect3.ResolutionReason.CurrentValue = "Fixed"; defect3.Save(); } }
/// <summary> /// This method get the defect list based on filter search criteria -Prabasini & Shilpa /// </summary> /// <param name="projectId"></param> /// <param name="typeId"></param> /// <param name="priorityId"></param> /// <param name="statusId"></param> /// <param name="createdBy"></param> /// <returns></returns> public static IEnumerable<Defect> GetDefectListBasedOnFilter(int projectId,int typeId,int priorityId,int statusId, string createdBy) { SqlConnection conn = new SqlConnection(SqlConString); List<Defect> defectlist = new List<Defect>(); try { //Create the SqlCommand object SqlCommand cmd = new SqlCommand("sp_GetDefectsBasedOnFilter", conn); //Specify that the SqlCommand is a stored procedure cmd.CommandType = System.Data.CommandType.StoredProcedure; //Add the input parameters to the command object cmd.Parameters.AddWithValue("@Project", projectId); cmd.Parameters.AddWithValue("@DefectType", typeId); cmd.Parameters.AddWithValue("@DefectPriority", priorityId); cmd.Parameters.AddWithValue("@DefectStatus", statusId); cmd.Parameters.AddWithValue("@DefectCreatedBy", createdBy); conn.Open(); SqlDataReader reader = cmd.ExecuteReader();//define reader object and populate data in it if (reader != null) { while (reader.Read()) { Defect defect = new Defect(); defect.Id = int.Parse(reader["Id_Defect"].ToString()); defect.ProjectName = reader["ProjectName"].ToString(); defect.Title = reader["Txt_Title"].ToString(); defect.DefectType = reader["Txt_DefType"].ToString(); defect.Status = reader["Txt_Status"].ToString(); defect.CreatedBy = reader["Txt_CreatedBy"].ToString(); defect.AssignedTo = reader["Txt_AssignTo"].ToString(); defect.FixedBy = reader["Txt_FixedBy"].ToString(); defect.ClosedBy = reader["Txt_ClosedBy"].ToString(); defect.Priority = reader["Txt_Priority"].ToString(); if (reader["Dt_ClosedBy"] != System.DBNull.Value) defect.DateClosed = Convert.ToDateTime(reader["Dt_ClosedBy"]); defectlist.Add(defect); } } reader.Close(); } catch (Exception ex) { throw (ex); } finally { if (conn != null) conn.Close(); } return defectlist; }
public static DefectServiceModel mapDefectEntityToModel(Defect defect) { DefectServiceModel model = new DefectServiceModel(); model.createdDate = defect.CreateDate; model.subject = defect.Subject; model.description = defect.Description; model.environment = defect.Environment; model.lastUpdatedDate = defect.LastUpdatedDate; model.serverity = mapDefectServerity(defect.Serverity); model.status = mapDefectServerity(defect.Status); model.id = defect.Id; return model; }
static void Main(string[] args) { // create a service object RallyServiceService service = new RallyServiceService(); service.Url = "https://rally1.rallydev.com/slm/webservice/1.42/RallyService"; // login to service using HTTP Basic auth System.Net.NetworkCredential crediential = new System.Net.NetworkCredential("*****@*****.**", "secret"); Uri uri = new Uri(service.Url); System.Net.ICredentials credentials = crediential.GetCredential(uri, "Basic"); service.Credentials = credentials; service.PreAuthenticate = true; // Configure the service to maintain an HTTP session cookie service.CookieContainer = new System.Net.CookieContainer(); Workspace workspace = null; // Make the web service call //--------------------------- Defect defect = new Defect(); service.create(defect); // Name is required defect.Name = "bad defect"; defect.Description = "trouble"; //Create defect on the server CreateResult createResult = service.create(defect); if (hasErrors(createResult)) { // something went wrong Console.WriteLine("Could not create defect result:"); printWarningsErrors(createResult); } else { // look at the object returned from create() defect = (Defect)createResult.Object; Console.WriteLine("Created defect, ref = " + defect.@ref); } }
/// <summary> /// Method to add defect in the database /// </summary> /// <param name="defect"></param> public static void AddDefect(Defect defect) { SqlConnection conn = new SqlConnection(SqlConString); try { //Create the SqlCommand object SqlCommand cmd = new SqlCommand("sp_InsertUpdateSelectDefect", conn); //Specify that the SqlCommand is a stored procedure cmd.CommandType = System.Data.CommandType.StoredProcedure; //Add the input parameters to the command object cmd.Parameters.AddWithValue("@Defect_Id", defect.Id); cmd.Parameters.AddWithValue("@Proj_Id", defect.ProjectId); cmd.Parameters.AddWithValue("@Title", defect.Title); cmd.Parameters.AddWithValue("@DefectType_Id", defect.DefectType); cmd.Parameters.AddWithValue("@StageOfOrigin_Id", defect.StageOfOrigin); cmd.Parameters.AddWithValue("@Priority_Id", defect.Priority); cmd.Parameters.AddWithValue("@Status_Id", defect.Status); cmd.Parameters.AddWithValue("@AssignTo", defect.AssignedTo); cmd.Parameters.AddWithValue("@Description", defect.Description); cmd.Parameters.AddWithValue("@HowFixed", defect.HowFixed); cmd.Parameters.AddWithValue("@CreatedBy", defect.CreatedBy); cmd.Parameters.AddWithValue("@StatementType", "Insert"); //Open the connection and execute the query conn.Open(); cmd.ExecuteNonQuery(); } catch(Exception ex) { throw ex; } finally { conn.Close(); } }
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 ActionResult AddDefect(DefectModel model) { if (Convert.ToInt32(Session["Defect_SIT"]) == 1) { if (model.DetailList[0] != "") { int projectID = Convert.ToInt32(Session["ProjectID"]); Defect d = new Defect(); SubTask st = new SubTask(); int SIT_ID = Convert.ToInt32(Session["SIT_ID"]); var count = model.DetailList.Count; if (count > 1) { for (int i = 0; i < count; ++i) { d.Sub_ID = SIT_ID; d.Detail = model.DetailList[i].ToString(); d.SendDate = model.SendDateList[i]; d.Status = 0; d.CreateDate = DateTime.Now; d.CreateBy = Convert.ToInt32(Session["userID"]); d.Project_ID = projectID; if (model.AttachFileList[i] != null) { var Upload = Upload_Defect(model.AttachFileList[i]); string[] txt = Upload.Split(",".ToCharArray()); d.AttachFile = txt[0]; d.AttachShow = txt[1]; } db.Defects.Add(d); db.SaveChanges(); var SIT = db.SITs.Where(m => m.SIT_ID == SIT_ID).FirstOrDefault(); SIT.Defect_SIT = 1; SIT.Status = 4; db.SaveChanges(); var Email = db.Users.Where(m => m.User_ID == d.CreateBy).FirstOrDefault(); var Sendto = db.Users.Where(m => m.User_ID == SIT.Dev_ID).FirstOrDefault(); string sender = Email.User_Email.ToString(); //string sender = "*****@*****.**"; string subject = "Defect หัวข้อ" + st.SubName; string receiver = Sendto.User_Email.ToString(); //string receiver = "*****@*****.**"; string mess = "มีข้อผิดพลาดในหัวข้อ" + st.SubName; InboxController ms = new InboxController(); ms.SendEmail(receiver, subject, mess, sender); } } else { d.Sub_ID = SIT_ID; d.Detail = model.DetailList[0].ToString(); d.SendDate = model.SendDateList[0]; d.Status = 0; d.CreateDate = DateTime.Now; d.CreateBy = Convert.ToInt32(Session["userID"]); d.Project_ID = projectID; if (model.AttachFileList[0] != null) { var Upload = Upload_Defect(model.AttachFileList[0]); string[] txt = Upload.Split(",".ToCharArray()); d.AttachFile = txt[0]; d.AttachShow = txt[1]; } db.Defects.Add(d); db.SaveChanges(); var SIT = db.SITs.Where(m => m.SIT_ID == SIT_ID).FirstOrDefault(); SIT.Defect_SIT = 1; SIT.Status = 4; db.SaveChanges(); var Email = db.Users.Where(m => m.User_ID == d.CreateBy).FirstOrDefault(); var Sendto = db.Users.Where(m => m.User_ID == SIT.Dev_ID).FirstOrDefault(); string sender = Email.User_Email.ToString(); //string sender = "*****@*****.**"; string subject = "Defect หัวข้อ" + st.SubName; string receiver = Sendto.User_Email.ToString(); //string receiver = "*****@*****.**"; string mess = "มีข้อผิดพลาดในหัวข้อ" + st.SubName; InboxController ms = new InboxController(); ms.SendEmail(receiver, subject, mess, sender); } return(RedirectToAction("ShowDefect")); } return(View(new DefectModel { Error_Detail = "กรุณาใส่ข้อมูลให้ครบถ้วน" })); } else { if (model.DetailList[0] != "") { int projectID = Convert.ToInt32(Session["ProjectID"]); Defect d = new Defect(); SubTask st = new SubTask(); int SubID = Convert.ToInt32(Session["SubID"]); var count = model.DetailList.Count; if (count > 1) { for (int i = 0; i < count; ++i) { d.Sub_ID = model.Sub_ID; d.Detail = model.DetailList[i].ToString(); d.SendDate = model.SendDateList[i]; d.Status = 0; d.CreateDate = DateTime.Now; d.CreateBy = Convert.ToInt32(Session["userID"]); d.Project_ID = projectID; if (model.AttachFileList[i] != null) { var Upload = Upload_Defect(model.AttachFileList[i]); string[] txt = Upload.Split(",".ToCharArray()); d.AttachFile = txt[0]; d.AttachShow = txt[1]; } db.Defects.Add(d); db.SaveChanges(); var s = db.SubTasks.Where(m => m.SubID == model.Sub_ID).FirstOrDefault(); s.HaveDefect = 1; s.SubStatus = 5; s.SubPercent = 25; db.SaveChanges(); var Email = db.Users.Where(m => m.User_ID == d.CreateBy).FirstOrDefault(); var Sendto = db.Users.Where(m => m.User_ID == s.SubDevID).FirstOrDefault(); string sender = Email.User_Email.ToString(); //string sender = "*****@*****.**"; string subject = "Defect หัวข้อ" + st.SubName; string receiver = Sendto.User_Email.ToString(); //string receiver = "*****@*****.**"; string mess = "มีข้อผิดพลาดในหัวข้อ" + st.SubName; InboxController ms = new InboxController(); ms.SendEmail(receiver, subject, mess, sender); } } else { d.Sub_ID = model.Sub_ID; d.Detail = model.DetailList[0].ToString(); d.SendDate = model.SendDateList[0]; d.Status = 0; d.CreateDate = DateTime.Now; d.CreateBy = Convert.ToInt32(Session["userID"]); d.Project_ID = projectID; if (model.AttachFileList[0] != null) { var Upload = Upload_Defect(model.AttachFileList[0]); string[] txt = Upload.Split(",".ToCharArray()); d.AttachFile = txt[0]; d.AttachShow = txt[1]; } db.Defects.Add(d); db.SaveChanges(); var s = db.SubTasks.Where(m => m.SubID == model.Sub_ID).FirstOrDefault(); s.HaveDefect = 1; s.SubStatus = 5; db.SaveChanges(); var Email = db.Users.Where(m => m.User_ID == d.CreateBy).FirstOrDefault(); var Sendto = db.Users.Where(m => m.User_ID == s.SubDevID).FirstOrDefault(); string sender = Email.User_Email.ToString(); //string sender = "*****@*****.**"; string subject = "Defect หัวข้อ" + st.SubName; string receiver = Sendto.User_Email.ToString(); //string receiver = "*****@*****.**"; string mess = "มีข้อผิดพลาดในหัวข้อ" + st.SubName; InboxController ms = new InboxController(); ms.SendEmail(receiver, subject, mess, sender); } return(RedirectToAction("ShowDefect")); } return(View(new DefectModel { Error_Detail = "กรุณาใส่ข้อมูลให้ครบถ้วน" })); } }
private void GenerateCodeFlows(Defect defect, Result result) { List <SFA> sfas = defect?.Path?.SFAs; if (sfas == null || sfas.Count == 0) { return; } int step = 0; var locations = new List <AnnotatedCodeLocation>(); bool pathUsesKeyEvents = defect.Path.SFAs.Any(x => !string.IsNullOrWhiteSpace(x?.KeyEvent?.Id)); foreach (var sfa in defect.Path.SFAs) { var region = new Region() { StartColumn = sfa.Column + 1, StartLine = sfa.Line }; var uri = new Uri($"{sfa.FilePath}{sfa.FileName}", UriKind.Relative); var fileLocation = new PhysicalLocation(uri: uri, uriBaseId: null, region: region); var annotatedCodeLocation = new AnnotatedCodeLocation { PhysicalLocation = fileLocation, Step = ++step }; if (pathUsesKeyEvents) { if (string.IsNullOrWhiteSpace(sfa.KeyEvent?.Id)) { annotatedCodeLocation.Importance = AnnotatedCodeLocationImportance.Unimportant; } else { annotatedCodeLocation.SetProperty("keyEventId", sfa.KeyEvent.Id); if (Enum.TryParse(sfa.KeyEvent.Kind, true, out AnnotatedCodeLocationKind kind)) { annotatedCodeLocation.Kind = kind; } if (Enum.TryParse(sfa.KeyEvent.Importance, true, out AnnotatedCodeLocationImportance importance)) { annotatedCodeLocation.Importance = importance; } if (!string.IsNullOrWhiteSpace(sfa.KeyEvent.Message)) { annotatedCodeLocation.Message = sfa.KeyEvent.Message; } } } locations.Add(annotatedCodeLocation); } result.CodeFlows = new List <CodeFlow>() { new CodeFlow { Locations = locations } }; }
private void justfortest() { /*for (int i = 0; i < 5; i++) * { * SessionInfo Session0 = new SessionInfo(0, i, i); * Session0.myHardInfo.AssignedName = "L1"; * sessionsInfoList.Add(Session0); * } * SessionInfo Session1 = new SessionInfo(1, 8, 8); * Session1.myHardInfo.AssignedName = "TOFD"; * sessionsInfoList.Add(Session1);*/ /*rowDatasList = new List<RowData>(); * for (int i = 0; i < 8; i++) * { * RowData newrow = new RowData(); * newrow.Cycle = "L1"; newrow.Activity = true; newrow.Source = Source.GateB; newrow.Mode = Mode.Strip; * rowDatasList.Add(newrow); * } * RowData newrow1 = new RowData(); * newrow1.Cycle = "TOFD"; newrow1.Activity = true; newrow1.Source = Source.GateB; newrow1.Mode = Mode.TOFD; * rowDatasList.Add(newrow1);*/ SessionInfo Session0 = new SessionInfo(0, 0, 0); Session0.myHardInfo.AssignedName = "L1"; Session0.type = 0; Session0.LR = 1; Session0.zonename = "FILL-0-L"; sessionsInfoList.Add(Session0); SessionInfo Session1 = new SessionInfo(0, 1, 1); Session1.myHardInfo.AssignedName = "L2"; Session1.type = 0; Session1.LR = 1; Session1.zonename = "FILL-1-L"; sessionsInfoList.Add(Session1); SessionInfo Session2 = new SessionInfo(0, 2, 2); Session2.myHardInfo.AssignedName = "L3"; Session2.type = 1; Session2.LR = 1; Session2.zonename = "HP-0-L"; sessionsInfoList.Add(Session2); SessionInfo Session3 = new SessionInfo(0, 3, 3); Session3.myHardInfo.AssignedName = "R1"; Session3.type = 0; Session3.LR = 0; Session3.zonename = "FILL-0-R"; sessionsInfoList.Add(Session3); Defect defect0 = new Defect(); defect0.subregionName = "FILL-0-L"; defect0.beginRadio = 1.0; defect0.endRadio = 10.0; sampleDefects.Add(defect0); Defect defect1 = new Defect(); defect1.subregionName = "FILL-1-L"; defect1.beginRadio = 2.0; defect1.endRadio = 9.0; sampleDefects.Add(defect1); Defect defect2 = new Defect(); defect2.subregionName = "HP-0-L"; defect2.beginRadio = 3.0; defect2.endRadio = 8.0; sampleDefects.Add(defect2); Defect defect3 = new Defect(); defect3.subregionName = "FILL-0-R"; defect3.beginRadio = 1.0; defect3.endRadio = 10.0; sampleDefects.Add(defect3); Defect defect4 = new Defect(); defect4.subregionName = "FILL-0-R"; defect4.beginRadio = 11.0; defect4.endRadio = 15.0; sampleDefects.Add(defect4); MaxValueOfSessions.Add(Session0.myHardInfo.AssignedName, 0.6); MaxValueOfSessions.Add(Session1.myHardInfo.AssignedName, 0.7); MaxValueOfSessions.Add(Session2.myHardInfo.AssignedName, 0.8); MaxValueOfSessions.Add(Session3.myHardInfo.AssignedName, 0.9); }
private static void SaveDefectImages(defectsdbContext dataBase, string badFile, Dictionary <string, TestDevice> devices, String deviceName) { var defectTypes = new Dictionary <String, DefectType>(); if (File.Exists(badFile)) { using (var file = new StreamReader(badFile)) { String fileName; while ((fileName = file.ReadLine()) != null) { if (fileName.Length > 0) { if (null == deviceName) { deviceName = fileName.Split('\\')[0]; } var device = GetTestDevice(dataBase, deviceName, devices); String[] img = fileName.Split('|'); String source = img[0]; var screenShot = new ScreenShot(); screenShot.FileName = deviceName + "\\" + source; screenShot.TestDevice = device; screenShot.Invalid = false; dataBase.ScreenShot.Add(screenShot); Console.WriteLine(source); for (int i = 1; i < img.Length; i++) { var d = img[i].Split('@')[0]; DefectType defectType; if (false == defectTypes.TryGetValue(d, out defectType)) { defectType = dataBase.DefectType.FirstOrDefault(p => p.Code == d); if (null == defectType) { defectType = new DefectType(); defectType.Code = d; defectType.Description = d; dataBase.DefectType.Add(defectType); dataBase.SaveChanges(); } else { defectTypes[d] = defectType; } } var defect = new Defect(); defect.DefectType = defectType; defect.ScreenShot = screenShot; dataBase.Defect.Add(defect); } } } } dataBase.SaveChanges(); } }
public DefectMethod(Defect Cdo, DefectMethods Method, Defect_Parameters Parameters) { this.Cdo = Cdo; this.ServiceMethod = Method; this.Parameters = Parameters; }
/// <summary> /// Method to read UI values & store in defect object to return /// </summary> /// <param name="defect"></param> /// <returns></returns> private static Defect GetDefectDetails(object defect) { var objDefect = new Defect(); var tmp = (Dictionary<string, object>)defect ; object objId = null; object objProjectId = null; object objTitle = null; object objDefectType = null; object objDescription = null; object objStageOfOrigin = null; object objDefectStatus = null; object objPriority = null; object objAssignedTo = null; object objHowFixed = null; if (tmp.TryGetValue("Id", out objId)) objDefect.Id = int.Parse(objId.ToString()); if (tmp.TryGetValue("ProjectId", out objProjectId)) objDefect.ProjectId = int.Parse(objProjectId.ToString()); if (tmp.TryGetValue("Title", out objTitle)) objDefect.Title = objTitle.ToString(); if (tmp.TryGetValue("DefectType", out objDefectType)) objDefect.DefectType = objDefectType.ToString(); if (tmp.TryGetValue("Description", out objDescription)) objDefect.Description = objDescription.ToString(); if (tmp.TryGetValue("StageOfOrigin", out objStageOfOrigin)) objDefect.StageOfOrigin = objStageOfOrigin.ToString(); if (tmp.TryGetValue("Status", out objDefectStatus)) objDefect.Status = objDefectStatus.ToString(); if (tmp.TryGetValue("AssignedTo", out objAssignedTo)) objDefect.AssignedTo = objAssignedTo.ToString(); if (tmp.TryGetValue("HowFixed", out objHowFixed)) objDefect.HowFixed = objHowFixed.ToString(); if (tmp.TryGetValue("Priority", out objPriority)) objDefect.Priority = objPriority.ToString(); objDefect.CreatedBy = HttpContext.Current.User.Identity.Name; return objDefect; }
// POST: api/Defect public void Post([FromBody] Defect defect) { var defectQueryObject = new DefectQueryObject(); DefectQueryObject.AddDefect(defect); }
/// <summary> /// get all defect list details from database /// </summary> /// <param name="userID"></param> /// <param name="roleOfLogin"></param> /// <returns></returns> public static IEnumerable<Defect> GetAllDefectList(string userID, string roleOfLogin) { SqlConnection conn = new SqlConnection(SqlConString); List<Defect> defectlist = new List<Defect>(); try { //Create the SqlCommand object SqlCommand cmd = new SqlCommand("sp_GetDefectsList", conn); //Specify that the SqlCommand is a stored procedure cmd.CommandType = System.Data.CommandType.StoredProcedure; //Add the input parameters to the command object cmd.Parameters.AddWithValue("@LoginID", userID); cmd.Parameters.AddWithValue("@Role", roleOfLogin); conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader != null) { while (reader.Read()) { Defect defect = new Defect(); defect.Id = int.Parse(reader["Id_Defect"].ToString()); defect.ProjectName = reader["ProjectName"].ToString(); defect.Title = reader["Txt_Title"].ToString(); defect.DefectType = reader["Txt_DefType"].ToString(); defect.Status = reader["Txt_Status"].ToString(); defect.CreatedBy = reader["Txt_CreatedBy"].ToString(); defect.AssignedTo = reader["Txt_AssignTo"].ToString(); defect.FixedBy = reader["Txt_FixedBy"].ToString(); defect.ClosedBy = reader["Txt_ClosedBy"].ToString(); if (reader["Dt_ClosedBy"] != System.DBNull.Value) defect.DateClosed = Convert.ToDateTime(reader["Dt_ClosedBy"]); defectlist.Add(defect); } } reader.Close(); } catch (Exception ex) { throw (ex); } finally { if (conn != null) conn.Close(); } return defectlist; }
/// <summary> /// Get the defect details of a particular defectid /// </summary> /// <param name="defectId"></param> /// <returns></returns> public static Defect GetDefectById(int defectId) { SqlConnection con = new SqlConnection(SqlConString); Defect defect = new Defect(); try { SqlCommand cmd = new SqlCommand("sp_GetDefectDetails", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; //Add the input parameters to the command object cmd.Parameters.AddWithValue("@DefectID", defectId); con.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader != null) { while (reader.Read()) { defect.Id = int.Parse(reader["Id_Defect"].ToString()); defect.ProjectId = int.Parse(reader["Id_Project"].ToString()); defect.ProjectName = reader["ProjectName"].ToString(); defect.StageOfOrigin = reader["Id_StageOfOrigin"].ToString(); defect.Priority = reader["Id_Priority"].ToString(); defect.DefectType = reader["Id_DefType"].ToString(); defect.Status = reader["Id_Status"].ToString(); defect.Title = reader["Txt_Title"].ToString(); defect.HowFixed = reader["Txt_HowFixed"].ToString(); defect.Description = reader["Txt_Description"].ToString(); defect.CreatedBy = reader["Txt_CreatedBy"].ToString(); defect.AssignedTo = reader["Txt_AssignTo"].ToString(); } } reader.Close(); } catch (Exception ex) { throw (ex); } finally { if (con != null) con.Close(); } return defect; }
private void Set_Default_Stats(ref Equipment_Foundation Weapon_Editor, float Area_Of_Effect, float Number_Of_Attacks, float Minimum_Distance, float Maximum_Distance, float Movement, float Jump, float Knockback, float Level, float Melee_Multiplier, float Magic_Multiplier, float Archery_Multiplier, float Accuracy, float Evade, float Critical_Damage, float Critical_Chance, float Melee_Resistance, float Magic_Resistance, float Archery_Resistance,float Hitpoints_Multiplier = 0f, float Energy = 0f, Defect Defect = Defect.None) { Weapon_Editor.Get_Stat(Stat.Area_Of_Effect,Area_Of_Effect,true); Weapon_Editor.Get_Stat(Stat.Number_Of_Attacks,Number_Of_Attacks,true); Weapon_Editor.Get_Stat(Stat.Minimum_Distance,Minimum_Distance,true); Weapon_Editor.Get_Stat(Stat.Maximum_Distance,Maximum_Distance,true); Weapon_Editor.Get_Stat(Stat.Movement,Movement,true); Weapon_Editor.Get_Stat(Stat.Jump,Jump,true,true); Weapon_Editor.Get_Stat(Stat.Knockback,Knockback,true); Weapon_Editor.Level = Level; Weapon_Editor.Stat_Multiplier[(int)Stat.Melee_Damage] = Melee_Multiplier; Weapon_Editor.Stat_Multiplier[(int)Stat.Magic_Damage] = Magic_Multiplier; Weapon_Editor.Stat_Multiplier[(int)Stat.Archery_Damage] = Archery_Multiplier; Weapon_Editor.Stat_Multiplier[(int)Stat.Accuracy] = Accuracy; Weapon_Editor.Stat_Multiplier[(int)Stat.Evade] = Evade; Weapon_Editor.Get_Stat(Stat.Critical_Damage,Critical_Damage,true,true); Weapon_Editor.Get_Stat(Stat.Critical_Chance,Critical_Chance,true,true); Weapon_Editor.Get_Stat(Stat.Melee_Resistance,Melee_Resistance,true,true); Weapon_Editor.Get_Stat(Stat.Magic_Resistance,Magic_Resistance,true,true); Weapon_Editor.Get_Stat(Stat.Archery_Resistance,Archery_Resistance,true,true); Weapon_Editor.Get_Stat(Stat.Energy,Energy,true,true); Weapon_Editor.Stat_Multiplier[(int)Stat.Hitpoints] = Hitpoints_Multiplier; Weapon_Editor.Defect = Defect; Weapon_Editor.Passives.Clear(); }
public void CreateDefect(Defect defect) { throw new NotImplementedException(); }
private void GenerateCodeFlows(Defect defect, Result result) { List <SFA> sfas = defect?.Path?.SFAs; if (sfas == null || sfas.Count == 0) { return; } var locations = new List <ThreadFlowLocation>(); bool pathUsesKeyEvents = defect.Path.SFAs.Any(x => !string.IsNullOrWhiteSpace(x?.KeyEvent?.Id)); foreach (SFA sfa in defect.Path.SFAs) { var region = new Region() { StartColumn = sfa.Column + 1, StartLine = sfa.Line }; string filePath = sfa.FilePath + ((sfa.FilePath.EndsWith(@"\") ? "" : @"\")); var uri = new Uri($"{filePath}{sfa.FileName}", UriKind.Relative); var fileLocation = new PhysicalLocation { ArtifactLocation = new ArtifactLocation { Uri = uri }, Region = region }; var threadFlowLocation = new ThreadFlowLocation { Location = new Location { PhysicalLocation = fileLocation }, }; if (pathUsesKeyEvents) { if (string.IsNullOrWhiteSpace(sfa.KeyEvent?.Id)) { threadFlowLocation.Importance = ThreadFlowLocationImportance.Unimportant; } else { threadFlowLocation.SetProperty("keyEventId", sfa.KeyEvent.Id); if (Enum.TryParse(sfa.KeyEvent.Importance, true, out ThreadFlowLocationImportance importance)) { threadFlowLocation.Importance = importance; } if (!string.IsNullOrWhiteSpace(sfa.KeyEvent.Message) && threadFlowLocation.Location?.Message != null) { threadFlowLocation.Location.Message.Text = sfa.KeyEvent.Message; } } } locations.Add(threadFlowLocation); } result.CodeFlows = new List <CodeFlow>() { SarifUtilities.CreateSingleThreadedCodeFlow(locations) }; }
/// <summary> /// This reads all defects for the supplied User Story /// </summary> /// <param name="Parent">User Story to get all defects for</param> public static List<Defect> GetDefectsForStory(UserStory Parent) { List<Defect> listReturn = new List<Defect>(); // Grab all Defects under the given User Story LogOutput("Using RallyAPI to request defect information for all stories...", "GetDefectsForStory", true); LogOutput("Building Rally Request...", "GetDefectsForStory", true); Request rallyRequest = new Request("Defect"); rallyRequest.Fetch = new List<string>() { "Name", "FormattedID", "Description", "Iteration", "Owner", "Release", "State", "Blocked", "BlockedReason" }; rallyRequest.Query = new Query("Requirement.Name", Query.Operator.Equals, Parent.Name.Trim()); LogOutput("Running Rally Query request...", "GetDefectsForStory", true); QueryResult rallyResult = RallyAPI.Query(rallyRequest); LogOutput("Looping through Query request...", "GetDefectsForStory", true); foreach (var result in rallyResult.Results) { Defect defect = new Defect(); defect.Name = RationalizeData(result["Name"]); defect.FormattedID = RationalizeData(result["FormattedID"]); defect.Description = RationalizeData(result["Description"]); defect.Iteration = RationalizeData(result["Iteration"]); defect.Owner = RationalizeData(result["Owner"]); defect.Release = RationalizeData(result["Release"]); defect.State = RationalizeData(result["State"]); defect.ParentStory = Parent.FormattedID.Trim(); defect.Tasks = GetTasksForUserStory(defect.FormattedID); defect.Blocked = RationalizeData(result["Blocked"]); defect.BlockedReason = RationalizeData(result["BlockedReason"]); LogOutput("Appending new defect object to return list...", "GetDefectsForStory", true); listReturn.Add(defect); } LogOutput("Completed processing all defects, returning list", "GetDefectsForStory", true); return listReturn; }
public List <Statistic> getStatistics(string start, string days) { return(Defect.EnumStatistics(DateTime.ParseExact(start, defDateFormat, CultureInfo.InvariantCulture), Convert.ToInt32(days))); }
public ResultStatus GetActions(Defect defect) { return(this.GetActions(defect, (Defect_Parameters)null, (Defect_Request)null, out Defect_Result _)); }
public void SetTaskTestStatus(string ttid, string failed, string userphone) { try { MPSUser bsu = MPSUser.FindUserbyPhone(userphone); if (bsu == null) { Logger.Log($"Cannot update task {ttid} by testing system. User was not found by phone number: {userphone}"); return; } Defect d = new Defect(ttid); d.SetUpdater(bsu); string lockguid = Guid.NewGuid().ToString(); var lt = Defect.Locktask(ttid.ToString(), lockguid, bsu.ID.ToString()); bool locked = lt.globallock != lockguid; bool testFail; bool testcancel = false; if (!bool.TryParse(failed, out testFail)) { testcancel = true; } if (locked) { MPSUser lu = new MPSUser(lt.lockedby); TasksBot.SendMessage(lu.CHATID, $"You was disconnected from the task by the testing system to update task status!{Settings.CurrentSettings.GetTTAnchor(int.Parse(ttid), "disconnect.png")}"); NotifyHub.lockTaskForceUpdatePages(int.Parse(ttid), lockguid, bsu.ID); lt = Defect.Locktask(ttid.ToString(), lockguid, bsu.ID.ToString()); } List <DefectDispo> disp = (testcancel || testFail) ? DefectDispo.EnumTestsFailed() : DefectDispo.EnumTestsPassed(); if (disp.Count > 0) { if (!testcancel) { d.DISPO = disp[0].ID.ToString(); } else { d.AddMessage("Test request have been ignored", bsu.ID); } d.Store(); Defect.UnLocktask(ttid, lt.globallock); if (!testcancel) { DefectUser du = new DefectUser(d.AUSER); if (du.TRID > -1) { MPSUser worker = new MPSUser(du.TRID); string result = "Succeeded!"; string img = "taskokay.png"; if (testcancel) { result = "Cancelled!"; img = "bin.png"; } else if (testFail) { result = "Failed!"; img = "taskfail.png"; } TasksBot.SendMessage(worker.CHATID, $"The task tests have been marked as BST {result} by {bsu.PERSON_NAME}{Settings.CurrentSettings.GetTTAnchor(int.Parse(ttid), img)}"); } } } } catch (Exception e) { Logger.Log(e); } }
public void Get() { Defect defect = DataRepository.Defect.Get(6); Assert.AreEqual(304, defect.PartCode); }
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 void unlocktask(string ttid, string lockid) { Defect.UnLocktask(ttid, lockid); }
public void lockTaskForce(int ttid, string currentlock, int userid) { LockInfo li = Defect.Locktask(ttid.ToString(), currentlock, userid.ToString(), true); Clients.Caller.OnLockTask(li); }
public void FinishBuild(int id, string requestguid) { try { DefectBuild b = new DefectBuild(id) { STATUS = DefectBuild.BuildStatus.finishedok.ToString(), TESTGUID = requestguid }; b.Store(); if (Settings.CurrentSettings.RELEASETTID == b.TTID.ToString() && b.TYPE == (int)DefectBuild.BuildType.releasebuild) { //release builder sends its own notifications return; } Defect d = new Defect(b.TTID); DefectUser u = new DefectUser(b.TTUSERID); d.SetUpdater(new MPSUser(u.TRID)); List <DefectDispo> dsps = DefectDispo.EnumTestsStarted(); if (dsps.Count > 0) { string currentlock = Guid.NewGuid().ToString(); LockInfo li = Defect.Locktask(b.TTID.ToString(), currentlock, u.TRID.ToString(), true); d.DISPO = dsps[0].ID.ToString(); if (d.PRIMARYHOURS == null) { d.PRIMARYHOURS = d.SPENT; } d.Store(); DefectEvent.AddEventByTask(id, DefectEvent.Eventtype.QualityAssurance, b.TTUSERID, "Sent for QA Automation"); Defect.UnLocktask(u.TRID.ToString(), currentlock); } if (Settings.CurrentSettings.RELEASETTID == b.TTID.ToString()) { VersionBuilder.SendAlarm("✅New internal release build has been finished. Testing is starting..."); } else { try { string mess = $"New task from {u.FULLNAME} is ready for tests!{Settings.CurrentSettings.GetTTAnchor(b.TTID, d.FIRE ? "taskfire.png" : "")}"; TestChannel.SendMessage(mess); } catch (Exception e) { Logger.Log(e); } } string bst_b = d.BSTBATCHES.Trim(); string bst_c = d.BSTCOMMANDS.Trim(); if (!string.IsNullOrEmpty(bst_b) || !string.IsNullOrEmpty(bst_c)) { string batches = string.Join(",", bst_b.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries)); string commands = string.Join(",", bst_c.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries)); using (var wcClient = new WebClient()) { var reqparm = new NameValueCollection(); reqparm.Add("guid", requestguid); reqparm.Add("commaseparatedbatches", batches); reqparm.Add("commaseparatedcommands", commands); reqparm.Add("priority", d.TESTPRIORITY); //reqparm.Add("branch", d.BRANCHBST); wcClient.UploadValues(Settings.CurrentSettings.BSTSITESERVICE + "/StartTest", reqparm); } } } catch (Exception e) { Logger.Log(e); } }
public void UnLockTask(int ttid, string currentlock) { Defect.UnLocktask(ttid.ToString(), currentlock); }
public string alarmEmail(int ttid, string addresses) { if (!CurrentContext.Valid) { return("Please login"); } Defect d = new Defect(ttid); MailMessage mail = new MailMessage(); foreach (string addr in addresses.Split(',')) { mail.To.Add(new MailAddress(addr.Trim())); } mail.From = new MailAddress(CurrentContext.User.EMAIL.Trim()); mail.Subject = string.Format("TT{0} {1}", d.ID, d.SUMMARY); mail.IsBodyHtml = true; string descr = d.DESCR.Replace(Environment.NewLine, "<br/>"); descr = descr.Replace("\n", "<br/>"); descr = BodyProcessor.ResolveLinks(descr); descr = Regex.Replace(descr, "----+", "<hr>"); descr = Regex.Replace(descr, "====+", "<hr>"); string body = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">"; body += "<HTML><HEAD><META http-equiv=Content-Type content=\"text/html; charset=iso-8859-1\">"; body += "</HEAD><BODY'>" + descr + " </BODY></HTML>"; System.Net.Mime.ContentType mimeType = new System.Net.Mime.ContentType("text/html"); AlternateView alternate = AlternateView.CreateAlternateViewFromString(body, mimeType); mail.AlternateViews.Add(alternate); SmtpClient smtp = new SmtpClient(); Settings sett = Settings.CurrentSettings; smtp.Host = sett.SMTPHOST; smtp.Port = Convert.ToInt32(sett.SMTPPORT); smtp.EnableSsl = Convert.ToBoolean(sett.SMTPENABLESSL);; smtp.Timeout = Convert.ToInt32(sett.SMTPTIMEOUT);; smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.UseDefaultCredentials = false; smtp.Credentials = new NetworkCredential(sett.CREDENTIALS1, sett.CREDENTIALS2); string strError = "The email was sent!"; long counter = 0; while (true) { try { counter++; smtp.Send(mail); break; } catch (Exception e) { strError = e.Message; if (!strError.Contains("The operation has timed out.") || counter > 10) { break; } } } return(strError); }
public DefectEventDefect(int id) : base(id) { DEFECT = new DefectBase(Defect.GetTTbyID(DEFECTID)); }
private async Task Update(DefectViewModel viewModel, Defect defect) { var user = await GetUserAsync(); defect.Update(user, viewModel.Name, viewModel.Description); }
static XElement CreateDefect(Defect defect) { return(null); }
private void CheckMethodBody(MethodDefinition method) { var synchronizedEvents = new Dictionary <MethodReference, List <MethodReference> > (); var thisSynchronized = new List <TypeReference> (); foreach (Instruction ins in method.Body.Instructions) { MethodReference candidate = null; switch (ins.OpCode.Code) { case Code.Newobj: if (ins.Previous != null && ins.Previous.OpCode.Code == Code.Ldftn) { MethodReference ctor = (MethodReference)ins.Operand; TypeReference type = ctor.DeclaringType; if (type.IsDelegate()) { string nspace = type.Namespace; // ldftn entry-point // newobj System.Void System.Threading.XXX::.ctor (System.Object,System.IntPtr) // i.e. creation of a System.Threading delegate if (nspace == "System.Threading") { string name = type.Name; if (name == "ThreadStart" || name == "ParameterizedThreadStart" || name == "WaitCallback" || name == "WaitOrTimerCallback" || name == "TimerCallback") { candidate = (MethodReference)ins.Previous.Operand; } // ldftn entry-point // newobj System.Void System.AsyncCallback::.ctor (System.Object,System.IntPtr) // i.e. creation of a async delegate } else if (nspace == "System") { if (type.Name == "AsyncCallback") { candidate = (MethodReference)ins.Previous.Operand; } // ldftn entry-point // newobj System.Void ThreadedDelegate::.ctor (System.Object,System.IntPtr) // i.e. creation of a delegate which is decorated with a threading attribute } else if (!ThreadRocks.ThreadedNamespace(nspace)) { // Delegates must be able to call the methods they are bound to. MethodDefinition target = ((MethodReference)ins.Previous.Operand).Resolve(); if (target != null) { ThreadModel callerModel = type.ThreadingModel(); if (!target.IsGeneratedCode() || target.IsProperty()) { ThreadModel targetModel = target.ThreadingModel(); if (!IsValidCall(callerModel, targetModel)) { string mesg = String.Format(CultureInfo.InvariantCulture, "{0} delegate cannot be bound to {1} {2} method.", callerModel, targetModel, target.Name); ++DefectCount; Log.WriteLine(this, "Defect: {0}", mesg); Defect defect = new Defect(this, method, method, ins, Severity.High, Confidence.High, mesg); Runner.Report(defect); } } else if (!callerModel.Is(ThreadModel.MainThread)) { anonymous_entry_points.Add(target); } } } } } break; case Code.Call: case Code.Callvirt: if (!method.IsGeneratedCode() || method.IsProperty()) { CheckForLegalCall(method, ins); } // ldftn entry-point // newobj XXX // callvirt System.Void SynchronizedType::add_Name (XXX) // i.e. adding a delegate to an event in a type which uses SynchronizingObject MethodReference call = (MethodReference)ins.Operand; TypeReference call_type = call.DeclaringType; if (ins.Previous.Is(Code.Newobj) && ins.Previous.Previous.Is(Code.Ldftn)) { // A few events are blacklisted because they do not use SynchronizingObject and // are therefore always threaded. if (IsNonSynchronizedSetter(call)) { candidate = (MethodReference)ins.Previous.Previous.Operand; // But most events do use SynchronizingObject and therefore their threading // depends on whether and how SynchronizingObject is initialized. } else if (HasSynchronizingObject(call_type)) { List <MethodReference> methods; if (!synchronizedEvents.TryGetValue(call, out methods)) { methods = new List <MethodReference> (); synchronizedEvents.Add(call, methods); } methods.AddIfNew((MethodReference)ins.Previous.Previous.Operand); // Misc threaded events. } else if (call_type.IsNamed("System.ComponentModel", "BackgroundWorker")) { if (call.Name == "add_DoWork") { candidate = (MethodReference)ins.Previous.Previous.Operand; } } // callvirt System.Void System.Diagnostics.Process::set_SynchronizingObject (System.ComponentModel.ISynchronizeInvoke) } else if (SetSynchronizingObject.Matches(call)) { if (ins.Previous.OpCode.Code == Code.Ldarg_0) { thisSynchronized.Add(call_type); } } break; } if (candidate != null) { Log.WriteLine(this, "{0} is a thread entry point", candidate); CheckEntryPoint(candidate); } } // For every method added to a threaded event, ThreadModel?method_model = null; foreach (KeyValuePair <MethodReference, List <MethodReference> > entry in synchronizedEvents) { // if the event is synchronized on this then the target must have the same thread // as the current method's type or better and it should not be treated as a entry point. if (thisSynchronized.Contains(entry.Key.DeclaringType)) { if (method_model == null) { method_model = method.DeclaringType.ThreadingModel(); } foreach (MethodReference mr in entry.Value) { MethodDefinition target = mr.Resolve(); if (target != null) { ThreadModel targetModel = target.ThreadingModel(); if (!IsValidCall(method_model.Value, targetModel)) { string mesg = String.Format(CultureInfo.InvariantCulture, "{0} {1} cannot be bound to {2} {3} method.", method_model, entry.Key, targetModel, target.Name); ReportDefect(method, Severity.High, Confidence.High, mesg); } } } // otherwise the method has to be treated as a thread entry point. } else { foreach (MethodReference mr in entry.Value) { Log.WriteLine(this, "{0} is a thread entry point", mr); CheckEntryPoint(mr); } } } }
public void CreateDefectTest() { Defect defect = CreateDefect(); }
private void GenerateCodeFlows(Defect defect, Result result) { List <SFA> sfas = defect?.Path?.SFAs; if (sfas == null || sfas.Count == 0) { return; } int step = 0; var locations = new List <CodeFlowLocation>(); bool pathUsesKeyEvents = defect.Path.SFAs.Any(x => !string.IsNullOrWhiteSpace(x?.KeyEvent?.Id)); foreach (var sfa in defect.Path.SFAs) { var region = new Region() { StartColumn = sfa.Column + 1, StartLine = sfa.Line }; var uri = new Uri($"{sfa.FilePath}{sfa.FileName}", UriKind.Relative); var fileLocation = new PhysicalLocation(id: 0, fileLocation: new FileLocation(uri: uri, uriBaseId: null), region: region, contextRegion: null); var codeFlowLocation = new CodeFlowLocation { Location = new Location { PhysicalLocation = fileLocation }, Step = ++step }; if (pathUsesKeyEvents) { if (string.IsNullOrWhiteSpace(sfa.KeyEvent?.Id)) { codeFlowLocation.Importance = CodeFlowLocationImportance.Unimportant; } else { codeFlowLocation.SetProperty("keyEventId", sfa.KeyEvent.Id); if (Enum.TryParse(sfa.KeyEvent.Importance, true, out CodeFlowLocationImportance importance)) { codeFlowLocation.Importance = importance; } if (!string.IsNullOrWhiteSpace(sfa.KeyEvent.Message) && codeFlowLocation.Location?.Message != null) { codeFlowLocation.Location.Message.Text = sfa.KeyEvent.Message; } } } locations.Add(codeFlowLocation); } result.CodeFlows = new List <CodeFlow>() { SarifUtilities.CreateSingleThreadedCodeFlow(locations) }; }
public async Task <bool> Create(Defect entity) { await _db.Defects.AddAsync(entity); return(await Save()); }
public int insertDefect(DefectServiceModel defect) { DefectsRepository repo = new DefectsRepository(entities); Defect model = new Defect(); model.CreateDate = DateTime.Now; model.Description = defect.description; model.Id = 0; model.LastUpdatedDate = DateTime.Now; model.Serverity = DefectUtil.unmapDefectToServerity(defect.serverity); model.Status = DefectUtil.unmapDefectToStatus(defect.status); model.Subject = defect.subject; return repo.Insert(model); }
public async Task <bool> Delete(Defect entity) { _db.Defects.Remove(entity); return(await Save()); }
/// <summary> /// Generates a view of User Stories for a project rolled up to the story level /// </summary>q /// <param name="defects">Original list of Defects for project</param> /// <param name="DateToCalc">Date to create rollup for</param> public static List<Defect> CreateDailyRollup(List<Defect> defects, DateTime DateToCalc) { List<Defect> rollup = new List<Defect>(); foreach (Defect defect in defects) { Defect newdefect = new Defect(); newdefect.Description = defect.Description; newdefect.FormattedID = defect.FormattedID; newdefect.Iteration = defect.Iteration; newdefect.Name = defect.Name; newdefect.Owner = defect.Owner; newdefect.ParentStory = defect.ParentStory; newdefect.Release = defect.Release; newdefect.State = defect.State; newdefect.Tasks = defect.Tasks; newdefect.Blocked = defect.Blocked; newdefect.BlockedReason = defect.BlockedReason; newdefect.DefectActual = TaskTotal(defect.Tasks, ProjectTotal.Actual, DateToCalc); newdefect.DefectEstimate = TaskTotal(defect.Tasks, ProjectTotal.Estimate, DateToCalc); newdefect.DefectToDo = TaskTotal(defect.Tasks, ProjectTotal.ToDo, DateToCalc); if (newdefect.DefectActual != 0) { rollup.Add(newdefect); } } return rollup; }
public async Task <bool> Update(Defect entity) { _db.Defects.Update(entity); return(await Save()); }
// Logic IfBrackDownInProgrss Add Defect, Update It, Add Second Defect public void LogicBrackDowns(RaportareDbContext context, PlcModel plc, PlcService plcService, ReportService reportService) { Defect lastDefect = GetLastElementByPlc(context, plc); // Get Last defect from Plc // If is time of report finalise last defect and send mail (added for report excel file) if (lastDefect != null && lastDefect.DefectFinalizat == false) { //if list is not empty and last defect is not finalised // make report if it is time TODO if (reportService.MakeReport(context, plcService)) // make report to excel { UpdateLastNotFinishedDefect(context, lastDefect); // finished not finalised defect } } // Add PlcViewModel foreach (var plcViewModel in plcService.ListPlcViewModels) { if (lastDefect != null) { if (plcViewModel.PlcModel.Name == plc.Name) { plcViewModel.MapDefect(plcService, lastDefect, plc, context.Defects.Where(def => def.PlcModelID == plc.PlcModelID).ToList()); break; } } } // If is Breakdown in progress and list of defects is empty or last defect is finished Add Defect to list if (IsBreakDownInProgress(plc)) { // if is brackdown if (lastDefect == null) // if list is empty { AddNewDefectForPlc(context, plc); // Add Defect } else if (lastDefect.DefectFinalizat == true) // if list is not empty and last defect is finalised { AddNewDefectForPlc(context, plc); // Add defect } else if (lastDefect.DefectFinalizat == false) // if last defect is not finalised add Motiv Stationare { lastDefect.MotivStationare = GetMotivStationare(plcService, plc); // Add Motiv Stationare to lastDefect when it is pressed the button lastDefect.TimpStopDefect = DateTime.Now; // Add Stop time defect dynamic // Catch overflow error to IntervalStationare try { lastDefect.IntervalStationare = LimitMaxTimeSpan(lastDefect.TimpStartDefect, lastDefect.TimpStopDefect);// Add dynamic interval stationare // Limit the Interval Stationare Max Value } catch (OverflowException ex) { Console.WriteLine(String.Format("{0} <=> {1} <=> PlcaName: {2}", DateTime.Now.ToString("dd.MM.yyyy hh:mm:ss"), ex.Message, lastDefect.PlcModel.Name)); lastDefect.IntervalStationare = new TimeSpan(23, 59, 00); } context.Update(lastDefect); // Update DbContext with motiv stationare } } else // when machine start work again finished defect { if (lastDefect != null && lastDefect.DefectFinalizat == false) //if list is not empty and last defect is not finalised { UpdateLastNotFinishedDefect(context, lastDefect); // finished not finalised defect } } }
public ResultStatus ExecuteTransaction(Defect cdo) { return(this.ExecuteTransaction(cdo, (Defect_Request)null, out Defect_Result _)); }