public object Get(Statistics request) { Ares.Tags.Statistics result = new Ares.Tags.Statistics(); using (TagsDBUser user = new TagsDBUser(request.Test)) { result = user.TagsDB.BrowseInterface.GetStatistics(); var response = CreateItemResponse <StatisticsResponse, Ares.Tags.Statistics>(request, result, user); UploadStatistics uploadStats; DownloadStatistics downloadStats; StatisticsDB.GetStatisticsDB(request.Test).GetStatistics(out uploadStats, out downloadStats); response.UploadStats = uploadStats; response.DownloadStats = downloadStats; return(CreateHttpResponse(request, response)); } }
public object Post(Upload request) { using (System.IO.StringWriter writer = new System.IO.StringWriter()) { UploadResponse response = new UploadResponse(); try { // try several times to prevent possible problems with concurrent modifications int retryCount = 0; const int MAX_RETRIES = 5; while (true) { try { int nrOfNewFiles, nrOfNewTags; using (TagsDBUser user = new TagsDBUser(request.Test)) { user.TagsDB.GlobalDBInterface.ImportDataFromClient(request.TagsData, request.User, writer, out nrOfNewFiles, out nrOfNewTags); } StatisticsDB.GetStatisticsDB(request.Test).InsertUpload(nrOfNewFiles, nrOfNewTags); response.Status = 0; response.ErrorMessage = String.Empty; break; } catch (Exception) { if (++retryCount >= MAX_RETRIES) { throw; } } } } catch (Exception ex) { response.Status = 1; response.ErrorMessage = ex.Message; } String log = writer.ToString(); if (!request.IncludeLog) { log = String.Empty; } response.Log = log; return(response); } }
public object Post(Download request) { DownloadResponse response = new DownloadResponse(); try { // try several times to prevent possible problems with concurrent modifications int retryCount = 0; const int MAX_RETRIES = 5; while (true) { try { int nrOfFoundFiles; using (TagsDBUser user = new TagsDBUser(request.Test)) { response.TagsData = user.TagsDB.GlobalDBInterface.ExportDataForFiles(request.FileIdentification, out nrOfFoundFiles); response.NrOfFoundFiles = nrOfFoundFiles; } int nrOfRequestedFiles = request.FileIdentification != null ? request.FileIdentification.Count : 0; StatisticsDB.GetStatisticsDB(request.Test).InsertDownload(nrOfRequestedFiles, nrOfFoundFiles); response.Status = 0; response.ErrorMessage = String.Empty; break; } catch (Exception) { if (++retryCount >= MAX_RETRIES) { throw; } } } } catch (Exception ex) { response.Status = 1; response.ErrorMessage = ex.Message; response.TagsData = new Ares.Tags.TagsExportedData <Ares.Tags.FileIdentification>(); } return(response); }