コード例 #1
0
        public void UploadUsageData(UDCUploadRequest request)
        {
            string sentAppKey = request.ApplicationKey;
            string storedAppKey = ConfigurationManager.AppSettings[AppSettings_ApplicationKey];

            if (0 != String.Compare(sentAppKey, storedAppKey, true))
            {
                // Invalid application key was sent, do not store message
                if (log.IsErrorEnabled)
                    log.ErrorFormat("Received message with invalid application key {0}", sentAppKey);

                return;
            }

            string dropDirectory = ConfigurationManager.AppSettings[appSettingsDropDirectoryKey];
            string fileGuidPart = Guid.NewGuid().ToString();
            string uploadingFilePath = dropDirectory +  fileGuidPart + uploadingFileExtension;

            string finalFilePath = dropDirectory + fileGuidPart + fileExtension;

            using (DisposableUploadStream us = new DisposableUploadStream(request.UsageData))
            {
                if (StoreUploadedStream(uploadingFilePath, us.Stream))
                {
                    // mark it as uploaded successfully by giving it the final file extension
                    try
                    {
                        File.Move(uploadingFilePath, finalFilePath);
                    }
                    catch (System.Exception ex)
                    {
                        if (log.IsErrorEnabled)
                            log.Error("Final File.Move failed", ex);

                        throw new Exception("An error occured while processing the message upload");
                    }

                    if (log.IsInfoEnabled)
                        log.InfoFormat("Message {0} stored successfully", fileGuidPart);
                }
                else
                {
                    // there is no point in telling the client details
                    throw new Exception("An error occured while processing the message upload");
                }
            }
        }
コード例 #2
0
 // A "do nothing" service for testing purposes of sample client applications
 // or for providing a testing service URL that doesn't create load on the server
 public void UploadUsageData(UDCUploadRequest request)
 {
 }
コード例 #3
0
 public void UploadUsageData(UDCUploadRequest request)
 {
     _active.UploadUsageData(request);
 }