public void TestDomainTableInfo() { OrmLiteConfig.DialectProvider = SqliteDialect.Provider; InfoTable info = new InfoTable(); info.Should().NotBeNull(); Assert.Throws <NullReferenceException>(new TestDelegate( delegate { info.Create(null); })); Assert.Throws <NullReferenceException>(new TestDelegate( delegate { info.Create_Index(null); })); PropertyInfo pi = info.GetType().GetProperty("IndexName", BindingFlags.NonPublic | BindingFlags.Instance); pi.Should().NotBeNull(); Assert.IsNotNull(pi.GetValue(info)); pi = info.GetType().GetProperty("IndexFieldName", BindingFlags.NonPublic | BindingFlags.Instance); pi.Should().NotBeNull(); Assert.IsNotNull(pi.GetValue(info)); }
private static void GenerateBinary(string sheetName, InfoTable infoTable) { try { var filePath = Path.Combine(BinaryDirectoryPath, sheetName + ".bytes"); var fw = new FileWriter(filePath); MemoryStream ms = new MemoryStream(); BinaryFormatter b = new BinaryFormatter(); b.Serialize(ms, infoTable); var bytes = ms.GetBuffer(); fw.Write(bytes); var dataPathUri = new System.Uri(Application.dataPath); var relativeUri = dataPathUri.MakeRelativeUri(new System.Uri(filePath)); var relativePath = System.Uri.UnescapeDataString(relativeUri.ToString()); AssetDatabase.ImportAsset(relativePath, ImportAssetOptions.ForceUpdate); } catch (IOException e) { throw e; } }
private void btnTabla_Click(object sender, EventArgs e) { tablas = new InfoTable(); this.ContentPanel.Controls.Clear(); this.ContentPanel.Controls.Add(tablas); tablas.Show(); }
private static string WriteCode(string sheetName, InfoTable infoTable) { int depth = 0; StringBuilder sb = new StringBuilder(); sb.Append('\t', depth).AppendLine("using System;"); sb.Append('\t', depth).AppendLine(""); sb.Append('\t', depth).AppendLine("[Serializable]"); sb.Append('\t', depth).AppendLine($"public class {sheetName}"); sb.Append('\t', depth).AppendLine("{"); depth++; foreach (var type in infoTable.types) { string columnName = type.Key; string typeName = type.Value; sb.Append('\t', depth).AppendLine($"public {typeName} {columnName};"); } sb.Append('\t', depth).AppendLine(""); depth--; sb.Append('\t', depth).AppendLine("}"); return(sb.ToString()); }
public async Task <IActionResult> Edit(int id, [Bind("Id,IfoItem,IfoName")] InfoTable infoTable) { if (id != infoTable.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(infoTable); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InfoTableExists(infoTable.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(infoTable)); }
protected virtual void LoadSchemaImpl() { InfoTable infoTable = new InfoTable(); infoTable.Create(DbConnection); infoTable.Create_Index(DbConnection); }
public virtual InfoTable ExecuteRawSelect(string connectionString, string sql) { IDbConnection connection = null; IDbCommand cmd = null; try { connection = CreateConnection(connectionString); connection.Open(); cmd = connection.CreateCommand(); cmd.CommandText = sql; var reader = (IDataReader)ExecuteCommand(cmd, DbExecutionType.Reader); var table = new InfoTable(reader); table.Load(reader); reader.Dispose(); //should be Dispose, not Close for .NET core return(table); } finally { if (cmd != null) { cmd.Connection = null; } if (connection != null) { connection.Close(); } } }
public async Task <IActionResult> AddAdmin(AdminInsertSetting NewAdmin) { if (!ModelState.IsValid) { return(View(new AdminInsertSetting { AdminList = GetAdmin() })); } NewAdmin.Admin.ID = NewAdmin.Admin.ID.Trim(); NewAdmin.Admin.Name = NewAdmin.Admin.Name.Trim(); NewAdmin.Admin.Password = NewAdmin.Admin.Password.Trim(); NewAdmin.Admin.RePassword = NewAdmin.Admin.RePassword.Trim(); var targetAdmin = _dbContext.InfoTable.SingleOrDefault(i => i.Id == NewAdmin.Admin.ID); if (targetAdmin != null) { throw new Exception("User name already exists."); } var hasher = new PasswordHasher <InfoTable>(); targetAdmin = new InfoTable { Id = NewAdmin.Admin.ID, Name = NewAdmin.Admin.Name, RoleId = 3 }; targetAdmin.Pass = hasher.HashPassword(targetAdmin, NewAdmin.Admin.Password); await _dbContext.InfoTable.AddAsync(targetAdmin); await _dbContext.SaveChangesAsync(); return(View(new AdminInsertSetting { AdminList = GetAdmin() })); }
public string ToString(string format, IFormatProvider formatProvider) { return(format switch { ClrStructureSettings.FORMAT_ALL => InfoTable.ToString(), ClrStructureSettings.FORMAT_MIN => IdTable.ToString(), _ => IdTable.ToString(), });
public void TestInfoTable() { using (RepositoryDataSource dataSource = new RepositoryDataSource()) { string filename = Path.GetTempFileName(); File.Delete(filename); File.Exists(filename).Should().BeFalse(); try { dataSource.New(filename); dataSource.IsOpen().Should().BeTrue(); InfoTable info = new InfoTable { InfoName = "Setting1", Value = "V1" }; IDomainTableRepository <InfoTable> repository = dataSource.DataRepository.GetTableRepositoryFor <InfoTable>(); repository.Should().NotBeNull(); info = repository.Save(info); info.Id.Should().NotBe(0); InfoTable info2 = new InfoTable(); info2 = repository[info.Id]; info2.Id.Should().Be(info.Id); info2.InfoName.Should().Be(info.InfoName); info2.Value.Should().Be(info.Value); IList <IField> fields = info.SupportedFields(); fields.Should().NotBeNull(); fields.Count.Should().Be(2); fields[0].Name.Should().Be(StandardFieldName.InfoName); fields[1].Name.Should().Be(StandardFieldName.Value); ((IEditField)fields[0]).SetValue(0, "Test2"); ((IEditField)fields[1]).SetValue(0, "Test3"); info.InfoName.Should().Be("Test2"); info.Value.Should().Be("Test3"); repository.Save(info); info2.Should().NotBe(info); IField infoNameField = info.Field(StandardFieldName.InfoName); infoNameField.GetValue(0).Should().Be("Test2"); IField valueField = info.Field(StandardFieldName.Value); valueField.GetValue(0).Should().Be("Test3"); } finally { dataSource.Close(); } File.Delete(filename); } }
public async Task <IActionResult> Upload(IFormFile file) { TempRepository.RemoveAll(); var path = Path.Combine( Directory.GetCurrentDirectory(), "wwwroot", file.FileName); using (var stream = new FileStream(path, FileMode.Create)) { await file.CopyToAsync(stream); } //Load the the data from the uploaded file IEnumerable <NewStudentInsert> ToAdd = DataLoader.Load(@"wwwroot\" + file.FileName); foreach (NewStudentInsert s in ToAdd) { s.Id = s.Id.Trim(); s.Name = s.Name.Trim(); s.Pass = s.Pass.Trim(); s.RepeatPass = s.RepeatPass.Trim(); var targetUser = _dbContext.InfoTable.SingleOrDefault(i => i.Id.Equals(s.Id, StringComparison.CurrentCulture)); var targetGPA = _dbContext.InfoTable.SingleOrDefault(i => i.Id.Equals(s.Id, StringComparison.CurrentCulture)); if (targetUser != null) { TempRepository.AddStudent(new NewStudentInsert { Id = s.Id, Name = s.Name, StudentGPA = s.StudentGPA, ADD = false }); continue; } var hasher = new PasswordHasher <InfoTable>(); targetUser = new InfoTable { Id = s.Id, Name = s.Name, RoleId = 2 }; targetUser.Pass = hasher.HashPassword(targetUser, s.Pass); //targetGPA = new StudnetGpa { StuId = student.Id, StuGpa = student.StudentGPA }; await _dbContext.InfoTable.AddAsync(targetUser); await _dbContext.SaveChangesAsync(); if (s.StudentGPA != double.NaN) { await GpaSet(s); } ViewBag.templist = true; TempRepository.AddStudent(s); } ViewBag.inserted = true; return(View(TempRepository.Inserted)); }
public async Task <IActionResult> Create([Bind("Id,IfoItem,IfoName")] InfoTable infoTable) { if (ModelState.IsValid) { _context.Add(infoTable); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(infoTable)); }
}//test method private void CheckDataType(InfoTable dtColumns, string columnName, string dataType, int size = 0) { //find row var colRow = dtColumns.FindRow("column_name", columnName); Assert.AreEqual(dataType, (string)colRow["Data_Type"], "Data type does not match, column: " + columnName); if (size > 0) { Assert.AreEqual(size, (int)colRow["character_maximum_length"], "Size does not match, column: " + columnName); } }
private void OnEnable() { if (InfoTable.IT == null) { InfoTable.IT = this; } else { if (InfoTable.IT != this) { Destroy(this.gameObject); } } DontDestroyOnLoad(this.gameObject); }
public async Task <IActionResult> ManualRegister(AllInfo student) { if (!ModelState.IsValid) { return(View()); } else { //Remove any spaces in the first student.newStudnet.Id = student.newStudnet.Id.Trim(); student.newStudnet.Name = student.newStudnet.Name.Trim(); student.newStudnet.Pass = student.newStudnet.Pass.Trim(); student.newStudnet.RepeatPass = student.newStudnet.RepeatPass.Trim(); //check if the target user is used before or not var targetUser = _dbContext.InfoTable.SingleOrDefault(i => i.Id.Equals(student.newStudnet.Id, StringComparison.CurrentCulture)); var targetGPA = _dbContext.InfoTable.SingleOrDefault(i => i.Id.Equals(student.newStudnet.Id, StringComparison.CurrentCulture)); if (targetUser != null) { ViewBag.IdTarget = "This ID is already used"; return(View()); } //hash password var hasher = new PasswordHasher <InfoTable>(); targetUser = new InfoTable { Id = student.newStudnet.Id, Name = student.newStudnet.Name, RoleId = 2 }; targetUser.Pass = hasher.HashPassword(targetUser, student.newStudnet.Pass); //chech the GPA if (student.newStudnet.StudentGPA != double.NaN) { await GpaSet(student.newStudnet); } await _dbContext.InfoTable.AddAsync(targetUser); await _dbContext.SaveChangesAsync(); ViewBag.templist = true; TempRepository.AddStudent(student.newStudnet); ViewBag.inserted = true; return(View(new AllInfo { Studentslist = TempRepository.Inserted })); } }
public void insertAsync(string num, string state) { if (!File.Exists(dbPath)) { createDatabase(dbPath); } sqliteConn = new SQLiteConnection(dbPath); var Table = sqliteConn.GetTableInfo(TableName); if (Table.Count == 0) { sqliteConn.CreateTable <InfoTable>(); } InfoTable info = new InfoTable() { EmsNum = num, state = state, dateTime = System.DateTime.Now.ToShortDateString() }; sqliteConn.Insert(info); }
public ActionResult DeleteDesign(int id) { List <Error> errors = new List <Error>(); DataSource <SalaryBasisDesignViewModel> Source = new DataSource <SalaryBasisDesignViewModel>(); InfoTable info = _hrUnitOfWork.SalaryDesignRepository.Find(a => a.Id == id).FirstOrDefault(); _hrUnitOfWork.SalaryDesignRepository.Remove(info.Id); string message = "OK"; Source.Errors = SaveChanges(Language); if (Source.Errors.Count > 0) { return(Json(Source)); } else { return(Json(message)); } }
//[AllowAnonymous, HttpGet] //public async Task<IActionResult> Register() //{ // await // HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); // return View(); //} //[AllowAnonymous, HttpPost] //public async Task<IActionResult> Register(RegisterViewModel model) //{ // if (!ModelState.IsValid) // { // throw new Exception("Invalid registration information."); // } // model.Name = model.Name.Trim(); // model.Password = model.Password.Trim(); // model.RepeatPassword = model.RepeatPassword.Trim(); // model.Id = model.Id.Trim(); // var targetUser = _dbContext.InfoTable.SingleOrDefault(i => i.Id.Equals(model.Id, StringComparison.CurrentCulture)); // if (targetUser != null) // { // throw new Exception("User name already exists."); // } // if (!model.Password.Equals(model.RepeatPassword)) // { // throw new Exception("Passwords are not identical."); // } // var hasher = new PasswordHasher<InfoTable>(); // targetUser = new InfoTable { Name = model.Name, Id = model.Id, RoleId = 1}; // targetUser.Pass = hasher.HashPassword(targetUser, model.Password); // await _dbContext.InfoTable.AddAsync(targetUser); // await _dbContext.SaveChangesAsync(); // await LogInUserAsync(targetUser); // return RedirectToAction("Index", "Home"); //} private async Task LogInUserAsync(InfoTable user) { var claims = new List <Claim>(); claims.Add(new Claim(ClaimTypes.Name, user.Id)); if (user.RoleId == 1) { claims.Add(new Claim(ClaimTypes.Role, "Administrator")); } else { claims.Add(new Claim(ClaimTypes.Role, "Student")); } var claimsIndentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); var claimsPrincipal = new ClaimsPrincipal(claimsIndentity); await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, claimsPrincipal); await _dbContext.SaveChangesAsync(); }
public void Draw(SpriteBatch spriteBatch, GraphicsDeviceManager graphics) { Background.Draw(spriteBatch, graphics); // Banner string WeekString = "Week of " + ThisMonday.ToString("M/d"); DrawingUtils.DrawTextBanner(spriteBatch, graphics, Arial, WeekString, Color.Red, Color.Black); Notebook.Draw(spriteBatch, graphics); // create calendar Calendar.Draw(spriteBatch, graphics); // Confirm activity to move on to the next day DrawingUtils.DrawFilledRectangle(spriteBatch, graphics, ActivityRect, Color.Beige); DrawingUtils.DrawOpenRectangle(spriteBatch, graphics, ActivityRect, Color.DarkSlateBlue, 3); // Formulate Activity - "Today I will [blank] with [blank]" spriteBatch.DrawString(JustBreathe, "Today I will ...", new Vector2(ActivityRect.X, ActivityRect.Y), Color.Navy); ActivitiesList.Draw(spriteBatch, graphics); spriteBatch.DrawString(JustBreathe, "with", new Vector2(ActivityRect.X + 250, ActivityRect.Y + 100), Color.Navy); PeopleList.Draw(spriteBatch, graphics); // Add tables for current Main Character stats (need to find a different way to update them live string[] Aspects = new string[6] { "charm", "courage", "empathy", "intelligence", "strength", "money" }; StatsTable = new InfoTable(MainCharacter.Stats, Aspects, new Rectangle(110, 400, 200, 252), JustBreathe); string[] People = Case.Suspects.Concat(Case.TestimonyOnly).ToArray(); RelTable = new InfoTable(MainCharacter.Relationships, People, new Rectangle(350, 400, 200, 252), JustBreathe); StatsTable.Draw(spriteBatch, graphics); RelTable.Draw(spriteBatch, graphics); if (GState == CalendarState.ConfirmActivity) { ConfirmButton.Draw(spriteBatch, graphics); } }
private static void GenerateClassCode(string sheetName, InfoTable infoTable) { var text = WriteCode(sheetName, infoTable); string fileName = sheetName + ".cs"; var filePath = Path.Combine(CodeDirectoryPath, fileName); using (FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None)) { using (StreamWriter writer = new StreamWriter(fs, Encoding.UTF8)) { writer.Write(text.ToString()); writer.Flush(); } } var dataPathUri = new Uri(Application.dataPath); var relativeUri = dataPathUri.MakeRelativeUri(new Uri(filePath)); var relativePath = Uri.UnescapeDataString(relativeUri.ToString()); AssetDatabase.ImportAsset(relativePath, ImportAssetOptions.ForceUpdate); }
static public void Create(GameObject canvas) { go = new GameObject("Shop_Screen", typeof(RectTransform)); go.transform.SetParent(canvas.transform); go.AddComponent <Dragable>(); RectTransform tr = (RectTransform)go.transform; tr.sizeDelta = new Vector2(1100, 600); tr.anchorMin = new Vector2(.5f, .5f); tr.anchorMax = new Vector2(.5f, .5f); tr.pivot = new Vector2(.5f, .5f); tr.anchoredPosition = new Vector2(0, 0); Image im = go.AddComponent <Image>(); im.sprite = QuintensUITools.Graphics.GetSprite("Inventory_window"); im.type = Image.Type.Sliced; /// Table with the shops inventory { shopInventoryTable = InfoTable.Create(go.transform, () => inventory, (Loot l) => new List <TextRef>() { l.ToString(), GetSpecificDetails(l), l.weight, l.value, l.slot.ToString() }, 520, new List <TextRef>() { "Inventory", "Specifics", TextRef.Create("w", "Weight", false), TextRef.Create("v", "value", false), "s" }, 24, "Shop"); shopInventoryTable.transform.anchorMin = new Vector2(0, 1); shopInventoryTable.transform.anchorMax = new Vector2(0, 1); shopInventoryTable.transform.pivot = new Vector2(0, 1); shopInventoryTable.transform.anchoredPosition = new Vector2(10, -50); shopInventoryTable.SetColumnWidths(new List <float>() { 160, 80, 60, 60, 160 }); } /// Table with my inventory { myInventoryTable = InfoTable.Create(go.transform, () => Player.instance.inventory, (Loot l) => new List <TextRef>() { l.ToString(), GetSpecificDetails(l), l.weight, l.value, l.slot.ToString() }, 520, new List <TextRef>() { "Inventory", "Specifics", TextRef.Create("w", "Weight", false), TextRef.Create("v", "value", false), "s" }, 24, "Me"); myInventoryTable.transform.anchorMin = new Vector2(1, 1); myInventoryTable.transform.anchorMax = new Vector2(1, 1); myInventoryTable.transform.pivot = new Vector2(1, 1); myInventoryTable.transform.anchoredPosition = new Vector2(-10, -50); myInventoryTable.SetColumnWidths(new List <float>() { 160, 80, 60, 60, 160 }); } /// Bottom buttons { TextBox equipButton = new TextBox(go.transform, TextRef.Create("Buy", "Make sure your product is selected.", false).AddLink(() => BuySelected()), 24); equipButton.transform.anchorMin = new Vector2(0, 0); equipButton.transform.anchorMax = new Vector2(0, 0); equipButton.transform.pivot = new Vector2(0, 0); equipButton.transform.anchoredPosition = new Vector2(40, 40); TextBox dropAllButton = new TextBox(go.transform, TextRef.Create("Sell All", "Sell everything in your inventory.\nBeware! You can't buy it back.", false).AddLink(() => DiscardAll()), 24, TextAnchor.MiddleRight); dropAllButton.transform.anchorMin = new Vector2(1, 0); dropAllButton.transform.anchorMax = new Vector2(1, 0); dropAllButton.transform.pivot = new Vector2(1, 0); dropAllButton.transform.anchoredPosition = new Vector2(-150, 40); TextBox dropButton = new TextBox(go.transform, TextRef.Create("Sell", "-Select an item.\n-Press this button.", false).AddLink(() => DiscardSelected()), 24, TextAnchor.MiddleRight); dropButton.transform.anchorMin = new Vector2(1, 0); dropButton.transform.anchorMax = new Vector2(1, 0); dropButton.transform.pivot = new Vector2(1, 0); dropButton.transform.anchoredPosition = new Vector2(-40, 40); } go.SetActive(false); }
static public void Create(GameObject canvas) { go = new GameObject("Inventory", typeof(RectTransform)); go.transform.SetParent(canvas.transform); go.AddComponent <Dragable>(); RectTransform tr = (RectTransform)go.transform; tr.sizeDelta = new Vector2(800, 600); tr.anchorMin = new Vector2(.5f, .5f); tr.anchorMax = new Vector2(.5f, .5f); tr.pivot = new Vector2(.5f, .5f); tr.anchoredPosition = new Vector2(0, 0); Image im = go.AddComponent <Image>(); im.sprite = QuintensUITools.Graphics.GetSprite("Inventory_window"); im.type = Image.Type.Sliced; /// Equipment { TextBox head = new TextBox(go.transform, TextRef.Create("Head", "Hats and stuff", false), 24, TextAnchor.UpperLeft); head.transform.anchoredPosition = new Vector2(10, -80); TextBox head2 = new TextBox(go.transform, TextRef.Create(() => Player.instance.equipment.head.GetItemName(), () => Player.instance.equipment.head.GetItemStats()), 24, TextAnchor.UpperLeft); head2.transform.anchoredPosition = new Vector2(60, -100); MakeEquButton(head); TextBox chest = new TextBox(go.transform, TextRef.Create("Chest", "Upper body protection", false), 24, TextAnchor.UpperLeft); chest.transform.anchoredPosition = new Vector2(10, -130); TextBox chest2 = new TextBox(go.transform, TextRef.Create(() => Player.instance.equipment.chest.GetItemName(), () => Player.instance.equipment.chest.GetItemStats()), 24, TextAnchor.UpperLeft); chest2.transform.anchoredPosition = new Vector2(60, -150); MakeEquButton(chest); TextBox rhand = new TextBox(go.transform, TextRef.Create("Right Hand", "The weapon hand", false), 24, TextAnchor.UpperLeft); rhand.transform.anchoredPosition = new Vector2(10, -180); TextBox rhand2 = new TextBox(go.transform, TextRef.Create(() => Player.instance.equipment.rHand.GetItemName(), () => Player.instance.equipment.rHand.GetItemStats()), 24, TextAnchor.UpperLeft); rhand2.transform.anchoredPosition = new Vector2(60, -200); MakeEquButton(rhand); TextBox lhand = new TextBox(go.transform, TextRef.Create("Left Hand", "The shield hand", false), 24, TextAnchor.UpperLeft); lhand.transform.anchoredPosition = new Vector2(10, -230); TextBox lhand2 = new TextBox(go.transform, TextRef.Create(() => Player.instance.equipment.lHand.GetItemName(), () => Player.instance.equipment.lHand.GetItemStats()), 24, TextAnchor.UpperLeft); lhand2.transform.anchoredPosition = new Vector2(60, -250); MakeEquButton(lhand); TextBox rarm = new TextBox(go.transform, TextRef.Create("Right arm", "Arm protection", false), 24, TextAnchor.UpperLeft); rarm.transform.anchoredPosition = new Vector2(10, -280); TextBox rarm2 = new TextBox(go.transform, TextRef.Create(() => Player.instance.equipment.rArm.GetItemName(), () => Player.instance.equipment.rArm.GetItemStats()), 24, TextAnchor.UpperLeft); rarm2.transform.anchoredPosition = new Vector2(60, -300); MakeEquButton(rarm); TextBox larm = new TextBox(go.transform, TextRef.Create("Left arm", "Arm protection", false), 24, TextAnchor.UpperLeft); larm.transform.anchoredPosition = new Vector2(10, -330); TextBox larm2 = new TextBox(go.transform, TextRef.Create(() => Player.instance.equipment.lArm.GetItemName(), () => Player.instance.equipment.lArm.GetItemStats()), 24, TextAnchor.UpperLeft); larm2.transform.anchoredPosition = new Vector2(60, -350); MakeEquButton(larm); TextBox rleg = new TextBox(go.transform, TextRef.Create("Right leg", "Leg protection", false), 24, TextAnchor.UpperLeft); rleg.transform.anchoredPosition = new Vector2(10, -380); TextBox rleg2 = new TextBox(go.transform, TextRef.Create(() => Player.instance.equipment.rLeg.GetItemName(), () => Player.instance.equipment.rLeg.GetItemStats()), 24, TextAnchor.UpperLeft); rleg2.transform.anchoredPosition = new Vector2(60, -400); MakeEquButton(rleg); TextBox lleg = new TextBox(go.transform, TextRef.Create("Left leg", "Leg protection", false), 24, TextAnchor.UpperLeft); lleg.transform.anchoredPosition = new Vector2(10, -430); TextBox lleg2 = new TextBox(go.transform, TextRef.Create(() => Player.instance.equipment.lLeg.GetItemName(), () => Player.instance.equipment.lLeg.GetItemStats()), 24, TextAnchor.UpperLeft); lleg2.transform.anchoredPosition = new Vector2(60, -450); MakeEquButton(lleg); } /// Table with the inventory { inventoryTable = InfoTable.Create(go.transform, () => Player.instance.inventory, (Loot l) => new List <TextRef>() { l.ToString(), GetSpecificDetails(l), l.weight, l.value, l.slot.ToString() }, 520, new List <TextRef>() { "Inventory", "Specifics", TextRef.Create("w", "Weight", false), TextRef.Create("v", "value", false), "Slot" }, 24); inventoryTable.transform.anchorMin = new Vector2(1, 1); inventoryTable.transform.anchorMax = new Vector2(1, 1); inventoryTable.transform.pivot = new Vector2(1, 1); inventoryTable.transform.anchoredPosition = new Vector2(-10, -50); inventoryTable.SetColumnWidths(new List <float>() { 160, 80, 60, 60, 160 }); } /// Bottom buttons { TextBox equipButton = new TextBox(go.transform, TextRef.Create("Equip", "-Select a weapon.\n-Select a slot.\n-Press this button.", false).AddLink(() => EquipSelected()), 24); equipButton.transform.anchorMin = new Vector2(0, 0); equipButton.transform.anchorMax = new Vector2(0, 0); equipButton.transform.pivot = new Vector2(0, 0); equipButton.transform.anchoredPosition = new Vector2(40, 40); TextBox dropAllButton = new TextBox(go.transform, TextRef.Create("Discard All", "Throw away everything in your inventory.\nBeware! All will be lost.", false).AddLink(() => DiscardAll()), 24, TextAnchor.MiddleRight); dropAllButton.transform.anchorMin = new Vector2(1, 0); dropAllButton.transform.anchorMax = new Vector2(1, 0); dropAllButton.transform.pivot = new Vector2(1, 0); dropAllButton.transform.anchoredPosition = new Vector2(-150, 40); TextBox dropButton = new TextBox(go.transform, TextRef.Create("Discard", "-Select an item.\n-Press this button.", false).AddLink(() => DiscardSelected()), 24, TextAnchor.MiddleRight); dropButton.transform.anchorMin = new Vector2(1, 0); dropButton.transform.anchorMax = new Vector2(1, 0); dropButton.transform.pivot = new Vector2(1, 0); dropButton.transform.anchoredPosition = new Vector2(-40, 40); } go.SetActive(false); }
public InfoTable GetSteamSensorReadings() { var table = new InfoTable(getDataShapeDefinition("SteamSensorReadings")); var now = DateTime.Now; try { //entry 1 var entry = new ValueCollection(); entry.SetStringValue(SENSOR_NAME_FIELD, "Sensor Alpha"); entry.SetDateTimeValue(ACTIV_TIME_FIELD, now.AddDays(1)); entry.SetNumberValue(TEMPERATURE_FIELD, 50); entry.SetNumberValue(PRESSURE_FIELD, 15); entry.SetBooleanValue(FAULT_STATUS_FIELD, false); entry.SetBooleanValue(INLET_VALVE_FIELD, true); entry.SetNumberValue(TEMPERATURE_LIMIT_FIELD, 150); entry.SetNumberValue(TOTAL_FLOW_FIELD, 87); table.addRow(entry); //entry 2 entry = new ValueCollection(); entry.SetStringValue(SENSOR_NAME_FIELD, "Sensor Beta"); entry.SetDateTimeValue(ACTIV_TIME_FIELD, now.AddDays(2)); entry.SetNumberValue(TEMPERATURE_FIELD, 60); entry.SetNumberValue(PRESSURE_FIELD, 25); entry.SetBooleanValue(FAULT_STATUS_FIELD, true); entry.SetBooleanValue(INLET_VALVE_FIELD, true); entry.SetNumberValue(TEMPERATURE_LIMIT_FIELD, 150); entry.SetNumberValue(TOTAL_FLOW_FIELD, 77); table.addRow(entry); //entry 3 entry = new ValueCollection(); entry.SetStringValue(SENSOR_NAME_FIELD, "Sensor Gamma"); entry.SetDateTimeValue(ACTIV_TIME_FIELD, now.AddDays(3)); entry.SetNumberValue(TEMPERATURE_FIELD, 70); entry.SetNumberValue(PRESSURE_FIELD, 30); entry.SetBooleanValue(FAULT_STATUS_FIELD, true); entry.SetBooleanValue(INLET_VALVE_FIELD, true); entry.SetNumberValue(TEMPERATURE_LIMIT_FIELD, 150); entry.SetNumberValue(TOTAL_FLOW_FIELD, 67); table.addRow(entry); //entry 4 entry = new ValueCollection(); entry.SetStringValue(SENSOR_NAME_FIELD, "Sensor Delta"); entry.SetDateTimeValue(ACTIV_TIME_FIELD, now.AddDays(4)); entry.SetNumberValue(TEMPERATURE_FIELD, 80); entry.SetNumberValue(PRESSURE_FIELD, 35); entry.SetBooleanValue(FAULT_STATUS_FIELD, false); entry.SetBooleanValue(INLET_VALVE_FIELD, true); entry.SetNumberValue(TEMPERATURE_LIMIT_FIELD, 150); entry.SetNumberValue(TOTAL_FLOW_FIELD, 57); table.addRow(entry); //entry 5 entry = new ValueCollection(); entry.SetStringValue(SENSOR_NAME_FIELD, "Sensor Epsilon"); entry.SetDateTimeValue(ACTIV_TIME_FIELD, now.AddDays(5)); entry.SetNumberValue(TEMPERATURE_FIELD, 90); entry.SetNumberValue(PRESSURE_FIELD, 40); entry.SetBooleanValue(FAULT_STATUS_FIELD, true); entry.SetBooleanValue(INLET_VALVE_FIELD, false); entry.SetNumberValue(TEMPERATURE_LIMIT_FIELD, 150); entry.SetNumberValue(TOTAL_FLOW_FIELD, 47); table.addRow(entry); } catch (Exception e) { // handle exception as appropriate } return(table); }
private static InfoTable ReadTable(string sheetName, string path) { InfoTable infoTable = new InfoTable(); infoTable.tableName = sheetName; XSSFWorkbook workbook; using (FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read)) { workbook = new XSSFWorkbook(file); } ISheet sheet = workbook.GetSheetAt(0); var typeRow = sheet.GetRow(0); var keyRow = sheet.GetRow(1); string tempStr; for (int i = 0; i < typeRow.Cells.Count; i++) { var columeName = keyRow.Cells[i].StringCellValue; var columnType = typeRow.Cells[i].StringCellValue; if (columnType == "#") { continue; } infoTable.types.Add(columeName, columnType); Debug.Log(columeName); Debug.Log(columnType); List <object> dataList = new List <object>(); for (int j = 2; j <= sheet.LastRowNum; j++) { var dataRow = sheet.GetRow(j); var dataCell = dataRow.Cells[i]; switch (columnType) { case "short": dataList.Add((short)dataCell.NumericCellValue); break; case "int": dataList.Add((int)dataCell.NumericCellValue); break; case "long": dataList.Add((long)dataCell.NumericCellValue); break; case "float": dataList.Add((float)dataCell.NumericCellValue); break; case "bool": dataList.Add((bool)dataCell.BooleanCellValue); break; case "string": dataList.Add(dataCell.StringCellValue); break; case "short[]": tempStr = dataCell.StringCellValue; if (tempStr.Last() != ';') { tempStr += ";"; } var shortSplitStr = tempStr.Split(';'); short[] arrShort = new short[shortSplitStr.Length]; for (int c = 0; c < shortSplitStr.Length; c++) { arrShort[c] = default(int); short.TryParse(shortSplitStr[c], out arrShort[c]); } dataList.Add(arrShort); break; case "int[]": tempStr = dataCell.StringCellValue; if (tempStr.Last() != ';') { tempStr += ";"; } var intSplitStr = tempStr.Split(';'); int[] arrInt = new int[intSplitStr.Length]; for (int c = 0; c < intSplitStr.Length; c++) { arrInt[c] = default(int); int.TryParse(intSplitStr[c], out arrInt[c]); } dataList.Add(arrInt); break; case "float[]": tempStr = dataCell.StringCellValue; if (tempStr.Last() != ';') { tempStr += ";"; } var floatSplitStr = tempStr.Split(';'); float[] arrFloat = new float[floatSplitStr.Length]; for (int c = 0; c < floatSplitStr.Length; c++) { arrFloat[c] = default(float); float.TryParse(floatSplitStr[c], out arrFloat[c]); } dataList.Add(arrFloat); break; case "bool[]": tempStr = dataCell.StringCellValue; if (tempStr.Last() != ';') { tempStr += ";"; } var boolSplitStr = tempStr.Split(';'); bool[] arrBool = new bool[boolSplitStr.Length]; for (int c = 0; c < boolSplitStr.Length; c++) { arrBool[c] = default(bool); bool.TryParse(boolSplitStr[c], out arrBool[c]); } dataList.Add(arrBool); break; case "string[]": tempStr = dataCell.StringCellValue; if (tempStr.Last() != ';') { tempStr += ";"; } var stringSplitStr = tempStr.Split(';'); dataList.Add(stringSplitStr); break; case "long[]": tempStr = dataCell.StringCellValue; if (tempStr.Last() != ';') { tempStr += ";"; } var longSplitStr = tempStr.Split(';'); long[] arrLong = new long[longSplitStr.Length]; for (int c = 0; c < longSplitStr.Length; c++) { arrLong[c] = default(long); long.TryParse(longSplitStr[c], out arrLong[c]); } dataList.Add(arrLong); break; } } infoTable.columns.Add(columeName, dataList); } return(infoTable); }
public ActionResult DetailsSecondPage(SalaryDesignSecondViewModel model, OptionsViewModel moreInfo, SalaryBasisDesignViewModel grid1, LinkTableVM grid2) { var msg = "OK,"; List <Error> errors = new List <Error>(); if (ModelState.IsValid) { if (ServerValidationEnabled) { errors = _hrUnitOfWork.CompanyRepository.CheckForm(new CheckParm { CompanyId = CompanyId, ObjectName = "SalaryBasisPage2", Columns = Models.Utils.GetColumnViews(ModelState.Where(a => !a.Key.Contains('.'))), ParentColumn = "CompanyId", Culture = Language }); if (errors.Count() > 0) { foreach (var e in errors) { foreach (var errorMsg in e.errors) { ModelState.AddModelError(errorMsg.field, errorMsg.message); } } return(Json(Models.Utils.ParseFormErrors(ModelState))); } } } if (model.Id == 0) { InfoTable record = new InfoTable(); AutoMapper(new Models.AutoMapperParm { Destination = record, Source = model, ObjectName = "SalaryBasisPage2", Version = Convert.ToByte(Request.QueryString["Version"]), Options = moreInfo }); record.Name = grid1.Name; record.IsLocal = grid1.IsLocal; record.StartDate = grid1.StartDate; record.EndDate = grid1.EndDate; record.Basis = grid1.Basis; record.Purpose = grid1.Purpose; record.CompanyId = CompanyId; record.CreatedTime = DateTime.Now; record.CreatedUser = UserName; _hrUnitOfWork.SalaryDesignRepository.Add(record); SaveGrid2(grid2, ModelState.Where(a => a.Key.Contains("grid2")), record); errors = SaveChanges(Language); if (errors.Count > 0) { msg = errors.First().errors.First().message; } } return(Json(msg)); }
public ActionResult DetailsFirstPage(SalaryBasisDesignViewModel model, OptionsViewModel moreInfo, RangeTableVm grid1) { string msg = "OK,"; List <Error> errors = new List <Error>(); if (model.Purpose != 2) { if (ModelState.IsValid) { if (ServerValidationEnabled) { errors = _hrUnitOfWork.CompanyRepository.CheckForm(new CheckParm { CompanyId = CompanyId, ObjectName = "SalaryBasisPage1", Columns = Models.Utils.GetColumnViews(ModelState.Where(a => !a.Key.Contains('.'))), ParentColumn = "CompanyId", Culture = Language }); if (errors.Count() > 0) { foreach (var e in errors) { foreach (var errorMsg in e.errors) { ModelState.AddModelError(errorMsg.field, errorMsg.message); } } return(Json(Models.Utils.ParseFormErrors(ModelState))); } } } msg += ((new JavaScriptSerializer().Serialize(model))); return(Json(msg)); } else { if (ModelState.IsValid) { if (ServerValidationEnabled) { errors = _hrUnitOfWork.CompanyRepository.CheckForm(new CheckParm { CompanyId = CompanyId, ObjectName = "SalaryBasisPage1", Columns = Models.Utils.GetColumnViews(ModelState.Where(a => !a.Key.Contains('.'))), ParentColumn = "CompanyId", Culture = Language }); if (errors.Count() > 0) { foreach (var e in errors) { foreach (var errorMsg in e.errors) { ModelState.AddModelError(errorMsg.field, errorMsg.message); } } return(Json(Models.Utils.ParseFormErrors(ModelState))); } } } if (model.Id == 0) { InfoTable record = new InfoTable(); AutoMapper(new Models.AutoMapperParm { Destination = record, Source = model, ObjectName = "SalaryBasisPage1", Version = Convert.ToByte(Request.QueryString["Version"]), Options = moreInfo }); record.CompanyId = CompanyId; record.TableType = (grid1.inserted != null ? grid1.inserted.FirstOrDefault().TableType : null); record.CreatedTime = DateTime.Now; record.CreatedUser = UserName; _hrUnitOfWork.SalaryDesignRepository.Add(record); SaveGrid1(grid1, ModelState.Where(a => a.Key.Contains("grid1")), record); errors = SaveChanges(Language); if (errors.Count > 0) { msg = errors.First().errors.First().message; } } } return(Json(msg)); }
private void SaveGrid2(LinkTableVM grid1, IEnumerable <KeyValuePair <string, ModelState> > state, InfoTable info) { if (grid1.inserted != null) { foreach (LinkTableViewModel model in grid1.inserted) { var range = new LinkTable(); AutoMapper(new Models.AutoMapperParm { Destination = range, Source = model }); range.CreatedTime = DateTime.Now; range.CreatedUser = UserName; _hrUnitOfWork.SalaryDesignRepository.AddLinkTable(range); } } }
/// <summary>Load animation from a stream</summary> public teAnimation(Stream stream, bool keepOpen = false) { using (BinaryReader reader = new BinaryReader(stream, Encoding.Default, keepOpen)) { Header = reader.Read <AnimHeader>(); InfoTableSize = (int)(Header.FPS * Header.Duration) + 1; reader.BaseStream.Position = Header.BoneListOffset; BoneList = reader.ReadArray <int>(Header.BoneCount); reader.BaseStream.Position = Header.InfoTableOffset; InfoTables = new InfoTable[Header.BoneCount]; BoneAnimations = new BoneAnimation[Header.BoneCount]; for (int boneIndex = 0; boneIndex < Header.BoneCount; boneIndex++) { long streamPos = reader.BaseStream.Position; InfoTable infoTable = reader.Read <InfoTable>(); long afterTablePos = reader.BaseStream.Position; InfoTables[boneIndex] = infoTable; long scaleIndicesPos = (long)infoTable.ScaleIndicesOffset * 4 + streamPos; long positionIndicesPos = (long)infoTable.PositionIndicesOffset * 4 + streamPos; long rotationIndicesPos = (long)infoTable.RotationIndicesOffset * 4 + streamPos; long scaleDataPos = (long)infoTable.ScaleDataOffset * 4 + streamPos; long positionDataPos = (long)infoTable.PositionDataOffset * 4 + streamPos; long rotationDataPos = (long)infoTable.RotationDataOffset * 4 + streamPos; reader.BaseStream.Position = scaleIndicesPos; int[] scaleIndices = ReadIndices(reader, infoTable.ScaleCount); reader.BaseStream.Position = positionIndicesPos; int[] positionIndices = ReadIndices(reader, infoTable.PositionCount); reader.BaseStream.Position = rotationIndicesPos; int[] rotationIndices = ReadIndices(reader, infoTable.RotationCount); BoneAnimation boneAnimation = new BoneAnimation(); BoneAnimations[boneIndex] = boneAnimation; reader.BaseStream.Position = scaleDataPos; for (int j = 0; j < infoTable.ScaleCount; j++) { int frame = System.Math.Abs(scaleIndices[j]) % InfoTableSize; boneAnimation.Scales[frame] = ReadScale(reader); } reader.BaseStream.Position = positionDataPos; for (int j = 0; j < infoTable.PositionCount; j++) { int frame = System.Math.Abs(positionIndices[j]) % InfoTableSize; boneAnimation.Positions[frame] = ReadPosition(reader); } reader.BaseStream.Position = rotationDataPos; for (int j = 0; j < infoTable.RotationCount; j++) { int frame = System.Math.Abs(rotationIndices[j]) % InfoTableSize; boneAnimation.Rotations[frame] = ReadRotation(reader); } reader.BaseStream.Position = afterTablePos; } } }
private void DrawRightPage(SpriteBatch spriteBatch, GraphicsDeviceManager graphics) { Vector2 TextPosRight = new Vector2(OpenNotebookRect.X + 0.55f * OpenNotebookRect.Width, OpenNotebookRect.Y); switch (GState) { case NotebookState.Stats: Rectangle StatTableRect = new Rectangle((TextPosRight + TextOffset).ToPoint(), new Point(OpenNotebookRect.Width / 5, OpenNotebookRect.Height / 2)); if (MainOptionsList.SelectedOption == "stats") { spriteBatch.DrawString(JustBreathe, "My Stats: ", TextPosRight, Color.Black); string[] Aspects = new string[6] { "charm", "courage", "empathy", "intelligence", "strength", "money" }; InfoTable StatTable = new InfoTable(MainCharacter.Stats, Aspects, StatTableRect, JustBreathe); StatTable.Draw(spriteBatch, graphics); } else if (MainOptionsList.SelectedOption == "relationships") { spriteBatch.DrawString(JustBreathe, "Friendship Levels: ", TextPosRight, Color.Black); string[] People = Case.Suspects.Concat(Case.TestimonyOnly).ToArray(); InfoTable RelTable = new InfoTable(MainCharacter.Relationships, People, StatTableRect, JustBreathe); RelTable.Draw(spriteBatch, graphics); } break; case NotebookState.ClickedQuitGame: case NotebookState.Options: if (MainOptionsList.SelectedOption == "savequit") { if (QuitButton == null) { SaveButton = new Button("Save Game", Arial, TextPosRight); QuitButton = new Button("Quit Game", Arial, TextPosRight + new Vector2(0.0f, 2 * SaveButton.Rect.Height)); } QuitButton.Draw(spriteBatch, graphics); SaveButton.Draw(spriteBatch, graphics); } break; case NotebookState.Profiles: if (MainOptionsList.SelectedOption != null) { DrawCharacterEntry(spriteBatch, graphics, AllChars.AllChars[MainOptionsList.SelectedOption], TextPosRight); } break; case NotebookState.Testimonies: case NotebookState.SelectedTestimony: // must select a character and a topic to view testimony. Only previously heard testimonies will appear if (TopicOptionsList.SelectedOption != null && MainOptionsList?.SelectedOption != null) { List <Testimony> Testimonies = (from testimony in TestimonyList.Testimonies where testimony.TopicTag == TopicOptionsList.SelectedOption && testimony.CharacterKey == MainOptionsList.SelectedOption && MainCharacter.TestimonyIds.Contains(testimony.Id) select testimony).ToList(); if (Testimonies.Count > 0) { TestimonyId[0] = Testimonies[0].IdContradict; } DrawTestimonies(spriteBatch, graphics, Testimonies, TextPosRight); if (SeekingTestimony) { if (SelectTestimonyButton == null) { SelectTestimonyButton = new Button("Select", JustBreathe25, TextPosRight + new Vector2(0, OpenNotebookRect.Height - 50)); } SelectTestimonyButton.Draw(spriteBatch, graphics); } } break; default: break; } }