Example #1
0
        /// <summary>
        /// The page is loading.
        /// </summary>
        /// <param name="pageContext">The page content.</param>
        public override void OnLoad(HttpPageContext pageContext)
        {
            bool deleteFiles       = true;
            bool deleteDirectories = true;

            // Get the download file directory.
            string directoryQuery = "";

            if (base.Request.QueryString != null)
            {
                if (!string.IsNullOrEmpty(base.Request.QueryString["directory"]))
                {
                    directoryQuery = base.Request.QueryString["directory"];
                }

                // If the delete file query exists
                if (!String.IsNullOrEmpty(base.Request.QueryString["deletefile"]))
                {
                    // Get the file to delete path.
                    string fileNameToDelete = base.UploadDirectory + base.Request.QueryString["deletefile"].Replace("/", "\\");

                    // If the file exists then delete the file.
                    if (System.IO.File.Exists(fileNameToDelete))
                    {
                        System.IO.File.Delete(fileNameToDelete);
                    }
                }

                // If the delete directory query exists
                if (!String.IsNullOrEmpty(base.Request.QueryString["deletedirectory"]))
                {
                    // Get the directory to delete path.
                    string directoryToDelete = base.UploadDirectory + base.Request.QueryString["deletedirectory"].Replace("/", "\\").TrimStart('\\') + "\\";

                    // If the directory exists then delete the directory.
                    if (System.IO.Directory.Exists(directoryToDelete))
                    {
                        System.IO.Directory.Delete(directoryToDelete, true);
                    }
                }
            }

            // Get the file system html.
            base.AlternativeContent = HttpResponseContent.UploadFileList(base.Response, base.UploadDirectory,
                                                                         System.IO.Path.GetFileName(base.UrlFilePath), directoryQuery, deleteFiles, deleteDirectories);
        }
Example #2
0
 /// <summary>
 /// The pre-process event.
 /// </summary>
 /// <param name="pageContext">The page content.</param>
 public override void OnPreProcess(HttpPageContext pageContext)
 {
 }
Example #3
0
 /// <summary>
 /// The page is loading.
 /// </summary>
 /// <param name="pageContext">The page content.</param>
 public override void OnLoad(HttpPageContext pageContext)
 {
 }
Example #4
0
 /// <summary>
 /// The page is initialised.
 /// </summary>
 /// <param name="pageContext">The page content.</param>
 public override void OnInit(HttpPageContext pageContext)
 {
 }
Example #5
0
 /// <summary>
 /// The pre-process event.
 /// </summary>
 /// <param name="pageContext">The page content.</param>
 public override void OnPreProcess(HttpPageContext pageContext)
 {
     // Get the download file directory.
     base.UploadDirectory          = Helper.BaseDownloadPath().TrimEnd('\\') + "\\";
     pageContext.ProcessOnPostBack = false;
 }
Example #6
0
        /// <summary>
        /// The page is loading.
        /// </summary>
        /// <param name="pageContext">The page content.</param>
        public override void OnLoad(HttpPageContext pageContext)
        {
            try
            {
                string notesHtmlData = "";

                // Get the response data.
                Data.NotesFormService.notes noteHtml = new Data.NotesFormService.notes();

                // If post back
                if (base.IsPostBack)
                {
                    // If form data exists then
                    // wrire ti the file.
                    if (base.Form != null)
                    {
                        if (base.Form.Count > 0)
                        {
                            StreamWriter streamWriter = null;
                            try
                            {
                                // Get the 'NoteName' key name from the form.
                                string notename = base.Form.AllKeys.Where(u => u.ToLower() == "notename".ToLower()).First();

                                // Save path.
                                string savePath = base.UploadDirectory + "Notes\\" + base.Form[notename] + ".txt";

                                // If the directory does not exist
                                // then create the directory.
                                if (!Directory.Exists(Path.GetDirectoryName(savePath)))
                                {
                                    Directory.CreateDirectory(Path.GetDirectoryName(savePath));
                                }

                                // Create a new file or over write extisting file.
                                using (streamWriter = System.IO.File.CreateText(savePath))
                                {
                                    for (int i = 0; i < base.Form.Count; i++)
                                    {
                                        // Write the line of data.
                                        streamWriter.WriteLine(base.Form.Keys[i] + " : " + base.Form.Get(i));
                                    }

                                    // Close the stream.
                                    streamWriter.Flush();
                                    streamWriter.Close();
                                }
                            }
                            catch (Exception fex)
                            {
                                LogHandler.WriteTypeMessage(
                                    fex.Message,
                                    MethodInfo.GetCurrentMethod(),
                                    Helper.EventApplicationName());
                            }
                            finally
                            {
                                if (streamWriter != null)
                                {
                                    streamWriter.Close();
                                }
                            }

                            // Get the response data.
                            notesHtmlData = noteHtml.TransformText().
                                            Replace("value=\"NoteName\"", "value=\"" + base.Form.Get("NoteName") + "\"").
                                            Replace("value=\"01/01/01\"", "value=\"" + base.Form.Get("NoteDate") + "\"").
                                            Replace("value=\"ContextName\"", "value=\"" + base.Form.Get("ContextName") + "\"").
                                            Replace("value=\"NoteData\"", base.Form.Get("NoteData"));
                        }
                    }
                }
                else
                {
                    // Get the response data.
                    notesHtmlData = noteHtml.TransformText().
                                    Replace("value=\"NoteName\"", "").
                                    Replace("value=\"01/01/01\"", "").
                                    Replace("value=\"ContextName\"", "").
                                    Replace("value=\"NoteData\"", "");
                }

                // Send the new content.
                base.AlternativeContent = Encoding.UTF8.GetBytes(notesHtmlData);
            }
            catch (Exception ex)
            {
                LogHandler.WriteTypeMessage(
                    ex.Message,
                    MethodInfo.GetCurrentMethod(),
                    Helper.EventApplicationName());
            }
        }