示例#1
0
        public ActionResult AddNewDataRuleForEmails(AddNewRuleForDataModel model)
        {
            var userId = UserHelper.GetUserByEmail(User.Identity.Name).Id;

            if (ModelState.IsValid && IsUsersEmailParsingRule(userId, model.RuleId))
            {
                    var table =
                    tablesRepository.Find(w => w.Name.Equals(model.Cell.TableId) && w.AdministratorId_Id.Equals(userId));

                var emailDataParsingRule = new Model.EmailDataParsingRulesModels()
                {
                    Expression = HttpUtility.HtmlEncode(model.Expression),
                    IsRegexpExpression = model.IsRegexpExpression.Equals("C"),
                    DataExploration = (int)Enum.Parse(typeof(DataExplorationEnums), model.DataExploration),
                    DataExplorationExpression = HttpUtility.HtmlEncode(model.DataExplorationExpression),
                    IsChanging = model.IsChanging.Equals("C"),
                    ExpressionToChange = HttpUtility.HtmlEncode(model.ExpressionToChange),
                    RegularExpressionToChange = HttpUtility.HtmlEncode(model.RegularExpressionToChange),
                    ChangeTo = HttpUtility.HtmlEncode(model.ChangeTo),

                    EmailParsingRulesModelsId_Id = model.RuleId,

                    IsUpdatindIndex = model.IsUpdatindIndex.Equals("C"),
                    TableId_Id = table.Id,
                    Worksheet = Int32.Parse(model.Cell.Worksheet),
                    Column = (int)Enum.Parse(typeof(ColumnEnums), model.Cell.Column),
                    Status = RuleStatusEnums.Active.ToString(),
                    ParsingMode = (int)Enum.Parse(typeof(ParsingModeEnum), "SearchInSubjectAndBody"),
                    ConsiderRegister = false
                };
                emailDataParsingRulesRepository.Add(emailDataParsingRule);
                emailDataParsingRulesRepository.Commit();
                return RedirectToAction("EditEmailParsingRule", "Email", new { ruleId = model.RuleId });
            }

            return View();
        }
示例#2
0
        public ActionResult AddNewDataRuleForEmails(long ruleId)
        {
            var userId = UserHelper.GetUserByEmail(User.Identity.Name).Id;

            var tables = tablesRepository.FindAll(w => w.AspNetUsers.Id.Equals(userId));

            List<SelectListItem> worksheetsList = new List<SelectListItem>();
            for (int i = 0; i <= 10; i++)
            {
                worksheetsList.Add(new SelectListItem { Text = i.ToString(), Value = i.ToString() });
            }

            var model = new AddNewRuleForDataModel
            {
                RuleId = ruleId,
                Tables = new List<SelectListItem>(),
                WorksheetsList = worksheetsList
            };

            model.Tables.Add(new SelectListItem { Text = CultureHelper.GetStringForCurentCulture("EmailController_AddNewDataRuleForEmails_Select_table"), Value = "-1" });

            if (tables.Any())
            {
                foreach (var t in tables)
                {
                    model.Tables.Add(new SelectListItem { Text = t.Name, Value = t.Id.ToString() });
                }
            }

            return PartialView(model);
        }