Exemple #1
0
        /// <summary>
        /// Handles the recursion through directories: if a folder looks like a Bloom book upload it; otherwise, try its children.
        /// Invisible folders like .hg are ignored.
        /// </summary>
        /// <param name="folder"></param>
        /// <param name="dlg"></param>
        /// <param name="container"></param>
        /// <param name="context"></param>
        private void UploadInternal(string folder, BulkUploadProgressDlg dlg, ApplicationContainer container, ref ProjectContext context)
        {
            if (Path.GetFileName(folder).StartsWith("."))
            {
                return;                 // secret folder, probably .hg
            }
            if (Directory.GetFiles(folder, "*.htm").Count() == 1)
            {
                // Exactly one htm file, assume this is a bloom book folder.
                dlg.Progress.WriteMessage("Starting to upload " + folder);

                // Make sure the files we want to upload are up to date.
                // Unfortunately this requires making a book object, which requires making a ProjectContext, which must be created with the
                // proper parent book collection if possible.
                var parent         = Path.GetDirectoryName(folder);
                var collectionPath = Directory.GetFiles(parent, "*.bloomCollection").FirstOrDefault();
                if (collectionPath == null && context == null)
                {
                    collectionPath = Settings.Default.MruProjects.Latest;
                }
                if (context == null || context.SettingsPath != collectionPath)
                {
                    if (context != null)
                    {
                        context.Dispose();
                    }
                    // optimise: creating a context seems to be quite expensive. Probably the only thing we need to change is
                    // the collection. If we could update that in place...despite autofac being told it has lifetime scope...we would save some time.
                    // Note however that it's not good enough to just store it in the project context. The one that is actually in
                    // the autofac object (_scope in the ProjectContext) is used by autofac to create various objects, in particular, books.
                    context = container.CreateProjectContext(collectionPath);
                }
                var server = context.BookServer;
                var book   = server.GetBookFromBookInfo(new BookInfo(folder, true));
                book.BringBookUpToDate(new NullProgress());

                // Assemble the various arguments needed to make the objects normally involved in an upload.
                // We leave some constructor arguments not actually needed for this purpose null.
                var bookSelection = new BookSelection();
                bookSelection.SelectBook(book);
                var currentEditableCollectionSelection = new CurrentEditableCollectionSelection();
                if (collectionPath != null)
                {
                    var collection = new BookCollection(collectionPath, BookCollection.CollectionType.SourceCollection,
                                                        bookSelection);
                    currentEditableCollectionSelection.SelectCollection(collection);
                }
                var publishModel = new PublishModel(bookSelection, new PdfMaker(), currentEditableCollectionSelection, null, server, _htmlThumbnailer);
                publishModel.PageLayout = book.GetLayout();
                var    view = new PublishView(publishModel, new SelectedTabChangedEvent(), new LocalizationChangedEvent(), this, null);
                string dummy;
                FullUpload(book, dlg.Progress, view, out dummy, dlg);
                return;
            }
            foreach (var sub in Directory.GetDirectories(folder))
            {
                UploadInternal(sub, dlg, container, ref context);
            }
        }
        //[UmbracoAuthorize(Permissions = new[] { FixedPermissionIds.Publish })]
        public JsonResult PublishForm(PublishModel model)
        {
            if (!TryValidateModel(model))
            {
                return(ModelState.ToJsonErrors());
            }

            using (var uow = Hive.Create <IContentStore>())
            {
                var contentEntity = uow.Repositories.Revisions.GetLatestRevision <TypedEntity>(model.Id);
                if (contentEntity == null)
                {
                    throw new ArgumentException(string.Format("No entity found for id: {0} on action PublishForm", model.Id));
                }

                //get its children recursively
                if (model.IncludeChildren)
                {
                    // Get all descendents
                    var descendents = uow.Repositories.GetDescendentRelations(model.Id, FixedRelationTypes.DefaultRelationType);

                    foreach (var descendent in descendents)
                    {
                        //get the revision
                        var revisionEntity = uow.Repositories.Revisions.GetLatestRevision <TypedEntity>(descendent.DestinationId);

                        //publish it if it's already published or if the user has specified to publish unpublished content
                        if (revisionEntity != null && (revisionEntity.MetaData.StatusType.Alias == FixedStatusTypes.Published.Alias) || model.IncludeUnpublishedChildren)
                        {
                            var publishRevision = revisionEntity.CopyToNewRevision(FixedStatusTypes.Published);
                            uow.Repositories.Revisions.AddOrUpdate(publishRevision);
                        }
                    }
                }

                //publish this node
                var toPublish = contentEntity.CopyToNewRevision(FixedStatusTypes.Published);
                uow.Repositories.Revisions.AddOrUpdate(toPublish);

                //save
                uow.Complete();

                var contentViewModel = BackOfficeRequestContext.Application.FrameworkContext.TypeMappers.Map <Revision <TypedEntity>, ContentEditorModel>(toPublish);

                Notifications.Add(new NotificationMessage(
                                      model.IncludeChildren
                                          ? "Publish.ChildrenSuccess.Message".Localize(this, new { contentViewModel.Name }, encode: false)
                                          : "Publish.SingleSuccess.Message".Localize(this, new { contentViewModel.Name }, encode: false),
                                      "Publish.Title".Localize(this), NotificationType.Success));
                return(new CustomJsonResult(new
                {
                    success = true,
                    notifications = Notifications,
                    msg = model.IncludeChildren
                                  ? "Publish.ChildrenSuccess.Message".Localize(this, new { contentViewModel.Name }, encode: false)
                                  : "Publish.SingleSuccess.Message".Localize(this, new { contentViewModel.Name }, encode: false)
                }.ToJsonString));
            }
        }
        public void RemoveUnwantedLanguageData_TextPage_RemovesUnwantedDivs()
        {
            var html = @"<!DOCTYPE html>
<html>
<body>
	<div class='bloom-page numberedPage customPage side-right A4Landscape bloom-monolingual' data-page='' id='ba82b94f-71ec-48f7-a1cc-a68d5765e255' data-page-number='2' testRemoves='false' lang=''>
		<div class='pageLabel' data-i18n='TemplateBooks.PageLabel.Just Text' testRemoves='false' lang='en'>
			Just Text
		</div>
		<div class='pageDescription' testRemoves='false' lang='en'></div>
		<div class='marginBox'>
			<div class='split-pane-component-inner'>
				<div aria-describedby='qtip-0' data-hasqtip='true' class='bloom-translationGroup bloom-trailingElement' data-default-languages='auto'>
					<div role='textbox' class='bloom-editable normal-style bloom-content1 bloom-visibility-code-on' contenteditable='true' testRemoves='false' lang='en'>
						<p>This is Robin.</p>
					</div>
					<div role='textbox' class='bloom-editable normal-style' contenteditable='true' testRemoves='true' lang='tl'>
						<p>Ako si Robin</p>
					</div>
					<div role='textbox' class='bloom-editable normal-style' contenteditable='true' testRemoves='true' lang='ceb'></div>
					<div class='bloom-editable normal-style' contenteditable='true' testRemoves='false' lang='z'></div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>";
            // Check occurrences in original HTML.
            var dom           = new HtmlDom(html);
            var assertThatDom = AssertThatXmlIn.Dom(dom.RawDom);

            assertThatDom.HasSpecifiedNumberOfMatchesForXpath("//div[@lang='' and contains(@class, 'bloom-page')]", 1);
            assertThatDom.HasSpecifiedNumberOfMatchesForXpath("//div[@lang='en' and @class='pageLabel']", 1);
            assertThatDom.HasSpecifiedNumberOfMatchesForXpath("//div[@lang='en' and @class='pageDescription']", 1);
            assertThatDom.HasSpecifiedNumberOfMatchesForXpath("//div[@lang='en' and contains(@class, 'bloom-editable') and @role='textbox']", 1);
            assertThatDom.HasSpecifiedNumberOfMatchesForXpath("//div[@lang='tl' and contains(@class, 'bloom-editable') and @role='textbox']", 1);
            assertThatDom.HasSpecifiedNumberOfMatchesForXpath("//div[@lang='ceb' and contains(@class, 'bloom-editable') and @role='textbox']", 1);
            assertThatDom.HasSpecifiedNumberOfMatchesForXpath("//div[@lang='z' and contains(@class, 'bloom-editable') and @contenteditable='true']", 1);

            assertThatDom.HasSpecifiedNumberOfMatchesForXpath("//div[@lang]", 7);
            assertThatDom.HasSpecifiedNumberOfMatchesForXpath("//div[@lang and @testRemoves='false']", 5);
            assertThatDom.HasSpecifiedNumberOfMatchesForXpath("//div[@lang and @testRemoves='true']", 2);

            // SUT
            PublishModel.RemoveUnwantedLanguageData(dom, new[] { "en" });

            // Check occurrences in modified HTML.
            assertThatDom.HasSpecifiedNumberOfMatchesForXpath("//div[@lang='' and contains(@class, 'bloom-page')]", 1);                                  // unchanged
            assertThatDom.HasSpecifiedNumberOfMatchesForXpath("//div[@lang='en' and @class='pageLabel']", 1);                                            // unchanged
            assertThatDom.HasSpecifiedNumberOfMatchesForXpath("//div[@lang='en' and @class='pageDescription']", 1);                                      // unchanged
            assertThatDom.HasSpecifiedNumberOfMatchesForXpath("//div[@lang='en' and contains(@class, 'bloom-editable') and @role='textbox']", 1);        // unchanged
            assertThatDom.HasNoMatchForXpath("//div[@lang='tl' and contains(@class, 'bloom-editable') and @role='textbox']");                            // removed editable textbox
            assertThatDom.HasNoMatchForXpath("//div[@lang='ceb' and contains(@class, 'bloom-editable') and @role='textbox']");                           // removed editable textbox
            assertThatDom.HasSpecifiedNumberOfMatchesForXpath("//div[@lang='z' and contains(@class, 'bloom-editable') and @contenteditable='true']", 1); // unchanged

            assertThatDom.HasSpecifiedNumberOfMatchesForXpath("//div[@lang]", 5);                                                                        // removed 2 editable textboxes
            assertThatDom.HasSpecifiedNumberOfMatchesForXpath("//div[@lang and @testRemoves='false']", 5);
            assertThatDom.HasNoMatchForXpath("//div[@lang and @testRemoves='true']");
        }
