private void SerializeActivity(Activity rootActivity, Guid id) { if (!ActivityIsSerializable(rootActivity)) { Log.LogVerbose(LogTitle, $"The workflow does not support persiting. Id = {id}, Type = {rootActivity.GetType()}"); return; } string filename = GetFileName(id); IFormatter formatter = new BinaryFormatter(); formatter.SurrogateSelector = ActivitySurrogateSelector.Default; using (var stream = new C1FileStream(filename, FileMode.OpenOrCreate)) { try { rootActivity.Save(stream, formatter); stream.Close(); } catch (SerializationException ex) { Log.LogError(LogTitle, ex); } } // Log.LogVerbose(LogTitle, $"Workflow persisted. Id = {id}, Type = {rootActivity.GetType()}"); }
private object DeserializeActivity(Activity rootActivity, Guid id) { string filename = GetFileName(id); object result; IFormatter formatter = new BinaryFormatter(); formatter.SurrogateSelector = ActivitySurrogateSelector.Default; using (C1FileStream stream = new C1FileStream(filename, FileMode.Open)) { result = Activity.Load(stream, rootActivity, formatter); stream.Close(); } // Log.LogVerbose(LogTitle, $"Workflow loaded. Id = {id}, Type = {result.GetType()}"); return(result); }
private object DeserializeActivity(Activity rootActivity, Guid id) { string filename = GetFileName(id); object result; IFormatter formatter = new BinaryFormatter(); formatter.SurrogateSelector = ActivitySurrogateSelector.Default; using (C1FileStream stream = new C1FileStream(filename, FileMode.Open)) { result = Activity.Load(stream, rootActivity, formatter); stream.Close(); } // LoggingService.LogVerbose("FileWorkFlowPersisetenceService", string.Format("Workflow loaded. Id = {0}, Type = {1}", id, result.GetType())); return(result); }
private void SerializeActivity(Activity rootActivity, Guid id) { if (!ActivityIsSerializable(rootActivity)) { LoggingService.LogVerbose("FileWorkFlowPersisetenceService", string.Format("The workflow does not support persiting. Id = {0}, Type = {1}", id, rootActivity.GetType())); return; } string filename = GetFileName(id); IFormatter formatter = new BinaryFormatter(); formatter.SurrogateSelector = ActivitySurrogateSelector.Default; using (C1FileStream stream = new C1FileStream(filename, FileMode.OpenOrCreate)) { rootActivity.Save(stream, formatter); stream.Close(); } // LoggingService.LogVerbose("FileWorkFlowPersisetenceService", string.Format("Workflow persisted. Id = {0}, Type = {1}", id, rootActivity.GetType())); }