Ejemplo n.º 1
0
        private async Task <IActionResult> CreatePOST(AdvancedFormViewModel viewModel, Func <ContentItem, Task> conditionallyPublish)
        {
            var contentItem = await _contentManager.NewAsync(_id);

            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageAdvancedForms, contentItem))
            {
                return(Unauthorized());
            }

            var advForm = new AdvancedForm(viewModel.Description, viewModel.Instructions,
                                           viewModel.Container, viewModel.Title, viewModel.Header, viewModel.Footer, viewModel.Tag);

            contentItem.Content.AdvancedForm       = JToken.FromObject(advForm);
            contentItem.DisplayText                = viewModel.Title;
            contentItem.Content.AutoroutePart.Path = CreatePath(viewModel.Title);
            if (!ModelState.IsValid)
            {
                _session.Cancel();
                return(View(viewModel));
            }

            await _contentManager.CreateAsync(contentItem, VersionOptions.Draft);

            await conditionallyPublish(contentItem);

            return(RedirectToAction("Edit", new RouteValueDictionary {
                { "ContentItemId", contentItem.ContentItemId }
            }));
        }
Ejemplo n.º 2
0
        private async Task <IActionResult> EditPOST(AdvancedFormViewModel viewModel, string returnUrl, Func <ContentItem, Task> conditionallyPublish)
        {
            string contentItemId = viewModel.Id;

            var contentItem = await _contentManager.GetAsync(contentItemId, VersionOptions.DraftRequired);

            if (contentItem == null)
            {
                return(NotFound());
            }

            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageAdvancedForms, contentItem))
            {
                return(Unauthorized());
            }

            var advForm = new AdvancedForm(viewModel.Description, viewModel.Instructions,
                                           viewModel.Container, viewModel.Title);
            var titlePart = new TitlePart(viewModel.Title);

            contentItem.Content.AdvancedForm       = JToken.FromObject(advForm);
            contentItem.Content.TitlePart          = JToken.FromObject(titlePart);
            contentItem.Content.AutoroutePart.Path = CreatePath(viewModel.Title);

            var model = new AdvancedFormViewModel
            {
                Id           = viewModel.Id,
                Title        = contentItem.Content.AdvancedForm.Title,
                Container    = contentItem.Content.AdvancedForm.Container.Html,
                Description  = contentItem.Content.AdvancedForm.Description.Html,
                Instructions = contentItem.Content.AdvancedForm.Instructions.Html
            };

            if (!ModelState.IsValid)
            {
                _session.Cancel();
                return(View("Create", model));
            }

            await conditionallyPublish(contentItem);

            // The content item needs to be marked as saved (again) in case the drivers or the handlers have
            // executed some query which would flush the saved entities. In this case the changes happening in handlers
            // would not be taken into account.
            _session.Save(contentItem);

            var typeDefinition = _contentDefinitionManager.GetTypeDefinition(contentItem.ContentType);

            if (returnUrl == null)
            {
                return(RedirectToAction("Edit", new RouteValueDictionary {
                    { "ContentItemId", viewModel.Id }
                }));
            }
            else
            {
                return(LocalRedirect(returnUrl));
            }
        }
Ejemplo n.º 3
0
        private void BtnOpen_Click(object sender, EventArgs e)
        {
            try
            {
                AdvancedForm form = (AdvancedForm)ListBox.SelectedIndices[0];
                Form         tool = new Form();
                switch (form)
                {
                case AdvancedForm.tenZoneCal:
                    if (Application.OpenForms.OfType <CalGenerator>().Any())
                    {
                        Application.OpenForms.OfType <CalGenerator>().First().BringToFront();
                    }
                    else
                    {
                        tool = new CalGenerator();
                    }
                    Close();
                    break;

                case AdvancedForm.uTPlogParser:
                    if (Application.OpenForms.OfType <uTP.PrintLogParser>().Any())
                    {
                        Application.OpenForms.OfType <uTP.PrintLogParser>().First().BringToFront();
                    }
                    else
                    {
                        tool = new uTP.PrintLogParser();
                    }
                    Close();
                    break;

                case AdvancedForm.mapFlip:
                    if (Application.OpenForms.OfType <MapFlip>().Any())
                    {
                        Application.OpenForms.OfType <MapFlip>().First().BringToFront();
                    }
                    else
                    {
                        tool = new MapFlip();
                    }
                    Close();
                    break;

                // Create a form in the AdvancedTools folder and add a case above this comment
                // for the newly added enum field and copy the above examples to launch the new form
                default:
                    MessageBox.Show("Invalid Selection", "XferSuite Advanced Tools");
                    return;
                }
                tool.Activated += Tool_Activated;
                tool.Show();
                MainMenu.Settings.PropertyGrid.SelectedObject = form;
            }
            catch (Exception)
            {
                MessageBox.Show("Invalid Selection", "XferSuite Advanced Tools");
            }
        }