Exemple #4
0
        internal PublishViewModel(PublishModel model)
        {
            this.model = model;

            PublishCommand              = new DelegateCommand(OnPublish, CanPublish);
            model.UploadStateChanged   += OnModelStateChanged;
            model.CustomizerURLChanged += OnCustomizerURLChanged;
        }
        public async Task <ActionResult> Index()
        {
            try
            {
                string userObjectID = ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value;
                string tenantId     = ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/tenantid").Value;

                string authority = string.Format(Startup.AuthorityFormat, tenantId);

                AuthenticationContext authContext = new AuthenticationContext(authority, new NaiveSessionCache(userObjectID));
                AuthenticationResult  authenticationResult;

                if (Startup.Certificate == null)
                {
                    ClientCredential credential = new ClientCredential(clientId, appKey);
                    authenticationResult = await authContext.AcquireTokenSilentAsync(nugetServiceResourceId, credential, new UserIdentifier(userObjectID, UserIdentifierType.UniqueId));
                }
                else
                {
                    ClientAssertionCertificate clientAssertionCertificate = new ClientAssertionCertificate(clientId, Startup.Certificate);
                    authenticationResult = await authContext.AcquireTokenSilentAsync(nugetServiceResourceId, clientAssertionCertificate, new UserIdentifier(userObjectID, UserIdentifierType.UniqueId));
                }

                HttpClient         client  = new HttpClient();
                HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, nugetPublishServiceBaseAddress + "/domains");
                request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", authenticationResult.AccessToken);
                HttpResponseMessage response = await client.SendAsync(request);

                if (response.IsSuccessStatusCode)
                {
                    string json = await response.Content.ReadAsStringAsync();

                    JArray result = JArray.Parse(json);

                    PublishModel model = new PublishModel();
                    foreach (string s in result.Values().Select(jtoken => jtoken.ToString()))
                    {
                        model.Domains.Add(s);
                    }

                    return(View(model));
                }
                else
                {
                    return(View(new PublishModel {
                        Message = "Unable to load list of domains"
                    }));
                }
            }
            catch (AdalSilentTokenAcquisitionException)
            {
                //TODO: this isn't quite right
                HttpContext.GetOwinContext().Authentication.Challenge(OpenIdConnectAuthenticationDefaults.AuthenticationType);
                return(View(new PublishModel {
                    Message = "AuthorizationRequired"
                }));
            }
        }
