public async Task <IHttpActionResult> DB(string fileName)
        {
            Log.Info("Request for {0}", Request.RequestUri);
            db = new Entities();
            using (var transaction = db.Database.BeginTransaction())
                using (db)
                {
                    db.Configuration.AutoDetectChangesEnabled = false;
                    try
                    {
                        await Task.Run(() =>
                        {
                            StructHelper structHelper = new StructHelper(fileName);
                            structHelper.Open(FileAccess.Read, FileShare.None);

                            var header = (Header)structHelper.GetNextStructureValue(typeof(Header));

                            int count = 0;
                            object record;
                            while ((record = structHelper.GetNextStructureValue(typeof(StructModels.TradeRecord))) != null)
                            {
                                var rec    = (StructModels.TradeRecord)record;
                                var recObj = new TradeRecord
                                {
                                    Id       = rec.id,
                                    FileName = fileName,
                                    Account  = rec.account,
                                    Volume   = rec.volume,
                                    Comment  = rec.comment,
                                    Version  = header.version,
                                    Type     = header.type
                                };

                                ++count;
                                db = AddToContext(db, recObj, count, numberOfBulkSave, true);
                            }

                            //Thread.Sleep(3000);
                        }).ConfigureAwait(false);

                        db.SaveChanges();
                        transaction.Commit();
                    }
                    catch (FileNotFoundException ex)
                    {
                        transaction.Rollback();
                        Log.Warn("Exception message {0}. Stack Trace: {1}", ex.Message, ex.StackTrace);
                        return(BadRequest(ex.Message));
                    }
                    catch (DbUpdateException ex)
                    {
                        transaction.Rollback();
                        Log.Error("Exception message {0}. Stack Trace: {1}", ex.Message, ex.StackTrace);
                        return(InternalServerError(ex));
                    }
                }
            return(Ok());
        }
        public static void ExecuteProcessCSV(string fileName, string csvFileName)
        {
            StructHelper structHelper = new StructHelper(fileName);

            structHelper.Open(FileAccess.Read, FileShare.None);

            using (StreamWriter output = new StreamWriter(csvFileName))
            {
                var header = structHelper.GetNextStructureValue(typeof(Header));
                if (header is Header)
                {
                    var head = (Header)header;
                    output.WriteLine(string.Format("{0},{1}", head.version, head.type));
                }

                object record;
                while ((record = structHelper.GetNextStructureValue(typeof(StructModels.TradeRecord))) != null)
                {
                    var rec = (StructModels.TradeRecord)record;
                    output.WriteLine(string.Format("{0},{1},{2},{3}", rec.id, rec.account, rec.volume, rec.comment));
                }
            }
        }