private void addNew(EventArgs e) { QT.Moduls.Company.DBComTableAdapters.Job_WebsiteConfigLogTableAdapter adtJob = new QT.Moduls.Company.DBComTableAdapters.Job_WebsiteConfigLogTableAdapter(); adtJob.Connection.ConnectionString = Server.ConnectionString; Company.frmAddWeb frm = new Company.frmAddWeb(); frm.Text = "Thêm mới website"; if (frm.ShowDialog() == DialogResult.OK) { TimeSpan timestartup = new TimeSpan(0, 1, 1, 0); TimeSpan timeSleep = new TimeSpan(0, 1, 1, 0); Uri uri = new Uri(frm.Website); String domain = uri.Host.ToLower(); domain = domain.Replace("www.", ""); Alexa a = new Alexa(); a = Common.GetRankAlexa(uri.Host); try { this.companyTableAdapter1.Insert( Common.GetIDCompany(domain), "", "", frm.Website, domain, DateTime.Now, "", "", "", "", Common.CompanyStatus.NOTCONFIG, "", a.AlexaRankContries, a.AlexaRank, timestartup, timeSleep, 0, 0, DateTime.Now, DateTime.Now, 30, 0, 0, 0, "", DateTime.Now, 0, 0, "", false, 0, DateTime.Now.AddYears(-1), DateTime.Now.AddYears(-1)); adtJob.Insert(QT.Users.User.UserID, Common.GetIDCompany(domain), "", "", QT.Users.JobNhapLieuStatus.NhapMoi, DateTime.Now); LogJobAdapter.SaveLog(JobName.FrmCompany_AddNew, "Thêm mới công ty " + domain, Convert.ToInt64(Common.GetIDCompany(domain)), (int)JobTypeData.Company); } catch (Exception) { MessageBox.Show("Website này đã có trong hệ thống"); } _command = Common.ListWebCommand.ViewProfile; GetIDCompanyCurrent = Common.GetIDCompany(domain); ExcuteCommand(_command, e); } }
public static void Main(string[] args) { Program prg = new Program(); Alexa alexa = new Alexa(); Bing bing = new Bing(); string folder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); string inputfilename = "urls.txt"; string outputfilename = "siteranks.csv"; string inputpath = Path.Combine(folder, inputfilename); string outputpath = Path.Combine(folder, outputfilename); Dictionary <string, List <int> > siteranks = new Dictionary <string, List <int> >(); //Reading urls and saving to a dictionary if (File.Exists(inputpath)) { string[] urls = File.ReadAllLines(inputpath); //create array and put urls from urls.txt inside it foreach (var url in urls) { int alexarank = Alexa.GetAlexaRank(url); int bingrank = Bing.GetBingRank(url); List <int> ranklist = new List <int>(); ranklist.Add(alexarank); ranklist.Add(bingrank); siteranks.Add(url, ranklist); //add the url and the ranks list to the siteranks dictionary if (prg.debug) { Console.WriteLine(url + "," + ranklist[0] + "," + ranklist[1]); } } Console.WriteLine("SUCCESS! Check your Documents folder for the output file"); } else { Console.WriteLine("ERROR! Please provide a list of urls in a file named 'urls.txt' in your Documents folder"); } //Writing dictionary to alexaranks.csv using (var file = new StreamWriter(outputpath)) //opens or creates new csv file to write url and corresponding site rank to. add true here if you want to append instead of overwrite { foreach (var siterank in siteranks) //for each url and corresponding site rank { file.WriteLine("{0},{1},{2}", siterank.Key, siterank.Value[0], siterank.Value[1]); //write each url and corresponding site ranks to the file created or opened } } //Not sure what this line does but it works if used in lieu of the function above so leaving it commented in for future reference //File.WriteAllLines(outputpath, siteranks.Select(x => x.Key + "," + x.Value).ToArray()); }
public static void AskAlexa() { var alexa = new Alexa(); Console.WriteLine(alexa.Talk()); alexa.Configure(x => { x.greetingmessage = "Hello {ownername}, I'm at your service"; x.ownername = "Bob Markey"; } ); Console.WriteLine(alexa.Talk()); }
public static void ReadWebSiteRanking() { try { using (var alexa = new Alexa("xomorod.com")) { ConnectionManager.GetDefaultConnection().SqlConn.Execute("sp_TrafficRankings_Insert", new { GlobalRank = alexa.GetGlobalRanking(), IranRank = alexa.GetLocalRanking() }, commandType: CommandType.StoredProcedure); } } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); } }
private static void Main(string[] args) { var alexa = new Alexa(); Console.WriteLine(alexa.Talk()); //print hello, i am Alexa alexa.Configure(x => { x.GreetingMessage = "Hello {OwnerName}, I'm at your service"; x.OwnerName = "Bob Marley"; }); Console.WriteLine(alexa.Talk()); //print Hello Bob Marley, I'm at your service Console.WriteLine("press any key to exit ..."); Console.ReadKey(); }
public static void PlayDemo() { Alexa johnsAlexa = new Alexa(); IOTDevice johnsIOTDevice = new VinnysHomeAutomation(); johnsIOTDevice.Connect(new WindowCurtains("John's Room Curtains")); johnsIOTDevice.Connect(new WindowCurtains("Kitchen Curtains")); johnsIOTDevice.Connect(new AirConditioning("Central AC")); johnsIOTDevice.Connect(new DogFeeder("Dog Sonu")); johnsIOTDevice.Connect(new DogFeeder("Dog Ana")); johnsIOTDevice.Connect(new Dishwasher("Dish-washer")); johnsIOTDevice.Connect(new LightingSystem("Living Room Lighting")); johnsIOTDevice.Connect(new LightingSystem("Kitchen Lights")); johnsIOTDevice.Connect(new LightingSystem("Backyard Lights")); johnsIOTDevice.Connect(new Sprinkler("Garden Sprinkler")); johnsIOTDevice.Connect(new Blender("Smoothie")); johnsIOTDevice.Connect(new Alarm("Alarm")); johnsAlexa.Interface(johnsIOTDevice); johnsAlexa.Run(); }
private void btupdatefulltext_Click(object sender, EventArgs e) { Alexa item = Common.GetRankAlexa("dienmayrenhat.com"); }
public override int GetHashCode() { return(Alexa != null ? Alexa.GetHashCode() : 0); }
void doCrawler() { dtCom = new DB.CompanyDataTable(); adtCom = new DBTableAdapters.CompanyTableAdapter(); adtCom.Connection.ConnectionString = QT.Entities.Server.ConnectionString; if (adtCom.Connection.State == ConnectionState.Closed) { adtCom.Connection.Open(); } if (chkFind.Checked == true) { webCRC = new List <long>(); adtCom.Fill(dtCom); int i0 = 0; foreach (var dr in dtCom) { i0 = webCRC.BinarySearch(dr.ID); if (i0 < 0) { webCRC.Insert(~i0, dr.ID); } } //adtCom.Connection.Close(); //adtCom.Dispose(); //dtCom.Dispose(); } visitedCount = 0; crawlerLink = new Queue <string>(); visitedCRC = new List <long>(); rootUri = new Uri(rootUrl); crawlerLink.Enqueue(rootUrl); while (crawlerLink.Count > 0) { if (finish) { break; } if (!pause) { string c_url = crawlerLink.Dequeue(); try { string html = GABIZ.Base.HtmlUrl.HTMLTransmitter.getHTML(c_url, 45, 2); if (html != "") { GABIZ.Base.HtmlAgilityPack.HtmlDocument doc = new GABIZ.Base.HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(html); var a_nodes = doc.DocumentNode.SelectNodes("//a[@href]"); if (a_nodes != null) { #region add link to process for (int i = 0; i < a_nodes.Count; i++) { string s = Common.GetAbsoluteUrl(a_nodes[i].Attributes["href"].Value, rootUri); if (!IsNoVisitUrl(s)) { long s_crc = Tools.getCRC64(LinkCanonicalization.NormalizeLink(s)); int index = visitedCRC.BinarySearch(s_crc); if (index < 0) { if (IsRelevantUrl(s)) { crawlerLink.Enqueue(s); } visitedCRC.Insert(~index, s_crc); if (chkFind.Checked == true) { if (!IsRelevantUrl(s)) { Uri uri = new Uri(s); TimeSpan timestartup = new TimeSpan(0, 1, 1, 0); TimeSpan timeSleep = new TimeSpan(0, 1, 1, 0); String domain = uri.Host.ToLower(); domain = domain.Replace("www.", ""); long idcom = Common.GetIDCompany(domain); int index1 = webCRC.BinarySearch(idcom); if (index1 < 0) { Alexa a = new Alexa(); a = Common.GetRankAlexa(uri.Host); Thread.Sleep(Common.Obj2Int(txtDelay.Text.Trim())); countWeb++; webCRC.Insert(~index1, idcom); adtCom.Insert( idcom, "", "Tìm thấy từ " + txtURL.Text, domain, domain, DateTime.Now, "", "", "", "", Common.CompanyStatus.WEB_ADDNEWS, false, "", a.AlexaRankContries, a.AlexaRank, timestartup, timeSleep, 500, 0, DateTime.Now, DateTime.Now, 30, 0, 0, 0, "", DateTime.Now, "", 0, DateTime.Now, 0, "", "", true, false, false, true, true, true, null, null, false, "", 3); } } } } } } #endregion } if (showLog) { #region show log this.Invoke((MethodInvoker) delegate { lblVisited.Text = visitedCount.ToString(); lblQueue.Text = crawlerLink.Count.ToString(); lblProduct.Text = countWeb.ToString(); txtUrlCurrent.Text = currentUrl; var xx = DateTime.Now - start; DateTime mydate = new DateTime(xx.Ticks); lblTime.Text = mydate.ToString("HH:mm:ss"); lblIgnored.Text = ignoredCount.ToString(); }); #endregion } } visitedCount++; currentUrl = c_url; } catch (Exception ex) { FileLog.WriteAppendText(DateTime.Now.ToString("dd/MM HH:mm:ss") + "\t, " + c_url + "\r\n" + ex.ToString(), rootUri.Host + ".csv"); } } } finish = true; crawlerLink.Clear(); crawlerLink = null; this.timer1.Start(); if (crawlerThread != null) { if (crawlerThread.IsAlive) { crawlerThread.Abort(); crawlerThread.Join(); crawlerThread = null; } } }
public async Task <ActionResult> Ranking(string url = null) { ViewBag.Title = Localization.XomorodRanking; var alexa = new Alexa(url ?? SecurityKeys.WebSiteRout); var trends = ConnectionManager.GetDefaultConnection().SqlConn.Query("Select * From dbo.udft_TrafficRankings()").ToList(); var gData = new object[trends.Count(), 2]; // global ranking data var iData = new object[trends.Count(), 2]; // iran ranking data for (var i = 0; i < trends.Count(); i++) { // The x value of the point. For datetime axes, the X value is the timestamp in milliseconds since 1970. gData[i, 0] = new TimeSpan(((DateTime)trends[i].ModifyDate).Subtract(new DateTime(1970, 1, 1)).Ticks).TotalMilliseconds; iData[i, 0] = gData[i, 0]; // The y value of the point. Defaults to null. gData[i, 1] = (double)trends[i].GlobalRanking; iData[i, 1] = (double)trends[i].IranRanking; } var rangeSelect = new RangeSelector() { Buttons = new[] { //new ButtonsItems() { Type = "hour", Count = 12, Text = "12h" }, new ButtonsItems() { Type = "day", Count = 3, Text = Localization._3day }, new ButtonsItems() { Type = "week", Count = 1, Text = Localization._1week }, new ButtonsItems() { Type = "month", Count = 1, Text = Localization._1month }, new ButtonsItems() { Type = "month", Count = 6, Text = Localization._6month }, new ButtonsItems() { Type = "year", Count = 1, Text = Localization._1year }, new ButtonsItems() { Type = "all", Text = Localization.All } }, Selected = 5 }; DotNet.Highstock.Highstock gChart = new DotNet.Highstock.Highstock("gStockChart"); DotNet.Highstock.Highstock iChart = new DotNet.Highstock.Highstock("iStockChart"); gChart.SetTitle(new Title() { Text = Localization.GlobalHistoricalTrafficTrends }); iChart.SetTitle(new Title() { Text = Localization.IranHistoricalTrafficTrends }); gChart.SetYAxis(new[] { new YAxis { Title = new YAxisTitle() { Text = Localization.RankingScore }, LineWidth = 2 } }); iChart.SetYAxis(new[] { new YAxis { Title = new YAxisTitle() { Text = Localization.RankingScore }, LineWidth = 2 } }); gChart.SetSeries( new Series() { Data = new Data(gData), Color = Color.DeepSkyBlue, DashStyle = DashStyles.Solid, Type = ChartTypes.Line, Name = "Global" }); iChart.SetSeries( new Series() { Data = new Data(iData), Color = Color.Aquamarine, DashStyle = DashStyles.Solid, Type = ChartTypes.Column, Name = "Iran" }); gChart.SetRangeSelector(rangeSelect); iChart.SetRangeSelector(rangeSelect); ViewData.Add("GlobalChart", gChart); ViewData.Add("IranChart", iChart); var ps = new PageSpeed(url ?? SecurityKeys.WebSiteRout) { Screenshot = true }; await ps.AnalyzeAsync(); return(View(Tuple.Create(alexa, ps))); }
private void CheckCompanyButton_Click(object sender, EventArgs e) { Wait.Show("Đang kiểm tra công ty!"); //idcomnay này có thể là idharavan hoặc id mới đc sinh ra theo domain chính xác long idcompany = Common.Obj2Int64(companyIdWSSSpinEdit.Text); //QT.Entities.Company company = new QT.Entities.Company(idcompany); #region CheckCompany try { DBWebPartnerTableAdapters.CompanyTableAdapter companyAdapter = new DBWebPartnerTableAdapters.CompanyTableAdapter(); companyAdapter.Connection.ConnectionString = Server.ConnectionString; DBWebPartner.CompanyDataTable _companyTable = new DBWebPartner.CompanyDataTable(); companyAdapter.FillBy_ID(_companyTable, idcompany); //Trường hợp cài app thành công nhưng lúc tạo ra company xảy ra lỗi (api.websosanh.vn). // Lấy dữ liệu company từ haravan và thêm mới vào database. if (_companyTable.Rows.Count == 0) { string shopname = shopNameTextEdit.Text; string accesstoken = accessTokenTextEdit.Text; HaravanAuthorizationState authorizeState = new HaravanAuthorizationState(); authorizeState.ShopName = shopname; authorizeState.AccessToken = accesstoken; var client = new HaravanAPIClient(authorizeState); object obj = client.Get("/admin/shop.json"); if (obj != null) { ShopHaravanInfo shopharavanInfo = JsonConvert.DeserializeObject <ShopHaravanInfo>(obj.ToString()); //domain và website lấy theo domain chính xác được config (hoặc mặc định là shopname.myharavan.com) string website = string.Format("http://{0}/", domainChinhXacTextEdit.Text); Uri uri = new Uri(website); String domain = uri.Host.ToLower(); domain = domain.Replace("www.", ""); TimeSpan timestartup = new TimeSpan(0, 1, 1, 0); TimeSpan timeSleep = new TimeSpan(0, 1, 1, 0); Alexa a = new Alexa(); a = Common.GetRankAlexa(uri.Host); #region Insert try { companyAdapter.Insert( Common.GetIDCompany(domain), authorizeState.ShopName, "Shop in Haravan install App", website, domain, DateTime.Now, shopharavanInfo.shop.phone, shopharavanInfo.shop.email, shopharavanInfo.shop.customer_email, shopharavanInfo.shop.address1, Common.CompanyStatus.WEB_HARAVAN, "", a.AlexaRankContries, a.AlexaRank, timestartup, timeSleep, 0, 0, DateTime.Now, DateTime.Now, 30, 0, 0, 0, "", DateTime.Now, 0); Log.InfoFormat("HARAVAN : Insert Company Success With ShopName = {0}", authorizeState.ShopName); MessageBox.Show("Thêm mới công ty thành công!"); } catch (Exception ex) { Log.ErrorFormat("HARAVAN : Error Insert Company {0}", ex); } #endregion } } else { MessageBox.Show("Có công ty này!"); } } catch (Exception exx) { Log.ErrorFormat("HARAVAN : CheckCompany {0}", exx); } #endregion Wait.Close(); }