예제 #1
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;
 }
예제 #2
0
        public static method from_json(string text, security.titan_token token, bool save = true)
        {
            method m = JsonConvert.DeserializeObject <method>(text, new JsonSerializerSettings {
                Error = delegate(object sender, ErrorEventArgs args){
                    Console.WriteLine(args.ErrorContext.Error.Message);
                    args.ErrorContext.Handled = true;
                }
            });


            if (null == m.data_schema)
            {
                m.data_schema = new List <titan.core.column>();
            }
            if (null == m.parameters)
            {
                m.parameters = new List <titan.core.parameter>();
            }

            m.parameters.RemoveAll(item => item == null);
            m.parameters.RemoveAll(item => String.IsNullOrWhiteSpace(item.name));

            parameters param = m.execute_load_parameters(token, null, true);

            if (m.regenerate_columns)
            {
                m.data_schema.Clear();
                data_set row   = db.fetch(m.connection_string, strip_comments(m.query), param); //no conn string denotes localhost, aything else is treated as a conn string.. (titan)
                int      index = 0;
                if (null != row)                                                                //only update the titan.core.columns if we have atlest 1 result.
                {
                    foreach (string key in row.Keys)
                    {
                        index++;
                        titan.core.column c = new titan.core.column(key, "text", index, true);
                        m.data_schema.Add(c);                                                 //only add if it doesnt exist...
                    }
                }
                //   if(null!=titan.core.columns) titan.core.columns.RemoveAll(item=> !row.ContainsKey(item.name) );
            }    //
            //global.reload();
            if (save)
            {
                if (!string.IsNullOrWhiteSpace(m.data_mapping_name))
                {
                    if (null == m.sig_init)
                    {
                        m.sig_init        = new external_data_defaults();
                        m.sig_init.group  = m.group;
                        m.sig_init.method = m.method;
                        m.sig_init.owner  = m.owner;
                    }

                    m.sig_init.save();
                }
                m.save();
                m.generate_queries();
            }
            else
            {
                m.generate_queries();
            }
            return(m);
        }