コード例 #1
0
        /// <summary>
        /// Запрос на Web интерфейс VersaLink B7030 устройства!
        /// </summary>
        /// <param name="listSerNumber">Список серийных номеров для поиска</param>
        /// <param name="printer">Ссылка на объект</param>
        /// <returns></returns>
        private void SoapClientPrinter(List <string> listSerNumber, SynchronizationPrintServer printer)
        {
            var parametersSoap = @"<soap:Envelope xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/""><soap:Header><msg:MessageInformation xmlns:msg=""http://www.fujixerox.co.jp/2014/08/ssm/management/message""><msg:MessageExchangeType>RequestResponse</msg:MessageExchangeType><msg:MessageType>Request</msg:MessageType><msg:Action>http://www.fujixerox.co.jp/2003/12/ssm/management/statusConfig#GetAttribute</msg:Action><msg:From><msg:Address>http://www.fujixerox.co.jp/2014/08/ssm/management/soap/epr/client</msg:Address><msg:ReferenceParameters/></msg:From></msg:MessageInformation></soap:Header><soap:Body><cfg:GetAttribute xmlns:cfg=""http://www.fujixerox.co.jp/2003/12/ssm/management/statusConfig""><cfg:Object name=""urn:fujixerox:names:ssm:1.0:management:productInformation"" offset=""0""/><cfg:Object name=""urn:fujixerox:names:ssm:1.0:management:WirelessLANStatus"" offset=""0""/><cfg:Object name=""urn:fujixerox:names:ssm:1.0:management:OperationStatus"" offset=""0""/><cfg:Object name=""urn:fujixerox:names:ssm:1.0:management:ProductName"" offset=""0""/></cfg:GetAttribute></soap:Body></soap:Envelope>";

            Client = new WebClient();
            Client.Headers.Add(HttpRequestHeader.UserAgent, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36");
            Client.Headers.Add(HttpRequestHeader.Accept, "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9");
            Client.Headers.Add(HttpRequestHeader.ContentLanguage, "ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7");
            Client.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
            Client.Headers.Add(HttpRequestHeader.ContentType, "text/xml; charset=UTF-8");
            Client.Headers.Add("SOAPAction", "http://www.fujixerox.co.jp/2003/12/ssm/management/statusConfig#GetAttribute");
            Client.Headers.Add(HttpRequestHeader.Cookie, "SESSION_ID=8438; statusSelected=1");
            try
            {
                var data = Client.UploadString(printer.FullUrl, "POST", parametersSoap);
                foreach (var serN in listSerNumber)
                {
                    if (data.Contains(serN))
                    {
                        printer.SerNumberPrintServer = serN;
                        printer.StatusFindPrintServerAndSynchronization = 1;
                        printer.IsErrorInfo = null;
                        break;
                    }
                    printer.IsErrorInfo = "Серийный номер по ссылке не найден!";
                    printer.StatusFindPrintServerAndSynchronization = 2;
                }
            }
            catch (Exception e)
            {
                printer.IsErrorInfo = e.Message;
                printer.StatusFindPrintServerAndSynchronization = 4;
            }
        }
コード例 #2
0
 /// <summary>
 /// Запрос на Web интерфейс устройства!
 /// </summary>
 /// <param name="listSerNumber">Список серийных номеров для поиска</param>
 /// <param name="printer">Ссылка на объект</param>
 /// <returns></returns>
 private void ClientSendWebForm(List <string> listSerNumber, SynchronizationPrintServer printer)
 {
     Client = new WebClient();
     Client.Headers.Add(HttpRequestHeader.UserAgent, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36");
     Client.Headers.Add(HttpRequestHeader.Accept, "text/html,application/xhtml+xml,application/xml,text/xml,*/*;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9");
     Client.Headers.Add(HttpRequestHeader.ContentLanguage, "ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7");
     Client.Headers.Add(HttpRequestHeader.Cookie, "SESSION_ID=8438; statusSelected=1");
     try
     {
         using (var receiveStream = Client.OpenRead(printer.FullUrl))
         {
             StreamReader readStream = new StreamReader(receiveStream ?? throw new InvalidOperationException());
             string       data       = readStream.ReadToEnd();
             foreach (var serN in listSerNumber)
             {
                 if (data.Contains(serN))
                 {
                     printer.SerNumberPrintServer = serN;
                     printer.StatusFindPrintServerAndSynchronization = 1;
                     printer.IsErrorInfo = null;
                     break;
                 }
                 printer.IsErrorInfo = "Серийный номер по ссылке не найден!";
                 printer.StatusFindPrintServerAndSynchronization = 2;
             }
         }
     }
     catch (Exception e)
     {
         printer.IsErrorInfo = e.Message;
         printer.StatusFindPrintServerAndSynchronization = 4;
     }
 }