Exemplo n.º 1
0
        public bool Delete(UploadSettings configuration, string fileName)
        {
            Ensure.NotNullOrEmpty(fileName, "fileName");

            if (!configuration.IsDeleteEnabled)
            {
                return(false);
            }

            string extension = Path.GetExtension(fileName)?.ToLowerInvariant();

            if (!configuration.IsSupportedExtension(extension))
            {
                return(false);
            }

            if (!Directory.Exists(configuration.StoragePath))
            {
                return(false);
            }

            string filePath = Path.Combine(configuration.StoragePath, fileName);

            File.Delete(filePath);

            return(true);
        }
Exemplo n.º 2
0
        private bool ValidateUser(UploadSettings settings, ClaimsPrincipal principal)
        {
            if (settings == null)
            {
                return(false);
            }

            if (settings.Roles == null || settings.Roles.Count == 0)
            {
                return(true);
            }

            if (!principal.Identity.IsAuthenticated)
            {
                return(false);
            }

            List <string> userRoles = principal.Claims
                                      .Where(c => c.Type == ClaimTypes.Role)
                                      .Select(c => c.Value)
                                      .ToList();

            if (userRoles == null || userRoles.Count == 0)
            {
                return(true);
            }

            if (settings.Roles.Any(r => userRoles.Contains(r)))
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
        public void CreateStepsTest()
        {
            //Arrange
            var stepMediator = new Mock<IStepMediator>();
            var webClient = new Mock<IEncodeWebClient>();
            var creatorFactory = new Mock<IEncodeCreatorFactory>();
            var ffmpeg = new Mock<IFfmpeg>();
            var watchDogTimer = new Mock<IWatchDogTimer>();
            var storagePdrovider = new Mock<IFileSystem>();
            var tempFileManager = new Mock<ITempFileManager>();
            var fileWrapper = new Mock<IFileWrapper>();

            var uploadSettings = new UploadSettings("backendId");

            var strategy = new PipelineStrategy(stepMediator.Object, webClient.Object, creatorFactory.Object,
                                                ffmpeg.Object, watchDogTimer.Object, storagePdrovider.Object,
                                                tempFileManager.Object, uploadSettings, fileWrapper.Object);

            //Act
            var stepList = strategy.CreateSteps().ToList();

            //Assert
            Assert.IsInstanceOfType(stepList[0], typeof (GetTaskStep));
            Assert.IsInstanceOfType(stepList[1], typeof (InitializingWebClientStep));
            Assert.IsInstanceOfType(stepList[2], typeof (GettingEntityStep));
            Assert.IsInstanceOfType(stepList[3], typeof (DownloadStep));
            Assert.IsInstanceOfType(stepList[4], typeof (CreatorStep));
            Assert.IsInstanceOfType(stepList[5], typeof (EncodeStep));
            Assert.IsInstanceOfType(stepList[6], typeof (UploadStep));
            Assert.IsInstanceOfType(stepList[7], typeof (FinishStep));
        }
Exemplo n.º 4
0
        private static void Main(string[] args)
        {
            const string k2Server = "localhost";

            const string fileName = "import.csv";
            var          status   = ImportCsv(fileName);

            //const string fileName = "import.xlsx";
            //var status = ImportExcel(fileName);

            if (status != ImportStatus.Complete)
            {
                Console.WriteLine("Fail!");
                Console.ReadLine();
                return;
            }

            var uploadSettings = new UploadSettings
            {
                K2Server           = k2Server,
                Port               = 5555,
                SmartObjectName    = "DataImport.SmartObject.Target",
                HeaderRowSpaces    = "Replace",
                IsBulkImport       = false,
                Data               = _importedData,
                TransactionIdName  = "TransactionId",
                TransactionIdValue = "123"
            };

            Upload(uploadSettings);

            Console.WriteLine("Done!");
            Console.ReadLine();
        }
        public void CreateStepsTest()
        {
            //Arrange
            var stepMediator     = new Mock <IStepMediator>();
            var webClient        = new Mock <IEncodeWebClient>();
            var creatorFactory   = new Mock <IEncodeCreatorFactory>();
            var ffmpeg           = new Mock <IFfmpeg>();
            var watchDogTimer    = new Mock <IWatchDogTimer>();
            var storagePdrovider = new Mock <IFileSystem>();
            var tempFileManager  = new Mock <ITempFileManager>();
            var fileWrapper      = new Mock <IFileWrapper>();

            var uploadSettings = new UploadSettings("backendId");

            var strategy = new PipelineStrategy(stepMediator.Object, webClient.Object, creatorFactory.Object,
                                                ffmpeg.Object, watchDogTimer.Object, storagePdrovider.Object,
                                                tempFileManager.Object, uploadSettings, fileWrapper.Object);

            //Act
            var stepList = strategy.CreateSteps().ToList();

            //Assert
            Assert.IsInstanceOfType(stepList[0], typeof(GetTaskStep));
            Assert.IsInstanceOfType(stepList[1], typeof(InitializingWebClientStep));
            Assert.IsInstanceOfType(stepList[2], typeof(GettingEntityStep));
            Assert.IsInstanceOfType(stepList[3], typeof(DownloadStep));
            Assert.IsInstanceOfType(stepList[4], typeof(CreatorStep));
            Assert.IsInstanceOfType(stepList[5], typeof(EncodeStep));
            Assert.IsInstanceOfType(stepList[6], typeof(UploadStep));
            Assert.IsInstanceOfType(stepList[7], typeof(FinishStep));
        }
Exemplo n.º 6
0
        private UploadSettings CreateUploadSettings(IServiceProvider services)
        {
            ActionContext         actionContext        = services.GetRequiredService <IActionContextAccessor>().ActionContext;
            UploadSettingsService configurationService = services.GetRequiredService <UploadSettingsService>();
            UploadSettings        configuration        = configurationService.Find(actionContext.RouteData, actionContext.HttpContext.User);

            return(configuration);
        }
Exemplo n.º 7
0
        public void ShouldBeInvalidWithoutLastUploadTime()
        {
            var uut = new UploadSettings {
                LastNotificationDate = DateTime.Now
            };

            Assert.IsFalse(uut.IsInitialized());
        }
Exemplo n.º 8
0
        /// <summary>
        /// 创建图片处理对象
        /// </summary>
        /// <param name="file">文件</param>
        /// <param name="newName">新文件名,当未指定该名时,文件名随机</param>
        /// <param name="maxLength">最大长度</param>
        /// <param name="path">保存路径</param>
        public static FileOperateBase CreateOperate(Uploads uploads, UploadSettings uploadSettings)
        {
            FileOperateBase fileOperate = null;

            if (uploadSettings.UploadParam.UploadType is UploadType.SingleImage or UploadType.MutipleImage)
            {
                fileOperate = new ImageFileOperate();
            }
Exemplo n.º 9
0
        public void ShouldBeValidWithAllData()
        {
            var uut = new UploadSettings {
                LastNotificationDate = DateTime.Now, LastUploadDate = DateTime.Now
            };

            Assert.IsTrue(uut.IsInitialized());
        }
Exemplo n.º 10
0
        private static void Upload(UploadSettings settings)
        {
            var uploader = new SmartObjectDataUploadService(settings);

            uploader.Upload();

            Console.WriteLine(uploader.Message);
        }
Exemplo n.º 11
0
 public MainController(FileService fileService, UploadSettings configuration, Factory factory)
 {
     Ensure.NotNull(fileService, "fileService");
     Ensure.NotNull(configuration, "configuration");
     Ensure.NotNull(factory, "factory");
     this.fileService = fileService;
     this.configuration = configuration;
     this.factory = factory;
 }
Exemplo n.º 12
0
        public void OnResourceExecuting(ResourceExecutingContext context)
        {
            UploadSettings configuration = context.HttpContext.RequestServices.GetService <UploadSettings>();

            if (configuration == null)
            {
                context.Result = new NotFoundResult();
            }
        }
Exemplo n.º 13
0
        public void SetUpSettings()
        {
            _uploadSettings = new UploadSettings();
            _uploadSettings.Initialize();

            _mockSettingsStore = new Mock <ISettingsStore>();
            _mockSettingsStore.Setup(store => store.GetSettings <UploadSettings>()).Returns(_uploadSettings);
            _mockSettingsStore.Setup(store => store.SetSettings(It.IsAny <UploadSettings>()))
            .Callback <UploadSettings>(settings => _updatedUploadSettings = settings);
        }
Exemplo n.º 14
0
 public Factory(FileService fileService, UploadSettingsService settingsService, UploadSettings configuration, UrlBuilder urlBuilder)
 {
     Ensure.NotNull(fileService, "fileService");
     Ensure.NotNull(settingsService, "settingsService");
     Ensure.NotNull(configuration, "configuration");
     Ensure.NotNull(urlBuilder, "urlBuilder");
     this.fileService     = fileService;
     this.settingsService = settingsService;
     this.configuration   = configuration;
     this.urlBuilder      = urlBuilder;
 }
Exemplo n.º 15
0
        public UploadSettings Find(RouteData routeData, ClaimsPrincipal principal)
        {
            UploadSettings settings = FindSettings(routeData);

            if (ValidateUser(settings, principal))
            {
                return(settings);
            }

            return(null);
        }
Exemplo n.º 16
0
        public void ShouldInitializeWithCurrentDate()
        {
            var uut = new UploadSettings();

            uut.Initialize();
            var now = DateTimeOffset.Now;

            Assert.IsTrue(uut.IsInitialized());
            Assert.IsTrue(GetDiffInMs(uut.LastNotificationDate, now) < 50);
            Assert.IsTrue(GetDiffInMs(uut.LastUploadDate, now) < 50);
        }
Exemplo n.º 17
0
        public async Task <bool> SaveAsync(UploadSettings configuration, string name, long length, Stream content)
        {
            Ensure.NotNull(configuration, "configuration");

            if (length > configuration.MaxLength)
            {
                return(false);
            }

            string extension = Path.GetExtension(name);

            if (extension == null)
            {
                return(false);
            }

            extension = extension.ToLowerInvariant();
            if (!configuration.IsSupportedExtension(extension))
            {
                return(false);
            }

            DirectoryInfo directory = new DirectoryInfo(configuration.StoragePath);

            if (configuration.MaxStorageLength != null && directory.GetLength() + length > configuration.MaxStorageLength.Value)
            {
                return(false);
            }

            if (!directory.Exists)
            {
                directory.Create();
            }

            string filePath = Path.Combine(configuration.StoragePath, name);

            if (File.Exists(filePath))
            {
                if (configuration.IsOverrideEnabled)
                {
                    TryBackupFile(configuration, filePath);
                    File.Delete(filePath);
                }
                else
                {
                    return(false);
                }
            }

            using (Stream fileContent = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Write))
                await content.CopyToAsync(fileContent);

            return(true);
        }
Exemplo n.º 18
0
        public void SuccessfulExportUpdatesLastUploadDate()
        {
            _testDateUtils.Now = DateTime.Now;
            UploadSettings uploadSettings = null;

            _mockSettingStore.Setup(store => store.SetSettings(It.IsAny <UploadSettings>()))
            .Callback <UploadSettings>(settings => uploadSettings = settings);

            WhenExportIsExecuted();

            Assert.AreEqual(_testDateUtils.Now, uploadSettings.LastUploadDate);
        }
Exemplo n.º 19
0
        public void ShouldInitializeWithCurrentDate()
        {
            var uut = new UploadSettings();

            uut.Initialize();
            var dateTime = DateTime.Now;

            Assert.IsTrue(uut.IsInitialized());
            var comparer = new SimilarDateTimeComparer(50);

            Assert.IsTrue(comparer.Equal(dateTime, uut.LastNotificationDate));
            Assert.IsTrue(comparer.Equal(dateTime, uut.LastUploadDate));
        }
Exemplo n.º 20
0
        public (FileStream Content, string ContentType)? FindContent(UploadSettings configuration, string fileName, string extension)
        {
            Ensure.NotNull(configuration, "configuration");

            if (!configuration.IsDownloadEnabled)
            {
                return(null);
            }

            if (extension == null)
            {
                return(null);
            }

            extension = "." + extension;
            fileName  = fileName + extension;
            if (fileName.Contains(Path.DirectorySeparatorChar) || fileName.Contains(Path.AltDirectorySeparatorChar) || fileName.Contains("..") || Path.IsPathRooted(fileName))
            {
                return(null);
            }

            extension = extension.ToLowerInvariant();
            if (!configuration.IsSupportedExtension(extension))
            {
                return(null);
            }

            string filePath = Path.Combine(configuration.StoragePath, fileName);

            if (File.Exists(filePath))
            {
                string contentType = "application/octet-stream";
                if (extension == ".gif")
                {
                    contentType = "image/gif";
                }
                else if (extension == ".png")
                {
                    contentType = "image/png";
                }
                else if (extension == ".jpg" || extension == ".jpeg")
                {
                    contentType = "image/jpg";
                }

                return(new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read), contentType);
            }

            return(null);
        }
        public UploadFileService()
        {
            _uploadSettings = Config.Get <UploadSettings>();
            if (_uploadSettings.Path.StartsWith("~"))
            {
                _uploadSettings.Path = HostingEnvironment.MapPath(_uploadSettings.Path);
            }

            if (!Directory.Exists(_uploadSettings.Path))
            {
                Directory.CreateDirectory(_uploadSettings.Path);
            }

            _streamProvider = new MultipartFormDataStreamProvider(_uploadSettings.Path);
        }
