//public static string Entry(long entryPosition, string list, string delimiter = ",")
        //{
        //    string functionReturnValue;
        //    var returnEntry = "";

        //    if (entryPosition == 0) return "";

        //    var numEntries = CountEntries(list, delimiter);
        //    if (numEntries == 1)
        //    {
        //        functionReturnValue = list.Replace(delimiter, "");
        //        if (functionReturnValue == null)
        //            functionReturnValue = "";
        //        return functionReturnValue;
        //    }
        //    long lengthList = list.Length;
        //    numEntries = 1;
        //    long counter = 0;
        //    for (counter = 1; counter <= lengthList; counter++)
        //    {
        //        returnEntry = returnEntry + Strings.Mid(list, counter, 1);
        //        if (Strings.Mid(list, counter, 1) == delimiter | counter == lengthList)
        //        {
        //            if (counter != lengthList)
        //            {
        //                numEntries = numEntries + 1;
        //            }
        //            else
        //            {
        //                if (numEntries + 1 == entryPosition + 1)
        //                {
        //                    functionReturnValue = returnEntry.Replace(delimiter, "");
        //                    if ((functionReturnValue == null))
        //                        functionReturnValue = "";
        //                    return functionReturnValue;
        //                }

        //            }
        //            if (numEntries == entryPosition + 1)
        //            {
        //                functionReturnValue = returnEntry.Replace(delimiter, "");
        //                if ((functionReturnValue == null))
        //                    functionReturnValue = "";
        //                return functionReturnValue;
        //            }
        //            else
        //            {
        //                returnEntry = "";
        //            }
        //        }
        //    }
        //    return "";

        //    return functionReturnValue;
        //}

        //public static string SetEntry(string value, string listValues, string defaultValue, string delimiter)
        //{
        //    int li1;
        //    var lcEq = "=";
        //    var lcComa = ",";

        //    if ((delimiter.Trim().Length == 2))
        //    {
        //        lcEq = delimiter.Substring(0, 1);
        //        lcComa = delimiter.Substring(1, 1);
        //    }

        //    var li2 = CountEntries(listValues, lcComa);
        //    var llFound = false;

        //    for (li1 = 1; li1 <= li2; li1++)
        //    {
        //        var lcEntry = Entry(li1, listValues, lcComa).Trim();
        //        if ((lcEntry.StartsWith(value + " " + lcEq)) | (lcEntry.StartsWith(value + lcEq)))
        //        {
        //            SpecialSetEntry(2, ref lcEntry, defaultValue, lcEq);
        //            SpecialSetEntry(li1, ref listValues, lcEntry, lcComa);
        //            llFound = true;
        //            break; // TODO: might not be correct. Was : Exit For
        //        }
        //    }

        //    if (!llFound)
        //    { listValues = value + lcEq + defaultValue + lcComa + listValues; }

        //    return listValues;

        //}

        //public static void SpecialSetEntry(long tokenNumber, ref string str, object value, string delimiter = ",")
        //{
        //    int i;
        //    //Was empty before instead of nothing
        //    if (tokenNumber <= 0 || str.Length == 0) return;

        //    string[] laStr = str.Split(delimiter, -1, Constants.vbTextCompare);
        //    if (laStr.Length + 1 < tokenNumber) return;

        //    laStr[tokenNumber - 1] = value;
        //    var lcWork = "";
        //    for (i = 0; i <= laStr.Length; i++)
        //    { lcWork = lcWork + delimiter + laStr[i]; }

        //    lcWork = Strings.Mid(lcWork, delimiter.Length + 1);
        //    if (lcWork.Length > 0)
        //    { str = lcWork; }
        //}

        public static string Quotify(string list)
        {
            if (CheckEmpty.String(list) == "")
            {
                return("''");
            }
            var listArray = new List <string>(list.Split(','));

            for (var i = 0; i <= listArray.Count - 1; i++)
            {
                listArray[i] = "'" + listArray[i] + "'";
            }
            return(string.Join(",", listArray));
        }
Beispiel #2
0
        private static Expression <Func <Log, bool> > CreateFilter(string search)
        {
            var serializer = new JavaScriptSerializer();
            var dict       = serializer.Deserialize <Dictionary <string, object> >(search);

            var predicate = PredicateBuilder.True <Log>();

            if (CheckEmpty.String(ref dict, "Module") != "")
            {
                predicate = predicate.And(p => p.Module.Id == dict["Module"].ToString());
            }

            if (CheckEmpty.String(ref dict, "Action") != "")
            {
                predicate = predicate.And(p => p.Action.Contains(dict["Action"].ToString()));
            }

            if (CheckEmpty.String(ref dict, "Text") != "")
            {
                predicate = predicate.And(p => p.Text.Contains(dict["Text"].ToString()));
            }

            if (CheckEmpty.String(ref dict, "UserId") != "")
            {
                predicate = predicate.And(p => p.UserId == Convert.ToInt64(dict["UserId"]));
            }

            if (CheckEmpty.String(ref dict, "BranchId") != "")
            {
                predicate = predicate.And(p => p.BranchId == Convert.ToInt64(dict["BranchId"]));
            }

            if (CheckEmpty.String(ref dict, "DateFilter") != "")
            {
                var dtLimits = DateUtilities.GetDateFilter(dict["DateFilter"].ToString(), dict["FromDate"].ToString(), dict["ToDate"].ToString());
                predicate = predicate.And(p => p.EntryDate >= dtLimits.FromDate);
                predicate = predicate.And(p => p.EntryDate <= dtLimits.ToDate);
            }

            return(predicate);
        }