Exemple #6
0
        public ActionResult Validate(PublishModel model)
        {
            if (model.EntityId != 0)
            {
                return(this.RedirectToAction(model.ActionName, model.ControllerName, new { id = model.EntityId, publishCode = model.Code }));
            }

            return(this.RedirectToAction(model.ActionName, model.ControllerName, new { model.Skip, model.Take, publishKey = model.Code }));
        }
        public void Startup(ViewStartupParams p)
        {
            publishModel     = new PublishModel(p.AuthProvider, p.CustomNodeManager);
            publishViewModel = new PublishViewModel(publishModel);

            inviteModel = new InviteModel(p.AuthProvider);
            inviteModel.MessageLogged += this.OnMessageLogged;
            inviteViewModel            = new InviteViewModel(inviteModel);
        }
 public async UnaryResult <string> PublishAsync(PublishModel model)
 {
     if (!_dictionary.ContainsKey(model.ClientId))
     {
         _dictionary[model.ClientId] = new ConcurrentQueue <string>();
     }
     _dictionary[model.ClientId].Enqueue(model.OperationName);
     return("Success");
 }
Exemple #9
0
        public ActionResult Publish(TemplatePublisherModel templatePublisher, HttpPostedFileBase file, string tenantId)
        {
            CloudBlockBlob originalFileBlob = null;
            PublishModel   publishJob       = new PublishModel();

            try
            {
                if (file == null)
                {
                    ModelState.AddModelError(string.Empty, "Please provide file path");
                }

                //create an instance of templateModel from inputs
                IEnumerable <TemplateModel> templatesFromStorage = TemplateModel.GetFromStorage(tenantId);
                templatePublisher.Template = templatesFromStorage.Single <TemplateModel>(x => string.Compare(x.TemplateId, templatePublisher.Template.TemplateId,
                                                                                                             StringComparison.OrdinalIgnoreCase) == 0);

                publishJob.TenantId                = tenantId;
                publishJob.OriginalFileName        = file.FileName;
                publishJob.TemplateId              = templatePublisher.Template.TemplateId;
                publishJob.OriginalFileSizeInBytes = file.ContentLength;
                publishJob.SaveToStorage();

                originalFileBlob = DataModel.StorageFactory.Instance.IpcAzureAppFileBlobContainer.GetBlockBlobReference(publishJob.OriginalFileBlobRef);

                // Create the blob by uploading the original file.
                using (var fileStream = file.InputStream)
                {
                    originalFileBlob.UploadFromStream(fileStream);
                }

                //Create a command message for the worker role and send it by queue
                RmsCommand        rmsCommand        = new RmsCommand(RmsCommand.Command.PublishTemplate, tenantId, publishJob.OriginalFileBlobRef);
                CloudQueueMessage cloudQueueMessage = new CloudQueueMessage(rmsCommand.ToString());
                DataModel.StorageFactory.Instance.IpcAzureAppWorkerJobQueue.AddMessage(cloudQueueMessage);

                //Poll for completion of job by worker role. Don't poll for more than a minute
                DateTime     startTime = DateTime.Now;
                PublishModel pJob      = publishJob;
                while (startTime.AddMinutes(1) > DateTime.Now &&
                       string.Compare(pJob.JState.ToString(), DataModel.Models.PublishModel.JobState.Completed.ToString(), true) != 0)
                {
                    System.Threading.Thread.Sleep(1 * 100);
                    pJob = DataModel.Models.PublishModel.GetFromStorage(publishJob.TenantId, publishJob.OriginalFileBlobRef);
                }

                //send the published file to the user
                CloudBlockBlob publishedFileblob = DataModel.StorageFactory.Instance.IpcAzureAppFileBlobContainer.GetBlockBlobReference(pJob.PublishedFileBlobRef);
                return(File(publishedFileblob.OpenRead(), "application/force-download", pJob.PublishedFileName));
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.Message);
                return(View("Error"));
            }
        }
        public JsonResult GetSurveyInfo(string surveyid)
        {
            var          SurveyInfo = this._isurveyFacade.GetSurveyInfoModel(surveyid);
            PublishModel Model      = new PublishModel();

            Model.EndDate    = AddLeadingZero(SurveyInfo.ClosingDate.Month.ToString()) + "/" + AddLeadingZero(SurveyInfo.ClosingDate.Day.ToString()) + "/" + SurveyInfo.ClosingDate.Year;
            Model.IsDraft    = SurveyInfo.IsDraftMode;
            Model.SurveyName = SurveyInfo.SurveyName;
            return(Json(Model));
        }
