using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Collections.Specialized;
using System.Web.UI.WebControls;
//using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
using System.Reflection;
using System.Runtime.CompilerServices;
using EncryptionFunctions;
using System.Collections.Generic;
using System.Threading;
using Dataglobal;
using System.Text;
using System.Xml;
using StopListWords;
//using com.msn.search.soap;
using BingService;
using DenialofService;
using Enyim.Caching;
using Enyim.Caching.Memcached;
using Enyim.Caching.Configuration;
using System.Net;
using System.Net.Sockets;
public partial class MultiSearch : System.Web.UI.Page
{
Int64 Uid = 0;
Int32 SearchFlag = -1;
string strSQL;
int s;
int pages;
int rowperpages = 10;
// string QUERY_MACRO = " ()";
string _queryString = "";
public DataSet DatasetSearch;
protected int SR_SPELLING = 0;
protected int SR_IMAGE = 1;
protected int SR_WEB = 2;
// Replace with your own developer ID from http://search.live.com/developer
// string _APPID = "9FAD77179BF2CE6860F6EA74B53FCEB009D87EA2";
string _APPID = "3FDEA8A09B5F110EBBD310B78B0CA71217DF7ACE";
public string webResultsHTML;
LiteralControl webResultsCTL;
public bool IsFirstVisit()
{
if (Session["IsFirstVisit"] == null)
{
Session["IsFirstVisit"] = false;
return true;
}
else
{
return false;
}
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
// Check if revisit is valid or not
if (!base.IsPostBack)
{
// Block cookie less visit attempts
if (IsFirstVisit())
{
if (!ActionValidator.IsValid(ActionValidator.ActionTypeEnum.FirstVisit))
Response.End();
}
else
{
if (!ActionValidator.IsValid(ActionValidator.ActionTypeEnum.ReVisit))
Response.End();
}
}
else
{
// Limit number of postbacks
if (!ActionValidator.IsValid(ActionValidator.ActionTypeEnum.Postback))
Response.End();
}
}
protected void Page_Load(object sender, EventArgs e)
{
DateTime dt = DateTime.UtcNow;
Lblcache.Text = "Page Date UTC: " + (DateTime.UtcNow.ToString("MMM dd, yyyy")) + ", " + string.Format("{0:T}", dt);
TxtSearch.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('ctl00_ContentPlaceHolder1_BtnSearch').click();return false;}} else {return true}; ");
DDlistDiscipline.Attributes["onchange"] = "HideParametersResults();";
DDlistEnterprise.Attributes["onchange"] = "SetContextSearch();";
DDlistSearchType.Attributes["onchange"] = "SetContextSearch();";
RadioList.Attributes["onclick"] = "SetContextSearch2();";
TxtSearch.Attributes.Add("OnKeyPress", "SetContextSearchToggle();");
TxtCityState.Attributes.Add("OnKeyPress", "SetContextSearchToggle();");
Tcvdiv.Attributes.Add("style", "display:none");
if (hiddenvaluex.Value == "")
{
Div1.Attributes.Add("style", "display:none");
}
else
{
Div1.Attributes.Add("style", "display:block");
}
if (!IsPostBack)
{
{
Control GoogleAnalyticsUserControl = LoadControl("GoogleAnalytics.ascx");
Controls.Add(GoogleAnalyticsUserControl);
ViewState["Count"] = 0;
ViewState["Countpages"] = 0;
ChkLatest.Checked = false;
ViewState["LatestResults"] = false;
InitialUI();
string[] Months = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
DDlistDate.Items.Add("AnyDate");
DDliststartDate.Items.Add("AnyDate");
for (Int32 i = 0; i < 2; i++)
{
for (Int32 j = 0; j < 12; j++)
{
DDlistDate.Items.Add(Months[j] + " " + System.DateTime.Now.AddYears(i).Year.ToString());
}
}
for (Int32 i = -1; i < 1; i++)
{
for (Int32 j = 0; j < 12; j++)
{
DDliststartDate.Items.Add(Months[j] + " " + System.DateTime.Now.AddYears(i).Year.ToString());
}
}
SponsorshipDetails();
}
Response.Cache.SetExpires(DateTime.Now.AddSeconds(1800));
Response.Cache.SetCacheability(HttpCacheability.ServerAndPrivate);
Response.Cache.SetValidUntilExpires(true);
}
else
{
Response.Cache.SetNoServerCaching();
Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
Response.Cache.SetNoStore();
Response.Cache.SetExpires(new DateTime(1900, 01, 01, 00, 00, 00, 00));
//Response.Write("search" + DateTime.Now);
SponsorshipDetails();
ViewState["SearchAssist"] = TxtSearch.Text.ToString();
if (ViewState["SearchAssist"].ToString() != "")
{
SearchAssistBindHtml(ViewState["SearchAssist"].ToString());
}
}
}
private void InitialUI()
{
searchpanel.Visible = true;
PageTop.Visible = false;
PageBottom.Visible = false;
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
TxtSearch.Focus();
MessageEnterpriseLabel.Width = 650;
MessageEnterpriseLabel.Text = " Enter Search Query ";
}
public bool ValidateQuery()
{
if ((DDlistEnterprise.SelectedValue == "Individual") & (DDlistDiscipline.SelectedValue == "Any"))
{
PageTop.Visible = false;
PageBottom.Visible = false;
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
MessageEnterpriseLabel.Text = "For Individuals Search (Search Category) must be selected";
MessageEnterpriseLabel.Width = 770;
return false;
}
if (TxtSearch.Text.Trim() == "")
{
PageTop.Visible = false;
PageBottom.Visible = false;
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
MessageEnterpriseLabel.Text = "Enter Search Query";
MessageEnterpriseLabel.Width = 650;
return false;
}
else
{
return true;
}
}
protected void ButtonSearch_Click(object sender, EventArgs e)
{
UIManipulations();
if (ValidateQuery())
{
ViewState["hit"] = 0;
ViewState["SearchText"] = TxtSearch.Text.ToString().Trim();
ViewState["SearchState"] = TxtCityState.Text.ToString().Trim();
if (ChkLatest.Checked == true)
{
ViewState["LatestResults"] = true;
}
else
{
ViewState["LatestResults"] = false;
}
TxtPageBox.Text = "";
TxtPageBox2.Text = "";
if (DDlistSearchType.SelectedValue.ToLower() == "Web".ToLower())
{
try
{
string search = WebSearchEngineQuery();
if (search.StartsWith("#"))
{
MessageEnterpriseLabel.Text = "#Tag Assist keywords- not allowed for Web Search";
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
PageTop.Visible = false;
PageBottom.Visible = false;
}
else
{
Searchweb(search + " " + ViewState["SearchState"].ToString().Trim());
MessageEnterpriseLabel.Text = "Web search Results";
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
PageTop.Visible = false;
PageBottom.Visible = false;
}
}
catch
{
MessageEnterpriseLabel.Text = "Web Search Engine: Failure";
}
}
else
{
string search = WebSearchEngineQuery();
if (DDlistSearchType.SelectedValue.ToLower() == "Content".ToLower())
{
if (search.StartsWith("#"))
{
MessageEnterpriseLabel.Text = "#Tag Assist keywords- not allowed for Content Search";
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
PageTop.Visible = false;
PageBottom.Visible = false;
}
else
{
populateSearch();
}
}
else if (DDlistSearchType.SelectedValue.ToLower() == "Company".ToLower())
{
if (search.StartsWith("#"))
{
MessageEnterpriseLabel.Text = "#Tag Assist keywords- not allowed for Enterprise or Individuals ";
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
PageTop.Visible = false;
PageBottom.Visible = false;
}
else
{
populateSearch();
}
}
else
{
populateSearch();
}
}
}
PropertyInfo isreadonly = typeof(System.Collections.Specialized.NameValueCollection).GetProperty("IsReadOnly", BindingFlags.Instance | BindingFlags.NonPublic);
// make collection editable
isreadonly.SetValue(this.Request.QueryString, false, null);//
String SessID = Session.SessionID;
this.Request.QueryString.Set("tx", SessID);// make collection readonly again
isreadonly.SetValue(this.Request.QueryString, true, null);
}
private void UIManipulations()
{
Tcvdiv.Attributes.Add("style", "display:none");
//Divmain.Visible = false;
//HyperLinksmallX.Visible = false;
MessageEnterpriseLabel.Width = 1075;
}
private string L2CacheSearchPattern()
{
string _CachePattern = "";
string SearchQuery = ViewState["SearchText"].ToString().Trim().Replace("&", "ampx").ToLower();
string Continent = DDlistWorld.SelectedValue.ToString().Substring(0, 3);
string Category = DDlistDiscipline.Text.Trim();
string ReqOfering = DDlistReqOffering.Text.Trim().Substring(0, 3); ;
string Country = DDlsubCountry.Text.Trim();
string contentkeywordwebename = DDlistSearchType.SelectedValue.ToString().Substring(0, 3); ;
string Enterprise = DDlistEnterprise.SelectedValue.ToString().Substring(0, 3); ;
string StateCity = ViewState["SearchState"].ToString().ToLower(); ;
string dt1 = DDliststartDate.SelectedValue.ToString();
string dt2 = DDlistDate.SelectedValue.ToString();
_CachePattern = SearchQuery + "C" + "#A1_" + Continent + "#B1_" + Category + "#C1_" + ReqOfering + "#D1_" + Country + "#E1_" + contentkeywordwebename + "#F1" + Enterprise + "#G1" + StateCity + "#H1" + dt1 + "#I1" + dt2;
string LatestBroadcastDays = "";
if ((bool)ViewState["LatestResults"] == true)
{
LatestBroadcastDays = DDListDays.SelectedValue.ToString();
_CachePattern = _CachePattern + "#X1" + LatestBroadcastDays;
}
return _CachePattern;
}
protected void ButtonSearch1_Click(object sender, EventArgs e)
{
DDlistSearchType.SelectedValue = "Keyword";
if (ChkLatest.Checked == true)
{
ViewState["LatestResults"] = true;
}
else
{
ViewState["LatestResults"] = false;
}
UIManipulations();
if (ValidateQuery())
{
ViewState["hit"] = 0;
ViewState["SearchText"] = TxtSearch.Text.ToString().Trim();
ViewState["SearchState"] = TxtCityState.Text.ToString().Trim();
TxtPageBox.Text = "";
TxtPageBox2.Text = "";
if (DDlistSearchType.SelectedValue.ToLower() == "Web".ToLower())
{
try
{
string search = WebSearchEngineQuery();
if (search.StartsWith("#"))
{
MessageEnterpriseLabel.Text = "#Tag Assist keywords- not allowed for Web";
}
else
{
Searchweb(search + " " + ViewState["SearchState"].ToString().Trim());
MessageEnterpriseLabel.Text = "Web search Results";
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
PageTop.Visible = false;
PageBottom.Visible = false;
}
}
catch
{
MessageEnterpriseLabel.Text = "Web Search Engine: Failure";
}
}
else
{
string search = WebSearchEngineQuery();
if (DDlistSearchType.SelectedValue.ToLower() == "Content".ToLower())
{
if (search.StartsWith("#"))
{
MessageEnterpriseLabel.Text = "#Tag Assist keywords- not allowed for Content Search ";
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
PageTop.Visible = false;
PageBottom.Visible = false;
}
else
{
populateSearch();
}
}
else if (DDlistSearchType.SelectedValue.ToLower() == "Company".ToLower())
{
if (search.StartsWith("#"))
{
MessageEnterpriseLabel.Text = "#Tag Assist keywords- not allowed for Enterprise or Individuals ";
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
PageTop.Visible = false;
PageBottom.Visible = false;
}
else
{
populateSearch();
}
}
else
{
populateSearch();
}
}
}
PropertyInfo isreadonly = typeof(System.Collections.Specialized.NameValueCollection).GetProperty("IsReadOnly", BindingFlags.Instance | BindingFlags.NonPublic);
// make collection editable
isreadonly.SetValue(this.Request.QueryString, false, null);//
String SessID = Session.SessionID;
this.Request.QueryString.Set("tx", SessID);// make collection readonly again
isreadonly.SetValue(this.Request.QueryString, true, null);
}
protected void ButtonSearch2_Click(object sender, EventArgs e)
{
DDlistSearchType.SelectedValue = "Content";
if (ChkLatest.Checked == true)
{
ViewState["LatestResults"] = true;
}
else
{
ViewState["LatestResults"] = false;
}
UIManipulations();
if (ValidateQuery())
{
ViewState["hit"] = 0;
ViewState["SearchText"] = TxtSearch.Text.ToString().Trim();
ViewState["SearchState"] = TxtCityState.Text.ToString().Trim();
TxtPageBox.Text = "";
TxtPageBox2.Text = "";
if (DDlistSearchType.SelectedValue.ToLower() == "Web".ToLower())
{
try
{
string search = WebSearchEngineQuery();
if (search.StartsWith("#"))
{
MessageEnterpriseLabel.Text = "#Tag Assist keywords- not allowed for Web Search";
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
PageTop.Visible = false;
PageBottom.Visible = false;
}
else
{
Searchweb(search + " " + ViewState["SearchState"].ToString().Trim());
MessageEnterpriseLabel.Text = "Web search Results";
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
PageTop.Visible = false;
PageBottom.Visible = false;
}
}
catch
{
MessageEnterpriseLabel.Text = "Web Search Engine: Failure";
}
}
else
{
string search = WebSearchEngineQuery();
if (DDlistSearchType.SelectedValue.ToLower() == "Content".ToLower())
{
if (search.StartsWith("#"))
{
MessageEnterpriseLabel.Text = "#Tag Assist keywords- not allowed for Content search ";
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
PageTop.Visible = false;
PageBottom.Visible = false;
}
else
{
populateSearch();
}
}
else if (DDlistSearchType.SelectedValue.ToLower() == "Company".ToLower())
{
if (search.StartsWith("#"))
{
MessageEnterpriseLabel.Text = "#Tag Assist keywords- not allowed for Enterprise or Individuals Search ";
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
PageTop.Visible = false;
PageBottom.Visible = false;
}
else
{
populateSearch();
}
}
else
{
populateSearch();
}
}
}
PropertyInfo isreadonly = typeof(System.Collections.Specialized.NameValueCollection).GetProperty("IsReadOnly", BindingFlags.Instance | BindingFlags.NonPublic);
// make collection editable
isreadonly.SetValue(this.Request.QueryString, false, null);//
String SessID = Session.SessionID;
this.Request.QueryString.Set("tx", SessID);// make collection readonly again
isreadonly.SetValue(this.Request.QueryString, true, null);
}
protected void ButtonSearch3_Click(object sender, EventArgs e)
{
DDlistSearchType.SelectedValue = "Company";
if (ChkLatest.Checked == true)
{
ViewState["LatestResults"] = true;
}
else
{
ViewState["LatestResults"] = false;
}
UIManipulations();
if (ValidateQuery())
{
ViewState["hit"] = 0;
ViewState["SearchText"] = TxtSearch.Text.ToString().Trim();
ViewState["SearchState"] = TxtCityState.Text.ToString().Trim();
TxtPageBox.Text = "";
TxtPageBox2.Text = "";
if (DDlistSearchType.SelectedValue.ToLower() == "Web".ToLower())
{
try
{
string search = WebSearchEngineQuery();
if (search.StartsWith("#"))
{
MessageEnterpriseLabel.Text = "#Tag Assist keywords- not allowed for Web Search ";
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
PageTop.Visible = false;
PageBottom.Visible = false;
}
else
{
Searchweb(search + " " + ViewState["SearchState"].ToString().Trim());
MessageEnterpriseLabel.Text = "Web search Results";
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
PageTop.Visible = false;
PageBottom.Visible = false;
}
}
catch
{
MessageEnterpriseLabel.Text = "Web Search Engine: Failure";
}
}
else
{
string search = WebSearchEngineQuery();
if (DDlistSearchType.SelectedValue.ToLower() == "Content".ToLower())
{
if (search.StartsWith("#"))
{
MessageEnterpriseLabel.Text = "#Tag Assist keywords- not allowed for Content search";
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
PageTop.Visible = false;
PageBottom.Visible = false;
}
else
{
populateSearch();
}
}
else if (DDlistSearchType.SelectedValue.ToLower() == "Company".ToLower())
{
if (search.StartsWith("#"))
{
MessageEnterpriseLabel.Text = "#Tag Assist keywords- not allowed for Enterprise or Individuals search";
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
PageTop.Visible = false;
PageBottom.Visible = false;
}
else
{
populateSearch();
}
}
else
{
populateSearch();
}
}
}
PropertyInfo isreadonly = typeof(System.Collections.Specialized.NameValueCollection).GetProperty("IsReadOnly", BindingFlags.Instance | BindingFlags.NonPublic);
// make collection editable
isreadonly.SetValue(this.Request.QueryString, false, null);//
String SessID = Session.SessionID;
this.Request.QueryString.Set("tx", SessID);// make collection readonly again
isreadonly.SetValue(this.Request.QueryString, true, null);
}
protected void ButtonSearch4_Click(object sender, EventArgs e)
{
DDlistSearchType.SelectedValue = "Web";
if (ChkLatest.Checked == true)
{
ViewState["LatestResults"] = true;
}
else
{
ViewState["LatestResults"] = false;
}
UIManipulations();
if (ValidateQuery())
{
ViewState["hit"] = 0;
ViewState["SearchText"] = TxtSearch.Text.ToString().Trim();
ViewState["SearchState"] = TxtCityState.Text.ToString().Trim();
TxtPageBox.Text = "";
TxtPageBox2.Text = "";
if (DDlistSearchType.SelectedValue.ToLower() == "Web".ToLower())
{
try
{
string search = WebSearchEngineQuery();
if (search.StartsWith("#"))
{
MessageEnterpriseLabel.Text = "#Tag Assist keywords- not allowed for Web Search ";
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
PageTop.Visible = false;
PageBottom.Visible = false;
}
else
{
Searchweb(search + " " + ViewState["SearchState"].ToString().Trim());
MessageEnterpriseLabel.Text = "Web search Results";
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
PageTop.Visible = false;
PageBottom.Visible = false;
}
}
catch
{
MessageEnterpriseLabel.Text = "Web Search Engine: Failure";
}
}
else
{
string search = WebSearchEngineQuery();
if (DDlistSearchType.SelectedValue.ToLower() == "Content".ToLower())
{
if (search.StartsWith("#"))
{
MessageEnterpriseLabel.Text = "#Tag Assist keywords- not allowed for Content Search";
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
PageTop.Visible = false;
PageBottom.Visible = false;
}
else
{
populateSearch();
}
}
else if (DDlistSearchType.SelectedValue.ToLower() == "Company".ToLower())
{
if (search.StartsWith("#"))
{
MessageEnterpriseLabel.Text = "#Tag Assist keywords- not allowed for Enterprise or Individuals ";
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
PageTop.Visible = false;
PageBottom.Visible = false;
}
else
{
populateSearch();
}
}
else
{
populateSearch();
}
}
}
PropertyInfo isreadonly = typeof(System.Collections.Specialized.NameValueCollection).GetProperty("IsReadOnly", BindingFlags.Instance | BindingFlags.NonPublic);
// make collection editable
isreadonly.SetValue(this.Request.QueryString, false, null);//
String SessID = Session.SessionID;
this.Request.QueryString.Set("tx", SessID);// make collection readonly again
isreadonly.SetValue(this.Request.QueryString, true, null);
}
protected void ButtonPage_Click(object sender, EventArgs e)
{
if (ChkLatest.Checked == true)
{
ViewState["LatestResults"] = true;
}
else
{
ViewState["LatestResults"] = false;
}
if (TxtPageBox.Text == "")
{
TxtPageBox.Text = "1";
}
try
{
if (Int64.Parse(TxtPageBox.Text.ToString().Trim()) > Int64.Parse(ViewState["pages"].ToString()))
{
ViewState["hit"] = ViewState["pages"].ToString();
TxtPageBox.Text = ViewState["pages"].ToString();
TxtPageBox2.Text = ViewState["pages"].ToString();
}
else
{
ViewState["hit"] = TxtPageBox.Text.ToString().Trim();
TxtPageBox2.Text = TxtPageBox.Text.ToString().Trim();
}
}
catch
{
MessageEnterpriseLabel.Text = "Incorrect Page Number Entered";
string scriptSource = "HideParametersResultsError();";
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "testFunction31", scriptSource, true);
return;
}
UIManipulations();
populateSearch();
}
protected void ButtonPage2_Click(object sender, EventArgs e)
{
if (ChkLatest.Checked == true)
{
ViewState["LatestResults"] = true;
}
else
{
ViewState["LatestResults"] = false;
}
if (TxtPageBox2.Text == "")
{
TxtPageBox2.Text = "1";
}
try
{
if (Int64.Parse(TxtPageBox2.Text.ToString().Trim()) > Int64.Parse(ViewState["pages"].ToString()))
{
ViewState["hit"] = ViewState["pages"].ToString();
TxtPageBox.Text = ViewState["pages"].ToString();
TxtPageBox2.Text = ViewState["pages"].ToString();
}
else
{
ViewState["hit"] = TxtPageBox2.Text.ToString().Trim();
TxtPageBox.Text = TxtPageBox2.Text.ToString().Trim();
}
}
catch
{
MessageEnterpriseLabel.Text = "Incorrect Page Number Entered";
string scriptSource = "HideParametersResultsError();";
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "testFunction32", scriptSource, true);
return;
}
UIManipulations();
populateSearch();
}
protected void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
if (ChkLatest.Checked == true)
{
ViewState["LatestResults"] = true;
}
else
{
ViewState["LatestResults"] = false;
}
ViewState["hit"] = DropDownList1.SelectedValue.Trim().ToString();
DropDownList2.SelectedValue = ViewState["hit"].ToString();
TxtPageBox.Text = ViewState["hit"].ToString();
TxtPageBox2.Text = ViewState["hit"].ToString();
UIManipulations();
populateSearch();
}
protected void DropDownList2_SelectedIndexChanged(object sender, System.EventArgs e)
{
if (ChkLatest.Checked == true)
{
ViewState["LatestResults"] = true;
}
else
{
ViewState["LatestResults"] = false;
}
ViewState["hit"] = DropDownList2.SelectedValue.Trim().ToString();
DropDownList1.SelectedValue = ViewState["hit"].ToString();
TxtPageBox.Text = ViewState["hit"].ToString();
TxtPageBox2.Text = ViewState["hit"].ToString();
UIManipulations();
populateSearch();
}
protected void ButtonPrev_Click(object sender, EventArgs e)
{
if (ChkLatest.Checked == true)
{
ViewState["LatestResults"] = true;
}
else
{
ViewState["LatestResults"] = false;
}
ViewState["hit"] = Int64.Parse(ViewState["hit"].ToString()) - 1;
if (Int64.Parse(ViewState["hit"].ToString()) == 0 || Int64.Parse(ViewState["hit"].ToString()) == -1)
{
ViewState["hit"] = 1;
}
TxtPageBox.Text = ViewState["hit"].ToString();
TxtPageBox2.Text = ViewState["hit"].ToString();
UIManipulations();
populateSearch();
}
protected void ButtonNext_Click(object sender, EventArgs e)
{
if (ChkLatest.Checked == true)
{
ViewState["LatestResults"] = true;
}
else
{
ViewState["LatestResults"] = false;
}
if (Int64.Parse(ViewState["hit"].ToString()) == 0)
{
ViewState["hit"] = 1;
}
ViewState["hit"] = Int64.Parse(ViewState["hit"].ToString()) + 1;
if (Int64.Parse(ViewState["hit"].ToString()) >= Int64.Parse(ViewState["pages"].ToString()))
{
ViewState["hit"] = Int64.Parse(ViewState["pages"].ToString());
}
TxtPageBox.Text = ViewState["hit"].ToString();
TxtPageBox2.Text = ViewState["hit"].ToString();
UIManipulations();
populateSearch();
}
protected void ButtonPrevBottom_Click(object sender, EventArgs e)
{
if (ChkLatest.Checked == true)
{
ViewState["LatestResults"] = true;
}
else
{
ViewState["LatestResults"] = false;
}
ViewState["hit"] = Int64.Parse(ViewState["hit"].ToString()) - 1;
if (Int64.Parse(ViewState["hit"].ToString()) == 0 || Int64.Parse(ViewState["hit"].ToString()) == -1)
{
ViewState["hit"] = 1;
}
TxtPageBox.Text = ViewState["hit"].ToString();
TxtPageBox2.Text = ViewState["hit"].ToString();
UIManipulations();
populateSearch();
}
protected void ButtonNextBottom_Click(object sender, EventArgs e)
{
if (ChkLatest.Checked == true)
{
ViewState["LatestResults"] = true;
}
else
{
ViewState["LatestResults"] = false;
}
if (Int64.Parse(ViewState["hit"].ToString()) == 0)
{
ViewState["hit"] = 1;
}
ViewState["hit"] = Int64.Parse(ViewState["hit"].ToString()) + 1;
if (Int64.Parse(ViewState["hit"].ToString()) >= Int64.Parse(ViewState["pages"].ToString()))
{
ViewState["hit"] = Int64.Parse(ViewState["pages"].ToString());
}
TxtPageBox.Text = ViewState["hit"].ToString();
TxtPageBox2.Text = ViewState["hit"].ToString();
UIManipulations();
populateSearch();
}
public void SponsorshipDetails()
{
XmlDocument xmldoc = new XmlDocument();
// Get the XML file path
string xmlFilePath = Server.MapPath("~") + "/Sponsorship/Adrot.xml";
// Load the XML File
xmldoc.Load(xmlFilePath);
XmlNodeList xmlnode = xmldoc.GetElementsByTagName("Ad");
Table MainSponsorshipTable = new Table();
TableRow R1 = new TableRow();
TableCell Announcement = new TableCell();
Announcement.Text = " [ This space is classified for selected World Changing Promotions and for announcements of Large scale emergencies.Contact T&C Vectors. ] ";
Announcement.Width = 255;
for (int i = 0; i < 1; i++)
{
string strNavigate = xmlnode[i].ChildNodes[0].InnerText;
// update Description
string strCompany = xmlnode[i].ChildNodes[1].InnerText;
// update Active
string strCaption = xmlnode[i].ChildNodes[2].InnerText;
System.Web.UI.WebControls.HyperLink but = new System.Web.UI.WebControls.HyperLink();
but.Target = "_blank";
if (strNavigate != "")
{
but.NavigateUrl = "http://" + strNavigate;
but.ForeColor = System.Drawing.Color.YellowGreen;
}
else
{
but.NavigateUrl = "";
but.ForeColor = System.Drawing.Color.YellowGreen;
}
if (strNavigate.Length >= 25)
{
but.Text = strNavigate.Substring(0, 25);
}
else
{
but.Text = strNavigate;
}
Label Company = new Label();
if (strCompany.Length >= 25)
{
Company.Text = strCompany.Substring(0, 25);
}
else
{
Company.Text = strCompany;
}
Label Caption = new Label();
if (strCaption.Length >= 35)
{
Caption.Text = strCaption.Substring(0, 35);
}
else
{
Caption.Text = strCaption;
}
TableRow Hyperlinkrow1 = new TableRow();
TableCell HyperCell1 = new TableCell();
HyperCell1.Controls.Add(Company);
HyperCell1.Font.Bold = true;
HyperCell1.Font.Size = 10;
HyperCell1.Font.Name = "Arial";
HyperCell1.ForeColor = System.Drawing.Color.Black;
HyperCell1.HorizontalAlign = HorizontalAlign.Center;
Hyperlinkrow1.Cells.Add(HyperCell1);
TableRow Hyperlinkrow2 = new TableRow();
TableCell HyperCell2 = new TableCell();
HyperCell2.Controls.Add(Caption);
HyperCell2.Font.Bold = true;
HyperCell2.Font.Size = 10;
HyperCell2.Font.Name = "Arial";
HyperCell2.ForeColor = System.Drawing.Color.Black;
HyperCell2.HorizontalAlign = HorizontalAlign.Center;
//Hyperlinkrow1.Cells.Add(HyperCell1);
Hyperlinkrow2.Cells.Add(HyperCell2);
TableRow Hyperlinkrow3 = new TableRow();
TableCell HyperCell3 = new TableCell();
HyperCell3.Controls.Add(but);
HyperCell3.Font.Bold = true;
HyperCell3.Font.Size = 10;
HyperCell3.Font.Name = "Arial";
HyperCell3.ForeColor = System.Drawing.Color.GreenYellow;
HyperCell3.HorizontalAlign = HorizontalAlign.Center;
//Hyperlinkrow1.Cells.Add(HyperCell1);
Hyperlinkrow3.Cells.Add(HyperCell3);
TableRow Row = new TableRow();
Table T1 = new Table();
// T1.Width = 235;
T1.Rows.Add(Hyperlinkrow1);
T1.Rows.Add(Hyperlinkrow2);
T1.Rows.Add(Hyperlinkrow3);
TableCell FinalCell = new TableCell();
FinalCell.Controls.Add(T1);
R1.Controls.Add(FinalCell);
MainSponsorshipTable.Rows.Add(R1);
}
TableCell x1 = new TableCell();
x1.Controls.Add(MainSponsorshipTable);
// Sponsorship.Controls.Add(new LiteralControl("
"));
Sponsorship.Controls.Add(new LiteralControl("This Space is Sponsored by"));
Sponsorship.Controls.Add(new LiteralControl("
"));
TableRow Rx = new TableRow();
// Rx.Controls.Add(Announcement);
Rx.Controls.Add(x1);
Table FinalTable = new Table();
FinalTable.Controls.Add(Rx);
Sponsorship.Controls.Add(FinalTable);
Sponsorship.Controls.Add(new LiteralControl("
"));
}
public string[] Advertisements(Int32 i)
{
XmlDocument xmldoc = new XmlDocument();
// Get the XML file path
string xmlFilePath = Server.MapPath("~") + "/Sponsorship/Adrot.xml";
// Load the XML File
xmldoc.Load(xmlFilePath);
XmlNodeList xmlnode = xmldoc.GetElementsByTagName("Ad");
Table MainSponsorshipTable = new Table();
TableRow R1 = new TableRow();
TableCell Announcement = new TableCell();
Announcement.Text = " [ This space is classified for selected World Changing Promotions and for announcements of Large scale emergencies.Contact T&C Vectors. ] ";
Announcement.Width = 255;
string strNavigate = xmlnode[i].ChildNodes[0].InnerText;
// update Description
string strCompany = xmlnode[i].ChildNodes[1].InnerText;
// update Active
string strCaption = xmlnode[i].ChildNodes[2].InnerText;
string[] ads = new string[3];
ads[0] = strNavigate;
ads[1] = strCompany;
ads[2] = strCaption;
return ads;
}
public void populateSearch()
{
if (ViewState["hit"].ToString() == "0")
{
try
{
if (DDlistEnterprise.SelectedValue.ToString().ToLower() == "Any".ToLower())
{
SuperSearchPart1();
}
else
{
FetchCommnd();
FetchCommnd2();
bind_table();
}
}
catch (Exception ex)
{
MessageEnterpriseLabel.Text = "Critical Data Error.Try again after some time.";
MessageEnterpriseLabel.Width = 650;
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
PageTop.Visible = false;
PageBottom.Visible = false;
}
}
else
{
try
{
if (DDlistEnterprise.SelectedValue.ToString().ToLower() == "Any".ToLower())
{
SuperSearchPart1();
}
else
{
FetchCommnd2();
bind_table();
}
}
catch
{
MessageEnterpriseLabel.Text = "Critical Data Error.Try again after some time.";
MessageEnterpriseLabel.Width = 650;
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
PageTop.Visible = false;
PageBottom.Visible = false;
}
}
}
public void SuperSearchPart1()
{
DataSet SuperResults = new DataSet();
DataSet[] DatasetArray = new DataSet[5];
Int32 count = 0;
try
{
SuperResults = FetchCommndSuperResults();
if (ViewState["hit"].ToString() == "0")
{
if (Int64.Parse(ViewState["Super"].ToString()) > 0)
{
BtnPageHit.Enabled = true;
BtnPageHit2.Enabled = true;
PageTop.Visible = true;
PageBottom.Visible = true;
MessageEnterpriseLabel.Text = "";
}
if (Int64.Parse(ViewState["Super"].ToString()) > 0 & Int64.Parse(ViewState["Super"].ToString()) < 1)
{
BtnPageHit.Enabled = true;
BtnPageHit2.Enabled = true;
PageTop.Visible = true;
PageBottom.Visible = true;
try
{
string search = WebSearchEngineQuery();
if (search.StartsWith("#"))
{
MessageEnterpriseLabel.Text = DDlistEnterprise.SelectedItem + " - Inter-Xect Broadcast Search Results only";
}
else
{
Searchweb(search + " " + ViewState["SearchState"].ToString().Trim());
MessageEnterpriseLabel.Text = DDlistEnterprise.SelectedItem.ToString().Substring(0, 12) + " - Inter-Xect broadcast Search Results ";
}
}
catch
{
MessageEnterpriseLabel.Text = "Web Search Engine: Failure";
}
}
if (Int64.Parse(ViewState["Super"].ToString()) < 1)
{
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
PageTop.Visible = false;
PageBottom.Visible = false;
try
{
string search = WebSearchEngineQuery();
if (search.StartsWith("#"))
{
MessageEnterpriseLabel.Text = "No Search Results - Available";
}
else
{
Searchweb(search + " " + ViewState["SearchState"].ToString().Trim());
MessageEnterpriseLabel.Text = "No Broadcast Search Results Found -showing Web search results";
}
}
catch
{
MessageEnterpriseLabel.Text = "Web Search Engine: Failure";
}
}
if (Int64.Parse(ViewState["Super"].ToString()) >= 1)
{
MessageEnterpriseLabel.Text = DDlistEnterprise.SelectedItem + " - Inter-Xect Broadcast Search Results";
}
ViewState["pages"] = (Int32.Parse(ViewState["Super"].ToString()) / rowperpages);
if (((Int32.Parse(ViewState["Super"].ToString()) - (Int32.Parse(ViewState["pages"].ToString()) * rowperpages)) > 0))
{
ViewState["pages"] = (Int32.Parse(ViewState["pages"].ToString()) + 1);
}
int i;
DropDownList1.Items.Clear();
DropDownList2.Items.Clear();
for (i = 1; (i <= Int32.Parse(ViewState["pages"].ToString())); i++)
{
DropDownList1.Items.Add(i.ToString());
DropDownList2.Items.Add(i.ToString());
if (i >= 20)
{
break;
}
}
LblMaxPages.Text = Int32.Parse(ViewState["pages"].ToString()) + " :Total Pages";
LblMaxPages2.Text = Int32.Parse(ViewState["pages"].ToString()) + " :Total Pages"; ;
}
//---------------The difference between the normal search and super search is that we fetch the data(all records) once in a dataset and get the count and data, where
//as in the normal query we fetch count and then the data(Only 10 records from sql server).
bind_tableSuper(SuperResults);
}
catch
{
MessageEnterpriseLabel.Text = "Critical Data Error.Try again after some time.";
MessageEnterpriseLabel.Width = 650;
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
PageTop.Visible = false;
PageBottom.Visible = false;
}
}
public delegate void DatabaseDelegate(SqlDataAdapter dbstring, out DataSet i, SqlConnection conn);
public DataSet FetchCommndSuperResults()
{
DataSet DatasetSuperResults = new DataSet();
DataSet SuperResults = new DataSet();
DataSet SuperResultsFinal = new DataSet();
DataTable Datafinal = new DataTable();
try
{
DatabaseDelegate[] DDArray = new DatabaseDelegate[5];
IAsyncResult[] DDResult = new IAsyncResult[5];
DataSet[] TempDataSet = new DataSet[5];
MultiSearch mx = new MultiSearch();
try
{
//C:\mem>memcached.exe -d start
//C:\mem>memcached.exe -d stop
//C:\mem>memcached.exe -d uninstall
//C:\mem>memcached.exe -d install -m 512 -p 8081 -l 127.0.0.1
//C:\mem>memcached.exe -d start
//C:\mem>memcached.exe -d stop
//C:\mem>memcached.exe -d uninstall
//C:\mem>memcached.exe -d install -m 512 -p 11211 -l 127.0.0.1
//C:\mem>memcached.exe -d start
Enyim.Caching.Configuration.MemcachedClientConfiguration config = new Enyim.Caching.Configuration.MemcachedClientConfiguration();
IPEndPoint endpoint = new IPEndPoint(System.Net.IPAddress.Parse("127.0.0.1"), 11211);
config.Servers.Add(endpoint);
config.Protocol = Enyim.Caching.Memcached.MemcachedProtocol.Text; //you must set a protocol
Enyim.Caching.MemcachedClient mc = new Enyim.Caching.MemcachedClient(config);
int z = (Int32.Parse(ViewState["hit"].ToString()));
if (z == 0)
{
z = 1;
}
String CachePattern3 = L2CacheSearchPattern();
CachePattern3 = CachePattern3 + "Super" + z;
String Cache_Total_Count = CachePattern3 + "Count";
CachePattern3 = Oneway(CachePattern3);
Cache_Total_Count = Oneway(Cache_Total_Count);
object cachedObject_Count;
cachedObject_Count = mc.Get(Cache_Total_Count);
object cachedObject3;
cachedObject3 = mc.Get(CachePattern3);
if (cachedObject3 != null && cachedObject_Count != null)
{
SuperResultsFinal = (DataSet)cachedObject3;
Int64 countx = SuperResultsFinal.Tables[0].Rows.Count;
Int32 CacheCount = (Int32)cachedObject_Count;
ViewState["Super"] = CacheCount;
Lblz.Text = "High-speed-cache";
Lblz.ForeColor = System.Drawing.Color.Silver;
Lblz.Font.Size = FontUnit.Small;
}
else
{
Int32 ThreadCount = 0;
string[] DatabaseList = new string[] { "Large", "Medium", "Small", "University", "Community" };
foreach (string db in DatabaseList)
{
SqlConnection conn = new SqlConnection(GetConnectionStringAllDatabases(db));
conn.Open();
SqlCommand FetchCommandx = QueryFormsuper(conn);
SqlDataAdapter myDataAdapter = new SqlDataAdapter(FetchCommandx);
SqlCommandBuilder cmdBldr = new SqlCommandBuilder(myDataAdapter);
DDArray[ThreadCount] = new DatabaseDelegate(mx.DatabaseLevelThread);
DDResult[ThreadCount] = DDArray[ThreadCount].BeginInvoke(myDataAdapter, out TempDataSet[ThreadCount], conn, null, null);
ThreadCount = ThreadCount + 1;
}
DDArray[0].EndInvoke(out TempDataSet[0], DDResult[0]);
DDArray[1].EndInvoke(out TempDataSet[1], DDResult[1]);
DDArray[2].EndInvoke(out TempDataSet[2], DDResult[2]);
DDArray[3].EndInvoke(out TempDataSet[3], DDResult[3]);
DDArray[4].EndInvoke(out TempDataSet[4], DDResult[4]);
for (Int32 i = 0; i < 5; i++)
{
DatasetSuperResults.Merge(TempDataSet[i]);
}
SuperResults = DatasetSuperResults;
Int32 StartCount = 0;
Int32 count = 0;
Int32 Maxrow = 0;
count = SuperResults.Tables[0].Rows.Count;
var resultCount = mc.Store(Enyim.Caching.Memcached.StoreMode.Set, Cache_Total_Count, count, TimeSpan.FromHours(8.00));
ViewState["Super"] = count;
Int32 remainder = Int32.Parse(ViewState["Super"].ToString()) % rowperpages;
Datafinal = SuperResults.Tables[0].Clone();
int y = (Int32.Parse(ViewState["hit"].ToString()) - 1);
if ((y == 0) || (y == -1))
{
ViewState["SqlStartPageNos"] = 0;
if (remainder == 0 && Int32.Parse(ViewState["Super"].ToString()) > rowperpages)
{
Maxrow = rowperpages;
}
else if (remainder != 0 && Int32.Parse(ViewState["Super"].ToString()) > rowperpages)
{
Maxrow = rowperpages;
}
else if (remainder != 0 && Int32.Parse(ViewState["Super"].ToString()) < rowperpages)
{
Maxrow = remainder;
}
else if (remainder != 0 && Int32.Parse(ViewState["Super"].ToString()) == 0)
{
Maxrow = 0;
}
for (Int32 I = Int32.Parse(ViewState["SqlStartPageNos"].ToString()); I < Int32.Parse(ViewState["SqlStartPageNos"].ToString()) + Maxrow; I++)
{
Datafinal.ImportRow((DataRow)SuperResults.Tables[0].Rows[I]);
}
}
else if (y < Int32.Parse(ViewState["pages"].ToString()) - 1)
{
ViewState["SqlStartPageNos"] = y * rowperpages;
Maxrow = rowperpages;
for (Int32 I = Int32.Parse(ViewState["SqlStartPageNos"].ToString()); I < Int32.Parse(ViewState["SqlStartPageNos"].ToString()) + Maxrow; I++)
{
Datafinal.ImportRow((DataRow)SuperResults.Tables[0].Rows[I]);
}
}
else if (y == Int32.Parse(ViewState["pages"].ToString()) - 1)
{
ViewState["SqlStartPageNos"] = y * rowperpages;
if (remainder < rowperpages)
{
Maxrow = remainder;
}
else
{
Maxrow = rowperpages;
}
for (Int32 I = Int32.Parse(ViewState["SqlStartPageNos"].ToString()); I < Int32.Parse(ViewState["SqlStartPageNos"].ToString()) + Maxrow; I++)
{
Datafinal.ImportRow((DataRow)SuperResults.Tables[0].Rows[I]);
}
}
SuperResultsFinal.Tables.Add(Datafinal);
var result = mc.Store(Enyim.Caching.Memcached.StoreMode.Set, CachePattern3, SuperResultsFinal, TimeSpan.FromHours(8.00));
Lblz.Text = "Low-speed-cache";
Lblz.ForeColor = System.Drawing.Color.Silver;
Lblz.Font.Size = FontUnit.Small;
}
}
catch (Exception ex)
{
MessageEnterpriseLabel.Text = "Critical Data Error.Try again after some time.";
MessageEnterpriseLabel.Width = 650;
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
PageTop.Visible = false;
PageBottom.Visible = false;
Lblz.Text = "Data error";
Lblz.ForeColor = System.Drawing.Color.Silver;
Lblz.Font.Size = FontUnit.Small;
throw ex;
}
}
catch (Exception ex)
{
throw ex;
}
//return DatasetSuperResults;
return SuperResultsFinal;
}
public void DatabaseLevelThread(SqlDataAdapter myDataAdapter, out DataSet TempResults, SqlConnection conn)
{
DataSet DatasetTemp = new DataSet();
//Thread.Sleep(i * 25000);
myDataAdapter.Fill(DatasetTemp, "SearchResult");
conn.Close();
TempResults = DatasetTemp;
}
public static string Oneway(string sPassword)
{
System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] bs = System.Text.Encoding.UTF8.GetBytes(sPassword);
bs = x.ComputeHash(bs);
System.Text.StringBuilder s = new System.Text.StringBuilder();
foreach (byte b in bs)
{
s.Append(b.ToString("x2").ToLower());
}
return s.ToString();
}
public static long ConvertIPToLong(string ipAddress)
{
System.Net.IPAddress ip;
if (System.Net.IPAddress.TryParse(ipAddress, out ip))
{
byte[] bytes = ip.GetAddressBytes();
return (long)(((long)bytes[0] << 24) | (bytes[1] << 16) |
(bytes[2] << 8) | bytes[3]);
}
else
return 0;
}
public void FetchCommnd()
{
try
{
Enyim.Caching.Configuration.MemcachedClientConfiguration config = new Enyim.Caching.Configuration.MemcachedClientConfiguration();
IPEndPoint endpoint = new IPEndPoint(System.Net.IPAddress.Parse("127.0.0.1"), 11211);
config.Servers.Add(endpoint);
config.Protocol = Enyim.Caching.Memcached.MemcachedProtocol.Text; //you must set a protocol
Enyim.Caching.MemcachedClient mc = new Enyim.Caching.MemcachedClient(config);
String CachePattern = L2CacheSearchPattern();
CachePattern = CachePattern + "Count";
CachePattern = Oneway(CachePattern);
object cachedObject;
cachedObject = mc.Get(CachePattern);
if (cachedObject != null)
{
DatasetSearch = (DataSet)cachedObject;
}
else
{
SqlConnection conn = new SqlConnection(GetConnectionString());
DatasetSearch = new DataSet();
conn.Open();
SqlCommand FetchCommandx = QueryForm(conn);
SqlDataAdapter myDataAdapter = new SqlDataAdapter(FetchCommandx);
SqlCommandBuilder cmdBldr = new SqlCommandBuilder(myDataAdapter);
myDataAdapter.Fill(DatasetSearch, "SearchResult");
var result = mc.Store(Enyim.Caching.Memcached.StoreMode.Set, CachePattern, DatasetSearch, TimeSpan.FromHours(8.00));
conn.Close();
}
//ViewState["s"] = DatasetSearch.Tables[0].Rows.Count;
ViewState["s"] = DatasetSearch.Tables[0].Rows[0]["Count"];
//if (DatasetSearch.Tables[0].Rows.Count > 0)
if (Int64.Parse(ViewState["s"].ToString()) > 0)
{
BtnPageHit.Enabled = true;
BtnPageHit2.Enabled = true;
PageTop.Visible = true;
PageBottom.Visible = true;
MessageEnterpriseLabel.Text = "";
}
if (Int64.Parse(ViewState["s"].ToString()) > 0 & Int64.Parse(ViewState["s"].ToString()) < 1)
{
BtnPageHit.Enabled = true;
BtnPageHit2.Enabled = true;
PageTop.Visible = true;
PageBottom.Visible = true;
try
{
string search = WebSearchEngineQuery();
if (search.StartsWith("#"))
{
MessageEnterpriseLabel.Text = DDlistEnterprise.SelectedItem + " -Inter-Xect Broadcast Search Results only";
}
else
{
Searchweb(search + " " + ViewState["SearchState"].ToString().Trim());
MessageEnterpriseLabel.Text = DDlistEnterprise.SelectedItem + " -Inter-Xect broadcast Search Results";
}
}
catch
{
MessageEnterpriseLabel.Text = "Web Search Engine: Failure";
}
}
if (Int64.Parse(ViewState["s"].ToString()) < 1)
{
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
PageTop.Visible = false;
PageBottom.Visible = false;
try
{
string search = WebSearchEngineQuery();
if (search.StartsWith("#"))
{
MessageEnterpriseLabel.Text = "No Search Results - Available";
}
else
{
Searchweb(search + " " + ViewState["SearchState"].ToString().Trim());
MessageEnterpriseLabel.Text = "No Broadcast Search Results Found - Showing web search results ";
}
}
catch
{
MessageEnterpriseLabel.Text = "Web Search Engine: Failure";
}
}
if (Int64.Parse(ViewState["s"].ToString()) >= 1)
{
MessageEnterpriseLabel.Text = DDlistEnterprise.SelectedItem + " -Inter-Xect Broadcast Search Results";
}
ViewState["pages"] = (Int32.Parse(ViewState["s"].ToString()) / rowperpages);
if (((Int32.Parse(ViewState["s"].ToString()) - (Int32.Parse(ViewState["pages"].ToString()) * rowperpages)) > 0))
{
ViewState["pages"] = (Int32.Parse(ViewState["pages"].ToString()) + 1);
}
int i;
DropDownList1.Items.Clear();
DropDownList2.Items.Clear();
for (i = 1; (i <= Int32.Parse(ViewState["pages"].ToString())); i++)
{
DropDownList1.Items.Add(i.ToString());
DropDownList2.Items.Add(i.ToString());
if (i >= 20)
{
break;
}
}
LblMaxPages.Text = Int32.Parse(ViewState["pages"].ToString()) + " :Total Pages";
LblMaxPages2.Text = Int32.Parse(ViewState["pages"].ToString()) + " :Total Pages"; ;
DatasetSearch.Clear();
}
catch (Exception ex)
{
throw ex;
}
}
public void FetchCommnd2()
{
try
{
Enyim.Caching.Configuration.MemcachedClientConfiguration config = new Enyim.Caching.Configuration.MemcachedClientConfiguration();
IPEndPoint endpoint = new IPEndPoint(System.Net.IPAddress.Parse("127.0.0.1"), 11211);
config.Servers.Add(endpoint);
config.Protocol = Enyim.Caching.Memcached.MemcachedProtocol.Text; //you must set a protocol
Enyim.Caching.MemcachedClient mc = new Enyim.Caching.MemcachedClient(config);
String CachePattern2 = L2CacheSearchPattern();
int PageNos = (Int32.Parse(ViewState["hit"].ToString()));
if (PageNos == 0)
{
PageNos = 1;
}
CachePattern2 = CachePattern2 + "Results" + PageNos.ToString();
CachePattern2 = Oneway(CachePattern2);
object cachedObject2;
cachedObject2 = mc.Get(CachePattern2);
if (cachedObject2 != null)
{
DatasetSearch = (DataSet)cachedObject2;
Lblz.Text = "High-speed-cache";
Lblz.ForeColor = System.Drawing.Color.Silver;
Lblz.Font.Size = FontUnit.Small;
}
else
{
SqlConnection conn = new SqlConnection(GetConnectionString());
try
{
DatasetSearch = new DataSet();
conn.Open();
SqlCommand FetchCommandx = QueryForm2(conn);
SqlDataAdapter myDataAdapter = new SqlDataAdapter(FetchCommandx);
SqlCommandBuilder cmdBldr = new SqlCommandBuilder(myDataAdapter);
Int32 x;
x = (Int32.Parse(ViewState["hit"].ToString()) - 1);
if ((x == 0) || (x == -1))
{
// myDataAdapter.Fill(DatasetSearch, 0, rowperpages, "SearchResult");
myDataAdapter.Fill(DatasetSearch, "SearchResult");
var result = mc.Store(Enyim.Caching.Memcached.StoreMode.Set, CachePattern2, DatasetSearch, TimeSpan.FromHours(8.00));
Lblz.Text = "Low-speed-cache";
Lblz.ForeColor = System.Drawing.Color.Silver;
Lblz.Font.Size = FontUnit.Small;
}
else
{
//myDataAdapter.Fill(DatasetSearch, 0, rowperpages, "SearchResult");
//myDataAdapter.Fill(DatasetSearch, (x * rowperpages), rowperpages, "SearchResult");
myDataAdapter.Fill(DatasetSearch, "SearchResult");
var result = mc.Store(Enyim.Caching.Memcached.StoreMode.Set, CachePattern2, DatasetSearch, TimeSpan.FromHours(8.00));
Lblz.Text = "Low-speed-cache";
Lblz.ForeColor = System.Drawing.Color.Silver;
Lblz.Font.Size = FontUnit.Small;
}
}
catch (Exception ex)
{
MessageEnterpriseLabel.Text = "Critical Data Error.Try again after some time.";
MessageEnterpriseLabel.Width = 650;
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
PageTop.Visible = false;
PageBottom.Visible = false;
throw ex;
}
finally
{
conn.Close();
}
}
}
catch (Exception ex)
{
}
}
public SqlCommand QueryForm(SqlConnection conn)
{
string strSQL = "";
SqlCommand FetchCommand;
strSQL = " ";
FetchCommand = new SqlCommand(strSQL, conn);
FetchCommand = keyorContentQuery(FetchCommand, conn);
if (DDlistWorld.SelectedValue.ToString().ToLower() == "any".ToLower())
{
FetchCommand.Parameters.AddWithValue("@Location", DBNull.Value);
}
else
{
FetchCommand.Parameters.AddWithValue("@Location", DDlistWorld.Text.Trim());
}
FetchCommand.Parameters.AddWithValue("@Domain", DBNull.Value);
if (DDlistDiscipline.SelectedValue.ToString().ToLower() != "Any".ToLower())
{
FetchCommand.Parameters.AddWithValue("@Discipline", DDlistDiscipline.Text.Trim());
}
else
{
FetchCommand.Parameters.AddWithValue("@Discipline", DBNull.Value);
}
FetchCommand.Parameters.AddWithValue("@Broadcasttype", DDlistReqOffering.Text.Trim());
FetchCommand.Parameters.AddWithValue("@Domain_Type", DBNull.Value);
if (DDlsubCountry.SelectedValue.ToString().ToLower() != "any".ToLower())
{
FetchCommand.Parameters.AddWithValue("@Country", DDlsubCountry.Text.Trim());
}
else
{
FetchCommand.Parameters.AddWithValue("@Country", DBNull.Value);
}
if (ViewState["SearchState"].ToString().Trim().ToLower() != "")
{
FetchCommand.Parameters.AddWithValue("@City", HttpUtility.HtmlEncode(ViewState["SearchState"].ToString()));
}
else
{
FetchCommand.Parameters.AddWithValue("@City", DBNull.Value);
}
if (DDlistDate.SelectedValue.ToString() == ("AnyDate"))
{
FetchCommand.Parameters.AddWithValue("@Date", DBNull.Value);
}
else
{
FetchCommand.Parameters.AddWithValue("@Date", DDlistDate.SelectedValue.ToString());
}
if (DDliststartDate.SelectedValue.ToString() == ("AnyDate"))
{
FetchCommand.Parameters.AddWithValue("@Datestart", DBNull.Value);
}
else
{
FetchCommand.Parameters.AddWithValue("@Datestart", DDliststartDate.SelectedValue.ToString());
}
return FetchCommand;
}
public SqlCommand keyorContentQuery(SqlCommand Fetchcmd, SqlConnection conn)
{
if ((bool)ViewState["LatestResults"] == false)
{
if (DDlistSearchType.SelectedValue.ToString().ToLower() == "keyword".ToLower())
{
ViewState["SearchText"] = ViewState["SearchText"].ToString().Trim().Replace("ampx", "&");
strSQL = " SELECT count(*) as Count FROM Enterprise_Broadcasts where project_domain=( ISNULL(@Domain,project_domain) ) and Project_Domain_type=( ISNULL(@Domain_Type,Project_Domain_type) ) and (Project_Discipline = ( ISNULL(@Discipline,Project_Discipline) )) and (Broadcast_type = @Broadcasttype) and Location=( ISNULL(@Location,Location) ) " +
" and SubLocation= (ISNULL(@Country,SubLocation) ) and Keyword3=(ISNULL(@City,Keyword3)) and ( ( Keyword1 Like @Keyword1 or Keyword1 Like @Keyword1x or Keyword1 Like @Keyword1xy ) or (keyword2 Like @Keyword1 or keyword2 Like @Keyword1x or keyword2 Like @Keyword1xy ) or (keyword2a Like @Keyword1 or keyword2a Like @Keyword1x or keyword2a Like @Keyword1xy ) ) and ( DateName(Month,Req_Finish_Date)+ ' ' + DateName(Year,Req_Finish_Date)= COALESCE(@Date,(DateName(Month,Req_Finish_Date)+ ' '+DateName(Year,Req_Finish_Date)) ) ) and ( DateName(Month,Req_Start_Date)+ ' ' + DateName(Year,Req_Start_Date)= COALESCE(@Datestart,(DateName(Month,Req_Start_Date)+ ' '+DateName(Year,Req_Start_Date)) ) ) ";
Fetchcmd = new SqlCommand(strSQL, conn);
Fetchcmd.Parameters.AddWithValue("@Keyword1", HttpUtility.HtmlEncode(ViewState["SearchText"].ToString().Trim()));
Fetchcmd.Parameters.AddWithValue("@Keyword1x", HttpUtility.HtmlEncode(ViewState["SearchText"].ToString().Trim()) + "_");
Fetchcmd.Parameters.AddWithValue("@Keyword1xy", HttpUtility.HtmlEncode(ViewState["SearchText"].ToString().Trim()) + "__");
}
else if (DDlistSearchType.SelectedValue.ToString().ToLower() == "Company".ToLower())
{
ViewState["SearchText"] = ViewState["SearchText"].ToString().Trim().Replace("ampx", "&");
strSQL = "SELECT count(*) as Count FROM Enterprise_Broadcasts where project_domain=( ISNULL(@Domain,project_domain) ) and Project_Domain_type=( ISNULL(@Domain_Type,Project_Domain_type) ) and (Project_Discipline = ( ISNULL(@Discipline,Project_Discipline) )) and (Broadcast_type =@Broadcasttype) and Location=( ISNULL(@Location,Location) ) " +
" and SubLocation= (ISNULL(@Country,SubLocation) ) and Keyword3=(ISNULL(@City,Keyword3)) and (Enterprise_Name like @Enterprise_Name ) and ( DateName(Month,Req_Finish_Date)+ ' ' + DateName(Year,Req_Finish_Date)= COALESCE(@Date,(DateName(Month,Req_Finish_Date)+ ' '+DateName(Year,Req_Finish_Date)) ) ) and ( DateName(Month,Req_Start_Date)+ ' ' + DateName(Year,Req_Start_Date)= COALESCE(@Datestart,(DateName(Month,Req_Start_Date)+ ' '+DateName(Year,Req_Start_Date)) ) ) ";
Fetchcmd = new SqlCommand(strSQL, conn);
Fetchcmd.Parameters.AddWithValue("@Enterprise_Name", HttpUtility.HtmlEncode(ViewState["SearchText"].ToString().Trim()) + "%");
}
else if (DDlistSearchType.SelectedValue.ToString().ToLower() == "Content".ToLower())
{
ViewState["SearchText"] = ViewState["SearchText"].ToString().Trim().Replace("&", "ampx");
strSQL = "SELECT count(*) as Count FROM Enterprise_Broadcasts where project_domain=( ISNULL(@Domain,project_domain) ) and Project_Domain_type=( ISNULL(@Domain_Type,Project_Domain_type) ) and (Project_Discipline = ( ISNULL(@Discipline,Project_Discipline) )) and (Broadcast_type =@Broadcasttype) and Location=( ISNULL(@Location,Location) ) " +
" and SubLocation= (ISNULL(@Country,SubLocation) ) and Keyword3=(ISNULL(@City,Keyword3)) and CONTAINS(Project_Requirement, @Project_Requirement ) and ( DateName(Month,Req_Finish_Date)+ ' ' + DateName(Year,Req_Finish_Date)= COALESCE(@Date,(DateName(Month,Req_Finish_Date)+ ' '+DateName(Year,Req_Finish_Date)) ) ) and ( DateName(Month,Req_Start_Date)+ ' ' + DateName(Year,Req_Start_Date)= COALESCE(@Datestart,(DateName(Month,Req_Start_Date)+ ' '+DateName(Year,Req_Start_Date)) ) ) ";
Fetchcmd = new SqlCommand(strSQL, conn);
string[] words = ViewState["SearchText"].ToString().Trim().Split(' ');
StringBuilder split1 = new StringBuilder();
StringBuilder split2 = new StringBuilder();
StringBuilder split1Final = new StringBuilder();
StringBuilder split2Final = new StringBuilder();
//StopList stplist = new StopList();
for (int i = 0; i < words.Length; i++)
{
if (i != words.Length - 1)
{
//if (words[i].Length > 3)
if (!CheckIfStopword(words[i].ToLower()))
{
split1.Append(("\"" + HttpUtility.HtmlEncode(words[i]) + "*" + "\"" + " and "));
}
}
else
{
split1.Append(("\"" + HttpUtility.HtmlEncode(words[i]) + "*" + "\"" + " "));
}
}
split1Final.Append(split1);
Fetchcmd.Parameters.AddWithValue("@Project_Requirement", split1Final.ToString());
}
}
else if ((bool)ViewState["LatestResults"] == true)
{
string Days = DDListDays.SelectedValue.ToString();
if (DDlistSearchType.SelectedValue.ToString().ToLower() == "keyword".ToLower())
{
ViewState["SearchText"] = ViewState["SearchText"].ToString().Trim().Replace("ampx", "&");
strSQL = " SELECT count(*) as Count FROM Enterprise_Broadcasts where project_domain=( ISNULL(@Domain,project_domain) ) and Project_Domain_type=( ISNULL(@Domain_Type,Project_Domain_type) ) and (Project_Discipline = ( ISNULL(@Discipline,Project_Discipline) )) and (Broadcast_type = @Broadcasttype) and Location=( ISNULL(@Location,Location) ) " +
" and SubLocation= (ISNULL(@Country,SubLocation) ) and Keyword3=(ISNULL(@City,Keyword3)) and ( ( Keyword1 Like @Keyword1 or Keyword1 Like @Keyword1x or Keyword1 Like @Keyword1xy ) or (keyword2 Like @Keyword1 or keyword2 Like @Keyword1x or keyword2 Like @Keyword1xy ) or (keyword2a Like @Keyword1 or keyword2a Like @Keyword1x or keyword2a Like @Keyword1xy ) ) and create_date > getdate() " + Days + " ";
Fetchcmd = new SqlCommand(strSQL, conn);
Fetchcmd.Parameters.AddWithValue("@Keyword1", HttpUtility.HtmlEncode(ViewState["SearchText"].ToString().Trim()));
Fetchcmd.Parameters.AddWithValue("@Keyword1x", HttpUtility.HtmlEncode(ViewState["SearchText"].ToString().Trim()) + "_");
Fetchcmd.Parameters.AddWithValue("@Keyword1xy", HttpUtility.HtmlEncode(ViewState["SearchText"].ToString().Trim()) + "__");
}
else if (DDlistSearchType.SelectedValue.ToString().ToLower() == "Company".ToLower())
{
ViewState["SearchText"] = ViewState["SearchText"].ToString().Trim().Replace("ampx", "&");
strSQL = "SELECT count(*) as Count FROM Enterprise_Broadcasts where project_domain=( ISNULL(@Domain,project_domain) ) and Project_Domain_type=( ISNULL(@Domain_Type,Project_Domain_type) ) and (Project_Discipline = ( ISNULL(@Discipline,Project_Discipline) )) and (Broadcast_type =@Broadcasttype) and Location=( ISNULL(@Location,Location) ) " +
" and SubLocation= (ISNULL(@Country,SubLocation) ) and Keyword3=(ISNULL(@City,Keyword3)) and (Enterprise_Name like @Enterprise_Name ) and create_date > getdate() " + Days + " ";
Fetchcmd = new SqlCommand(strSQL, conn);
Fetchcmd.Parameters.AddWithValue("@Enterprise_Name", HttpUtility.HtmlEncode(ViewState["SearchText"].ToString().Trim()) + "%");
}
else if (DDlistSearchType.SelectedValue.ToString().ToLower() == "Content".ToLower())
{
ViewState["SearchText"] = ViewState["SearchText"].ToString().Trim().Replace("&", "ampx");
strSQL = "SELECT count(*) as Count FROM Enterprise_Broadcasts where project_domain=( ISNULL(@Domain,project_domain) ) and Project_Domain_type=( ISNULL(@Domain_Type,Project_Domain_type) ) and (Project_Discipline = ( ISNULL(@Discipline,Project_Discipline) )) and (Broadcast_type =@Broadcasttype) and Location=( ISNULL(@Location,Location) ) " +
" and SubLocation= (ISNULL(@Country,SubLocation) ) and Keyword3=(ISNULL(@City,Keyword3)) and CONTAINS(Project_Requirement, @Project_Requirement ) and create_date > getdate() " + Days + " ";
Fetchcmd = new SqlCommand(strSQL, conn);
string[] words = ViewState["SearchText"].ToString().Trim().Split(' ');
StringBuilder split1 = new StringBuilder();
StringBuilder split2 = new StringBuilder();
StringBuilder split1Final = new StringBuilder();
StringBuilder split2Final = new StringBuilder();
//StopList stplist = new StopList();
for (int i = 0; i < words.Length; i++)
{
if (i != words.Length - 1)
{
//if (words[i].Length > 3)
if (!CheckIfStopword(words[i].ToLower()))
{
split1.Append(("\"" + HttpUtility.HtmlEncode(words[i]) + "*" + "\"" + " and "));
}
}
else
{
split1.Append(("\"" + HttpUtility.HtmlEncode(words[i]) + "*" + "\"" + " "));
}
}
split1Final.Append(split1);
Fetchcmd.Parameters.AddWithValue("@Project_Requirement", split1Final.ToString());
}
}
return Fetchcmd;
}
public bool CheckIfStopword(string word)
{
bool Flag = false;
for (int j = 0; j < StopList.SMART_STOP_WORDS.Length; j++)
{
if (word.ToLower() == StopList.SMART_STOP_WORDS[j])
{
Flag = true;
break;
}
}
return Flag;
}
public SqlCommand QueryForm2(SqlConnection conn)
{
string strSQL = "";
SqlCommand FetchCommand;
strSQL = " ";
FetchCommand = new SqlCommand(strSQL, conn);
FetchCommand = keyorContentQuery2(FetchCommand, conn);
if (DDlistWorld.SelectedValue.ToString().ToLower() == "any".ToLower())
{
FetchCommand.Parameters.AddWithValue("@Location", DBNull.Value);
}
else
{
FetchCommand.Parameters.AddWithValue("@Location", DDlistWorld.Text.Trim());
}
FetchCommand.Parameters.AddWithValue("@Domain", DBNull.Value);
if (DDlistDiscipline.SelectedValue.ToString().ToLower() != "Any".ToLower())
{
FetchCommand.Parameters.AddWithValue("@Discipline", DDlistDiscipline.Text.Trim());
}
else
{
FetchCommand.Parameters.AddWithValue("@Discipline", DBNull.Value);
}
FetchCommand.Parameters.AddWithValue("@Broadcasttype", DDlistReqOffering.Text.Trim());
FetchCommand.Parameters.AddWithValue("@Domain_Type", DBNull.Value);
if (DDlsubCountry.SelectedValue.ToString().ToLower() != "any".ToLower())
{
FetchCommand.Parameters.AddWithValue("@Country", DDlsubCountry.Text.Trim());
}
else
{
FetchCommand.Parameters.AddWithValue("@Country", DBNull.Value);
}
if (ViewState["SearchState"].ToString().Trim().ToLower() != "")
{
FetchCommand.Parameters.AddWithValue("@City", HttpUtility.HtmlEncode(ViewState["SearchState"].ToString()));
}
else
{
FetchCommand.Parameters.AddWithValue("@City", DBNull.Value);
}
if (DDlistDate.SelectedValue.ToString() == ("AnyDate"))
{
FetchCommand.Parameters.AddWithValue("@Date", DBNull.Value);
}
else
{
FetchCommand.Parameters.AddWithValue("@Date", DDlistDate.SelectedValue.ToString());
}
if (DDliststartDate.SelectedValue.ToString() == ("AnyDate"))
{
FetchCommand.Parameters.AddWithValue("@Datestart", DBNull.Value);
}
else
{
FetchCommand.Parameters.AddWithValue("@Datestart", DDliststartDate.SelectedValue.ToString());
}
return FetchCommand;
}
public SqlCommand keyorContentQuery2(SqlCommand Fetchcmd, SqlConnection conn)
{
int y = (Int32.Parse(ViewState["hit"].ToString()) - 1);
if ((y == 0) || (y == -1))
{
ViewState["SqlStartPageNos"] = 0;
}
else
{
ViewState["SqlStartPageNos"] = y * rowperpages;
}
if ((bool)ViewState["LatestResults"] == false)
{
if (DDlistSearchType.SelectedValue.ToString().ToLower() == "keyword".ToLower())
{
ViewState["SearchText"] = ViewState["SearchText"].ToString().Trim().Replace("ampx", "&");
strSQL = " Select * from (SELECT * ,ROW_NUMBER() OVER(ORDER BY Clicks desc,Positives desc,Create_Date asc, BroadcastID) AS rownum FROM Enterprise_Broadcasts where project_domain=( ISNULL(@Domain,project_domain) ) and Project_Domain_type=( ISNULL(@Domain_Type,Project_Domain_type) ) and (Project_Discipline = ( ISNULL(@Discipline,Project_Discipline) )) and (Broadcast_type = @Broadcasttype) and Location=( ISNULL(@Location,Location) ) " +
" and SubLocation= (ISNULL(@Country,SubLocation) ) and Keyword3=(ISNULL(@City,Keyword3)) and ( ( Keyword1 Like @Keyword1 or Keyword1 Like @Keyword1x or Keyword1 Like @Keyword1xy ) or (keyword2 Like @Keyword1 or keyword2 Like @Keyword1x or keyword2 Like @Keyword1xy ) or (keyword2a Like @Keyword1 or keyword2a Like @Keyword1x or keyword2a Like @Keyword1xy ) ) and ( DateName(Month,Req_Start_Date)+ ' ' + DateName(Year,Req_Start_Date)= COALESCE(@Datestart,(DateName(Month,Req_Start_Date)+ ' '+DateName(Year,Req_Start_Date)) ) ) and ( DateName(Month,Req_Finish_Date)+ ' ' + DateName(Year,Req_Finish_Date)= COALESCE(@Date,(DateName(Month,Req_Finish_Date)+ ' '+DateName(Year,Req_Finish_Date)) )) ) as QueryTable where rownum > " + ViewState["SqlStartPageNos"].ToString() + " AND rownum <= " + (Int32.Parse(ViewState["SqlStartPageNos"].ToString()) + rowperpages);
Fetchcmd = new SqlCommand(strSQL, conn);
Fetchcmd.Parameters.AddWithValue("@Keyword1", HttpUtility.HtmlEncode(ViewState["SearchText"].ToString().Trim()));
Fetchcmd.Parameters.AddWithValue("@Keyword1x", HttpUtility.HtmlEncode(ViewState["SearchText"].ToString().Trim()) + "_");
Fetchcmd.Parameters.AddWithValue("@Keyword1xy", HttpUtility.HtmlEncode(ViewState["SearchText"].ToString().Trim()) + "__");
}
else if (DDlistSearchType.SelectedValue.ToString().ToLower() == "Company".ToLower())
{
ViewState["SearchText"] = ViewState["SearchText"].ToString().Trim().Replace("ampx", "&");
strSQL = "Select * from (SELECT *,ROW_NUMBER() OVER(ORDER BY Clicks desc,Positives desc,Create_Date asc, BroadcastID) AS rownum FROM Enterprise_Broadcasts where project_domain=( ISNULL(@Domain,project_domain) ) and Project_Domain_type=( ISNULL(@Domain_Type,Project_Domain_type) ) and (Project_Discipline = ( ISNULL(@Discipline,Project_Discipline) )) and (Broadcast_type =@Broadcasttype) and Location=( ISNULL(@Location,Location) )" +
" and SubLocation= (ISNULL(@Country,SubLocation) ) and Keyword3=(ISNULL(@City,Keyword3)) and (Enterprise_Name like @Enterprise_Name ) and ( DateName(Month,Req_Start_Date)+ ' ' + DateName(Year,Req_Start_Date)= COALESCE(@Datestart,(DateName(Month,Req_Start_Date)+ ' '+DateName(Year,Req_Start_Date)) ) ) and ( DateName(Month,Req_Finish_Date)+ ' ' + DateName(Year,Req_Finish_Date)= COALESCE(@Date,(DateName(Month,Req_Finish_Date)+ ' '+DateName(Year,Req_Finish_Date)) ) )) as QueryTable where rownum > " + ViewState["SqlStartPageNos"].ToString() + " AND rownum <= " + (Int32.Parse(ViewState["SqlStartPageNos"].ToString()) + rowperpages);
Fetchcmd = new SqlCommand(strSQL, conn);
Fetchcmd.Parameters.AddWithValue("@Enterprise_Name", HttpUtility.HtmlEncode(ViewState["SearchText"].ToString().Trim()) + "%");
}
else if (DDlistSearchType.SelectedValue.ToString().ToLower() == "Content".ToLower())
{
ViewState["SearchText"] = ViewState["SearchText"].ToString().Trim().Replace("&", "ampx");
strSQL = "Select * from (SELECT *,ROW_NUMBER() OVER(ORDER BY Clicks desc,Positives desc,Create_Date asc, BroadcastID) AS rownum FROM Enterprise_Broadcasts where project_domain=( ISNULL(@Domain,project_domain) ) and Project_Domain_type=( ISNULL(@Domain_Type,Project_Domain_type) ) and (Project_Discipline = ( ISNULL(@Discipline,Project_Discipline) )) and (Broadcast_type =@Broadcasttype) and Location=( ISNULL(@Location,Location) )" +
" and SubLocation= (ISNULL(@Country,SubLocation) ) and Keyword3=(ISNULL(@City,Keyword3)) and CONTAINS(Project_Requirement, @Project_Requirement) and ( DateName(Month,Req_Start_Date)+ ' ' + DateName(Year,Req_Start_Date)= COALESCE(@Datestart,(DateName(Month,Req_Start_Date)+ ' '+DateName(Year,Req_Start_Date)) ) ) and ( DateName(Month,Req_Finish_Date)+ ' ' + DateName(Year,Req_Finish_Date)= COALESCE(@Date,(DateName(Month,Req_Finish_Date)+ ' '+DateName(Year,Req_Finish_Date)) ) )) as QueryTable where rownum > " + ViewState["SqlStartPageNos"].ToString() + " AND rownum <= " + (Int32.Parse(ViewState["SqlStartPageNos"].ToString()) + rowperpages);
Fetchcmd = new SqlCommand(strSQL, conn);
string[] words = ViewState["SearchText"].ToString().Trim().Split(' ');
StringBuilder split1 = new StringBuilder();
StringBuilder split2 = new StringBuilder();
StringBuilder split1Final = new StringBuilder();
StringBuilder split2Final = new StringBuilder();
for (int i = 0; i < words.Length; i++)
{
if (i != words.Length - 1)
{
if (!CheckIfStopword(words[i].ToLower()))
{
split1.Append(("\"" + HttpUtility.HtmlEncode(words[i]) + "*" + "\"" + " and "));
}
}
else
{
split1.Append(("\"" + HttpUtility.HtmlEncode(words[i]) + "*" + "\"" + " "));
}
}
split1Final.Append(split1);
SqlParameter param = new SqlParameter();
Fetchcmd.Parameters.AddWithValue("@Project_Requirement", split1Final.ToString());
}
}
else if ((bool)ViewState["LatestResults"] == true)
{
string Days = DDListDays.SelectedValue.ToString();
if (DDlistSearchType.SelectedValue.ToString().ToLower() == "keyword".ToLower())
{
ViewState["SearchText"] = ViewState["SearchText"].ToString().Trim().Replace("ampx", "&");
strSQL = " Select * from (SELECT * ,ROW_NUMBER() OVER(ORDER BY Clicks desc,Positives desc,Create_Date asc, BroadcastID) AS rownum FROM Enterprise_Broadcasts where project_domain=( ISNULL(@Domain,project_domain) ) and Project_Domain_type=( ISNULL(@Domain_Type,Project_Domain_type) ) and (Project_Discipline = ( ISNULL(@Discipline,Project_Discipline) )) and (Broadcast_type = @Broadcasttype) and Location=( ISNULL(@Location,Location) ) " +
" and SubLocation= (ISNULL(@Country,SubLocation) ) and Keyword3=(ISNULL(@City,Keyword3)) and ( ( Keyword1 Like @Keyword1 or Keyword1 Like @Keyword1x or Keyword1 Like @Keyword1xy ) or (keyword2 Like @Keyword1 or keyword2 Like @Keyword1x or keyword2 Like @Keyword1xy ) or (keyword2a Like @Keyword1 or keyword2a Like @Keyword1x or keyword2a Like @Keyword1xy ) ) and create_date > getdate() " + Days + " ) as QueryTable where rownum > " + ViewState["SqlStartPageNos"].ToString() + " AND rownum <= " + (Int32.Parse(ViewState["SqlStartPageNos"].ToString()) + rowperpages);
Fetchcmd = new SqlCommand(strSQL, conn);
Fetchcmd.Parameters.AddWithValue("@Keyword1", HttpUtility.HtmlEncode(ViewState["SearchText"].ToString().Trim()));
Fetchcmd.Parameters.AddWithValue("@Keyword1x", HttpUtility.HtmlEncode(ViewState["SearchText"].ToString().Trim()) + "_");
Fetchcmd.Parameters.AddWithValue("@Keyword1xy", HttpUtility.HtmlEncode(ViewState["SearchText"].ToString().Trim()) + "__");
}
else if (DDlistSearchType.SelectedValue.ToString().ToLower() == "Company".ToLower())
{
ViewState["SearchText"] = ViewState["SearchText"].ToString().Trim().Replace("ampx", "&");
strSQL = "Select * from (SELECT *,ROW_NUMBER() OVER(ORDER BY Clicks desc,Positives desc,Create_Date asc, BroadcastID) AS rownum FROM Enterprise_Broadcasts where project_domain=( ISNULL(@Domain,project_domain) ) and Project_Domain_type=( ISNULL(@Domain_Type,Project_Domain_type) ) and (Project_Discipline = ( ISNULL(@Discipline,Project_Discipline) )) and (Broadcast_type =@Broadcasttype) and Location=( ISNULL(@Location,Location) )" +
" and SubLocation= (ISNULL(@Country,SubLocation) ) and Keyword3=(ISNULL(@City,Keyword3)) and (Enterprise_Name like @Enterprise_Name) and create_date > getdate()" + Days + " ) as QueryTable where rownum > " + ViewState["SqlStartPageNos"].ToString() + " AND rownum <= " + (Int32.Parse(ViewState["SqlStartPageNos"].ToString()) + rowperpages);
Fetchcmd = new SqlCommand(strSQL, conn);
Fetchcmd.Parameters.AddWithValue("@Enterprise_Name", HttpUtility.HtmlEncode(ViewState["SearchText"].ToString().Trim()) + "%");
}
else if (DDlistSearchType.SelectedValue.ToString().ToLower() == "Content".ToLower())
{
ViewState["SearchText"] = ViewState["SearchText"].ToString().Trim().Replace("&", "ampx");
strSQL = "Select * from (SELECT *,ROW_NUMBER() OVER(ORDER BY Clicks desc,Positives desc,Create_Date asc, BroadcastID) AS rownum FROM Enterprise_Broadcasts where project_domain=( ISNULL(@Domain,project_domain) ) and Project_Domain_type=( ISNULL(@Domain_Type,Project_Domain_type) ) and (Project_Discipline = ( ISNULL(@Discipline,Project_Discipline) )) and (Broadcast_type =@Broadcasttype) and Location=( ISNULL(@Location,Location) )" +
" and SubLocation= (ISNULL(@Country,SubLocation) ) and Keyword3=(ISNULL(@City,Keyword3)) and CONTAINS(Project_Requirement, @Project_Requirement) and create_date > getdate() " + Days + " ) as QueryTable where rownum > " + ViewState["SqlStartPageNos"].ToString() + " AND rownum <= " + (Int32.Parse(ViewState["SqlStartPageNos"].ToString()) + rowperpages);
Fetchcmd = new SqlCommand(strSQL, conn);
string[] words = ViewState["SearchText"].ToString().Trim().Split(' ');
StringBuilder split1 = new StringBuilder();
StringBuilder split2 = new StringBuilder();
StringBuilder split1Final = new StringBuilder();
StringBuilder split2Final = new StringBuilder();
for (int i = 0; i < words.Length; i++)
{
if (i != words.Length - 1)
{
if (!CheckIfStopword(words[i].ToLower()))
{
split1.Append(("\"" + HttpUtility.HtmlEncode(words[i]) + "*" + "\"" + " and "));
}
}
else
{
split1.Append(("\"" + HttpUtility.HtmlEncode(words[i]) + "*" + "\"" + " "));
}
}
split1Final.Append(split1);
SqlParameter param = new SqlParameter();
Fetchcmd.Parameters.AddWithValue("@Project_Requirement", split1Final.ToString());
}
}
return Fetchcmd;
}
public SqlCommand QueryFormsuper(SqlConnection conn)
{
string strSQL = "";
SqlCommand FetchCommand;
strSQL = " ";
FetchCommand = new SqlCommand(strSQL, conn);
FetchCommand = keyorContentQuerySuper(FetchCommand, conn);
if (DDlistWorld.SelectedValue.ToString().ToLower() == "any".ToLower())
{
FetchCommand.Parameters.AddWithValue("@Location", DBNull.Value);
}
else
{
FetchCommand.Parameters.AddWithValue("@Location", DDlistWorld.Text.Trim());
}
FetchCommand.Parameters.AddWithValue("@Domain", DBNull.Value);
if (DDlistDiscipline.SelectedValue.ToString().ToLower() != "Any".ToLower())
{
FetchCommand.Parameters.AddWithValue("@Discipline", DDlistDiscipline.Text.Trim());
}
else
{
FetchCommand.Parameters.AddWithValue("@Discipline", DBNull.Value);
}
FetchCommand.Parameters.AddWithValue("@Broadcasttype", DDlistReqOffering.Text.Trim());
FetchCommand.Parameters.AddWithValue("@Domain_Type", DBNull.Value);
if (DDlsubCountry.SelectedValue.ToString().ToLower() != "any".ToLower())
{
FetchCommand.Parameters.AddWithValue("@Country", DDlsubCountry.Text.Trim());
}
else
{
FetchCommand.Parameters.AddWithValue("@Country", DBNull.Value);
}
if (ViewState["SearchState"].ToString().Trim().ToLower() != "")
{
FetchCommand.Parameters.AddWithValue("@City", HttpUtility.HtmlEncode(ViewState["SearchState"].ToString()));
}
else
{
FetchCommand.Parameters.AddWithValue("@City", DBNull.Value);
}
if (DDlistDate.SelectedValue.ToString() == ("AnyDate"))
{
FetchCommand.Parameters.AddWithValue("@Date", DBNull.Value);
}
else
{
FetchCommand.Parameters.AddWithValue("@Date", DDlistDate.SelectedValue.ToString());
}
if (DDliststartDate.SelectedValue.ToString() == ("AnyDate"))
{
FetchCommand.Parameters.AddWithValue("@Datestart", DBNull.Value);
}
else
{
FetchCommand.Parameters.AddWithValue("@Datestart", DDliststartDate.SelectedValue.ToString());
}
return FetchCommand;
}
public SqlCommand keyorContentQuerySuper(SqlCommand Fetchcmd, SqlConnection conn)
{
int y = (Int32.Parse(ViewState["hit"].ToString()) - 1);
if ((y == 0) || (y == -1))
{
ViewState["SqlStartPageNos"] = 0;
}
else
{
ViewState["SqlStartPageNos"] = y * rowperpages;
}
if ((bool)ViewState["LatestResults"] == false)
{
if (DDlistSearchType.SelectedValue.ToString().ToLower() == "keyword".ToLower())
{
ViewState["SearchText"] = ViewState["SearchText"].ToString().Trim().Replace("ampx", "&");
strSQL = " Select * from (SELECT * ,ROW_NUMBER() OVER(ORDER BY Clicks desc,Positives desc,Create_Date asc, BroadcastID) AS rownum FROM Enterprise_Broadcasts where project_domain=( ISNULL(@Domain,project_domain) ) and Project_Domain_type=( ISNULL(@Domain_Type,Project_Domain_type) ) and (Project_Discipline = ( ISNULL(@Discipline,Project_Discipline) )) and (Broadcast_type = @Broadcasttype) and Location=( ISNULL(@Location,Location) ) " +
" and SubLocation= (ISNULL(@Country,SubLocation) ) and Keyword3=(ISNULL(@City,Keyword3)) and ( ( Keyword1 Like @Keyword1 or Keyword1 Like @Keyword1x or Keyword1 Like @Keyword1xy ) or (keyword2 Like @Keyword1 or keyword2 Like @Keyword1x or keyword2 Like @Keyword1xy ) or (keyword2a Like @Keyword1 or keyword2a Like @Keyword1x or keyword2a Like @Keyword1xy ) ) and ( DateName(Month,Req_Start_Date)+ ' ' + DateName(Year,Req_Start_Date)= COALESCE(@Datestart,(DateName(Month,Req_Start_Date)+ ' '+DateName(Year,Req_Start_Date)) ) ) and ( DateName(Month,Req_Finish_Date)+ ' ' + DateName(Year,Req_Finish_Date)= COALESCE(@Date,(DateName(Month,Req_Finish_Date)+ ' '+DateName(Year,Req_Finish_Date)) ) )) as QueryTable";
Fetchcmd = new SqlCommand(strSQL, conn);
Fetchcmd.Parameters.AddWithValue("@Keyword1", HttpUtility.HtmlEncode(ViewState["SearchText"].ToString().Trim()));
Fetchcmd.Parameters.AddWithValue("@Keyword1x", HttpUtility.HtmlEncode(ViewState["SearchText"].ToString().Trim()) + "_");
Fetchcmd.Parameters.AddWithValue("@Keyword1xy", HttpUtility.HtmlEncode(ViewState["SearchText"].ToString().Trim()) + "__");
}
else if (DDlistSearchType.SelectedValue.ToString().ToLower() == "Company".ToLower())
{
ViewState["SearchText"] = ViewState["SearchText"].ToString().Trim().Replace("ampx", "&");
strSQL = "Select * from (SELECT *,ROW_NUMBER() OVER(ORDER BY Clicks desc,Positives desc,Create_Date asc, BroadcastID) AS rownum FROM Enterprise_Broadcasts where project_domain=( ISNULL(@Domain,project_domain) ) and Project_Domain_type=( ISNULL(@Domain_Type,Project_Domain_type) ) and (Project_Discipline = ( ISNULL(@Discipline,Project_Discipline) )) and (Broadcast_type =@Broadcasttype) and Location=( ISNULL(@Location,Location) )" +
" and SubLocation= (ISNULL(@Country,SubLocation) ) and Keyword3=(ISNULL(@City,Keyword3)) and (Enterprise_Name like @Enterprise_Name ) and ( DateName(Month,Req_Start_Date)+ ' ' + DateName(Year,Req_Start_Date)= COALESCE(@Datestart,(DateName(Month,Req_Start_Date)+ ' '+DateName(Year,Req_Start_Date)) ) ) and ( DateName(Month,Req_Finish_Date)+ ' ' + DateName(Year,Req_Finish_Date)= COALESCE(@Date,(DateName(Month,Req_Finish_Date)+ ' '+DateName(Year,Req_Finish_Date)) ) )) as QueryTable ";
Fetchcmd = new SqlCommand(strSQL, conn);
Fetchcmd.Parameters.AddWithValue("@Enterprise_Name", HttpUtility.HtmlEncode(ViewState["SearchText"].ToString().Trim()) + "%");
}
else if (DDlistSearchType.SelectedValue.ToString().ToLower() == "Content".ToLower())
{
ViewState["SearchText"] = ViewState["SearchText"].ToString().Trim().Replace("&", "ampx");
strSQL = "Select * from (SELECT *,ROW_NUMBER() OVER(ORDER BY Clicks desc,Positives desc,Create_Date asc, BroadcastID) AS rownum FROM Enterprise_Broadcasts where project_domain=( ISNULL(@Domain,project_domain) ) and Project_Domain_type=( ISNULL(@Domain_Type,Project_Domain_type) ) and (Project_Discipline = ( ISNULL(@Discipline,Project_Discipline) )) and (Broadcast_type =@Broadcasttype) and Location=( ISNULL(@Location,Location) )" +
" and SubLocation= (ISNULL(@Country,SubLocation) ) and Keyword3=(ISNULL(@City,Keyword3)) and CONTAINS(Project_Requirement, @Project_Requirement) and ( DateName(Month,Req_Start_Date)+ ' ' + DateName(Year,Req_Start_Date)= COALESCE(@Datestart,(DateName(Month,Req_Start_Date)+ ' '+DateName(Year,Req_Start_Date)) ) ) and ( DateName(Month,Req_Finish_Date)+ ' ' + DateName(Year,Req_Finish_Date)= COALESCE(@Date,(DateName(Month,Req_Finish_Date)+ ' '+DateName(Year,Req_Finish_Date)) ) )) as QueryTable ";
Fetchcmd = new SqlCommand(strSQL, conn);
string[] words = ViewState["SearchText"].ToString().Trim().Split(' ');
StringBuilder split1 = new StringBuilder();
StringBuilder split2 = new StringBuilder();
StringBuilder split1Final = new StringBuilder();
StringBuilder split2Final = new StringBuilder();
for (int i = 0; i < words.Length; i++)
{
if (i != words.Length - 1)
{
if (!CheckIfStopword(words[i].ToLower()))
{
split1.Append(("\"" + HttpUtility.HtmlEncode(words[i]) + "*" + "\"" + " and "));
}
}
else
{
split1.Append(("\"" + HttpUtility.HtmlEncode(words[i]) + "*" + "\"" + " "));
}
}
split1Final.Append(split1);
SqlParameter param = new SqlParameter();
Fetchcmd.Parameters.AddWithValue("@Project_Requirement", split1Final.ToString());
}
}
else if ((bool)ViewState["LatestResults"] == true)
{
string Days = DDListDays.SelectedValue.ToString();
if (DDlistSearchType.SelectedValue.ToString().ToLower() == "keyword".ToLower())
{
ViewState["SearchText"] = ViewState["SearchText"].ToString().Trim().Replace("ampx", "&");
strSQL = " Select * from (SELECT * ,ROW_NUMBER() OVER(ORDER BY Clicks desc,Positives desc,Create_Date asc, BroadcastID) AS rownum FROM Enterprise_Broadcasts where project_domain=( ISNULL(@Domain,project_domain) ) and Project_Domain_type=( ISNULL(@Domain_Type,Project_Domain_type) ) and (Project_Discipline = ( ISNULL(@Discipline,Project_Discipline) )) and (Broadcast_type = @Broadcasttype) and Location=( ISNULL(@Location,Location) ) " +
" and SubLocation= (ISNULL(@Country,SubLocation) ) and Keyword3=(ISNULL(@City,Keyword3)) and ( ( Keyword1 Like @Keyword1 or Keyword1 Like @Keyword1x or Keyword1 Like @Keyword1xy ) or (keyword2 Like @Keyword1 or keyword2 Like @Keyword1x or keyword2 Like @Keyword1xy ) or (keyword2a Like @Keyword1 or keyword2a Like @Keyword1x or keyword2a Like @Keyword1xy ) ) and create_date > getdate() " + Days + " ) as QueryTable";
Fetchcmd = new SqlCommand(strSQL, conn);
Fetchcmd.Parameters.AddWithValue("@Keyword1", HttpUtility.HtmlEncode(ViewState["SearchText"].ToString().Trim()));
Fetchcmd.Parameters.AddWithValue("@Keyword1x", HttpUtility.HtmlEncode(ViewState["SearchText"].ToString().Trim()) + "_");
Fetchcmd.Parameters.AddWithValue("@Keyword1xy", HttpUtility.HtmlEncode(ViewState["SearchText"].ToString().Trim()) + "__");
}
else if (DDlistSearchType.SelectedValue.ToString().ToLower() == "Company".ToLower())
{
ViewState["SearchText"] = ViewState["SearchText"].ToString().Trim().Replace("ampx", "&");
strSQL = "Select * from (SELECT *,ROW_NUMBER() OVER(ORDER BY Clicks desc,Positives desc,Create_Date asc, BroadcastID) AS rownum FROM Enterprise_Broadcasts where project_domain=( ISNULL(@Domain,project_domain) ) and Project_Domain_type=( ISNULL(@Domain_Type,Project_Domain_type) ) and (Project_Discipline = ( ISNULL(@Discipline,Project_Discipline) )) and (Broadcast_type =@Broadcasttype) and Location=( ISNULL(@Location,Location) )" +
" and SubLocation= (ISNULL(@Country,SubLocation) ) and Keyword3=(ISNULL(@City,Keyword3)) and (Enterprise_Name like @Enterprise_Name ) and create_date > getdate() " + Days + " ) as QueryTable ";
Fetchcmd = new SqlCommand(strSQL, conn);
Fetchcmd.Parameters.AddWithValue("@Enterprise_Name", HttpUtility.HtmlEncode(ViewState["SearchText"].ToString().Trim()) + "%");
}
else if (DDlistSearchType.SelectedValue.ToString().ToLower() == "Content".ToLower())
{
ViewState["SearchText"] = ViewState["SearchText"].ToString().Trim().Replace("&", "ampx");
strSQL = "Select * from (SELECT *,ROW_NUMBER() OVER(ORDER BY Clicks desc,Positives desc,Create_Date asc, BroadcastID) AS rownum FROM Enterprise_Broadcasts where project_domain=( ISNULL(@Domain,project_domain) ) and Project_Domain_type=( ISNULL(@Domain_Type,Project_Domain_type) ) and (Project_Discipline = ( ISNULL(@Discipline,Project_Discipline) )) and (Broadcast_type =@Broadcasttype) and Location=( ISNULL(@Location,Location) )" +
" and SubLocation= (ISNULL(@Country,SubLocation) ) and Keyword3=(ISNULL(@City,Keyword3)) and CONTAINS(Project_Requirement, @Project_Requirement) and create_date > getdate() " + Days + " ) as QueryTable ";
Fetchcmd = new SqlCommand(strSQL, conn);
string[] words = ViewState["SearchText"].ToString().Trim().Split(' ');
StringBuilder split1 = new StringBuilder();
StringBuilder split2 = new StringBuilder();
StringBuilder split1Final = new StringBuilder();
StringBuilder split2Final = new StringBuilder();
for (int i = 0; i < words.Length; i++)
{
if (i != words.Length - 1)
{
if (!CheckIfStopword(words[i].ToLower()))
{
split1.Append(("\"" + HttpUtility.HtmlEncode(words[i]) + "*" + "\"" + " and "));
}
}
else
{
split1.Append(("\"" + HttpUtility.HtmlEncode(words[i]) + "*" + "\"" + " "));
}
}
split1Final.Append(split1);
SqlParameter param = new SqlParameter();
Fetchcmd.Parameters.AddWithValue("@Project_Requirement", split1Final.ToString());
}
}
return Fetchcmd;
}
public void bind_table()
{
int i;
TableCell tcxy = new TableCell();
tcxy.Text = "
";
tcxy.ColumnSpan = 8;
TableRow theaderline = new TableRow();
theaderline.Cells.Add(tcxy);
Table Table1 = new Table();
//Table1.Font.Size = 10;
Table1.Font.Name = "Arial";
if (Int64.Parse(ViewState["s"].ToString()) > 0)
{
// Table1.Rows.Add(theader);
Table1.Rows.Add(theaderline);
for (i = 0; (i < rowperpages); i++)
{
if ((Int64.Parse(ViewState["s"].ToString()) <= rowperpages))
{
rowperpages = Int32.Parse(ViewState["s"].ToString());
}
try
{
DataRow drow = DatasetSearch.Tables[0].Rows[i];
TableRow tr = new TableRow();
tr.Height = 50;
tr.BorderStyle = BorderStyle.Solid;
tr.BorderWidth = 1;
string TransactionCost = CostofTransaction((drow[21].ToString()));
DateTime StartDate = DateTime.Parse(drow[9].ToString());
DateTime EndDate = DateTime.Parse(drow[10].ToString());
String StateCity = drow[18].ToString();
if (StateCity == "Any" || StateCity == "any")
{
StateCity = "No City or State Information";
}
string Key1 = HttpUtility.HtmlDecode(drow[15].ToString());
if (Key1.StartsWith("#"))
{
Key1 = "--x--";
}
string Key2 = HttpUtility.HtmlDecode(drow[16].ToString());
if (Key2.StartsWith("#"))
{
Key2 = "--x--";
}
string Key3 = HttpUtility.HtmlDecode(drow[17].ToString());
if (Key3.StartsWith("#"))
{
Key3 = "--x--";
}
TableCell tc = new TableCell();
tc.Width = Unit.Percentage(6);
int rowcount;
if (ViewState["hit"].ToString() == "0")
{
ViewState["Temphit"] = "1";
}
else
{
ViewState["Temphit"] = ViewState["hit"];
}
if ((Int32.Parse(ViewState["Temphit"].ToString()) == 1))
{
rowcount = (i + 1);
}
else
{
rowcount = ((rowperpages * (Int32.Parse(ViewState["Temphit"].ToString()) - 1)) + (i + 1));
}
tc.Text = rowcount.ToString();
tr.Cells.Add(tc);
string EnterpriseData = drow[24].ToString() + " " + EmployeeStrength(drow[3].ToString());
// '''''
tc = new TableCell();
tc.Width = Unit.Percentage(27);
if (drow[1].ToString().Length >= 33)
{
string email = "";
string emailx = drow[2].ToString();
int startindex = emailx.IndexOf("@");
string domain = emailx.Substring(startindex + 1);
if (domain.Length >= 20)
{
email = " [ @" + domain.Substring(0, 20) + " ]";
}
else
{
email = " [ @" + domain + " ]";
}
string Skype_id = "";
string skype = "";
if (drow[26].ToString() == "")
{
Skype_id = "";
skype = "";
}
else if (drow[26].ToString().Contains("X1C2R3") || drow[26].ToString().Contains("S1K2Y3"))
{
if (drow[26].ToString().Contains("X1C2R3"))
{
Skype_id = drow[26].ToString().Replace("X1C2R3", "");
skype = "" + "XcriticalID:" + Skype_id + "";
}
else if (drow[26].ToString().Contains("S1K2Y3"))
{
Skype_id = drow[26].ToString().Replace("S1K2Y3", "");
skype = "";
}
else
{
Skype_id = "";
skype = "";
}
}
tc.Text = "" + HttpUtility.HtmlDecode(drow[1].ToString().Substring(0, 33)) + ".." + "
" + email + "
" + "" + EnterpriseData + " " +
"
" + " [ Keywords : " + Key1 + "," + Key2 + "," + Key3 + " ] "
+ "
" + " Financial Result/Value/Cost:
[" + (TransactionCost) + " ] "
+ "
" + " [ Start Dt: " + StartDate.ToString("dd-MMM-yyyy") + " -- End Dt : " + EndDate.ToString("dd-MMM-yyyy") + " ] "
+ "
" + " [ City /State : " + StateCity + " ] "
+ "
" + skype;
tc.ForeColor = System.Drawing.ColorTranslator.FromHtml("Black");
tc.Font.Bold = true;
}
else
{
string email = "";
string emailx = drow[2].ToString();
int startindex = emailx.IndexOf("@");
string domain = emailx.Substring(startindex + 1);
if (domain.Length >= 20)
{
email = " [ @" + domain.Substring(0, 20) + " ]";
}
else
{
email = " [ @" + domain + " ]";
}
string Skype_id = "";
string skype = "";
if (drow[26].ToString() == "")
{
Skype_id = "";
skype = "";
}
else if (drow[26].ToString().Contains("X1C2R3") || drow[26].ToString().Contains("S1K2Y3"))
{
if (drow[26].ToString().Contains("X1C2R3"))
{
Skype_id = drow[26].ToString().Replace("X1C2R3", "");
skype = "" + "XcriticalID:" + Skype_id + "";
}
else if (drow[26].ToString().Contains("S1K2Y3"))
{
Skype_id = drow[26].ToString().Replace("S1K2Y3", "");
skype = "";
}
else
{
Skype_id = "";
skype = "";
}
}
tc.Text = "" + HttpUtility.HtmlDecode(drow[1].ToString()) + "" + "
" + email + "
" + "" + EnterpriseData + "" +
"
" + " [ Keywords : " + Key1 + "," + Key2 + "," + Key3 + " ] "
+ "
" + " Financial Result/Value/Cost:
[" + (TransactionCost) + " ] "
+ "
" + " [ Start Dt: " + StartDate.ToString("dd-MMM-yyyy") + " -- End Dt : " + EndDate.ToString("dd-MMM-yyyy") + " ] "
+ "
" + " [ City /State : " + StateCity + " ] "
+ "
" + skype;
tc.ForeColor = System.Drawing.ColorTranslator.FromHtml("Black");
tc.Font.Bold = true;
}
tr.Cells.Add(tc);
TableCell tc2 = new TableCell();
tc2.Width = Unit.Percentage(62);
String URLlink = "";
if (drow[13].ToString().Trim().ToLower().EndsWith("?"))
{
string searchtext = "";
if (ViewState["SearchText"].ToString().Trim().StartsWith("#"))
{
searchtext = "";
}
else
{
searchtext = Server.UrlEncode(ViewState["SearchText"].ToString().Trim());
}
string Category = "";
if (DDlistDiscipline.SelectedItem.ToString() == "Anything")
{
Category = "Anything";
}
else
{
Category = Server.UrlEncode(DDlistDiscipline.SelectedItem.ToString());
}
string Country = "";
if (DDlsubCountry.SelectedItem.ToString() == "Any Country")
{
Country = "Global";
}
else
{
Country = Server.UrlEncode(DDlsubCountry.SelectedItem.ToString());
}
if (searchtext == "")
{
URLlink = "http://" + drow[13].ToString().ToLower().Trim();
}
else
{
URLlink = "http://" + drow[13].ToString().ToLower().Trim() + "Country=" + Country + "&Search=" + searchtext + "&Category=" + Category;
}
}
else
{
URLlink = "http://" + drow[13].ToString().ToLower().Trim();
}
if (drow[8].ToString().Length > 600)
{
Int64 param = Int64.Parse(drow[0].ToString());
Int32 db = GetConnectionTableId(drow[24].ToString());
tc2.Text = "" + " " + (HttpUtility.HtmlDecode(drow[22].ToString()))
+ " " + "" + "" + " " + (HttpUtility.HtmlDecode(drow[23].ToString())) + " - Views " + " " + "" + " " + (HttpUtility.HtmlDecode(drow[25].ToString())) + " +Ve " + " " + " + Vote" + ""
+ "
" + "" + HttpUtility.HtmlDecode(drow[8].ToString().Replace("ampx", "&").Substring(0, 600)) + "
";
//tc2.Font.Name = "Arial";
tc2.VerticalAlign = VerticalAlign.Middle;
//tc2.Font.Size = 10;
}
else
{
Int64 param = Int64.Parse(drow[0].ToString());
Int32 db = GetConnectionTableId(drow[24].ToString());
tc2.Text = "" + " " + (HttpUtility.HtmlDecode(drow[22].ToString()))
+ " " + "" + "" + " " + (HttpUtility.HtmlDecode(drow[23].ToString())) + " - Views " + " " + "" + " " + (HttpUtility.HtmlDecode(drow[25].ToString())) + " +Ve " + " " + " + Vote" + ""
+ "
" + "" + HttpUtility.HtmlDecode(drow[8].ToString()).Replace("ampx", "&") + "
";
//tc2.Font.Name = "Arial";
tc2.VerticalAlign = VerticalAlign.Middle;
//tc2.Font.Size = 10;
}
tc2.Width = Unit.Percentage(62);
tr.Cells.Add(tc2);
TableCell tcempty = new TableCell();
tcempty.Text = " ";
//tc2.ForeColor = System.Drawing.Color.Blue;
tr.Cells.Add(tcempty);
PlaceHolder ph2 = new PlaceHolder();
if (double.Parse(drow[19].ToString()) == 0.0000000)
{
}
else
{
LinkButton link = new LinkButton();
string a = drow[19].ToString();
string b = drow[20].ToString();
link.OnClientClick = "OpenMap(" + a + "," + b + ");";
link.Attributes.Add("onClick", "return false;");
link.Text = "Map";
ph2.Controls.Add(link);
}
TableCell tc3 = new TableCell();
tc3.Width = Unit.Percentage(0);
tr.Cells.Add(tc3);
TableCell tc4 = new TableCell();
tc4.Width = Unit.Percentage(3);
tc4.Controls.Add(ph2);
tr.Cells.Add(tc4);
tr.Height = 120;
Table1.Rows.Add(tr);
TableRow tr2 = new TableRow();
TableCell tcx = new TableCell();
tcx.Text = "
";
tcx.ColumnSpan = 11;
tr2.Cells.Add(tcx);
Table1.Rows.Add(tr2);
}
catch (Exception ex)
{
break;
}
}
SearchResult.Controls.Add(Table1);
LblResultsTypeTop.Text = "Category: " + DDlistDiscipline.SelectedItem.ToString();
LblResultsTypebottom.Text = "Category: " + DDlistDiscipline.SelectedItem.ToString();
}
}
public void bind_tableSuper(DataSet SuperResults)
{
int i;
//TableRow theader = new TableRow();
//TableCell tcheader = new TableCell();
//tcheader.Text = "Seq";
//tcheader.Width = Unit.Percentage(6);
//theader.Cells.Add(tcheader);
//TableCell tcheaderA = new TableCell();
//tcheaderA.Text = "Company Name /Individual";
//tcheaderA.Width = Unit.Percentage(27);
//theader.Cells.Add(tcheaderA);
//TableCell tcheaderB = new TableCell();
//tcheaderB.Text = "Description";
//tcheaderB.Width = Unit.Percentage(62);
//theader.Cells.Add(tcheaderB);
//TableCell tcheaderEmpty = new TableCell();
//tcheaderEmpty.Text = "";
//tcheaderEmpty.Width = Unit.Percentage(2);
//theader.Cells.Add(tcheaderEmpty);
//TableCell tcheaderC = new TableCell();
//tcheaderC.Text = "";
//tcheaderC.Width = Unit.Percentage(0);
//theader.Cells.Add(tcheaderC);
//TableCell tcheaderD = new TableCell();
//tcheaderD.Text = "Map";
//tcheaderD.Width = Unit.Percentage(3);
//theader.Cells.Add(tcheaderD);
//theader.ForeColor = System.Drawing.ColorTranslator.FromHtml("white");
//theader.BackColor = System.Drawing.ColorTranslator.FromHtml("black");
TableCell tcxy = new TableCell();
tcxy.Text = "
";
tcxy.ColumnSpan = 8;
TableRow theaderline = new TableRow();
theaderline.Cells.Add(tcxy);
Table Table1 = new Table();
Table1.Font.Size = 10;
Table1.Font.Name = "Arial";
if (Int64.Parse(ViewState["Super"].ToString()) > 0)
{
// Table1.Rows.Add(theader);
Table1.Rows.Add(theaderline);
for (i = 0; (i < rowperpages); i++)
{
if ((Int64.Parse(ViewState["Super"].ToString()) <= rowperpages))
{
rowperpages = Int32.Parse(ViewState["Super"].ToString());
}
try
{
DataRow drow = SuperResults.Tables[0].Rows[i];
TableRow tr = new TableRow();
tr.Height = 50;
tr.BorderStyle = BorderStyle.Solid;
tr.BorderWidth = 1;
string TransactionCost = CostofTransaction((drow[21].ToString()));
DateTime StartDate = DateTime.Parse(drow[9].ToString());
DateTime EndDate = DateTime.Parse(drow[10].ToString());
String StateCity = drow[18].ToString();
if (StateCity == "Any" || StateCity == "any")
{
StateCity = "No City or State Information";
}
string Key1 = HttpUtility.HtmlDecode(drow[15].ToString());
if (Key1.StartsWith("#"))
{
Key1 = "--x--";
}
string Key2 = HttpUtility.HtmlDecode(drow[16].ToString());
if (Key2.StartsWith("#"))
{
Key2 = "--x--";
}
string Key3 = HttpUtility.HtmlDecode(drow[17].ToString());
if (Key3.StartsWith("#"))
{
Key3 = "--x--";
}
TableCell tc = new TableCell();
tc.Width = Unit.Percentage(6);
int rowcount;
if (ViewState["hit"].ToString() == "0")
{
ViewState["Temphit"] = "1";
}
else
{
ViewState["Temphit"] = ViewState["hit"];
}
if ((Int32.Parse(ViewState["Temphit"].ToString()) == 1))
{
rowcount = (i + 1);
}
else
{
rowcount = ((rowperpages * (Int32.Parse(ViewState["Temphit"].ToString()) - 1)) + (i + 1));
}
tc.Text = rowcount.ToString();
tr.Cells.Add(tc);
string EnterpriseData = drow[24].ToString() + " " + EmployeeStrength(drow[3].ToString());
// '''''
tc = new TableCell();
tc.Width = Unit.Percentage(27);
if (drow[1].ToString().Length >= 33)
{
string email = "";
string emailx = drow[2].ToString();
int startindex = emailx.IndexOf("@");
string domain = emailx.Substring(startindex + 1);
if (domain.Length >= 20)
{
email = " [ @" + domain.Substring(0, 20) + " ]";
}
else
{
email = " [ @" + domain + " ]";
}
string Skype_id = "";
string skype = "";
if (drow[26].ToString() == "")
{
Skype_id = "";
skype = "";
}
else if (drow[26].ToString().Contains("X1C2R3") || drow[26].ToString().Contains("S1K2Y3"))
{
if (drow[26].ToString().Contains("X1C2R3"))
{
Skype_id = drow[26].ToString().Replace("X1C2R3", "");
skype = "" + "XcriticalID:" + Skype_id + "";
}
else if (drow[26].ToString().Contains("S1K2Y3"))
{
Skype_id = drow[26].ToString().Replace("S1K2Y3", "");
skype = "";
}
else
{
Skype_id = "";
skype = "";
}
}
tc.Text = "" + HttpUtility.HtmlDecode(drow[1].ToString().Substring(0, 33)) + ".." + "
" + email + "
" + "" + EnterpriseData + " " +
"
" + " [ Keywords : " + Key1 + "," + Key2 + "," + Key3 + " ] "
+ "
" + " Financial Result/Value/Cost:
[" + (TransactionCost) + " ] "
+ "
" + " [ Start Dt: " + StartDate.ToString("dd-MMM-yyyy") + "-- End Dt : " + EndDate.ToString("dd-MMM-yyyy") + " ] "
+ "
" + " [ City /State : " + StateCity + " ] "
+ "
" + skype;
tc.ForeColor = System.Drawing.ColorTranslator.FromHtml("Black");
tc.Font.Bold = true;
}
else
{
string email = "";
string emailx = drow[2].ToString();
int startindex = emailx.IndexOf("@");
string domain = emailx.Substring(startindex + 1);
if (domain.Length >= 20)
{
email = " [ @" + domain.Substring(0, 20) + " ]";
}
else
{
email = " [ @" + domain + " ]";
}
string Skype_id = "";
string skype = "";
if (drow[26].ToString() == "")
{
Skype_id = "";
skype = "";
}
else if (drow[26].ToString().Contains("X1C2R3") || drow[26].ToString().Contains("S1K2Y3"))
{
if (drow[26].ToString().Contains("X1C2R3"))
{
Skype_id = drow[26].ToString().Replace("X1C2R3", "");
skype = "" + "XcriticalID:" + Skype_id + "";
}
else if (drow[26].ToString().Contains("S1K2Y3"))
{
Skype_id = drow[26].ToString().Replace("S1K2Y3", "");
skype = "";
}
else
{
Skype_id = "";
skype = "";
}
}
tc.Text = "" + HttpUtility.HtmlDecode(drow[1].ToString()) + "" + "
" + email + "
" + "" + EnterpriseData + "" +
"
" + " [ Keywords : " + Key1 + "," + Key2 + "," + Key3 + " ] "
+ "
" + " Financial Result/Value/Cost:
[ " + (TransactionCost) + " ] "
+ "
" + " [ Start Dt: " + StartDate.ToString("dd-MMM-yyyy") + " -- End Dt : " + EndDate.ToString("dd-MMM-yyyy") + " ] "
+ "
" + " [ City /State : " + StateCity + " ] "
+ "
" + skype;
tc.ForeColor = System.Drawing.ColorTranslator.FromHtml("Black");
tc.Font.Bold = true;
}
tr.Cells.Add(tc);
TableCell tc2 = new TableCell();
tc2.Width = Unit.Percentage(62);
String URLlink = "";
if (drow[13].ToString().Trim().ToLower().EndsWith("?"))
{
string searchtext = "";
if (ViewState["SearchText"].ToString().Trim().StartsWith("#"))
{
searchtext = "";
}
else
{
searchtext = Server.UrlEncode(ViewState["SearchText"].ToString().Trim());
}
string Category = "";
if (DDlistDiscipline.SelectedItem.ToString() == "Anything")
{
Category = "Anything";
}
else
{
Category = Server.UrlEncode(DDlistDiscipline.SelectedItem.ToString());
}
string Country = "";
if (DDlsubCountry.SelectedItem.ToString() == "Any Country")
{
Country = "Global";
}
else
{
Country = Server.UrlEncode(DDlsubCountry.SelectedItem.ToString());
}
if (searchtext == "")
{
URLlink = "http://" + drow[13].ToString().ToLower().Trim();
}
else
{
URLlink = "http://" + drow[13].ToString().ToLower().Trim() + "Country=" + Country + "&Search=" + searchtext + "&Category=" + Category;
}
}
else
{
URLlink = "http://" + drow[13].ToString().ToLower().Trim();
}
if (drow[8].ToString().Length > 600)
{
Int64 param = Int64.Parse(drow[0].ToString());
Int32 db = GetConnectionTableId(drow[24].ToString());
tc2.Text = "" + " " + (HttpUtility.HtmlDecode(drow[22].ToString()))
+ " " + "" + "" + " " + (HttpUtility.HtmlDecode(drow[23].ToString())) + " - Views " + " " + "" + " " + (HttpUtility.HtmlDecode(drow[25].ToString())) + " +Ve " + " " + " + Vote" + ""
+ "
" + "" + HttpUtility.HtmlDecode(drow[8].ToString().Replace("ampx", "&").Substring(0, 600)) + "
";
//tc2.Font.Name = "Arial";
tc2.VerticalAlign = VerticalAlign.Middle;
//tc2.Font.Size = 10;
}
else
{
Int64 param = Int64.Parse(drow[0].ToString());
Int32 db = GetConnectionTableId(drow[24].ToString());
tc2.Text = "" + " " + (HttpUtility.HtmlDecode(drow[22].ToString()))
+ " " + "" + "" + " " + (HttpUtility.HtmlDecode(drow[23].ToString())) + " - Views " + " " + "" + " " + (HttpUtility.HtmlDecode(drow[25].ToString())) + " +Ve " + " " + " + Vote" + ""
+ "
" + "" + HttpUtility.HtmlDecode(drow[8].ToString()).Replace("ampx", "&") + "
";
//tc2.Font.Name = "Arial";
tc2.VerticalAlign = VerticalAlign.Middle;
//tc2.Font.Size = 10;
}
//tc2.ForeColor = System.Drawing.Color.Blue;
tc2.Width = Unit.Percentage(62);
tr.Cells.Add(tc2);
TableCell tcempty = new TableCell();
tcempty.Text = " ";
//tc2.ForeColor = System.Drawing.Color.Blue;
tr.Cells.Add(tcempty);
PlaceHolder ph2 = new PlaceHolder();
if (double.Parse(drow[19].ToString()) == 0.0000000)
{
}
else
{
LinkButton link = new LinkButton();
string a = drow[19].ToString();
string b = drow[20].ToString();
link.OnClientClick = "OpenMap(" + a + "," + b + ");";
link.Attributes.Add("onClick", "return false;");
link.Text = "Map";
ph2.Controls.Add(link);
}
TableCell tc3 = new TableCell();
tc3.Width = Unit.Percentage(0);
tr.Cells.Add(tc3);
TableCell tc4 = new TableCell();
tc4.Width = Unit.Percentage(3);
tc4.Controls.Add(ph2);
tr.Cells.Add(tc4);
tr.Height = 120;
Table1.Rows.Add(tr);
TableRow tr2 = new TableRow();
TableCell tcx = new TableCell();
tcx.Text = "
";
tcx.ColumnSpan = 11;
tr2.Cells.Add(tcx);
Table1.Rows.Add(tr2);
}
catch (Exception ex)
{
break;
}
}
SearchResult.Controls.Add(Table1);
LblResultsTypeTop.Text = "Category: " + DDlistDiscipline.SelectedItem.ToString();
LblResultsTypebottom.Text = "Category: " + DDlistDiscipline.SelectedItem.ToString();
}
}
public void link_button_click(object sender, System.EventArgs e)
{
CustomLinkButton ctrl = new CustomLinkButton();
ctrl = (CustomLinkButton)sender;
ViewState["hit"] = 0;
ViewState["SearchText"] = ctrl.LinkSecondaryData.ToString().Trim();
ViewState["SearchState"] = TxtCityState.Text.ToString().Trim();
TxtPageBox.Text = "";
TxtPageBox2.Text = "";
Tcvdiv.Attributes.Add("style", "display:none");
string search = WebSearchEngineQuery();
if (DDlistSearchType.SelectedValue.ToLower() == "Web".ToLower())
{
if (search.StartsWith("#"))
{
MessageEnterpriseLabel.Text = "# Related keywords- not allowed for Web search ";
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
PageTop.Visible = false;
PageBottom.Visible = false;
}
}
else if (DDlistSearchType.SelectedValue.ToLower() == "Content".ToLower())
{
if (search.StartsWith("#"))
{
MessageEnterpriseLabel.Text = "# Related keywords- not allowed for Content Search ";
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
PageTop.Visible = false;
PageBottom.Visible = false;
}
}
else if (DDlistSearchType.SelectedValue.ToLower() == "Company".ToLower())
{
if (search.StartsWith("#"))
{
MessageEnterpriseLabel.Text = "# Related keywords- not allowed for Enterprise or Individuals ";
BtnPageHit.Enabled = false;
BtnPageHit2.Enabled = false;
PageTop.Visible = false;
PageBottom.Visible = false;
}
}
else
{
populateSearch();
}
}
public void SearchAssistBindHtml(String Searchword)
{
SearchAssist instance = new SearchAssist();
ArrayList SpecialArraylist = instance.SearchAssistMethod(Searchword);
TableRow SearchAssistRow = new TableRow();
TableCell tcHeading = new TableCell();
tcHeading.Text = "Related Search Keywords:";
SearchAssistRow.Controls.Add(tcHeading);
foreach (SearchAssistData SaData in SpecialArraylist)
{
// LinkButton searchAssist = new LinkButton();
CustomLinkButton searchAssist = new CustomLinkButton();
searchAssist.Click += link_button_click;
searchAssist.Text = SaData.LinkDisplay.ToString();
searchAssist.LinkSecondaryData = SaData.SearchCode;
searchAssist.ForeColor = System.Drawing.Color.Blue;
searchAssist.Font.Size = 10;
TableCell tcSearchCell = new TableCell();
TableCell tcEmptyspace = new TableCell();
tcEmptyspace.Text = " ";
tcSearchCell.Controls.Add(searchAssist);
SearchAssistRow.Controls.Add(tcEmptyspace);
SearchAssistRow.Controls.Add(tcSearchCell);
}
if (SpecialArraylist.Count > 0)
{
PlaceHolderSearchAssist.Controls.Add(new LiteralControl("
"));
PlaceHolderSearchAssist.Controls.Add(SearchAssistRow);
//PlaceHolderSearchAssist.Controls.Add(new LiteralControl("
"));
PlaceHolderSearchAssist.Visible = true;
}
else
{
TableCell tcHeadingEmpty = new TableCell();
PlaceHolderSearchAssist.Controls.Add(new LiteralControl("
"));
tcHeadingEmpty.Text = "";// "No Related KeyWords Found:";
//PlaceHolderSearchAssist.Controls.Add(new LiteralControl("
"));
PlaceHolderSearchAssist.Controls.Add(tcHeadingEmpty);
//PlaceHolderSearchAssist.Controls.Add(new LiteralControl("
"));
PlaceHolderSearchAssist.Visible = false;
}
}
public void Searchweb(String _queryString)
{
try
{
//SearchResponse searchResponse;
BingService.SearchResponse searchResponse;
// execute the query
searchResponse = runQuery(_queryString);
renderWebResults(searchResponse);
}
catch (System.Web.Services.Protocols.SoapException ex)
{
// DisplayErrors(ex.Detail);
throw;
}
catch (System.Net.WebException ex)
{
//Console.WriteLine(ex.Message);
throw;
}
}
protected SearchResponse runQuery(string query)
{
//MSNSearchService s = new MSNSearchService();
BingService.BingService service = new BingService.BingService();
SearchRequest request = new SearchRequest();
// Common request fields (required)
request.AppId = _APPID;
request.Query = query;
request.Sources = new SourceType[] { SourceType.Web };
// Common request fields (optional)
request.Version = "2.0";
request.Market = "en-US";
request.Adult = AdultOption.Moderate;
request.AdultSpecified = true;
request.Options = new SearchOption[] { SearchOption.EnableHighlighting };
// Web-specific request fields (optional)
request.Web = new BingService.WebRequest();
request.Web.Count = 15;
request.Web.CountSpecified = true;
request.Web.Offset = 0;
request.Web.OffsetSpecified = true;
request.Options = new SearchOption[]
{
SearchOption.EnableHighlighting
};
request.Web.Options = new WebSearchOption[]
{
WebSearchOption.DisableHostCollapsing,
WebSearchOption.DisableQueryAlterations
};
SearchResponse response = service.Search(request);
return response;
// SearchResponse searchResponse = s.Search(searchRequest);
// BingService.SearchResponse searchResponse = s.Search(searchRequest);
}
static void DisplayTextWithHighlighting(string text)
{
// Write text to the standard output stream, changing the console
// foreground color as highlighting characters are encountered.
foreach (char c in text.ToCharArray())
{
if (c == '\uE000')
{
// If the current character is the begin highlighting
// character (U+E000), change the console foreground color
// to green.
Console.ForegroundColor = ConsoleColor.Green;
}
else if (c == '\uE001')
{
// If the current character is the end highlighting
// character (U+E001), revert the console foreground color
// to gray.
Console.ForegroundColor = ConsoleColor.Gray;
}
else
{
Console.Write(c);
}
}
}
private void DisplayErrors(XmlNode errorDetails)
{
// Add the default namespace to the namespace manager.
XmlNamespaceManager nsmgr = new XmlNamespaceManager(errorDetails.OwnerDocument.NameTable);
nsmgr.AddNamespace("api", "http://schemas.microsoft.com/LiveSearch/2008/03/Search");
XmlNodeList errors = errorDetails.SelectNodes("./api:Errors/api:Error", nsmgr);
if (errors != null)
{
StringBuilder builder = new StringBuilder();
foreach (XmlNode error in errors)
{
foreach (XmlNode detail in error.ChildNodes)
builder.AppendLine(detail.Name + ": " + detail.InnerText);
builder.AppendLine(Environment.NewLine);
}
}
}
protected void renderWebResults(BingService.SearchResponse queryResults)
{
StringBuilder sb = new StringBuilder(1024);
TableRow theader = new TableRow();
TableCell tcheader = new TableCell();
tcheader.Text = "Web Search Results";
tcheader.Width = 700;
theader.Cells.Add(tcheader);
theader.ForeColor = System.Drawing.Color.Black;
theader.Font.Bold = true;
theader.Font.Size = 12;
theader.Font.Name = "Arial";
//theader.BackColor = System.Drawing.ColorTranslator.FromHtml("#ffba14");
theader.BackColor = System.Drawing.Color.LightSteelBlue;
Table Table1 = new Table();
//-- Advertisement Code --
Table TableAdvertise = new Table();
Table TableFinalRender = new Table();
TableRow FinalRow = new TableRow();
TableRow AdvtHeader = new TableRow();
TableCell TCell1 = new TableCell();
TableCell TCell2 = new TableCell();
TableCell tcheaderAdvt = new TableCell();
tcheaderAdvt.Text = "Super Sponsored Advertisements";
tcheaderAdvt.HorizontalAlign = HorizontalAlign.Center;
AdvtHeader.Width = 400;
AdvtHeader.Cells.Add(tcheaderAdvt);
AdvtHeader.ForeColor = System.Drawing.Color.White;
AdvtHeader.Font.Bold = true;
AdvtHeader.Font.Size = 12;
AdvtHeader.Font.Name = "Arial";
//theader.BackColor = System.Drawing.ColorTranslator.FromHtml("#ffba14");
AdvtHeader.BackColor = System.Drawing.Color.Black;
TableAdvertise.Rows.Add(AdvtHeader);
//----------------------------
//TCell2.Width = 500;
TCell1.HorizontalAlign = HorizontalAlign.Left;
TCell2.HorizontalAlign = HorizontalAlign.Center;
FinalRow.HorizontalAlign = HorizontalAlign.Left;
Table1.Rows.Add(theader);
Table1.Width = 700;
Table1.Font.Size = 10;
Table1.Font.Name = "Verdana";
//foreach (Result sourceResult in queryResults.Responses[SR_WEB].Results)
Int32 i = 1;
if (queryResults.Web.Results != null)
{
foreach (BingService.WebResult sourceResult in queryResults.Web.Results)
{
string title, description, url;
title = (!String.IsNullOrEmpty(sourceResult.Title)) ? sourceResult.Title : "";
title = title.Replace("\uE000", string.Empty).Replace("\uE001", string.Empty);
description = (!String.IsNullOrEmpty(sourceResult.Description)) ? sourceResult.Description : "";
description = description.Replace("\uE000", string.Empty).Replace("\uE001", string.Empty);
url = (!String.IsNullOrEmpty(sourceResult.Url)) ? sourceResult.Url : "";
TableRow tr = new TableRow();
TableCell tc2 = new TableCell();
System.Web.UI.WebControls.HyperLink TitleLink = new System.Web.UI.WebControls.HyperLink();
TitleLink.Text = title;
TitleLink.ForeColor = System.Drawing.Color.Blue;
TitleLink.NavigateUrl = url;
TitleLink.Target = "_blank";
TitleLink.Font.Size = 11;
tc2.Controls.Add(TitleLink);
tr.Cells.Add(tc2);
Table1.Rows.Add(tr);
TableRow tr2 = new TableRow();
TableCell tc3 = new TableCell();
tc3.Text = description;
tr2.Cells.Add(tc3);
Table1.Rows.Add(tr2);
System.Web.UI.WebControls.HyperLink but = new System.Web.UI.WebControls.HyperLink();
but.Target = "_blank";
if (url.Length >= 75)
{
but.Text = url.ToString().Substring(0, 75).Trim().ToLower();
but.ForeColor = System.Drawing.Color.YellowGreen;
but.Font.Bold = false;
}
else
{
but.Text = url.ToString().Trim().ToLower();
but.ForeColor = System.Drawing.Color.YellowGreen;
//but.ForeColor = System.Drawing.ColorTranslator.FromHtml("#85CA39");
but.Font.Bold = false;
}
//but.NavigateUrl = url;
PlaceHolder ph1 = new PlaceHolder();
ph1.Controls.Add(but);
TableRow tr3 = new TableRow();
TableCell tc4 = new TableCell();
tc4.Controls.Add(ph1);
tr3.Cells.Add(tc4);
Table1.Rows.Add(tr3);
//---------------------------------------------Advertisement Code------------------------------//
if (i <= 4)
{
string[] ads = Advertisements(i);
i++;
string strNavigate = ads[0];
// update Description
string strCompany = ads[1];
// update Active
string strCaption = ads[2];
System.Web.UI.WebControls.HyperLink Hlink = new System.Web.UI.WebControls.HyperLink();
Hlink.Target = "_blank";
if (strNavigate != "")
{
Hlink.NavigateUrl = "http://" + strNavigate;
Hlink.ForeColor = System.Drawing.Color.YellowGreen;
}
else
{
Hlink.NavigateUrl = "";
Hlink.ForeColor = System.Drawing.Color.YellowGreen;
}
if (strNavigate.Length >= 25)
{
Hlink.Text = strNavigate.Substring(0, 25);
}
else
{
Hlink.Text = strNavigate;
}
Label Company = new Label();
if (strCompany.Length >= 25)
{
Company.Text = strCompany.Substring(0, 25);
}
else
{
Company.Text = strCompany;
}
Label Caption = new Label();
if (strCaption.Length >= 35)
{
Caption.Text = strCaption.Substring(0, 35);
}
else
{
Caption.Text = strCaption;
}
TableRow Hyperlinkrow1 = new TableRow();
TableCell HyperCell1 = new TableCell();
HyperCell1.Controls.Add(Company);
HyperCell1.Font.Bold = true;
HyperCell1.Font.Size = 10;
HyperCell1.Font.Name = "Arial";
HyperCell1.ForeColor = System.Drawing.Color.Black;
HyperCell1.HorizontalAlign = HorizontalAlign.Center;
Hyperlinkrow1.Cells.Add(HyperCell1);
TableRow Hyperlinkrow2 = new TableRow();
TableCell HyperCell2 = new TableCell();
HyperCell2.Controls.Add(Caption);
HyperCell2.Font.Bold = true;
HyperCell2.Font.Size = 10;
HyperCell2.Font.Name = "Arial";
HyperCell2.ForeColor = System.Drawing.Color.Black;
HyperCell2.HorizontalAlign = HorizontalAlign.Center;
//Hyperlinkrow1.Cells.Add(HyperCell1);
Hyperlinkrow2.Cells.Add(HyperCell2);
TableRow Hyperlinkrow3 = new TableRow();
TableCell HyperCell3 = new TableCell();
HyperCell3.Controls.Add(Hlink);
HyperCell3.Font.Bold = true;
HyperCell3.Font.Size = 10;
HyperCell3.Font.Name = "Arial";
HyperCell3.ForeColor = System.Drawing.Color.GreenYellow;
HyperCell3.HorizontalAlign = HorizontalAlign.Center;
//Hyperlinkrow1.Cells.Add(HyperCell1);
Hyperlinkrow3.Cells.Add(HyperCell3);
TableAdvertise.Width = 400;
TableAdvertise.Rows.Add(Hyperlinkrow1);
TableAdvertise.Rows.Add(Hyperlinkrow2);
TableAdvertise.Rows.Add(Hyperlinkrow3);
TableCell Emptycell = new TableCell();
Emptycell.Text = "
";
TableRow EmptyRow = new TableRow();
EmptyRow.Cells.Add(Emptycell);
TableAdvertise.Rows.Add(EmptyRow);
TableAdvertise.Rows.Add(EmptyRow);
TableAdvertise.Rows.Add(EmptyRow);
}
else
{
TableCell Emptycell = new TableCell();
Emptycell.Text = "";
TableRow EmptyRow = new TableRow();
EmptyRow.Cells.Add(Emptycell);
TableAdvertise.Width = 400;
TableAdvertise.Rows.Add(EmptyRow);
TableAdvertise.Rows.Add(EmptyRow);
TableAdvertise.Rows.Add(EmptyRow);
}
//-------------------------------
TableRow tr4 = new TableRow();
TableCell tcx = new TableCell();
tcx.Text = "
";
tcx.ColumnSpan = 11;
tr4.Cells.Add(tcx);
Table1.Rows.Add(tr4);
TCell1.Controls.Add(Table1);
TCell2.Controls.Add(TableAdvertise);
FinalRow.VerticalAlign = VerticalAlign.Top;
FinalRow.Cells.Add(TCell1);
FinalRow.Cells.Add(TCell2);
TableFinalRender.Rows.Add(FinalRow);
}
WebSearchResult.Controls.Add(TableFinalRender);
}
}
private string CostofTransaction(string Cost)
{
string Currency = "";
if (Cost.Contains("Dollar"))
{
Currency = "($)USD";
}
else if (Cost.Contains("Euro"))
{
Currency = "(€)Euro";
}
else if (Cost.Contains("Pound"))
{
Currency = "(£)Pound";
}
else if (Cost.Contains("Yen"))
{
Currency = "(¥)Yen";
}
else if (Cost.Contains("Yuan"))
{
Currency = "(?)Yuan";
}
else if (Cost.Contains("LocalCurrency"))
{
Currency = "Loc Currency";
}
Cost = Cost.Replace("Dollar", "");
Cost = Cost.Replace("Euro", "");
Cost = Cost.Replace("Pound", "");
Cost = Cost.Replace("Yen", "");
Cost = Cost.Replace("Yuan", "");
Cost = Cost.Replace("LocalCurrency", "");
float strCost = 0;
strCost = float.Parse(Cost);
string FinalCostStr = "";
if (Math.Abs(strCost) < 1000000)
{
FinalCostStr = String.Format("{0:0.0}", strCost) + " " + Currency;
}
if (Math.Abs(strCost) > 1000000)
{
FinalCostStr = String.Format("{0:0.000}", (strCost / 1000000)) + " Million " + Currency;
}
if (Math.Abs(strCost) > 1000000000)
{
FinalCostStr = String.Format("{0:0.000}", (strCost / 1000000000)) + " Billion " + Currency;
}
return FinalCostStr;
}
private string EmployeeStrength(string number)
{
String strCost = "";
if (number == "20")
{
strCost = "0-20 Employees(Firm)";
return strCost;
}
else if (number == "50")
{
strCost = "20-50 Employees(Firm)";
return strCost;
}
else if (number == "500")
{
strCost = "50-500 Employees(Firm)";
return strCost;
}
else if (number == "2500")
{
strCost = "500-2.5K Employees(Firm)";
return strCost;
}
else if (number == "5000")
{
strCost = "2.5K-5K Employees(Firm)";
return strCost;
}
else if (number == "20000")
{
strCost = "5K-20K Employees(Firm) ";
return strCost;
}
else if (number == "50000")
{
strCost = "20K-50K Employees(Firm)";
return strCost;
}
else if (number == "100000")
{
strCost = "50K-100K Employees(Firm)";
return strCost;
}
else if (number == "200000")
{
strCost = "100K-200K Employees(Firm)";
return strCost;
}
else if (number == "500000")
{
strCost = "200K-500K Employees(Firm)";
return strCost;
}
else if (number == "Nation")
{
strCost = "(National-Community)";
return strCost;
}
else if (number == "City")
{
strCost = "(City Community)";
return strCost;
}
else if (number == "State")
{
strCost = "(State Community)";
return strCost;
}
else if (number == "Township")
{
strCost = "(Town Community)";
return strCost;
}
else if (number == "Rural")
{
strCost = "(Rural Community)";
return strCost;
}
else if (number == "Integrated")
{
strCost = "(Integrated)";
return strCost;
}
else if (number == "Science")
{
strCost = "(Science)";
return strCost;
}
else if (number == "Technology")
{
strCost = "(Technical)";
return strCost;
}
else if (number == "Arts")
{
strCost = "(Arts)";
return strCost;
}
else if (number == "SpecialSciences")
{
strCost = "(Special)";
return strCost;
}
else if (number == "OtherEducation")
{
strCost = "(Other Edu)";
return strCost;
}
else if (number == "10Years")
{
strCost = "(Age 10-15 Yrs)";
return strCost;
}
else if (number == "20Years")
{
strCost = "(Age 15-20 Yrs)";
return strCost;
}
else if (number == "30Years")
{
strCost = "(Age 20-30 Yrs)";
return strCost;
}
else if (number == "40Years")
{
strCost = "(Age 30-40 Yrs)";
return strCost;
}
else if (number == "50Years")
{
strCost = "(Age 40-50 Yrs)";
return strCost;
}
else if (number == "60Years")
{
strCost = "(Age 50-60 Yrs)";
return strCost;
}
else if (number == "70Years")
{
strCost = "(Age 60-70 Yrs)";
return strCost;
}
else if (number == "70YearsPlus")
{
strCost = "(Age 70+ Yrs)";
return strCost;
}
return strCost;
}
private string WebSearchEngineQuery()
{
string search = ViewState["SearchText"].ToString().Trim();
if (DDlistDiscipline.SelectedValue == "HR")
{
search = search + " " + "Jobs";
return search;
}
else if (DDlistDiscipline.SelectedValue == "Service")
{
search = search + " " + "Services";
return search;
}
else if (DDlistDiscipline.SelectedValue == "Offers")
{
search = search + " " + "Offers Discounts";
return search;
}
else if (DDlistDiscipline.SelectedValue == "Blogs")
{
search = search + " " + "Blogs";
return search;
}
else if (DDlistDiscipline.SelectedValue == "Books")
{
search = search + " " + "Books";
return search;
}
else if (DDlistDiscipline.SelectedValue == "News")
{
search = search + " " + "News";
return search;
}
else if (DDlistDiscipline.SelectedValue == "Video")
{
search = search + " " + "Video";
return search;
}
else if (DDlistDiscipline.SelectedValue == "Downloads")
{
search = search + " " + "Download";
return search;
}
else if (DDlistDiscipline.SelectedValue == "Reviews")
{
search = search + " " + "Review";
return search;
}
else if (DDlistDiscipline.SelectedValue == "Contact")
{
search = search + " " + "Contact address";
return search;
}
return search;
}
TCVECTE-TOMMY-TA--ENSTEGOENSTEIT [ EMECTIONAB-ENVECT ---- 128 FUNCTION NAMES ]
SOURAV-ENSTEGO ---1485 BBSR - ADVERFIC - TCVECTE-BUREAUOFFICE
}