/// <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); } } } }
public void Dev2PutRawOperation_Constructor_TakesContentsAndWriteTypeEnum() { //------------Setup for test-------------------------- const WriteType WriteType = WriteType.AppendBottom; const string Contents = "Some test"; //------------Execute Test--------------------------- var dev2PutRawOperation = new Dev2PutRawOperationTO(WriteType, Contents); //------------Assert Results------------------------- Assert.IsNotNull(dev2PutRawOperation); }
public void Dev2PutRawOperationTO_Constructor_GivenParameter_ShouldSetProperties() { //------------Setup for test-------------------------- const WriteType WriteType = WriteType.AppendBottom; const string Contents = "Some test"; //------------Execute Test--------------------------- var dev2PutRawOperation = new Dev2PutRawOperationTO(WriteType, Contents); //------------Assert Results------------------------- Assert.AreEqual(WriteType, dev2PutRawOperation.WriteType); Assert.AreEqual(Contents, dev2PutRawOperation.FileContents); }
void InitPersistSettings(DebugTO to) { if (!_debugOptsEndPoint.PathExist(_debugPath)) { var args = new Dev2PutRawOperationTO(WriteType.Overwrite, ""); ActivityIOFactory.CreateOperationsBroker().PutRaw(_debugOptsEndPoint, args); } else { FetchFromDisk(to); } }
protected override IList <OutputTO> ExecuteConcreteAction(IDSFDataObject dataObject, out ErrorResultTO allErrors, int update) { IList <OutputTO> outputs = new List <OutputTO>(); allErrors = new ErrorResultTO(); var colItr = new WarewolfListIterator(); //get all the possible paths for all the string variables var inputItr = new WarewolfIterator(dataObject.Environment.Eval(OutputPath, update)); colItr.AddVariableToIterateOn(inputItr); var unameItr = new WarewolfIterator(dataObject.Environment.Eval(Username, update)); colItr.AddVariableToIterateOn(unameItr); var passItr = new WarewolfIterator(dataObject.Environment.Eval(DecryptedPassword, update)); colItr.AddVariableToIterateOn(passItr); var privateKeyItr = new WarewolfIterator(dataObject.Environment.Eval(PrivateKeyFile, update)); colItr.AddVariableToIterateOn(privateKeyItr); var contentItr = new WarewolfIterator(dataObject.Environment.Eval(FileContents, update)); colItr.AddVariableToIterateOn(contentItr); outputs.Add(DataListFactory.CreateOutputTO(Result)); if (dataObject.IsDebugMode()) { AddDebugInputItem(OutputPath, "Output Path", dataObject.Environment, update); AddDebugInputItem(new DebugItemStaticDataParams(GetMethod(), "Method")); AddDebugInputItemUserNamePassword(dataObject.Environment, update); if (!string.IsNullOrEmpty(PrivateKeyFile)) { AddDebugInputItem(PrivateKeyFile, "Private Key File", dataObject.Environment, update); } AddDebugInputItem(FileContents, "File Contents", dataObject.Environment, update); } while (colItr.HasMoreData()) { IActivityOperationsBroker broker = ActivityIOFactory.CreateOperationsBroker(); var writeType = GetCorrectWriteType(); Dev2PutRawOperationTO putTo = ActivityIOFactory.CreatePutRawOperationTO(writeType, TextUtils.ReplaceWorkflowNewLinesWithEnvironmentNewLines(colItr.FetchNextValue(contentItr))); IActivityIOPath opath = ActivityIOFactory.CreatePathFromString(colItr.FetchNextValue(inputItr), colItr.FetchNextValue(unameItr), colItr.FetchNextValue(passItr), true, colItr.FetchNextValue(privateKeyItr)); IActivityIOOperationsEndPoint endPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(opath); try { if (allErrors.HasErrors()) { outputs[0].OutputStrings.Add(null); } else { string result = broker.PutRaw(endPoint, putTo); outputs[0].OutputStrings.Add(result); } } catch (Exception e) { outputs[0].OutputStrings.Add(null); allErrors.AddError(e.Message); break; } } return(outputs); }
public string PutRaw(IActivityIOOperationsEndPoint dst, Dev2PutRawOperationTO args) { Destination = dst; Dev2PutRawOperationTo = args; return("Successful"); }
protected override IList <OutputTO> ExecuteConcreteAction(NativeActivityContext context, out ErrorResultTO allErrors) { IList <OutputTO> outputs = new List <OutputTO>(); IDSFDataObject dataObject = context.GetExtension <IDSFDataObject>(); IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(); allErrors = new ErrorResultTO(); ErrorResultTO errors; Guid executionId = dataObject.DataListID; IDev2IteratorCollection colItr = Dev2ValueObjectFactory.CreateIteratorCollection(); //get all the possible paths for all the string variables IBinaryDataListEntry inputPathEntry = compiler.Evaluate(executionId, enActionType.User, OutputPath, false, out errors); allErrors.MergeErrors(errors); IDev2DataListEvaluateIterator inputItr = Dev2ValueObjectFactory.CreateEvaluateIterator(inputPathEntry); colItr.AddIterator(inputItr); IBinaryDataListEntry usernameEntry = compiler.Evaluate(executionId, enActionType.User, Username, false, out errors); allErrors.MergeErrors(errors); IDev2DataListEvaluateIterator unameItr = Dev2ValueObjectFactory.CreateEvaluateIterator(usernameEntry); colItr.AddIterator(unameItr); IBinaryDataListEntry passwordEntry = compiler.Evaluate(executionId, enActionType.User, Password, false, out errors); allErrors.MergeErrors(errors); IDev2DataListEvaluateIterator passItr = Dev2ValueObjectFactory.CreateEvaluateIterator(passwordEntry); colItr.AddIterator(passItr); IBinaryDataListEntry contentsEntry = compiler.Evaluate(executionId, enActionType.User, FileContents, false, out errors); if (contentsEntry == null) { errors.AddError("Contents could not be evaluated"); } allErrors.MergeErrors(errors); IDev2DataListEvaluateIterator contentItr = Dev2ValueObjectFactory.CreateEvaluateIterator(contentsEntry); colItr.AddIterator(contentItr); outputs.Add(DataListFactory.CreateOutputTO(Result)); if (dataObject.IsDebugMode()) { AddDebugInputItem(OutputPath, "Output Path", inputPathEntry, executionId); AddDebugInputItem(new DebugItemStaticDataParams(GetMethod(), "Method")); AddDebugInputItemUserNamePassword(executionId, usernameEntry); AddDebugInputItem(FileContents, "File Contents", contentsEntry, executionId); } while (colItr.HasMoreData()) { IActivityOperationsBroker broker = ActivityIOFactory.CreateOperationsBroker(); var writeType = GetCorrectWriteType(); Dev2PutRawOperationTO putTo = ActivityIOFactory.CreatePutRawOperationTO(writeType, TextUtils.ReplaceWorkflowNewLinesWithEnvironmentNewLines(colItr.FetchNextRow(contentItr).TheValue)); IActivityIOPath opath = ActivityIOFactory.CreatePathFromString(colItr.FetchNextRow(inputItr).TheValue, colItr.FetchNextRow(unameItr).TheValue, colItr.FetchNextRow(passItr).TheValue, true); IActivityIOOperationsEndPoint endPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(opath); try { if (allErrors.HasErrors()) { outputs[0].OutputStrings.Add(null); } else { string result = broker.PutRaw(endPoint, putTo); outputs[0].OutputStrings.Add(result); } } catch (Exception e) { outputs[0].OutputStrings.Add(null); allErrors.AddError(e.Message); break; } } return(outputs); }