Exemple #11
0
        internal PublishViewModel(PublishModel model)
        {
            this.model = model;

            PublishCommand              = new DelegateCommand(OnPublish, CanPublish);
            VisitCommand                = new DelegateCommand(Visit, CanVisit);
            CopyLinkCommand             = new DelegateCommand(CopyLink, CanCopyLink);
            model.UploadStateChanged   += OnModelStateChanged;
            model.CustomizerURLChanged += OnCustomizerURLChanged;
        }
Exemple #12
0
        private void SendEmailNotification(PublishModel model, HttpPostedFileBase newfile2)
        {
            string strPassCode = Epi.Web.MVC.Utility.SurveyHelper.GetPassCode();
            var    SurveyInfo  = this._isurveyFacade.GetSurveyInfoModel(model.EmailSurveyKey);
            Guid   ResponseID  = Guid.NewGuid();

            Epi.Web.Common.DTO.SurveyAnswerDTO SurveyAnswer = _isurveyFacade.CreateSurveyAnswer(SurveyInfo.SurveyId, ResponseID.ToString());



            _isurveyFacade.UpdatePassCode(ResponseID.ToString(), strPassCode);
        }
Exemple #13
0
 public void RemoveUnwantedLanguageData(string destDirName, IEnumerable <string> languagesToInclude)
 {
     // There should be only one html file with the same name as the directory it's in, but let's
     // not make any assumptions here.
     foreach (var filepath in Directory.EnumerateFiles(destDirName, "*.htm"))
     {
         var xmlDomFromHtmlFile = XmlHtmlConverter.GetXmlDomFromHtmlFile(filepath, false);
         var dom = new HtmlDom(xmlDomFromHtmlFile);
         PublishModel.RemoveUnwantedLanguageData(dom, languagesToInclude);
         XmlHtmlConverter.SaveDOMAsHtml5(dom.RawDom, filepath);
     }
 }
        public void RemoveUnwantedLanguageData_BloomDataDiv_RemovesNothingEvenWithN1()
        {
            var dom = new HtmlDom(kDataDivHtml);

            // Check occurrences in original HTML.
            VerifyDataDivValues(dom);

            // SUT
            PublishModel.RemoveUnwantedLanguageData(dom, new[] { "en" }, "en");

            // Check occurrences in modified HTML.  This should be exactly the same as before.
            VerifyDataDivValues(dom);
        }
        public void RemoveUnwantedLanguageData_PreserveIfEmbeddedDivWantedWithXmatter()
        {
            var dom = new HtmlDom(kEmbeddedLangDivsXMatterHtml);

            // Check occurrences in original HTML.
            VerifyOriginalEmbeddedDivsAreAllThere(dom);

            // SUT
            PublishModel.RemoveUnwantedLanguageData(dom, new[] { "en" });

            // Check occurrences in modified HTML: nothing removed from xmatter unless national language is specified.
            VerifyOriginalEmbeddedDivsAreAllThere(dom);
        }
        public void RemoveUnwantedLanguageData_PreserveIfEmbeddedDivWantedWithXmatterN1()
        {
            var dom = new HtmlDom(kEmbeddedLangDivsXMatterHtml);

            // Check occurrences in original HTML.
            VerifyOriginalEmbeddedDivsAreAllThere(dom);

            // SUT
            PublishModel.RemoveUnwantedLanguageData(dom, new[] { "en" }, "de");

            // Check occurrences in modified HTML: German should be preserved, French and Spanish removed.
            VerifyOnlyUnwantedEmbeddedDivsAreRemoved(dom, true);
        }
        public void RemoveUnwantedLanguageData_PreserveIfEmbeddedDivWanted()
        {
            var dom = new HtmlDom(kEmbeddedLangDivsHtml);

            // Check occurrences in original HTML.
            VerifyOriginalEmbeddedDivsAreAllThere(dom);

            // SUT
            PublishModel.RemoveUnwantedLanguageData(dom, new[] { "en" });

            // Check occurrences in modified HTML.
            VerifyOnlyUnwantedEmbeddedDivsAreRemoved(dom, false);
        }
        public void RemoveUnwantedLanguageData_PreserveIfEmbeddedDivWantedWithN1()
        {
            var dom = new HtmlDom(kEmbeddedLangDivsHtml);

            // Check occurrences in original HTML.
            VerifyOriginalEmbeddedDivsAreAllThere(dom);

            // SUT
            PublishModel.RemoveUnwantedLanguageData(dom, new[] { "en" }, "de");

            // Check occurrences in modified HTML: should be same for content page regardless of specifying national language.
            VerifyOnlyUnwantedEmbeddedDivsAreRemoved(dom, false);
        }
        public void RemoveUnwantedLanguageData_CreditsPage_RemovesRemovesUnwantedButKeepsN1()
        {
            var dom = new HtmlDom(kCreditsPageHtml);

            // Check occurrences in original HTML.
            VerifyCreditsPageValues(dom, false);

            // SUT
            PublishModel.RemoveUnwantedLanguageData(dom, new[] { "en" }, "en");

            // Check occurrences in modified HTML.  This should NOT be exactly the same as before.
            VerifyCreditsPageValues(dom, true);
        }
        public void RemoveUnwantedLanguageData_FrontCoverPage_RemovesNothing()
        {
            var dom = new HtmlDom(kFrontCoverHtml);

            // Check occurrences in original HTML.
            VerifyFrontCoverValues(dom, false);

            // SUT
            PublishModel.RemoveUnwantedLanguageData(dom, new[] { "en" });

            // Check occurrences in modified HTML.  This should be exactly the same as before.
            VerifyFrontCoverValues(dom, false);
        }
