Пример #1
0
        /// <summary>
        /// renders the complete plupload Module(UI) using custom settings given by configuration
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="html">the instance of the htmlhelper</param>
        /// <param name="configuration">custom instance settings. This configuration will be merged with the application and default configuration.
        /// fill only settings what are needed by the specific instance, all another settings will be used from application or default configuration.
        /// </param>
        /// <returns>the main view of the plupload modul inclusiv complete UI</returns>
        public static MvcHtmlString Plupload <T>(this HtmlHelper <T> html, PluploadConfiguration configuration)
        {
            LogWriter.Debug("create plupload...");
            PluploadContext.Instance.SetConfiguration(configuration);

            return(html.Action("Index", "Plupload"));
        }
Пример #2
0
        /// <summary>
        /// writes a message using specific loglevel
        /// </summary>
        /// <param name="loglevel">a specific loglevel</param>
        /// <param name="message">text of the debug entry</param>
        private static void Write(LogLevel loglevel, string message)
        {
            PluploadConfiguration config = PluploadContext.GetConfiguration();
            string logPath = config.GetPhysicalLogPath();

            lock (lockThis)
            {
                if (!Directory.Exists(logPath))
                {
                    Directory.CreateDirectory(logPath);
                }

                string logFile = Path.Combine(logPath, "plupload.log");
                if (!File.Exists(logFile))
                {
                    using (FileStream fs = File.Create(logFile)) { }
                }

                using (StreamWriter sw = File.AppendText(logFile))
                {
                    sw.AutoFlush = true;
                    sw.WriteLine(String.Format("{0} | {1} | {2} #end#", DateTime.Now, loglevel, message));
                }
            }
        }
Пример #3
0
        /// <summary>
        /// gets the merged plupload configuration.
        /// There are many levels(default => application => instance),
        /// where you can configure the plupload.net.
        /// this instance of configuration is merged. You should always working
        /// with the merged configuration.
        /// </summary>
        public PluploadConfiguration GetConfiguration()
        {
            PluploadConfiguration config = HttpContext.Current.Session[PluploadConstants.REQUEST_CONFIGURATION] as PluploadConfiguration;

            if (config == null)
            {
                return(this.MergedConfiguration);
            }

            return(config);
        }
Пример #4
0
        /// <summary>
        /// sets the instancesspecific configuration.
        /// this configuration will be merged with the application and global configuration.
        /// the merged configuration will be stored to the current session.
        /// </summary>
        /// <param name="configuration"></param>
        public void SetConfiguration(PluploadConfiguration configuration)
        {
            LogWriter.Debug("merge configuration: " + configuration.ToJSON());

            if (configuration != null)
            {
                HttpContext.Current.Session[PluploadConstants.REQUEST_CONFIGURATION] = this.Merge(configuration);
            }

            LogWriter.Debug("the new merged configuration:" + PluploadContext.Instance.GetConfiguration().ToJSON());
        }
Пример #5
0
        /// <summary>
        /// renders the startup script, using plupload.startup.js.
        /// all placeholders within js template file will be resolved.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="html"></param>
        /// <param name="resPath"></param>
        /// <param name="onCompleteFunction"></param>
        /// <returns></returns>
        public static MvcHtmlString ScriptContent <T>(this HtmlHelper <T> html, string resPath, string onCompleteFunction)
        {
            string scriptContent = RessourceHelper.GetTextResource(PluploadConstants.JS_PLUPLOAD_STARTUP);

            PluploadConfiguration config = PluploadContext.Instance.GetConfiguration();

            scriptContent = scriptContent.Replace("[SCRIPT_URL]", resPath.GetAbsoluteWebPathForRessource()).
                            Replace("[ON_COMPLETE_FUNCTION]", onCompleteFunction).
                            Replace("[SCRIPT_JQUERY_URL]", config.JSjQuery.GetAbsoluteWebPath());

            return(new MvcHtmlString(scriptContent));

            //html.Action("EmbeddedTextRessource", "Ressource", new { textPath = resPath, contentType = "text/javascript" });
        }
Пример #6
0
 /// <summary>
 /// merges the configuration given by config witch the current merged configuration.
 /// </summary>
 /// <param name="config">the configuration to be merged</param>
 /// <returns>a merged result a new PluploadConfiguration instance</returns>
 private PluploadConfiguration Merge(PluploadConfiguration config)
 {
     return(this.MergedConfiguration.Merge(config));
 }