public void OnItemChanged(DBItem item, string propertyName, DBColumn column) { if (item is T titem) { OnItemChanged(titem, propertyName, column); } }
public static Dictionary <string, object> CreateParam(DBProcedure procedure, DBItem document = null) { var parameters = DBProcedure.CreateParams(document); CheckParam(procedure, parameters); return(parameters); }
public override void Execute(MySqlConnection connection) { String query = "SELECT * FROM muonline.items WHERE account='matias9'"; //create mysql command MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = query; cmd.Connection = connection; try { //Create a data reader and Execute the command MySqlDataReader dataReader = cmd.ExecuteReader(); //Read the data and store them in the list if (dataReader.Read()) { this.DBItem = new Data.DBItem(); this.DBItem.load(dataReader); } else { Logging.LogManager.DefaultLogger.Warn("ItemLoadTask could not read"); } //close Data Reader dataReader.Close(); Logging.LogManager.DefaultLogger.Trace("ItemLoadTask executed"); } catch (MySqlException ex) { Logging.LogManager.DefaultLogger.Error(ex.Message); Logging.LogManager.DefaultLogger.Error(ex.StackTrace); } }
protected bool satisfiesConstraints(DBItem dbitem) { foreach (string propertyName in _propertiesToFilter.Keys) { if (!dbitem.propertyExists(propertyName)) { return(false); } else if (_propertiesToFilter[propertyName] != null) { if (dbitem.getProperty(propertyName) is List <string> ) { if (!(dbitem.getProperty(propertyName) as List <string>).Contains(_propertiesToFilter[propertyName] as string)) { return(false); } } else if (!_propertiesToFilter[propertyName].Equals(dbitem.getProperty(propertyName))) { Debug.Log(string.Format("Item {0} failed filter for property {1} expected: {2} actual: {3}", dbitem.ClassName, propertyName, _propertiesToFilter[propertyName], dbitem.getProperty(propertyName))); return(false); } } } return(true); }
public override void runExtension(Database db) { foreach (DBItem giver in db.getSpawnableItems()) { if (!giver.propertyExists("gives")) { continue; } List <string> gives = (List <string>)giver.getProperty("gives"); foreach (string giftName in gives) { if (!db.itemExists(giftName)) { continue; } DBItem gift = db.getItem(giftName); if (!gift.propertyExists("givenby")) { gift.setProperty("givenby", new List <string>() { giver.ClassName }); } else if (!(gift.getProperty("givenby") as List <string>).Contains(giver.ClassName)) { (gift.getProperty("givenby") as List <string>).Add(giver.ClassName); } } } }
private string FormatMessage(PostgresException pex, DBTable table, DBItem dbItem) { var text = string.IsNullOrEmpty(pex.Detail) ? pex.MessageText : pex.Detail; var refTable = string.IsNullOrEmpty(pex.TableName) ? null : DBService.Schems.ParseTable(pex.TableName); var builder = new StringBuilder(); text = text.Replace("character varying", "Text"); foreach (var item in text.Split(new char[] { ',', ' ', '"', '(', ')' }, StringSplitOptions.RemoveEmptyEntries)) { if (table != null) { var column = refTable?.ParseColumnProperty(item) ?? table?.ParseColumnProperty(item); if (column != null) { builder.Append(column.DisplayName); builder.Append(' '); continue; } } builder.Append(item); builder.Append(' '); } return(builder.ToString()); }
private void Insert(JToken newValue) { var item = new DBItem(db, table); SetDBItemValues(ref item, table.Columns, newValue); table.Add(item); }
public virtual GuestItem CreateGuestItem(DBItem dbItem, decimal orderId) { var guestItem = new GuestItem() { Availability = dbItem.Availability, BasePrice = PricePerItemIncludingToppings, CanBeHalf = dbItem.CanBeHalf, Description = dbItem.Description, HasAllMods = dbItem.HasAllMods, HasRequiredMods = dbItem.HasRequiredMods, OrderID = orderId, ID = dbItem.ID, LongName = dbItem.LongName, NonTaxable = dbItem.NonTaxable, ShortName = dbItem.ShortName, SelectCommand = dbItem.SelectCommand, SizeTable = dbItem.SizeTable, Stackable = dbItem.Stackable, SubCategoryID = dbItem.SubCategoryID, SubCategoryName = dbItem.SubCategoryName, SuperCategory = dbItem.SuperCategory, SuperCategoryID = dbItem.SuperCategoryID, TieredPricing = dbItem.TieredPricing, OrderSent = false, Mods = new List <GuestModifier>(), Note = new List <string>() }; return(guestItem); }
public void CheckViews(DBItem item, string property, DBColumn column) { for (int i = 0; i < queryViews.Count; i++) { queryViews[i].OnItemChanged(item, property, column); } }
protected override bool spawnFilteredOutput(string outputName) { if (_verbose) { Debug.Log(string.Format("Generating Property Change Puzzle for {0}", outputName)); } // For property change puzzles we don't actually want to spawn the output here since the output nees to be spawned // (with relevant starting properties) at one of our inputs. if (!Database.Instance.itemExists(outputName)) { if (_verbose) { Debug.Log(string.Format("WARNING: Tried to access item that does not exist in database: {0}", outputName)); } return(false); } DBItem dbOutput = Database.Instance.getItem(outputName); if (dbOutput.Spawned) { if (_verbose) { Debug.Log(string.Format("Failed to generate Property Change Puzzle: {0} already spawned", outputName)); } return(false); } return(true); }
public DBLoadProgressEventArgs(IDBTableView view, int total, int current, DBItem row) : base(view, null) { this.totalCount = total; this.current = current; this.row = row; }
public void OnTableChanged(DBItem item, NotifyCollectionChangedAction type) { if (item == null || item is T) { OnTableChanged((T)item, type); } }
public bool Contains(DBItem obj) { if (obj == null || cache[obj.GetType()] == null) return false; return cache[obj.GetType()].ContainsValue(obj); }
public bool IsActionFull(EAction actionType) { DBItem db = ZTConfig.Instance.GetDBAction(actionType); int count = GetActionCountByType(actionType); return(count >= db.Data1); }
public DBItem GetDBItem(int id) { DBItem db = null; DictItem.TryGetValue(id, out db); return(db); }
public DBItem GetDBMoney(EMoney moneyType) { DBItem db = null; DictItem.TryGetValue((int)moneyType, out db); return(db); }
public bool IsActionFull(int key) { DBItem db = ZTConfig.Instance.GetDBItem(key); int count = GetItemCountById(key); return(count >= db.Data1); }
public static void CalcOutput(string output, string FWQ) { DataRow dr = m_outputdt.NewRow(); try { List <DBItemInSale> lst_iteminsale = DBItemInSale.GetItemInSaleByName(output.Trim(), FWQ); if (lst_iteminsale.Count > 0) { DBItemInSale iteminsale = lst_iteminsale[0]; DBItem item = DBItem.GetItemByName(output, FWQ); float profit = iteminsale.avgprice - item.avgprice; dr["name"] = output; dr["avgprice"] = item.avgprice; dr["lowprice"] = item.lowprice; dr["highprice"] = item.highprice; dr["updatetime"] = item.updatetime; dr["FWQ"] = item.FWQ; dr["num"] = iteminsale.avgnum; dr["avgsaleprice"] = iteminsale.avgprice; dr["avgprofit"] = profit; dr["avgprofitrate"] = profit / item.avgprice; TimeSpan ts = new TimeSpan(0, m_manufacturingcycle, 0); dr["manufacturingcycle"] = String.Format("{0}天", ts.Days); m_outputdt.Rows.Add(dr); } } catch (Exception ex) { } }
protected override bool spawnFilteredOutput(string outputName) { if (_verbose) { Debug.Log(string.Format("Generating Insertion puzzle for {0}", outputName)); } if (!Database.Instance.itemExists(outputName)) { if (_verbose) { Debug.Log(string.Format("WARNING: Tried to access item that does not exist in database: {0}", outputName)); } return(false); } DBItem dbReward = Database.Instance.getItem(outputName); if (dbReward.Spawned) { if (_verbose) { Debug.Log(string.Format("Failed to generate Insertion Puzzle: {0} already spawned", outputName)); } return(false); } return(true); }
/// <summary> /// 如果是删除 目录 ,查找该目录的所有子目录,查找所有的文件 /// 若是删除文档,则直接删除 /// </summary> /// <returns></returns> public List <DBItem> FindTarget(string dbName, string collectionName, string id) { List <DBItem> list = new List <DBItem>(); var db = DataStorage.GetInstance(DBType.MongoDB); if (collectionName == CONST.DB.CollectionName_CategoryItem) { var categoryList = CategoryManager.GetInstance().GetSubCategory(id); categoryList.Add(CategoryItem.Load(id)); foreach (var category in categoryList) { var dbItem1 = DBItem.Create(CONST.DB.DBName_DocService, CONST.DB.CollectionName_CategoryItem, category.id); list.Add(dbItem1); var docList = DocManager.GetInstance().Find("{'CategoryID':'" + dbItem1.ID + "'}", "{}", "{}", 0, int.MaxValue); foreach (var doc in docList) { var dbItem2 = DBItem.Create(CONST.DB.DBName_DocService, CONST.DB.CollectionName_DocItem, doc.ID); list.Add(dbItem2); } } } else { list.Add(DBItem.Create(dbName, collectionName, id)); } return(list); }
private void ShowNewItem(DBItem item) { newItem = item; var fileColumn = Table.Columns.GetByKey(DBColumnKeys.File); if (fileColumn != null) { using (var dialog = new OpenFileDialog { Multiselect = false }) { if (dialog.Run(ParentWindow)) { item[fileColumn] = File.ReadAllBytes(dialog.FileName); var fileNameColumn = Table.Columns.GetByKey(DBColumnKeys.FileName); if (fileNameColumn != null) { item[fileNameColumn] = Path.GetFileName(dialog.FileName); } } } } if (OwnerRow != null && baseColumn != null) { item[baseColumn] = OwnerRow.PrimaryId; } if (Table.GroupKey != null && Selected != null && Selected.Table == Table) { item[Table.GroupKey] = Selected.PrimaryId; } toolWindow.ButtonAccept.Sensitive = true; ((LayoutList)toolWindow.Target).FieldSource = item; toolWindow.Show(bar, toolAdd.Bound.BottomLeft); }
// Like property change and insertion puzzles, we don't actually generate the desired output here. protected override bool spawnFilteredOutput(string outputName) { if (_verbose) { Debug.Log(string.Format("Generating unboxing puzzle for {0}", outputName)); } if (!Database.Instance.itemExists(outputName)) { if (_verbose) { Debug.Log(string.Format("WARNING: Tried to generate item not in database: {0}", outputName)); } return(false); } DBItem dbOutput = Database.Instance.getItem(outputName); if (dbOutput.Spawned) { if (_verbose) { Debug.Log("Failed to generate Unboxing Puzzle: output already spawned"); } return(false); } _outputSpawnIndex = dbOutput.NextSpawnIndex; return(true); }
protected SpawnedPuzzleItem spawnLockedDoor() { DBItem lockDB = Database.Instance.getItem("lock"); PuzzleItem lockItem = lockDB.spawnItem(); return(spawnItem(lockItem)); }
public bool UseItemById(int id, int num = 1) { DBItem itemDB = ZTConfig.Instance.GetDBItem(id); switch (itemDB.ItemType) { case EItemType.MONEY: return(UseMoney(id, num)); case EItemType.ACTION: return(UseAction(id, num)); case EItemType.PETSOUL: return(UseSoul(id, num)); case EItemType.BOX: case EItemType.DRUG: case EItemType.KEY: case EItemType.MAT: return(UseBagItem(id, num)); case EItemType.EXP: return(false); case EItemType.CHIP: return(UseBagChip(id, num)); default: return(false); } }
// POST api/cartitem public HttpResponseMessage Post([FromBody] CartItemModel cartItem) { try { // token correct if (cartItem != null && cartItem.Token != null && Common.Token.Equals(cartItem.Token)) { if (ModelState.IsValid) { DBItem db = new DBItem(cartItem.Token); HttpStatusCode status; // Add cart item in DB bool success = db.AddCartItem(cartItem, out status); if (success) { // HTTP 200 - Saved Successfully return(Request.CreateErrorResponse(HttpStatusCode.OK, "Item added successfully to your cart")); } else { if (status == HttpStatusCode.Gone) { // HTTP 410 - Not enough quantity in stock return(Request.CreateErrorResponse(HttpStatusCode.ExpectationFailed, "Not enough quantity in stock. Please check if you already have this item in the cart")); } else { // HTTP 500 - Internal Error return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Internal Error")); } } } else { //validation errors string message = string.Join(", ", ModelState.Values .SelectMany(x => x.Errors) .Select(x => x.ErrorMessage)); return(Request.CreateErrorResponse(HttpStatusCode.ExpectationFailed, message)); } } else { new Logging().LogProgress(cartItem.Token, Common.CallerIP, new Exception("Invalid token passed")); // HTTP 400 - Bad Request (token incorrect) return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, "Invalid token passed")); } } catch (Exception ex) { new Logging().LogProgress(cartItem.Token, Common.CallerIP, ex); // HTTP 500 - Internal Error return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Internal Error")); } }
public static List <DBItem> RecordDatesDeleted(COREobject core, List <DBItem> OldData, List <DBItem> NewData) { // List of newly removed users from AD List <DBItem> removedUsers = new List <DBItem>(); for (int i = 0; i < OldData.Count; i++) { DBItem oldUser = OldData[i]; string sapid1 = (string)oldUser["sapid1"]; // Remove old active users, so oldData contains only deleted users in the end if (!(NewData.Any(c => (string)c["sapid1"] == sapid1))) { removedUsers.Add(oldUser); } } foreach (DBItem removedUser in removedUsers) { string sapid1 = (string)removedUser["sapid1"]; var user = core.Context.Users.SingleOrDefault(c => c.UserName == sapid1 && c.DeletedBySync == null); if (user != null) { user.DeletedBySync = DateTime.Now; } } core.Context.SaveChanges(); return(OldData); }
internal void OnReferenceChanged(DBItem item) { if (!item.Attached) { return; } //if (item is DocumentWork work) //{ // if (work.Completed || work.UpdateState == DBUpdateState.Default) // RefreshCache(); //} //else if (item is DocumentReference reference) //{ // RefChanged?.Invoke(this, ListChangedType.Reset); //} if (item.UpdateState != DBUpdateState.Default && (item.UpdateState & DBUpdateState.Commit) != DBUpdateState.Commit && item.Attached) { changes++; } else if (changes > 0 && (item.UpdateState == DBUpdateState.Default || !item.Attached)) { changes--; } ReferenceChanged?.Invoke(this, new DBItemEventArgs(item)); }
static void DeserializeObject(WORLDMSG msgID, BinReader data) { string str = data.ReadString(); Type type = dbTypes.GetType(str); if (type == null) { throw new Exception("Failed to deserialize " + str + ": type == null"); } uint ObjectID = data.ReadUInt32(); DBObject obj = GetDBObject(type, ObjectID); if (obj != null) { obj.Deserialize(data); // we will probably never deserialized an existing object Console.WriteLine("woooah! WorldServer deserialized a " + str + " that already exists. Notify something!"); } else { obj = (DBObject)Activator.CreateInstance(type); obj.Deserialize(data); AddDBObject(obj); } if (type == typeof(DBCharacter)) { int n = data.ReadInt32(); DBCharacter c = (DBCharacter)obj; if (n > 0) { c.Items = new DBItem[n]; for (int i = 0; i < n; i++) { ObjectID = data.ReadUInt32(); DBItem item = (DBItem)GetDBObject(typeof(DBItem), ObjectID); if (item == null) { item = new DBItem(); item.Deserialize(data); AddDBObject(item); } else { item.Deserialize(data); } item.Template = (DBItemTemplate)GetDBObject(typeof(DBItemTemplate), item.TemplateID); if (item.Template == null) { Console.WriteLine("Missing Item Template " + item.TemplateID); } c.Items[i] = item; } } else { c.Items = null; } } }
public DockPage InitReference(DBItem owner, StageForeign param) { var foreign = param.Foreign; if (foreign == null || foreign.ReferenceTable != Document.DBTable) { return(null); } var name = foreign.Table.Name + " (" + foreign.Column.Name + ")"; var page = dock.GetPage(name); if (page == null) { var editor = new TableEditor() { Name = name, Text = param.Name == null || param.Name.Length == 0 ? foreign.Table.ToString() : param.Name, TableView = foreign.Table.CreateItemsView("", DBViewKeys.None, DBStatus.Actual | DBStatus.New | DBStatus.Edit | DBStatus.Error), OwnerColumn = foreign.Column, OpenMode = TableEditorMode.Referencing }; //editor.ToolSave = false; editor.SelectionChanged += OnReferenceTableRowSelected; page = dock.Put(editor, DockType.Content); } page.Tag = owner; return(page); }
private void addCommentBtn_Click(object sender, EventArgs e) { if (new ItemCheck(nameSurnameEmailComboBox.SelectedItem, moviesComboBox.SelectedItem, commentTxtBox.Text, commentDateTimePicker.Value).CommentCheck() == true) { //error, do nothing } else { if (MessageBox.Show("Do you want to add this comment to database?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { string name = nameSurnameEmailComboBox.SelectedItem.ToString().Split(' ')[0]; string secondName = nameSurnameEmailComboBox.SelectedItem.ToString().Split(' ', ',')[1]; string email = nameSurnameEmailComboBox.SelectedItem.ToString().Substring(nameSurnameEmailComboBox.SelectedItem.ToString().LastIndexOf(',') + 2); string movieTitle = moviesComboBox.SelectedItem.ToString(); string contents = commentTxtBox.Text; DateTime addDate = commentDateTimePicker.Value; BsonDocument _document = DBItem.Comment(name, secondName, email, movieTitle, contents, addDate); NewComment = _document; MovieTitle = movieTitle; UserEmail = email; this.DialogResult = DialogResult.Yes; } else { //do nothing } } }
public ItemObject CreateItem(DBItem dbItem) { ItemObject item; if (dbItem.Template == null) { Console.WriteLine("DBItem " + dbItem.ObjectId + " is missing Item template on worldserver."); return(null); } if (dbItem.Template.InvType == INVTYPE.BAG) { item = new ContainerObject(dbItem, this); } else { item = new ItemObject(dbItem, this); } m_slots[dbItem.OwnerSlot] = item.GUID; m_invObjects[dbItem.OwnerSlot] = item; m_owner.UpdateValue(m_baseField + dbItem.OwnerSlot * 2); if (dbItem.OwnerSlot < 19) { m_owner.UpdateValue(((int)PLAYERFIELDS.VISIBLE_ITEM_1_0) + dbItem.OwnerSlot * 9); m_owner.VisibleItems[dbItem.OwnerSlot] = m_invObjects[dbItem.OwnerSlot].Entry; } m_itemCount++; return(item); }
// Shoudl really only be called if an item has been deleted from the database public void Remove(DBItem obj) { if (obj == null || obj.Id == null) return; cache[obj.GetType()].Remove((int)obj.Id); }
public FrontNews(string type, string text, DateTime? time, DBItem dbItem) { this.dbItem = dbItem; NotificationType = type; var now = DateTime.Now; var timeSpan = (TimeSpan)(now - time); Time = getTimeSpan(timeSpan); Text = text; switch (type) { case "medal": NotificationImage = "Medal_WhiteB"; break; case "droplet": NotificationImage = "DropletFull_WhiteB.png"; break; case "rank": NotificationImage = "Trophy_WhiteB.png"; break; case "warning": NotificationImage = "Club_News.png"; break; case "join": NotificationImage = "Club_News.png"; break; case "friend": NotificationImage = "Medal_WhiteB.png"; break; case "ban": NotificationImage = "AF36.png"; break; case "clubRequest": NotificationImage = "Club_News.png"; break; case "invite": NotificationImage = "Club_News.png"; break; case "friendRequest": NotificationImage = "AF1.png"; Text = text + " has sent you a friend request"; break; default: NotificationImage = "Club_News.png"; break; } }
// Adds the given element to the cacheing system public DBItem Add(DBItem obj) { if (obj == null || obj.Id == null) return obj; if (!cache.ContainsKey(obj.GetType())) cache[obj.GetType()] = new Dictionary<int, DBItem>(); if (!cache[obj.GetType()].ContainsKey((int)obj.Id)) cache[obj.GetType()][(int)obj.Id] = obj; return cache[obj.GetType()][(int)obj.Id]; }
public DBItem RenameItem(IUser user, DBItem item, string newName) { if(item is DBFile) return RenameFile(user,item as DBFile, newName); else if(item is DBDirectory){ return RenameDirectory(user,item as DBDirectory, newName); } return item; }
// remove the existing object with the same ID from the cache and store this one instead. public void Replace(DBItem obj) { if (obj == null || obj.Id == null) return; if (!cache.ContainsKey(obj.GetType())) cache[obj.GetType()] = new Dictionary<int, DBItem>(); cache[obj.GetType()][(int)obj.Id] = obj; }
// Returns the value of this field for the given object. public object GetValue(DBItem owner) { try { return propertyInfo.GetGetMethod().Invoke(owner, null); } catch (Exception) { throw new Exception("DBField does not belong to the Type of the supplied Owner."); } }
// sets the default value based on the datatype. public void InitializeValue(DBItem owner) { SetValue(owner, Default); }
public void RenameDBItem(DBItem item, string newName) { AsyncCallback call = new AsyncCallback( ServerRenamedDBItem ); RenamingDBItem process = _ro.RenameItem; IAsyncResult ar = process.BeginInvoke(_user, item, newName, call, null); }
// Sets the value of this field for the given object. public void SetValue(DBItem owner, object value) { try { // if we were passed a null value, try to set that. if (value == null) { propertyInfo.GetSetMethod().Invoke(owner, new object[] { null }); return; } // if we were passed a matching object, just set it if (value.GetType() == propertyInfo.PropertyType) { string strVal = value as string; if (strVal != null) value = strVal.Trim(); propertyInfo.GetSetMethod().Invoke(owner, new object[] { value }); return; } if (value is string) propertyInfo.GetSetMethod().Invoke(owner, new object[] { ConvertString((string)value) }); } catch (Exception e) { Logger.LogError("Error writing to {0}.{1} Property: {2}", owner.GetType().Name, this.Name, e.Message); } }
public IRelationList GetRelationList(DBItem dbObject) { return (IRelationList)getRelationListMethod.Invoke(dbObject, null); }
void getStartupSettings(ref DBItem startupItem, ref bool launch) { //startupItem = EmulatorsCore.Database.GetGame(5359); //launch = false; //return; if (string.IsNullOrEmpty(_loadParameter)) return; //Check and load startup parameters Regex paramReg = new Regex(@"([A-z]+)\s*:\s*([-]?[A-z0-9]+)"); List<string> loadParams = new List<string>(_loadParameter.Split(';')); foreach (string param in loadParams) { Match m = paramReg.Match(param); if (!m.Success) continue; switch (m.Groups[1].Value.ToLower()) { case "emulator": int id; if (int.TryParse(m.Groups[2].Value, out id)) startupItem = EmulatorsCore.Database.Get<Emulator>(id); break; case "rom": if (int.TryParse(m.Groups[2].Value, out id)) startupItem = EmulatorsCore.Database.Get<Game>(id); break; case "group": List<DBItem> groups = EmulatorsCore.Database.Get(typeof(RomGroup), new BaseCriteria(DBField.GetField(typeof(RomGroup), "Title"), "=", m.Groups[2].Value)); if (groups.Count > 0) startupItem = groups[0]; break; case "launch": bool tryLaunch; if (bool.TryParse(m.Groups[2].Value, out tryLaunch)) launch = tryLaunch; break; } } }
public ActionResult InsertRow(string appName, string tableName, FormCollection fc) { DBApp app = new DBApp() { Name = appName, ConnectionString = (new Entities()).Database.Connection.ConnectionString }; DBTable table = app.GetTable(tableName); bool isClusterIndex = false; foreach (DBIndex index in table.indices) //looking for cluster index between all indeces { if (index.indexName == "index_" + appName + tableName) { isClusterIndex = true; break; } } if (!isClusterIndex)//condition for cluster, you can not insert/update/delete without cluster in Azure { TempData["message-error"] = "Row can not be inserted, because table does not have a cluster index. The cluster index is created when you first create a primary key."; return RedirectToAction("Data", new { @appName = appName, @tableName = tableName }); } DBItem row = new DBItem(); foreach (DBColumn c in table.columns) //converting to right data type { if (fc.Get("col" + c.Name) == "") { row.createProperty(c.ColumnId, c.Name, null); } else { row.createProperty(c.ColumnId, c.Name, table.ConvertValue(c, fc.Get("col" + c.Name))); } } table.Add(row); app.SaveChanges(); TempData["message-success"] = "Row was successfully inserted."; return RedirectToAction("Data", new { @appName = appName, @tableName = tableName }); }
public ActionResult UpdateRow(string appName, string tableName, FormCollection fc) { DBApp app = new DBApp() { Name = appName, ConnectionString = (new Entities()).Database.Connection.ConnectionString }; DBTable table = app.GetTable(tableName); DBItem changes = new DBItem(); DBItem oldVal = new DBItem(); foreach (DBColumn c in table.columns)//converting to right data type { changes.createProperty(c.ColumnId, c.Name, table.ConvertValue(c, fc.Get("col" + c.Name))); oldVal.createProperty(c.ColumnId, c.Name, TempData[c.Name]); } table.Update(changes, oldVal); app.SaveChanges(); TempData["message-success"] = "Row was successfully updated."; return RedirectToAction("Data", new { @appName = appName, @tableName = tableName }); }
void Database_OnItemDeleting(DBItem changedItem) { Game game = changedItem as Game; if (game != null && importer != null) importer.Remove(game.Id); }
public ActionResult DeleteOrUpdate(string appName, string tableName, FormCollection fc) { DBApp app = new DBApp() { Name = appName, ConnectionString = (new Entities()).Database.Connection.ConnectionString }; DBTable table = app.GetTable(tableName); DBItem row = new DBItem(); foreach (DBColumn c in table.columns)//converting to right data type { row.createProperty(c.ColumnId, c.Name, table.ConvertValue(c, fc.Get("col" + c.Name))); TempData.Remove(c.Name); TempData.Add(c.Name, row[c.Name]); } if (fc.Get("Update") != null) { ViewBag.Row = row.getAllProperties(); return View("UpdateView", table); } else { table.Remove(row); app.SaveChanges(); TempData["message-success"] = "Row was successfully deleted."; return RedirectToAction("Data", new { @appName = appName, @tableName = tableName }); } }