/// <summary> /// Executes the service /// </summary> /// <param name="values">The values.</param> /// <param name="theWorkspace">The workspace.</param> /// <returns></returns> public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace) { if (values == null) { throw new InvalidDataContractException(ErrorResource.NoParameter); } string serializedSource = null; StringBuilder tmp; ExecuteMessage msg = new ExecuteMessage(); values.TryGetValue("SharepointServer", out tmp); if (tmp != null) { serializedSource = tmp.ToString(); } Dev2JsonSerializer serializer = new Dev2JsonSerializer(); if (string.IsNullOrEmpty(serializedSource)) { var res = new ExecuteMessage { HasError = true }; res.SetMessage(ErrorResource.NoSharepointServerSet); Dev2Logger.Debug(ErrorResource.NoSharepointServerSet); return(serializer.SerializeToBuilder(res)); } try { msg.HasError = false; var sharepointSource = serializer.Deserialize <SharepointSource>(serializedSource); var result = sharepointSource.TestConnection(); if (result.Contains("Failed")) { msg.HasError = true; } msg.Message = serializer.SerializeToBuilder(result); var sharepointSourceTo = new SharepointSourceTo { TestMessage = result, IsSharepointOnline = sharepointSource.IsSharepointOnline }; return(serializer.SerializeToBuilder(sharepointSourceTo)); } catch (Exception ex) { Dev2Logger.Error(ex); msg.Message = serializer.SerializeToBuilder(ex.Message); } return(serializer.SerializeToBuilder(msg)); }
/// <summary> /// Executes the service /// </summary> /// <param name="values">The values.</param> /// <param name="theWorkspace">The workspace.</param> /// <returns></returns> public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace) { if (values == null) { throw new InvalidDataContractException("No parameter values provided."); } string serializedSource = null; StringBuilder tmp; values.TryGetValue("SharepointServer", out tmp); if (tmp != null) { serializedSource = tmp.ToString(); } Dev2JsonSerializer serializer = new Dev2JsonSerializer(); if (string.IsNullOrEmpty(serializedSource)) { var res = new ExecuteMessage(); res.HasError = true; res.SetMessage("No sharepoint server set"); Dev2Logger.Log.Debug("No sharepoint server set."); return(serializer.SerializeToBuilder(res)); } try { var sharepointSource = serializer.Deserialize <SharepointSource>(serializedSource); var result = sharepointSource.TestConnection(); var sharepointSourceTo = new SharepointSourceTo { TestMessage = result, IsSharepointOnline = sharepointSource.IsSharepointOnline }; return(serializer.SerializeToBuilder(sharepointSourceTo)); } catch (Exception ex) { Dev2Logger.Log.Error(ex); var res = new DbColumnList(ex); return(serializer.SerializeToBuilder(res)); } }