Example #1
0
        public CodeSection Handle(PeHeader PeHeader, PeSectionHeader Header, System.IO.BinaryReader Reader)
        {
            var imps = new ImportSection();


            return(imps);
        }
Example #2
0
        public ActionResult GetLoadPurchasePriceToQuote(string orderNumbers, string date1, string lineNumbers, string amount4s)
        {
            List <ImportColumn> listOfColumns = new List <ImportColumn>();

            var orderNumberColumn = new ImportColumn("OrderNumber", orderNumbers);

            listOfColumns.Add(new ImportColumn("OrderNumber", orderNumberColumn[0]));
            listOfColumns.Add(new ImportColumn("OrderType", "Комм. предложение"));
            listOfColumns.Add(new ImportColumn("Date1", date1));

            var importSection = new ImportSection("ORDERHEADER", ImportMode.Change, listOfColumns);

            List <ImportColumn> secondListOfColumns = new List <ImportColumn>();

            secondListOfColumns.Add(orderNumberColumn);
            secondListOfColumns.Add(new ImportColumn("OrderType", "Комм. предложение"));
            secondListOfColumns.Add(new ImportColumn("LineNumber", lineNumbers));
            secondListOfColumns.Add(new ImportColumn("Amount4", amount4s));

            var secondImportSection = new ImportSection("ORDERLINE", ImportMode.Change, listOfColumns);

            var worker = new ImportWorker("LoadPricesToIPO");

            worker.DoWork(ImportWorker.CreateDataSet(new ImportSection[] { importSection, secondImportSection }));
            return(DownloadTxt(worker.GetResult(), "test"));
        }
Example #3
0
        //TODO Не реализовано. Жду реализации функции от коллег
        public ActionResult GetUpdateDeliveryDates(string vendorNumbers, string dates, string numberPOs, string numberIPOs, Inventory inventory)
        {
            // Пилим список столбцов файла импорта
            List <ImportColumn> listOfColumns = new List <ImportColumn>();

            // Класс колонки сам распарсит строку
            // Если в строке всего один ряд, он возмет строку как значение по умолчанию
            var IPOColumn = new ImportColumn("ItemPurchaseOrderNumber", vendorNumbers);

            listOfColumns.Add(IPOColumn);
            var LinesColumn = new ImportColumn("LineNumber", "1");

            listOfColumns.Add(LinesColumn);
            var ItemsColumn = new ImportColumn("ItemNumber", "itemnumber");

            listOfColumns.Add(ItemsColumn);
            var Date2Column = new ImportColumn("Date2", dates);

            listOfColumns.Add(Date2Column);

            // Подгружаем из базы необходимые данные

            listOfColumns.Add(new ImportColumn("ExpectedCommitmentDate", numberPOs));
            listOfColumns.Add(new ImportColumn("Date1", numberIPOs));
            listOfColumns.Add(new ImportColumn("Date4", numberIPOs));
            // Создаем секцию файла импорта, передав ему название таблицы, режим и список столбцов и их значений
            var importSection = new ImportSection("ITEMPURCHASELINE", ImportMode.CreateChange, listOfColumns);
            // Создаем класс-создатель файла импорта
            var importWorker = new ImportWorker("GetUpdateDeliveryDates");

            // Передаем ему секцию и заставляем работать.
            importWorker.DoWork(importSection);
            return(DownloadTxt(importWorker.GetResult(), "test"));
        }
Example #4
0
        /// <summary>
        /// Перегрузка DoWork, позволяющая вместо набора секций использовать лишь одну без лишнего геморроя
        /// </summary>
        public void DoWork(ImportSection section)
        {
            List <ImportSection> sections = new List <ImportSection> {
                section
            };
            var ds = CreateDataSet(sections);

            DoWork(ds);
        }
Example #5
0
 public Configuration()
 {
     BindingSection(out _font, v => _font = v);
     BindingSection(out _analogControl, v => _analogControl = v);
     BindingSection(out _graphics, v => _graphics           = v);
     BindingSection(out _cheats, v => _cheats           = v);
     BindingSection(out _import, v => _import           = v);
     BindingSection(out _export, v => _export           = v);
     BindingSection(out _tetraMaster, v => _tetraMaster = v);
     BindingSection(out _fixes, v => _fixes             = v);
     BindingSection(out _hacks, v => _hacks             = v);
     BindingSection(out _battle, v => _battle           = v);
     BindingSection(out _icons, v => _icons             = v);
     BindingSection(out _debug, v => _debug             = v);
 }
