private bool ValidateInvoiceData(AddInvoiceViewModel vm) { bool result = false; if (!String.IsNullOrEmpty(vm.IMAGEID)) { // Verify image file path. string imagePath = GSA.R7BD.Utility.Utilities.GetImageNowPath(vm.IMAGEID); if (!string.IsNullOrEmpty(imagePath) && System.IO.File.Exists(imagePath)) { vm.IMAGEPATH = imagePath; // Grab page count. string extension = Path.GetExtension(imagePath); byte pageCount = 1; if (extension == ".tiff" || extension == ".tif") { TIF TheFile = new TIF(imagePath); pageCount = (byte)TheFile.PageCount; TheFile.Dispose(); } vm.DOCPAGE = pageCount; result = true; } } return(result); }
public static ActionResult TiffViewResult(string Type, string TypeId, string FilePath, Controller controller, HttpResponseBase Response) { var model = new UserExceptionViewModel(); model.TiffType = Type; model.TiffTypeId = TypeId; string extension = Path.GetExtension(FilePath); if (extension == ".tiff" || extension == ".tif") { TIF TheFile = new TIF(FilePath); model.TotalTIFPgs = TheFile.PageCount; TheFile.Dispose(); var result = GetViewResult(controller, "UserException/TiffViewerModal", model); return(result); } else { byte[] fileBytes = System.IO.File.ReadAllBytes(FilePath); var cd = new System.Net.Mime.ContentDisposition { FileName = Path.GetFileName(FilePath), // always prompt the user for downloading, set to true if you want // the browser to try to show the file inline Inline = false, }; Response.AppendHeader("Content-Disposition", cd.ToString()); var result = new FileContentResult(fileBytes, MimeMapping.GetMimeMapping(FilePath)); return(result); } }
public void Initialize(ClientMarketData.OrderRow orderRow) { this.orderId = orderRow.OrderId; this.transactionType = (TransactionType)orderRow.TransactionTypeCode; this.tif = (TIF)orderRow.TimeInForceCode; this.pricedAt = (PricedAt)orderRow.OrderTypeCode; this.quantity = orderRow.Quantity; this.price1 = orderRow.IsPrice1Null() ? (object)null : orderRow.Price1; this.price2 = orderRow.IsPrice2Null() ? (object)null : orderRow.Price2; }
/// <summary> /// Creates a proposed order record. /// </summary> /// <param name="proposedOrderId">The primary identifer of the record.</param> /// <param name="position">Identifies the account/security/position type code for the order.</param> /// <param name="tif">Time in Force</param> /// <param name="pricedAt">How the order is priced.</param> /// <param name="quantity">The number of units being purchased.</param> /// <param name="price1">The limit/stop price.</param> /// <param name="price2">The stop limit price.</param> public ProposedOrder(int proposedOrderId, Position position, TIF tif, PricedAt pricedAt, decimal quantity, object price1, object price2) { // Initialize the object. this.proposedOrderId = proposedOrderId; this.position = position; this.transactionType = transactionType; this.tif = tif; this.pricedAt = pricedAt; this.quantity = quantity; this.price1 = price1; this.price2 = price2; }
/// <summary> /// Executes a block order. /// </summary> /// <param name="configurationId">Defines which external fields are used to identify an object.</param> /// <param name="brokerId">The destination broker for the order.</param> /// <param name="tif">Specifies a time limit on the order.</param> /// <param name="quantity">The number of units to be traded.</param> /// <param name="pricedAt">Specifies how the order is to be priced.</param> /// <param name="limitPrice">A limit price for the order.</param> public void Execute(Broker broker, TIF tif, decimal quantity, PricedAt pricedAt, decimal limitPrice) { RemoteBatch remoteBatch = new RemoteBatch(); RemoteAssembly remoteAssembly = remoteBatch.Assemblies.Add("Service.Trading"); RemoteType remoteType = remoteAssembly.Types.Add("Shadows.WebService.Trading.BlockOrder"); RemoteMethod remoteMethod = remoteType.Methods.Add("Execute"); remoteMethod.Parameters.Add("blockOrderId", this.blockOrderId); remoteMethod.Parameters.Add("brokerId", broker.BrokerId); remoteMethod.Parameters.Add("timeInForceCode", (int)tif); remoteMethod.Parameters.Add("quantity", quantity); remoteMethod.Parameters.Add("orderTypeCode", (int)pricedAt); remoteMethod.Parameters.Add("price1", limitPrice); ClientMarketData.Execute(remoteBatch); }
/// <summary> /// Adds an order to a block order. /// </summary> /// <param name="configurationId">Defines which external fields are used to identify an object.</param> /// <param name="accountId">The destination account for the order.</param> /// <param name="tif">Specifies a time limit on the order.</param> /// <param name="quantity">The number of units to be traded.</param> /// <returns>An internal identifier used to track the order.</returns> public int AddOrder(Account account, TIF tif, decimal quantity) { RemoteBatch remoteBatch = new RemoteBatch(); RemoteAssembly remoteAssembly = remoteBatch.Assemblies.Add("Service.Trading"); RemoteType remoteType = remoteAssembly.Types.Add("Shadows.WebService.Trading.Order"); RemoteMethod remoteMethod = remoteType.Methods.Add("Insert"); remoteMethod.Parameters.Add("orderId", DataType.Int, Direction.ReturnValue); remoteMethod.Parameters.Add("blockOrderId", this.blockOrderId); remoteMethod.Parameters.Add("accountId", account.AccountId); remoteMethod.Parameters.Add("securityId", this.Security.SecurityId); remoteMethod.Parameters.Add("settlementId", this.Settlement.SecurityId); remoteMethod.Parameters.Add("timeInForceCode", (int)tif); remoteMethod.Parameters.Add("transactionTypeCode", (int)this.transactionType); remoteMethod.Parameters.Add("orderTypeCode", (int)PricedAt.Market); remoteMethod.Parameters.Add("quantity", quantity); ClientMarketData.Execute(remoteBatch); return (int)remoteMethod.Parameters["orderId"].Value; }
/// <summary> /// Creates a proposed order record. /// </summary> /// <param name="proposedOrderRow">A proposed order record from the primary ADO database.</param> /// <returns>A ProposedOrder record based on the ADO record.</returns> internal static ProposedOrder Make(ClientMarketData.ProposedOrderRow proposedOrderRow) { // Initialize the object DataRowVersion dataRowVersion = proposedOrderRow.RowState == DataRowState.Deleted ? DataRowVersion.Original : DataRowVersion.Current; // Extract the data from the ADO record. int proposedOrderId = (int)proposedOrderRow[ClientMarketData.ProposedOrder.ProposedOrderIdColumn, dataRowVersion]; TransactionType transactionType = (TransactionType)proposedOrderRow[ClientMarketData.ProposedOrder.TransactionTypeCodeColumn, dataRowVersion]; int accountId = (int)proposedOrderRow[ClientMarketData.ProposedOrder.AccountIdColumn, dataRowVersion]; int securityId = (int)proposedOrderRow[ClientMarketData.ProposedOrder.SecurityIdColumn, dataRowVersion]; int positionTypeCode = Common.TransactionType.GetPosition((int)transactionType); Position position = Position.Make(accountId, securityId, positionTypeCode); TIF tif = (TIF)proposedOrderRow[ClientMarketData.ProposedOrder.TimeInForceCodeColumn, dataRowVersion]; PricedAt pricedAt = (PricedAt)proposedOrderRow[ClientMarketData.ProposedOrder.OrderTypeCodeColumn, dataRowVersion]; decimal quantity = (decimal)proposedOrderRow[ClientMarketData.ProposedOrder.QuantityColumn, dataRowVersion]; object price1 = proposedOrderRow[ClientMarketData.ProposedOrder.Price1Column, dataRowVersion]; object price2 = proposedOrderRow[ClientMarketData.ProposedOrder.Price2Column, dataRowVersion]; // Create a new record based on the data extracted from the ADO database. return(new ProposedOrder(proposedOrderId, position, tif, pricedAt, quantity, price1, price2)); }
private static string processFile(string path) { BMAP bmap = new BMAP(); string extension = Path.GetExtension(path).Substring(1); string outputName = ""; if (settings.Raw) { if (Raw.IsValid(path)) { Console.WriteLine("Loading : {0}", Path.GetFileName(path)); Raw.Load(path, true); return(path); } } else if (settings.Compress) { WreckfestExtensions we; if (Enum.TryParse <WreckfestExtensions>(extension, out we)) { using (MemoryStream ms = new MemoryStream(File.ReadAllBytes(path))) using (BinaryReader br = new BinaryReader(ms)) { if ( br.ReadInt32() != 4 || br.ReadByte() != extension[3] || br.ReadByte() != extension[2] || br.ReadByte() != extension[1] || br.ReadByte() != extension[0]) { br.BaseStream.Position = 0; var input = br.ReadBytes((int)ms.Length); File.Move(path, path + ".bak"); using (BinaryWriter bw = new BinaryWriter(new FileStream(path, FileMode.Create))) { bw.Write(4); bw.Write(extension[3]); bw.Write(extension[2]); bw.Write(extension[1]); bw.Write(extension[0]); bw.Write((int)we); var hashTable = new int[1 << (14 - 2)]; var output = new byte[LZ4Compress.CalculateChunkSize(input.Length)]; int i = 0; while (i < input.Length) { byte[] chunk = new byte[Math.Min(input.Length - i, output.Length)]; Array.Copy(input, i, chunk, 0, chunk.Length); Array.Clear(hashTable, 0, hashTable.Length); int size = LZ4Compress.Compress(hashTable, chunk, output, chunk.Length, chunk.Length + 4); bw.Write(size); bw.Write(output, 0, size); i += chunk.Length; } } } else { Console.WriteLine("Skipping : {0} is already compressed", Path.GetFileName(path)); } } } else { Console.WriteLine("Error : unsupported extension '{0}'.", extension); } } else if (extension == "bmap") { if (BMAP.IsBMAP(path)) { Console.WriteLine("Loading : {0}", Path.GetFileName(path)); bmap = BMAP.Load(path, false); outputName = string.Format("{0}.{1}.png", Path.GetFileNameWithoutExtension(path), (bmap.Mode == 1 ? "clutter" : (bmap.DDS.Format == D3DFormat.A8R8G8B8 ? "raw" : bmap.DDS.Format.ToString().ToLower()))); Console.WriteLine("Saving : {0}", outputName); if (!Overwrite(string.Format(@"{0}\{1}", Path.GetDirectoryName(path), outputName))) { return(null); } bmap.SaveAsPNG(outputName); return(path); } } else if (extension == "dds") { Console.WriteLine("Loading : {0}", Path.GetFileName(path)); bmap.Path = Path.GetFileName(path); bmap.DDS = DDS.Load(path); Console.WriteLine("Saving : {0}", Path.GetFileName(path.Replace(".dds", ".bmap"))); bmap.Save(path.Replace(".dds", ".x.bmap")); return(path); } else if (Array.IndexOf(new string[] { "png", "tga", "tif" }, extension) > -1) { Texture texture = null; Console.WriteLine("Loading : {0}", Path.GetFileName(path)); switch (extension) { case "png": texture = PNG.Load(path); break; case "tga": texture = TGA.Load(path); break; case "tif": texture = TIF.Load(path); break; } BreckfestSettings original = settings.Clone(); if (Path.GetFileNameWithoutExtension(path).EndsWith(".clutter", StringComparison.OrdinalIgnoreCase)) { settings.Clutter = true; path = path.Replace(".clutter", ""); } else if (Path.GetFileNameWithoutExtension(path).EndsWith(".raw", StringComparison.OrdinalIgnoreCase)) { settings.Format = D3DFormat.A8R8G8B8; path = path.Replace(".raw", ""); } else if (Path.GetFileNameWithoutExtension(path).EndsWith(".dxt1", StringComparison.OrdinalIgnoreCase)) { settings.Format = D3DFormat.DXT1; path = path.Replace(".dxt1", ""); } else if (Path.GetFileNameWithoutExtension(path).EndsWith(".dxt5", StringComparison.OrdinalIgnoreCase)) { settings.Format = D3DFormat.DXT5; path = path.Replace(".dxt5", ""); } bmap.Path = Path.GetFileName(path); if (settings.Clutter) { Console.WriteLine("Cluttering: {0}x{1}", texture.Bitmap.Width, texture.Bitmap.Height); bmap.Mode = 1; bmap.Raw = texture.Bitmap; } else { if (settings.Format == D3DFormat.A8R8G8B8) { Console.WriteLine("Formatting: {0}x{1} (this might take awhile)", texture.Bitmap.Width, texture.Bitmap.Height); } else { Console.WriteLine("Squishing : {0}x{1} (this might take awhile)", texture.Bitmap.Width, texture.Bitmap.Height); } bmap.DDS = new DDS(settings.Format, texture.Bitmap); } Console.WriteLine("Saving : {0}", Path.GetFileName(path.Replace(string.Format(".{0}", extension), ".bmap"))); bmap.Save(path.Replace(string.Format(".{0}", extension), ".x.bmap"), true); settings = original.Clone(); return(path); } return(null); }
public Order(Account account, Security security, TransactionType transactionType, TIF tif, PricedAt pricedAt, decimal quantity, decimal limitPrice, decimal stopLimitPrice) { Initialize(account, security, transactionType, tif, pricedAt, quantity, limitPrice, stopLimitPrice); }
public Order(Account account, Security security, TransactionType transactionType, TIF tif, decimal quantity) { Initialize(account, security, transactionType, tif, PricedAt.Market, quantity, 0.0M, 0.0M); }
public void Initialize(Account account, Security security, TransactionType transactionType, TIF tif, PricedAt pricedAt, decimal quantity, object price1, object price2) { // Create a block order on the server. RemoteBatch remoteBatch = new RemoteBatch(); RemoteAssembly remoteAssembly = remoteBatch.Assemblies.Add("Service.Trading"); RemoteType remoteType = remoteAssembly.Types.Add("Shadows.WebService.Trading.Order"); RemoteMethod remoteMethod = remoteType.Methods.Add("Insert"); remoteMethod.Parameters.Add("orderId", DataType.Int, Direction.ReturnValue); remoteMethod.Parameters.Add("accountId", account.AccountId); remoteMethod.Parameters.Add("securityId", security.SecurityId); remoteMethod.Parameters.Add("settlementId", security.SettlementId); remoteMethod.Parameters.Add("transactionTypeCode", (int)transactionType); remoteMethod.Parameters.Add("timeInForceCode", (int)tif); remoteMethod.Parameters.Add("orderTypeCode", (int)pricedAt); remoteMethod.Parameters.Add("quantity", quantity); remoteMethod.Parameters.Add("price1", price1 == null ? (object)DBNull.Value : price1); remoteMethod.Parameters.Add("price2", price2 == null ? (object)DBNull.Value : price2); ClientMarketData.Execute(remoteBatch); // Now that the block order is created, construct the in-memory version of the record. int orderId = (int)remoteMethod.Parameters["orderId"].Value; try { // Lock the tables. Debug.Assert(!ClientMarketData.AreLocksHeld); ClientMarketData.AccountLock.AcquireReaderLock(CommonTimeout.LockWait); ClientMarketData.OrderLock.AcquireReaderLock(CommonTimeout.LockWait); ClientMarketData.ObjectLock.AcquireReaderLock(CommonTimeout.LockWait); ClientMarketData.SecurityLock.AcquireReaderLock(CommonTimeout.LockWait); ClientMarketData.OrderRow orderRow = ClientMarketData.Order.FindByOrderId(orderId); if (orderRow == null) { throw new Exception(String.Format("Order {0} doesn't exist", orderId)); } Initialize(orderRow); } finally { // Release the table locks. if (ClientMarketData.AccountLock.IsReaderLockHeld) { ClientMarketData.AccountLock.ReleaseReaderLock(); } if (ClientMarketData.OrderLock.IsReaderLockHeld) { ClientMarketData.OrderLock.ReleaseReaderLock(); } if (ClientMarketData.ObjectLock.IsReaderLockHeld) { ClientMarketData.ObjectLock.ReleaseReaderLock(); } if (ClientMarketData.SecurityLock.IsReaderLockHeld) { ClientMarketData.SecurityLock.ReleaseReaderLock(); } Debug.Assert(!ClientMarketData.AreLocksHeld); } }