Exemplo n.º 22
0
        public async Task Test_Upload_ContentLength()
        {
            //Upload
            UploadSettings settings = CakeHelper.CreateEnvironment().CreateUploadSettings();

            settings.BucketName = "cake-aws-s3";

            settings.GenerateContentLength = true;
            settings.CompressContent       = true;
            settings.CannedACL             = Amazon.S3.S3CannedACL.PublicRead;
            settings.CacheControl          = "private, max-age=86400";

            IS3Manager manager = CakeHelper.CreateS3Manager();
            await manager.Upload(new FilePath("./Files/Test.css"), "Tester.css", settings);
        }
Exemplo n.º 23
0
    protected void UploadDoc(object sender, EventArgs e)
    {
        int measureID = Convert.ToInt32(Request.QueryString["mID"]);

        if (FileUpload_Doc.HasFile)
        {
            UploadSettings s = new UploadSettings(
                Server.MapPath("~/webdocs/").ToString()
                , FileUpload_Doc.PostedFile.FileName.ToString()
                , UploadFiletype.Doc);

            s.doctitle          = txtDocTitle.Text.ToString();
            s.docdesc           = txtDocDesc.Text.ToString();
            s.doctypeID         = Convert.ToInt32(ddl_DocType.SelectedValue);
            s.docstatusID       = Convert.ToInt32(ddl_DocStatus.SelectedValue);
            s.linked_entitytype = DbEntityType.measure;
            s.linked_entityID   = measureID;

            if (s.IsAllowed)
            {
                string upload_results = Uploader.UploadDoc(FileUpload_Doc, s);

                if (upload_results == "ok")
                {
                    lblDocUploadInfo.Text      = "You have successfully upload this document.";
                    lblDocUploadInfo.ForeColor = Color.ForestGreen;
                }
                else
                {
                    lblDocUploadInfo.Text      = upload_results;
                    lblDocUploadInfo.ForeColor = Color.DarkRed;
                }
            }
            else
            {             //Not an allowed file type
                lblDocUploadInfo.Text      = "Error: This file type is not allowed.";
                lblDocUploadInfo.ForeColor = Color.DarkRed;
            }
        }
        else
        {
            lblDocUploadInfo.Text      = "You must select a file for upload.";
            lblDocUploadInfo.ForeColor = Color.DarkRed;
        }

        LoadDocs(measureID);
    }
