public static string SerializeSurveyJson(SurveyReturnResponse response, ITracingService trace) { if (trace == null) { throw new InvalidPluginExecutionException("trace is null;"); } if (response == null) { throw new InvalidPluginExecutionException("SurveyReturnResponse is null;"); } trace.Trace("Processing Serialization of SurveyReturnResponse - start"); using (var memoryStream = new MemoryStream()) { DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(SurveyReturnResponse)); serializer.WriteObject(memoryStream, response); byte[] json = memoryStream.ToArray(); trace.Trace("Processing Serialization of SurveyReturnResponse - end"); return(Encoding.UTF8.GetString(json, 0, json.Length)); } }
public string ProcessResponse(SurveyReturnResponse response) { var failedSurveys = new StringBuilder(); var failedSurveysList = response.FailedSurveys; if (failedSurveysList != null && failedSurveysList.Count > 0) { for (int i = 0; i < failedSurveysList.Count; i++) { if (failedSurveys.Length == 0) { failedSurveys.Append(failedSurveysList[i].SurveyId); } else { failedSurveys.Append("," + failedSurveysList[i].SurveyId); } Trace.TraceError("Error occured in custom action for Survey:: {0} || Exception:: {1}", failedSurveysList[i].SurveyId, failedSurveysList[i].Exception); } } return(failedSurveys.ToString()); }