/// <summary> /// Save file to HardDrive /// TODO: Set Timer to remove file after 20 minutes /// </summary> /// <param name="path">Full path to store file</param> /// <param name="data">File data</param> public ServerFile storeFileOnServer(byte[] data, string originalName) { ServerFile sf = new ServerFile(originalName, Guid.NewGuid().ToString()); System.IO.File.WriteAllBytes(Path.Combine(UploadPath, sf.ServerName), data); addFileToTimeoutQueue(sf); return(sf); }
public ComparisonResult() { File = string.Empty; Redline = new ServerFile(); RedlineMl = new ServerFile(); Summary = new ServerFile(); Error = string.Empty; }
public ServerFile storeFileOnServer(string data, string originalName) { ServerFile sf = new ServerFile(originalName, Guid.NewGuid().ToString()); FileInfo file = new FileInfo(Path.Combine(UploadPath, sf.ServerName)); if (file.Exists) { file.Delete(); } //xml has utf-16 encoding declared, so we need to save it as utf-16 using (System.IO.StreamWriter sw = new StreamWriter(file.FullName, false, System.Text.Encoding.Unicode)) { sw.Write(data); } addFileToTimeoutQueue(sf); return(sf); }
private void checkTimeOutFiles() { try { lock (Lock) { for (int i = TimeoutQueue.Count - 1; i >= 0; i--) { ServerFile sf = TimeoutQueue[i]; if (sf.ExpireTime < DateTime.Now) { File.Delete(Path.Combine(UploadPath, sf.ServerName)); TimeoutQueue.Remove(sf); } } } } catch (Exception ex) { Log.Write(TraceEventType.Error, "{0}", ex); } }
private void addFileToTimeoutQueue(ServerFile sf) { TimeoutQueue.Add(sf); }