Ejemplo n.º 1
0
        public void InStreamDataTest()
        {
            excelDoc = new ExcelDoc();

            excelDoc.Open();
            excelDoc.InStreamData();
            excelDoc.Close();

            StringBuilder sb = new StringBuilder();

            foreach (KeyValuePair <string, ExcelPartNumber> kvp in excelDoc.partNumList)
            {
                sb.AppendLine(kvp.Key + " " + kvp.Value.restockSODate + " " + kvp.Value.bracketsPerSheet);
            }

            System.IO.File.WriteAllText(@"\\msw-fp1\user$\wchan\Documents\InventoryManagementAppTest\Part Numbers.txt", sb.ToString());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Opens the specified filepath for reading
        /// </summary>
        /// <returns></returns>
        public void OpenExcelReader()
        {
            if (ExcelDoc != null)
            {
                ExcelDoc.Close();
                ExcelDoc.Dispose();
            }

            if (ExcelStream != null)
            {
                ExcelStream.Close();
                ExcelStream.Dispose();
            }

            ExcelStream = System.IO.File.Open(ExcelFilePath, FileMode.Open, FileAccess.Read);

            ExcelDoc = DocumentFormat.OpenXml.Packaging.SpreadsheetDocument.Open(ExcelStream, false);
        }
Ejemplo n.º 3
0
        public void PolyMinMaxTest()
        {
            QuickBooksDataTable itemTable = new ItemDataTable();
            QuickBooksDataTable soTable   = new SODataTable();

            itemTable.BuildTable();
            soTable.BuildTable();

            using (excelDoc = new ExcelDoc())
            {
                excelDoc.Open();
                excelDoc.InStreamData();
                excelDoc.Close();

                DataTable minMaxDt = new DataTable().BuildTable(soTable, itemTable, excelDoc.partNumList);

                minMaxDt.Write(@"\\msw-fp1\user$\wchan\Documents\Visual Studio 2015\Projects\InventoryManagementApp\InventoryManagementApp\bin\Debug\Test\PolyMinMax.csv");
            }
        }
Ejemplo n.º 4
0
        public void ProcessRaceReport(RaceReport raceReport)
        {
            var currentReportsRace = _raceService.GetRace(raceReport.Race.Id.Value);

            _context.Races.Attach(currentReportsRace);
            raceReport.Race = currentReportsRace;

            CheckForPersonalBests(raceReport);
            ProcessIndividualResults(raceReport);

            var datestring = currentReportsRace.Date.ToShortDateString();

            var path = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/content/excelfiles/"),
                                    currentReportsRace.RaceName + datestring.Replace('/', '-') + ".xlsx");

            ExcelDoc ex = new ExcelDoc();

            ex.CreateNewFile();

            WriteNameColumn(ex, raceReport);
            WriteTimeColumn(ex, raceReport);
            WritePlaceColumn(ex, raceReport);

            ex.SaveAs(path);
            ex.Close();

            FileStream       fs     = new FileStream(path, FileMode.Open, FileAccess.Read);
            BinaryReader     reader = new BinaryReader(fs);
            RaceReportBinary binary = new RaceReportBinary
            {
                RaceId = raceReport.Race.Id,

                Data     = reader.ReadBytes((Int32)fs.Length),
                FileName = currentReportsRace.RaceName + datestring.Replace('/', '-') + ".xlsx"
            };

            var reportindb = _context.RaceReports.SingleOrDefault(r => r.FileName == binary.FileName);

            if (reportindb == null)
            {
                _context.RaceReports.Add(binary);
            }
            else
            {
                reportindb.FileName = binary.FileName;
                reportindb.Data     = binary.Data;
            }

            try
            {
                _context.SaveChanges();
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    System.Diagnostics.Debug.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                                       eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        System.Diagnostics.Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                                           ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }

            fs.Close();
            reader.Close();

            System.IO.File.Delete(path);
        }
 /// <summary>
 /// Closes the Excel Document
 /// </summary>
 public void Close()
 {
     excelDoc.Close();
 }