public void RunTestCalls() { using (ComProxy proxy = new ComProxy()) { // query database(s) DatabaseResponse dbResponse = proxy.GetDatabases(); foreach (KeyAndValueItem item in dbResponse.Items) { LOGGER.Info($"DbId: {item.Id}, Name: {item.Name}"); // query each db details SPDatabaseDetailsResponse dbDetails = proxy.GetDatabaseDetails(new SPDatabaseDetailsRequest() { DatabaseId = item.Id }); LOGGER.Info($"Currency: {dbDetails.Currency}"); LOGGER.Info($"Population: {dbDetails.Population.ToString()}"); LOGGER.Info($"Sample: {dbDetails.Sample.ToString()}"); LOGGER.Info("Languages:"); foreach (KeyAndValueItem langItem in dbDetails.Languages) { LOGGER.Info($"{langItem.Id}, name: {langItem.Name}"); } LOGGER.Info("-----------"); } } Console.WriteLine("Success! Check your log file."); }
public SPDatabaseDetailsResponse GetDatabaseDetails(SPDatabaseDetailsRequest requestData) { if (requestData == null) { throw new ArgumentNullException(nameof(requestData)); } if (mDatabaseDetails.ContainsKey(requestData.DatabaseId)) { return(mDatabaseDetails[requestData.DatabaseId]); } RemoteMessageBinary request = new RemoteMessageBinary(); request.CommunicationPattern = CommunicationPatternEnum.Request; request.MessageTypeCustomId = string.Format("{0}_{1}", requestData.DatabaseId, GET_SP_DATABASE_DETAILS.ToString()); request.Timeout = WaitTimeout; request.Data = SerializeRequestData <SPDatabaseDetailsRequest>(requestData); RemoteMessageBase response = SendMessage(this, request); if (response is RemoteMessageBinary) { // deserialize response content RemoteMessageBinary arrayResponse = (RemoteMessageBinary)response; SPDatabaseDetailsResponse detailsResponse = DeserializeResponseData <SPDatabaseDetailsResponse>(arrayResponse); mDatabaseDetails[requestData.DatabaseId] = detailsResponse; return(detailsResponse); } else if (response is RemoteMessageError) { RemoteMessageError errorMessage = (RemoteMessageError)response; if (errorMessage.ErrorCode == (int)RemoteMessageErrorCodesEnum.Unknown_Message_Type) { throw new ApplicationException("Unknown message. No backend configured for understand that message or it is offline."); } else { throw errorMessage.GetException(); } } else { throw new InvalidDataException(); } }