Ejemplo n.º 4
0
        private async Task <IActionResult> EditPOST(AdvancedFormViewModel viewModel, string returnUrl, Func <ContentItem, Task> conditionallyPublish, bool isEditPage = false)
        {
            string contentItemId = viewModel.Id;

            var contentItem = await _contentManager.GetAsync(contentItemId, VersionOptions.DraftRequired);

            if (contentItem == null)
            {
                return(NotFound());
            }

            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageAdvancedForms, contentItem))
            {
                return(Unauthorized());
            }

            var advForm = new AdvancedForm(viewModel.Description, viewModel.Instructions,
                                           viewModel.Container, viewModel.Title, viewModel.Header, viewModel.Footer, viewModel.Type, viewModel.AdminContainer, viewModel.HideFromListing, viewModel.IsGlobalHeader, viewModel.IsGlobalFooter, viewModel.Group, viewModel.FormFields);

            contentItem.Content.AdvancedForm = JToken.FromObject(advForm);
            contentItem.DisplayText          = viewModel.Title;
            var path = CreatePath(viewModel.Title);

            contentItem.Content.AutoroutePart.Path = path;

            contentItem.Alter <OrchardCore.Autoroute.Model.AutoroutePart>(x => x.Path = path);

            var model = new AdvancedFormViewModel
            {
                Id        = viewModel.Id,
                Title     = contentItem.DisplayText,
                Container = contentItem.Content.AdvancedForm.Container.Html != null?JsonConvert.SerializeObject(contentItem.Content.AdvancedForm.Container.Html) : String.Empty,
                                FormFields = contentItem.Content.AdvancedForm.FormFields != null && contentItem.Content.AdvancedForm.FormFields.Html != null?JsonConvert.SerializeObject(contentItem.Content.AdvancedForm.FormFields.Html) : String.Empty,
                                                 AdminContainer = contentItem.Content.AdvancedForm.AdminContainer.Html != null?JsonConvert.SerializeObject(contentItem.Content.AdvancedForm.AdminContainer.Html) : String.Empty,
                                                                      Description     = contentItem.Content.AdvancedForm.Description.Html,
                                                                      Instructions    = contentItem.Content.AdvancedForm.Instructions.Html,
                                                                      Header          = contentItem.Content.AdvancedForm.Header.Html,
                                                                      Footer          = contentItem.Content.AdvancedForm.Footer.Html,
                                                                      Type            = contentItem.Content.AdvancedForm.Type.Text,
                                                                      Group           = contentItem.Content.AdvancedForm.Group.Text,
                                                                      HideFromListing = contentItem.Content.AdvancedForm.HideFromListing.Value,
                                                                      IsGlobalHeader  = contentItem.Content.AdvancedForm.IsGlobalHeader.Value,
                                                                      IsGlobalFooter  = contentItem.Content.AdvancedForm.IsGlobalFooter.Value
            };

            if (!ModelState.IsValid)
            {
                _session.Cancel();
                if (isEditPage)
                {
                    return(View("Create", model));
                }
                else
                {
                    return(View("Adminfields", model));
                }
            }

            await conditionallyPublish(contentItem);

            // The content item needs to be marked as saved (again) in case the drivers or the handlers have
            // executed some query which would flush the saved entities. In this case the changes happening in handlers
            // would not be taken into account.
            _session.Save(contentItem);

            var typeDefinition = _contentDefinitionManager.GetTypeDefinition(contentItem.ContentType);

            if (returnUrl == null)
            {
                if (isEditPage)
                {
                    return(RedirectToAction("Edit", new RouteValueDictionary {
                        { "ContentItemId", viewModel.Id }
                    }));
                }
                else
                {
                    return(RedirectToAction("Adminfields", new RouteValueDictionary {
                        { "ContentItemId", viewModel.Id }
                    }));
                }
            }
            else
            {
                return(LocalRedirect(returnUrl));
            }
        }
