protected void Page_Load(object sender, EventArgs e) { string strDocId = Request.QueryString["DocId"]; string strStatus = DBStore.GetDocStatus(strDocId); Response.Clear(); Response.Write(strStatus); }
protected void Page_Load(object sender, EventArgs e) { string strDocId = Request.QueryString["DocId"]; string strActionType = Request.QueryString["AT"]; DBStore.UpdateDocStatus(strDocId, strActionType, "TempForm.Page_Load"); Response.Clear(); Response.Write("OK"); }
public void ProcessRequest(HttpContext context) { string strDocId = context.Request["DocId"]; DBStore.UpdateDocStatus(strDocId, "", "WebEditor.ProcessRequest: " + context.Request["type"] + " : " + context.Request.UserHostName); switch (context.Request["type"]) { case "track": Track(context); break; } }
public static DocInfo CreateNewDoc(string strDocName) { DocInfo objDoc = new DocInfo() { DocId = Guid.NewGuid().ToString(), DocName = strDocName, Status = "CREATED" }; lsDocs.Add(objDoc); DBStore.AddStatus(objDoc.DocId, "CREATED", "New Document Created."); return(objDoc); }
public static string GetDocLogs() { StringBuilder sb = new StringBuilder(); sb.Append("<div style='font-family:monospace;'><OL>"); foreach (DocInfo objDI in lsDocs) { sb.AppendFormat("<LI>{0} :: {1} :: {2}<BR>", objDI.DocId, objDI.DocName, objDI.Status); sb.AppendFormat("{0}</LI>", DBStore.GetDocStatusLogs(objDI.DocId)); } sb.Append("</OL></DIV>"); return(sb.ToString()); }
protected static List <DocInfo> GetStoredFiles() { if (DBStore.GetDocList().Count <= 0) { var directory = HttpRuntime.AppDomainAppPath + WebConfigurationManager.AppSettings["storage-path"]; var directoryInfo = new DirectoryInfo(directory); List <string> storedFiles = directoryInfo.GetFiles("*.*", SearchOption.TopDirectoryOnly).Select(fileInfo => fileInfo.Name).ToList(); for (int idx = 0; idx < storedFiles.Count; idx++) { DBStore.CreateNewDoc(storedFiles[idx]); } } return(DBStore.GetDocList()); }
public static void UpdateDocStatus(string strDocId, string strStatus, string strMessage) { foreach (DocInfo objDI in lsDocs) { if (objDI.DocId == strDocId) { if (strStatus == "") { strStatus = objDI.Status; } objDI.Status = strStatus; DBStore.AddStatus(strDocId, strStatus, strMessage); } } }
protected void Page_Load(object sender, EventArgs e) { string strDocId = Request.QueryString["DocId"]; string strFileName = DBStore.GetDocName(strDocId); string strPhysicalPath = Server.MapPath("~/Files/") + strFileName; DBStore.UpdateDocStatus(strDocId, "EDIT_INPROGRESS", "FileHandler.Page_Load: Document " + strFileName + ", sent to OO"); using (FileStream fs = new FileStream(strPhysicalPath, FileMode.Open, FileAccess.Read)) { byte[] buffer = new byte[4096]; int count = 0; while ((count = fs.Read(buffer, 0, buffer.Length)) > 0) { Response.ContentType = MimeMapping.GetMimeMapping(strPhysicalPath); Response.OutputStream.Write(buffer, 0, count); Response.Flush(); } } }
protected void Page_Load(object sender, EventArgs e) { DocId = Request["DocId"]; FileName = DBStore.GetDocName(DocId); RM = Request["RM"].ToLower(); }
protected void Page_Load(object sender, EventArgs e) { Response.Write(DBStore.GetDocLogs()); }
private static void Track(HttpContext context) { string strDocId = context.Request["DocId"]; string strFileName = DBStore.GetDocName(strDocId); string strBody = ""; string strStatus = "0"; try { using (var receiveStream = context.Request.InputStream) { using (var readStream = new StreamReader(receiveStream)) { strBody = readStream.ReadToEnd(); } } DBStore.AddStatus(strDocId, "WebEditor.Track", strBody); } catch (Exception e) { throw new HttpException((int)HttpStatusCode.BadRequest, e.Message); } if (string.IsNullOrEmpty(strBody)) { return; } JavaScriptSerializer jss = new JavaScriptSerializer(); Dictionary <string, object> dicResponse = jss.Deserialize <Dictionary <string, object> >(strBody); string strDocKey = ""; int intStatusVal = 0; TrackerStatus enumStatus = TrackerStatus.NotFound; string strFileDownloadUrl = ""; string strUser = ""; if (dicResponse.ContainsKey("key")) { strDocKey = dicResponse["key"].ToString(); } if (dicResponse.ContainsKey("status")) { intStatusVal = Convert.ToInt32(dicResponse["status"]); enumStatus = (TrackerStatus)intStatusVal; } if (dicResponse.ContainsKey("url")) { strFileDownloadUrl = dicResponse["url"].ToString(); } if (dicResponse.ContainsKey("users")) { strUser = (dicResponse["users"] as ArrayList)[0].ToString(); } DBStore.UpdateDocStatus(strDocId, "", "WebEditor.Track: " + enumStatus + " : " + intStatusVal.ToString()); DBStore.AddStatus(strDocId, "strDocKey", strDocKey); DBStore.AddStatus(strDocId, "strUser", strUser); DBStore.AddStatus(strDocId, "strFileDownloadUrl", strFileDownloadUrl); switch (enumStatus) { case TrackerStatus.MustSave: HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strFileDownloadUrl); try { var storagePath = Sample.StoragePath(strFileName); if (DBStore.GetDocStatus(strDocId) == "OkClicked" || DBStore.GetDocStatus(strDocId) == "EDITOR_CLOSED") { //--- This is the document stream sent from Document Service using (var stream = req.GetResponse().GetResponseStream()) { if (stream == null) { throw new Exception("stream is null"); } const int bufferSize = 4096; using (var fs = File.Open(storagePath, FileMode.Create)) { var buffer = new byte[bufferSize]; int readed; while ((readed = stream.Read(buffer, 0, bufferSize)) != 0) { fs.Write(buffer, 0, readed); } } } DBStore.UpdateDocStatus(strDocId, enumStatus.ToString(), "WebEditor.Track: Saved Path: " + storagePath); DBStore.AddStatus(strDocId, "Command Service", "Start"); string strRes = ServiceConverter.GetCommandService("drop", strDocKey, "", (new List <string>() { strUser })); DBStore.AddStatus(strDocId, "Command Service", strRes); } else { DBStore.UpdateDocStatus(strDocId, enumStatus.ToString(), "WebEditor.Track: NOT SAVED"); } } catch (Exception ex) { DBStore.AddStatus(strDocId, "Exception", ex.ToString()); } break; case TrackerStatus.Corrupted: case TrackerStatus.ForceSave: case TrackerStatus.Closed: break; case TrackerStatus.Editing: //--- Check User and Key combination and set the status of document strStatus = "0"; break; } context.Response.Write("{\"error\":" + strStatus + "}"); }
protected void btnClearData_Click(object sender, EventArgs e) { DBStore.Clear(); Response.Redirect("Sample.aspx"); }