Example #6
0
        public ActionResult GetImportFileForLoadPrice(string numberIPOs, string lineNumbers, string itemNumbers, string newPrices)
        {
            List <ImportColumn> listOfColumns = new List <ImportColumn>();

            listOfColumns.Add(new ImportColumn("ItemPurchaseOrderNumber", numberIPOs));
            listOfColumns.Add(new ImportColumn("LineNumber", lineNumbers));
            listOfColumns.Add(new ImportColumn("ItemNumber", itemNumbers));
            listOfColumns.Add(new ImportColumn("UnitPriceCurrency", newPrices));

            var importSection = new ImportSection("ITEMPURCHASELINE", ImportMode.Change, listOfColumns);

            var worker = new ImportWorker("LoadPricesToIPO");

            worker.DoWork(importSection);
            return(DownloadTxt(worker.GetResult(), "test"));
        }
Example #7
0
        private void buttonImport_Click(object sender, EventArgs e)
        {
            HSSFWorkbook    sourceWorkbook = null;
            IReportImporter importer;
            StringBuilder   sql = new StringBuilder();

            try
            {
                textBoxSQL.Text = string.Empty;
                Cursor          = Cursors.WaitCursor;

                if (string.IsNullOrEmpty(textBoxFile.Text.Trim()))
                {
                    throw new Exception("請選擇檔案名稱與路徑!");
                }

                importConfiguration = ConfigurationManager.GetSection(ImportSection.SECTION_NAME) as ImportSection;

                using (FileStream fileStream = new FileStream(textBoxFile.Text.Trim(), FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    sourceWorkbook = new HSSFWorkbook(fileStream);
                    fileStream.Close();
                }

                importer = new BaseImporter();

                for (int sheetIndex = 0; sheetIndex < sourceWorkbook.NumberOfSheets; sheetIndex++)
                {
                    HSSFSheet sourceSheet = sourceWorkbook.GetSheetAt(sheetIndex) as HSSFSheet;
                    foreach (HallElement hall in importConfiguration.Halls)
                    {
                        importer.Import(importConfiguration, dateTimePickerDate.Value.AddDays(sheetIndex * 7), hall.Name, sourceSheet, ref sql);
                        Application.DoEvents();
                    }
                }

                textBoxSQL.Text = sql.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }
Example #8
0
        /// <summary>
        /// Reads the non-custom section with the given header.
        /// </summary>
        /// <param name="Header">The section header.</param>
        /// <returns>The parsed section.</returns>
        protected Section ReadKnownSectionPayload(SectionHeader Header)
        {
            switch (Header.Name.Code)
            {
            case SectionCode.Type:
                return(TypeSection.ReadSectionPayload(Header, this));

            case SectionCode.Import:
                return(ImportSection.ReadSectionPayload(Header, this));

            case SectionCode.Function:
                return(FunctionSection.ReadSectionPayload(Header, this));

            case SectionCode.Table:
                return(TableSection.ReadSectionPayload(Header, this));

            case SectionCode.Memory:
                return(MemorySection.ReadSectionPayload(Header, this));

            case SectionCode.Global:
                return(GlobalSection.ReadSectionPayload(Header, this));

            case SectionCode.Export:
                return(ExportSection.ReadSectionPayload(Header, this));

            case SectionCode.Start:
                return(StartSection.ReadSectionPayload(Header, this));

            case SectionCode.Element:
                return(ElementSection.ReadSectionPayload(Header, this));

            case SectionCode.Code:
                return(CodeSection.ReadSectionPayload(Header, this));

            case SectionCode.Data:
                return(DataSection.ReadSectionPayload(Header, this));

            default:
                return(ReadUnknownSectionPayload(Header));
            }
        }
Example #9
0
        public void Import(ImportSection importSection, DateTime meetingDate, string hallName, HSSFSheet sourceSheet, ref StringBuilder sql)
        {
            HallElement hall                 = importSection.Halls[hallName];
            string      leftHeaderString     = string.Empty;
            string      leftSubHeaderString  = string.Empty;
            string      left2SubHeaderString = string.Empty;
            string      topHeaderString      = string.Empty;
            string      topSubHeaderString   = string.Empty;
            string      top2SubHeaderString  = string.Empty;

            using (DataTable lifeNumberTable = InitializeTable(importSection.Cols))
            {
                for (int dataRowIndex = hall.SourceLeftHeaderRow; ; dataRowIndex++)
                {
                    HSSFRow sourceTopHeaderRow     = sourceSheet.GetRow(hall.SourceTopHeaderRow) as HSSFRow;
                    HSSFRow sourceTopSubHeaderRow  = sourceSheet.GetRow(hall.SourceTopSubHeaderRow) as HSSFRow;
                    HSSFRow sourceTop2SubHeaderRow = sourceSheet.GetRow(hall.SourceTopSubHeaderRow + 1) as HSSFRow;
                    HSSFRow sourceDataRow          = sourceSheet.GetRow(dataRowIndex) as HSSFRow;
                    string  key = string.Empty;
                    if (!string.IsNullOrEmpty(sourceDataRow.GetCell(hall.SourceLeftHeaderCol).StringCellValue))
                    {
                        leftHeaderString = sourceDataRow.GetCell(hall.SourceLeftHeaderCol).StringCellValue;
                    }

                    if (leftHeaderString == "總計")
                    {
                        break;
                    }

                    if (leftHeaderString == "合計")
                    {
                        continue;
                    }

                    switch (sourceDataRow.GetCell(hall.SourceLeftSubHeaderCol).CellType)
                    {
                    case CellType.String:
                        leftSubHeaderString = sourceDataRow.GetCell(hall.SourceLeftSubHeaderCol).StringCellValue;
                        break;

                    case CellType.Numeric:
                        leftSubHeaderString = Convert.ToString(sourceDataRow.GetCell(hall.SourceLeftSubHeaderCol).NumericCellValue);
                        break;
                    }

                    switch (sourceDataRow.GetCell(hall.SourceLeftSubHeaderCol + 1).CellType)
                    {
                    case CellType.String:
                        left2SubHeaderString = sourceDataRow.GetCell(hall.SourceLeftSubHeaderCol + 1).StringCellValue;
                        break;

                    case CellType.Numeric:
                        left2SubHeaderString = Convert.ToString(sourceDataRow.GetCell(hall.SourceLeftSubHeaderCol + 1).NumericCellValue);
                        break;
                    }

                    //if (left2SubHeaderString == "區小計")
                    //{
                    key = string.Format("{0}{1}{2}", leftHeaderString, importSection.Seperator, leftSubHeaderString);
                    //}
                    //else
                    //{
                    //    key = string.Format("{0}{1}{2}{1}{3}", leftHeaderString, importSection.Seperator, leftSubHeaderString, left2SubHeaderString);
                    //}

                    DataRow dataRow = lifeNumberTable.NewRow();
                    dataRow["MeetingDate"] = meetingDate;
                    dataRow["TableID"]     = FindTableID(hall, key);
                    dataRow["BaseNum"]     = sourceDataRow.GetCell(hall.SourceLeftSubHeaderCol + 2).NumericCellValue;
                    dataRow["TargetNum"]   = sourceDataRow.GetCell(hall.SourceLeftSubHeaderCol + 3).NumericCellValue;

                    for (int dataColIndex = hall.SourceTopHeaderCol; dataColIndex < sourceTopHeaderRow.LastCellNum; dataColIndex++)
                    {
                        string value;

                        if (!string.IsNullOrEmpty(sourceTopHeaderRow.GetCell(dataColIndex).StringCellValue))
                        {
                            topHeaderString     = sourceTopHeaderRow.GetCell(dataColIndex).StringCellValue;
                            topSubHeaderString  = string.Empty;
                            top2SubHeaderString = string.Empty;
                        }

                        if (!string.IsNullOrEmpty(sourceTopSubHeaderRow.GetCell(dataColIndex).StringCellValue))
                        {
                            topSubHeaderString = sourceTopSubHeaderRow.GetCell(dataColIndex).StringCellValue;
                        }

                        if (!string.IsNullOrEmpty(sourceTop2SubHeaderRow.GetCell(dataColIndex).StringCellValue))
                        {
                            top2SubHeaderString = sourceTop2SubHeaderRow.GetCell(dataColIndex).StringCellValue;
                            value = FindField(importSection.Cols, string.IsNullOrEmpty(top2SubHeaderString) ? topHeaderString : string.Format("{0}{1}{2}{1}{3}", topHeaderString, importSection.Seperator, topSubHeaderString, top2SubHeaderString));
                        }
                        else
                        {
                            value = FindField(importSection.Cols, string.IsNullOrEmpty(topSubHeaderString) ? topHeaderString : string.Format("{0}{1}{2}", topHeaderString, importSection.Seperator, topSubHeaderString));
                        }


                        if (!string.IsNullOrEmpty(value))
                        {
                            dataRow[value] = sourceDataRow.GetCell(dataColIndex).NumericCellValue;
                        }
                    }

                    WriteTo(lifeNumberTable, dataRow, ref sql);
                }
            }
        }
        public CodeSection Handle(PeHeader PeHeader, PeSectionHeader Header, System.IO.BinaryReader Reader)
        {
            var imps = new ImportSection();

            return imps;
        }
        // strict parse means all sections must come in order
        public void ParseAsWASM(string filename, bool strict_parse = true)
        {
            if (!BitConverter.IsLittleEndian)
            {
                throw new NotImplementedException("LEB128 implementation only handles little endian systems");
            }

            using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read))
            {
                BinaryReader reader = new BinaryReader(fs);
                uint         magic  = reader.ReadUInt32();
                if (magic != MAGIC)
                {
                    throw new Exception("Not a compiled Web Assembly file.");
                }

                uint version = reader.ReadUInt32();
                if (version > SUPPORTED_VERSION)
                {
                    throw new Exception($"Unsupported version. Expected version <= {SUPPORTED_VERSION}, received {version}.");
                }

                int last_parsed_module = int.MinValue;

                /* Read in each module */

                while (true)
                {
                    int id = reader.PeekChar();

                    // EOF
                    if (id == -1)
                    {
                        break;
                    }

                    if (strict_parse && id < last_parsed_module)
                    {
                        throw new Exception("File contains out of order sections.");
                    }
                    last_parsed_module = id;

                    switch (id)
                    {
                    case (int)WebAssemblyModuleID.Custom:
                        if (strict_parse && custom != null)
                        {
                            throw new Exception("File contains a duplicate custom section.");
                        }
                        custom = new CustomSection(reader);
                        break;

                    case (int)WebAssemblyModuleID.Type:
                        if (strict_parse && type != null)
                        {
                            throw new Exception("File contains a duplicate type section.");
                        }
                        type = new TypeSection(reader);
                        break;

                    case (int)WebAssemblyModuleID.Import:
                        if (strict_parse && import != null)
                        {
                            throw new Exception("File contains a duplicate import section.");
                        }
                        import = new ImportSection(reader);
                        break;

                    case (int)WebAssemblyModuleID.Function:
                        if (strict_parse && function != null)
                        {
                            throw new Exception("File contains a duplicate function section.");
                        }
                        function = new FunctionSection(reader);
                        break;

                    case (int)WebAssemblyModuleID.Table:
                        if (strict_parse && table != null)
                        {
                            throw new Exception("File contains a duplicate table section.");
                        }
                        table = new TableSection(reader);
                        break;

                    case (int)WebAssemblyModuleID.Memory:
                        if (strict_parse && memory != null)
                        {
                            throw new Exception("File contains a duplicate memory section.");
                        }
                        memory = new MemorySection(reader);
                        break;

                    case (int)WebAssemblyModuleID.Global:
                        if (strict_parse && global != null)
                        {
                            throw new Exception("File contains a duplicate global section.");
                        }
                        global = new GlobalSection(reader);
                        break;

                    case (int)WebAssemblyModuleID.Export:
                        if (strict_parse && export != null)
                        {
                            throw new Exception("File contains a duplicate export section.");
                        }
                        export = new ExportSection(reader);
                        break;

                    case (int)WebAssemblyModuleID.Start:
                        if (strict_parse && start != null)
                        {
                            throw new Exception("File contains a duplicate start section.");
                        }
                        start = new StartSection(reader);
                        break;

                    case (int)WebAssemblyModuleID.Element:
                        if (strict_parse && element != null)
                        {
                            throw new Exception("File contains a duplicate element section.");
                        }
                        element = new ElementSection(reader);
                        break;

                    case (int)WebAssemblyModuleID.Code:
                        if (strict_parse && code != null)
                        {
                            throw new Exception("File contains a duplicate code section.");
                        }
                        code = new CodeSection(reader);
                        break;

                    case (int)WebAssemblyModuleID.Data:
                        if (strict_parse && data != null)
                        {
                            throw new Exception("File contains a duplicate data section.");
                        }
                        data = new DataSection(reader);
                        break;

                    // Error
                    default:
                        throw new Exception($"Unknown section {id}.");
                    }
                }

                /* Additional validation */

                // The lengths of vectors produced by the (possibly empty) function and code section must match up.
                if ((function != null && code == null) || (function == null && code != null))
                {
                    throw new Exception("File corrupt. Must include both function and code sections.");
                }
                if (function.types.Length != code.bodies.Length)
                {
                    throw new Exception("File corrupt. Function and code sections do not match up.");
                }

                // TODO: I don't actually check if data overlaps

                // TODO: Validate everything in this list
                // https://webassembly.github.io/spec/core/valid/modules.html
            }
        }