public IActionResult GetLatestEvents()
        {
            var sb = new StringBuilder("<pre>");

            var context  = Hosting.GetHttpContext();
            var eventLog = context.Session.Get <Stack <string> >(EventLogSessionKey);

            if (eventLog == null || eventLog.Count == 0)
            {
                sb.AppendLine("No events.");
            }
            else
            {
                while (eventLog.Count > 0)
                {
                    sb.AppendLine("Event " + eventLog.Count + " - " + DateTime.Now.ToString("T"));
                    sb.AppendLine(new String('-', 80));
                    sb.AppendLine(eventLog.Pop());
                }
            }

            sb.AppendLine("</pre>");

            return(Content(sb.ToString(), "text/html"));
        }
        private void HandleLanguage(FileUploader fileUploader)
        {
            var context          = Hosting.GetHttpContext();
            var selectedLanguage = context.Request["languageSelector"];

            if (selectedLanguage != null)
            {
                fileUploader.DisplayLanguage = selectedLanguage;
            }
            else
            {
                selectedLanguage = fileUploader.DisplayLanguage;
            }

            PopulateLanguageSelector(selectedLanguage);
        }
        public IActionResult Dynamic()
        {
            var fileManager = new FileManager
            {
                Width     = 800,
                Height    = 600,
                Resizable = true
            };

            var context      = Hosting.GetHttpContext();
            var selectedUser = context.Request["userSelector"] ?? "User1";

            SetDynamicFolderAndPermissions(fileManager, selectedUser);

            PopulateUserSelector(selectedUser);

            return(View(fileManager));
        }
Exemple #4
0
        public IActionResult Overview()
        {
            var fileUploader = new FileUploader
            {
                Width          = 600, //Default unit is pixels. Percentage can be specified as CssLength.Percentage(100)
                Height         = 300,
                Resizable      = true,
                UploadLocation = "~/App_Data/Uploads"
            };

            var context          = Hosting.GetHttpContext();
            var selectedLanguage = context.Request["languageSelector"];

            if (selectedLanguage != null)
            {
                fileUploader.DisplayLanguage = selectedLanguage;
            }

            PopulateLanguageSelector(selectedLanguage);

            return(View(fileUploader));
        }
Exemple #5
0
        public IActionResult Processing()
        {
            var context = Hosting.GetHttpContext();
            int selectedValue;

            int.TryParse(context.Request["taskSelector"], out selectedValue);

            var model = new ProcessingViewModel
            {
                ExampleFileSelector = new ExampleFileSelector
                {
                    Id          = "exampleFileSelector",
                    InitialFile = "JPG Image.jpg",
                    FormWrapped = false
                },
                TaskSelectList = PopulateTaskSelector(selectedValue)
            };

            model.ImagePath = model.ExampleFileSelector.SelectedFile;

            var expression = TaskExpressions[selectedValue];
            var lambda     = expression.Compile();

            model.TaskAction = task =>
            {
                task.ResizeWidth(400);
                lambda(task);
            };

            model.CodeString = string.Format(
                "@this.ImageTag(\"{0}\", {1})",
                model.ExampleFileSelector.SelectedFile.FileName,
                ExpressionStringBuilder.ToString(expression)
                );

            return(View(model));
        }
        public IActionResult Overview()
        {
            var fileManager = new FileManager
            {
                Width     = 800, //Default unit is pixels. Percentage can be specified as CssLength.Percentage(100)
                Height    = 600,
                Resizable = true
            };

            //Create a root folder via assignment statements and add it to the control.
            var rootFolder = new FileManagerRootFolder();

            rootFolder.Name = "1. Root Folder";

            /*
             * For connecting as a specific user to a protected folder (UNC or local) use this format:
             *
             *  Location="Path=\\server\share; User Name=USERNAME; Password=PASSWORD"
             *  Please see description of Location property on the right pane for more information.
             *
             * Information on FileManagerRootFolder.Location property as of v4.7:
             *
             *  This property is now of type Location class instead of string. You can still assign
             *  a string to this property as it's automatically casted so this is not a breaking change. The advantage of this special
             *  Location class is that you can now set it directly to an instance of PhysicalLocation or AmazonS3Location (more will
             *  be available in the future) classes. For instance this line:
             *
             *  rootFolder.Location = "Type=AmazonS3; Bucket Name=mybucket";
             *
             *  is same as this line:
             *
             *  rootFolder.Location = new AmazonS3Location { BucketName = "mybucket" };
             *
             *  This means you don't need to bother with formatting location strings correctly (eg. guessing property names)
             *  Except in aspx markup, you will still need to use strings which look like connection strings if you need to set
             *  advanced properties. Also note that this line:
             *
             *  rootFolder.Location = "c:\some\folder";
             *
             *  is same as this line:
             *
             *  rootFolder.Location = "Type=Physical; Path=c:\some\folder";
             *
             *  and also same as this line:
             *
             *  rootFolder.Location = new PhysicalLocation { Path = "c:\some\folder" };
             *
             *  So as in previous versions, setting location to a path string directly means it's a physical location by default.
             */
            rootFolder.Location = "~/App_Data/RootFolder1";

            fileManager.RootFolders.Add(rootFolder);
            var accessControl = new FileManagerAccessControl();

            accessControl.Path = @"\";
            accessControl.AllowedPermissions = FileManagerPermissions.Full;
            rootFolder.AccessControls.Add(accessControl);

            //Create another root folder. This time use object initializers (See CreateRootFolder2 method body).
            fileManager.RootFolders.Add(CreateRootFolder2());

            //Create the final root folder and add it to the control
            fileManager.RootFolders.Add(CreateRootFolder3());

            var context          = Hosting.GetHttpContext();
            var selectedLanguage = context.Request["languageSelector"];

            if (selectedLanguage != null)
            {
                fileManager.DisplayLanguage = selectedLanguage;
            }

            PopulateLanguageSelector(selectedLanguage);

            return(View(fileManager));
        }
        private static void SaveEventInfo(Dictionary <string, object> eventInfo)
        {
            var resultText = new StringBuilder();

            foreach (var kvp in eventInfo)
            {
                resultText.Append(kvp.Key);
                resultText.Append(": \n");

                var enumerable = kvp.Value as IEnumerable;
                if (enumerable is string)
                {
                    enumerable = null;
                }
                if (enumerable != null)
                {
                    foreach (var item in enumerable)
                    {
                        var subDictionary = item as Dictionary <string, object>;
                        if (subDictionary != null)
                        {
                            foreach (var subKvp in subDictionary)
                            {
                                resultText.Append("\t");
                                resultText.Append(subKvp.Key);
                                resultText.Append(": ");
                                resultText.Append(subKvp.Value);
                                resultText.Append("\n");
                            }
                        }
                        else
                        {
                            resultText.Append("\t");
                            resultText.Append(item);
                        }
                        resultText.Append("\n");
                    }
                }
                else
                {
                    resultText.Append("\t");
                    resultText.Append(kvp.Value);
                    resultText.Append("\n");
                }
            }

            var context  = Hosting.GetHttpContext();
            var eventLog = context.Session.Get <Stack <string> >(EventLogSessionKey);

            if (eventLog == null)
            {
                eventLog = new Stack <string>();
            }
            if (eventLog.Count > 50)
            {
                eventLog.Clear();
            }

            eventLog.Push(resultText.ToString());
            context.Session.Set(EventLogSessionKey, eventLog);
        }