public static Boolean exportTourData(String inSanctionId) { String curMethodName = "exportTourData"; StringBuilder curSqlStmt = new StringBuilder(""); StringBuilder curXml = new StringBuilder(""); Boolean returnStatus = false; try { curSqlStmt = new StringBuilder(""); curXml.Append("<LiveWebRequest>"); curSqlStmt = new StringBuilder(""); curSqlStmt.Append("SELECT * FROM Tournament "); curSqlStmt.Append("Where SanctionId = '" + inSanctionId + "' "); curXml.Append(exportData("Tournament", new String[] { "SanctionId" }, curSqlStmt.ToString(), "Update")); curXml.Append("</LiveWebRequest>"); SendMessageHttp.sendMessagePostXml(LiveWebLocation, curXml.ToString()); Log.WriteFile(curMethodName + ":Connection successsful to " + LiveWebLocation + " for tournament " + inSanctionId); returnStatus = true; } catch (Exception ex) { returnStatus = false; MessageBox.Show("Error encountered trying to send data to web location \n\nError: " + ex.Message); Log.WriteFile(curMethodName + ":Exception=" + ex.Message); } return(returnStatus); }
public static Boolean exportCurrentSkierTrickVideo(String inSanctionId, String inMemberId, String inAgeGroup, byte inRound) { String curMethodName = "exportCurrentSkierTrickVideo"; StringBuilder curSqlStmt = new StringBuilder(""); StringBuilder curXml = new StringBuilder(""); Boolean returnStatus = false; try { curSqlStmt = new StringBuilder(""); curXml.Append("<LiveWebRequest>"); curSqlStmt = new StringBuilder(""); curSqlStmt.Append("SELECT * FROM TrickVideo "); curSqlStmt.Append("Where SanctionId = '" + inSanctionId + "' And MemberId = '" + inMemberId + "' And AgeGroup = '" + inAgeGroup + "' "); curSqlStmt.Append("And Round = " + inRound); curXml.Append(exportData("TrickVideo", new String[] { "SanctionId", "MemberId", "AgeGroup", "Round" }, curSqlStmt.ToString(), "Insert")); curXml.Append("</LiveWebRequest>"); SendMessageHttp.sendMessagePostXml(LiveWebLocation, curXml.ToString()); returnStatus = true; } catch (Exception ex) { returnStatus = false; //MessageBox.Show( "Error encountered trying to send data to web location \n\nError: " + ex.Message ); Log.WriteFile(curMethodName + ":Exception=" + ex.Message); } return(returnStatus); }
public static Boolean sendMessage(String inMessage) { String curMethodName = "ExportLiveTwitter:sendMessage"; Boolean returnStatus = true; String curTwitterLocation = "https://api.twitter.com/1.1/statuses/update.json"; List <KeyValuePair <String, String> > curResponseDataList = null; String curMessage = inMessage; String curMessageParm = "status=" + Uri.EscapeDataString(curMessage); String curContentType = "application/x-www-form-urlencoded;charset=UTF-8"; String curSignatureMethod = myDefaultSignatureMethod; String curConsumerKey = myDefaultConsumerKey; String curConsumerSecret = myDefaultConsumerSecret; String curAccessToken = "", curAccessTokenSecret = ""; if (ExportLiveTwitter.TwitterRequestTokenURL.Equals(ExportLiveTwitter.TwitterDefaultAccount)) { curAccessToken = myDefaultAccessToken; curAccessTokenSecret = myDefaultAccessTokenSecret; } else { curAccessToken = ExportLiveTwitter.TwitterAccessToken; curAccessTokenSecret = ExportLiveTwitter.TwitterAccessTokenSecret; } String curOAuthNonce = Convert.ToBase64String(new ASCIIEncoding().GetBytes(DateTime.Now.Ticks.ToString())); String curOAuthVersion = Uri.EscapeDataString("1.0"); TimeSpan curTimeSpan = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); String curAuthTimestamp = Convert.ToInt64(curTimeSpan.TotalSeconds).ToString(); //Build the signature string StringBuilder curBaseString = new StringBuilder(""); curBaseString.Append("POST" + "&" + Uri.EscapeDataString(curTwitterLocation) + "&"); curBaseString.Append(Uri.EscapeDataString("oauth_consumer_key=" + curConsumerKey)); curBaseString.Append(Uri.EscapeDataString("&oauth_nonce=" + curOAuthNonce)); curBaseString.Append(Uri.EscapeDataString("&oauth_signature_method=" + curSignatureMethod)); curBaseString.Append(Uri.EscapeDataString("&oauth_timestamp=" + curAuthTimestamp)); curBaseString.Append(Uri.EscapeDataString("&oauth_token=" + curAccessToken)); curBaseString.Append(Uri.EscapeDataString("&oauth_version=" + curOAuthVersion)); curBaseString.Append(Uri.EscapeDataString("&status=" + Uri.EscapeDataString(curMessage))); // Sign the request String curSigningKey = Uri.EscapeDataString(curConsumerSecret) + "&" + Uri.EscapeDataString(curAccessTokenSecret); HMACSHA1 curHasher = new HMACSHA1(new ASCIIEncoding().GetBytes(curSigningKey)); String curSignature = Convert.ToBase64String(curHasher.ComputeHash(new ASCIIEncoding().GetBytes(curBaseString.ToString()))); ServicePointManager.Expect100Continue = false; StringBuilder curAuthHeaderParm = new StringBuilder(""); curAuthHeaderParm.Append("OAuth "); curAuthHeaderParm.Append("oauth_nonce=\"" + Uri.EscapeDataString(curOAuthNonce) + "\""); curAuthHeaderParm.Append(", oauth_signature_method=\"" + Uri.EscapeDataString(curSignatureMethod) + "\""); curAuthHeaderParm.Append(", oauth_timestamp=\"" + Uri.EscapeDataString(curAuthTimestamp) + "\""); curAuthHeaderParm.Append(", oauth_consumer_key=\"" + Uri.EscapeDataString(curConsumerKey) + "\""); curAuthHeaderParm.Append(", oauth_token=\"" + Uri.EscapeDataString(curAccessToken) + "\""); curAuthHeaderParm.Append(", oauth_signature=\"" + Uri.EscapeDataString(curSignature) + "\""); curAuthHeaderParm.Append(", oauth_version=\"" + curOAuthVersion + "\""); try { returnStatus = SendMessageHttp.sendMessagePostWithHeader(curTwitterLocation, curAuthHeaderParm.ToString(), curContentType, curMessageParm); } catch (Exception ex) { MessageBox.Show("Error encountered trying to send data to web location \n\nError: " + ex.Message); String curMsg = curMethodName + ":Exception=" + ex.Message; Log.WriteFile(curMsg); } return(returnStatus); }
public static Boolean getAppAccessToken() { String curMethodName = "ExportLiveTwitter:getAppAccessToken"; Boolean returnStatus = true; String curTwitterLocation = "https://api.twitter.com/oauth/access_token"; List <KeyValuePair <String, String> > curResponseDataList = null; //String curContentType = "application/x-www-form-urlencoded;charset=UTF-8"; String curContentType = "application/json"; String curSignatureMethod = myDefaultSignatureMethod; String curConsumerKey = myDefaultConsumerKey; String curConsumerSecret = myDefaultConsumerSecret; String curOAuthNonce = Convert.ToBase64String(new ASCIIEncoding().GetBytes(DateTime.Now.Ticks.ToString())); String curOAuthVersion = Uri.EscapeDataString("1.0"); TimeSpan curTimeSpan = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); String curAuthTimestamp = Convert.ToInt64(curTimeSpan.TotalSeconds).ToString(); //Build the signature string StringBuilder curBaseString = new StringBuilder(""); curBaseString.Append("POST" + "&" + Uri.EscapeDataString(curTwitterLocation) + "&"); curBaseString.Append(Uri.EscapeDataString("oauth_consumer_key=" + curConsumerKey)); curBaseString.Append(Uri.EscapeDataString("&oauth_nonce=" + curOAuthNonce)); curBaseString.Append(Uri.EscapeDataString("&oauth_signature_method=" + curSignatureMethod)); curBaseString.Append(Uri.EscapeDataString("&oauth_timestamp=" + curAuthTimestamp)); curBaseString.Append(Uri.EscapeDataString("&oauth_token=" + ExportLiveTwitter.TwitterRequestToken)); curBaseString.Append(Uri.EscapeDataString("&oauth_verifier=" + ExportLiveTwitter.TwitterAccessPin)); curBaseString.Append(Uri.EscapeDataString("&oauth_version=" + curOAuthVersion)); // Sign the request String curSigningKey = Uri.EscapeDataString(curConsumerSecret) + "&" + Uri.EscapeDataString(ExportLiveTwitter.TwitterAccessTokenSecret); HMACSHA1 curHasher = new HMACSHA1(new ASCIIEncoding().GetBytes(curSigningKey)); String curSignature = Convert.ToBase64String(curHasher.ComputeHash(new ASCIIEncoding().GetBytes(curBaseString.ToString()))); StringBuilder curAuthHeaderParm = new StringBuilder(""); curAuthHeaderParm.Append("OAuth auth_consumer_key=\"" + Uri.EscapeDataString(curConsumerKey) + "\""); curAuthHeaderParm.Append(", oauth_nonce=\"" + Uri.EscapeDataString(curOAuthNonce) + "\""); curAuthHeaderParm.Append(", oauth_signature_method=\"" + Uri.EscapeDataString(curSignatureMethod) + "\""); curAuthHeaderParm.Append(", oauth_signature=\"" + Uri.EscapeDataString(curSignature) + "\""); curAuthHeaderParm.Append(", oauth_timestamp=\"" + Uri.EscapeDataString(curAuthTimestamp) + "\""); curAuthHeaderParm.Append(", oauth_token=\"" + Uri.EscapeDataString(ExportLiveTwitter.TwitterRequestToken) + "\""); curAuthHeaderParm.Append(", oauth_verifier=\"" + Uri.EscapeDataString(ExportLiveTwitter.TwitterAccessPin + "\"")); curAuthHeaderParm.Append(", oauth_version=\"" + curOAuthVersion + "\""); String curMessageAuthParm = "oauth_verifier=" + ExportLiveTwitter.TwitterAccessPin; try { curResponseDataList = SendMessageHttp.sendMessagePostJsonResp(curTwitterLocation, curAuthHeaderParm.ToString(), curContentType, curMessageAuthParm); if (curResponseDataList.Count > 0) { foreach (KeyValuePair <String, String> curEntry in curResponseDataList) { if (curEntry.Key.Equals("oauth_token")) { ExportLiveTwitter.TwitterAccessToken = curEntry.Value; } else if (curEntry.Key.Equals("oauth_token_secret")) { ExportLiveTwitter.TwitterAccessTokenSecret = curEntry.Value; } else if (curEntry.Key.Equals("user_id")) { ExportLiveTwitter.TwitterAccessUserid = curEntry.Value; } else if (curEntry.Key.Equals("screen_name")) { ExportLiveTwitter.TwitterAccessUserScreenName = curEntry.Value; } } } } catch (Exception ex) { returnStatus = false; MessageBox.Show("Error encountered trying to send data to web location \n\nError: " + ex.Message); String curMsg = curMethodName + ":Exception=" + ex.Message; Log.WriteFile(curMsg); ExportLiveTwitter.TwitterAccessToken = ""; ExportLiveTwitter.TwitterAccessTokenSecret = ""; ExportLiveTwitter.TwitterAccessUserid = ""; ExportLiveTwitter.TwitterAccessUserScreenName = ""; } return(returnStatus); }
public static Boolean exportCurrentSkiersRunOrder(String inEvent, String inSanctionId, byte inRound, String inEventGroup) { String curMethodName = "exportCurrentSkiersRunOrder"; StringBuilder curSqlStmt = new StringBuilder(""); StringBuilder curXml = new StringBuilder(""); String curMsg = ""; Boolean returnStatus = false; int curLineCount = 0; DataTable curDataTable = new DataTable(); ProgressWindow myProgressInfo = new ProgressWindow(); try { curSqlStmt.Append("Select TR.SanctionId, TR.MemberId, TR.SkierName, TR.AgeGroup, ER.EventGroup, " + inRound + " as Round "); curSqlStmt.Append("From TourReg TR "); curSqlStmt.Append("Inner Join EventReg ER on ER.SanctionId = TR.SanctionId AND ER.MemberId = TR.MemberId "); curSqlStmt.Append(" AND TR.AgeGroup = ER.AgeGroup AND ER.Event = '" + inEvent + "' "); if (inRound > 0) { curSqlStmt.Append("Inner Join EventRunOrder RO on RO.SanctionId = TR.SanctionId AND RO.MemberId = TR.MemberId "); curSqlStmt.Append(" AND RO.AgeGroup = TR.AgeGroup AND RO.Event = ER.Event AND RO.Round = " + inRound + " "); } curSqlStmt.Append("Where TR.SanctionId = '" + inSanctionId + "' "); if (inEventGroup != null) { if (inEventGroup.Equals("All")) { } else if (inEventGroup.ToUpper().Equals("MEN A")) { curSqlStmt.Append("And ER.AgeGroup = 'CM' "); } else if (inEventGroup.ToUpper().Equals("WOMEN A")) { curSqlStmt.Append("And ER.AgeGroup = 'CW' "); } else if (inEventGroup.ToUpper().Equals("MEN B")) { curSqlStmt.Append("And ER.AgeGroup = 'BM' "); } else if (inEventGroup.ToUpper().Equals("WOMEN B")) { curSqlStmt.Append("And ER.AgeGroup = 'BW' "); } else if (inEventGroup.ToUpper().Equals("NON TEAM")) { curSqlStmt.Append("And ER.AgeGroup not in ('CM', 'CW', 'BM', 'BW') "); } else { curSqlStmt.Append("AND ER.EventGroup = '" + inEventGroup + "' "); } } curSqlStmt.Append("Order by TR.SanctionId, ER.EventGroup, TR.MemberId, TR.AgeGroup"); curDataTable = getData(curSqlStmt.ToString()); myProgressInfo.setProgressMin(1); myProgressInfo.setProgressMax(curDataTable.Rows.Count); String curMemberId = "", curAgeGroup = "", curSkierName = ""; byte curRound = 0; foreach (DataRow curRow in curDataTable.Rows) { curMemberId = (String)curRow["MemberId"]; curAgeGroup = (String)curRow["AgeGroup"]; curSkierName = (String)curRow["SkierName"]; curRound = (byte)((int)curRow["Round"]); curLineCount++; myProgressInfo.setProgressValue(curLineCount); myProgressInfo.setProgessMsg("Processing " + curSkierName); myProgressInfo.Show(); myProgressInfo.Refresh(); curXml = new StringBuilder(""); curXml.Append("<LiveWebRequest>"); curSqlStmt = new StringBuilder(""); curSqlStmt.Append("SELECT * FROM TourReg "); curSqlStmt.Append("Where SanctionId = '" + inSanctionId + "' And MemberId = '" + curMemberId + "' And AgeGroup = '" + curAgeGroup + "' "); curXml.Append(exportData("TourReg", new String[] { "SanctionId", "MemberId", "AgeGroup" }, curSqlStmt.ToString(), "Update")); curSqlStmt = new StringBuilder(""); curSqlStmt.Append("Select * from EventReg "); curSqlStmt.Append("Where SanctionId = '" + inSanctionId + "' And MemberId = '" + curMemberId + "' And AgeGroup = '" + curAgeGroup + "' "); curSqlStmt.Append("And Event = '" + inEvent + "' "); curXml.Append(exportData("EventReg", new String[] { "SanctionId", "MemberId", "AgeGroup", "Event" }, curSqlStmt.ToString(), "Update")); if (inRound > 0) { curSqlStmt = new StringBuilder(""); curSqlStmt.Append("Select * from EventRunOrder "); curSqlStmt.Append("Where SanctionId = '" + inSanctionId + "' And MemberId = '" + curMemberId + "' And AgeGroup = '" + curAgeGroup + "' "); curSqlStmt.Append("And Event = '" + inEvent + "' And Round = " + inRound); curXml.Append(exportData("EventRunOrder", new String[] { "SanctionId", "MemberId", "AgeGroup", "Event", "Round" }, curSqlStmt.ToString(), "Update")); } curXml.Append("</LiveWebRequest>"); SendMessageHttp.sendMessagePostXml(LiveWebLocation, curXml.ToString()); returnStatus = true; } myProgressInfo.Close(); } catch (Exception ex) { //MessageBox.Show( "Error encountered trying to send data to web location \n\nError: " + ex.Message ); curMsg = curMethodName + ":Exception=" + ex.Message; Log.WriteFile(curMsg); } return(returnStatus); }
public static Boolean exportCurrentSkierJump(String inSanctionId, String inMemberId, String inAgeGroup, byte inRound, int inPassNum, String inEventGroup) { String curMethodName = "exportCurrentSkierJump"; StringBuilder curSqlStmt = new StringBuilder(""); StringBuilder curXml = new StringBuilder(""); Boolean returnStatus = false; try { curSqlStmt = new StringBuilder(""); curXml.Append("<LiveWebRequest>"); if (inPassNum > 1) { curSqlStmt = new StringBuilder(""); curSqlStmt.Append("SELECT * FROM JumpScore "); curSqlStmt.Append("Where SanctionId = '" + inSanctionId + "' And MemberId = '" + inMemberId + "' And AgeGroup = '" + inAgeGroup + "' "); curSqlStmt.Append("And Round = " + inRound); curXml.Append(exportData("JumpScore", new String[] { "SanctionId", "MemberId", "AgeGroup", "Round" }, curSqlStmt.ToString(), "Insert")); curSqlStmt = new StringBuilder(""); curSqlStmt.Append("SELECT * FROM JumpRecap "); curSqlStmt.Append("Where SanctionId = '" + inSanctionId + "' And MemberId = '" + inMemberId + "' And AgeGroup = '" + inAgeGroup + "' "); if (inPassNum == 0) { curSqlStmt.Append("And Round = " + inRound); } else { curSqlStmt.Append("And Round = " + inRound + " And PassNum = " + inPassNum); } curXml.Append(exportData("JumpRecap", new String[] { "SanctionId", "MemberId", "AgeGroup", "Round", "PassNum" }, curSqlStmt.ToString(), "Insert")); } else { curSqlStmt = new StringBuilder(""); curSqlStmt.Append("SELECT * FROM TourReg "); curSqlStmt.Append("Where SanctionId = '" + inSanctionId + "' And MemberId = '" + inMemberId + "' And AgeGroup = '" + inAgeGroup + "' "); curXml.Append(exportData("TourReg", new String[] { "SanctionId", "MemberId", "AgeGroup" }, curSqlStmt.ToString(), "Update")); curSqlStmt = new StringBuilder(""); curSqlStmt.Append("Select * from EventReg "); curSqlStmt.Append("Where SanctionId = '" + inSanctionId + "' And MemberId = '" + inMemberId + "' And AgeGroup = '" + inAgeGroup + "' "); curSqlStmt.Append("And Event = 'Jump'"); curXml.Append(exportData("EventReg", new String[] { "SanctionId", "MemberId", "AgeGroup", "Event" }, curSqlStmt.ToString(), "Update")); curSqlStmt = new StringBuilder(""); curSqlStmt.Append("Select * from EventRunOrder "); curSqlStmt.Append("Where SanctionId = '" + inSanctionId + "' And MemberId = '" + inMemberId + "' And AgeGroup = '" + inAgeGroup + "' "); curSqlStmt.Append("And Event = 'Jump' And Round = " + inRound); curXml.Append(exportData("EventRunOrder", new String[] { "SanctionId", "MemberId", "AgeGroup", "Event", "Round" }, curSqlStmt.ToString(), "Update")); curSqlStmt = new StringBuilder(""); curSqlStmt.Append("SELECT SanctionId, MemberId, AgeGroup, Round FROM JumpScore "); curSqlStmt.Append("Where SanctionId = '" + inSanctionId + "' And MemberId = '" + inMemberId + "' And AgeGroup = '" + inAgeGroup + "' "); curSqlStmt.Append("And Round = " + inRound); curXml.Append(exportData("JumpScore", new String[] { "SanctionId", "MemberId", "AgeGroup", "Round" }, curSqlStmt.ToString(), "Delete")); curSqlStmt = new StringBuilder(""); curSqlStmt.Append("SELECT Distinct SanctionId, MemberId, AgeGroup, Round FROM JumpRecap "); curSqlStmt.Append("Where SanctionId = '" + inSanctionId + "' And MemberId = '" + inMemberId + "' And AgeGroup = '" + inAgeGroup + "' "); if (inPassNum == 0) { curSqlStmt.Append("And Round = " + inRound); } else { curSqlStmt.Append("And Round = " + inRound + " And PassNum = " + inPassNum); } curXml.Append(exportData("JumpRecap", new String[] { "SanctionId", "MemberId", "AgeGroup", "Round" }, curSqlStmt.ToString(), "Delete")); curSqlStmt = new StringBuilder(""); curSqlStmt.Append("SELECT * FROM JumpScore "); curSqlStmt.Append("Where SanctionId = '" + inSanctionId + "' And MemberId = '" + inMemberId + "' And AgeGroup = '" + inAgeGroup + "' "); curSqlStmt.Append("And Round = " + inRound); curXml.Append(exportData("JumpScore", new String[] { "SanctionId", "MemberId", "AgeGroup", "Round" }, curSqlStmt.ToString(), "Update")); curSqlStmt = new StringBuilder(""); curSqlStmt.Append("SELECT * FROM JumpRecap "); curSqlStmt.Append("Where SanctionId = '" + inSanctionId + "' And MemberId = '" + inMemberId + "' And AgeGroup = '" + inAgeGroup + "' "); if (inPassNum == 0) { curSqlStmt.Append("And Round = " + inRound); } else { curSqlStmt.Append("And Round = " + inRound + " And PassNum = " + inPassNum); } curXml.Append(exportData("JumpRecap", new String[] { "SanctionId", "MemberId", "AgeGroup", "Round", "PassNum" }, curSqlStmt.ToString(), "Update")); } curXml.Append("</LiveWebRequest>"); SendMessageHttp.sendMessagePostXml(LiveWebLocation, curXml.ToString()); returnStatus = true; } catch (Exception ex) { returnStatus = false; //MessageBox.Show( "Error encountered trying to send data to web location \n\nError: " + ex.Message ); Log.WriteFile(curMethodName + ":Exception=" + ex.Message); } return(returnStatus); }