Exemple #21
0
        public JsonResult BackupSelect(string toPath)
        {
            List <EnvDetail> envPathList = PublishModel.ReadServerCsv();

            EnvDetail envPath = envPathList.Find(r => r.ToPath == toPath);

            List <BackupPathDetail> backupPathList = null;

            // selectIndexに当てはまる商材の情報がない場合、nullを返す
            if (envPath != null)
            {
                string backupDirectory = ConfigurationManager.AppSettings["BackupDirectory"];

                // 発行先(toPath)の最後のディレクトリ名 = 現在のインスタンスの名前を取得
                string toDirectory = new DirectoryInfo(envPath.ToPath).Name;

                // バックアップ先のパス
                string backupPath = backupDirectory + toDirectory;

                // ディレクトリが存在する場合、ディレクトリ一覧を取得する
                if (Directory.Exists(backupPath))
                {
                    backupPathList = new List <BackupPathDetail>();

                    DirectoryInfo backupDir = new DirectoryInfo(backupPath);

                    int count = 1;
                    foreach (DirectoryInfo dir in backupDir.GetDirectories())
                    {
                        // ディレクトリ名が"LatestBackup"(ロールバック用の臨時バックアップ)の場合、表示しない
                        if (dir.Name != "LatestBackup")
                        {
                            BackupPathDetail bp = new BackupPathDetail();
                            bp.viewName     = dir.Name;
                            bp.value        = Convert.ToString(count);
                            bp.BackupPath   = backupPath + @"\" + dir.Name;
                            bp.CreationTime = dir.CreationTime;
                            backupPathList.Add(bp);
                            count++;
                        }
                    }

                    // フォルダの作成日付を基準にソート
                    backupPathList.Sort(CreationTimeComparer);
                }
            }
            // APIとして下記を設定してJsonで返す
            // JsonRequestBehavior.AllowGet > クライアントからの HTTP GET 要求を許可します。
            return(Json(backupPathList, JsonRequestBehavior.AllowGet));
        }
