コード例 #1
0
            public void run_crons() {
                string query="SELECT * FROM titanDWS WITH (NOLOCK) WHERE cron=cast(1 as bit)"; //get all methods that are cron's
                data_set rows=db.fetch_all("titan",query);

                foreach(row row in rows) {
                    lambda i=new lambda();
                    i.group =(string)row["group"];
                    i.method=(string)row["method"];
                    string cron=(string)row["schedule"];
                    string[] tokens=cron.Split(' ');
                    if(tokens.Length!=5) continue;          //we need 5 pieces.
                    string minute       =tokens[0];
                    string hour         =tokens[1];
                    string day          =tokens[2];
                    string month        =tokens[3];
                    string day_of_week  =tokens[4];
                    DateTime time=DateTime.Now;
                    if(minute       !="*" && time.Minute.ToString()     !=minute) continue;
                    if(hour         !="*" && time.Hour.ToString()       !=hour) continue;
                    if(day          !="*" && time.Day.ToString()        !=day) continue;
                    if(month        !="*" && time.Month.ToString()      !=month) continue;
                    if(day_of_week  !="*" && time.DayOfWeek.ToString()  !=day_of_week) continue;
                    //we only get here if we have passed all the checks.
                    //web_service w=new web_service();
                    method m=new method();
                    m.execute(i,true,null,true);
                }
            }
コード例 #2
0
        static void Main(string[] args)
        {
            // We are creating an instance of our delegate called lambda.
            // Here you can see the lambda operator => in action.
            // On the left side we have the arguments, in our case x
            // and on the right side we have the expression x + 1
            // You can notice that instead of creating a separate method for
            // incrementing of x by 1, we are using lambda expression here
            // and achieve the same with one line of code.

            lambda addOne = x => x + 1;

            Console.WriteLine(addOne(1)); // Output: 2
            Console.WriteLine("--------------");


            // We are creating an instance of our delegate called multi.
            // Once again, on the left side we have the arguments but this
            // time we have three(x,y,z) arguments. On the right side where we
            // put the expression, we are just multiplying them.

            multi multiply = (x, y, z) => x * y * z;

            Console.WriteLine(multiply(2, 3, 4)); //Output: 24
            Console.WriteLine("--------------");


            // We are creating an instance of our delegate caleld noparamsLambda.
            // You can see above that our delegate returns int but doesn.t have any
            // input parameters. That's the meaning of '() ' below. On the left side
            // you can see we have just empty paratheses.
            // Also note that on the right side we put a logic for a random number
            // generaor, the same way we are doing it in every normal method.

            noparamsLambda randomNumber = () =>
            {
                int random = new Random().Next();
                Console.WriteLine("Random number generated - {0}", random);
                return(random);
            };

            Console.WriteLine(randomNumber());
            Console.WriteLine("--------------");

            int[] firstTen = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            foreach (var num in firstTen)
            {
                Console.Write("{0} ", num);
            }
            Console.Write("\n");

            Console.WriteLine("Even numbers:");
            var even = firstTen.Where(n => n % 2 == 0);

            foreach (var num in even)
            {
                Console.Write("{0} ", num);
            }
            Console.Write("\n");
        }
コード例 #3
0
        public void export(string export_id1, int export_id, string name, string type)
        {
            lambda i = new lambda();

            i.export_id = export_id;
            string web_token = string.Format("{0}", export_id1);
            //enable web service jwt validation
            web_service w = new web_service(i);

            w.export(i, web_token);
        }//end export
コード例 #4
0
 public  method fetch_method(lambda i,security.titan_token token) {      //for building the method in the report page/editing
     method m=new method();
     m.titan_debug=titan_debug;
     if(string.IsNullOrWhiteSpace(i.group) || string.IsNullOrWhiteSpace(i.method)) return new method();
     bool found=m.load(i.group,i.method,i.owner,i.configure,token);
     
     m.base_init();
     if(ConfigurationManager.AppSettings["titan_debug"]=="true") {
         m.titan_debug=true;
         m.generate_queries();
     }
     
     return m;
 }
コード例 #5
0
 public json_results test_method(lambda i)
 {
     return(security.wrapper(JWT, i, (token) => {
         method m = method.from_json(i.crud, token, false);
         string res;
         if (m.data_schema == null || m.data_schema.Count == 0)
         {
             res = "No columns in this query";
         }
         else
         {
             res = String.Format("Column count {0}", m.data_schema.Count);
         }
         return res;
     }));
 }//end titan test method
コード例 #6
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (comboBox1.SelectedItem.ToString())
            {
            case "x^2 + y^2 = z":
                f = (x, y) => x * x + y * y;
                break;

            case "1/(1+x^2) + 1/(1+y^2) = z":
                f = (x, y) => Math.Sin(x) * Math.Cos(y);
                break;

            case "x^2 - y^2 = z":
                f = (x, y) => x * x - y * y;
                break;
            }
        }
