internal bool Filter(Context context, Expression where) { foreach (PropertyInfo pi in this.GetType().GetProperties()) context.Variables[pi.Name] = pi.GetValue(this, null); return where == null || (bool)where.Calculate(context); }
internal List<Hashtable> GetData(Context context, Expression where, ListSelect fieldNames) { List<Hashtable> list = new List<Hashtable>(); foreach (FBPost item in GetData()) { if (item.Filter(context, where)) { Hashtable ht = new Hashtable(); foreach (Select field in fieldNames) ht[field.Alias] = field.Field.Calculate(context); list.Add(ht); } } return list; }
public AndExpression(Expression leftChildExpression, Expression rightChildExpression) : base(leftChildExpression, rightChildExpression) { }
public Subtraction(Expression leftChildExpression, Expression rightChildExpression) : base(leftChildExpression, rightChildExpression) { }
public NotExpression(Expression childExpression) : base(childExpression) { }
public object GetMaxOf(Expression expression) { throw new NotImplementedException(); }
internal List<Hashtable> GetData(Context context, Expression where, ListSelect fieldNames) { List<Hashtable> list = new List<Hashtable>(); foreach (CSVItem item in File.ReadAllText(path).Split('\n').Select(line => new CSVItem(line.Split(seperator)))) { if (item.Filter(context, where)) { Hashtable ht = new Hashtable(); foreach (Select field in fieldNames) ht[field.Alias] = field.Field.Calculate(context);//context.Variables[fieldName]; list.Add(ht); } } return list; }
internal List<Hashtable> GetData(Context context, Expression where, ListSelect fieldNames) { List<Hashtable> list = getFileList(context, where, fieldNames, path); return list; }
public IfShortCut(Expression boolExp, Expression trueExpression, Expression falseExpression) { this.boolExp = boolExp; this.trueExpression = trueExpression; this.falseExpression = falseExpression; }
public FunctionCall(string name, Expression[] arguments) { if (name == null) throw new ArgumentNullException("name"); if (arguments == null) throw new ArgumentNullException("arguments"); if (name.Length == 0) throw new ArgumentException("name cannot be an empty string.", "name"); fName = name; fArguments = arguments; }
public Comparison(ComparisonOperator comparisonOperator, Expression leftChildExpression, Expression rightChildExpression) : base(leftChildExpression, rightChildExpression) { fOperator = comparisonOperator; }
public CaseWhen(Dictionary<Expression, Expression> caseWhen, Expression _else) { this.caseWhen = caseWhen; this._else = _else; }
protected BinaryExpression(Expression leftChildExpression, Expression rightChildExpression) { if (leftChildExpression == null) throw new ArgumentNullException("leftChildExpression"); if (rightChildExpression == null) throw new ArgumentNullException("rightChildExpression"); fLeftChildExpression = leftChildExpression; fRightChildExpression = rightChildExpression; }
protected UnaryExpression(Expression childExpression) { if (childExpression == null) throw new ArgumentNullException("childExpression"); fChildExpression = childExpression; }
internal List<Hashtable> GetData(Join join, Expression where, ListSelect fieldNames) { List<Hashtable> list = new List<Hashtable>(); switch (join.TableName.ToLowerInvariant()) { case "information_schema.tables": { list.Add(new Hashtable() { { "table_name", "Rss" }, { "table_type", "table" } }); list.Add(new Hashtable() { { "table_name", "Pop3" }, { "table_type", "table" } }); list.Add(new Hashtable() { { "table_name", "File" }, { "table_type", "table" } }); list.Add(new Hashtable() { { "table_name", "Facebook" }, { "table_type", "table" } }); list.Add(new Hashtable() { { "table_name", "Twitter" }, { "table_type", "table" } }); list.Add(new Hashtable() { { "table_name", "Youtube" }, { "table_type", "table" } }); list.Add(new Hashtable() { { "table_name", "SocialMedia" }, { "table_type", "table" } }); list.Add(new Hashtable() { { "table_name", "Yahoo" }, { "table_type", "table" } }); list.Add(new Hashtable() { { "table_name", "FriendFeed" }, { "table_type", "table" } }); list.Add(new Hashtable() { { "table_name", "DailyMotion" }, { "table_type", "table" } }); list.Add(new Hashtable() { { "table_name", "CSV" }, { "table_type", "table" } }); break; } case "information_schema.columns": { list.AddRange(getColumnsOf(typeof(RSSItem), "Rss", where, fieldNames)); list.AddRange(getColumnsOf(typeof(POP3Item), "Pop3", where, fieldNames)); list.AddRange(getColumnsOf(typeof(FileItem), "File", where, fieldNames)); list.AddRange(getColumnsOf(typeof(FBPost), "Facebook", where, fieldNames)); list.AddRange(getColumnsOf(typeof(Tweet), "Twitter", where, fieldNames)); list.AddRange(getColumnsOf(typeof(RSSItem), "Youtube", where, fieldNames)); list.AddRange(getColumnsOf(typeof(SocialMediaItem), "SocialMedia", where, fieldNames)); list.AddRange(getColumnsOf(typeof(YahooResultItem), "Yahoo", where, fieldNames)); list.AddRange(getColumnsOf(typeof(FriendFeedItem), "FriendFeed", where, fieldNames)); list.AddRange(getColumnsOf(typeof(DailyMotionItem), "DailyMotion", where, fieldNames)); list.AddRange(getColumnsOf(typeof(CSVItem), "CSV", where, fieldNames)); break; } case "file": { if (!join.CinarTableOptions.ContainsKey("Path") || !join.CinarTableOptions.ContainsKey("Recursive")) throw new Exception("Provide file path. Exp: select .. from FILE(Path='c:\\...', Recursive=false)"); string path = Convert.ToString(join.CinarTableOptions["Path"].Calculate(this)); bool recursive = Convert.ToBoolean(join.CinarTableOptions["Recursive"].Calculate(this)); FileProvider fileProvider = new FileProvider(path, recursive); list.AddRange(fileProvider.GetData(this, where, fieldNames)); break; } case "pop3": { if (!join.CinarTableOptions.ContainsKey("Server") || !join.CinarTableOptions.ContainsKey("UserName") || !join.CinarTableOptions.ContainsKey("Password")) throw new Exception("Provide mail settings. Exp: select .. from POP3(Server='', UserName='', Password='')"); string server = (string)join.CinarTableOptions["Server"].Calculate(this); string userName = (string)join.CinarTableOptions["UserName"].Calculate(this); string password = (string)join.CinarTableOptions["Password"].Calculate(this); POP3Provider pop3Provider = new POP3Provider(server, userName, password); list.AddRange(pop3Provider.GetData(this, where, fieldNames)); break; } case "rss": { if (!join.CinarTableOptions.ContainsKey("Url")) throw new Exception("Provide url. Exp: select .. from RSS(Url='http://...')"); string url = (string)join.CinarTableOptions["Url"].Calculate(this); RSSProvider rssProvider = new RSSProvider(url); list.AddRange(rssProvider.GetData(this, where, fieldNames)); break; } case "facebook": { if (!join.CinarTableOptions.ContainsKey("Query")) throw new Exception("Provide query. Exp: select .. from Facebook(Query='...')"); string query = (string)join.CinarTableOptions["Query"].Calculate(this); FacebookProvider fbProvider = new FacebookProvider(query); list.AddRange(fbProvider.GetData(this, where, fieldNames)); break; } case "twitter": { string query2 = "", lang = ""; int page = 1; if (join.CinarTableOptions.ContainsKey("Query")) { query2 = (string)join.CinarTableOptions["Query"].Calculate(this); if (join.CinarTableOptions.ContainsKey("Lang")) lang = (string)join.CinarTableOptions["Lang"].Calculate(this); if (join.CinarTableOptions.ContainsKey("Page")) page = Convert.ToInt32(join.CinarTableOptions["Page"].Calculate(this)); TwitterProvider twProvider = new TwitterProvider(query2, lang, page); list.AddRange(twProvider.GetData(this, where, fieldNames)); } else throw new Exception("Provide query. Exp: select .. from Twitter(Query='...' [, Lang='tr'] [, Page=1])"); break; } case "youtube": { if (!join.CinarTableOptions.ContainsKey("Query")) throw new Exception("Provide query. Exp: select .. from Youtube(Query='...')"); string query = (string)join.CinarTableOptions["Query"].Calculate(this); YoutubeProvider ytProvider = new YoutubeProvider(query); list.AddRange(ytProvider.GetData(this, where, fieldNames)); break; } case "socialmedia": { if (!join.CinarTableOptions.ContainsKey("Query")) throw new Exception("Provide query. Exp: select .. from SocialMedia(Query='...' [, Lang='tr'] [, Source='Twitter,Facebook'] [, Page=1])"); string query = (string)join.CinarTableOptions["Query"].Calculate(this); string lang = ""; if (join.CinarTableOptions.ContainsKey("Lang")) lang = (string)join.CinarTableOptions["Lang"].Calculate(this); string source = "All"; if (join.CinarTableOptions.ContainsKey("Source")) source = (string)join.CinarTableOptions["Source"].Calculate(this); int page = 1; if (join.CinarTableOptions.ContainsKey("Page")) page = Convert.ToInt32(join.CinarTableOptions["Page"].Calculate(this)); SocialMediaProvider provider = new SocialMediaProvider(query, lang, page, source); list.AddRange(provider.GetData(this, where, fieldNames)); break; } case "yahoo": { string query2 = ""; if (join.CinarTableOptions.ContainsKey("Query")) { query2 = (string)join.CinarTableOptions["Query"].Calculate(this); YahooBossProvider twProvider = new YahooBossProvider(query2); list.AddRange(twProvider.GetData(this, where, fieldNames)); } else throw new Exception("Provide query. Exp: select .. from Yahoo(Query='...')"); break; } case "friendfeed": { string query2 = ""; if (join.CinarTableOptions.ContainsKey("Query")) { query2 = (string)join.CinarTableOptions["Query"].Calculate(this); FriendFeedProvider twProvider = new FriendFeedProvider(query2, ""); list.AddRange(twProvider.GetData(this, where, fieldNames)); } else throw new Exception("Provide query. Exp: select .. from Yahoo(Query='...')"); break; } case "dailymotion": { string query2 = "", lang = ""; if (join.CinarTableOptions.ContainsKey("Query")) { query2 = (string)join.CinarTableOptions["Query"].Calculate(this); if (join.CinarTableOptions.ContainsKey("Lang")) lang = (string)join.CinarTableOptions["Lang"].Calculate(this); DailyMotionProvider twProvider = new DailyMotionProvider(query2, lang); list.AddRange(twProvider.GetData(this, where, fieldNames)); } else throw new Exception("Provide query. Exp: select .. from Twitter(Query='...')"); break; } case "csv": { if (!join.CinarTableOptions.ContainsKey("Path") || !join.CinarTableOptions.ContainsKey("Seperator")) throw new Exception("Provide file path. Exp: select .. from CSV(Path='c:\\...', Seperator=';')"); string path = Convert.ToString(join.CinarTableOptions["Path"].Calculate(this)); char seperator = Convert.ToChar(join.CinarTableOptions["Seperator"].Calculate(this)); CSVProvider csvProvider = new CSVProvider(path, seperator); list.AddRange(csvProvider.GetData(this, where, fieldNames)); break; } } return list; }
internal List<Hashtable> GetData(Context context, Expression where, ListSelect fieldNames) { List<Hashtable> list = new List<Hashtable>(); SyndicationFeed s = new SyndicationFeed(); using (XmlTextReader reader = new XmlTextReader(url)) { SyndicationFeed client = SyndicationFeed.Load(reader); foreach (SyndicationItem rItem in client.Items) { RSSItem item = new RSSItem(rItem); if (item.Filter(context, where)) { Hashtable ht = new Hashtable(); foreach (Select field in fieldNames) ht[field.Alias] = field.Field.Calculate(context);//context.Variables[fieldName]; list.Add(ht); } } return list; } }
private List<Hashtable> getFileList(Context context, Expression where, ListSelect fieldNames, string dirPath) { List<Hashtable> list = new List<Hashtable>(); DirectoryInfo di = new DirectoryInfo(dirPath); foreach (FileSystemInfo fi in di.GetDirectories()) { FileItem item = new FileItem(fi); if (item.Filter(context, where)) { Hashtable ht = new Hashtable(); foreach (Select field in fieldNames) ht[field.Alias] = field.Field.Calculate(context);//context.Variables[fieldName]; list.Add(ht); if (recursive) list.AddRange(getFileList(context, where, fieldNames, fi.FullName)); } } foreach (FileSystemInfo fi in di.GetFiles()) { FileItem item = new FileItem(fi); if (item.Filter(context, where)) { Hashtable ht = new Hashtable(); foreach (Select field in fieldNames) ht[field.Alias] = field.Field.Calculate(context);//context.Variables[fieldName]; list.Add(ht); } } return list; }
public IsNullShortCut(Expression nullableExp, Expression notNullExp) { this.nullableExp = nullableExp; this.notNullExp = notNullExp; }
public MemberAccess(Expression leftChildExpression, Expression rightChildExpression) : base(leftChildExpression, rightChildExpression) { }
public Multiplication(Expression leftChildExpression, Expression rightChildExpression) : base(leftChildExpression, rightChildExpression) { }
internal List<Hashtable> GetData(Context context, Expression where, ListSelect fieldNames) { List<SocialMediaItem> items = new List<SocialMediaItem>(); if (source == "All" || source.IndexOf("Facebook", StringComparison.InvariantCultureIgnoreCase) > -1) foreach (FBPost item in new FacebookProvider(query).GetData()) items.Add(new SocialMediaItem(item)); if (source == "All" || source.IndexOf("Twitter", StringComparison.InvariantCultureIgnoreCase) > -1) foreach (Tweet item in new TwitterProvider(query, lang, page).GetData()) items.Add(new SocialMediaItem(item)); if (source == "All" || source.IndexOf("Youtube", StringComparison.InvariantCultureIgnoreCase) > -1) foreach (RSSItem item in new YoutubeProvider(query).GetData()) items.Add(new SocialMediaItem(item)); if (source == "All" || source.IndexOf("FriendFeed", StringComparison.InvariantCultureIgnoreCase) > -1) foreach (FriendFeedItem item in new FriendFeedProvider(query, lang).GetData()) items.Add(new SocialMediaItem(item)); if (source == "All" || source.IndexOf("DailyMotion", StringComparison.InvariantCultureIgnoreCase) > -1) foreach (DailyMotionItem item in new DailyMotionProvider(query, lang).GetData()) items.Add(new SocialMediaItem(item)); List<Hashtable> list = new List<Hashtable>(); foreach (SocialMediaItem item in items) { if (item.Filter(context, where)) { Hashtable ht = new Hashtable(); foreach (Select field in fieldNames) ht[field.Alias] = field.Field.Calculate(context); list.Add(ht); } } return list; }
public Negation(Expression childExpression) : base(childExpression) { }
internal List<Hashtable> GetData(Context context, Expression where, ListSelect fieldNames) { List<Hashtable> list = new List<Hashtable>(); var client = new Pop3Client(userName, password, server); client.OpenInbox(); while (client.NextEmail()) { POP3Item item = new POP3Item(client.ReadAsMailMessage()); if (item.Filter(context, where)) { Hashtable ht = new Hashtable(); foreach (Select field in fieldNames) ht[field.Alias] = field.Field.Calculate(context);//context.Variables[fieldName]; list.Add(ht); } } client.CloseConnection(); return list; }
private List<Hashtable> getColumnsOf(Type type, string tableName, Expression where, ListSelect fieldNames) { List<Hashtable> list = new List<Hashtable>(); foreach (PropertyInfo pi in type.GetProperties()) { if (pi.PropertyType == typeof(string) || pi.PropertyType.IsValueType || pi.PropertyType==typeof(byte[])) { if (pi.PropertyType.IsEnum) continue; Variables["COLUMN_DEFAULT"] = ""; Variables["DATA_TYPE"] = pi.PropertyType.Name; Variables["COLUMN_TYPE"] = pi.PropertyType.Name; Variables["CHARACTER_MAXIMUM_LENGTH"] = 65532; Variables["IS_NULLABLE"] = false; Variables["COLUMN_NAME"] = pi.Name; Variables["IS_AUTO_INCREMENT"] = false; Variables["TABLE_NAME"] = tableName; if (where==null || (bool)where.Calculate(this)) { Hashtable ht = new Hashtable(); foreach (Select field in fieldNames) ht[field.Alias] = field.Field.Calculate(this);//Variables[fieldName]; list.Add(ht); } } } return list; }