예제 #1
0
        public async Task <EsclStatus> GetStatus()
        {
            var response = await esclClient.GetAsync(endpoint);

            var xmlDocument      = response.Content;
            var namespaceManager = NamespaceUtils.CreateNamespaceManager(xmlDocument);
            var versionNode      = xmlDocument.SelectSingleNode("/scan:ScannerStatus/pwg:Version", namespaceManager);
            var stateNode        = xmlDocument.SelectSingleNode("/scan:ScannerStatus/pwg:State", namespaceManager);

            return(new EsclStatus {
                State = stateNode.InnerText,
                Version = versionNode.InnerText
            });
        }
예제 #2
0
        public async Task <bool> Ready()
        {
            var response = await esclClient.GetAsync(endpoint);

            var xmlDocument      = response.Content;
            var namespaceManager = NamespaceUtils.CreateNamespaceManager(xmlDocument);
            var jobInfoNode      = xmlDocument.SelectSingleNode(
                $"/scan:ScannerStatus/scan:Jobs/scan:JobInfo[pwg:JobUri = '{Uri}']",
                namespaceManager);
            var imagesToTransferNode = jobInfoNode.SelectSingleNode("./pwg:ImagesToTransfer", namespaceManager);

            if (int.Parse(imagesToTransferNode.InnerText) > 0)
            {
                return(true);
            }
            return(false);
        }
예제 #3
0
        public async Task <CapabilitiesInfo> GetCapabilities()
        {
            var response = await esclClient.GetAsync(endpoint);

            var xml = response.Content;
            var namespaceManager = NamespaceUtils.CreateNamespaceManager(xml);
            var extractor        = new Extractor(xml, namespaceManager);

            return(new CapabilitiesInfo
            {
                Model = extractor.Extract("/scan:ScannerCapabilities/pwg:MakeAndModel"),
                MinWidth = extractor.ExtractInt("/scan:ScannerCapabilities/scan:Platen/scan:PlatenInputCaps/scan:MinWidth"),
                MaxWidth = extractor.ExtractInt("/scan:ScannerCapabilities/scan:Platen/scan:PlatenInputCaps/scan:MaxWidth"),
                MinHeight = extractor.ExtractInt("/scan:ScannerCapabilities/scan:Platen/scan:PlatenInputCaps/scan:MinHeight"),
                MaxHeight = extractor.ExtractInt("/scan:ScannerCapabilities/scan:Platen/scan:PlatenInputCaps/scan:MaxHeight"),
                DocumentFormatExtensions = extractor.ExtractList("/scan:ScannerCapabilities/scan:Platen/scan:PlatenInputCaps/scan:SettingProfiles/scan:SettingProfile/scan:DocumentFormats/scan:DocumentFormatExt"),
                Resolutions =
                    extractor.ExtractNodes("/scan:ScannerCapabilities/scan:Platen/scan:PlatenInputCaps/scan:SettingProfiles/scan:SettingProfile/scan:SupportedResolutions/scan:DiscreteResolutions/scan:DiscreteResolution")
                    .Select(node => new Resolution {
                    X = node.SelectSingleNode("./scan:XResolution", namespaceManager).InnerText.ParseIntOrDefault(0),
                    Y = node.SelectSingleNode("./scan:YResolution", namespaceManager).InnerText.ParseIntOrDefault(0)
                }).ToList()
            });
        }