コード例 #7
0
ファイル: Form1.cs プロジェクト: Ukolnir/MMCS_332
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (comboBox1.SelectedItem.ToString())
            {
            case "x^2 + y^2 = z":
                f = (x, y) => x * x + y * y;
                break;

            case "Sin(x)*Cos(x) = z":
                f = (x, y) => Math.Sin(x) * Math.Cos(y);
                break;

            case "((1 – x)^2 + 100 * (1 + y – x^2)^2) / 500 - 2.5 = z":
                f = (x, y) => ((1 - x) * (1 - x) + 100 * (1 + y - x * x) * (1 + y - x * x)) / 500 - 2.5;
                break;
            }
        }
コード例 #8
0
        static void Main(string[] args)
        {
            string oper = "";

            Console.WriteLine("Enter your operation:");
            oper = Console.ReadLine();
            Console.WriteLine("Enter your arguments: X:");
            int x = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Y:");
            int y = Convert.ToInt32(Console.ReadLine());

            switch (oper)
            {
            case "add":
                lambda lam1    = (int arg1, int arg2) => arg1 + arg2;
                int    lam1res = lam1(x, y);
                Console.WriteLine(lam1res);
                break;

            case "mul":
                lambda lam2    = (int arg1, int arg2) => arg1 * arg2;
                int    lam2res = lam2(x, y);
                Console.WriteLine(lam2res);
                break;

            case "sub":
                lambda lam3    = (int arg1, int arg2) => arg1 - arg2;
                int    lam3res = lam3(x, y);
                Console.WriteLine(lam3res);
                break;

            case "div":
                lambda lam4    = (int arg1, int arg2) => arg2 == 0 ? 0 : arg1 / arg2;
                int    lam4res = lam4(x, y);
                Console.WriteLine(lam4res);
                break;

            default:
                break;
            }
            Console.ReadKey();
        }
コード例 #9
0
 public json_results get(lambda i)
 {
     return(security.wrapper(JWT, i, (token) => {
         bool no_links = false;
         bool init = false;
         if (i.configure == "preview")
         {
             init = true;
         }
         web_service w = new web_service(i);
         method m = new titan.method();
         if (ConfigurationManager.AppSettings["titan_debug"] == "true")
         {
             m.titan_debug = true;
         }
         method_results results = m.execute(i, no_links, token, init);
         return results;
     }));
 }//end titan lambda
コード例 #10
0
        public json_results fetch_method(lambda i)
        {
            return(security.wrapper(JWT, i, (token) => {
                web_service w = new web_service(i);
                method results = w.fetch_method(i, token);

                if (null == results)
                {
                    results = new method(i, i.group, i.method, i.owner, i.configure, token);

                    results.generate_queries();

                    if (null == results)
                    {
                        //results="Failed to load empty method";
                    }
                    return results;
                }
                return results;
            }));
        }//end fetch_method
コード例 #11
0
        static void Main(string[] args)
        {
            lambda addOne = x => x + 1;

            Console.WriteLine(addOne(1)); // Output: 2
            Console.WriteLine("--------------");

            multi multiply = (x, y, z) => x * y * z;

            Console.WriteLine(multiply(2, 3, 4)); //Output: 24
            Console.WriteLine("--------------");

            noparamsLambda randomNumber = () => {
                int random = new Random().Next();
                Console.WriteLine("Random number generated - {0}", random);
                return(random);
            };

            Console.WriteLine(randomNumber());
            Console.WriteLine("--------------");

            int[] firstTen = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            foreach (var num in firstTen)
            {
                Console.Write("{0} ", num);
            }
            Console.Write("\n");

            Console.WriteLine("Even numbers:");
            var even = firstTen.Where(n => n % 2 == 0);

            foreach (var num in even)
            {
                Console.Write("{0} ", num);
            }
            Console.Write("\n");
        }
