Example #1
0
 public ActionResult Aflever(Filehandler file)
 {
     if (file.file.ContentLength > 0)
     {
         string filename = Path.GetFileName(file.file.FileName);
         string path     = Path.Combine(Server.MapPath("~/Files"), filename);
         file.file.SaveAs(path);
     }
     return(RedirectToAction("Index", "News"));
 }
        public void CreateGraph()
        {
            /// DATA
            /// 0: Open file
            /// 1: Define type
            /// 2: Interprete data
            /// CHART
            /// 3: Import data to chart
            /// 4: Configure chart
            /// EXPORT TO FILE
            /// 5: Chart export
            /// FINISH
            /// 6: Cleanup files
            /// 7: Write log
            ///

            Filehandler filehandler = new Filehandler();

            try
            {
                // 0: Open file
                string[] filetext = filehandler.OpenFile(originalFile);

                // 1-2: Interprete data
                DataInterpreter dataInterpreter = new DataInterpreter();
                dataset = DataInterpreter.Interprete(filetext);

                // 3: Import data to chart
                chart = dataset.CreateChart();

                // 5: Chart export
                string newfile = Path.GetDirectoryName(originalFile);
                newfile += dataset.NewFilepath;
                filehandler.CreatePath(newfile);
                newfile += dataset.NewFileName;
                filehandler.saveChart(chart, newfile);
                filehandler.Archive(originalFile, newfile);
                lognote += " Processed OK: " + newfile;
            }
            catch (Exception e)
            {
                lognote += " " + e.Message + " -*- " + e.StackTrace;
            }
            finally
            {
                lognote += Environment.NewLine;
                DateTime dt      = DateTime.Now;
                string   logname = $"{dt.Year}-{dt.Month}-{dt.Day}.log";
                filehandler.Log(logname, lognote);
            }
        }
 public CharacterController()
 {
     filehandler = new Filehandler();
 }