Exemple #22
0
        public BloomLibraryPublishModel(BookTransfer transferer, BookInstance book, PublishModel model)
        {
            Book          = book;
            _transferrer  = transferer;
            _publishModel = model;

            _licenseMetadata = Book.GetLicenseMetadata();
            // This is usually redundant, but might not be on old books where the license was set before the new
            // editing code was written.
            Book.SetMetadata(_licenseMetadata);
            _license = _licenseMetadata.License;

            EnsureBookAndUploaderId();
        }
Exemple #23
0
        public JsonResult ProductListSelect(string selectValue)
        {
            List <EnvDetail> envPathList = null;

            // 0以外を選択した場合、商材のパスを取得する
            if (selectValue != "0")
            {
                envPathList = PublishModel.GetServerList(selectValue);
            }

            // APIとして下記を設定してJsonで返す
            // JsonRequestBehavior.AllowGet > クライアントからの HTTP GET 要求を許可します。
            return(Json(envPathList, JsonRequestBehavior.AllowGet));
        }
        private void SendEmailNotification(PublishModel model, HttpPostedFileBase newfile2)
        {
            string strPassCode = Epi.Web.MVC.Utility.SurveyHelper.GetPassCode();
            var    SurveyInfo  = this._isurveyFacade.GetSurveyInfoModel(model.EmailSurveyKey);
            Guid   ResponseID  = Guid.NewGuid();

            Epi.Web.Common.DTO.SurveyAnswerDTO SurveyAnswer = _isurveyFacade.CreateSurveyAnswer(SurveyInfo.SurveyId, ResponseID.ToString());

            // Epi.Web.Common.Message.UserAuthenticationResponse AuthenticationResponse = _isurveyFacade.GetAuthenticationResponse(ResponseID.ToString());


            //  if (string.IsNullOrEmpty(AuthenticationResponse.PassCode))
            // {

            _isurveyFacade.UpdatePassCode(ResponseID.ToString(), strPassCode);
            // }
        }
