public async Task <ActionResult <DefectType> > PostDefectType(DefectType defectType) { _context.DefectTypes.Add(defectType); await _context.SaveChangesAsync(); return(CreatedAtAction("GetDefectType", new { id = defectType.Id }, defectType)); }
// GET: DefectTypes/Create public ActionResult Create() { DefectType defectType = new DefectType(); //set default value return(View(defectType)); }
public IDictionary <string, object> GetDefectTypeDynamic( DefectType row, DefectTypeQueryProjection projection, DefectTypeQueryOptions options) { var obj = new Dictionary <string, object>(); foreach (var f in projection.GetFieldsArr()) { switch (f) { case DefectTypeQueryProjection.INFO: { var entity = row; obj["id"] = entity.Id; obj["name"] = entity.Name; obj["code"] = entity.Code; obj["qc_mapping_code"] = entity.QCMappingCode; obj["description"] = entity.Description; obj["sample_image"] = entity.SampleImage; } break; } } return(obj); }
public ValidationData ValidateUpdateDefectType(ClaimsPrincipal principal, DefectType entity, UpdateDefectTypeModel model) { var validationData = new ValidationData(); if (string.IsNullOrWhiteSpace(model.Code)) { validationData.Fail("Defect code must not be null", Constants.AppResultCode.FailValidation); } else if (DefectTypes.Exists(model.Code)) { validationData.Fail("Defect code existed", Constants.AppResultCode.FailValidation); } if (string.IsNullOrWhiteSpace(model.QCMappingCode)) { validationData.Fail("QC Defect code must not be null", Constants.AppResultCode.FailValidation); } else if (DefectTypes.ExistsQCMappingCode(model.QCMappingCode)) { validationData.Fail("QC Defect code existed", Constants.AppResultCode.FailValidation); } if (string.IsNullOrWhiteSpace(model.Name)) { validationData.Fail("Name must not be null", Constants.AppResultCode.FailValidation); } return(validationData); }
public void LogDefectData(DefectType defect, DefectType nearest) { string line = defect.transform.name + "," + defect.ParentSurface.name + "," + defect.transform.position.ToString() + ":" + defect.NotMarked + "," + defect.NotRealDefect + ":" + nearest.transform.name; defect_data_writer.WriteLine(line); }
private Result refreshLayer(DefectType type) { int minXid = 0, minYid = 0, maxXid = 0, maxYid = 0; getGridID(ref minXid, ref minYid, ref maxXid, ref maxYid); try { GisClient.Result res = GisClient.ServiceApi.getGisLayerService().refreshDefectLayer(minXid, minYid, maxXid, maxYid, type); if (res.Ok) { return(new Result(true, "网内干扰图层图层刷新成功")); } else { return(new Result(false, "网内干扰图层刷新失败")); } } catch (Exception e) { return(new Result(false, "远程调用失败" + e)); } finally { ServiceApi.CloseConn(); } //OperateDefectLayer operateGrid3d = new OperateDefectLayer(layerName); //operateGrid3d.ClearLayer(); //if (!operateGrid3d.constuctGrid3Ds(minxid, minyid, maxxid, maxyid, type)) // return new Result(false, "数据为空"); //return new Result(true); }
public async Task <IActionResult> PutDefectType(Guid id, DefectType defectType) { if (id != defectType.Id) { return(BadRequest()); } _context.Entry(defectType).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DefectTypeExists(id)) { return(NotFound()); } else { return(StatusCode(StatusCodes.Status500InternalServerError)); } } return(NoContent()); }
public void DeleteDefectTypeFolder(DefectType entity, string uploadPath, string rootPath) { var fileService = provider.GetRequiredService <IFileService>(); var folderPath = Path.Combine(uploadPath, nameof(DefectType), entity.Id.ToString()); fileService.DeleteDirectory(folderPath, rootPath); }
public (string, string) GetDefectTypeImagePath(DefectType entity, string uploadPath, string rootPath) { var fileService = provider.GetRequiredService <IFileService>(); var folderPath = Path.Combine(rootPath, uploadPath, nameof(DefectType), entity.Id.ToString(), "Sample"); var result = fileService.GetFilePath(folderPath, rootPath, ext: ".jpg"); return(result); }
//[ValidateAntiForgeryToken] public ActionResult DeleteConfirmed(int id) { DefectType defectType = _defectTypeService.Find(id); _defectTypeService.Delete(defectType); _unitOfWork.SaveChanges(); if (Request.IsAjaxRequest()) { return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); } DisplaySuccessMessage("Has delete a DefectType record"); return(RedirectToAction("Index")); }
public AppEvent DeleteDefectType(DefectType entity, ClaimsPrincipal principal) { string username = principal.FindFirstValue(AppClaimType.UserName); var ev = new AppEvent { Data = null, Description = $"User {username} deleted defect type id: {entity.Id}", Type = Data.Constants.AppEventType.DeleteDefectType, UserId = principal.Identity.Name }; PrepareCreate(ev); return(context.AppEvent.Add(ev).Entity); }
// GET: DefectTypes/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DefectType defectType = _defectTypeService.Find(id); if (defectType == null) { return(HttpNotFound()); } return(View(defectType)); }
protected override void OnChangeColumn(string col, string val) { if (col == _stat) { DefectBase db = new DefectBase(TTID); string ttimg = ""; var st = GetBuildStatus(); var success = !(st == BuildStatus.failed || st == BuildStatus.cancelled); if (!success) { ttimg = FailImage; } NotifyHub.NotifyBuildStatusChange(ID, TTID, int.Parse(db.AUSER), STATUSTXT, ttimg); if (success && db.TYPE != DefectType.DbType().ToString()) { var branch = db.BRANCH.ToUpper(); var settings = Settings.CurrentSettings; if (branch != "MASTER" && branch != "RELEASE" && !string.IsNullOrEmpty(settings.DATABASEPATTERN)) { var pattern = settings.DATABASEPATTERN.ToUpper(); var git = new Git(settings.WORKGITLOCATION); var gitBranch = git.GetBranch(branch); var commits = gitBranch.EnumCommits(1, 100); foreach (var commit in commits) { var files = commit.EnumFiles(); foreach (var file in files) { if (file.Name.ToUpper().Contains(pattern)) { NotifyHub.NotifyBuildStatusChange(ID, TTID, int.Parse(db.AUSER), "Build System has detected database changes in task commit. But the task is not marked as requiring database changes. Please update the task! This is a warning message and you do not need to start the build again - only check the task!", FailImage); return; } } } } } } }
public void LogSelection(Vector3 location, bool action) { // action == T: selection ~ action == F: deselection string act = (action ? "Selection" : "Deselection"); // Get nearest defect DefectType nearest = null; float min_dist = float.MaxValue; foreach (DefectType def in defects) { if (def != null) { float dist = Vector3.Distance(def.transform.position, location); if (dist < min_dist) { min_dist = dist; nearest = def; } } } // Get viewing angle -- angle from defect to camera such that // viewing head-on would produce an angle of 0 degrees, from the defect's left: -90 degrees, // and from the defect's right: 90 degrees. Vector3 dlv = nearest.transform.forward; Vector3 dfv = new Vector3(dlv.z, dlv.y, -dlv.x); Debug.Log("Camera Forward: " + Camera.main.transform.forward.ToString()); Debug.Log("Defect Forward: " + dlv.ToString()); float viewing_angle = Vector3.Angle(Camera.main.transform.forward, dlv); Debug.Log("Viewing Angle: " + viewing_angle); string line = timestamp + ":" + act + "," + location + ":" + nearest.name + ":" + viewing_angle; selection_log_writer.WriteLine(line); selection_log_writer.Flush(); }
//[ValidateAntiForgeryToken] public ActionResult Create([Bind(Include = "DefectCodes,Id,Name,Code,Description,CreatedUserId,CreatedDateTime,LastEditUserId,LastEditDateTime")] DefectType defectType) { if (ModelState.IsValid) { _defectTypeService.Insert(defectType); _unitOfWork.SaveChanges(); if (Request.IsAjaxRequest()) { return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); } DisplaySuccessMessage("Has append a DefectType record"); return(RedirectToAction("Index")); } if (Request.IsAjaxRequest()) { var modelStateErrors = String.Join("", this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors.Select(n => n.ErrorMessage))); return(Json(new { success = false, err = modelStateErrors }, JsonRequestBehavior.AllowGet)); } DisplayErrorMessage(); return(View(defectType)); }
public DefectType DeleteDefectType(DefectType entity) { entity = context.DefectType.Remove(entity).Entity; return(entity); }
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(); } }
/// <summary> /// Get all defect type to populate defect type dropdown /// </summary> /// <returns></returns> public static IEnumerable<DefectType> GetDefectType() { SqlConnection con = new SqlConnection(SqlConString); List<DefectType> defectTypes = new List<DefectType>(); try { string strquery = "Select * from DTSDefType where IsActive = 1"; SqlCommand cmd = new SqlCommand(strquery, con); con.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader != null) { while (reader.Read()) { var defType = new DefectType(); defType.Id = int.Parse(reader[0].ToString()); defType.Description = reader[1].ToString(); defType.IsActive = Convert.ToBoolean(reader[2].ToString()); defectTypes.Add(defType); } } reader.Close(); } catch (Exception ex) { throw (ex); } finally { if (con != null) con.Close(); } return defectTypes; }
public List <DefectType> gettasktypes() { return(DefectType.Enum()); }
// Use this for initialization void Start() { logger = GameObject.Find("Logger").GetComponent <LogAllData>(); defects = gameObject.GetComponentsInChildren <DefectType>(); surf_planes = PlaneCollection.GetComponentsInChildren <MeshFilter>(); plane_sizes = new float[surf_planes.Length]; defects_by_plane = new List <List <Plane> >(); //defect_mats = Resources.LoadAll<Material>(""); root = defects[0].gameObject; transparency_uses = new int[] { 1, 1, 1, 1 }; marked_uses = new int[] { 0, 0, 0 }; // Assign user-selected augmentation type string aug_path = "demoseed_box"; switch (OutlineType) { case AUGMENT_TYPE.Square: aug_path = "demoseed_box"; break; case AUGMENT_TYPE.Corners: aug_path = "demoseed_box_corner"; break; case AUGMENT_TYPE.Outline: aug_path = "demoseed_box_squiggly"; break; default: aug_path = "demoseed_box"; break; } augment = Resources.Load <Sprite>(aug_path); Debug.Log("Sprite to use: " + augment.ToString()); Bounds def_bounds = root.transform.Find("demoseed_augmentation").GetComponent <SpriteRenderer>().bounds; Vector3 min_d = def_bounds.min; Vector3 max_d = def_bounds.max; DEFECT_W = Mathf.Abs(max_d.z - min_d.z); DEFECT_H = Mathf.Abs(max_d.y - min_d.y); Debug.Log("Width, Height: " + DEFECT_W + ", " + DEFECT_H); for (int i = 0; i < surf_planes.Length; i++) { defects_by_plane.Add(new List <Plane>()); Vector3 min = surf_planes[i].mesh.bounds.min; Vector3 max = surf_planes[i].mesh.bounds.max; plane_sizes[i] = Mathf.Abs((max.x - min.x) * (max.y - min.y)); } max_plane_size = Mathf.Max(plane_sizes); // Distribute defects randomly among planes MeshFilter surf = surf_planes[0]; int surf_idx = 0; int num_planes_to_use = (int)(surf_planes.Length / Random.Range(2.5f, 3.4f)); List <int> used_surfs = new List <int>(); int[,] used_defects = new int[defects.Length, 4]; Debug.Log("Using " + num_planes_to_use + " out of " + surf_planes.Length + "surface planes"); List <Transform> defects_on_this_plane; int def_id = 0; logger.LogDefectMetaData(augment.name, run_transparency); for (int i = 0; i < num_planes_to_use; i++) { defects_on_this_plane = new List <Transform>(); // Get next random surface to use and mark it as used surf_idx = Random.Range(0, surf_planes.Length); while (used_surfs.Contains(surf_idx)) { surf_idx = Random.Range(0, surf_planes.Length); } used_surfs.Add(surf_idx); surf = surf_planes[surf_idx]; //logger.LogDefectPlaneData(surf.transform); // Assign random number of defects within user-set limit int num_defects = Random.Range(1, (int)(plane_sizes[surf_idx] / max_plane_size) * (MaxDefectsPerPlane + 1)); //Debug.Log("Using plane: " + surf.name + " with " + num_defects + " defects."); // Get placement bounds for this surface plane Vector3 min = surf.mesh.bounds.min; Vector3 max = surf.mesh.bounds.max; float rmin_x = Mathf.Min(min.x, max.x) * surf.transform.localScale.x; float rmax_x = Mathf.Max(min.x, max.x) * surf.transform.localScale.x; float rmin_y = Mathf.Min(min.z, max.z) * surf.transform.localScale.z; float rmax_y = Mathf.Max(min.z, max.z) * surf.transform.localScale.z; float xrange = (rmax_x - rmin_x - DEFECT_W) / 2.0f; float yrange = (rmax_y - rmin_y - DEFECT_H) / 2.0f; // Distribute defects across plane for (int j = 0; j < num_defects; ++j) { //DefectType defect = defects[Random.Range(0, defects.Length)]; DefectType defect = Instantiate(root).GetComponent <DefectType>(); defect.ParentSurface = surf.transform; defect.transform.parent = transform; Material defect_mat = null; // Get defect component material so we can set transparency according to target distribution defect_mat = defect.transform.Find("demoseed_defect").GetComponent <SpriteRenderer>().material; Color new_transparency = defect_mat.color; //new_transparency.a = DistributeTransparency(transparency_uses); new_transparency.a = run_transparency; defect_mat.color = new_transparency; // Assign augment sprite defect.transform.Find("demoseed_augmentation").GetComponent <SpriteRenderer>().sprite = augment; // Set random z-rotation (0, 90, 180, 270) // and match x/y-rotations to plane float ex = surf.transform.eulerAngles.x; float ey = surf.transform.eulerAngles.y; float ez = surf.transform.eulerAngles.z; if (ey > -180f && ey < -250f) { Debug.Log("Flipping defect " + defect.name); } else { Debug.Log("Surface " + surf.name + " has rotation of " + surf.transform.eulerAngles); } Quaternion def_rot = Quaternion.Euler(ex + (ez == 180f ? -90f : 90f), ey, new float[] { 0f, 90f, 180f, 270f }[Random.Range(0, 4)]); defect.transform.rotation = def_rot; // Set 'flagged' and 'visible' attributes according to target distribution bool[] status = DistributeMarked(marked_uses); defect.NotMarked = (OutlineType == AUGMENT_TYPE.NoOutline ? true : status[0]); defect.NotRealDefect = status[1]; // Check for overlap and reassign if necessary bool overlap = true; int iters = 0; while (overlap && iters < 100) { overlap = false; iters++; defect.transform.position = surf.transform.position + surf.transform.rotation * (new Vector3( (Random.Range(-xrange, xrange)), 0.02f, (Random.Range(-yrange, yrange)))); foreach (Transform def in defects_on_this_plane) { float dist = Vector3.Distance(def.position, defect.transform.position); if (dist < 2f) { overlap |= true; } } } if (iters >= 100) { Destroy(defect.gameObject); } else { defect.transform.rotation = def_rot; defect.transform.name = "Defect_" + def_id; def_id++; defects_on_this_plane.Add(defect.transform); } } } // Log all defect data then close log Destroy(root); defects = gameObject.GetComponentsInChildren <DefectType>(); foreach (DefectType def in defects) { DefectType nearest = null; float min_dist = float.MaxValue; foreach (DefectType def2 in defects) { if (!ReferenceEquals(def, def2) && def2 != null && def2.name != "RootDefect(Clone)") { float dist = Vector3.Distance(def.transform.position, def2.transform.position); if (dist < min_dist) { min_dist = dist; nearest = def2; } } } if (def.name != "RootDefect") { logger.LogDefectData(def, nearest); } } logger.LogDefectClose(); logger.UpdateDefects(gameObject); }
public ValidationData ValidateDeleteDefectType(ClaimsPrincipal principal, DefectType entity) { return(new ValidationData()); }
public ValidationData ValidateUpdateDefectTypeImage(ClaimsPrincipal principal, DefectType entity, UpdateDefectTypeImageModel model) { return(new ValidationData()); }
private static string FormatMessage(string sysSettingCode, string sysSettingValue, DefectType defectType, string details = "") { string message = string.Format("Configuration problem. Check '{0}' system setting it appears to be '{1}'.", sysSettingCode, defectType); if (defectType == DefectType.Invalid) { message += string.Format("Current value: '{0}'.", sysSettingValue); } if (details.IsNotNullOrWhiteSpace()) { message += "Details: " + details; } return(message); }
public void UpdateDefectTypeImage(DefectType entity, string relPath) { entity.SampleImage = relPath; }
protected void PrepareCreate(DefectType entity) { }
public void UpdateDefectType(DefectType entity, UpdateDefectTypeModel model) { model.CopyTo(entity); }