コード例 #1
0
        string ProcessRequest(HubRequest request, IModelProcessor processor, NetWorkSetting networkSetting)
        {
            try
            {
                Document[] requestDocuments = request.Documents.Select(d => new Lpp.Dns.DataMart.Model.Document(d.ID.ToString("D"), d.Document.MimeType, d.Document.Name)
                {
                    IsViewable = d.Document.IsViewable, Size = Convert.ToInt32(d.Document.Size), Kind = d.Document.Kind
                }).ToArray();
                Document[] desiredDocuments;
                string     requestId = request.Source.ID.ToString();
                IDictionary <string, string> requestProperties;
                processor.Request(requestId, networkSetting.CreateInterfaceMetadata(), request.CreateInterfaceMetadata(), requestDocuments, out requestProperties, out desiredDocuments);

                _log.Info("Request posted: " + request.Source.Identifier + " (ID: " + requestId + ")");
                _log.Info("Number of documents available: " + requestDocuments.Length);
                _log.Info("Number of documents desired: " + desiredDocuments.Length);
                if (requestProperties != null && requestProperties.Count > 0)
                {
                    _log.Info("Properties: ");
                    foreach (string key in requestProperties.Keys)
                    {
                        _log.Info("Key: " + key + "=" + requestProperties[key]);
                    }
                }

                // TODO[ddee] Needs to update the requestProperties here, but do not have a proper status.
                // Temporarily using InProgress.
                // BMS: Don't report inprogress status until portal is fixed to display status in routings
                // DnsServiceManager.SetRequestStatus(request, DnsServiceManager.ConvertModelRequestStatus(processor.Status(requestId)), requestProperties, networkSetting);

                foreach (Lpp.Dns.DataMart.Model.Document requestDocument in desiredDocuments)
                {
                    _log.Info("About to post desired document id: " + requestDocument.DocumentID);
                    DocumentChunkStream requestDocumentStream = new DocumentChunkStream(Guid.Parse(requestDocument.DocumentID), networkSetting);
                    processor.RequestDocument(requestId, requestDocument.DocumentID, requestDocumentStream);
                    _log.Info("Posted desired document id: " + requestDocument.DocumentID);
                }

                _log.Info("Starting request with local request: " + request.Source.Identifier + " (ID: " + requestId + ")");
                processor.Start(requestId);
                _log.Info("Start finished on request with local request: " + request.Source.Identifier + " (ID: " + requestId + ")");

                return(requestId);
            }
            catch (Exception ex)
            {
                _log.Error("Unexpected exception in Util.ProcessRequest.", ex);
                throw;
            }
        }
コード例 #2
0
        private string ProcessRequest(HubRequest request, IModelProcessor processor)
        {
            try
            {
                Document[] requestDocuments = request.Documents.Select(d => new Lpp.Dns.DataMart.Model.Document(d.ID.ToString("D"), d.Document.MimeType, d.Document.Name)
                {
                    IsViewable = d.Document.IsViewable, Size = Convert.ToInt32(d.Document.Size), Kind = d.Document.Kind
                }).ToArray();
                Document[] desiredDocuments;
                string     requestId = request.Source.ID.ToString();
                IDictionary <string, string> requestProperties;
                processor.Request(requestId, _networkSetting.CreateInterfaceMetadata(), request.CreateInterfaceMetadata(), requestDocuments, out requestProperties, out desiredDocuments);

                Log.Info("Request posted: " + request.Source.Identifier + " (ID: " + requestId + ")");
                Log.Info("Number of documents available: " + requestDocuments.Length);
                Log.Info("Number of documents desired: " + desiredDocuments.Length);
                if (requestProperties != null && requestProperties.Count > 0)
                {
                    Log.Info("Properties: ");
                    foreach (string key in requestProperties.Keys)
                    {
                        Log.Info("Key: " + key + "=" + requestProperties[key]);
                    }
                }

                foreach (Lpp.Dns.DataMart.Model.Document requestDocument in desiredDocuments)
                {
                    Log.Debug("Downloading document" + requestDocument.Filename + $" for Request: {request.Source.MSRequestID}, DataMart: { request.DataMartName }");
                    DocumentChunkStream requestDocumentStream = new DocumentChunkStream(Guid.Parse(requestDocument.DocumentID), _networkSetting);
                    processor.RequestDocument(requestId, requestDocument.DocumentID, requestDocumentStream);
                    Log.Debug("Successfully Downloaded document" + requestDocument.Filename + $" for Request: {request.Source.MSRequestID}, DataMart: { request.DataMartName }");
                }

                Log.Info("Starting request with local request: " + request.Source.Identifier + " (ID: " + requestId + ")");
                processor.Start(requestId);
                Log.Info("Start finished on request with local request: " + request.Source.Identifier + " (ID: " + requestId + ")");

                return(requestId);
            }
            catch (Exception ex)
            {
                Log.Error("Unexpected exception in Util.ProcessRequest.", ex);
                throw;
            }
        }