{"id":211669,"date":"2014-02-06T14:55:03","date_gmt":"2014-02-06T10:55:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=211669"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=211669","title":{"rendered":"<span class=\"post_title\">\u041a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0439 \u043f\u043e\u0447\u0442\u044b \u0432 SharePoint 2010 \u2014 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u041d\u0435\u0440\u0435\u0434\u043a\u043e \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0439 \u0448\u0442\u0440\u0438\u0445-\u043a\u043e\u0434\u044b, \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0437\u0430\u043d\u0435\u0441\u0435\u043d\u0438\u0435\u043c \u0438\u0445 \u0432 \u043d\u0435\u043a\u0443\u044e \u0443\u0447\u0435\u0442\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443. \u042d\u0442\u043e \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u0441\u0444\u0435\u0440\u044b \u0416\u0414-\u043f\u0435\u0440\u0435\u0432\u043e\u0437\u043e\u043a \u0438 \u0430\u0432\u0438\u0430\u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0439: \u0432 \u0448\u0442\u0440\u0438\u0445-\u043a\u043e\u0434 \u043a\u0443\u043f\u043e\u043d\u0430, \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u0435\u043c\u043e\u0433\u043e \u043d\u0430 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u0443\u044e \u043f\u043e\u0447\u0442\u0443 \u0430\u0433\u0435\u043d\u0442\u0430\u043c\u0438 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438, \u0437\u0430\u0448\u0438\u0442\u044b \u043d\u043e\u043c\u0435\u0440\u0430 \u0431\u0438\u043b\u0435\u0442\u043e\u0432. \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u0438\u0441\u0442\u044b \u0432\u044b\u043d\u0443\u0436\u0434\u0435\u043d\u044b \u0435\u0436\u0435\u0434\u043d\u0435\u0432\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0438 \u0437\u0430\u043d\u043e\u0441\u0438\u0442\u044c \u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u0443\u0447\u0435\u0442\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0442\u044b\u0441\u044f\u0447\u0438 \u0442\u0430\u043a\u0438\u0445 \u043a\u0443\u043f\u043e\u043d\u043e\u0432.<\/p>\n<p>  \u0420\u0430\u0431\u043e\u0442\u0430 \u0440\u0443\u0442\u0438\u043d\u043d\u0430\u044f, \u0447\u0435\u043b\u043e\u0432\u0435\u0447\u0435\u0441\u043a\u0438\u0439 \u0444\u0430\u043a\u0442\u043e\u0440 \u043f\u0440\u043e\u0432\u043e\u0446\u0438\u0440\u0443\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0438. \u041a\u0430\u043a \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438 \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043e\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0440\u0443\u0447\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0438\u0441\u0435\u043c \u0438 \u0438\u0445 \u0432\u043b\u043e\u0436\u0435\u043d\u0438\u0439? \u041c\u044b \u043d\u0430\u0448\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c MS SharePoint. \u041f\u043e \u0441\u0432\u043e\u0435\u043c\u0443 \u043e\u0431\u044b\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044e, \u043c\u044b \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0438\u0441\u044c \u043f\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0443 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u0435\u044e\u0449\u0438\u0439\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0441\u0438\u0441\u0442\u0435\u043c, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u0432\u043e\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0441\u043a\u043e\u0439 \u043c\u0430\u0433\u0438\u0438:)<\/p>\n<p>  <a name=\"habracut\"><\/a><\/p>\n<h5>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 Exchange<\/h5>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b <a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/cc287879(v=office.14).aspx\">\u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043b\u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e<\/a> \u0438 \u0432\u0441\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435 \u0434\u043b\u044f \u0432\u0430\u0441 \u0432\u0441\u0435 \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u0439, \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/71c\/bda\/0a5\/71cbda0a5883d2a8b7f39627773e69d9.png\"\/><\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/194\/a6f\/c29\/194a6fc297adacbef670c4c9211443d7.png\"\/> <\/p>\n<p>  \u041d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0441 SharePoint \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0447\u0442\u043e\u0432\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 \u043f\u0440\u0438\u0435\u043c \u043f\u0438\u0441\u0435\u043c. \u0412\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u043f\u0438\u0441\u044c\u043c\u0430 \u0432 \u0432\u0438\u0434\u0435 eml-\u0444\u0430\u0439\u043b\u043e\u0432 \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0432 \u043f\u0430\u043f\u043a\u0435 inbox. SharePoint \u043a\u0430\u0436\u0434\u044b\u0435 \u0434\u0432\u0435 \u043c\u0438\u043d\u0443\u0442\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043f\u0430\u043f\u043a\u0443 inbox, \u0438 \u0435\u0441\u043b\u0438 \u0442\u0430\u043c \u0435\u0441\u0442\u044c \u0444\u0430\u0439\u043b\u044b, \u043e\u043d \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0438 \u0443\u0434\u0430\u043b\u044f\u0435\u0442.<\/p>\n<p>  \u0421\u0442\u043e\u0438\u0442 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0432\u0441\u0435 \u043f\u043e\u0434\u0440\u044f\u0434 \u0444\u0430\u0439\u043b\u044b (\u0441 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c \u0430\u0434\u0440\u0435\u0441\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u044f, \u0441 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0442\u0435\u0433\u0430\u043c\u0438 \u043b\u0438\u0431\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b Outlook Express) \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u2014 \u0444\u0430\u0439\u043b \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d \u0438\u043c\u0435\u043d\u043d\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c SMTP \u0438\u0437 \u0441\u043e\u0441\u0442\u0430\u0432\u0430 IIS. <\/p>\n<p>  \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435, \u0432\u0441\u0435 \u043f\u0438\u0441\u044c\u043c\u0430, \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0430\u0434\u0440\u0435\u0441, \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/ba7\/dff\/c98\/ba7dffc98ec62d024f25d4e2a98c7eea.png\"\/><\/p>\n<p>  \u0412 \u043a\u0430\u0436\u0434\u043e\u043c \u043f\u0438\u0441\u044c\u043c\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u0434\u043d\u043e \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0430\u0445 jpg, png, tiff, pdf, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043e\u0442\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u0445 \u0448\u0442\u0440\u0438\u0445-\u043a\u043e\u0434\u043e\u043c:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/ac1\/688\/e6e\/ac1688e6e33e0591d82aea691890a218.png\"\/><\/p>\n<p>  \u0414\u043b\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0448\u0442\u0440\u0438\u0445-\u043a\u043e\u0434\u043e\u0432 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 open source \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 zxing, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0448\u0442\u0440\u0438\u0445-\u043a\u043e\u0434\u043e\u0432. \u0417\u0434\u0435\u0441\u044c \u043d\u0430\u043c \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u0442.\u043a. \u0443 \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u0432\u043e\u044f \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432 zxing \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f (\u0445\u043e\u0442\u044c \u0438 \u043f\u043e\u0445\u043e\u0436\u0430 \u043d\u0430 codabar). <\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 Event Handler, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e zxing \u043a\u0430\u0436\u0434\u044b\u0435 15 \u043c\u0438\u043d\u0443\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b \u0432\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 \u043f\u0438\u0441\u0435\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u043d\u0430 \u043f\u043e\u0440\u0442\u0430\u043b \u0447\u0435\u0440\u0435\u0437 Exchange. \u0414\u0430\u043b\u0435\u0435 \u043e\u043d \u0437\u0430\u0431\u0438\u0440\u0430\u0435\u0442 \u0438\u0445 \u0447\u0435\u0440\u0435\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0435\u0442 \u0432\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0430\u0434\u0440\u0435\u0441 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u044f \u0438 \u043a\u043e\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u044f (\u043b\u0438\u0447\u043d\u044b\u0439 \u043a\u043e\u0434 \u0430\u0433\u0435\u043d\u0442\u0430 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438). <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.RegularExpressions; using ADODB; using CDO; using ETR.REBT.BarcodeReader; using Stream = System.IO.Stream;  namespace ETR.BusinessLogic.EBTBlanks {     internal class EBTMailParser     {         private static readonly string[] SupportedExtensions =         {             &quot;application\/pdf&quot;             , &quot;image\/jpeg&quot;             , &quot;image\/bmp&quot;             , &quot;image\/png&quot;             , &quot;image\/tiff&quot;         };          private static readonly Regex AgencyCodePattern = new Regex(@&quot;{\\w*}&quot;);         public static EBTMailParseResult ParseEmail(Stream emlStream)         {             var result = new EBTMailParseResult             {                 Success = true             };             Message msg = new MessageClass();             ADODB.Stream stream = new StreamClass();             try             {                 CopyStream(emlStream, stream);                  msg.DataSource.OpenObject(stream, &quot;_Stream&quot;);                   result.FromAddress = msg.From;                 result.SendDate = msg.SentOn;                 result.ReceivedDate = msg.ReceivedTime;                 string agentCode;                 if (TryParseAgencyCode(msg.Subject, out agentCode))                 {                     result.AgencyCode = agentCode;                 }                 else                 {                     result.Status = &quot;\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0442\u044c \u043a\u043e\u0434 \u0410\u0433\u0435\u043d\u0442\u0430. \u041a\u043e\u0434 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f \u0432 \u0442\u0435\u043c\u0435 \u043f\u0438\u0441\u044c\u043c\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0446\u0438\u0444\u0440\u044b \u0438 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u0444\u0438\u0433\u0443\u0440\u043d\u044b\u0445 \u0441\u043a\u043e\u0431\u043e\u043a. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, {12345}&quot;;                     return result;                 }                  if (msg.Attachments.Count == 0)                 {                     result.Status = &quot;\u0412 \u043f\u0438\u0441\u044c\u043c\u0435 \u043d\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u043e \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u0438\u044f&quot;;                     return result;                 }                  result.Attachments = ParseAttachments(msg.Attachments).ToList();                 return result;             }             catch (Exception ex)             {                 \/\/If we get unknown error - we don't mark letter as parsed an try next time                 result.Success = false;                 result.Status = &quot;\u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044f\u044f \u043e\u0448\u0438\u0431\u043a\u0430.&quot;;                 result.ExceptionMessage = ex.Message;                 return result;             }             finally             {                 stream.Close();             }          }          private static bool TryParseAgencyCode(string subject, out string result)         {             var allMatchResults = AgencyCodePattern.Matches(subject);             if (allMatchResults.Count != 1 || false == allMatchResults[0].Success)             {                 result = null;                 return false;             }             result = allMatchResults[0].Value.Substring(1, allMatchResults[0].Value.Length - 2);             return true;         }          private static void CopyStream(Stream netStream, ADODB.Stream adoStream)         {             \/\/adoStream.Open(Type.Missing, ADODB.ConnectModeEnum.adModeUnknown, ADODB.StreamOpenOptionsEnum.adOpenStreamUnspecified, String.Empty, String.Empty);             adoStream.Type = StreamTypeEnum.adTypeBinary;             adoStream.Open();              netStream.Position = 0;             var buffer = new byte[1024];             while (netStream.Read(buffer, 0, buffer.Length) != 0)             {                 adoStream.Write(buffer);             }             adoStream.Flush();         }           private static void CopyStream(ADODB.Stream adoStream, Stream netStream)         {             while (!adoStream.EOS)             {                 var bytes = (byte[])adoStream.Read(1024);                 netStream.Write(bytes, 0, bytes.Length);             }             netStream.Flush();         }           private static IEnumerable&lt;EBTAttachmentParseResult&gt; ParseAttachments(IBodyParts attachments)         {             var barcodeReader = new BarcodeReader(true);              for (var i = 1; i &lt;= attachments.Count; i++)             {                 var attachment = attachments[i];                 var fileResult = new EBTAttachmentParseResult                 {                     FileName = attachment.FileName                 };                  if (false == SupportedExtensions.Any(ct =&gt; ct == attachment.ContentMediaType))                 {                     fileResult.Status = String.Format(&quot;\u0424\u0430\u0439\u043b\u044b {0} \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f&quot;, attachment.ContentMediaType);                     yield return fileResult;                 }                  var stream = attachment.GetDecodedContentStream();                 try                 {                     var memoryStream = new MemoryStream();                     CopyStream(stream, memoryStream);                     memoryStream.Position = 0;                     var parseResult = barcodeReader.Decode(memoryStream, attachment.FileName);                      fileResult.Status = parseResult.AllPages &gt; parseResult.RecognizedPages                         ? String.Format(&quot;\u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043d\u043e {0} \u0438\u0437 {1} \u0441\u0442\u0440\u0430\u043d\u0438\u0446&quot;, parseResult.RecognizedPages,                             parseResult.AllPages)                         : fileResult.Status;                     fileResult.Stream = memoryStream;                      if (parseResult.ResultList != null && parseResult.ResultList.Count &gt; 0)                     {                         fileResult.BarcodeNumbers = parseResult.ResultList.Select(b =&gt; ParseBarcode(b.Text)).ToList();                     }                 }                 catch (Exception ex)                 {                     fileResult.Status = &quot;\u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044f\u044f \u043e\u0448\u0438\u0431\u043a\u0430.&quot;;                     fileResult.ExceptionMessage = ex.Message;                 }                 finally                 {                     stream.Close();                 }                 yield return fileResult;             }         }          private static EBTBarcodeParseResult ParseBarcode(string barCode)         {             if (barCode.Length != 15)                 return new EBTBarcodeParseResult                 {                     BarcodeNumber = barCode,                     Status = &quot;\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0442\u044c \u043a\u043e\u0434 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430&quot;                 };               return new EBTBarcodeParseResult             {                 BarcodeNumber = barCode,                 CouponNumber = barCode.Substring(1, 13).Insert(3, &quot; &quot;)             };         }     } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0415\u0441\u043b\u0438 \u0445\u044d\u043d\u0434\u043b\u0435\u0440 \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0443 (\u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432, \u043d\u0435 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u0434 \u0430\u0433\u0435\u043d\u0442\u0430 \u0438 \u0442.\u0434.), \u0432 EventBus \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0441 \u0435\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c. <\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043e\u0448\u0438\u0431\u043e\u043a \u043d\u0435\u0442, \u0432\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u0438\u0437 \u043d\u0438\u0445 \u00ab\u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u044e\u0442\u0441\u044f\u00bb \u0448\u0442\u0440\u0438\u0445-\u043a\u043e\u0434\u044b, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f. \u041d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0448\u0442\u0440\u0438\u0445-\u043a\u043e\u0434 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0431\u043b\u0430\u043d\u043a \u0432 SharePoint, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0436\u0435 \u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u0438\u0441\u0442\u044b, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044b \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432. <\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/e5c\/f17\/162\/e5cf17162159c5f72e8435f62c8d66f9.png\"\/> <\/p>\n<p>  \u0412 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435, \u0432 EventBus \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\u043c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0438\u0441\u044c\u043c\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043d\u043e, \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u043d\u0435\u043c \u043d\u0430\u0439\u0434\u0435\u043d\u043e, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u0443\u043f\u043e\u043d\u043e\u0432 \u0432\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0438\u043b\u0435\u0442\u043e\u0432 \u0432 \u043a\u0443\u043f\u043e\u043d\u0430\u0445. \u0412\u0441\u0435 \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043b\u0438\u0446\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 push-\u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435. <\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/02a\/6c8\/145\/02a6c81456d2677c733fbe436c0d7263.png\"\/><\/p>\n<p>  \u0414\u0430\u043d\u043d\u044b\u0439 \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u2014 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u0444\u0438\u0441\u0430 \u043a\u0440\u0443\u043f\u043d\u043e\u0439 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u043d\u043e\u0439 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438. \u0422\u0430\u043a\u0436\u0435 \u0435\u0433\u043e \u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0436\u043d\u043e \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0444\u0435\u0440\u044b, \u0433\u0434\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043c\u043d\u043e\u0433\u043e \u0438 \u0440\u0443\u0442\u0438\u043d\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0432\u0445\u043e\u0434\u044f\u0449\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e, \u0438 \u0433\u0434\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f SharePoint \u0438 Exchange. <\/p>\n<p>  \u041d\u0430\u0448 \u043f\u043e\u0441\u0442\u0443\u043b\u0430\u0442 \u0432 \u0442\u0430\u043a\u0438\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u2014 \u043d\u0435 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0432\u0430\u0442\u044c \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0440\u0443\u0442\u0438\u043d\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430, \u0441\u043c\u0435\u043a\u0430\u043b\u043a\u0443 \u0438 \u0441\u0432\u043e\u0438 \u043d\u0430\u0432\u044b\u043a\u0438 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438.    \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/company\/eastbanctech\/blog\/211669\/\"> http:\/\/habrahabr.ru\/company\/eastbanctech\/blog\/211669\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u041d\u0435\u0440\u0435\u0434\u043a\u043e \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0439 \u0448\u0442\u0440\u0438\u0445-\u043a\u043e\u0434\u044b, \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0437\u0430\u043d\u0435\u0441\u0435\u043d\u0438\u0435\u043c \u0438\u0445 \u0432 \u043d\u0435\u043a\u0443\u044e \u0443\u0447\u0435\u0442\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443. \u042d\u0442\u043e \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u0441\u0444\u0435\u0440\u044b \u0416\u0414-\u043f\u0435\u0440\u0435\u0432\u043e\u0437\u043e\u043a \u0438 \u0430\u0432\u0438\u0430\u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0439: \u0432 \u0448\u0442\u0440\u0438\u0445-\u043a\u043e\u0434 \u043a\u0443\u043f\u043e\u043d\u0430, \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u0435\u043c\u043e\u0433\u043e \u043d\u0430 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u0443\u044e \u043f\u043e\u0447\u0442\u0443 \u0430\u0433\u0435\u043d\u0442\u0430\u043c\u0438 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438, \u0437\u0430\u0448\u0438\u0442\u044b \u043d\u043e\u043c\u0435\u0440\u0430 \u0431\u0438\u043b\u0435\u0442\u043e\u0432. \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u0438\u0441\u0442\u044b \u0432\u044b\u043d\u0443\u0436\u0434\u0435\u043d\u044b \u0435\u0436\u0435\u0434\u043d\u0435\u0432\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0438 \u0437\u0430\u043d\u043e\u0441\u0438\u0442\u044c \u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u0443\u0447\u0435\u0442\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0442\u044b\u0441\u044f\u0447\u0438 \u0442\u0430\u043a\u0438\u0445 \u043a\u0443\u043f\u043e\u043d\u043e\u0432.<\/p>\n<p>  \u0420\u0430\u0431\u043e\u0442\u0430 \u0440\u0443\u0442\u0438\u043d\u043d\u0430\u044f, \u0447\u0435\u043b\u043e\u0432\u0435\u0447\u0435\u0441\u043a\u0438\u0439 \u0444\u0430\u043a\u0442\u043e\u0440 \u043f\u0440\u043e\u0432\u043e\u0446\u0438\u0440\u0443\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0438. \u041a\u0430\u043a \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438 \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043e\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0440\u0443\u0447\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0438\u0441\u0435\u043c \u0438 \u0438\u0445 \u0432\u043b\u043e\u0436\u0435\u043d\u0438\u0439? \u041c\u044b \u043d\u0430\u0448\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c MS SharePoint. \u041f\u043e \u0441\u0432\u043e\u0435\u043c\u0443 \u043e\u0431\u044b\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044e, \u043c\u044b \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0438\u0441\u044c \u043f\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0443 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u0435\u044e\u0449\u0438\u0439\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0441\u0438\u0441\u0442\u0435\u043c, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u0432\u043e\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0441\u043a\u043e\u0439 \u043c\u0430\u0433\u0438\u0438:)<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-211669","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/211669","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=211669"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/211669\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=211669"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=211669"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=211669"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}