Пример #1
0
        private void UploadWholeFile(HttpContext context, List <FilesStatus> statuses)
        {
            IUserBasic     user = context.User.Identity as IUserBasic;
            HttpPostedFile httpPostedFile;

            for (int i = 0; i < context.Request.Files.Count; i++)
            {
                httpPostedFile = context.Request.Files[i];

                ArticleAttachment articleAttachment = new ArticleAttachment(this.RequestContextData.ApplicationThemeInfo.ApplicationId, user);

                articleAttachment.Content     = ReadStream(httpPostedFile.InputStream, httpPostedFile.ContentLength);
                articleAttachment.ContentSize = httpPostedFile.ContentLength;
                articleAttachment.ContentType = httpPostedFile.ContentType;
                articleAttachment.FileName    = httpPostedFile.FileName;

                UrlHelper urlHelper = new UrlHelper(context.Request.RequestContext);
                string    action    = urlHelper.RouteUrl(MagicStrings.FormatRouteName(
                                                             this.RequestContextData.ApplicationThemeInfo.ApplicationGroup, "Articles_FileUploadHandler"));

                var report = InstanceContainer.ArticleAttachmentManager.CreateTemporaryFile(articleAttachment);
                if (report.Status != Workmate.Components.Contracts.DataRepositoryActionStatus.Success)
                {
                    // TODO (Roman): errorhandling
                    statuses.Add(new FilesStatus(articleAttachment, report.Message, action));
                }
                else
                {
                    statuses.Add(new FilesStatus(articleAttachment, action));
                }
            }
        }
Пример #2
0
 public void Setup()
 {
     MagicStrings.SetMinimalModelVersion(FdoCache.ModelVersion);
     _env = new TestEnvironment();
     _languageDepotFolder = new TemporaryFolder(TestContext.CurrentContext.Test.Name + Path.GetRandomFileName());
     _lDSettings          = new LfMergeSettingsDouble(_languageDepotFolder.Path);
     Directory.CreateDirectory(_lDSettings.WebWorkDirectory);
     LanguageDepotMock.ProjectFolderPath =
         Path.Combine(_lDSettings.WebWorkDirectory, TestLangProj);
     Directory.CreateDirectory(LanguageDepotMock.ProjectFolderPath);
     _lfProject               = LanguageForgeProject.Create(TestLangProj);
     _synchronizeAction       = new SynchronizeAction(_env.Settings, _env.Logger);
     _workDir                 = Directory.GetCurrentDirectory();
     LanguageDepotMock.Server = new MercurialServer(LanguageDepotMock.ProjectFolderPath);
 }
Пример #3
0
        public void Error_NoBranch_OlderSupportedBranch()
        {
            // Setup
            // Create a hg repo that doesn't contain a branch for the current model version
            var lDProjectFolderPath = LanguageDepotMock.ProjectFolderPath;

            MercurialTestHelper.InitializeHgRepo(lDProjectFolderPath);
            MercurialTestHelper.HgCreateBranch(lDProjectFolderPath, 7000065);             // simulate a too old version
            MercurialTestHelper.CreateFlexRepo(lDProjectFolderPath);
            MagicStrings.SetMinimalModelVersion(7000065);

            // Execute
            _EnsureCloneAction.Run(_lfProject);

            // Verify
            Assert.That(_lfProject.State.SRState, Is.EqualTo(ProcessingState.SendReceiveStates.CLONING));
            Assert.That(ModelVersion, Is.EqualTo(7000065));
            Assert.That(Directory.Exists(_lfProject.ProjectDir), Is.True);
        }
        public void Error_DifferentBranch()
        {
            // Setup
            // Create a hg repo that doesn't contain a branch for the current model version
            const int modelVersion = 7000067;

            MagicStrings.SetMinimalModelVersion(modelVersion);
            var lDProjectFolderPath = LanguageDepotMock.ProjectFolderPath;

            MercurialTestHelper.InitializeHgRepo(lDProjectFolderPath);
            MercurialTestHelper.HgCreateBranch(lDProjectFolderPath, modelVersion);
            MercurialTestHelper.CreateFlexRepo(lDProjectFolderPath, modelVersion);
            MercurialTestHelper.CloneRepo(lDProjectFolderPath, _lfProject.ProjectDir);
            LanguageDepotMock.Server.Start();

            // Execute
            _synchronizeAction.Run(_lfProject);

            // Verify
            Assert.That(_lfProject.State.SRState, Is.EqualTo(ProcessingState.SendReceiveStates.SYNCING));
            Assert.That(ModelVersion, Is.EqualTo(modelVersion));
        }
Пример #5
0
        public void Error_NoBranch_UnsupportedBranch()
        {
            // Setup
            // Create a hg repo that doesn't contain a branch for the current model version
            var lDProjectFolderPath = LanguageDepotMock.ProjectFolderPath;

            MercurialTestHelper.InitializeHgRepo(lDProjectFolderPath);
            MercurialTestHelper.HgCreateBranch(lDProjectFolderPath, 7000060);             // simulate a too old version
            MercurialTestHelper.CreateFlexRepo(lDProjectFolderPath);
            MagicStrings.SetMinimalModelVersion(7000068);

            // Execute
            _EnsureCloneAction.Run(_lfProject);

            // Verify
            Assert.That(_env.Logger.GetErrors(), Does.Contain("no such branch"));
            Assert.That(_env.Logger.GetErrors(), Does.Contain(
                            "clone model version '7000060' less than minimal supported model version '7000068'."));
            Assert.That(_lfProject.State.SRState, Is.EqualTo(ProcessingState.SendReceiveStates.ERROR));
            Assert.That(ModelVersion, Is.EqualTo(0));
            Assert.That(Directory.Exists(_lfProject.ProjectDir), Is.False);
        }