public JsonResult CreateData(ClassFormat model) { //var CurrentUserInstituteId = CommonFunction.CurrentUserInstituteId(); string retn = String.Empty; using (EMSContext db = new EMSContext()) { try { var exist = db.ClassFormats.Where(e => e.Name == model.Name).FirstOrDefault(); if (exist == null) { var advanced = new ClassFormat(); advanced.Name = model.Name; advanced.ModifyId = CurrentUserId; advanced.ModifyTime = DateTime.Now; db.ClassFormats.Add(advanced); db.SaveChanges(); retn = "Success"; } else { retn = "This Name is already exist."; } } catch { retn = "Failed"; } } return(Json(retn, JsonRequestBehavior.AllowGet)); }
public void PerformanceTest() { int fileCount = 100; ClassFormat dummy = ClassFormat.Dummy; CSVSerializer parser = new CSVSerializer(); string testFolderPath = Path.Combine("./", nameof(PerformanceTest)); Directory.CreateDirectory(testFolderPath); List <string> filePaths = new List <string>(); for (int i = 0; i < fileCount; i++) { dummy.className = $"class_{i + 1}"; string text = parser.Serialize(dummy); string path = Path.Combine(testFolderPath, $"{i + 1}.{parser.fileExtension}"); filePaths.Add(path); File.WriteAllText(path, text); } ToCodeVerb codeCommand = new ToCodeVerb(); codeCommand.inputPaths = new string[] { testFolderPath }; codeCommand.resultFolderPath = testFolderPath; codeCommand.fileName = nameof(PerformanceTest); ToCodeVerb.Verb(codeCommand).Result.Should().Be(0); Directory.Delete(testFolderPath, true); }
public void SerializeTest() { ClassFormat dummy = ClassFormat.Dummy; CSVSerializer parser = new CSVSerializer(); string text = parser.Serialize(dummy); if (parser.TryDeserialize(text, out ClassFormat[] formats) == false)
//[HttpPost] public JsonResult UpdateData(ClassFormat model) { //var CurrentUserInstituteId = CommonFunction.CurrentUserInstituteId(); string retn = String.Empty; using (EMSContext db = new EMSContext()) { try { if (model != null && model.Id > 0) { var exist = db.ClassFormats.Where(e => e.Id == model.Id).SingleOrDefault(); if (exist != null) { var duplicate = db.ClassFormats.Where(e => e.Id != model.Id && e.Name == model.Name).SingleOrDefault(); if (duplicate == null) { exist.Id = model.Id; exist.Name = model.Name; exist.ModifyId = CurrentUserId; exist.ModifyTime = DateTime.Now; db.ClassFormats.Attach(exist); db.Entry(exist).State = EntityState.Modified; db.SaveChanges(); retn = "Success."; } else { retn = "This Name Already Exist."; } } else { retn = "Shift ID is not found."; } } } catch { retn = "Failed"; } } return(Json(retn, JsonRequestBehavior.AllowGet)); }
public void WorkingTest() { ClassFormat dummy = ClassFormat.Dummy; CSVSerializer parser = new CSVSerializer(); string text = parser.Serialize(dummy); string path = $"{nameof(WorkingTest)}.{parser.fileExtension}"; File.WriteAllText(path, text); ToCodeVerb codeCommand = new ToCodeVerb(); codeCommand.inputPaths = new string[] { path }; codeCommand.fileName = nameof(WorkingTest); ToCodeVerb.Verb(codeCommand).Result.Should().Be(0); File.Delete(Path.Combine(Directory.GetCurrentDirectory(), path)); File.Delete(codeCommand.OutputFilePath()); }
public bool Validate(Validator v, string sIdentity, OTTable table) { bool bRet = true; if (ClassFormat == 1) { ClassDefFormat1_val cdf1 = GetClassDefFormat1_val(); bRet &= cdf1.Validate(v, sIdentity + "(Fmt1)", table); } else if (ClassFormat == 2) { ClassDefFormat2_val cdf2 = GetClassDefFormat2_val(); bRet &= cdf2.Validate(v, sIdentity + "(Fmt2)", table); } else { v.Error(T.T_NULL, E._OTL_ClassDefinitionTable_E_Format, table.m_tag, sIdentity + ", format = " + ClassFormat.ToString()); bRet = false; } // way too many ClassDefTables to justify this pass message //if (bRet) //{ // v.Pass("_OTL_ClassDefinitionTable_P_valid", table.m_tag, sIdentity); //} return(bRet); }