Monday, March 11, 2013

EnScript - ExportClass

I can search for something through
File Name,
Size,
Hash,
Full Path
.....

and then export CSV or something

##################################### CODE #####################################
class ExportDialogClass: DialogClass {
  PathEditClass SaveHere;

  ExportDialogClass(DialogClass parent, String &savePath) :
    DialogClass(parent, "ExportClass Example"),
    SaveHere  (this, "Location To save the CSV File", START, START, 200, DEFAULT, 0, savePath,  PathEditClass::REQUIRED | PathEditClass::FILECREATE)
  {
  }
}

class MainClass {
  ExportClass Export;


  MainClass() :
    Export(null, "File Name,MD5 Hash,Created Time,Written Time,Accessed Time,Entry Modified Time,Full Path,", 0)
  {
  }

  void Main(CaseClass c) {
    DateClass date();
    SystemClass::ClearConsole();
    SearchClass search();

    String savePath = "C:\\Exported_Report.CSV";

    date.Now();
    String Start = date.GetString();

    ExportDialogClass dialog(null, savePath);

    if (dialog.Execute() == SystemClass::OK) {
      LocalFileClass exportedReport();
      exportedReport.Open(savePath, FileClass::WRITE);
      Export.Open(exportedReport, ExportClass::TEXT);

      ItemIteratorClass it(c, 0, ItemIteratorClass::CURRENTVIEW_SELECTED);

      while( EntryClass entry = it.GetNextEntry()) {
       if (entry.Name() == "cmd.exe") {
        DateClass date();
        DateClass C = entry.Created();
        String created = C.Year() + "/" + C.Month() + "/" + C.Day() + " " + C.Hour() + ":" + C.Minute() + ":" + C.Second();
        DateClass W = entry.Written();
        String written = W.Year() + "/" + W.Month() + "/" + W.Day() + " " + W.Hour() + ":" + W.Minute() + ":" + W.Second();
        DateClass A = entry.Accessed();
        String accessed = A.Year() + "/" + A.Month() + "/" + A.Day() + " " + A.Hour() + ":" + A.Minute() + ":" + A.Second();
        DateClass M = entry.Modified();
        String modified = M.Year() + "/" + M.Month() + "/" + M.Day() + " " + M.Hour() + ":" + M.Minute() + ":" + M.Second();

        HashClass hash = search.ComputeHash(entry);
        Export.Write(entry.Name() + "," + hash + "," + created + " ," + written + " ," + accessed + " ," + modified + " ," + entry.ItemPath() + ",\n");
        }
      }
     Export.Close();

     date.Now();
     String Ended = date.GetString();
     Console.WriteLine("Exported report created at " + savePath + "\n\n" +
    "Start Time : " + Start + "\n" +
    "End   Time : " + Ended);
    }
  }
}




#################################### CONSOLE ####################################


Exported report created at C:\Exported_Report.CSV

Start Time : 03/11/13 09:54:00오전
End   Time : 03/11/13 09:55:07오전



##################################### DIAL LOG ####################################






###################################### Result #####################################