private void WritePropertyValues(DataWriter writer, bool useAllValueSources) { if (!HasMapping("SearchCriteria")) { writer.WriteValue("SearchCriteria", SearchCriteria, null); } if (!HasMapping("SocialNetworks")) { writer.WriteValue("SocialNetworks", SocialNetworks, null); } if (!HasMapping("SearchResult")) { writer.WriteValue("SearchResult", SearchResult, null); } if (ExceptionNetworks != null) { if (ExceptionNetworks.GetType().IsSerializable || ExceptionNetworks.GetType().GetInterface("ISerializable") != null) { writer.WriteSerializableObjectValue("ExceptionNetworks", ExceptionNetworks, null); } } if (AccessTokenExceptionNetworks != null) { if (AccessTokenExceptionNetworks.GetType().IsSerializable || AccessTokenExceptionNetworks.GetType().GetInterface("ISerializable") != null) { writer.WriteSerializableObjectValue("AccessTokenExceptionNetworks", AccessTokenExceptionNetworks, null); } } }
public virtual bool SearchSocialUsersScriptTaskExecute(ProcessExecutingContext context) { if (string.IsNullOrEmpty(SearchCriteria)) { return(true); } SocialNetwork network = SocialNetwork.All; if (!string.IsNullOrEmpty(SocialNetworks)) { network = (SocialNetwork)Enum.Parse(typeof(SocialNetwork), SocialNetworks, true); } var commutator = new SocialCommutator(UserConnection, network); ExceptionNetworks = SocialNetwork.None; AccessTokenExceptionNetworks = SocialNetwork.None; commutator.ExceptionOccurred += delegate(ISocialNetwork n, Exception e) { if (e is AccessTokenExpired) { AccessTokenExceptionNetworks = (SocialNetwork)AccessTokenExceptionNetworks | (e as AccessTokenExpired).SocialNetwork; } else if (e is SocialNetworkException) { ExceptionNetworks = (SocialNetwork)ExceptionNetworks | (e as SocialNetworkException).SocialNetwork; } else { throw e; } }; var users = JsonConvert.SerializeObject(commutator.FindUsers(SearchCriteria)); SearchResult = string.Format("{{users: {0}, accessTokenExNetworks:'{1}', exeptionNetworks:'{2}'}}", users, AccessTokenExceptionNetworks.ToString(), ExceptionNetworks.ToString()); return(true); }