예제 #1
0
파일: ParseHelper.cs 프로젝트: Zowal/Oasis
        private static void ParseCellValue(EmailModels email, EmailDataParsingRulesModels dataParsingRule, int row, bool CopyRuleFromPreviousOrder)
        {
            // AddLog("ParseCellValue");
            var path = SpreadsheetHelper.GetSpreadsheetPathById((long)dataParsingRule.TableId_Id);

            if (path != null)
            {
                var name = dataParsingRule.TableId_Id.ToString();

                SpreadsheetExtension.LoadDocument(name, path);
                IWorkbook workbook = SpreadsheetExtension.GetCurrentDocument(name);

                Worksheet worksheet = workbook.Worksheets[dataParsingRule.Worksheet];

                var value = BeforeParseValueFromEmail(email, dataParsingRule);
                if (value != null)
                {
                    if (dataParsingRule.IsUpdatingRule)
                    {
                        if (CopyRuleFromPreviousOrder)
                        {
                            worksheet.Cells[row, dataParsingRule.ColumnForUpdate].CopyFrom(worksheet.Cells[row + 1, dataParsingRule.ColumnForUpdate], PasteSpecial.Formats);
                        }
                        worksheet.Cells[row, dataParsingRule.ColumnForUpdate].Value = value.Replace("\n", " ");
                    }
                    else
                    {
                        if (CopyRuleFromPreviousOrder)
                        {
                            worksheet.Cells[row, dataParsingRule.Column].CopyFrom(worksheet.Cells[row + 1, dataParsingRule.Column], PasteSpecial.Formats);
                        }
                        worksheet.Cells[row, dataParsingRule.Column].Value = value.Replace("\n", " ");
                    }
                }
                workbook.SaveDocument(path);
                SpreadsheetExtension.CloseDocument(name);

                Repository<ParsedCells> parsedCellsRepository = new Repository<ParsedCells>();

                var cell = new ParsedCells
                {
                    Column = dataParsingRule.Column,
                    Content = value,
                    EmailId_Id = email.Id,
                    TableId_Id = dataParsingRule.TableId_Id,
                    Worksheet = dataParsingRule.Worksheet,
                    WorksheetName = worksheet.Name
                };

                parsedCellsRepository.Add(cell);
                parsedCellsRepository.Commit();
            }
        }
예제 #2
0
        //
        //   По аналогии с TreeList, Spreadsheet также должен находиться
        //   на в частичном представлении, которое включается в это представление.
        //
        public ActionResult ExampleTablesAfterParsing(long emailId)
        {
            List<Model.ParsedCells> workSheetCellsList = new List<Model.ParsedCells>();
            List<List<Model.ParsedCells>> tableCellsList = new List<List<Model.ParsedCells>>();
            List<List<List<Model.ParsedCells>>> cellsList = new List<List<List<Model.ParsedCells>>>();
            Model.ParsedCells cellsWSC = new Model.ParsedCells();

            if (emailId != 0)
            {
                var userId = UserHelper.GetUserByEmail(User.Identity.Name).Id;

                if (IsUsersEmail(userId, emailId))
                {
                    var cells = parsedCellsRepository.FindAll(w => w.EmailId_Id == emailId);
                    var distCellsByTable = cells.GroupBy(a => a.TableId_Id).Select(g => g.First()).OrderBy(i => i.TableId_Id).ToList();
                    foreach (var table in distCellsByTable)
                    {
                        var distCellsByWorkcheet = cells.Where(t => t.TableId_Id == table.TableId_Id)
                             .GroupBy(a => a.Worksheet).Select(g => g.First()).OrderBy(i => i.Worksheet).ToList();
                        foreach (var cell in distCellsByWorkcheet)
                        {
                            tableCellsList = new List<List<Model.ParsedCells>>();
                            workSheetCellsList = new List<Model.ParsedCells>();
                            var Cells = cells.Where(c => c.TableId_Id == table.TableId_Id && c.Worksheet == cell.Worksheet).OrderBy(i => i.Column).ToList();

                            foreach (var c in Cells)
                            {
                                c.ColumnName = GetColumnName(c.Column);
                                workSheetCellsList.Add(c);
                            }
                            tableCellsList.Add(workSheetCellsList);
                            cellsList.Add(tableCellsList);
                        }
                    }
                }
            }
            if (cellsList.Count() != 0)
                return View(cellsList);
            else
                return View("ExampleTablesAfterParsingNoData");
        }
예제 #3
0
 partial void DeleteParsedCells(ParsedCells instance);
예제 #4
0
		private void detach_ParsedCells(ParsedCells entity)
		{
			this.SendPropertyChanging();
			entity.TableModels = null;
		}
예제 #5
0
 partial void UpdateParsedCells(ParsedCells instance);
예제 #6
0
 partial void InsertParsedCells(ParsedCells instance);
예제 #7
0
		private void attach_ParsedCells(ParsedCells entity)
		{
			this.SendPropertyChanging();
			entity.EmailModels = this;
		}