コード例 #12
0
            public string export(lambda i,string web_token) {
                string query="SELECT TOP 1 json,token FROM titanDWS_exports WITH (NOLOCK) WHERE [id]=@export_id AND [web_token]=@token";
                parameters param=new parameters();
                param.add("@token"     ,web_token);
                param.add("@export_id" ,i.export_id);

                System.Web.Script.Serialization.JavaScriptSerializer jss=new System.Web.Script.Serialization.JavaScriptSerializer();
                lambda export_input=null;
                security.titan_token s_token=null;
                data_set result=db.fetch("titan",query,param);

                if(null!=results) {
                    string json= (string)result[0,"json"];
                    string token=(string)result[0,"token"];
                    export_input=jss.Deserialize<lambda>(json);
                    s_token=jss.Deserialize<security.titan_token>(token);
                } else {
                    return null;                                                 //nothing... lets exit
                }
                                       
            if(null==export_input) return null;
            string name=String.Format("{0}-{1}-{2}.csv",export_input.group,export_input.method,DateTime.Now.ToLongTimeString());
            /*HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.ClearHeaders();
            HttpContext.Current.Response.ClearContent();
            HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" + name);
            HttpContext.Current.Response.ContentType = "text/csv";
            HttpContext.Current.Response.AddHeader("Pragma", "public");
            */
            

            export_input.pageLength=0;
            export_input.page=0;
            this.input=export_input;

            StringBuilder sb=new StringBuilder();
            
            method m=new method();
            m.execute(input,true,s_token,false);
     
                int index=0;
                foreach (query.column c in results.columns) {
                    core.column mc=m.data_schema.Find(x=>x.name==c.name);
                    if(null!=mc && mc.export) {
                        if (index!=0) {
                            sb.Append(",");
                        }
                        index++;
                       sb.Append(String.Format("\"{0}\"",c.name));
                    }
                }        
                sb.Append("\r\n");
                   
                 
                foreach (string[] row in results.rows) {        //row
                    index=0;
                    foreach (string column in row) {        //column
                        if (index!=0) {
                            sb.Append(",");
                        }
                        index++;
                        sb.Append(String.Format("\"{0}\"",column));
                    }
                    sb.Append("\r\n");
                }

                return sb.ToString();
                //HttpContext.Current.Response.Flush();
                //HttpContext.Current.Response.End();
            }//end export
コード例 #13
0
 public web_service(lambda input){
     this.input=input;
     init();
 }
コード例 #14
0
ファイル: Functional.cs プロジェクト: mfkiwl/Things-IDA
 static void Main(string[] args)
 {
     recursive(stepper)(two);
     Console.WriteLine(COND(identity)(apply)(TRUE) == identity);
     Console.ReadKey();
 }
コード例 #15
0
        public string get_token(lambda i)                                                           //all get tokens are verified by login params....
        {
            if (null == i)
            {
                return("");
            }
            security.titan_token token = new security.titan_token();
            if (String.IsNullOrWhiteSpace(i.reference1))
            {
                i.reference1 = "";
            }
            if (String.IsNullOrWhiteSpace(i.reference2))
            {
                i.reference2 = "";
            }
            if (String.IsNullOrWhiteSpace(i.reference3))
            {
                i.reference3 = "";
            }
            if (String.IsNullOrWhiteSpace(i.reference4))
            {
                i.reference4 = "";
            }
            if (String.IsNullOrWhiteSpace(i.reference5))
            {
                i.reference5 = "";
            }
            if (String.IsNullOrWhiteSpace(i.reference6))
            {
                i.reference6 = "";
            }
            if (String.IsNullOrWhiteSpace(i.reference7))
            {
                i.reference7 = "";
            }
            if (String.IsNullOrWhiteSpace(i.reference8))
            {
                i.reference8 = "";
            }
            if (String.IsNullOrWhiteSpace(i.reference9))
            {
                i.reference9 = "";
            }
            if (String.IsNullOrWhiteSpace(i.reference10))
            {
                i.reference10 = "";
            }
            if (String.IsNullOrWhiteSpace(i.reference11))
            {
                i.reference11 = "";
            }
            if (String.IsNullOrWhiteSpace(i.reference12))
            {
                i.reference12 = "";
            }
            if (String.IsNullOrWhiteSpace(i.reference13))
            {
                i.reference13 = "";
            }
            if (String.IsNullOrWhiteSpace(i.reference14))
            {
                i.reference14 = "";
            }
            if (String.IsNullOrWhiteSpace(i.reference15))
            {
                i.reference15 = "";
            }

            byte[] hash = System.Security.Cryptography.MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(
                                                                                    i.reference1 +
                                                                                    i.reference2 +
                                                                                    i.reference3 +
                                                                                    i.reference4 +
                                                                                    i.reference5 +
                                                                                    i.reference6 +
                                                                                    i.reference7 +
                                                                                    i.reference8 +
                                                                                    i.reference9 +
                                                                                    i.reference10 +
                                                                                    i.reference11 +
                                                                                    i.reference12 +
                                                                                    i.reference13 +
                                                                                    i.reference14 +
                                                                                    i.reference15
                                                                                    ));
            string check = ToHex(hash, true);

            if (check != i.check.Trim().ToUpper())
            {
                return("");                                     //this is a variable check. if the md5 doesnt match the
            }
            //variables have been tampered with. otherwose we are good to go.


            return(security.Encode(i.reference1,
                                   i.reference2,
                                   i.reference3,
                                   i.reference4,
                                   i.reference5,
                                   i.reference6,
                                   i.reference7,
                                   i.reference8,
                                   i.reference9,
                                   i.reference10,
                                   i.reference11,
                                   i.reference12,
                                   i.reference13,
                                   i.reference14,
                                   i.reference15));
        }//end get_token