private static DataSet GetCompleteDatasetIteratively(ScribeConnection connection, string action, string accountId = null, string eventId = null, DateTime?modifiedAfter = null, DateTime?modifiedBefore = null, string additionCondition = null, Dictionary <string, string> keypairs = null) { var hasMoreRecords = true; DataSet returnSet = new DataSet(); List <DataSet> sets = new List <DataSet>(); int pageNumber = 1; while (hasMoreRecords) { var ds = GetDatasetIteratively(connection, action, accountId, eventId, null, null, null, null, pageNumber); //While there are if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { sets.Add(ds); if (ds.Tables[0].Rows.Count < connection.PageSize) { hasMoreRecords = false; } } else { hasMoreRecords = false; } pageNumber++; } returnSet.copyDataTable(sets); return(returnSet); }
/* https://www.eiseverywhere.com/api/v2/ereg/createEvent.format Parameters accesstoken required The access token assigned to you from the authorize function. Example: Ub57+fu2p/4KcaqIRNUNQD9HV8nWid+7flRBxbskZIv/DWkaZG0+e6H6ZcjPaAoAGqOtjSq4tHh9ChxUChZdZw== name required The name to create the new event with. folder optional The ID of folder to create the event in. Must be a numeric value. modules optional Array containing the names of modules to turn on for the event. Valid values are (case sensitive): 'eRFP', 'eBudget', 'eProject', 'eScheduler', 'eWiki', 'eHome', 'eMobile', 'eSelect', 'eReg', 'eBooth', 'eConnect', 'eSocial', 'eSeating'. rReg is always on by default. */ public static EventResult CreateEvent(ScribeConnection connection, string name) { Dictionary<string, string> keyPairs = new Dictionary<string, string>(); keyPairs.Add("name", name); var e = DataUtility.DoPost<EventResult>(connection, Extensions.Actions.EventCreate, string.Empty, keyPairs); return e; }
/* * https://www.eiseverywhere.com/api/v2/ereg/createEvent.format * Parameters * * accesstoken * required The access token assigned to you from the authorize function. * Example: Ub57+fu2p/4KcaqIRNUNQD9HV8nWid+7flRBxbskZIv/DWkaZG0+e6H6ZcjPaAoAGqOtjSq4tHh9ChxUChZdZw== * name * required The name to create the new event with. * folder * optional The ID of folder to create the event in. Must be a numeric value. * modules * optional Array containing the names of modules to turn on for the event. Valid values are (case sensitive): 'eRFP', 'eBudget', 'eProject', 'eScheduler', 'eWiki', 'eHome', 'eMobile', 'eSelect', 'eReg', 'eBooth', 'eConnect', 'eSocial', 'eSeating'. rReg is always on by default. */ public static EventResult CreateEvent(ScribeConnection connection, string name) { Dictionary <string, string> keyPairs = new Dictionary <string, string>(); keyPairs.Add("name", name); var e = DataUtility.DoPost <EventResult>(connection, Extensions.Actions.EventCreate, string.Empty, keyPairs); return(e); }
/* * /eventlist/[accountid]* * deleted (optional) * lastmodified-gt * (optional) * lastmodified-lt (optional) * attendees_modified-gt * (optional) * attendees_modified-lt * (optional) * pageNumber (optional) * pageSize (optional) */ public static DataSet ListEvents(ScribeConnection connection, DateTime?modifiedAfter = null, DateTime?modifiedBefore = null, DateTime?attendeesModifiedAfter = null, Dictionary <string, string> keypairs = null) { string aQuery = string.Empty; if (attendeesModifiedAfter.HasValue) { var d = attendeesModifiedAfter.Value.ToString("yyyy-MM-dd"); aQuery = $"attendees_modified-gt={d}"; } return(DataUtility.GetDataset(connection, Extensions.Actions.Event, null, modifiedAfter, modifiedBefore, aQuery, keypairs)); }
public static T DoPut <T>(ScribeConnection connection, Extensions.Actions action, string eventId, Dictionary <string, string> keyPairValues) { var path = buildPath(connection, action, eventId, keyPairValues); var http = new HttpClient(); var result = http.Put(path, null, HttpContentTypes.ApplicationJson); if (!String.IsNullOrEmpty(result.RawText) && result.RawText.StartsWith("{\"status\":\"error\",\"msg\":\"Not authorized to access account")) { connection.ReConnnect(); if (connection.IsConnected) { result = http.Put(path, null, HttpContentTypes.ApplicationJson); } } return(JsonConvert.DeserializeObject <T>(result.RawText)); }
/* * https://www.eiseverywhere.com/api/v2/ereg/updateEvent.json * accesstoken * required The access token assigned to you from the authorize function. * Example: Ub57+fu2p/4KcaqIRNUNQD9HV8nWid+7flRBxbskZIv/DWkaZG0+e6H6ZcjPaAoAGqOtjSq4tHh9ChxUChZdZw== * eventid * required The event ID to put the data into, must be a numeric value. * name * optional Update the event’s name. * eventid * optional Update the event’s code. * startdate * optional Update the event’s start date, dates need to be in ISO format. * Example: 2012-12-31 * enddate * optional Update the event’s end date, dates need to be in ISO format. * Example: 2012-12-31 * locationname * optional Update the event’s location name. * programmanager * optional Update the event’s program manager. * status * optional Update event status, allowed values: Archived, Cancelled, Closed, Live, On-site, Pre-Event, Sold Out * max_reg * optional Update "Maximum registrations" value */ public static EventResult UpdateEvent(ScribeConnection connection, int eventId, string name, string code, string startDate, string endDate, string locationName, string programManager, string status, string max_reg) { Dictionary <string, string> keyPairs = new Dictionary <string, string>(); keyPairs.Add("eventid", eventId.ToString()); if (!name.IsNullOrEmpty()) { keyPairs.Add("name", name); } if (!code.IsNullOrEmpty()) { keyPairs.Add("code", code); } if (!startDate.IsNullOrEmpty()) { keyPairs.Add("startdate", startDate); } if (!endDate.IsNullOrEmpty()) { keyPairs.Add("enddate", endDate); } if (!locationName.IsNullOrEmpty()) { keyPairs.Add("locationname", locationName); } if (!programManager.IsNullOrEmpty()) { keyPairs.Add("programmanager", programManager); } if (!status.IsNullOrEmpty()) { keyPairs.Add("status", status); } if (!max_reg.IsNullOrEmpty()) { keyPairs.Add("max_reg", max_reg); } var e = DataUtility.DoPut <EventResult>(connection, Extensions.Actions.EventUpdate, string.Empty, keyPairs); return(e); }
//https://www.eiseverywhere.com/api/v2/ereg/createAttendeeBridge.xml?accesstoken=Ub57%2Bfu2p%2F4KcaqIRNUNQD9HV8nWid%2B7flRBxbskZIv%2FDWkaZG0%2Be6H6ZcjPaAoAGqOtjSq4tHh9ChxUChZdZw%3D%3D&eventid=1&fname=Test&lname=Test /// <summary> /// This method will load a dataset iteratively. It converts one row and column at a time /// it protects against properties that are collections ignoring them /// it will protect against unix representation of null dates /// </summary> /// <param name="baseUrl"></param> /// <param name="action"></param> /// <param name="accesstoken"></param> /// <param name="accountId"></param> /// <param name="eventId"></param> /// <param name="modifiedAfter"></param> /// <param name="modifiedBefore"></param> /// <returns></returns> private static DataSet GetDatasetIteratively(ScribeConnection connection, string action, string accountId = null, string eventId = null, DateTime?modifiedAfter = null, DateTime?modifiedBefore = null, string additionCondition = null, Dictionary <string, string> keypairs = null, int?pageNumber = null) { HttpResponse result = DoHttpGetInternal(connection.BaseUrl, action, connection.AccessToken, accountId, eventId, modifiedAfter, modifiedBefore, additionCondition, connection.PageSize, keypairs, pageNumber); //We are going to try to reconnnect one time if (!String.IsNullOrEmpty(result.RawText) && result.RawText.StartsWith("{\"status\":\"error\",\"msg\":\"Not authorized to access account")) { connection.ReConnnect(); if (connection.IsConnected) { result = DoHttpGetInternal(connection.BaseUrl, action, connection.AccessToken, accountId, eventId, modifiedAfter, modifiedBefore, additionCondition, connection.PageSize, keypairs, pageNumber); } } if (String.IsNullOrEmpty(result.RawText)) { Logger.WriteError("Result of the get was empty"); throw new ApplicationException("Result of the get was empty"); } DataSet ds = null; string plainJson = result.RawText; try { ds = ConvertDataSetIteratively(plainJson); } catch (Exception ex) { var msg = $"Error : {ex.Message} while deserializing {plainJson}"; Logger.WriteError(msg); throw new ApplicationException(msg); } if (ds != null && ds.Tables != null && ds.Tables.Count > 0) { var msg = $"The Action {action} return {ds.Tables[0].Rows.Count} records"; Logger.WriteDebug(msg); } return(ds); }
public void Connect(IDictionary<string, string> properties) { this.Connection = new ScribeConnection(properties, ScribeConnection.ConnectionVersion.V1); //attempt connection & set connection status this.IsConnected = this.Connection.TryConnect(); //A config file switch if (!Configuration.BidirectionalEnabled) return; try { this.V2Connection = new ScribeConnection(properties, ScribeConnection.ConnectionVersion.V2); this.IsV2Connected = this.V2Connection.TryConnect(); } catch (Exception ex) { } }
private static string buildPath(ScribeConnection connection, Extensions.Actions action, string eventId, Dictionary <string, string> keyPairValues) { var path = string.Empty; if (String.IsNullOrEmpty(eventId)) { path = $"{connection.BaseUrl}/api/v2/ereg/{action.Name()}?accesstoken={connection.AccessToken}"; } else { path = $"{connection.BaseUrl}/api/v2/ereg/{action.Name()}?accesstoken={connection.AccessToken}&eventid={connection.EventId}"; } foreach (var kp in keyPairValues) { path = $"{path}&{kp.Key}={kp.Value}"; } return(path); }
public void Connect(IDictionary <string, string> properties) { this.Connection = new ScribeConnection(properties, ScribeConnection.ConnectionVersion.V1); //attempt connection & set connection status this.IsConnected = this.Connection.TryConnect(); //A config file switch if (!Configuration.BidirectionalEnabled) { return; } try { this.V2Connection = new ScribeConnection(properties, ScribeConnection.ConnectionVersion.V2); this.IsV2Connected = this.V2Connection.TryConnect(); } catch (Exception ex) { } }
public static DataSet GetDataset(ScribeConnection connection, Extensions.Actions action, string eventId = null, DateTime?modifiedAfter = null, DateTime?modifiedBefore = null, string additionCondition = null, Dictionary <string, string> keypairs = null) { var strAction = action.Name(); var isKeyPairs = keypairs != null; var key = ConnectorCache.Generatekey(connection.ConnectionKey, strAction, connection.AccountId, connection.EventId, null, keypairs); DataSet ds = ConnectorCache.GetCachedData <DataSet>(key); if (ds != null) { return(ds); } if (isKeyPairs) { ds = GetKeyPairValueFromMemory(connection.ConnectionKey, strAction, connection.AccountId, connection.EventId, keypairs); if (ds != null) { return(ds); } } //If we do not have key pairs, will load all pages for the dataset ds = GetCompleteDatasetIteratively(connection, strAction, connection.AccountId, eventId, modifiedAfter, modifiedBefore, additionCondition, keypairs); if (ds != null) { ConnectorCache.StoreData(key, ds, connection.TTL); } if (!isKeyPairs) { StoreGeneratedKey(connection.ConnectionKey, strAction, key); } return(ds); }
public static JObject GetJObject(ScribeConnection connection, Extensions.Actions action, string accountId = null, string eventId = null) { var strAction = action.Name(); var key = ConnectorCache.Generatekey(connection.ConnectionKey, strAction, connection.AccountId, connection.EventId, null, null); JObject json = ConnectorCache.GetCachedData <JObject>(key); if (json != null) { Logger.WriteDebug($"The action {strAction} successfully returned in GetJobject from cache."); return(json); } HttpResponse result = DoHttpGetInternal(connection.BaseUrl, strAction, connection.AccessToken, accountId, eventId); if (!String.IsNullOrEmpty(result.RawText) && result.RawText.StartsWith("{\"status\":\"error\",\"msg\":\"Not authorized to access account")) { connection.ReConnnect(); if (connection.IsConnected) { result = DoHttpGetInternal(connection.BaseUrl, strAction, connection.AccessToken, accountId, eventId); } } if (result == null) { Logger.WriteError("Result of get was null in GetJObject"); throw new ApplicationException("Result of get was null"); } var res = result.RawText; json = JObject.Parse(res); if (json != null) { ConnectorCache.StoreData(key, json, connection.TTL); Logger.WriteDebug($"The action {strAction} successfully returned in GetJobject"); } return(json); }
/* * /meetinglist/[accountid]/[eventid] * * pageNumber (optional) * pageSize (optional) */ public static DataSet ListMeetings(ScribeConnection connection, Dictionary <string, string> keypairs = null) { return(DataUtility.GetDataset(connection, Extensions.Actions.Meeting, connection.EventId, null, null, null, keypairs)); }
public MetadataProvider(ScribeConnection connection) { this.connection = connection; }
///sessionmetadata/ public static JObject GetSessionMetaData(ScribeConnection connection) { return DataUtility.GetJObject(connection, Extensions.Actions.SessionMeta, connection.AccountId, connection.EventId); }
/* * /financialtransactionlist/[accountid]/[eventid] accountid * accesstoken * deleted (optional) * fields (optional) * pageNumber (optional) * pageSize (optional) */ public static DataSet ListFinancialTransactions(ScribeConnection connection, Dictionary <string, string> keypairs = null) { return(DataUtility.GetDataset(connection, Extensions.Actions.FinanacialTransaction, connection.EventId, null, null, null, keypairs)); }
/* * GET /meetingmetadata/[accountid]/[eventid] accountid */ public static JObject GetMeetingMetaData(ScribeConnection connection) { return(DataUtility.GetJObject(connection, Extensions.Actions.MeetingMeta, connection.AccountId, connection.EventId)); }
/* /speakerlist/[accountid]/[eventid] * deleted (optional) pageNumber (optional) pageSize (optional) */ public static DataSet ListSpeakers(ScribeConnection connection, Dictionary<string, string> keypairs = null) { return DataUtility.GetDataset(connection, Extensions.Actions.Speaker, connection.EventId, null, null, null, keypairs); }
/* * /attendeelist/[accountid]/[eventid]* * deleted (optional) * lastmodified-gt * (optional) * lastmodified-lt (optional) * pageNumber (optional) * pageSize (optional) */ public static DataSet ListAttendees(ScribeConnection connection, DateTime?modifiedAfter = null, DateTime?modifiedBefore = null, Dictionary <string, string> keypairs = null) { return(DataUtility.GetDataset(connection, Extensions.Actions.Attendee, connection.EventId, modifiedAfter, modifiedBefore, null, keypairs)); }
/* /attendeelist/[accountid]/[eventid]* deleted (optional) lastmodified-gt (optional) lastmodified-lt (optional) pageNumber (optional) pageSize (optional) */ public static DataSet ListAttendees(ScribeConnection connection, DateTime? modifiedAfter = null, DateTime? modifiedBefore = null, Dictionary<string, string> keypairs = null) { return DataUtility.GetDataset(connection, Extensions.Actions.Attendee, connection.EventId, modifiedAfter, modifiedBefore, null, keypairs); }
/* * GET /financialtransactionmetadata/[accountid]/[eventid] accountid */ public static JObject GetFinancialTransactionMetaData(ScribeConnection connection) { return(DataUtility.GetJObject(connection, Extensions.Actions.FinancialTransactionMeta, connection.AccountId, connection.EventId)); }
/* /eventlist/[accountid]* deleted (optional) lastmodified-gt (optional) lastmodified-lt (optional) attendees_modified-gt (optional) attendees_modified-lt (optional) pageNumber (optional) pageSize (optional) */ public static DataSet ListEvents(ScribeConnection connection, DateTime? modifiedAfter = null, DateTime? modifiedBefore = null, DateTime? attendeesModifiedAfter = null, Dictionary<string, string> keypairs = null) { string aQuery = string.Empty; if (attendeesModifiedAfter.HasValue) { var d = attendeesModifiedAfter.Value.ToString("yyyy-MM-dd"); aQuery = $"attendees_modified-gt={d}"; } return DataUtility.GetDataset(connection, Extensions.Actions.Event, null, modifiedAfter, modifiedBefore, aQuery, keypairs); }
/* * https://www.eiseverywhere.com/api/v2/ereg/updateEvent.json accesstoken required The access token assigned to you from the authorize function. Example: Ub57+fu2p/4KcaqIRNUNQD9HV8nWid+7flRBxbskZIv/DWkaZG0+e6H6ZcjPaAoAGqOtjSq4tHh9ChxUChZdZw== eventid required The event ID to put the data into, must be a numeric value. name optional Update the event’s name. eventid optional Update the event’s code. startdate optional Update the event’s start date, dates need to be in ISO format. Example: 2012-12-31 enddate optional Update the event’s end date, dates need to be in ISO format. Example: 2012-12-31 locationname optional Update the event’s location name. programmanager optional Update the event’s program manager. status optional Update event status, allowed values: Archived, Cancelled, Closed, Live, On-site, Pre-Event, Sold Out max_reg optional Update "Maximum registrations" value */ public static EventResult UpdateEvent(ScribeConnection connection, int eventId, string name, string code, string startDate, string endDate, string locationName, string programManager, string status, string max_reg) { Dictionary<string, string> keyPairs = new Dictionary<string, string>(); keyPairs.Add("eventid", eventId.ToString()); if (!name.IsNullOrEmpty()) keyPairs.Add("name", name); if (!code.IsNullOrEmpty()) keyPairs.Add("code", code); if (!startDate.IsNullOrEmpty()) keyPairs.Add("startdate", startDate); if (!endDate.IsNullOrEmpty()) keyPairs.Add("enddate", endDate); if (!locationName.IsNullOrEmpty()) keyPairs.Add("locationname", locationName); if (!programManager.IsNullOrEmpty()) keyPairs.Add("programmanager", programManager); if (!status.IsNullOrEmpty()) keyPairs.Add("status", status); if (!max_reg.IsNullOrEmpty()) keyPairs.Add("max_reg", max_reg); var e = DataUtility.DoPut<EventResult>(connection, Extensions.Actions.EventUpdate, string.Empty, keyPairs); return e; }
public MetadataProvider(ScribeConnection connection) { this.connection = connection; }
/* /financialtransactionlist/[accountid]/[eventid] accountid accesstoken deleted (optional) fields (optional) pageNumber (optional) pageSize (optional) */ public static DataSet ListFinancialTransactions(ScribeConnection connection, Dictionary<string, string> keypairs = null) { return DataUtility.GetDataset(connection, Extensions.Actions.FinanacialTransaction, connection.EventId, null, null, null, keypairs); }