Ejemplo n.º 5
0
        // Set advanced parameters(PaperSupply,BlankPageSkip,AutoRotation,MultiFeedDetection,Brightness,
        // Contrast).
        private void buttonAdvanced_Click(object sender, System.EventArgs e)
        {
            timerLogout.Stop();
            timerLogout.Interval = autoLogoutTime;

            AdvancedForm advancedform = new AdvancedForm();

            advancedform.papersupply = scanParam.PaperSupply;
            advancedform.paperfacedirection = scanParam.PaperFaceDirection;
            advancedform.blankpageskip = scanParam.BlankPageSkip;
            advancedform.autorotation = scanParam.AutoRotation;
            advancedform.multifeeddetection = scanParam.MultifeedDetection;
            advancedform.multifeeddetectiondetail = scanParam.MultiFeedDetectionDetail;
            advancedform.brightness = scanParam.Brightness;
            advancedform.contrast = scanParam.Contrast;
            advancedform.jpegcompression = scanParam.JPEGCompression;
            advancedform.highcompressionpdf = scanParam.HighCompressionPDF;

            if(advancedform.ShowDialog(this) == DialogResult.OK)
            {
                scanParam.PaperSupply = advancedform.papersupply;
                scanParam.PaperFaceDirection = advancedform.paperfacedirection;
                scanParam.BlankPageSkip = advancedform.blankpageskip;
                scanParam.AutoRotation = advancedform.autorotation;
                scanParam.MultifeedDetection = advancedform.multifeeddetection;
                scanParam.MultiFeedDetectionDetail = advancedform.multifeeddetectiondetail;
                scanParam.Brightness = advancedform.brightness;
                scanParam.Contrast = advancedform.contrast;
                scanParam.JPEGCompression = advancedform.jpegcompression;
                scanParam.HighCompressionPDF = advancedform.highcompressionpdf;

                labelPaperSupply.Text = scanParam.PaperSupply.ToString();

                if (scanParam.PaperFaceDirection)
                {
                    labelPaperFaceDirection.Text = "Face-up";
                }
                else
                {
                    labelPaperFaceDirection.Text = "Face-down";
                }

                if(scanParam.BlankPageSkip)
                {
                    labelBlackPageSkip.Text = "Yes";
                }
                else
                {
                    labelBlackPageSkip.Text = "No";
                }

                if(scanParam.AutoRotation)
                {
                    labelAutoRotation.Text = "Yes";
                }
                else
                {
                    labelAutoRotation.Text = "No";
                }

                if(scanParam.MultifeedDetection)
                {
                    switch (scanParam.MultiFeedDetectionDetail)
                    {
                        case MultiFeedDetectionDetail.Ultrasonic:
                            labelMultiFeedDetection.Text = "Ultrasonic";
                            break;
                        case MultiFeedDetectionDetail.Length:
                            labelMultiFeedDetection.Text = "Length";
                            break;
                        default:
                            labelMultiFeedDetection.Text = "Both";
                            break;
                    }
                }
                else
                {
                    labelMultiFeedDetection.Text = "None";
                }

                if (scanParam.HighCompressionPDF)
                {
                    labelHighCompressionPDF.Text = "Yes";
                }
                else
                {
                    labelHighCompressionPDF.Text = "No";
                }

                labelJPEGCompression.Text = scanParam.JPEGCompression.ToString();
                labelBrightnes.Text = scanParam.Brightness.ToString();
                labelContrast.Text = scanParam.Contrast.ToString();

            }

            timerLogout.Start();
        }