public CopyFromSaveDebugTO ( |
||
that | ||
Результат | void |
/// <summary> /// Boot strap the Session /// </summary> private void InitPersistSettings() { lock (SettingsLock) { if (!_debugOptsEndPoint.PathExist(_debugPath)) { var args = new Dev2PutRawOperationTO(WriteType.Overwrite, ""); ActivityIOFactory.CreateOperationsBroker().PutRaw(_debugOptsEndPoint, args); } else { // fetch from disk var filesToCleanup = new List <string>(); using (Stream s = _debugOptsEndPoint.Get(_debugPath, filesToCleanup)) { if (s.Length > 0) { var bf = new XmlSerializer(typeof(List <SaveDebugTO>)); try { var settings = (List <SaveDebugTO>)bf.Deserialize(s); _debugPersistSettings.Values.ToList().ForEach(a => a.CleanUp()); _debugPersistSettings.Clear(); // now push back into the Dictionary foreach (SaveDebugTO dto in settings) { if (dto.ServiceName.Length > 0) { var tmp = new DebugTO(); tmp.CopyFromSaveDebugTO(dto); string error; tmp.BinaryDataList = DeSerialize(tmp.XmlData, tmp.DataList, enTranslationTypes.XML, out error); _debugPersistSettings[dto.WorkflowID] = tmp; } } } catch (Exception e) { Dev2Logger.Log.Error(e); } } else { Dev2Logger.Log.Error("No debug data stream [ " + _debugPath + " ] "); } s.Close(); s.Dispose(); filesToCleanup.ForEach(File.Delete); } } } }
void PersistSettings(SaveDebugTO workflow) { if (!string.IsNullOrEmpty(workflow?.ServiceName)) { var tmp = new DebugTO(); tmp.CopyFromSaveDebugTO(workflow); _debugPersistSettings[workflow.WorkflowID] = tmp; } }
void PersistSettings(List <SaveDebugTO> settings) { foreach (SaveDebugTO dto in settings) { if (!string.IsNullOrEmpty(dto.ServiceName)) { var tmp = new DebugTO(); tmp.CopyFromSaveDebugTO(dto); _debugPersistSettings[dto.WorkflowID] = tmp; } } }
public void DebugTO_CopyFrom_ValuesCorrect() { DebugTO to = new DebugTO(); string rootFolder = Path.GetTempPath() + Guid.NewGuid(); to.RememberInputs = true; to.BaseSaveDirectory = rootFolder; to.DataList = "<DataList><scalar1 ColumnIODirection=\"Input\"/><persistantscalar ColumnIODirection=\"Input\"/><rs><f1 ColumnIODirection=\"Input\"/><f2 ColumnIODirection=\"Input\"/></rs><recset><field1/><field2/></recset></DataList>"; to.XmlData = "<DataList><scalar1>s1</scalar1><persistantscalar>SomeValue</persistantscalar><rs><f1>f1Value</f1><f2>f2Value</f2></rs><recset><field1>somedata</field1><field2>moredata</field2></recset><recset><field1></field1><field2></field2></recset></DataList>"; to.ServiceName = "DummyService"; to.WorkflowID = "DummyService"; var save = to.CopyToSaveDebugTO(); save.DataList = "bob"; save.WorkflowID = "dave"; save.IsDebugMode = false; to.CopyFromSaveDebugTO(save); Assert.AreEqual(to.WorkflowID,"dave"); Assert.AreEqual(to.IsDebugMode,false); Assert.AreEqual(to.DataList,"bob"); }
/// <summary> /// Boot strap the Session /// </summary> private void InitPersistSettings() { lock (SettingsLock) { if (!_debugOptsEndPoint.PathExist(_debugPath)) { var args = new Dev2PutRawOperationTO(WriteType.Overwrite, ""); ActivityIOFactory.CreateOperationsBroker().PutRaw(_debugOptsEndPoint, args); } else { // fetch from disk var filesToCleanup = new List<string>(); using (Stream s = _debugOptsEndPoint.Get(_debugPath, filesToCleanup)) { if (s.Length > 0) { var bf = new XmlSerializer(typeof (List<SaveDebugTO>)); try { var settings = (List<SaveDebugTO>) bf.Deserialize(s); _debugPersistSettings.Values.ToList().ForEach(a=>a.CleanUp()); _debugPersistSettings.Clear(); // now push back into the Dictionary foreach (SaveDebugTO dto in settings) { if (dto.ServiceName.Length > 0) { var tmp = new DebugTO(); tmp.CopyFromSaveDebugTO(dto); _debugPersistSettings[dto.WorkflowID] = tmp; } } } catch (Exception e) { Dev2Logger.Log.Error(e); } } else { Dev2Logger.Log.Error("No debug data stream [ " + _debugPath + " ] "); } s.Close(); s.Dispose(); filesToCleanup.ForEach(File.Delete); } } } }