public QueryExpression GetCachedQuery(QueryBase query) { var serialisedQuery = SerialiserHelpers.SerialiseStrictXml(query); queryCache.TryGetValue(serialisedQuery, out var queryExpression); return(queryExpression == null ? null : SerialiserHelpers.DeserialiseStrictXml <QueryExpression>(queryExpression)); }
protected IDictionary <string, object> GetInputs() { IDictionary <string, object> parameters = null; try { parameters = SerialiserHelpers.DeserialiseSimpleJson(Job.SerialisedInputParams) .ToDictionary(pair => pair.Key, pair => (object)pair.Value); } catch { log.Log("Parameters are not in JSON format, or are poorly formatted JSON."); try { parameters = SerialiserHelpers.DeserialiseStrictXml <IDictionary <string, object> >(Job.SerialisedInputParams); } catch { log.Log("Parameters are not in XML format, or are poorly formatted XML."); } if (parameters == null) { throw new InvalidPluginExecutionException("Failed to parse input params."); } } return(parameters); }
private string ParseMessages(EntityCollection result) { var messages = result.Entities.Select( e => { var regarding = e.GetAttributeValue <EntityReference>("regardingobjectid"); var regardingId = regarding?.Id.ToString() ?? e.GetAttributeValue <string>("ldv_regardingid"); var serialisedRegarding = regarding == null ? (string.IsNullOrEmpty(regardingId) ? null : SerialiserHelpers.SerialiseSimpleJson( new Dictionary <string, string> { ["id"] = regardingId, ["typecode"] = e.GetAttributeValue <int>("ldv_regardingtypecode").ToString(), ["name"] = e.GetAttributeValue <string>("subject") }, true)) : SerialiserHelpers.SerialiseSimpleJson( new Dictionary <string, string> { ["id"] = regardingId, ["typecode"] = e.GetAttributeValue <int>("ldv_regardingtypecode").ToString(), ["name"] = regarding.Name }, true); var serialisedMessage = SerialiserHelpers.SerialiseSimpleJson( new Dictionary <string, string> { ["id"] = e.GetAttributeValue <Guid>("activityid").ToString(), ["title"] = e.GetAttributeValue <string>("subject"), ["message"] = e.GetAttributeValue <string>("description"), ["modifiedon"] = e.GetAttributeValue <DateTime>("modifiedon").ToString("yyyy-MM-ddTHH:mm:ssZ"), ["modifiedonString"] = e.GetAttributeValue <DateTime>("modifiedon").ToString(), ["source"] = (e.GetAttributeValue <OptionSetValue>("ldv_notificationsource")?.Value ?? 1).ToString() }, true); if (serialisedRegarding != null) { serialisedMessage = serialisedMessage .Insert(serialisedMessage.Length - 1, ",\"regarding\":" + serialisedRegarding); } return(serialisedMessage); }).ToArray(); var messagesString = "["; if (messages.Any()) { messagesString += messages.Aggregate((m1, m2) => m1 + ", " + m2); } messagesString += "]"; return(messagesString); }
public void AddCachedQuery(QueryBase query, QueryExpression queryExpression) { var serialisedQuery = SerialiserHelpers.SerialiseStrictXml(query); queryCache[serialisedQuery] = SerialiserHelpers.SerialiseStrictXml(queryExpression); }