public ICollection <Guid> GetCurrentlyImportingShares() { CpAction action = GetAction("GetCurrentlyImportingShares"); IList <object> outParameters = action.InvokeAction(null); return(MarshallingHelper.ParseCsvGuidCollection((string)outParameters[0])); }
static UPnPError OnScheduleImports(DvAction action, IList <object> inParams, out IList <object> outParams, CallContext context) { outParams = null; ICollection <Guid> shareIds = MarshallingHelper.ParseCsvGuidCollection((string)inParams[0]); string importJobTypeStr = (string)inParams[1]; ImportJobType importJobType; UPnPError error = ParseImportJobType("ImportJobType", importJobTypeStr, out importJobType); if (error != null) { return(error); } IDictionary <Guid, Share> allShares = MediaLibrary.GetShares(null); IDictionary <string, ICollection <Share> > importRequests = new Dictionary <string, ICollection <Share> >(); foreach (Guid shareId in shareIds) { Share importShare; if (!allShares.TryGetValue(shareId, out importShare)) { // Share not found continue; } ICollection <Share> systemShares; if (!importRequests.TryGetValue(importShare.SystemId, out systemShares)) { importRequests[importShare.SystemId] = new List <Share> { importShare } } ; else { systemShares.Add(importShare); } } // Local imports at the server ISystemResolver systemResolver = ServiceRegistration.Get <ISystemResolver>(); ICollection <Share> shares; if (importRequests.TryGetValue(systemResolver.LocalSystemId, out shares)) { IImporterWorker importerWorker = ServiceRegistration.Get <IImporterWorker>(); foreach (Share share in shares) { if (importJobType == ImportJobType.Import) { importerWorker.ScheduleImport(share.BaseResourcePath, share.MediaCategories, true); } else { importerWorker.ScheduleRefresh(share.BaseResourcePath, share.MediaCategories, true); } } } ServiceRegistration.Get <IThreadPool>().Add(() => ScheduleClientImports(importRequests, importJobType)); return(null); }
public async Task <ICollection <Guid> > GetCurrentlyImportingSharesAsync() { CpAction action = GetAction("X_MediaPortal_GetCurrentlyImportingShares"); IList <object> outParameters = await action.InvokeAsync(null); return(MarshallingHelper.ParseCsvGuidCollection((string)outParameters[0])); }