Exemple #25
0
        public void SetUp()
        {
            authenticationProvider = new Mock <IAuthProvider>();
            authenticationProvider.Setup(provider => provider.Username).Returns("DummyUserName");

            // Create mock of reach client.
            var client = new Mock <IWorkspaceStorageClient>();

            client.Setup(c =>
                         // If it's sent any workspace or any custom nodes, result always will be successful.
                         c.Send(It.IsAny <HomeWorkspaceModel>(), It.IsAny <IEnumerable <CustomNodeWorkspaceModel> >(), null)).
            Returns(Resources.WorkspacesSendSucceededServerResponse);

            // Create publish model.
            publishModel = new PublishModel(authenticationProvider.Object,
                                            CurrentDynamoModel.CustomNodeManager, client.Object);
        }
        public ActionResult Backup(PublishModel model, string productDivision, string guid, string backupDivision)
        {
            // トークンの比較(F5押下による呼び出しか確認)
            if (guid != (string)TempData["guid"])
            {
                // F5押下の場合は初期表示に戻す。
                return(RedirectToAction("Backup"));
            }

            // 各プロパティに指定したバリデーションのチェックを行う。
            // チェックに反する場合は、画面に戻りエラーを返す。
            if (ModelState.IsValid)
            {
                model = PublishControl(model, guid, productDivision, backupDivision);
            }

            // 問題が発生した場合はフォームを再表示する
            return(View(SetToken(model)));
        }
        /// <summary>
        /// トークン処理(F5防止のため)
        /// </summary>
        /// <param name="publishModel">publishModel to join</param>
        /// <returns>publishModel</returns>
        private PublishModel SetToken(PublishModel publishModel)
        {
            // GUID生成&hiddenに格納
            string guid = Guid.NewGuid().ToString();

            publishModel.Guid = guid;
            ModelState.SetModelValue("Guid", new ValueProviderResult(guid, guid, null));

            // TempDataがない場合は追加、ある場合は値を上書き
            if (TempData["guid"] == null)
            {
                TempData.Add("guid", guid);
            }
            else
            {
                TempData["guid"] = guid;
            }

            return(publishModel);
        }
