RcBuilder@walla.com
call centre: 054-5614020

Is Search Engine Bot

Posted by: RcBuilder  /   Category: HttpContext / HttpRequest / List / Reference Types / Search Engines / SEO / SOURCE CODE / UserAgent   /   No Comments
16
Nov
2014

Is Search Engine Bot public static bool IsSearchEngineBot(System.Web.HttpContext context) { List<string> robots = new List<string>(); robots.Add("googlebot"); robots.Add("spider"); robots.Add("yahoo"); robots.Add("architext"); robots.Add("baidu"); robots.Add("msnbot"); robots.Add("scooter"); robots.Add("slurp"); robots.Add("teoma"); robots.Add("yandex"); try { string userAgent = context.Request.UserAgent.ToLower(); if(userAgent == string.Empty) return false; foreach (string robot in robots) if (userAgent.Contains(robot)) return true; return false; } catch { return false;.

Read more

LINQ – Find vs Single vs First

Posted by: RcBuilder  /   Category: Dictionary / Lambda / Linq / List / Predicate   /   No Comments
12
Oct
2014

LINQ - Find vs Single vs First Find() get an item by primary key. return null if not exists. look in the context before going to the database (EF). Single() get an single item by an expression. throw an exception if not exists or there's more than one. SingleOrDefault() get an single item by an expression. return null if not exists. throw an exception if there's.

Read more

Convert To Dictionary

Posted by: RcBuilder  /   Category: Dictionary / Generic T / Lambda / Linq / List / SOURCE CODE   /   No Comments
05
Oct
2014

Convert To Dictionary using System; using System.Collections.Generic; using System.Linq; class ConvertToDictionary { private List<string> values = new List<string>() { "ROBY", "AVI", "ISSAC", "YOSSI", "IDAN", "SHARON" }; public void ConvertAnonymous() { var res = from item in values select new { MyName = item, item.Length }; Dictionary<string, int> dic = res.ToDictionary(k => k.MyName, k => k.Length); foreach (var keypair in dic) Console.WriteLine(keypair.Key + " = " + keypair.Value); } public.

Read more

Read Excel Specific Column

Posted by: RcBuilder  /   Category: ADO.NET / List / OleDb / SOURCE CODE   /   No Comments
16
Jul
2014

Read Excel Specific Column public static List<string> ReadExcelSpecificColumn(string excel_path, string sheet_name, int column_index) { List<string> values = new List<string>(); OleDbConnection conn = null; OleDbDataReader dr = null; try { string connStr = string.Format("Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source={0}; Extended Properties=Excel 8.0;", excel_path); string query = string.Format("Select * From ", sheet_name); conn = new OleDbConnection(connStr); OleDbCommand cmd = new OleDbCommand(query, conn); conn.Open(); dr = cmd.ExecuteReader(); if (dr == null) return.

Read more

List 2 String using Join T

Posted by: RcBuilder  /   Category: Generic T / List / SOURCE CODE   /   1 Comment
24
Jun
2014

List 2 String using Join T structure string.Join<T>(string Delimiter, List<T> list); string str = string.Join<string>(";", MyList); example public void Fun1(string Login) { Fun1(new List<string>(){ Login }); } public void Fun1(List<string> Logins) { string sLogins = string.Join<string>(";",.

Read more

ToParams – string extension

Posted by: RcBuilder  /   Category: Dictionary / Extensions / Linq / List / Reference Types / SOURCE CODE   /   1 Comment
28
May
2014

ToParams - string extension ResponseParams public class ResponseParams { private Dictionary<string, string> _prms = null; public ResponseParams() { _prms = new Dictionary<string, string>(); } public ResponseParams(IEnumerable<KeyValuePair<string, string>> prms) : this() { foreach (var p in prms) _prms = p.Value; } public string this { get { return _prms; } set { if (!_prms.ContainsKey(Name)) // new _prms.Add(Name, value); else // update _prms = value; } } } Extensions internal static class Extensions { public static ResponseParams ToParams(this string me){ var res = from.

Read more

Converter – Report Item 2 Csv Row

Posted by: RcBuilder  /   Category: Converters / Linq / List / SOURCE CODE   /   No Comments
04
May
2014

public class ReportItem { public Guid AccountId { set; get; } public string Email { set; get; } public string AccountStatus { set; get; } public string MainTP { set; get; } public string FirstName { set; get; } public string LastName { set; get; } public string OptIn { set; get; } public DateTime LastUpdate { set; get; } } public class Converters { public static.

Read more
  • פיתוח מערכות
  • פתרונות טכנולוגים
  • קידום אתרים
  • בניית אתרים