public static int Cast(Processor proc, ProgramReader reader) { TypeFlag returnType = (TypeFlag)reader.NextInt(); uint addr = reader.NextPtr(); object v1 = BytesToNative(proc.Registers.TypeRegisters[0], proc.Registers.OperationRegisters[0]); byte[] b = null; switch (returnType) { case TypeFlag.Char: v1 = Conversions.ToChar(v1); break; case TypeFlag.Int: v1 = Conversions.ToInteger(v1); break; case TypeFlag.Float: v1 = Conversions.ToSingle(v1); break; } b = Convert(v1, returnType); MemoryWriter w = MemoryWriter.GetWriter(2, proc, addr); w.Write(b); return(reader.Elapsed()); }
public static List <int> GetProductIdByType(TypeFlag type) { string sqlCmd; switch (type) { case TypeFlag.Bestseller: sqlCmd = "select ProductId from Catalog.Product where Bestseller=1"; break; case TypeFlag.New: sqlCmd = "select ProductId from Catalog.Product where New=1"; break; case TypeFlag.Discount: sqlCmd = "select ProductId from Catalog.Product where Discount > 0"; break; case TypeFlag.OnSale: sqlCmd = "select ProductId from Catalog.Product where OnSale=1"; break; case TypeFlag.Recomended: sqlCmd = "select ProductId from Catalog.Product where Recomended=1"; break; default: throw new NotImplementedException(); } return(SQLDataAccess.ExecuteReadColumnIEnumerable <int>(sqlCmd, CommandType.Text, "ProductId", new SqlParameter { ParameterName = "@type", Value = (int)type }).ToList()); }
public PropertyID(string name, string returnType, TypeFlag returnTypeFlag, string[] parameterTypes, TypeFlag[] typeFlags) : base(parameterTypes, typeFlags) { this.name = name; this.retTypeName = returnType; this.retTypeFlag = returnTypeFlag; }
private void AddField(string key, Fnptr func, TypeFlag typeFlag) { keyword[nfield] = key; vfunc[nfield] = func; vtype[nfield] = typeFlag; nfield++; }
public static void AddProductByType(int productId, TypeFlag type) { string sqlCmd; switch (type) { case TypeFlag.Bestseller: sqlCmd = "Update Catalog.Product set SortBestseller=(Select min(SortBestseller)-10 from Catalog.Product), Bestseller=1 where ProductId=@productId"; break; case TypeFlag.New: sqlCmd = "Update Catalog.Product set SortNew=(Select min(SortNew)-10 from Catalog.Product), New=1 where ProductId=@productId"; break; case TypeFlag.Discount: sqlCmd = "Update Catalog.Product set SortDiscount=(Select min(SortDiscount)-10 from Catalog.Product) where ProductId=@productId"; break; default: return; } SQLDataAccess.ExecuteNonQuery(sqlCmd, CommandType.Text, new SqlParameter { ParameterName = "@productId", Value = productId }); }
public static void AddProductByType(int productId, TypeFlag type) { string sqlCmd; switch (type) { case TypeFlag.Bestseller: sqlCmd = "Update Catalog.Product set SortBestseller=(Select min(SortBestseller)-10 from Catalog.Product), Bestseller=1 where ProductId=@productId"; break; case TypeFlag.New: sqlCmd = "Update Catalog.Product set SortNew=(Select min(SortNew)-10 from Catalog.Product), New=1 where ProductId=@productId"; break; case TypeFlag.Discount: sqlCmd = "Update Catalog.Product set SortDiscount=(Select min(SortDiscount)-10 from Catalog.Product) where ProductId=@productId"; break; case TypeFlag.OnSale: sqlCmd = "Update Catalog.Product set SortOnSale=(Select min(SortOnSale)-10 from Catalog.Product), OnSale=1 where ProductId=@productId"; break; case TypeFlag.Recomended: sqlCmd = "Update Catalog.Product set SortRecomended=(Select min(SortRecomended)-10 from Catalog.Product), Recomended=1 where ProductId=@productId"; break; default: throw new NotImplementedException(); } SQLDataAccess.ExecuteNonQuery(sqlCmd, CommandType.Text, new SqlParameter { ParameterName = "@productId", Value = productId }); }
public static void UpdateProductByType(int productId, int sortOrder, TypeFlag type) { string sqlCmd; switch (type) { case TypeFlag.Bestseller: sqlCmd = "Update Catalog.Product set SortBestseller=@sortOrder where ProductId=@productId and Bestseller=1"; break; case TypeFlag.New: sqlCmd = "Update Catalog.Product set SortNew=@sortOrder where ProductId=@productId and New=1"; break; case TypeFlag.Discount: sqlCmd = "Update Catalog.Product set SortDiscount=@sortOrder where ProductId=@productId"; break; default: return; } SQLDataAccess.ExecuteNonQuery(sqlCmd, CommandType.Text, new SqlParameter { ParameterName = "@productId", Value = productId }, new SqlParameter { ParameterName = "@sortOrder", Value = sortOrder } ); }
public static DataTable GetAdminProductsByType(TypeFlag type, int count) { string sqlCmd; switch (type) { case TypeFlag.Bestseller: sqlCmd = "select Top(@count) Product.ProductId, Name from Catalog.Product where Bestseller=1 order by SortBestseller"; break; case TypeFlag.New: sqlCmd = "select Top(@count) Product.ProductId, Name from Catalog.Product where New=1 order by SortNew"; break; case TypeFlag.Discount: sqlCmd = "select Top(@count) Product.ProductId, Name from Catalog.Product where Discount > 0 order by SortDiscount"; break; case TypeFlag.OnSale: sqlCmd = "select Top(@count) Product.ProductId, Name from Catalog.Product where OnSale=1 order by SortOnSale"; break; case TypeFlag.Recomended: sqlCmd = "select Top(@count) Product.ProductId, Name from Catalog.Product where Recomended=1 order by SortOnRecomended"; break; default: throw new NotImplementedException(); } return(SQLDataAccess.ExecuteTable(sqlCmd, CommandType.Text, new SqlParameter { ParameterName = "@count", Value = count })); }
public static int GetProductCountByType(TypeFlag type) { string sqlCmd = "select Count(ProductId) from Catalog.Product where Enabled=1 and CategoryEnabled=1 and {0}"; switch (type) { case TypeFlag.Bestseller: sqlCmd = string.Format(sqlCmd, "bestseller=1"); break; case TypeFlag.New: sqlCmd = string.Format(sqlCmd, "new=1"); break; case TypeFlag.Discount: sqlCmd = string.Format(sqlCmd, "Discount > 0"); break; case TypeFlag.OnSale: sqlCmd = string.Format(sqlCmd, "OnSale = 1"); break; case TypeFlag.Recomended: sqlCmd = string.Format(sqlCmd, "Recomended = 1"); break; default: throw new NotImplementedException(); } return(SQLDataAccess.ExecuteScalar <int>(sqlCmd, CommandType.Text)); }
static bool matchReturnType(Type targetType, string typeName, TypeFlag flag) { // if (targetType.IsGenericParameter) // { // return 0 != (flag & TypeFlag.IsT); // } // // return (targetType.Name == typeName); return(true); }
public bool ColumnExists(string columnName, TypeFlag type, Version version) { var column = Columns.FirstOrDefault(x => x.Name == columnName && x.ValueType == type); if (column == null) { return(false); } return(column.DoesExist(version)); }
public static DataTable GetProductsByType(TypeFlag type, int count) { string sqlCmd = "select Top(@count) Product.ProductId, Product.ArtNo, Name, BriefDescription, " + "(CASE WHEN Offer.ColorID is not null THEN (Select TOP(1) PhotoId From [Catalog].[Photo] WHERE ([Photo].ColorID = Offer.ColorID or [Photo].ColorID is null) and [Product].[ProductID] = [Photo].[ObjId] and Type=@Type order by main desc, PhotoSortOrder) ELSE (Select TOP(1) PhotoId From [Catalog].[Photo] WHERE [Product].[ProductID] = [Photo].[ObjId] and Type=@Type order by main desc, PhotoSortOrder) END) AS PhotoId, " + "(CASE WHEN Offer.ColorID is not null THEN (Select TOP(1) PhotoName From [Catalog].[Photo] WHERE ([Photo].ColorID = Offer.ColorID or [Photo].ColorID is null) and [Product].[ProductID] = [Photo].[ObjId] and Type=@Type order by main desc, PhotoSortOrder) ELSE (Select TOP(1) PhotoName From [Catalog].[Photo] WHERE [Product].[ProductID] = [Photo].[ObjId] and Type=@Type order by main desc, PhotoSortOrder) END) AS Photo, " + "(CASE WHEN Offer.ColorID is not null THEN (Select TOP(1) [Photo].[Description] From [Catalog].[Photo] WHERE ([Photo].ColorID = Offer.ColorID or [Photo].ColorID is null) and [Product].[ProductID] = [Photo].[ObjId] and Type=@Type) ELSE (Select TOP(1) [Photo].[Description] From [Catalog].[Photo] WHERE [Product].[ProductID] = [Photo].[ObjId] and Type=@Type AND [Photo].[Main] = 1) END) AS PhotoDesc, " + "Discount, Ratio, RatioID, AllowPreOrder, Recomended, New, BestSeller, OnSale, UrlPath, " + "ShoppingCartItemID, Price, " + "(Select Max(Offer.Amount) from catalog.Offer Where ProductId=[Product].[ProductID]) as Amount," + " Offer.OfferID, Offer.ColorID, MinAmount, " + (SettingsCatalog.ComplexFilter ? "(select [Settings].[ProductColorsToString]([Product].[ProductID])) as Colors": "null as Colors") + " from Catalog.Product " + "LEFT JOIN [Catalog].[Offer] ON [Product].[ProductID] = [Offer].[ProductID] and Offer.main=1 " + "LEFT JOIN Catalog.Photo on Product.ProductID=Photo.ObjId and Type=@Type and Photo.main=1 " + "LEFT JOIN [Catalog].[ShoppingCart] ON [Catalog].[ShoppingCart].[OfferID] = [Catalog].[Offer].[OfferID] AND [Catalog].[ShoppingCart].[ShoppingCartType] = @ShoppingCartType AND [ShoppingCart].[CustomerID] = @CustomerId " + "Left JOIN [Catalog].[Ratio] on Product.ProductId=Ratio.ProductID and Ratio.CustomerId=@CustomerId " + "where {0} and Enabled=1 and CategoryEnabled=1 and [Settings].[CountCategoriesByProduct](Product.ProductID) > 0 order by {1}"; switch (type) { case TypeFlag.Bestseller: sqlCmd = string.Format(sqlCmd, "Bestseller=1", "SortBestseller"); break; case TypeFlag.New: sqlCmd = string.Format(sqlCmd, "New=1", "SortNew, [DateModified] DESC"); break; case TypeFlag.Discount: sqlCmd = string.Format(sqlCmd, "Discount>0", "SortDiscount"); break; case TypeFlag.OnSale: sqlCmd = string.Format(sqlCmd, "OnSale=1", "[DateModified] DESC"); break; case TypeFlag.Recomended: sqlCmd = string.Format(sqlCmd, "Recomended=1", "[DateModified] DESC"); break; default: throw new NotImplementedException(); } return(SQLDataAccess.ExecuteTable(sqlCmd, CommandType.Text, new SqlParameter { ParameterName = "@count", Value = count }, new SqlParameter("@CustomerId", CustomerContext.CustomerId.ToString()), new SqlParameter("@Type", PhotoType.Product.ToString()), new SqlParameter("@ShoppingCartType", (int)ShoppingCartType.Compare))); }
public static object BytesToNative(TypeFlag f, byte[] bytes) { switch (f) { case TypeFlag.Int: return(BitConverter.ToInt32(bytes)); case TypeFlag.Float: return(BitConverter.ToSingle(bytes)); } throw new Exception("Unknown Type"); }
internal void Set(string key, TypeFlag flag, object value) { var p = new Pair(flag, value); if (this.data.ContainsKey(key)) { this.data[key] = p; } else { this.data.Add(key, p); } }
public Pair(TypeFlag flag, Object v) { this.flag = flag; if ((flag & TypeFlag.Int) == TypeFlag.Int) { this._vInt = (int)v; } else if ((flag & TypeFlag.String) == TypeFlag.String) { this._vStr = (string)v; } else if ((flag & TypeFlag.Bytes) == TypeFlag.Bytes) { this._vBytes = (byte[])v; } }
public static TypeFlag GetHigherFlag(Processor proc) { TypeFlag f = TypeFlag.Char; if (Comparer(proc, TypeFlag.Int)) { f = TypeFlag.Int; } if (Comparer(proc, TypeFlag.Float)) { f = TypeFlag.Float; } return(f); }
/// <summary> /// Take clean packet data, packet destinations and packet message flag and build a Packet class. /// </summary> /// <param name="data"></param> /// <param name="destinationIDs"></param> /// <param name="messageFlag"></param> public Packet(byte[] data, Guid[] destinationIDs = null, TypeFlag messageFlag = TypeFlag.DATA, int packetId = -1) { //Allocate data array this.data = new byte[data.Length + NUUtilities.PacketHeaderSize]; //Copy array data Array.Copy(data, 0, this.data, NUUtilities.PacketHeaderSize, data.Length); //Set packet size this.packetSize = this.data.Length; BitConverter.GetBytes(this.packetSize).CopyTo(this.data, 0); //Set message flag this.data[20] = (byte)messageFlag; this.flag = messageFlag; //Set packet id this.id = packetId; BitConverter.GetBytes(this.id).CopyTo(this.data, 21); //Set clean size this.cleanSize = data.Length; //Destionation info if (destinationIDs == null) { destinationIDs = new Guid[0]; } this.destinationIDs = destinationIDs; //Make sure hash data in buffer is clear //to enable comparations on the receiver for (int i = 0; i < 16; i++) { this.data[4 + i] = (byte)0; } //Generate hash data this.hash = new Hash(this.data); //Copy to packet buffer this.hash.data.CopyTo(this.data, 4); }
public static void AddProductByType(int productId, TypeFlag type) { string sqlCmd; switch (type) { case TypeFlag.Bestseller: sqlCmd = "Update Catalog.Product set SortBestseller=(Select min(SortBestseller)-10 from Catalog.Product), Bestseller=1 where ProductId=@productId"; break; case TypeFlag.New: sqlCmd = "Update Catalog.Product set SortNew=(Select min(SortNew)-10 from Catalog.Product), New=1 where ProductId=@productId"; break; case TypeFlag.Discount: sqlCmd = "Update Catalog.Product set SortDiscount=(Select min(SortDiscount)-10 from Catalog.Product) where ProductId=@productId"; break; default: throw new NotImplementedException(); } SQLDataAccess.ExecuteNonQuery(sqlCmd, CommandType.Text, new SqlParameter { ParameterName = "@productId", Value = productId }); }
public void OverridePacketFlag(TypeFlag messageFlag) { //Override message flag this.data[20] = (byte)messageFlag; this.flag = messageFlag; //Make sure hash data in buffer is clear //to enable comparations on the receiver for (int i = 0; i < 16; i++) { this.data[4 + i] = (byte)0; } //Recalculate Hash Code this.hash = new Hash(this.data); //Copy to packet buffer this.hash.data.CopyTo(this.data, 4); }
public TypeWrapper(AssemblyWrapper assembly, TypeReference type) { this.Assembly = assembly; this.Type = type; this.Name = GetName(type); this.FullName = GetFullName(type); TypeDefinition definition = type.Resolve(); TypeFlag none = TypeFlag.None; using (Collection <CustomAttribute> .Enumerator enumerator = definition.CustomAttributes.GetEnumerator()) { while (enumerator.MoveNext()) { TypeReference attributeType = enumerator.Current.AttributeType; if (!(attributeType.GetAssemblyName() != "UnityEngine") && (attributeType.FullName == "UnityEngine.SharedBetweenAnimatorsAttribute")) { none |= TypeFlag.HasSharedBetweenAnimatorsAttribute; } } } if (definition.IsInterface) { none |= TypeFlag.Interface; } if (definition.IsAbstract) { none |= TypeFlag.Abstract; } if (type.IsGenericInstance) { none |= TypeFlag.GenericInstance; } if (type.HasGenericParameters) { none |= TypeFlag.GenericDefinition; } this.Flags = none; this.DefaultConstructor = definition.Methods.SingleOrDefault <MethodDefinition>(< > c.< > 9__70_0 ?? (< > c.< > 9__70_0 = new Func <MethodDefinition, bool>(< > c.< > 9. <.ctor > b__70_0))); if (type.IsGenericInstance && (this.DefaultConstructor != null)) { this.DefaultConstructor = this.DefaultConstructor.MakeGenericMethod(((GenericInstanceType)type).GenericArguments.ToArray()); } }
public static DataTable GetProductsByType(TypeFlag type, int count) { string sqlCmd; switch (type) { //Changed by Evgeni to order by random //case TypeFlag.Bestseller: // sqlCmd = "select Top(@count) Product.ProductId, ArtNo, Name, PhotoName as Photo, [Photo].[Description] AS PhotoDesc, Discount, Ratio, RatioID, OrderByRequest, Recomended, New, BestSeller, OnSale, UrlPath, ItemId, Price, Offer.Amount from Catalog.Product LEFT JOIN [Catalog].[Offer] ON [Product].[ProductID] = [Offer].[ProductID] and offerListid=6 left Join Catalog.Photo on Product.ProductID=Photo.ObjId and Type=@Type and main=1 LEFT JOIN [Catalog].[ShoppingCart] ON [Catalog].[ShoppingCart].[EntityID] = [Catalog].[Product].[ProductID] AND [Catalog].[ShoppingCart].[ShoppingCartTypeId] = 3 AND [ShoppingCart].[CustomerID] = @CustomerId Left JOIN [Catalog].[Ratio] on Product.ProductId=Ratio.ProductID and Ratio.CustomerId=@CustomerId where Bestseller=1 and Enabled=1 and HirecalEnabled=1 and [Settings].[CountCategoriesByProduct](Product.ProductID) > 0 order by SortBestseller"; // break; //case TypeFlag.New: // sqlCmd = "select Top(@count) Product.ProductId, ArtNo, Name, PhotoName as Photo, [Photo].[Description] AS PhotoDesc, Discount, Ratio, RatioID, OrderByRequest, Recomended, New, BestSeller, OnSale, UrlPath, ItemId, Price, Offer.Amount from Catalog.Product LEFT JOIN [Catalog].[Offer] ON [Product].[ProductID] = [Offer].[ProductID] and offerListid=6 left Join Catalog.Photo on Product.ProductID=Photo.ObjId and Type=@Type and main=1 LEFT JOIN [Catalog].[ShoppingCart] ON [Catalog].[ShoppingCart].[EntityID] = [Catalog].[Product].[ProductID] AND [Catalog].[ShoppingCart].[ShoppingCartTypeId] = 3 AND [ShoppingCart].[CustomerID] = @CustomerId Left JOIN [Catalog].[Ratio] on Product.ProductId= Ratio.ProductID and Ratio.CustomerId=@CustomerId where New=1 and Enabled=1 and HirecalEnabled=1 and [Settings].[CountCategoriesByProduct](Product.ProductID) > 0 order by SortNew"; // break; //case TypeFlag.Discount: // sqlCmd = "select Top(@count) Product.ProductId, ArtNo, Name, PhotoName as Photo, [Photo].[Description] AS PhotoDesc, Discount, Ratio, RatioID, OrderByRequest, Recomended, New, BestSeller, OnSale, UrlPath, ItemId, Price, Offer.Amount from Catalog.Product LEFT JOIN [Catalog].[Offer] ON [Product].[ProductID] = [Offer].[ProductID] and offerListid=6 left Join Catalog.Photo on Product.ProductID=Photo.ObjId and Type=@Type and main=1 LEFT JOIN [Catalog].[ShoppingCart] ON [Catalog].[ShoppingCart].[EntityID] = [Catalog].[Product].[ProductID] AND [Catalog].[ShoppingCart].[ShoppingCartTypeId] = 3 AND [ShoppingCart].[CustomerID] = @CustomerId Left JOIN [Catalog].[Ratio] on Product.ProductId= Ratio.ProductID and Ratio.CustomerId=@CustomerId where Discount > 0 and Enabled=1 and HirecalEnabled=1 and [Settings].[CountCategoriesByProduct](Product.ProductID) > 0 order by SortDiscount"; //sqlCmd = "select Top(@count) Product.ProductId, ArtNo, Name, PhotoName as Photo, [Photo].[Description] AS PhotoDesc, Discount, Ratio, RatioID, OrderByRequest, Recomended, New, BestSeller, OnSale, UrlPath, ItemId, Price, Offer.Amount, Offer.MinAmount from Catalog.Product LEFT JOIN [Catalog].[Offer] ON [Product].[ProductID] = [Offer].[ProductID] and offerListid=6 left Join Catalog.Photo on Product.ProductID=Photo.ObjId and Type=@Type and main=1 LEFT JOIN [Catalog].[ShoppingCart] ON [Catalog].[ShoppingCart].[EntityID] = [Catalog].[Product].[ProductID] AND [Catalog].[ShoppingCart].[ShoppingCartTypeId] = 3 AND [ShoppingCart].[CustomerID] = @CustomerId Left JOIN [Catalog].[Ratio] on Product.ProductId=Ratio.ProductID and Ratio.CustomerId=@CustomerId where Bestseller=1 and Enabled=1 and HirecalEnabled=1 and [Settings].[CountCategoriesByProduct](Product.ProductID) > 0 order by SortBestseller"; // break; case TypeFlag.Bestseller: sqlCmd = "select Top(@count) Product.ProductId, ArtNo, Name, PhotoName as Photo, [Photo].[Description] AS PhotoDesc ,Discount, Ratio, RatioID, OrderByRequest, Recomended, New, BestSeller, OnSale, UrlPath, ItemId, Price, Offer.Amount, Offer.MinAmount from Catalog.Product LEFT JOIN [Catalog].[Offer] ON [Product].[ProductID] = [Offer].[ProductID] and offerListid=6 left Join Catalog.Photo on Product.ProductID=Photo.ObjId and Type=@Type and main=1 LEFT JOIN [Catalog].[ShoppingCart] ON [Catalog].[ShoppingCart].[EntityID] = [Catalog].[Product].[ProductID] AND [Catalog].[ShoppingCart].[ShoppingCartTypeId] = 3 AND [ShoppingCart].[CustomerID] = @CustomerId Left JOIN [Catalog].[Ratio] on Product.ProductId=Ratio.ProductID and Ratio.CustomerId=@CustomerId where Bestseller=1 and Enabled=1 and HirecalEnabled=1 and [Settings].[CountCategoriesByProduct](Product.ProductID) > 0 ORDER BY SortBestseller"; break; case TypeFlag.New: sqlCmd = "select Top(@count) Product.ProductId, ArtNo, Name, PhotoName as Photo, [Photo].[Description] AS PhotoDesc,Discount, Ratio, RatioID, OrderByRequest, Recomended, New, BestSeller, OnSale, UrlPath, ItemId, Price, Offer.Amount, Offer.MinAmount from Catalog.Product LEFT JOIN [Catalog].[Offer] ON [Product].[ProductID] = [Offer].[ProductID] and offerListid=6 left Join Catalog.Photo on Product.ProductID=Photo.ObjId and Type=@Type and main=1 LEFT JOIN [Catalog].[ShoppingCart] ON [Catalog].[ShoppingCart].[EntityID] = [Catalog].[Product].[ProductID] AND [Catalog].[ShoppingCart].[ShoppingCartTypeId] = 3 AND [ShoppingCart].[CustomerID] = @CustomerId Left JOIN [Catalog].[Ratio] on Product.ProductId= Ratio.ProductID and Ratio.CustomerId=@CustomerId where New=1 and Enabled=1 and HirecalEnabled=1 and [Settings].[CountCategoriesByProduct](Product.ProductID) > 0 order by SortNew"; break; case TypeFlag.Discount: sqlCmd = "select Top(@count) Product.ProductId, ArtNo, Name, PhotoName as Photo, [Photo].[Description] AS PhotoDesc,Discount, Ratio, RatioID, OrderByRequest, Recomended, New, BestSeller, OnSale, UrlPath, ItemId, Price, Offer.Amount, Offer.MinAmount from Catalog.Product LEFT JOIN [Catalog].[Offer] ON [Product].[ProductID] = [Offer].[ProductID] and offerListid=6 left Join Catalog.Photo on Product.ProductID=Photo.ObjId and Type=@Type and main=1 LEFT JOIN [Catalog].[ShoppingCart] ON [Catalog].[ShoppingCart].[EntityID] = [Catalog].[Product].[ProductID] AND [Catalog].[ShoppingCart].[ShoppingCartTypeId] = 3 AND [ShoppingCart].[CustomerID] = @CustomerId Left JOIN [Catalog].[Ratio] on Product.ProductId= Ratio.ProductID and Ratio.CustomerId=@CustomerId where Discount > 0 and Enabled=1 and HirecalEnabled=1 and [Settings].[CountCategoriesByProduct](Product.ProductID) > 0 order by SortDiscount"; break; default: throw new NotImplementedException(); // } return(SQLDataAccess.ExecuteTable(sqlCmd, CommandType.Text, new SqlParameter { ParameterName = "@count", Value = count }, new SqlParameter("@CustomerId", CustomerSession.CustomerId.ToString()), new SqlParameter("@Type", PhotoType.Product.ToString()))); }
internal NameStateCreature StateForFlag(TypeFlag typeFlag) { Debug.Assert(IsLive); switch (typeFlag) { case TypeFlag.None: return(NameStateCreature.Nothing); case TypeFlag.Scout: return(NameStateCreature.DoScoutFlag); case TypeFlag.Attack: return(NameStateCreature.DoAttackFlag); case TypeFlag.Defense: return(NameStateCreature.DoDefenseFlag); default: throw new Exception($"Неизвестный тип флага: {typeFlag}"); } }
public static byte[] Convert(object o, TypeFlag f) { byte[] b = null; if (f == TypeFlag.Char) { o = Conversions.ToChar(o); b = BitConverter.GetBytes((char)o); } else if (f == TypeFlag.Int) { o = Conversions.ToInteger(o); b = BitConverter.GetBytes((int)o); } else if (f == TypeFlag.Float) { o = Conversions.ToSingle(o); b = BitConverter.GetBytes((float)o); } return(b); }
private AcbFormatHelperColumn GetColumn(string name, TypeFlag type, bool throwExIfNewColumn, int columnIndex) { if (Columns == null) { Columns = new List <AcbFormatHelperColumn>(); } var column = Columns.FirstOrDefault(x => x.Name == name && x.ValueType == type); if (column == null && throwExIfNewColumn) { throw new InvalidDataException($"Unknown column \"{name}\" of type \"{type}\" encountered in ACB file. Parse failed."); } if (column == null) { column = new AcbFormatHelperColumn(name, type, columnIndex); Columns.Add(column); } return(column); }
public static void UpdateProductByType(int productId, int sortOrder, TypeFlag type) { string sqlCmd; switch (type) { case TypeFlag.Bestseller: sqlCmd = "Update Catalog.Product set SortBestseller=@sortOrder where ProductId=@productId and Bestseller=1"; break; case TypeFlag.New: sqlCmd = "Update Catalog.Product set SortNew=@sortOrder where ProductId=@productId and New=1"; break; case TypeFlag.Discount: sqlCmd = "Update Catalog.Product set SortDiscount=@sortOrder where ProductId=@productId"; break; case TypeFlag.OnSale: sqlCmd = "Update Catalog.Product set SortOnSale=@sortOrder where ProductId=@productId and OnSale=1"; break; case TypeFlag.Recomended: sqlCmd = "Update Catalog.Product set SortRecomended=@recomendedOrder where ProductId=@productId and Recomended=1"; break; default: throw new NotImplementedException(); } SQLDataAccess.ExecuteNonQuery(sqlCmd, CommandType.Text, new SqlParameter { ParameterName = "@productId", Value = productId }, new SqlParameter { ParameterName = "@sortOrder", Value = sortOrder } ); }
public static int GetProductCountByType(TypeFlag type) { string sqlCmd; switch (type) { case TypeFlag.Bestseller: sqlCmd = "select Count(ProductId) from Catalog.Product where Bestseller=1 and Enabled=1 and HirecalEnabled=1 and [Settings].[CountCategoriesByProduct](Product.ProductID) > 0"; break; case TypeFlag.New: sqlCmd = "select Count(ProductId) from Catalog.Product where New=1 and Enabled=1 and HirecalEnabled=1 and [Settings].[CountCategoriesByProduct](Product.ProductID) > 0 "; break; case TypeFlag.Discount: sqlCmd = "select Count(ProductId) from Catalog.Product where Discount > 0 and Enabled=1 and HirecalEnabled=1 and [Settings].[CountCategoriesByProduct](Product.ProductID) > 0"; break; default: throw new NotImplementedException(); } return(SQLDataAccess.ExecuteScalar <int>(sqlCmd, CommandType.Text)); }
public AcbFormatHelperColumn(string name, TypeFlag type, int index) { Name = name; ValueType = type; Index = index; }
public static IReadOnlyList <string> DetectTypes(SimpleDataTable table) { var types = new TypeFlag[table.Columns.Count]; for (var i = 0; i < table.Columns.Count; i++) { types[i] = TypeFlag.Text | TypeFlag.Integer | TypeFlag.Real | TypeFlag.Date | TypeFlag.DateTime; } foreach (var row in table.Rows) { for (var i = 0; i < table.Columns.Count; i++) { var value = Convert.ToString(row[i]); if (string.IsNullOrWhiteSpace(value)) { // ok for all types as a null continue; } var type = TypeFlag.Text; if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out _)) { type |= TypeFlag.Integer; } if (double.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out _)) { type |= TypeFlag.Real; } if (DateTime.TryParse(value, CultureInfo.InvariantCulture, DateTimeStyles.None, out var dateTime)) { type |= TypeFlag.DateTime; if (dateTime == dateTime.Date) { type |= TypeFlag.Date; } } types[i] &= type; } } var chosenTypes = new string[table.Columns.Count]; if (table.Rows.Count == 0) { // special case: if there are no rows, use TEXT for all. for (var i = 0; i < table.Columns.Count; i++) { chosenTypes[i] = "TEXT"; } } else { for (var i = 0; i < table.Columns.Count; i++) { var mask = types[i]; if (mask.HasFlag(TypeFlag.Integer)) { chosenTypes[i] = "INTEGER"; } else if (mask.HasFlag(TypeFlag.Real)) { chosenTypes[i] = "REAL"; } else if (mask.HasFlag(TypeFlag.Date)) { chosenTypes[i] = "DATE"; } else if (mask.HasFlag(TypeFlag.DateTime)) { chosenTypes[i] = "DATETIME"; } else { chosenTypes[i] = "TEXT"; } } } return(chosenTypes); }
public CommandFlags(TypeFlag value) { _Value = value; }
public static void UpdateProductByType(int productId, int sortOrder, TypeFlag type) { string sqlCmd; switch (type) { case TypeFlag.Bestseller: sqlCmd = "Update Catalog.Product set SortBestseller=@sortOrder where ProductId=@productId and Bestseller=1"; break; case TypeFlag.New: sqlCmd = "Update Catalog.Product set SortNew=@sortOrder where ProductId=@productId and New=1"; break; case TypeFlag.Discount: sqlCmd = "Update Catalog.Product set SortDiscount=@sortOrder where ProductId=@productId"; break; default: throw new NotImplementedException(); } SQLDataAccess.ExecuteNonQuery(sqlCmd, CommandType.Text, new SqlParameter { ParameterName = "@productId", Value = productId }, new SqlParameter { ParameterName = "@sortOrder", Value = sortOrder } ); }
static bool matchParameters(ParameterInfo[] pi, string[] paramTypeNames, TypeFlag[] typeFlags) { int paramLen = (paramTypeNames == null ? 0 : paramTypeNames.Length); int flagLen = (typeFlags == null ? 0 : typeFlags.Length); if (paramLen == 0) { if (!(pi == null || pi.Length == 0)) { return false; } } if (pi.Length != paramLen) { return false; } for (var i = 0; i < pi.Length; i++) { Type real_t = pi[i].ParameterType; TypeFlag flag = (flagLen > i ? typeFlags[i] : TypeFlag.None); bool byRef = 0 != (flag & TypeFlag.IsRef); if ((byRef && !real_t.IsByRef) || (!byRef && real_t.IsByRef)) return false; bool isOut = 0 != (flag & TypeFlag.IsOut); if ((isOut && !pi[i].IsOut) || (!isOut && pi[i].IsOut)) return false; if (byRef || isOut) { real_t = real_t.GetElementType(); } bool isArray = 0 != (flag & TypeFlag.IsArray); if (isArray) { if (!pi[i].ParameterType.IsArray) return false; } else { bool isGT = 0 != (flag & TypeFlag.IsGenericType); if (isGT) { if (!real_t.IsGenericType) return false; if (real_t.GetGenericTypeDefinition().Name != paramTypeNames[i]) return false; } else { bool isT = 0 != (flag & TypeFlag.IsT); if (!isT) { if (real_t.Name != paramTypeNames[i]) return false; } } } } return true; }
public static List<int> GetProductIdByType(TypeFlag type) { string sqlCmd; switch (type) { case TypeFlag.Bestseller: sqlCmd = "select ProductId from Catalog.Product where Bestseller=1"; break; case TypeFlag.New: sqlCmd = "select ProductId from Catalog.Product where New=1"; break; case TypeFlag.Discount: sqlCmd = "select ProductId from Catalog.Product where Discount > 0"; break; default: throw new NotImplementedException(); } return SQLDataAccess.ExecuteReadColumnIEnumerable<int>(sqlCmd, CommandType.Text, "ProductId", new SqlParameter { ParameterName = "@type", Value = (int)type }).ToList(); }
public static DataTable GetProductsByType(TypeFlag type, int count, PriceType priceType) { var priceField = priceType.ToString(); string sqlCmd = "select Top(@count) Product.ProductId, Product.ArtNo, Name, BriefDescription, " + "(CASE WHEN Offer.ColorID is not null THEN (Select TOP(1) PhotoName From [Catalog].[Photo] WHERE ([Photo].ColorID = Offer.ColorID or [Photo].ColorID is null) and [Product].[ProductID] = [Photo].[ObjId] and Type=@Type order by main desc, PhotoSortOrder) ELSE (Select TOP(1) PhotoName From [Catalog].[Photo] WHERE [Product].[ProductID] = [Photo].[ObjId] and Type=@Type order by main desc, PhotoSortOrder) END) AS Photo, " + "(CASE WHEN Offer.ColorID is not null THEN (Select TOP(1) [Photo].[Description] From [Catalog].[Photo] WHERE ([Photo].ColorID = Offer.ColorID or [Photo].ColorID is null) and [Product].[ProductID] = [Photo].[ObjId] and Type=@Type) ELSE (Select TOP(1) [Photo].[Description] From [Catalog].[Photo] WHERE [Product].[ProductID] = [Photo].[ObjId] and Type=@Type AND [Photo].[Main] = 1) END) AS PhotoDesc, " + "Discount, Ratio, RatioID, AllowPreOrder, Recomended, New, BestSeller, OnSale, UrlPath, " + "ShoppingCartItemID, " + (SettingsCatalog.UseLastPrice ? string.Format("(CASE WHEN ProductPrice IS NULL THEN {0} ELSE ProductPrice END) as Price, ", priceField) : string.Format("{0} as Price, ", priceField) ) + "(Select Max(Offer.Amount) from catalog.Offer Where ProductId=[Product].[ProductID]) as Amount," + " Offer.OfferID, Offer.ColorID, MinAmount, " + (SettingsCatalog.ComplexFilter ? "(select [Settings].[ProductColorsToString]([Product].[ProductID])) as Colors": "null as Colors") + " from Catalog.Product " + "LEFT JOIN [Catalog].[Offer] ON [Product].[ProductID] = [Offer].[ProductID] and Offer.main=1 " + "LEFT JOIN Catalog.Photo on Product.ProductID=Photo.ObjId and Type=@Type and Photo.main=1 " + "LEFT JOIN [Catalog].[ShoppingCart] ON [Catalog].[ShoppingCart].[OfferID] = [Catalog].[Offer].[OfferID] AND [Catalog].[ShoppingCart].[ShoppingCartType] = @ShoppingCartType AND [ShoppingCart].[CustomerID] = @CustomerId " + "Left JOIN [Catalog].[Ratio] on Product.ProductId=Ratio.ProductID and Ratio.CustomerId=@CustomerId " + "LEFT JOIN [Customers].[LastPrice] ON [LastPrice].[ProductId] = [Product].[ProductId] AND [LastPrice].[CustomerId] = @CustomerId " + "where {0} and Enabled=1 and CategoryEnabled=1 and [Settings].[CountCategoriesByProduct](Product.ProductID) > 0 order by {1}"; switch (type) { case TypeFlag.Bestseller: sqlCmd = string.Format(sqlCmd, "Bestseller=1", "SortBestseller"); break; case TypeFlag.New: sqlCmd = string.Format(sqlCmd, "New=1", "SortNew"); break; case TypeFlag.Discount: sqlCmd = string.Format(sqlCmd, "Discount>0", "SortDiscount"); break; default: throw new NotImplementedException(); } return SQLDataAccess.ExecuteTable(sqlCmd, CommandType.Text, new SqlParameter {ParameterName = "@count", Value = count}, new SqlParameter("@CustomerId", CustomerSession.CustomerId.ToString()), new SqlParameter("@Type", PhotoType.Product.ToString()), new SqlParameter("@ShoppingCartType", ShoppingCartType.Compare)); }
public static DataTable GetAdminProductsByType(TypeFlag type, int count) { string sqlCmd; switch (type) { case TypeFlag.Bestseller: sqlCmd = "select Top(@count) Product.ProductId, Name from Catalog.Product where Bestseller=1 order by SortBestseller"; break; case TypeFlag.New: sqlCmd = "select Top(@count) Product.ProductId, Name from Catalog.Product where New=1 order by SortNew"; break; case TypeFlag.Discount: sqlCmd = "select Top(@count) Product.ProductId, Name from Catalog.Product where Discount > 0 order by SortDiscount"; break; default: throw new NotImplementedException(); } return SQLDataAccess.ExecuteTable(sqlCmd, CommandType.Text, new SqlParameter { ParameterName = "@count", Value = count }); }
public static int GetProductCountByType(TypeFlag type) { string sqlCmd = "select Count(ProductId) from Catalog.Product where Enabled=1 and CategoryEnabled=1 and {0}"; switch (type) { case TypeFlag.Bestseller: sqlCmd = string.Format(sqlCmd, "bestseller=1"); break; case TypeFlag.New: sqlCmd = string.Format(sqlCmd, "new=1"); break; case TypeFlag.Discount: sqlCmd = string.Format(sqlCmd, "Discount > 0"); break; default: throw new NotImplementedException(); } return SQLDataAccess.ExecuteScalar<int>(sqlCmd, CommandType.Text); }
public string[] paramTypeNames; // can be null #endregion Fields #region Constructors // constructor public ConstructorID(string[] paramTypes, TypeFlag[] paramFlags) { this.paramTypeNames = paramTypes; this.paramFlags = paramFlags; }
static bool matchReturnType(Type targetType, string typeName, TypeFlag flag) { // if (targetType.IsGenericParameter) // { // return 0 != (flag & TypeFlag.IsT); // } // // return (targetType.Name == typeName); return true; }
public MethodID(string name, string retTypeName, TypeFlag returnTypeFlag, string[] parameterTypes, TypeFlag[] typeFlags) : base(name, retTypeName, returnTypeFlag, parameterTypes, typeFlags) { }
static bool matchParameters(ParameterInfo[] pi, string[] paramTypeNames, TypeFlag[] typeFlags) { int paramLen = (paramTypeNames == null ? 0 : paramTypeNames.Length); int flagLen = (typeFlags == null ? 0 : typeFlags.Length); if (paramLen == 0) { if (!(pi == null || pi.Length == 0)) { return(false); } } if (pi.Length != paramLen) { return(false); } for (var i = 0; i < pi.Length; i++) { Type real_t = pi[i].ParameterType; TypeFlag flag = (flagLen > i ? typeFlags[i] : TypeFlag.None); bool byRef = 0 != (flag & TypeFlag.IsRef); if ((byRef && !real_t.IsByRef) || (!byRef && real_t.IsByRef)) { return(false); } bool isOut = 0 != (flag & TypeFlag.IsOut); if ((isOut && !pi[i].IsOut) || (!isOut && pi[i].IsOut)) { return(false); } if (byRef || isOut) { real_t = real_t.GetElementType(); } bool isArray = 0 != (flag & TypeFlag.IsArray); if (isArray) { if (!pi[i].ParameterType.IsArray) { return(false); } } else { bool isGT = 0 != (flag & TypeFlag.IsGenericType); if (isGT) { if (!real_t.IsGenericType) { return(false); } if (real_t.GetGenericTypeDefinition().Name != paramTypeNames[i]) { return(false); } } else { bool isT = 0 != (flag & TypeFlag.IsT); if (!isT) { if (real_t.Name != paramTypeNames[i]) { return(false); } } } } } return(true); }