Exemplo n.º 1
0
        public void TestPalindromsSets()
        {
            FilterSets sets   = new FilterSets();
            var        result = sets.GetPalindroms(new[] { "radar", "kajak", "test" });

            Assert.AreEqual(result.Length, 2);
        }
Exemplo n.º 2
0
        public void TestAnagramsSets()
        {
            FilterSets sets = new FilterSets();

            sets.words = new[] { "radar", "kajak", "test" };
            string[] result = sets.GetAnagramsSet("kaajk");
            Assert.AreEqual(result.Length, 1);
        }
Exemplo n.º 3
0
        public void TestWildCardsSets()
        {
            FilterSets sets = new FilterSets();

            sets.words = new[] { "radar", "kajak", "test" };
            var result = sets.GetWildCards("ra");

            Assert.AreEqual(result.Length, 1);
        }
        private void AddIllegalExpressions(LegalFilterParser parser)
        {
            foreach (var expr in parser.IllegalExpressionsForSplitRequest)
            {
                var newLegalParser  = new LegalFilterParser(strict);
                var newFilterParser = new FilterExpressionParser();

                var legalExpression    = newLegalParser.Visit(expr);
                var filteredExpression = newFilterParser.Visit(legalExpression);

                FilterSets.AddRange(GetFilters(newFilterParser.Conditions));

                AddIllegalExpressions(newLegalParser);
            }
        }
        private Expression ParseFilters(Expression expression)
        {
            Logger.Log("Identifying query filters", Indentation.Two);

            var filterExpressionParser = new FilterExpressionParser();

            Logger.Log("Identifying filter candidates", Indentation.Three);
            var filterExpression = filterExpressionParser.Visit(expression);

            var conditions = filterExpressionParser.Conditions;

            Logger.Log($"Found {conditions.Count} filter candidates", Indentation.Four, conditions);

            var adjustedFilters = GetFilters(conditions);

            if (adjustedFilters.Count > 0)
            {
                FilterSets.AddRange(adjustedFilters);
            }

            return(filterExpression);
        }
Exemplo n.º 6
0
        protected void btnEmail_Click(object sender, EventArgs e)
        {
            try
            {
                string    checkedRequiredField = "";
                DataTable dt           = new DataTable();
                string    subject      = "";
                string    fileName     = "";
                string    body         = "";
                Boolean   isSubjectYM  = false;
                Boolean   isFileNameYM = false;
                errorList = new CustomList <ErrorList>();
                MailSetupManager       manager   = new MailSetupManager();
                CustomList <MailSetup> mailSetup = manager.GetAllMailSetup(Convert.ToInt32(Session["ReportID"]));
                MailSetup mS = mailSetup.Find(f => f.Subject.IsNotNullOrEmpty());
                if (mS.IsNull())
                {
                    return;
                }
                else
                {
                    subject      = mS.Subject;
                    fileName     = mS.FileName;
                    body         = mS.Body;
                    isSubjectYM  = mS.IsSubjectYM;
                    isFileNameYM = mS.IsFileNameYM;
                }
                #region
                if (isSubjectYM)
                {
                    FilterSets month         = FilterSetList.Find(f => f.ColumnName == "MonthNo");
                    FilterSets year          = FilterSetList.Find(f => f.ColumnName == "YearNo");
                    string     monthYearName = "";
                    if (month.IsNotNull())
                    {
                        monthYearName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(month.ColumnActualValue.ToInt()).Substring(0, 3) + "' " + year.ColumnActualValue.Substring(2, 2);
                    }

                    if (monthYearName == "")
                    {
                        FilterSets fromDate = FilterSetList.Find(f => f.ColumnName == "FromDate");
                        if (fromDate.IsNotNull())
                        {
                            monthYearName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(fromDate.ColumnValue.Substring(0, 2).ToInt()).Substring(0, 3) + "' " + fromDate.ColumnValue.Substring(8, 2);
                        }
                    }
                    if (monthYearName == "")
                    {
                        FilterSets workDate = FilterSetList.Find(f => f.ColumnName == "Workdate");
                        if (workDate.IsNotNull())
                        {
                            monthYearName = Convert.ToDateTime(workDate.ColumnValue).ToString("dd MMM yy");
                        }
                    }
                    subject = subject + "_" + monthYearName;
                }
                if (isFileNameYM)
                {
                    FilterSets month         = FilterSetList.Find(f => f.ColumnName == "MonthNo");
                    FilterSets year          = FilterSetList.Find(f => f.ColumnName == "YearNo");
                    string     monthYearName = "";
                    if (month.IsNotNull())
                    {
                        monthYearName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(month.ColumnActualValue.ToInt()).Substring(0, 3) + "' " + year.ColumnActualValue.Substring(2, 2);
                    }

                    if (monthYearName == "")
                    {
                        FilterSets fromDate = FilterSetList.Find(f => f.ColumnName == "FromDate");
                        if (fromDate.IsNotNull())
                        {
                            monthYearName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(fromDate.ColumnValue.Substring(0, 2).ToInt()).Substring(0, 3) + "' " + fromDate.ColumnValue.Substring(8, 2);
                        }
                    }
                    if (monthYearName == "")
                    {
                        FilterSets workDate = FilterSetList.Find(f => f.ColumnName == "Workdate");
                        if (workDate.IsNotNull())
                        {
                            monthYearName = Convert.ToDateTime(workDate.ColumnValue).ToString("dd MMM yy");
                        }
                    }
                    fileName = fileName + "_" + monthYearName;
                }
                string    reportPath = Session["reportPath"].ToString();
                DataTable dt1        = new DataTable();
                if (!mS.IsIndividual)
                {
                    Report.LoadSourceDataSet(ref checkedRequiredField, ref dt1);
                }
                FilterSets empCode = FilterSetList.Find(f => f.ColumnName == "EmpCode");
                if (empCode.ColumnActualValue.IsNotNullOrEmpty())
                {
                    mailSetup = mailSetup.FindAll(f => f.EmpKey.ToString() == empCode.ColumnActualValue);
                }
                #endregion
                foreach (MailSetup m in mailSetup)
                {
                    //if (mS.IsIndividual)
                    //    Report.LoadSourceDataSet(m.EmpKey.ToString(), ref dt1);

                    //SentEmail sm = new SentEmail();
                    //string message = sm.EmailUtil(m.EmailAddress, reportPath, dt1, "", subject, fileName, body);
                    //if (message.IsNotNullOrEmpty())
                    //{
                    //    ErrorList eL = new ErrorList();
                    //    eL.EmpName = m.EmpName.Trim();
                    //    eL.Error = message;
                    //    errorList.Add(eL);
                    //}
                }
                ((PageBase)this.Page).SuccessMessage = "Mail sent successfully!";
            }
            catch (Exception ex)
            {
                ((PageBase)this.Page).ErrorMessage = (ExceptionHelper.getExceptionMessage(ex));
            }
        }