Exemple #28
0
        public async Task <JsonResult> Publish(PublishModel publishModel)
        {
            if (publishModel.Environment == "review")
            {
            }

            //1. read xml
            var template  = GetDefaultTemplateByName(publishModel.TemplateName);
            var viewModel = new PartnerView
            {
                PartnerList = _templateService.GetTemplate()
            };

            var content = await _viewRenderService.RenderToStringAsync("Partner", viewModel);

            var result = template.Replace("<sky.template.b9fb8f26-8f08-4d73-8c84-2c7058b046d1.body/>", content);

            SaveToStorage("test", result);

            return(Json(WebUtility.HtmlEncode(result)));
        }
Exemple #29
0
        public ActionResult CreateRPublish()
        {
            Company              _currentcompany = IoC.Resolve <ICompanyService>().Getbykey(((EInvoiceContext)FXContext.Current).CurrentCompany.id);
            PublishModel         model           = new PublishModel();
            ITaxAuthorityService taxSrc          = IoC.Resolve <ITaxAuthorityService>();
            IRegisterTempService regisSrc        = IoC.Resolve <IRegisterTempService>();

            model.TaxList     = new SelectList(from tax in taxSrc.Query select tax, "Code", "Name");
            model.RegTempList = new SelectList(from re in regisSrc.Query where re.ComId == _currentcompany.id select re, "Id", "Name");
            Publish mPub = new Publish();

            mPub.ComID           = _currentcompany.id;
            mPub.ComName         = _currentcompany.Name;
            mPub.ComAddress      = _currentcompany.Address;
            mPub.ComTaxCode      = _currentcompany.TaxCode;
            mPub.ComPhone        = _currentcompany.Phone;
            mPub.RepresentPerson = _currentcompany.RepresentPerson;
            mPub.City            = "Hà Nội";
            model.mPublish       = mPub;
            model.PubInvoiceList = "[]";
            return(View(model));
        }
        private SurveyInfoResponse DoPublish(PublishModel Model, HttpPostedFileBase Newfile)
        {
            Guid NewGuid = new Guid();
            bool IsGuid  = Guid.TryParse(Model.SurveyKey, out NewGuid);

            SurveyInfoRequest SurveyRequest = new SurveyInfoRequest();
            SurveyInfoDTO     SurveyInfoDTO = new Common.DTO.SurveyInfoDTO();

            SurveyRequest.Criteria.FileInputStream = Newfile;
            SurveyInfoDTO.OrganizationKey          = SurveyRequest.Criteria.OrganizationKey = new Guid(Model.OrganizationKey);
            SurveyInfoDTO.SurveyName = Model.SurveyName;
            SurveyInfoDTO.StartDate  = DateTime.Now;
            SurveyInfoDTO.SurveyType = SurveyRequest.Criteria.SurveyType = 1;

            if (Model.UpdateExisting)
            {
                SurveyInfoDTO.SurveyId    = Model.RepublishSurveyKey;
                SurveyInfoDTO.IsDraftMode = Model.IsDraft;
                SurveyInfoDTO.ClosingDate = DateTime.Parse(Model.EndDateUpdate); Model.EndDate = Model.EndDateUpdate;
                SurveyInfoDTO.SurveyName  = Model.SurveyName;
                SurveyRequest.SurveyInfoList.Add(SurveyInfoDTO);
                SurveyInfoDTO.UserPublishKey = new Guid(Model.RepublishUserPublishKey);
                SurveyRequest.Action         = "Update";
            }
            else
            {
                SurveyInfoDTO.SurveyId    = Guid.NewGuid().ToString();
                SurveyInfoDTO.ClosingDate = DateTime.Parse(Model.EndDate);
                SurveyRequest.SurveyInfoList.Add(SurveyInfoDTO);
                SurveyInfoDTO.UserPublishKey = SurveyRequest.Criteria.UserPublishKey = Guid.NewGuid();
                SurveyRequest.Action         = "Create";
            }
            var response = this._isurveyFacade.PublishExcelSurvey(SurveyRequest);

            return(response);
        }