public void GetSocialSiteData() { try { string dirPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\SocialScoupDataServiceSetup"; string path = dirPath + "\\hibernate.cfg.xml"; string startUpFilePath = Application.StartupPath + "\\hibernate.cfg.xml"; Console.Write(dirPath + " " + path + " " + startUpFilePath); if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath); } if (!File.Exists(path)) { File.Copy(startUpFilePath, path); } SessionFactory.configfilepath = path; SocialProfilesRepository objSocioRepo = new SocialProfilesRepository(); //string path = System.IO.Path.GetFullPath("hibernate.cfg.xml"); // SessionFactory.configfilepath = path; NHibernate.ISession session = SessionFactory.GetNewSession(); new Thread(() => { while (true) { ThreadPool.SetMaxThreads(10, 4); List<SocialProfile> lstUser = objSocioRepo.getAllSocialProfiles(); if (lstUser != null) { if (lstUser.Count != 0) { foreach (var item in lstUser) { switch (item.ProfileType) { case "twitter": try { TwitterData objTwitter = new TwitterData(); ThreadPool.QueueUserWorkItem(new WaitCallback(objTwitter.getTwitterData), (object)item.UserId); } catch (Exception err) { Console.Write(err.StackTrace); } break; case "facebook": try { FacebookData objFacebook = new FacebookData(); ThreadPool.QueueUserWorkItem(new WaitCallback(objFacebook.GetFacebookData), (object)item.UserId); // objFacebook.GetFacebookData((object)item.UserId); } catch (Exception err) { Console.Write(err.StackTrace); } break; case "linkedin": try { LinkedInData objLi = new LinkedInData(); ThreadPool.QueueUserWorkItem(new WaitCallback(objLi.GetLinkedIndata), (object)item.UserId); } catch (Exception err) { Console.Write(err.StackTrace); } break; case "instagram": try { InstagramData objIns = new InstagramData(); ThreadPool.QueueUserWorkItem(new WaitCallback(objIns.getIntagramImages), (object)item.UserId); } catch (Exception err) { Console.Write(err.StackTrace); } break; case "googleanalytics": try { GoogleAnalyticsData gaData = new GoogleAnalyticsData(); ThreadPool.QueueUserWorkItem(new WaitCallback(gaData.getAnalytics), (object)item.UserId); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } break; case "googleplus": try { GplusData gpData = new GplusData(); ThreadPool.QueueUserWorkItem(new WaitCallback(gpData.getGplusData), (object)item.UserId); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } break; } } } else { Console.WriteLine("No active record in Database"); } } else { Console.WriteLine("No active record in Database"); } Thread.Sleep(1000 * 60 * 15); } }).Start(); } catch (Exception ex) { Console.WriteLine("Error Case Debug : " + ex.StackTrace); Console.WriteLine("Error Case Debug : " + ex.Message); GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } }
private static void RunDataService() { SocialProfilesRepository objSocioRepo = new SocialProfilesRepository(); while (true) { ThreadPool.SetMaxThreads(10, 4); List<SocialProfile> lstUser = objSocioRepo.getAllSocialProfiles(); if (lstUser != null) { if (lstUser.Count != 0) { foreach (var item in lstUser) { clsSocialSiteDataFeedsFactory objclsSocialSiteDataFeedsFactory = new clsSocialSiteDataFeedsFactory(item.ProfileType); SocialSiteDataFeeds objSocialSiteDataFeeds = objclsSocialSiteDataFeedsFactory.CreateSocialSiteDataFeedsInstance(); objSocialSiteDataFeeds.GetData((object)item.UserId); //switch (item.ProfileType) //{ // case "twitter": // try // { // TwitterData objTwitter = new TwitterData(); // ThreadPool.QueueUserWorkItem(new WaitCallback(objTwitter.getTwitterData), (object)item.UserId); // //// objTwitter.getTwitterData((object)item.UserId); // // SocialSiteDataFeeds sc = new TwitterData(); // // sc.GetData((object)item.UserId); // } // catch (Exception err) // { // Console.Write(err.StackTrace); // } // break; // case "facebook": // try // { // FacebookData objFacebook = new FacebookData(); // ThreadPool.QueueUserWorkItem(new WaitCallback(objFacebook.GetFacebookData), (object)item.UserId); // //objFacebook.GetFacebookData((object)item.UserId); // } // catch (Exception err) // { // Console.Write(err.StackTrace); // } // break; // case "linkedin": // try // { // LinkedInData objLi = new LinkedInData(); // ThreadPool.QueueUserWorkItem(new WaitCallback(objLi.GetLinkedIndata), (object)item.UserId); // //objLi.GetLinkedIndata((object)item.UserId); // } // catch (Exception err) // { // Console.Write(err.StackTrace); // } // break; // case "instagram": try // { // InstagramData objIns = new InstagramData(); // ThreadPool.QueueUserWorkItem(new WaitCallback(objIns.getIntagramImages), (object)item.UserId); // } // catch (Exception err) // { // Console.Write(err.StackTrace); // } // break; // case "googleanalytics1": try // { // GoogleAnalyticsData gaData = new GoogleAnalyticsData(); // ThreadPool.QueueUserWorkItem(new WaitCallback(gaData.getAnalytics), (object)item.UserId); // } // catch (Exception ex) // { // Console.WriteLine(ex.StackTrace); // } // break; // case "googleplus1": try // { // GplusData gpData = new GplusData(); // ThreadPool.QueueUserWorkItem(new WaitCallback(gpData.getGplusData), (object)item.UserId); // } // catch (Exception ex) // { // Console.WriteLine(ex.StackTrace); // } // break; // case "tumblr": try // { // TumblrData tumblrData = new TumblrData(); // //try // //{ // // using (MySql.Data.MySqlClient.MySqlConnection con = new MySql.Data.MySqlClient.MySqlConnection("Data Source=localhost;User ID= root;Password=abhay;persist security info=False;initial catalog=abhay3;pooling=false;charset=utf8;")) // // { // // con.Open(); // // using (MySql.Data.MySqlClient.MySqlDataAdapter da = new MySql.Data.MySqlClient.MySqlDataAdapter("Select * from TumblrAccount where UserId='" + item.UserId + "'", con)) // // { // // System.Data.DataSet ds = new System.Data.DataSet(); // // da.Fill(ds); // // } // // } // //} // //catch (Exception ex) // //{ // // Console.WriteLine("Error : " + ex.StackTrace); // //} // //ThreadPool.QueueUserWorkItem(new WaitCallback(tumblrData.GetData), (object)item.UserId); // tumblrData.GetData((object)item.UserId); // } // catch (Exception ex) // { // Console.WriteLine(ex.StackTrace); // } // break; //} } } else { Console.WriteLine("No active record in Database"); } } else { Console.WriteLine("No active record in Database"); } Thread.Sleep(1000 * 60 * 15); } }