Exemplo n.º 24
0
        public async Task Test_Meta()
        {
            //Upload
            UploadSettings settings = CakeHelper.CreateEnvironment().CreateUploadSettings();

            settings.BucketName = "cake-aws-s3";

            IS3Manager manager = CakeHelper.CreateS3Manager();
            await manager.Upload(new FilePath("./Files/Encoding.txt"), "Encodings.txt", settings);



            //Get Meta
            MetadataCollection meta = await manager.GetObjectMetaData("Encodings.txt", "", settings);

            string metaHash = meta["x-amz-meta-hashtag"];
        }
Exemplo n.º 25
0
    protected UploadSettings LogTheUpload(UploadedFileInfo fileInfo, string docTitle, int doctypeID)
    {
        SQL_utils sql = new SQL_utils("backend");
        //Log the upload
        UploadSettings uploadSettings = new UploadSettings(fileInfo.FilePath, fileInfo.OriginalFileName, UploadFiletype.Doc);

        uploadSettings.linked_entitytype = (DbEntityType)Convert.ToInt32(Request.QueryString["entitytypeid"]);
        uploadSettings.linked_entityID   = GetEntityID(sql);
        uploadSettings.doctitle          = fileInfo.OriginalFileName;
        uploadSettings.doctypeID         = doctypeID; // sql.IntScalar_from_SQLstring("select doctypeID from tblDocType_lkup where doctype='Luminex Excel Data'");
        uploadSettings.docstatusID       = sql.IntScalar_from_SQLstring("select docstatusID from tblDocStatus_lkup where docstatus='default'");
        uploadSettings.LogUpload();

        string results = "";

        if (uploadSettings.docversID > 0)
        {
            //Copy to webdocs
            string path        = Server.MapPath(@"~\webdocs\");
            string newpathname = String.Format("{0}{1}", path, uploadSettings.docfilename);

            try
            {
                File.Copy(fileInfo.FilePath, newpathname);
                //int new_datauploadpk = sql.IntScalar_from_SQLstring(String.Format("select datauploadpk from def.DataUpload where docversID={0}", uploadSettings.docversID));

                results = String.Format("docID={0}, docversID={1}", uploadSettings.docID, uploadSettings.docversID);

                //if (new_datauploadpk == max_datauppk)
                //{
                //    results = String.Format("docID={0}, docversID={1}, datauploadpk={2}", uploadSettings.docID, uploadSettings.docversID, new_datauploadpk);
                //} else
                //{
                //    results = String.Format("Error logging data upload ({0} != {1}",
                //}
            }
            catch (Exception ex)
            {
                string err   = ex.Message;
                string unlog = uploadSettings.UnlogUpload();
                results = String.Format("{0} {1}", err, unlog);
            }
        }
        uploadSettings.results = results;
        return(uploadSettings);
    }
Exemplo n.º 26
0
        public void Test_Meta()
        {
            //Upload
            UploadSettings settings = CakeHelper.CreateEnvironment().CreateUploadSettings();

            settings.BucketName = "cake-aws-s3";

            IS3Manager manager = CakeHelper.CreateS3Manager();

            manager.Upload(new FilePath("../../packages.config"), "packages.config", settings);



            //Get Meta
            MetadataCollection meta = manager.GetObjectMetaData("packages.config", "", settings);

            string metaHash = meta["x-amz-meta-hashtag"];
        }
Exemplo n.º 27
0
        public void CreateUploadStepTest()
        {
            //Arrange
            var pipelineMediator = new Mock<IStepMediator>();
            var webClient = new Mock<IEncodeWebClient>();
            var storageProvider = new Mock<IFileSystem>();
            var tempFileManager = new Mock<ITempFileManager>();
            var fileWrapper = new Mock<IFileWrapper>();

            var settings = new UploadSettings("backendId");

            //Act
            var pipelineStep = new UploadStep(pipelineMediator.Object, webClient.Object, tempFileManager.Object, settings, storageProvider.Object, fileWrapper.Object);

            //Assert
            Assert.IsInstanceOfType(pipelineStep, typeof(PipelineStepBase<EncodeStepData>));
            Assert.IsInstanceOfType(pipelineStep, typeof(PipelineStepBase<EncodeStepData>));
            pipelineMediator.Verify(m => m.AddUploadStep(pipelineStep), Times.Once());
        }
Exemplo n.º 28
0
        public void CreateUploadStepTest()
        {
            //Arrange
            var pipelineMediator = new Mock <IStepMediator>();
            var webClient        = new Mock <IEncodeWebClient>();
            var storageProvider  = new Mock <IFileSystem>();
            var tempFileManager  = new Mock <ITempFileManager>();
            var fileWrapper      = new Mock <IFileWrapper>();

            var settings = new UploadSettings("backendId");

            //Act
            var pipelineStep = new UploadStep(pipelineMediator.Object, webClient.Object, tempFileManager.Object, settings, storageProvider.Object, fileWrapper.Object);

            //Assert
            Assert.IsInstanceOfType(pipelineStep, typeof(PipelineStepBase <EncodeStepData>));
            Assert.IsInstanceOfType(pipelineStep, typeof(PipelineStepBase <EncodeStepData>));
            pipelineMediator.Verify(m => m.AddUploadStep(pipelineStep), Times.Once());
        }
Exemplo n.º 29
0
        private static void TryBackupFile(UploadSettings configuration, string filePath)
        {
            if (!String.IsNullOrEmpty(configuration.BackupTemplate))
            {
                TokenWriter writer = new TokenWriter(configuration.BackupTemplate);

                int    order       = 0;
                string newFilePath = null;
                do
                {
                    string newFileName = writer.Format(token =>
                    {
                        if (token == "FileName")
                        {
                            return(Path.GetFileNameWithoutExtension(filePath));
                        }

                        if (token == "Extension")
                        {
                            return(Path.GetExtension(filePath).Substring(1));
                        }

                        if (token == "Order")
                        {
                            return((++order).ToString());
                        }

                        throw Ensure.Exception.NotSupported($"Not supported token '{token}' in backup template '{configuration.BackupTemplate}'.");
                    });

                    string currentNewFilePath = Path.Combine(Path.GetDirectoryName(filePath), newFileName);

                    if (currentNewFilePath == newFilePath || order > 100)
                    {
                        throw Ensure.Exception.InvalidOperation($"Maximum path probing reached on path '{newFilePath}'.");
                    }

                    newFilePath = currentNewFilePath;
                }while (File.Exists(newFilePath));

                File.Copy(filePath, newFilePath);
            }
        }
Exemplo n.º 30
0
        public void Initialize()
        {
            var settings = new UploadSettings(UserId);
            var stepData = new EncodeStepData()
            {
                EncoderState = EncoderState.Completed,
                ContentType = ContentType
            };

            _pipelineMediator = new Mock<IStepMediator>();
            _webClient = new Mock<IEncodeWebClient>();
            _fileSystem = new Mock<IFileSystem>();
            _tempFileManager = new Mock<ITempFileManager>();
            _fileWrapper = new Mock<IFileWrapper>();
            _tokenSource = new Mock<CancellationTokenSourceWrapper>();

            _pipelineStep = new UploadStep(_pipelineMediator.Object, _webClient.Object, _tempFileManager.Object, settings, _fileSystem.Object, _fileWrapper.Object);

            _tempFileManager.Setup(m => m.GetEncodingTempFilePath()).Returns(LocalFileUri);
            
            _pipelineStep.SetData(stepData);
        }
Exemplo n.º 31
0
        public void Initialize()
        {
            var settings = new UploadSettings(UserId);
            var stepData = new EncodeStepData()
            {
                EncoderState = EncoderState.Completed,
                ContentType  = ContentType
            };

            _pipelineMediator = new Mock <IStepMediator>();
            _webClient        = new Mock <IEncodeWebClient>();
            _fileSystem       = new Mock <IFileSystem>();
            _tempFileManager  = new Mock <ITempFileManager>();
            _fileWrapper      = new Mock <IFileWrapper>();
            _tokenSource      = new Mock <CancellationTokenSourceWrapper>();

            _pipelineStep = new UploadStep(_pipelineMediator.Object, _webClient.Object, _tempFileManager.Object, settings, _fileSystem.Object, _fileWrapper.Object);

            _tempFileManager.Setup(m => m.GetEncodingTempFilePath()).Returns(LocalFileUri);

            _pipelineStep.SetData(stepData);
        }
Exemplo n.º 32
0
        public IReadOnlyList <FileModel> FindList(UploadSettings configuration)
        {
            Ensure.NotNull(configuration, "configuration");

            if (!configuration.IsBrowserEnabled)
            {
                return(null);
            }

            if (!Directory.Exists(configuration.StoragePath))
            {
                return(Array.Empty <FileModel>());
            }

            List <FileModel> files = Directory
                                     .EnumerateFiles(configuration.StoragePath)
                                     .Where(f => configuration.IsSupportedExtension(Path.GetExtension(f).ToLowerInvariant()))
                                     .Select(f => new FileModel(new FileInfo(f)))
                                     .OrderBy(f => f.Name)
                                     .ToList();

            return(files);
        }
Exemplo n.º 33
0
 public TestController(ILog_AdminService logAdmin, IOptions <UploadSettings> uploadSettings, ILogger <TestController> log)
 {
     _logAdmin            = logAdmin;
     _log                 = log;
     this._uploadSettings = uploadSettings.Value;
 }
        private async Task LoadSettings()
        {
            RetryButtonIsVisible = false;
            App.Settings.ConnectionDetails = new ConnectionDetails
            {
                PortNo = 8096
            };

            var doNotShowFirstRun = _applicationSettings.Get(Constants.Settings.DoNotShowFirstRun, false);

            if (!doNotShowFirstRun)
            {
                NavigationService.NavigateTo(Constants.Pages.FirstRun.WelcomeView);
                return;
            }

            SetProgressBar(AppResources.SysTrayLoadingSettings);

#if !DEBUG
            //try
            //{
            //    if (!ApplicationManifest.Current.App.Title.ToLower().Contains("beta"))
            //    {
            //        var marketPlace = new MarketplaceInformationService();
            //        var appInfo = await marketPlace.GetAppInformationAsync(ApplicationManifest.Current.App.ProductId);

            //        if (new Version(appInfo.Entry.Version) > new Version(ApplicationManifest.Current.App.Version) &&
            //            MessageBox.Show("There is a newer version, would you like to install it now?", "Update Available", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
            //        {
            //            new MarketplaceDetailService().Show();
            //        }
            //    }
            //}
            //catch (Exception ex)
            //{
            //    Log.ErrorException("GetAppInformationAsync()", ex);
            //}
#endif
            // Get and set the app specific settings 
            _specificSettings = _applicationSettings.Get<SpecificSettings>(Constants.Settings.SpecificSettings);
            if (_specificSettings != null) Utils.CopyItem(_specificSettings, App.SpecificSettings);

            SetRunUnderLock();

            _uploadSettings = _applicationSettings.Get<UploadSettings>(Constants.Settings.PhotoUploadSettings);
            if (_uploadSettings != null) Utils.CopyItem(_uploadSettings, App.UploadSettings);

            _connectionDetails = _applicationSettings.Get<ConnectionDetails>(Constants.Settings.ConnectionSettings);
            _savedServer = _applicationSettings.Get<ServerInfo>(Constants.Settings.DefaultServerConnection);

            App.ServerInfo = _savedServer;

            await ConnectToServer();
        }