public override void FinishedMigration(IDataConnector genericData) { if (!genericData.TableExists("estates")) { return; } DataReaderConnection dr = genericData.QueryData("WHERE `Key` = 'EstateID'", "estates", "`ID`, `Key`, `Value`"); if (dr != null) { try { while (dr.DataReader.Read()) { try { UUID ID = UUID.Parse(dr.DataReader["ID"].ToString()); string value = dr.DataReader["Value"].ToString(); QueryFilter filter = new QueryFilter(); filter.andFilters["`ID`"] = value; filter.andFilters["`Key`"] = "EstateSettings"; List <string> results = genericData.Query(new string[1] { "`Value`" }, "estates", filter, null, null, null); if ((results != null) && (results.Count >= 1)) { EstateSettings es = new EstateSettings(); es.FromOSD((OSDMap)OSDParser.DeserializeLLSDXml(results[0])); genericData.Insert("estateregions", new object[] { ID, value }); filter = new QueryFilter(); filter.andFilters["`EstateID`"] = value; List <string> exist = genericData.Query(new string[1] { "`EstateID`" }, "estatesettings", filter, null, null, null); if (exist == null || exist.Count == 0) { genericData.Insert("estatesettings", new object[] { value, es.EstateName, es.EstateOwner, es.ParentEstateID, es.ToOSD() }); } } } catch { } } } catch { } finally { dr.DataReader.Close(); genericData.CloseDatabase(dr); } } }
//Create public Shoe CreateShoe(Shoe Shoe) { string sale = (Shoe.Sale) ? "0" : "1"; string date = DateTime.Now.ToString(); dataConnector.Insert("INSERT INTO `shoe`(`ID`, `img`, `Name`, `Price`, `OldPrice`, `GroupID`, `BrandID`, `Color`, `Sale`,`DateAdded`, `Description`, `Stock`) VALUES (NULL,'" + Shoe.img + "','" + Shoe.Name + "','" + Shoe.Price + "','" + Shoe.OldPrice + "','" + Shoe.Group.ID + "','" + Shoe.Brand.ID + "','" + Shoe.Color + "','" + sale + "','" + date + "','" + Shoe.Description + "', '50')"); return(GetShoe(Shoe)); }
protected override void DoCreateDefaults(IDataConnector genericData) { EnsureAllTablesInSchemaExist(genericData); genericData.Insert("webapi_access", new object[3] { // disables all access to the API by default UUID.Zero, "", null }); }
public void Update(TContext context, BasePrimitive <TItem> current, BasePrimitive <TItem> next) { var currentList = current?.Attributes.GetAttributeOrDefault(_attribute); var nextList = next?.Attributes.GetAttributeOrDefault(_attribute); // get an id to allow for easy viewing long loggingId = 0; if (IsLoggingEnabled.Value) { loggingId = Interlocked.Increment(ref LoggingId); Logging.Instance.LogInformation("CollectionUpdate:Begin {id} current Length:{currentLength} next Length:{nextLength}", loggingId, currentList?.Length ?? 0, nextList?.Length ?? 0); } IEnumerable <Operation <TTarget> > operations; // get a list of operations that transform currentList to nextList IReadOnlyList <Operation <TTarget> > comparisonOperations; if (IsLoggingEnabled.Value) { using var _ = Benchmark.Create((d, __) => { Logging.Instance.LogInformation("CollectionUpdate:Timings {id} duration:{duration}ms, algorithm:{algorithm}", loggingId, d, _collectionComparer.GetType().FriendlyName()); }); comparisonOperations = _collectionComparer.Compare(currentList, nextList); } else { comparisonOperations = _collectionComparer.Compare(currentList, nextList); } if (IsLoggingEnabled.Value) { Logging.Instance.LogInformation("CollectionUpdate:Raw {id} change count:{count}", loggingId, comparisonOperations.Count); } // only perform an attempt at a compaction if there is an insert and a delete both in existence if (comparisonOperations.Count >= 2 && comparisonOperations.Any(f => f.GetType() == typeof(DeleteOp <IPrimitive>)) && comparisonOperations.Any(f => f.GetType() == typeof(InsertOp <IPrimitive>))) { if (IsLoggingEnabled.Value) { Logging.Instance.LogInformation("CollectionUpdate:Compacting Changes"); } // create our collection change compactor which will look to reduce the number of updates made var collectionChangeCompactor = new CollectionChangeCompactor <TTarget>(currentList ?? nextList); foreach (var operation in comparisonOperations) { switch (operation) { case InsertOp <TTarget> op: collectionChangeCompactor.Insert(op.Index, op.Item); break; case DeleteOp <TTarget> op: collectionChangeCompactor.Delete(op.Index); break; case MoveOp <TTarget> op: collectionChangeCompactor.Delete(op.From); collectionChangeCompactor.Insert(op.To, op.Item); break; case UpdateOp <TTarget> op: collectionChangeCompactor.Update(op.Index, op.ToItem); break; } } operations = collectionChangeCompactor.GetChangOps(); } else { operations = comparisonOperations; } // now apply changes foreach (var operation in operations) { switch (operation) { case UpdateOp <TTarget> op: if (IsLoggingEnabled.Value) { Logging.Instance.LogInformation("CollectionUpdate:Update {id} {index}:{item}", loggingId, op.Index, op.FromItem, op.ToItem); } _connector.Update(op.Index, op.FromItem, op.ToItem); break; case DeleteOp <TTarget> op: if (IsLoggingEnabled.Value) { Logging.Instance.LogInformation("CollectionUpdate:Delete {id} {index}:{item}", loggingId, op.Index, op.Item); } _connector.Remove(op.Index, op.Item); break; case InsertOp <TTarget> op: if (IsLoggingEnabled.Value) { Logging.Instance.LogInformation("CollectionUpdate:Insert {id} {index}:{item}", loggingId, op.Index, op.Item); } _connector.Insert(op.Index, op.Item); break; default: throw new ArgumentOutOfRangeException(); } } if (IsLoggingEnabled.Value) { Logging.Instance.LogInformation("CollectionUpdate:End {id}", loggingId); } }
//Create public Group CreateGroup(Group Group) { dataConnector.Insert("INSERT INTO `group` (`ID`, `Name`) VALUES (NULL, '" + Group.Name + "');"); return(GetGroup(Group)); }
//Create public Brand CreateBrand(Brand Brand) { dataConnector.Insert("INSERT INTO `brand` (`ID`, `Name`) VALUES (NULL, '" + Brand.Name + "');"); return(GetBrand(Brand)); }
public override void FinishedMigration(IDataConnector genericData) { if (!genericData.TableExists("estates")) return; DataReaderConnection dr = genericData.QueryData("WHERE `Key` = 'EstateID'", "estates", "`ID`, `Key`, `Value`"); if (dr != null) { try { while (dr.DataReader.Read()) { try { UUID ID = UUID.Parse(dr.DataReader["ID"].ToString()); string value = dr.DataReader["Value"].ToString(); QueryFilter filter = new QueryFilter(); filter.andFilters["`ID`"] = value; filter.andFilters["`Key`"] = "EstateSettings"; List<string> results = genericData.Query(new string[1] { "`Value`" }, "estates", filter, null, null, null); if ((results != null) && (results.Count >= 1)) { EstateSettings es = new EstateSettings(); es.FromOSD((OSDMap)OSDParser.DeserializeLLSDXml(results[0])); genericData.Insert("estateregions", new object[] { ID, value }); filter = new QueryFilter(); filter.andFilters["`EstateID`"] = value; List<string> exist = genericData.Query(new string[1] { "`EstateID`" }, "estatesettings", filter, null, null, null); if (exist == null || exist.Count == 0) { genericData.Insert("estatesettings", new object[] { value, es.EstateName, es.EstateOwner, es.ParentEstateID, es.ToOSD() }); } } } catch { } } } catch { } finally { dr.DataReader.Close(); genericData.CloseDatabase(dr); } } }
//Create public Order CreateOrder(Order Order) { dataConnector.Insert("INSERT INTO `order` (`ID`, `AccountID`) VALUES (NULL, '" + Order.AccountID + "');"); return(GetOrder(Order)); }
//Create public OrderItem CreateOrderItem(OrderItem Orderitem) { dataConnector.Insert("INSERT INTO `orderitem` (`ID`, `OrderID`, `ProductID`) VALUES (NULL, '" + Orderitem.OrderID + "', '" + Orderitem.ProductID + "');"); return(GetOrderItem(Orderitem)); }
protected override void DoCreateDefaults(IDataConnector genericData) { EnsureAllTablesInSchemaExist(genericData); genericData.Insert("webapi_access", new object[3]{ // disables all access to the API by default UUID.Zero, "", null }); }
//Create public Account CreateAccount(Account Account) { Account.PhoneNumber = Convert.ToInt32(Account.PhoneNumber.ToString().Replace(" ", string.Empty)); dataConnector.Insert("INSERT INTO `account` (`ID`, `FirstName`, `MiddleName`, `LastName`, `PhoneNumber`, `Email`, `Country`, `Address`, `City`, `ZIPcode`, `LoginID`, `Admin`) VALUES (NULL, '" + Account.FirstName + "', '" + Account.MiddleName + "', '" + Account.LastName + "', '" + Account.PhoneNumber + "', '" + Account.Email + "', '" + Account.Country + "', '" + Account.Address + "', '" + Account.City + "', '" + Account.ZIPcode + "', '" + Account.Login.ID + "', '0');"); return(GetAccount(Account)); }
//Create public BagItem CreateBagItem(BagItem bagitem) { dataConnector.Insert("INSERT INTO `bagitem` (`ID`, `AccountID`, `ProductID`) VALUES (NULL, '" + bagitem.AccountID + "', '" + bagitem.ProductID + "');"); return(GetBagItem(bagitem)); }
//Create public Login CreateLogin(Login Login) { dataConnector.Insert("INSERT INTO `login` (`ID`, `Username`, `Password`, `Salt`) VALUES (NULL, '" + Login.UserName + "', '" + Login.HashedPassword + "', '" + Login.Salt + "');"); return(GetLogin(Login)); }
protected override void DoCreateDefaults(IDataConnector genericData) { EnsureAllTablesInSchemaExist(genericData); genericData.Insert("webapi_access_maxthreat", new object[2]{ UUID.Zero, (uint)WebAPIThreatLevel.VeryLow }); }