void UploadScreenshot(CAttachedFile jpgFile) { // fname should be in form JPG_ServerID_CustomerID_CharID_6497d172.jpg string[] parts = jpgFile.FileName.Split('_'); int ServerID = Convert.ToInt32(parts[1]); int CustomerID = Convert.ToInt32(parts[2]); int CharID = Convert.ToInt32(parts[3]); // create directory based on customer id string dir = string.Format("{0}\\{1}", PICTURES_DIR, CustomerID); System.IO.Directory.CreateDirectory(dir); // save jpg there string fname = string.Format("{0}\\{1}_{2}_{3}_{4}-{5:00}{6:00}-{7:00}{8:00}.jpg", dir, CustomerID, CharID, ServerID, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute); FileStream fs = new FileStream(fname, System.IO.FileMode.Create, System.IO.FileAccess.Write); fs.Write(jpgFile.data, 0, jpgFile.data.Length); fs.Close(); }
protected override void Execute() { string skey1 = web.Param("skey1"); if (skey1 != SERVER_API_KEY) { throw new ApiExitException("bad key"); } CAttachedFile lfile = new CAttachedFile(this, "log", true); CAttachedFile dfile = new CAttachedFile(this, "dmp", true); CAttachedFile jfile = new CAttachedFile(this, "jpg", false); if (lfile.IsValid() && dfile.IsValid()) { UploadDump(lfile, dfile); } if (jfile.IsValid()) { UploadScreenshot(jfile); } else if (!lfile.IsValid()) { // no log uploading yet throw new ApiExitException("no log/dump files"); } Response.Write("WO_0"); }
void UploadDump(CAttachedFile logFile, CAttachedFile dumpFile) { // save log there string fname = string.Format("{0}\\{1}", CRASH_DIR, logFile.FileName); FileStream fs = new FileStream(fname, System.IO.FileMode.Create, System.IO.FileAccess.Write); fs.Write(logFile.data, 0, logFile.data.Length); fs.Close(); // save dump there fname = string.Format("{0}\\{1}", CRASH_DIR, dumpFile.FileName); fs = new FileStream(fname, System.IO.FileMode.Create, System.IO.FileAccess.Write); fs.Write(dumpFile.data, 0, dumpFile.data.Length); fs.Close(); }