Наследование: ResumableResult
Пример #1
0
        internal static HarvestResult Harvest(Uri baseUri, string action, Dictionary <string, object> args, string username = "", string password = "")
        {
            string        path     = String.Format("{0}/{1}", Routes.Harvest, action);
            string        jsonData = getDataFromUri(baseUri, path, args, username, password);
            HarvestResult results  = new HarvestResult();

            switch (action)
            {
            case Harvester.HarvesterActions.GetRecord:
                results = _serializer.Deserialize <GetRecordHarvestResult>(jsonData);
                break;

            case Harvester.HarvesterActions.ListRecords:
                results = _serializer.Deserialize <ListRecordsHarvestResult>(jsonData);
                break;

            case Harvester.HarvesterActions.ListIdentifiers:
                results = _serializer.Deserialize <ListIdentifiersHarvestResult>(jsonData);
                break;

            case Harvester.HarvesterActions.ListMetadataFormats:
                results = _serializer.Deserialize <ListMetadataFormatsHarvestResult>(jsonData);
                break;

            default:
                throw new System.ArgumentException("Invalid harvester action: " + action);
            }

            if (!results.OK)
            {
                throw new WebException("Error while calling getRecord: " + results.error, WebExceptionStatus.UnknownError);
            }

            results.Action       = action;
            results.BaseUri      = baseUri;
            results.HttpUsername = username;
            results.HttpPassword = password;
            return(results);
        }
Пример #2
0
        internal static HarvestResult Harvest(Uri baseUri, string action, Dictionary<string, object> args, string username = "", string password = "")
        {
            string path = String.Format("{0}/{1}", Routes.Harvest, action);
            string jsonData = getDataFromUri(baseUri, path, args, username, password);
            HarvestResult results = new HarvestResult();
            switch (action)
            {
                case Harvester.HarvesterActions.GetRecord:
                    results = _serializer.Deserialize<GetRecordHarvestResult>(jsonData);
                    break;
                case Harvester.HarvesterActions.ListRecords:
                    results = _serializer.Deserialize<ListRecordsHarvestResult>(jsonData);
                    break;
                case Harvester.HarvesterActions.ListIdentifiers:
                    results = _serializer.Deserialize<ListIdentifiersHarvestResult>(jsonData);
                    break;
                case Harvester.HarvesterActions.ListMetadataFormats:
                    results = _serializer.Deserialize<ListMetadataFormatsHarvestResult>(jsonData);
                    break;
                default:
                    throw new System.ArgumentException("Invalid harvester action: " + action);
            }

            if (!results.OK)
                throw new WebException("Error while calling getRecord: " + results.error, WebExceptionStatus.UnknownError);

            results.Action = action;
            results.BaseUri = baseUri;
            results.HttpUsername = username;
            results.HttpPassword = password;
            return results;
        }
Пример #3
0
		static void AssertResponseOk (HarvestResult result)
		{
			Assert.IsTrue(result.OK);
			Assert.IsTrue(String.IsNullOrEmpty(result.error));
		}