Exemplo n.º 1
0
        private bool Parse(string path)
        {
            CompoundDocument doc = CompoundDocument.Load(path);
            if (doc == null)
                throw new InvalidOperationException(Constants.Messages.Error_ExcelFileNotFound);

            Lines.Clear();
            byte[] bookdata = doc.GetStreamData("Workbook");
            if (bookdata == null)
                throw new InvalidOperationException(Constants.Messages.Error_ExcelFileNoWorkbook);

            Workbook workbook = WorkbookDecoder.Decode(new MemoryStream(bookdata));
            if (workbook.Worksheets.Count == 0)
                throw new InvalidOperationException(Constants.Messages.Error_ExcelFileNoWorksheet);

            Worksheet sheet = workbook.Worksheets[0];
            for (int rowIndex = sheet.Cells.FirstRowIndex; rowIndex <= sheet.Cells.LastRowIndex; rowIndex++)
            {
                SourceLine line = new SourceLine();
                Row row = sheet.Cells.GetRow(rowIndex);
                for (int colIndex = row.FirstColIndex; colIndex <= row.LastColIndex; colIndex++)
                {
                    Cell cell = row.GetCell(colIndex);
                    line.Columns.Add(cell.StringValue);
                }
                Lines.Add(line);
            }

            doc.Close();

            return true;
        }
Exemplo n.º 2
0
        protected override void ProcessData()
        {
            base.ProcessData();

            this.Name = "s1.xls";
            string duongdan = Parser.pathworkingdir + Constants.Directory.ScriptDir;

            string path = duongdan + Name;
            this.PathFile = path;

            //--------minh diem cai interface co bao nhieu cot

            SourceLine _SourlineScript = new SourceLine();
            Parser.getopen(path);
            int cot = Parser.ColumnCount;
            Parser.pathlines = path;
            int dong = Parser.CountRow(path);

            //----------------------------------------------------

            ActionLines = new List<ActionLine>();
            for (int j = 1; j <= dong; j++)
            {
                if (_SourlineScript.CountColmsv(path) > 0)
                {
                    ActionLine actLine = new ActionLine();
                    actLine.ActionName = Parser.ValueCell(path, j - 1, 0).ToLower();

                    for (int i = 1; i < cot; i++)
                    {

                        string[] pairs = Parser.ValueCell(path, j - 1, i).Split(Constants.PropertyDelimeter.ToCharArray(), 2);
                        if (pairs.Length != 2)
                        {
                            continue;
                        }
                        if (Constants.KeywordWindow.Equals(pairs[0], StringComparison.CurrentCultureIgnoreCase))
                            actLine.WindowName = pairs[1].ToLower();
                        else if (Constants.KeywordControl.Equals(pairs[0], StringComparison.CurrentCultureIgnoreCase))
                            actLine.ControlName = pairs[1].ToLower();
                        else
                            actLine.Arguments[pairs[0].ToLower()] = pairs[1];

                    }

                    ActionLines.Add(actLine);
                }
            }
        }
Exemplo n.º 3
0
        // minh phai dc duoc script len coi su dung interface nao roi moi fare len
        protected override void ProcessData()
        {
            base.ProcessData();
            // Lay Dc Windown - Control
            // minh phải cho no den cua interface de doc
            this.Name = "calculator";
            string duongdan = Parser.pathworkingdir + Constants.Directory.InterfaceDir;

            string path = duongdan + Name + Parser.FileExtension;
            this.PathFile = path;
            Name.ToLower();
            //--------minh diem cai interface co bao nhieu cot

            SourceLine _Sourline = new SourceLine();
            Parser.getopen(path);
            int cot = Parser.ColumnCount;
            //int cot = _Sourline.CountColmsv(path);
            Parser.pathlines = path;
            int dong = Parser.CountRow(path);

            Controls = new Dictionary<string, Dictionary<string, string>>();
            Properties = new Dictionary<string, string>();
            for (int j = 1; j <= dong; j++)
            {

                if (_Sourline.CountColmsv(path) > 0)
                {
                    string window = Parser.ValueCell(path, j - 1, 0);
                    string control = Parser.ValueCell(path, j - 1, 0);
                    if (Constants.KeywordWindow == window)
                    {
                        this.NameWindow = Parser.ValueCell(path, j - 1, 1).ToLower();
                        for (int i = 2; i < _Sourline.CountColmsv(path); i++)
                        {
                            string[] pairs = Parser.ValueCell(path, j - 1, i).Split(Constants.PropertyDelimeter.ToCharArray(), 2);

                            if (pairs.Length != 2)
                                throw new FormatException(Constants.Messages.Error_Parsing_Interface_InvalidWindow);

                            Properties[pairs[0].ToLower()] = pairs[1];

                        }
                    }

                    else if (Constants.KeywordControl == control)
                    {
                        string controlName = Parser.ValueCell(path, j - 1, 1).ToLower();
                        for (int i = 2; i < _Sourline.CountColmsv(path); i++)
                        {
                            string[] pairs = Parser.ValueCell(path, j - 1, i).Split(Constants.PropertyDelimeter.ToCharArray(), 2);
                            if (pairs.Length != 2)
                                throw new FormatException(Constants.Messages.Error_Parsing_Interface_InvalidControl);

                            Controls.Add(controlName, new Dictionary<string, string>());
                            Controls[controlName][pairs[0].ToLower()] = pairs[1];

                        }
                    }
                }
            }
        }