public StatsManagement(string connectionString, SessionProperties sessionProperties) : base(connectionString, sessionProperties) { }
public ClubManagement(string connectionString, SessionProperties sessionProperties) : base(connectionString, sessionProperties) { }
public CommonDataFetches(string connectionString, SessionProperties sessionProperties) : base(connectionString, sessionProperties) { }
public IntiManagementBase(string connectionString, SessionProperties sessionProperties) { _connectionString = connectionString; _sessionProperties = sessionProperties; }
public UserTeamManagement(string connectionString, SessionProperties sessionProperties) : base(connectionString, sessionProperties) { }
public static void SendTweet(string tweet, string appendUrl, SessionProperties sessionProperties) { if (TwitterService == null) { InitiateTwitterAuthentication(sessionProperties); } if (TwitterService == null) { WebControlManager.SendAndLogErrorMessage(new Exception("TwitterService not initialized"), Parameters.Instance.MailSender, Parameters.Instance.SupportMail); //clear authentication, guess we need to authenticate again? Parameters.Instance.TwitterAccessToken = null; Parameters.Instance.TwitterAccessTokenSecret = null; return; } try { //format the string, replace if (tweet.Contains("&")) { tweet = HttpUtility.HtmlDecode(tweet); } string shortUrl = String.Empty; //parse url to shorturl if (!String.IsNullOrEmpty(appendUrl)) { IBitlyService s = new BitlyService("o_3cpfcndji4", "R_8e203358cb5ca0f68d809419b056b192"); string shortened = s.Shorten(appendUrl); if (shortened != null) { shortUrl = " " + shortened; } } var maxLength = 140 - shortUrl.Length; if (tweet.Length > maxLength) tweet = tweet.Substring(0, maxLength); tweet += shortUrl; TwitterService.SendTweet(new SendTweetOptions(){Status = tweet}); // Likely this is an error; we don't have to go fishing for it TwitterError error = TwitterService.Response.Error; TwitterResponse response = TwitterService.Response; if (error != null || response.StatusCode != HttpStatusCode.OK) { // You now know you have a real error from Twitter, and can handle it string message; if (error != null) { message = String.Format("Twitter error: {0} ({1})", error.Message, error.Code); } else { message = String.Format("Twitter response status not ok: {0} ({1})\n{2}", response.StatusDescription, response.StatusCode, response.Response); } WebControlManager.SendAndLogErrorMessage(new Exception(message), Parameters.Instance.MailSender, Parameters.Instance.SupportMail); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
//public static string TwitterAccessToken { get; set; } //public static string TwitterAccessTokenSecret { get; set; } private static void InitiateTwitterAuthentication(SessionProperties sessionProperties) { if (String.IsNullOrEmpty(Parameters.Instance.TwitterAccessToken) || String.IsNullOrEmpty(Parameters.Instance.TwitterAccessTokenSecret)) return; try { // Step 3 - Exchange the Request Token for an Access Token Global.TwitterService = new TwitterService(Global.TwitterConsumerKey, Global.TwitterConsumerSecret); // Step 4 - User authenticates using the Access Token Global.TwitterService.AuthenticateWith(Parameters.Instance.TwitterAccessToken, Parameters.Instance.TwitterAccessTokenSecret); TwitterUser user = Global.TwitterService.VerifyCredentials(new VerifyCredentialsOptions()); if (user == null) TwitterService = null; } catch (Exception exception) { WebControlManager.SendAndLogErrorMessage(exception, Parameters.Instance.MailSender, Parameters.Instance.SupportMail); Global.TwitterService = null; } }
protected void Session_Start(object sender, EventArgs e) { var clientInfo = WebControlManager.GetClientInfo(); var sessionInfo = new SessionProperties(true, clientInfo); //get the default tournament using (var db = Global.GetConnection()) { var tours = from t in db.Inti_Tournament select t; foreach (var tour in tours.OrderByDescending(tStart => tStart.StartRegistration).ToList()) { sessionInfo.SelectedTournament = tour; sessionInfo.DefaultTournament = tour; break; } } if (Request.Cookies != null) { if (Request.Cookies.Get("SignMeIn") != null) { //automatic sign in sessionInfo.UserGuid = new Guid(Request.Cookies["SignMeIn"].Value); //set user guid var user = new UserManagement(Global.ConnectionString, sessionInfo).GetUserByGuid(sessionInfo.UserGuid); sessionInfo.UserName = user.UserName; //set footer text sessionInfo.FooterText = String.Format("Inloggad som {0} {1}", user.FirstName, user.LastName); //set permissions sessionInfo.Permissions = new UserManagement(Global.ConnectionString, sessionInfo).GetUserPermissions(sessionInfo.UserName); } } //set as not signed in HttpContext.Current.Session.RemoveAll(); HttpContext.Current.Session.Add("sessionProps", sessionInfo); }