예제 #1
0
        static void Main(string[] args)
        {
            string executableLocation = AppContext.BaseDirectory;
            string directoryToSearch  = Path.Combine(Path.GetDirectoryName(executableLocation), "Test.dll");



            foreach (string file in Directory.EnumerateFiles(directoryToSearch, "*.dll"))
            {
                Assembly assembly = null;
                try
                {
                    //Load assembly using byte array
                    byte[] rawAssembly = File.ReadAllBytes(file);
                    assembly = Assembly.Load(rawAssembly);
                }
                catch (Exception)
                {
                }

                if (assembly != null)
                {
                    // yield return assembly;
                    Assembly s = assembly;
                }
            }

            var sss = GetAssemblies();

            char[] skkkk = "‎12‎/‎01‎/‎2019".Where(c => c < 128).ToArray();
            string x     = new string(skkkk);


            List <DataTable> lstDt = new List <DataTable>();

            DataTable dt = new DataTable();

            dt.Clear();
            dt.Columns.Add("Name");
            dt.Columns.Add("Marks");
            DataRow _ravi = dt.NewRow();

            _ravi["Name"]  = "ravi";
            _ravi["Marks"] = "500";
            dt.Rows.Add(_ravi);

            DataTable dtssss = Extension.AsDataTable(GetKeyValue());

            var kkkk = dtssss.AsEnumerable().ToList().CopyToDataTable();

            // DataTable s=ss.query.CopyToDataTable();

            for (int i = 0; i < 3; i++)
            {
                lstDt.Add(dtssss);
            }

            DataTable dt1 = new DataTable();
            int       j   = 0;

            foreach (DataTable data in lstDt)
            {
                DataRow dr = data.Copy().Rows[j];
                dt1.ImportRow(dr);
                dt1.AcceptChanges();
                //++j;
            }

            var ss = dt1.AsEnumerable();

            DataSet ds = new DataSet();



            //compareTwoandGetMatchingInTwoTable();

            //XmlDocument doc = new XmlDocument();
            //doc.Load("C:\\XMLDATA\\TestFile1.xml");

            //XmlReader xmlReader = new XmlNodeReader(doc);
            //DataSet dataSet = new DataSet();
            //dataSet.ReadXml(xmlReader);
            //DataTable ss = dataSet.Tables[0];


            //var ss = doc;
            //DataSet dataSet = new DataSet();
            //dataSet.ReadXml(doc);

            //MappedDiagnosisWithServiceAndGetMatchedOrNot();


            //DataTable dt = new DataTable();
            //try
            //{
            //    var ss = Convert.ToBoolean(dt.Compute("'#03/31/2017 16:00:00#' > '#01/12/2020 16:11:46#'", ""));
            //    var ssss = ss;
            //}
            //catch (Exception ex)
            //{

            //}
            //int count = 1;
            //StringBuilder sbFinalexpression = new StringBuilder();
            //StringBuilder nulloccurance = new StringBuilder();
            //string test = "'ppp' <> null OR null <> null OR 1 <> null AND 1=1";

            //string[] arrayOfExp = null;
            //arrayOfExp = test.Split(" ");
            //for (int i = 0; i < arrayOfExp.Length; i++)
            //{
            //    if (i > 0 && (arrayOfExp[i] == "<>" && arrayOfExp[i + 1] == "null"))
            //    {
            //        nulloccurance.Append(i - 1 + ",");
            //        nulloccurance.Append(i + 1 + ",");
            //    }
            //}

            //string[] nulloccur = nulloccurance.ToString().Split(",");
            //for (int i = 0; i < arrayOfExp.Length; i++)
            //{

            //    if (nulloccur.Contains(i.ToString()))
            //    {
            //        if (arrayOfExp[i].Contains("'"))
            //        {
            //            sbFinalexpression.Append(arrayOfExp[i] + "");
            //        }
            //        else
            //        {
            //            sbFinalexpression.Append("'" + arrayOfExp[i] + "'" + " ");
            //        }
            //    }
            //    else
            //    {
            //        sbFinalexpression.Append(arrayOfExp[i] + " ");
            //    }
            //}



            //var ss = dt.Compute(sbFinalexpression.ToString(), "");

            //var yes = ss;
            // compareTwoandGetMatchingInTwoTable();

            #region Encrytion
            //string key = "cloudsolutions@rcma12020";

            //Console.WriteLine("Please enter a secret key for the symmetric algorithm.");
            //var key = Console.ReadLine();

            //Console.WriteLine("Please enter a string for encryption");
            //var str = Console.ReadLine();
            //var encryptedString = Encryption.EncryptString(key, str);
            //Console.WriteLine($"encrypted string = {encryptedString}");
            //var decryptedString = Encryption.DecryptString(key, encryptedString);
            //Console.WriteLine($"decrypted string = {decryptedString}");

            //Console.ReadKey();
            #endregion

            #region commented for arithmatic
            // caller("", "");

            //string name = "vikash";

            //string chkvalue = "'" + name + "' not like '%salim%'";
            //DataTable dt = new DataTable();
            //bool ressss = Convert.ToBoolean(dt.Compute(chkvalue, ""));

            //string name = "true";

            //string chkvalue = "true=false";
            //DataTable dt = new DataTable();
            //bool ressss = Convert.ToBoolean(dt.Compute(chkvalue, ""));

            //var sss = ressss;


            //string cc2 = "AAAA1111111";
            //string ccc = @"^[0-9a -zA-Z]{4}\d{6,7}$".Trim();
            //string regex = "@" + ccc + "";

            //var match = Regex.Match("AAAA1111111", @""+ ccc + "", RegexOptions.IgnoreCase);
            //if (!match.Success)
            //{
            //    // does not match
            //}
            //else
            //{

            //}



            //var test1 = "20:00:00".Replace(":",",");
            //TimeSpan timespan = new TimeSpan(20,00,00);
            //DateTime time = DateTime.Today.Add(timespan);
            //string displayTime = time.ToString("hh:mm tt");
            //string test = "RAMIM";
            //string a = test.Substring(1);



            //string kkk = "Together we can do so mu_ch!";
            //string[] ppp = kkk.Split(" ");
            //if (ppp.Any(x => x == kkk.Contains("mu_").ToString()))
            //{
            //    // do some action here if true...
            //}



            //string str= "HI";
            //string[] splitstr = str.Split(" ");
            //var l = splitstr;
            //Test test = new Test();
            //test.evaluate("", null);
            //int a = 4;
            //int b = 5;
            //string functionName = "add";
            //object[] anArray= new object[2];
            //for (int i = 0; i < anArray.Length; i++)
            //{
            //    anArray[i] = i+1;

            //}
            //  object[] paramJoin=string.Join(",", anArray);

            // Test p = new Test();
            // Type t = p.GetType();
            // MethodInfo mi = t.GetMethod(functionName, BindingFlags.Public | BindingFlags.IgnoreCase | BindingFlags.Instance);
            // string ress = mi.Invoke(p, anArray).ToString();
            //// string result = mi.Invoke(p, new object[] { a, b }).ToString();
            // Console.WriteLine("Result = " + ress);
            // Console.ReadLine();


            //DateTime dateTime = DateTime.Now;

            //// string tmpDate = dateTime.ToString("MM/dd/yyyy HH:mm:ss ", CultureInfo.InvariantCulture);

            //DateTime dateTime1 = new DateTime();
            //dateTime1 = DateTime.Parse(Convert.ToString(null));
            //var tmpDate1 = dateTime.ToString("MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture);


            //string tmpDate = "null";
            //DateTime lstadate = DateTime.Now.AddDays(-1);
            //string chkvalue = "#" + tmpDate + "# < #06/07/1988 00:00:06 PM#";
            //DataTable dt = new DataTable();
            //bool ressss = Convert.ToBoolean(dt.Compute(chkvalue, ""));



            //string HIII = "91877 = '91877'  ";
            //string final = string.Empty;
            //if (HIII.ToLower().Contains("like"))
            //{
            //    StringBuilder sb = new StringBuilder();
            //    string[] array = HIII.Split(' ');
            //    bool isLikeExists = false;
            //    foreach(var s in array)
            //    {
            //        if (Convert.ToString(s).ToLower() == "like")
            //        {
            //            isLikeExists = true;
            //            break;
            //        }
            //    }

            //    if (isLikeExists)
            //    {
            //        for (int i = 0; i < array.Length; i++)
            //        {

            //            if (i > 1 && array[i - 1].ToString() == "LIKE")
            //            {
            //                var chkForSingleQuotesandRepl = array[i].ToString().Replace("'", "").Replace("'", "");
            //                sb.Append(" " + "'%" + chkForSingleQuotesandRepl + "%'" + " ");
            //            }
            //            else
            //            {
            //                if (array[i + 1].ToString() == "LIKE")
            //                {
            //                    sb.Append(" " + "'" + array[i].ToString() + "'" + " ");
            //                }
            //                else
            //                    sb.Append(" " + array[i].ToString() + " ");
            //            }
            //        }
            //    }
            //    final = sb.ToString();
            //}
            //else
            //    final = HIII;


            //string test = final.ToLower();
            //DataTable ddd = new DataTable();
            //var answer11eeee = Convert.ToBoolean(ddd.Compute(test, ""));



            //DateTime testD = new DateTime();
            //string  tests="Hii";
            //try
            //{
            //     testD = DateTime.Parse(("hii"));
            //}
            //catch (Exception)
            //{

            //    DateTime testDsss = DateTime.Parse(("09/07/2019"));
            //    string sdflfjsdfdks = testDsss.ToString("dd/M/yyyy", CultureInfo.InvariantCulture);
            //}



            //if (!string.IsNullOrEmpty(Convert.ToString(tests)))
            //{
            //    try
            //    {
            //        var expValueOfDateTime = Convert.ToDateTime(testD).ToString("MM/dd/yyyy");
            //        var kkkkkk = expValueOfDateTime;
            //    }
            //    catch
            //    {
            //        var sss = "";
            //    }

            //}

            //int six = 7;
            //DateTime first = DateTime.Now;
            //DateTime sec = DateTime.Now.AddDays(-1);
            //string PP = @" ("+ six + " > (5 + 1 ) AND 6 < ( 3 + 8 ) AND '5888' LIKE   '%5888'   ) AND true=true  AND " + Convert.ToDateTime(first).ToString("MM/dd/yyyyhhmmss") + "<" + Convert.ToDateTime(sec).ToString("MM/dd/yyyyhhmmss") + " ";
            //DataTable dt1 = new DataTable();
            //var answer11 = Convert.ToBoolean(dt1.Compute(PP, ""));


            //string KKKK = " 5 = 1 + 3 + 1";
            //DataTable dt = new DataTable();
            //double answer = Convert.ToDouble(dt.Compute(KKKK, ""));
            #endregion

            #region commented code

            //List<string> mylist = new List<string>(new string[] { "Age", "Weight", "Age" });
            //StringBuilder sbl = new StringBuilder();
            //foreach (var k in mylist)
            //{
            //    sbl.Append("Person." + k);
            //}

            //const string exp = @"(Person.Age > 3 AND Person.Weight > 50) OR Person.Age < 3";
            //var p = Expression.Parameter(typeof(Person), "Person");
            //var e = System.Linq.Dynamic.DynamicExpression.ParseLambda(new[] { p }, null, exp);
            //var bob = new Person
            //{
            //    Name = "Bob",
            //    Age = 30,
            //    Weight = 213,
            //    FavouriteDay = new DateTime(2000, 1, 1)
            //};

            //var result1 = e.Compile().DynamicInvoke(bob);
            //Console.WriteLine(result1);
            //Console.ReadKey();


            //String infix = "  DiscountAmount GreaterThan 100  OR ( DiscountAmount GreaterThan 20 ) AND DiscountAmount LessThanOrEqualTo 110 ";
            //FunctionEvaluate evaluate = new FunctionEvaluate();
            //Func<double, double> f =
            //evaluate.ConstructFunction(infix);

            //Console.WriteLine(StringTest.evaluate("  DiscountAmount GreaterThan 100  OR ( DiscountAmount GreaterThan 20 ) AND DiscountAmount LessThanOrEqualTo 110 "));
            // Console.ReadLine();

            //const string exp = @"(Person.Age > 3 AND Person.Weight > 50) OR Person.Age < 3";
            //var p = Expression.Parameter(typeof(Person), "Person");
            //var e = System.Linq.Dynamic.DynamicExpression.ParseLambda(new[] { p }, null, exp);
            //var bob = new Person
            //{
            //    Name = "Bob",
            //    Age = 30,
            //    Weight = 213,
            //    FavouriteDay = new DateTime(2000, 1, 1)
            //};

            //var result = e.Compile().DynamicInvoke(bob);
            //Console.WriteLine(result);
            //Console.ReadKey();



            //string star = "*";
            //Console.WriteLine(EvaluateString.evaluate("10 + 2 * 6"));
            //Console.WriteLine(EvaluateString.evaluate("100 * 2 + 12"));
            // Console.WriteLine(EvaluateString.evaluate("100 " + star + " ( 2 + 12 )"));
            //Console.WriteLine(EvaluateString.evaluate("100 * ( 2 + 12 ) / 14"));


            //// (((1-2)-3) + (4*(5+6)))
            //Node root = new Node('+', new Node('-', new Node('-', new Node("1"), new Node("2")), new Node("3")),
            //                            new Node('*', new Node("4"), new Node('+', new Node("5"), new Node("6"))));
            //Console.WriteLine("Prefix notation: \t" + root.Prefix());
            //Console.WriteLine("Postfix notation: \t" + root.Postfix());
            //Console.WriteLine("Infix notation: \t" + root.Infix());
            //Console.WriteLine("Solution for tree is:\t" + root.Solve());
            //Console.ReadKey(true);


            // var adsdsa = Convert.ToInt16("null".ToString());


            #endregion

            InputParameter parameter = new InputParameter();
            //parameter.RuleGroupName = "Bupa_Submission_Services";
            //parameter.KeyValue = BupaSubmissionServices();

            //parameter.RuleGroupName = "Submission_Patient";
            //parameter.KeyValue = PatientKeyValue();

            parameter.RuleGroupName = "TestGroup";
            parameter.KeyValue      = GetKeyValue();
            var kkkss = CallService(parameter).ToString();

            Result        result        = JsonConvert.DeserializeObject <Result>(kkkss);
            string        msg           = string.Empty;
            StringBuilder stringBuilder = new StringBuilder();
            var           ruleGroupName = result.RuleGroupName;
            var           ruleName      = result.RuleName;
            if (result.MessageDetail != null)
            {
                foreach (var s in result.MessageDetail)
                {
                    //if(!string.IsNullOrEmpty(s.Message))
                    msg += "\nRuleGroupName:" + ruleGroupName + ":" + s.Message;
                }
            }
            if (result.Data != null)
            {
                foreach (var ruleResult in result.Data)
                {
                    if (ruleResult != null)
                    {
                        foreach (RuleResult res in ruleResult)
                        {
                            stringBuilder.Append("\nRuleGroupName: " + ruleGroupName + " - RuleId:" + res.RuleId + " \nResultName ::" + res.ResultName + "\nResultValue ::" + res.ResultValue + "\nSeverityId ::" + res.SeverityId + "\nSeverityName ::" + res.SeverityName + "\nSeverityLevelTypeId ::" + res.SeverityLevelTypeId + "\n--------------------------------------------------------------");
                        }
                    }
                }
                Console.WriteLine("Status message: " + msg + "\n------------------------------------------------------------------" + "\nEvalution error details is ::" + "\n------------------------------------------------------------------------" + stringBuilder);
            }
            else
            {
                Console.WriteLine("Evalution Status is ::" + msg + "\n------------------------------------------------------------------");
            }


            Console.ReadLine();
        }