// GET /repository/ public void Delete(string assembly, string version) { AssemblyVersion realVersion = Version.Parse(version); var file = Directory.EnumerateFiles(AppConfig.RepositoryPath, "*.ldoc") .SingleOrDefault(ld => { var fd = FileDescriptor.Load(new FileInfo(ld)); return (string.Equals(fd.Assembly, assembly, StringComparison.OrdinalIgnoreCase) && fd.Version == realVersion); }); if (file == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } File.Delete(file); App.Instance.Content.QueueRebuild(string.Format("Deleted assembly: {{A:{0}, V:{1}}}", assembly, realVersion.ToString())); }
// GET /repository/LBi.Test/1.0.5.4 public FileDescriptor Get(string assembly, string version) { AssemblyVersion realVersion = Version.Parse(version); return(Directory.EnumerateFiles(AppConfig.RepositoryPath, "*.ldoc") .Select(ldocFile => FileDescriptor.Load(new FileInfo(ldocFile))) .SingleOrDefault( ld => string.Equals(ld.Assembly, assembly, StringComparison.OrdinalIgnoreCase) && ld.Version == realVersion)); }
// POST /repository public async Task <HttpResponseMessage> Post() { if (!this.Request.Content.IsMimeMultipartContent("form-data")) { throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType); } List <FileDescriptor> ret = new List <FileDescriptor>(); using (var tmp = new TempDir()) { MultipartFormDataStreamProvider provider = new MultipartFormDataStreamProvider(tmp.Path); var bodypart = await this.Request.Content.ReadAsMultipartAsync(provider); foreach (var fileName in provider.FileData) { var fi = new FileInfo(fileName.LocalFileName); try { var fd = FileDescriptor.Load(fi); string destFileName = Path.Combine(AppConfig.RepositoryPath, fileName.Headers.ContentDisposition.FileName.Trim('"')); File.Copy(fi.FullName, destFileName); ret.Add(fd); } catch (Exception ex) { // log TraceSources.Content.TraceError( "An exception of type {2} occured while processing '{0}': {1}", fileName, ex.ToString(), ex.GetType().Name); return(this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } fi.Delete(); } } string reason = ret.Aggregate( new StringBuilder(), (builder, descriptor) => (builder.Length == 0 ? builder : builder.Append(", ")) .AppendFormat( "{{A:{0}, V:{1}}}", descriptor.Assembly, descriptor.Version), builder => builder.ToString()); if (ret.Count > 0) { App.Instance.Content.QueueRebuild("Added assemblies: " + reason); } return(this.Request.CreateResponse(HttpStatusCode.Accepted, ret.AsEnumerable())); }
// GET /repository/LBi.Test public IEnumerable <FileDescriptor> Get(string assembly) { return(Directory.EnumerateFiles(AppConfig.RepositoryPath, "*.ldoc") .Select(ldocFile => FileDescriptor.Load(new FileInfo(ldocFile))) .Where(ld => string.Equals(ld.Assembly, assembly, StringComparison.OrdinalIgnoreCase))); }
public IEnumerable <FileDescriptor> Get() { return(Directory.EnumerateFiles(AppConfig.RepositoryPath, "*.ldoc") .Select(ldocFile => FileDescriptor.Load(new FileInfo(ldocFile)))); }