internal EditFieldForm(IServiceUI editor, ServiceAction action, Field field, ServiceEntity service) { InitializeComponent(); _action = action; _field = field; _service = service; _editor = editor; }
internal XmlElement GetXml(ServiceAction serviceAction) { XmlHelper h = new XmlHelper("<FieldList/>"); h.SetAttribute(".", "Name", this.Name); h.SetAttribute(".", "Source", this.Source); foreach (Field field in this.Fields) { h.AddElement(".", field.GetXml(serviceAction)); } return h.GetElement("."); }
private static void ExecuteServiceAction(ServiceController service, ServiceAction serviceAction) { var pricipal = new WindowsPrincipal(WindowsIdentity.GetCurrent()); var hasAdministrativeRight = pricipal.IsInRole(WindowsBuiltInRole.Administrator); if (hasAdministrativeRight) { switch (serviceAction) { case ServiceAction.Start: service.Start(); break; case ServiceAction.Stop: service.Stop(); break; case ServiceAction.Restart: service.Start(); service.Stop(); break; default: throw new ArgumentOutOfRangeException(string.Format("Unknown action {0}.", serviceAction)); } } else { string arguments; switch (serviceAction) { case ServiceAction.Start: arguments = "\"service start\""; break; case ServiceAction.Stop: arguments = "\"service stop\""; break; case ServiceAction.Restart: arguments = "\"service restart\""; break; default: throw new ArgumentOutOfRangeException(string.Format("Unknown action {0}.", serviceAction)); } var startInfo = new ProcessStartInfo { UseShellExecute = true, FileName = Assembly.GetExecutingAssembly().Location, Verb = "runas", Arguments = arguments, //start ? "\"service start\"" : "\"service stop\"", WindowStyle = ProcessWindowStyle.Hidden }; var p = Process.Start(startInfo); p.WaitForExit(); } }
public DynamicService CreateServiceEntry() { DynamicService newDs = new DynamicService(); newDs.Name = HandlesType(); newDs.DataListSpecification = "<DataList><Roles/><ResourceXml/><Dev2System.ManagmentServicePayload ColumnIODirection=\"Both\"></Dev2System.ManagmentServicePayload></DataList>"; ServiceAction sa = new ServiceAction(); sa.Name = HandlesType(); sa.ActionType = enActionType.InvokeManagementDynamicService; sa.SourceMethod = HandlesType(); newDs.Actions.Add(sa); return newDs; }
private ServiceEntity(string name, string targetTable, ServiceAction action) { this.Variables = new List<IVariable>(); this.Preprocesses = new List<Preprocess>(); this.Converters = new List<IConverter>(); this.FieldList = new FieldList(string.Empty, string.Empty); this.Action = action; this.Name = name; this.Enabled = true; if (!MainForm.CurrentUDT.ExistsInAllTables(targetTable)) throw new Exception("資料表不存在 : " + targetTable); string tableName = targetTable.StartsWith("$") ? targetTable.Substring(1) : targetTable; if (Action == ServiceAction.Select) { this.SQLTemplate = "SELECT @@FieldList FROM " + targetTable + " WHERE @@Condition @@Order"; this.ResponseRecordElement = "Response/" + StringUtil.ConvertToDisplayName(tableName); LoadFields(targetTable); LoadConditions(targetTable); LoadOrders(); LoadPagination(); } else if (Action == ServiceAction.Insert) { this.SQLTemplate = "INSERT INTO " + targetTable + " @@FieldList"; this.RequestRecordElement = StringUtil.ConvertToDisplayName(tableName); LoadFields(targetTable); } else if (Action == ServiceAction.Update) { this.SQLTemplate = "UPDATE " + targetTable + " SET @@FieldList WHERE @@Condition"; this.RequestRecordElement = StringUtil.ConvertToDisplayName(tableName); LoadFields(targetTable); LoadConditions(targetTable); } else if (Action == ServiceAction.Delete) { this.SQLTemplate = "DELETE FROM " + targetTable + " WHERE @@Condition"; this.RequestRecordElement = StringUtil.ConvertToDisplayName(tableName); LoadConditions(targetTable); } }
public DatabaseServiceContainer(ServiceAction sa, IDSFDataObject dataObj, IWorkspace workspace, IEsbChannel esbChannel) : base(sa, dataObj, workspace, esbChannel) { _databaseServiceExecution = new DatabaseServiceExecution(dataObj); }
public ServiceEventArg(string serviceName, ServiceAction action, string targetTable) { this.ServiceName = serviceName; this.Action = action; this.TargetTable = targetTable; }
public string BuildPost(ServiceAction action, string xmlNamespace) { var stateString = string.Empty; foreach (var arg in action.ArgumentList) { if (arg.Direction == "out") continue; if (arg.Name == "InstanceID") stateString += BuildArgumentXml(arg, "0"); else stateString += BuildArgumentXml(arg, null); } return string.Format(CommandBase, action.Name, xmlNamespace, stateString); }
public static ServiceEntity CreateNew(string name, string targetTable, ServiceAction action) { if (action == ServiceAction.Set) return new SetServiceEntity(name, targetTable); else if (action == ServiceAction.Javascript) return new JSServiceEntity(name); return new ServiceEntity(name, targetTable, action); }
//public dynamic WorkflowApplication(ServiceAction action, dynamic xmlRequest, string dataList) public dynamic WorkflowApplication(ServiceAction action, IDSFDataObject dataObj, string dataList) { //var dataObject = new DsfDataObject(xmlRequest.XmlString); ErrorResultTO errors; Guid instanceId = Guid.Empty; Guid parentWorkflowInstanceId; Guid parentInstanceId = Guid.Empty; string bookmark = string.Empty; // PBI : 5376 Refactored IBinaryDataListEntry tmp = SvrCompiler.Evaluate(null, dataObj.DataListID, DataList.Contract.enActionType.System, enSystemTag.Bookmark.ToString(), out errors); if(tmp != null) { bookmark = tmp.FetchScalar().TheValue; } tmp = SvrCompiler.Evaluate(null, dataObj.DataListID, DataList.Contract.enActionType.System, enSystemTag.InstanceId.ToString(), out errors); if(tmp != null) { Guid.TryParse(tmp.FetchScalar().TheValue, out instanceId); } tmp = SvrCompiler.Evaluate(null, dataObj.DataListID, DataList.Contract.enActionType.System, enSystemTag.ParentWorkflowInstanceId.ToString(), out errors); if(tmp != null) { Guid.TryParse(tmp.FetchScalar().TheValue, out parentWorkflowInstanceId); } //tmp = SvrCompiler.Evaluate(null, dataObj.DataListID, DataList.Contract.enActionType.System, // enSystemTag.ParentInstanceID.ToString(), out errors); //if (tmp != null) //{ // Guid.TryParse(tmp.FetchScalar().TheValue, out parentInstanceId); //} //bool isDebug = false; //if (xmlRequest.BDSDebugMode is string) //{ // bool.TryParse(xmlRequest.BDSDebugMode, out isDebug); //} // End PBI Mods dataObj.ServiceName = action.ServiceName; // Travis : Now set Data List dataObj.DataList = dataList; Exception wfException = null; IDSFDataObject data = null; PooledServiceActivity activity = action.PopActivity(); try { data = _wf.InvokeWorkflow(activity.Value, dataObj, new List<object> { _dsfChannel }, instanceId, _workspace, bookmark, dataObj.IsDebug); } catch(Exception ex) { wfException = ex; } finally { action.PushActivity(activity); } if(data != null) { return data.DataListID; //return UnlimitedObject.GetStringXmlDataAsUnlimitedObject(data.XmlData); } // ReSharper disable RedundantIfElseBlock else // ReSharper restore RedundantIfElseBlock { dynamic returnError = new UnlimitedObject("Error"); if(wfException != null) { returnError.ErrorDetail = new UnlimitedObject(wfException); } return GlobalConstants.NullDataListID; } }
/// <summary> /// Invokes a plugin assembly /// </summary> /// <param name="plugin">The action of type Plugin</param> /// <param name="req">The req.</param> /// <returns> /// Unlimited object /// </returns> public Guid Plugin(ServiceAction plugin, IDSFDataObject req) { return Plugin(plugin, req, true); }
public List <DynamicServiceObjectBase> GenerateServiceGraph(StringBuilder serviceData) { if (serviceData == null || serviceData.Length == 0) { throw new ArgumentException("serviceData"); } List <DynamicServiceObjectBase> result = new List <DynamicServiceObjectBase>(); var xe = serviceData.ToXElement(); if (IsSource(serviceData)) { Source src = new Source(); var tmp = src as DynamicServiceObjectBase; ServiceMetaData.ExtractMetaData(xe, ref tmp); var typeOf = xe.AttributeSafe("ResourceType"); enSourceType sourceType; src.Type = !Enum.TryParse(typeOf, out sourceType) ? enSourceType.Unknown : sourceType; src.ConnectionString = xe.AttributeSafe("ConnectionString"); var tmpUri = xe.AttributeSafe("Uri"); if (!string.IsNullOrEmpty(tmpUri)) { src.WebServiceUri = new Uri(tmpUri); } src.AssemblyName = xe.AttributeSafe("AssemblyName"); src.AssemblyLocation = xe.AttributeSafe("AssemblyLocation"); // PBI 6597: TWR - added source ID check var id = ServiceMetaData.SetID(ref xe); src.ID = id; src.ResourceDefinition = serviceData; result.Add(src); } else { DynamicService ds = new DynamicService(); var tmp = ds as DynamicServiceObjectBase; ServiceMetaData.ExtractMetaData(xe, ref tmp); // set the resource def ;) ds.ResourceDefinition = serviceData; var actions = xe.Element("Actions"); XElement action = actions != null?actions.Element("Action") : xe.Element("Action"); if (action != null) { ServiceAction sa = new ServiceAction { Name = action.AttributeSafe("Name"), ResourceDefinition = serviceData }; // Set service action ;) enActionType actionType; var typeOf = action.AttributeSafe("Type"); if (Enum.TryParse(typeOf, out actionType)) { sa.ActionType = actionType; } var element = action.Element("Outputs"); if (element != null) { sa.OutputSpecification = element.Value; } // set name and id ;) sa.ServiceName = ds.Name; var id = ServiceMetaData.SetID(ref xe); ds.ID = id; if (IsWorkflow(serviceData)) { // Convert to StringBuilder var xElement = action.Element("XamlDefinition"); if (xElement != null) { var def = xElement.ToStringBuilder(); def = def.Replace("<XamlDefinition>", "").Replace("</XamlDefinition>", ""); sa.XamlDefinition = def.Unescape(); } var dataList = xe.Element("DataList"); if (dataList != null) { ds.DataListSpecification = dataList.ToStringBuilder(); } } else { if (sa.ActionType == enActionType.InvokeStoredProc) { int timeout; Int32.TryParse(action.AttributeSafe("CommandTimeout"), out timeout); sa.CommandTimeout = timeout; } var xElement = action.Element("OutputDescription"); if (xElement != null) { sa.OutputDescription = xElement.Value; } // process inputs and outputs ;) var inputs = action.Element("Inputs"); if (inputs != null) { var inputCollection = inputs.Elements("Input"); foreach (var inputItem in inputCollection) { bool emptyToNull; bool.TryParse(inputItem.AttributeSafe("EmptyToNull"), out emptyToNull); ServiceActionInput sai = new ServiceActionInput { Name = inputItem.AttributeSafe("Name"), Source = inputItem.AttributeSafe("Source"), DefaultValue = inputItem.AttributeSafe("DefaultValue"), EmptyToNull = emptyToNull, NativeType = inputItem.AttributeSafe("NativeType") }; if (string.IsNullOrEmpty(sai.NativeType)) { sai.NativeType = "object"; } // handle validators ;) var validators = inputItem.Elements("Validator"); foreach (var validator in validators) { Validator v = new Validator(); enValidationType validatorType; v.ValidatorType = !Enum.TryParse(validator.AttributeSafe("Type"), out validatorType) ? enValidationType.Required : validatorType; sai.Validators.Add(v); } sa.ServiceActionInputs.Add(sai); } } } // add the action ds.Actions.Add(sa); result.Add(ds); } } return(result); }
private SqlCommand CreateSqlCommand(SqlConnection connection, ServiceAction serviceAction) { var cmd = connection.CreateCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = serviceAction.SourceMethod; cmd.CommandTimeout = serviceAction.CommandTimeout; //Add the parameters to the SqlCommand if (serviceAction.ServiceActionInputs.Any()) { foreach (ServiceActionInput sai in serviceAction.ServiceActionInputs) { var injectVal = (string)sai.Value; // 16.10.2012 : Travis.Frisinger - Convert empty to null if (sai.EmptyToNull && injectVal == AppServerStrings.NullConstant) { cmd.Parameters.AddWithValue(sai.Source, DBNull.Value); } else { cmd.Parameters.AddWithValue(sai.Source, sai.Value); } } } return cmd; }
static ServiceAction AddServiceAction(ServiceAction sa, XElement action) { if (sa.ActionType == enActionType.InvokeStoredProc) { Int32.TryParse(action.AttributeSafe("CommandTimeout"), out int timeout); sa.CommandTimeout = timeout; } var xElement = action.Element("OutputDescription"); if (xElement != null) { sa.OutputDescription = xElement.Value; } // process inputs and outputs ;) var inputs = action.Element("Inputs"); if (inputs != null) { var inputCollection = inputs.Elements("Input"); foreach (var inputItem in inputCollection) { bool.TryParse(inputItem.AttributeSafe("EmptyToNull"), out bool emptyToNull); var sai = new ServiceActionInput { Name = inputItem.AttributeSafe("Name"), Source = inputItem.AttributeSafe("Source"), DefaultValue = inputItem.AttributeSafe("DefaultValue"), EmptyToNull = emptyToNull, NativeType = inputItem.AttributeSafe("NativeType") }; if (string.IsNullOrEmpty(sai.NativeType)) { sai.NativeType = "object"; } // handle validators ;) var validators = inputItem.Elements("Validator"); foreach (var validator in validators) { var v = new Validator { ValidatorType = !Enum.TryParse(validator.AttributeSafe("Type"), out enValidationType validatorType) ? enValidationType.Required : validatorType }; sai.Validators.Add(v); } sa.ServiceActionInputs.Add(sai); } } return(sa); } bool IsSource(StringBuilder serviceData) => serviceData.IndexOf("<Source ", 0, false) == 0; bool IsWorkflow(StringBuilder serviceData) { var startIdx = serviceData.IndexOf("<XamlDefinition>", 0, false); if (startIdx >= 0) { var endIdx = serviceData.IndexOf("</XamlDefinition>", startIdx, false); var dif = endIdx - startIdx; // we know a blank wf is larger then our max string size ;) return(startIdx > 0 && dif > GlobalConstants.MAX_SIZE_FOR_STRING - 1024); } return(false); } }
protected override void ConfigureServicesBody(IServiceCollection services) { var isConstruction = true; // Perhaps get from service or configuration. // -1 ( IServiceAction <IDirectoryNameOperator> _, IServiceAction <IDirectorySeparatorOperator> _, IServiceAction <IFileExtensionOperator> _, IServiceAction <IFileNameOperator> fileNameOperatorAction, IServiceAction <IStringlyTypedPathOperator> stringlyTypedPathOperatorAction ) = services.AddStringlyTypedPathRelatedOperatorsAction(); // 0 IServiceAction <DeepEqualsXElementEqualityComparer> deepEqualsXElementEqualityComparerAction = ServiceAction <DeepEqualsXElementEqualityComparer> .New(() => services.AddSingleton <DeepEqualsXElementEqualityComparer>()); IServiceAction <FunctionalityDirectoryNameProvider> functionalityDirectoryNameProviderAction = ServiceAction <FunctionalityDirectoryNameProvider> .New(() => services.AddSingleton <FunctionalityDirectoryNameProvider>()); IServiceAction <IGuidProvider> guidProviderAction = services.AddGuidProviderAction(); IServiceAction <IMessageFormatter> messageFormatterAction = ServiceAction <IMessageFormatter> .New(serviceCollection => { serviceCollection .AddSingleton <IMessageFormatter, MessageFormatter>() ; }); //IServiceAction<IMessageRepository> messageRepositoryAction = ServiceAction<IMessageRepository>.New(serviceCollection => serviceCollection.AddSingleton<IMessageRepository, InMemoryMessageRepository>()); // Adds the default in-memory message repository. //IServiceAction<IMessageSink> messageSinkAction = ServiceAction<IMessageSink>.New( // serviceCollection => serviceCollection.AddSingleton<IMessageSink>( // serviceProvider => // { // var programStartTimeSpecificMessagesOutputDirectoryPathProvider = serviceProvider.GetRequiredService<IProgramStartTimeSpecificMessagesOutputDirectoryPathProvider>(); // var programStartTimeSpecificMessagesOutputDirectoryPath = programStartTimeSpecificMessagesOutputDirectoryPathProvider.GetProgramStartTimeSpecificMessagesOutputDirectoryPathAsync().Result; // var stringlyTypedPathOperator = serviceProvider // })); // No async Add() methods allowed! IServiceAction <IMessageSinkProvider> messageSinkProviderAction = ServiceAction <IMessageSinkProvider> .New(() => services.AddSingleton <IMessageSinkProvider, DefaultMessageSinkProvider>()); // One message sink provider for the whole application. IServiceAction <INowUtcProvider> nowUtcProviderAction = services.AddNowUtcProviderAction(); IServiceAction <OrderIndependentXElementEqualityComparer> orderIndependentXElementEqualityComparerAction = ServiceAction <OrderIndependentXElementEqualityComparer> .New(() => services.AddSingleton <OrderIndependentXElementEqualityComparer>()); IServiceAction <IProcessStartTimeUtcProvider> processStartTimeUtcProviderAction = services.AddProcessStartTimeUtcProviderAction(); IServiceAction <IProgramNameProvider> programNameProviderAction = services.AddProgramNameProviderAction(); IServiceAction <ITemporaryDirectoryFilePathProvider> temporaryDirectoryFilePathProviderAction = services.AddTemporaryDirectoryFilePathProviderAction(); IServiceAction <ITestingDataDirectoryContentPathsProvider> testingDataDirectoryContentPathsProviderAction = services.AddTestingDataDirectoryContentPathsProviderAction(); IServiceAction <ITimestampUtcDirectoryNameProvider> timestampUtcDirectoryNameProviderAction = services.AddTimestampUtcDirectoryNameProviderAction(); IServiceAction <IVisualStudioProjectFileDeserializationSettings> visualStudioProjectFileDeserializationSettingsAction = ServiceAction <IVisualStudioProjectFileDeserializationSettings> .New((serviceCollection) => { serviceCollection .AddVisualStudioProjectFileDeserializationSettings(settings => { settings.ThrowAtErrorOccurrence = false; settings.ThrowIfAnyErrorAtEnd = true; settings.ThrowIfInvalidProjectFile = false; }); }); // 1 IServiceAction <IProcessStartTimeUtcDirectoryNameProvider> processStartTimeUtcDirectoryNameProviderAction = services.AddProcessStartTimeUtcDirectoryNameProviderAction( processStartTimeUtcProviderAction, timestampUtcDirectoryNameProviderAction); IServiceAction <IProgramNameDirectoryNameProvider> programNameDirectoryNameProviderAction = services.AddProgramNameDirectoryNameProviderAction( programNameProviderAction); IServiceAction <IMessagesOutputBaseDirectoryPathProvider> messagesOutputBaseDirectoryPathProviderAction = ServiceAction <IMessagesOutputBaseDirectoryPathProvider> .New((serviceCollection) => { serviceCollection .AddSingleton <IMessagesOutputBaseDirectoryPathProvider, MessagesOutputBaseDirectoryPathProvider>() .Run(temporaryDirectoryFilePathProviderAction) .Run(stringlyTypedPathOperatorAction) ; }); IServiceAction <IProjectFileDeserializationMessagesOutputFileNameProvider> projectFileDeserializationMessagesOutputFileNameProviderAction = isConstruction ? ServiceAction <IProjectFileDeserializationMessagesOutputFileNameProvider> .New((serviceCollection) => { serviceCollection .AddSingleton <IProjectFileDeserializationMessagesOutputFileNameProvider, ConstructionTimeProjectFileDeserializationMessagesOutputFileNameProvider>() .Run(fileNameOperatorAction) .Run(stringlyTypedPathOperatorAction) ; }) : ServiceAction <IProjectFileDeserializationMessagesOutputFileNameProvider> .New((serviceCollection) => { serviceCollection .AddSingleton <IProjectFileDeserializationMessagesOutputFileNameProvider, ProjectFileDeserializationMessagesOutputFileNameProvider>() .Run(fileNameOperatorAction) .Run(guidProviderAction) .Run(stringlyTypedPathOperatorAction) ; }); IServiceAction <IVisualStudioProjectFileToXElementConverter> visualStudioProjectFileToXElementConverter = ServiceAction <IVisualStudioProjectFileToXElementConverter> .New((serviceCollection) => { serviceCollection .AddSingleton <IVisualStudioProjectFileToXElementConverter, VisualStudioProjectFileToXElementConverter>() .Run(nowUtcProviderAction) .Run(visualStudioProjectFileDeserializationSettingsAction) ; }); IServiceAction <IVisualStudioProjectFileValidator> visualStudioProjectFileValidatorAction = ServiceAction <IVisualStudioProjectFileValidator> .New((serviceCollection) => { serviceCollection .AddSingleton <IVisualStudioProjectFileValidator, VisualStudioProjectFileValidator>() .Run(nowUtcProviderAction) ; }); // 2 IServiceAction <IProgramSpecificMessagesOutputDirectoryPathProvider> programSpecificMessagesOutputDirectoryPathProviderAction = ServiceAction <IProgramSpecificMessagesOutputDirectoryPathProvider> .New(serviceCollection => { serviceCollection .AddSingleton <IProgramSpecificMessagesOutputDirectoryPathProvider, ProgramSpecificMessagesOutputDirectoryPathProvider>() .Run(messagesOutputBaseDirectoryPathProviderAction) .Run(programNameDirectoryNameProviderAction) .Run(stringlyTypedPathOperatorAction) ; }); IServiceAction <IRelativeFilePathsVisualStudioProjectFileStreamSerializer> relativeFilePathsVisualStudioProjectFileSerializerAction = ServiceAction <IRelativeFilePathsVisualStudioProjectFileStreamSerializer> .New((serviceCollection) => { serviceCollection .AddSingleton <IRelativeFilePathsVisualStudioProjectFileStreamSerializer, RelativeFilePathsVisualStudioProjectFileStreamSerializer>() .Run(stringlyTypedPathOperatorAction) .Run(visualStudioProjectFileToXElementConverter) ; }); // 3 IServiceAction <IProgramStartTimeSpecificMessagesOutputDirectoryPathProvider> programNameStartTimeMessagesOutputDirectoryPathProviderAction = isConstruction ? ServiceAction <IProgramStartTimeSpecificMessagesOutputDirectoryPathProvider> .New(serviceCollection => { serviceCollection .AddSingleton <IProgramStartTimeSpecificMessagesOutputDirectoryPathProvider, ConstructionTimeMessagesOutputDirectoryPathProvider>() .Run(programSpecificMessagesOutputDirectoryPathProviderAction) .Run(stringlyTypedPathOperatorAction) ; }) : ServiceAction <IProgramStartTimeSpecificMessagesOutputDirectoryPathProvider> .New(serviceCollection => { serviceCollection .AddSingleton <IProgramStartTimeSpecificMessagesOutputDirectoryPathProvider, ProgramNameStartTimeMessagesOutputDirectoryPathProvider>() .Run(programSpecificMessagesOutputDirectoryPathProviderAction) .Run(processStartTimeUtcDirectoryNameProviderAction) .Run(stringlyTypedPathOperatorAction) ; }) ; // 4 IServiceAction <IFunctionalitySpecificMessagesOutputDirectoryPathProvider> programNameStartTimeFunctionalityMessagesOutputDirectoryPathProviderAction = ServiceAction <IFunctionalitySpecificMessagesOutputDirectoryPathProvider> .New((serviceCollection) => { serviceCollection .AddSingleton <IFunctionalitySpecificMessagesOutputDirectoryPathProvider, ProgramNameStartTimeFunctionalityMessagesOutputDirectoryPathProvider>() .Run(functionalityDirectoryNameProviderAction) .Run(programNameStartTimeMessagesOutputDirectoryPathProviderAction) .Run(stringlyTypedPathOperatorAction) ; }); // 5 IServiceAction <IVisualStudioProjectFileSerializerMessagesOutputFilePathProvider> visualStudioProjectFileSerializerMessagesOutputFilePathProviderAction = ServiceAction <IVisualStudioProjectFileSerializerMessagesOutputFilePathProvider> .New((serviceCollection) => { serviceCollection .AddSingleton <IVisualStudioProjectFileSerializerMessagesOutputFilePathProvider, VisualStudioProjectFileSerializerMessagesOutputFilePathProvider>() .Run(projectFileDeserializationMessagesOutputFileNameProviderAction) .Run(programNameStartTimeFunctionalityMessagesOutputDirectoryPathProviderAction) .Run(stringlyTypedPathOperatorAction) ; }); // 6 IServiceAction <IFunctionalVisualStudioProjectFileStreamSerializer> functionalVisualStudioProjectFileSerializerAction = ServiceAction <IFunctionalVisualStudioProjectFileStreamSerializer> .New((serviceCollection) => { serviceCollection .AddSingleton <IFunctionalVisualStudioProjectFileStreamSerializer, FunctionalVisualStudioProjectFileStreamSerializer>() .Run(messageFormatterAction) .Run(nowUtcProviderAction) .Run(relativeFilePathsVisualStudioProjectFileSerializerAction) .Run(stringlyTypedPathOperatorAction) .Run(visualStudioProjectFileDeserializationSettingsAction) .Run(visualStudioProjectFileSerializerMessagesOutputFilePathProviderAction) .Run(visualStudioProjectFileValidatorAction) ; }); // 7 IServiceAction <IVisualStudioProjectFileStreamSerializer> visualStudioProjectFileStreamSerializerAction = ServiceAction <IVisualStudioProjectFileStreamSerializer> .New((serviceCollection) => { serviceCollection .AddSingleton <IVisualStudioProjectFileStreamSerializer, VisualStudioProjectFileStreamSerializer>() .Run(functionalVisualStudioProjectFileSerializerAction) .Run(messageSinkProviderAction) ; }); // 8 IServiceAction <IVisualStudioProjectFileSerializer> visualStudioProjectFileSerializerAction = ServiceAction <IVisualStudioProjectFileSerializer> .New((serviceCollection) => { serviceCollection .AddSingleton <IVisualStudioProjectFileSerializer, VisualStudioProjectFileSerializer>() .Run(visualStudioProjectFileStreamSerializerAction) ; }); services .Run(deepEqualsXElementEqualityComparerAction) .Run(fileNameOperatorAction) .Run(functionalityDirectoryNameProviderAction) .Run(functionalVisualStudioProjectFileSerializerAction) .Run(guidProviderAction) .Run(messagesOutputBaseDirectoryPathProviderAction) .Run(messageFormatterAction) .Run(messageSinkProviderAction) .Run(nowUtcProviderAction) .Run(orderIndependentXElementEqualityComparerAction) .Run(processStartTimeUtcDirectoryNameProviderAction) .Run(processStartTimeUtcProviderAction) .Run(programNameDirectoryNameProviderAction) .Run(programNameProviderAction) .Run(programNameStartTimeMessagesOutputDirectoryPathProviderAction) .Run(programNameStartTimeFunctionalityMessagesOutputDirectoryPathProviderAction) .Run(projectFileDeserializationMessagesOutputFileNameProviderAction) .Run(relativeFilePathsVisualStudioProjectFileSerializerAction) .Run(stringlyTypedPathOperatorAction) .Run(temporaryDirectoryFilePathProviderAction) .Run(testingDataDirectoryContentPathsProviderAction) .Run(timestampUtcDirectoryNameProviderAction) .Run(visualStudioProjectFileSerializerAction) .Run(visualStudioProjectFileStreamSerializerAction) .Run(visualStudioProjectFileSerializerMessagesOutputFilePathProviderAction) .Run(visualStudioProjectFileToXElementConverter) .Run(visualStudioProjectFileDeserializationSettingsAction) .Run(visualStudioProjectFileValidatorAction) ; }
/// <summary> /// Adds the <see cref="GeometryFactoryProvider"/> implementation of <see cref="IGeometryFactoryProvider"/> as a <see cref="ServiceLifetime.Singleton"/>. /// </summary> public static IServiceAction <IGeometryFactoryProvider> AddGeometryFactoryProviderAction(this IServiceCollection services) { var serviceAction = ServiceAction.New <IGeometryFactoryProvider>(() => services.AddGeometryFactoryProvider()); return(serviceAction); }
/// <summary> /// Adds the <see cref="INowProvider"/> service. /// </summary> public static ServiceAction <INowProvider> AddNowProviderAction(this IServiceCollection services) { var serviceAction = ServiceAction <INowProvider> .New(() => services.AddNowProvider()); return(serviceAction); }
/// <summary> /// Adds the <see cref="FileExtensionOperator"/> implementation of <see cref="IFileExtensionOperator"/> as a <see cref="ServiceLifetime.Singleton"/>. /// </summary> public static IServiceAction <IFileExtensionOperator> AddFileExtensionOperatorAction(this IServiceCollection services) { var serviceAction = ServiceAction.New <IFileExtensionOperator>(() => services.AddFileExtensionOperator()); return(serviceAction); }
/// <summary> /// Invoke Stored Procedure on Sql Server /// </summary> /// <param name="serviceAction">Action of type Sql Server</param> /// <param name="req">The req.</param> /// <returns> /// UnlimitedObject /// </returns> //public dynamic SqlDatabaseCommand(ServiceAction serviceAction, IDSFDataObject req) //{ // Guid result = GlobalConstants.NullDataListID; // Guid tmpID = GlobalConstants.NullDataListID; // var errors = new ErrorResultTO(); // var allErrors = new ErrorResultTO(); // using(var cn = new SqlConnection(serviceAction.Source.ConnectionString)) // { // var dataset = new DataSet(); // try // { // //Create a SqlCommand to execute at the source // var cmd = new SqlCommand(); // cmd.CommandType = CommandType.StoredProcedure; // cmd.Connection = cn; // cmd.CommandText = serviceAction.SourceMethod; // cmd.CommandTimeout = serviceAction.CommandTimeout; // //Add the parameters to the SqlCommand // if(serviceAction.ServiceActionInputs.Count() > 0) // { // foreach(ServiceActionInput sai in serviceAction.ServiceActionInputs) // { // var injectVal = (string)sai.Value; // // 16.10.2012 : Travis.Frisinger - Convert empty to null // if(sai.EmptyToNull && injectVal == AppServerStrings.NullConstant) // { // cmd.Parameters.AddWithValue(sai.Source, DBNull.Value); // } // else // { // cmd.Parameters.AddWithValue(sai.Source, sai.Value); // } // } // } // cn.Open(); // var xmlDbResponse = new StringBuilder(); // var adapter = new SqlDataAdapter(cmd); // adapter.Fill(dataset); // string res = // DataSanitizerFactory.GenerateNewSanitizer(enSupportedDBTypes.MSSQL) // .SanitizePayload(dataset.GetXml()); // xmlDbResponse.Append(res); // cn.Close(); // //Alert the caller that request returned no data // if(string.IsNullOrEmpty(xmlDbResponse.ToString())) // { // // handle any errors that might have occured // IBinaryDataListEntry be = Dev2BinaryDataListFactory.CreateEntry(enSystemTag.Error.ToString(), // string.Empty); // string error; // be.TryPutScalar( // Dev2BinaryDataListFactory.CreateBinaryItem( // "The request yielded no response from the data store.", enSystemTag.Error.ToString()), // out error); // if(error != string.Empty) // { // errors.AddError(error); // } // SvrCompiler.Upsert(null, req.DataListID, // DataListUtil.BuildSystemTagForDataList(enSystemTag.Error, true), be, // out errors); // } // else // { // string tmpData = xmlDbResponse.ToString(); // string od = serviceAction.OutputDescription; // od = od.Replace("<Dev2XMLResult>", "").Replace("</Dev2XMLResult>", "").Replace("<JSON />", ""); // if(!string.IsNullOrWhiteSpace(od)) // { // IOutputDescriptionSerializationService outputDescriptionSerializationService = // OutputDescriptionSerializationServiceFactory.CreateOutputDescriptionSerializationService // (); // IOutputDescription outputDescriptionInstance = // outputDescriptionSerializationService.Deserialize(od); // if(outputDescriptionInstance != null) // { // IOutputFormatter outputFormatter = // OutputFormatterFactory.CreateOutputFormatter(outputDescriptionInstance); // string formatedPayload = outputFormatter.Format(tmpData).ToString(); // // TODO : Now create a new dataList and merge the result into the current dataList ;) // string dlShape = // ClientCompiler.ShapeDev2DefinitionsToDataList(serviceAction.ServiceActionOutputs, // enDev2ArgumentType.Output, false, // out errors); // allErrors.MergeErrors(errors); // tmpID = ClientCompiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML), // formatedPayload, dlShape, out errors); // var parentID = ClientCompiler.FetchParentID(req.DataListID); // //ClientCompiler.SetParentID(tmpID, req.DataListID); // ClientCompiler.SetParentID(tmpID, parentID); // // set parent for merge op in finally... // allErrors.MergeErrors(errors); // } // } // } // cmd.Dispose(); // } // catch(Exception ex) // { // allErrors.AddError(ex.Message); // } // finally // { // // handle any errors that might have occured // IBinaryDataListEntry be = Dev2BinaryDataListFactory.CreateEntry(enSystemTag.Error.ToString(), // string.Empty); // string error; // be.TryPutScalar( // Dev2BinaryDataListFactory.CreateBinaryItem(allErrors.MakeDataListReady(), // enSystemTag.Error.ToString()), out error); // if(error != string.Empty) // { // errors.AddError(error); // } // SvrCompiler.Upsert(null, req.DataListID, // DataListUtil.BuildSystemTagForDataList(enSystemTag.Error, true), be, out errors); // // now merge and delete tmp // if(tmpID != GlobalConstants.NullDataListID) // { // ClientCompiler.Shape(tmpID, enDev2ArgumentType.Output, serviceAction.ServiceActionOutputs, // out errors); // ClientCompiler.DeleteDataListByID(tmpID); // result = req.DataListID; // } // //ExceptionHandling.WriteEventLogEntry("Application", string.Format("{0}.{1}", this.GetType().Name, "SqlDatabaseCommand"), string.Format("Exception:{0}\r\nInputData:{1}", xmlResponse.XmlString, xmlRequest.XmlString), EventLogEntryType.Error); // } // return result; // } //} public dynamic SqlDatabaseCommand(ServiceAction serviceAction, IDSFDataObject req) { Guid result = GlobalConstants.NullDataListID; Guid tmpID = GlobalConstants.NullDataListID; var errors = new ErrorResultTO(); var allErrors = new ErrorResultTO(); try { // Get XAML data from service action string xmlDbResponse = GetXmlDataFromSqlServiceAction(serviceAction); if (string.IsNullOrEmpty(xmlDbResponse)) { // If there was no data returned add error allErrors.AddError("The request yielded no response from the data store."); } else { // Get the output formatter from the service action IOutputFormatter outputFormatter = GetOutputFormatterFromServiceAction(serviceAction); if (outputFormatter == null) { // If there was an error getting the output formatter from the service action allErrors.AddError(string.Format("Output format in service action {0} is invalid.", serviceAction.Name)); } else { // Format the XML data string formatedPayload = outputFormatter.Format(xmlDbResponse).ToString(); // Create a shape from the service action outputs string dlShape = ClientCompiler.ShapeDev2DefinitionsToDataList(serviceAction.ServiceActionOutputs, enDev2ArgumentType.Output, false, out errors); allErrors.MergeErrors(errors); // Push formatted data into a datalist using the shape from the service action outputs tmpID = ClientCompiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML), formatedPayload, dlShape, out errors); allErrors.MergeErrors(errors); // Attach a parent ID to the newly created datalist var parentID = ClientCompiler.FetchParentID(req.DataListID); ClientCompiler.SetParentID(tmpID, parentID); } } } catch (Exception ex) { allErrors.AddError(ex.Message); } finally { // If a datalist was ceated if (tmpID != GlobalConstants.NullDataListID) { // Merge into it's parent ClientCompiler.Shape(tmpID, enDev2ArgumentType.Output, serviceAction.ServiceActionOutputs, out errors); allErrors.MergeErrors(errors); // Delete data list ClientCompiler.DeleteDataListByID(tmpID); result = req.DataListID; } // Add any errors that occured to the datalist AddErrorsToDataList(allErrors, req.DataListID); } return result; }
/// <summary> /// Adds the <see cref="IFileSerializer{T}"/> service. /// </summary> public static ServiceAction<IFileSerializer<T>> AddTextFileSerializerAction<T>(this IServiceCollection services, ServiceAction<ITextSerializer<T>> addTextSerializer) { var serviceAction = new ServiceAction<IFileSerializer<T>>(() => services.AddTextFileSerializer<T>(addTextSerializer)); return serviceAction; }
public dynamic MySqlDatabase(ServiceAction serviceAction, dynamic xmlRequest) { dynamic result = "Not supported"; return result; }
/// <summary> /// Adds the <see cref="ProcessStartTimeProvider"/> implementation of <see cref="IProcessStartTimeProvider"/> as a <see cref="ServiceLifetime.Singleton"/>. /// </summary> public static ServiceAction <IProcessStartTimeProvider> AddDefaultProcessStartTimeProviderAction(this IServiceCollection services) { var serviceAction = ServiceAction <IProcessStartTimeProvider> .New(() => services.AddDefaultProcessStartTimeProvider()); return(serviceAction); }
private IOutputFormatter GetOutputFormatterFromServiceAction(ServiceAction serviceAction) { string outputDescription = serviceAction.OutputDescription.Replace("<Dev2XMLResult>", "").Replace("</Dev2XMLResult>", "").Replace("<JSON />", ""); IOutputDescriptionSerializationService outputDescriptionSerializationService = OutputDescriptionSerializationServiceFactory.CreateOutputDescriptionSerializationService(); if (outputDescriptionSerializationService == null) { return null; } IOutputDescription outputDescriptionInstance = outputDescriptionSerializationService.Deserialize(outputDescription); if (outputDescriptionInstance == null) { return null; } return OutputFormatterFactory.CreateOutputFormatter(outputDescriptionInstance); }
/// <summary> /// Adds the <see cref="DefaultCommandLineInvocationOperator"/> implementation of <see cref="ICommandLineInvocationOperator"/> as a <see cref="ServiceLifetime.Singleton"/>. /// </summary> public static ServiceAction <ICommandLineInvocationOperator> AddDefaultCommandLineInvocationOperatorAction(this IServiceCollection services) { var serviceAction = new ServiceAction <ICommandLineInvocationOperator>(() => services.AddDefaultCommandLineInvocationOperator()); return(serviceAction); }
public dynamic BizRule(ServiceAction sa, dynamic xmlRequest, Guid dataListID) { dynamic bizRuleException = null; // ReSharper disable JoinDeclarationAndInitializer dynamic result; // ReSharper restore JoinDeclarationAndInitializer ErrorResultTO errors; IDynamicServicesInvoker invoker = new DynamicServicesInvoker(); result = invoker.Invoke(sa.Service, xmlRequest, dataListID, out errors); // ReSharper disable InconsistentNaming string Expression = sa.BizRule.Expression; // ReSharper restore InconsistentNaming string[] expressionColumns = sa.BizRule.ExpressionColumns; for(int count = 0; count < expressionColumns.Length; count++) { //Retrieve the value from the response of service object inputValue = result.GetValue(expressionColumns[count]); //The value does not exist so we stop right here if(inputValue.GetType() != typeof(string)) { _returnVal.Error = string.Format("Unable to execute business rule '{0}'", sa.BizRule.Name); _returnVal.ErrorDetail = string.Format( "Value of '{0}' does not exist in response from action '{1}'", expressionColumns[count], sa.Name); return _returnVal; } //Build an executable c# expression that we can evaluate this must always evaluate to a boolean value //true=input passed the business rule; false=input failed the business rule. // ReSharper disable SpecifyACultureInStringConversionExplicitly Expression = Expression.Replace("{" + count.ToString() + "}", inputValue.ToString()); // ReSharper restore SpecifyACultureInStringConversionExplicitly } #region Evaluate the c# expression dynamically try { object o = Eval(Expression); bool bizRuleSuccess; bool.TryParse(o.ToString(), out bizRuleSuccess); if(!bizRuleSuccess) { _returnVal.Error = string.Format("Request Failed Business Rule '{0}'", sa.BizRule.Name); return _returnVal; } } catch(InvalidExpressionException invalidExpressionEx) { bizRuleException = invalidExpressionEx; } catch(Exception ex) { bizRuleException = ex; } if(bizRuleException != null) { ExceptionHandling.WriteEventLogEntry( Resources.DynamicService_EventLogTarget , Resources.DynamicService_EventLogSource // ReSharper disable PossibleNullReferenceException , bizRuleException.ToString() // ReSharper restore PossibleNullReferenceException , EventLogEntryType.Error); _returnVal.Error = string.Format("Could not evaluate business rule expression {0}", Expression); _returnVal.ErrorDetail = bizRuleException.ToString(); return _returnVal; } #endregion return result; }
/// <summary> /// Add the <see cref="TestingDataDirectoryNameConvention"/> implementation of <see cref="ITestingDataDirectoryNameConvention"/> as a <see cref="ServiceLifetime.Singleton"/>. /// </summary> public static ServiceAction <ITestingDataDirectoryNameConvention> AddDefaultTestingDataDirectoryNameConventionAction(this IServiceCollection services) { var serviceAction = new ServiceAction <ITestingDataDirectoryNameConvention>(() => services.AddDefaultTestingDataDirectoryNameConvention()); return(serviceAction); }
private void RestartStopAppService(string folder, string SearchPattern, ServiceAction serviceAction) { string strService = PathBoss.GetService(SearchPattern, folder); string strMsg = String.Empty; switch (serviceAction) { case ServiceAction.ReStart: strMsg=folder + " serverında " + strService + " servisini restart etmek istediğinizden emin misiniz?"; break; case ServiceAction.Stop: strMsg=folder + " serverında " + strService + " servisini durdurmak istediğinizden emin misiniz?"; break; default: break; } var dd = MessageBox.Show(strMsg, "", MessageBoxButtons.YesNo); if (dd==System.Windows.Forms.DialogResult.No) { return; } string strMachine = ""; switch (folder) { case "DEV": strMachine = "10.87.8.74"; break; case "UAT": strMachine = "10.87.21.192"; break; default: MessageBox.Show("Servis yok"); return; } switch (serviceAction) { case ServiceAction.ReStart: RestartWindowsService(strMachine, strService, 5000); break; case ServiceAction.Stop: StopWindowsService(strMachine, strService, 5000); break; default: break; } }
// BUG 9304 - 2013.05.08 - TWR - Added IWorkflowHelper parameter to facilitate testing public WfExecutionContainer(ServiceAction sa, IDSFDataObject dataObj, IWorkspace theWorkspace, IEsbChannel esbChannel) : base(sa, dataObj, theWorkspace, esbChannel) { }
public string BuildSearchPost(ServiceAction action, string xmlNamesapce, object value, string commandParameter = "") { var stateString = string.Empty; foreach (var arg in action.ArgumentList) { if (arg.Direction == "out") continue; if (arg.Name == "ObjectID") stateString += BuildArgumentXml(arg, value.ToString()); else if (arg.Name == "Filter") stateString += BuildArgumentXml(arg, "*"); else if (arg.Name == "StartingIndex") stateString += BuildArgumentXml(arg, "0"); else if (arg.Name == "RequestedCount") stateString += BuildArgumentXml(arg, "200"); else if (arg.Name == "BrowseFlag") stateString += BuildArgumentXml(arg, null, "BrowseDirectChildren"); else if (arg.Name == "SortCriteria") stateString += BuildArgumentXml(arg, ""); else stateString += BuildArgumentXml(arg, value.ToString(), commandParameter); } return string.Format(CommandBase, action.Name, xmlNamesapce, stateString); }
public ServiceThreadData(ServiceAction _serviceAction, string _machineName, string _serviceName) { ServiceAction = _serviceAction; MachineName = _machineName; ServiceName = _serviceName; }
/// <summary> /// Adds the <see cref="DirectorySeparatorOperator"/> implementation of <see cref="IDirectorySeparatorOperator"/> as a <see cref="ServiceLifetime.Singleton"/>. /// </summary> public static IServiceAction <IDirectorySeparatorOperator> AddDirectorySeparatorOperatorAction(this IServiceCollection services) { var serviceAction = ServiceAction.New <IDirectorySeparatorOperator>(() => services.AddDirectorySeparatorOperator()); return(serviceAction); }
/// <summary> /// Adds the <see cref="IOrganizationDirectoryNameProvider"/> service. /// </summary> public static ServiceAction <IOrganizationDirectoryNameProvider> AddOrganizationDirectoryNameProviderAction(this IServiceCollection services) { var serviceAction = new ServiceAction <IOrganizationDirectoryNameProvider>(() => services.AddOrganizationDirectoryNameProvider()); return(serviceAction); }
/// <summary> /// Adds the <see cref="IDropboxDirectoryNameConvention"/> service. /// </summary> public static ServiceAction <IDropboxDirectoryNameConvention> AddDropboxDirectoryNameConventionAction(this IServiceCollection services) { var serviceAction = new ServiceAction <IDropboxDirectoryNameConvention>(() => services.AddDropboxDirectoryNameConvention()); return(serviceAction); }
/// <summary> /// Adds the <see cref="IOrganizationStringlyTypedPathOperator"/> service. /// </summary> public static ServiceAction <IOrganizationStringlyTypedPathOperator> AddOrganizationStringlyTypedPathOperatorAction(this IServiceCollection services) { var serviceAction = new ServiceAction <IOrganizationStringlyTypedPathOperator>(() => services.AddOrganizationStringlyTypedPathOperator()); return(serviceAction); }
/// <summary> /// Invokes a web service /// </summary> /// <param name="service">The action of type InvokeWebService</param> /// <param name="xmlRequest">The XML request.</param> /// <returns> /// UnlimitedObject /// </returns> public dynamic WebService(ServiceAction service, dynamic xmlRequest) { //dynamic webServiceException = null; dynamic error = new UnlimitedObject(); if(service.ActionType == enActionType.InvokeWebService) { string svc = service.Source.Invoker.AvailableServices.FirstOrDefault(); if(string.IsNullOrEmpty(svc)) { error.Error = "Web Service not found in dynamic proxy"; } string method = service.SourceMethod; var arguments = new List<string>(); service.ServiceActionInputs.ForEach(c => { if(c.Value != null) arguments.Add(c.Value.ToString()); }); string[] args = arguments.ToArray(); string result; try { // ReSharper disable CoVariantArrayConversion result = service.Source.Invoker.InvokeMethod<string>(svc, method, args); // ReSharper restore CoVariantArrayConversion } catch(Exception ex) { error.Error = "Error Processing Web Service Request"; error.ErrorDetail = new UnlimitedObject(ex).XmlString; ExceptionHandling.WriteEventLogEntry("Application", string.Format("{0}.{1}", GetType().Name, "WebServiceCommand"), error.XmlString, EventLogEntryType.Error); return error; } return UnlimitedObject.GetStringXmlDataAsUnlimitedObject(string.Format("<{0}>{1}</{0}>", "WebServiceResult", result)); } return new UnlimitedObject().XmlString; }
protected EsbExecutionContainer(ServiceAction sa, IDSFDataObject dataObject, IWorkspace theWorkspace, IEsbChannel esbChannel) : this(sa, dataObject, theWorkspace, esbChannel, null) { }
/// <summary> /// Invoke a management method which is a statically coded method in the service implementation for service engine administrators /// </summary> /// <param name="serviceAction">Action of type InvokeManagementDynamicService</param> /// <param name="xmlRequest">The XML request.</param> /// <returns> /// UnlimitedObject /// </returns> public Guid ManagementDynamicService(ServiceAction serviceAction, IDSFDataObject xmlRequest) { var errors = new ErrorResultTO(); var allErrors = new ErrorResultTO(); Guid result = GlobalConstants.NullDataListID; try { object[] parameterValues = null; //Instantiate a Endpoint object that contains all static management methods object o = this; //Activator.CreateInstance(typeof(Unlimited.Framework.DynamicServices.DynamicServicesEndpoint), new object[] {string.Empty}); //Get the management method MethodInfo m = o.GetType().GetMethod(serviceAction.SourceMethod); //Infer the parameters of the management method ParameterInfo[] parameters = m.GetParameters(); //If there are parameters then retrieve them from the service action input values if(parameters.Count() > 0) { IEnumerable<object> parameterData = from c in serviceAction.ServiceActionInputs select c.Value; parameterValues = parameterData.ToArray(); } //Invoke the management method and store the return value string val = m.Invoke(o, parameterValues).ToString(); result = ClientCompiler.UpsertSystemTag(xmlRequest.DataListID, enSystemTag.ManagmentServicePayload, val, out errors); //_clientCompiler.Upsert(xmlRequest.DataListID, DataListUtil.BuildSystemTagForDataList(enSystemTag.ManagmentServicePayload, true), val, out errors); allErrors.MergeErrors(errors); //returnval = new UnlimitedObject(GetXElement(val)); } catch(Exception ex) { allErrors.AddError(ex.Message); } finally { // handle any errors that might have occured if(allErrors.HasErrors()) { IBinaryDataListEntry be = Dev2BinaryDataListFactory.CreateEntry(enSystemTag.Error.ToString(), string.Empty); string error; be.TryPutScalar( Dev2BinaryDataListFactory.CreateBinaryItem(allErrors.MakeDataListReady(), enSystemTag.Error.ToString()), out error); if(error != string.Empty) { errors.AddError(error); } } // No cleanup to happen ;) } return result; }
/// <summary> /// Adds the <see cref="IDataDirectoryPathProvider"/> service. /// </summary> public static ServiceAction <IDataDirectoryPathProvider> AddDataDirectoryPathProviderAction(this IServiceCollection services) { var serviceAction = new ServiceAction <IDataDirectoryPathProvider>(() => services.AddDataDirectoryPathProvider()); return(serviceAction); }
public dynamic Switch(ServiceAction serviceAction, dynamic xmlRequest, Guid dataListID) { dynamic result = new UnlimitedObject(); DynamicService anonymousService = new DynamicService(); if(!string.IsNullOrEmpty(serviceAction.Cases.DataElementValue)) { List<ServiceAction> anonymousServiceActions; IEnumerable<ServiceActionCase> caseMatch = serviceAction.Cases.Cases.Where(c => Regex.IsMatch(serviceAction.Cases.DataElementValue, c.Regex)); // ReSharper disable ConvertIfStatementToConditionalTernaryExpression // ReSharper disable PossibleMultipleEnumeration if(caseMatch.Any()) // ReSharper restore PossibleMultipleEnumeration // ReSharper restore ConvertIfStatementToConditionalTernaryExpression { // ReSharper disable PossibleMultipleEnumeration anonymousServiceActions = caseMatch.First().Actions; // ReSharper restore PossibleMultipleEnumeration } else { anonymousServiceActions = serviceAction.Cases.DefaultCase.Actions; } anonymousService.Name = string.Format("serviceOf{0}", serviceAction.Name); anonymousService.Actions = anonymousServiceActions; IDynamicServicesInvoker invoker = new DynamicServicesInvoker(); ErrorResultTO errors; result = invoker.Invoke(anonymousService, xmlRequest, dataListID, out errors); } return result; }
/// <summary> /// Adds the <see cref="VisualStudioProjectFileTransformer"/> implementation of <see cref="IVisualStudioProjectFileTransformer"/> as a <see cref="ServiceLifetime.Singleton"/>. /// </summary> public static IServiceAction <IVisualStudioProjectFileTransformer> AddVisualStudioProjectFileTransformerAction(this IServiceCollection services) { var serviceAction = ServiceAction <IVisualStudioProjectFileTransformer> .New(() => services.AddVisualStudioProjectFileTransformer()); return(serviceAction); }
private string GetXmlDataFromSqlServiceAction(ServiceAction serviceAction) { string xmlData; using (var dataset = new DataSet()) { using (var connection = new SqlConnection(serviceAction.Source.ConnectionString)) { var cmd = CreateSqlCommand(connection, serviceAction); connection.Open(); using (cmd) { using (var adapter = new SqlDataAdapter(cmd)) { adapter.Fill(dataset); } } connection.Close(); } xmlData = DataSanitizerFactory.GenerateNewSanitizer(enSupportedDBTypes.MSSQL).SanitizePayload(dataset.GetXml()); } return xmlData; }
/// <summary> /// Determines whether a given <paramref name="serviceAction"/> should be advertised as bindable to the given <paramref name="resourceInstance"/>. /// </summary> /// <param name="operationContext">The data service operation context instance.</param> /// <param name="serviceAction">Service action to be advertised.</param> /// <param name="resourceInstance">Instance of the resource to which the service action is bound.</param> /// <param name="resourceInstanceInFeed">true if the resource instance to be serialized is inside a feed; false otherwise. The value true /// suggests that this method might be called many times during serialization since it will get called once for every resource instance inside /// the feed. If it is an expensive operation to determine whether to advertise the service action for the <paramref name="resourceInstance"/>, /// the provider may choose to always advertise in order to optimize for performance.</param> /// <param name="actionToSerialize">The <see cref="ODataAction"/> to be serialized. The server constructs /// the version passed into this call, which may be replaced by an implementation of this interface. /// This should never be set to null unless returning false.</param> /// <returns>true if the service action should be advertised; false otherwise.</returns> public virtual bool AdvertiseServiceAction(DataServiceOperationContext operationContext, ServiceAction serviceAction, object resourceInstance, bool resourceInstanceInFeed, ref ODataAction actionToSerialize) { return(true); }
//public dynamic Invoke(ServiceAction serviceAction, dynamic xmlRequest, string dataList) public Guid Invoke(ServiceAction serviceAction, IDSFDataObject dataObj, string dataList) { Guid result = GlobalConstants.NullDataListID; //TraceWriter.WriteTrace(_managementChannel, string.Format("Invoking service action '{0}' of Service '{1}'", serviceAction.Name, serviceAction.ServiceName??string.Empty), Resources.TraceMessageType_Message); switch(serviceAction.ActionType) { case enActionType.BizRule: //result = BizRule(serviceAction, xmlRequest); break; case enActionType.InvokeDynamicService: result = DynamicService(serviceAction, dataObj.DataListID); break; case enActionType.InvokeManagementDynamicService: result = ManagementDynamicService(serviceAction, dataObj); break; case enActionType.InvokeServiceMethod: break; case enActionType.InvokeStoredProc: switch(serviceAction.Source.Type) { case enSourceType.MySqlDatabase: //result = MySqlDatabase(serviceAction, xmlRequest); break; case enSourceType.SqlDatabase: result = SqlDatabaseCommand(serviceAction, dataObj); break; } break; case enActionType.InvokeWebService: //result = WebService(serviceAction, xmlRequest); break; case enActionType.Plugin: result = Plugin(serviceAction, dataObj); break; case enActionType.Switch: //result = Switch(serviceAction, xmlRequest); break; case enActionType.Workflow: result = WorkflowApplication(serviceAction, dataObj, dataList); break; } return result; }
/// <summary> /// Adds the <see cref="ServiceAction"/> to the list of service actions. /// </summary> /// <param name="action">the service action to be added.</param> /// <returns>the added service action.</returns> public ServiceAction AddAction(ServiceAction action) { return(this.AddServiceAction(action, null, null)); }
// PBI : 5376 - Broke this signature to avoid use ;) public dynamic Workflow(ServiceAction workflowAction, dynamic xmlRequest, int i) { dynamic returnVal = new UnlimitedObject(); IDictionary<string, object> inputs = new Dictionary<string, object>(); inputs.Add("AmbientDataList", new List<string> { xmlRequest.XmlString }); // ReSharper disable RedundantAssignment IDictionary<string, object> output = new Dictionary<string, object>(); // ReSharper restore RedundantAssignment var workflowInvoker = new WorkflowInvoker(workflowAction.WorkflowActivity); workflowInvoker.Extensions.Add(_dsfChannel); try { output = workflowInvoker.Invoke(inputs); foreach(var data in output) { if(data.Value != null) { if(data.Value is List<string>) { foreach(string result in (data.Value as List<string>)) { returnVal.AddResponse( UnlimitedObject.GetStringXmlDataAsUnlimitedObject(string.Format("<{0}>{1}</{0}>", Resources .DynamicService_ServiceResponseTag, result))); } } } else { returnVal = xmlRequest; } } } catch(WorkflowApplicationAbortedException workflowAbortedEx) { returnVal.Error = "Workflow Execution Was Aborted"; returnVal.ErrorDetail = new UnlimitedObject(workflowAbortedEx).XmlString; } catch(Exception workflowEx) { returnVal.Error = "Error occurred executing workflow"; returnVal.ErrorDetail = new UnlimitedObject(workflowEx).XmlString; } //ExceptionHandling.WriteEventLogEntry( // "Application", // string.Format("{0}.{1}", this.GetType().Name, "WorkflowCommand"), // string.Format("Exception:{0}\r\n", returnVal.XmlString), // EventLogEntryType.Error //); //if (returnVal.DSFResult is string) { // return UnlimitedObject.GetStringXmlDataAsUnlimitedObject(returnVal.DSFResult); //} //else { // if (returnVal.DSFResult is UnlimitedObject) { // if (!string.IsNullOrEmpty(returnVal.DSFResult.XmlString)) { // return returnVal.DSFResult; // } // } //} return returnVal; }
/// <summary> /// Constructs a delegate to invoke the service action with the provided parameters. /// </summary> /// <param name="operationContext">The data service operation context instance.</param> /// <param name="dataService">The data service instance.</param> /// <param name="action">The service action to invoke.</param> /// <param name="parameters">The parameters required to invoke the service action.</param> private void ConstructInvokeDelegateForServiceAction(DataServiceOperationContext operationContext, ServiceAction action, object[] parameters) { var info = action.CustomState as DSPServiceActionInfo; if (info == null) { throw new InvalidOperationException("Insufficient information to invoke the service action!"); } IDataServiceUpdateProvider2 updateProvider = (IDataServiceUpdateProvider2)operationContext.GetService(typeof(IDataServiceUpdateProvider2)); if (updateProvider == null) { throw new InvalidOperationException("DataServiceOperationContext.GetService(IDataServiceUpdateProvider2) returned null!"); } this.invokeDelegate = () => { int idx = 0; if (action.BindingParameter != null) { if (action.BindingParameter.ParameterType.ResourceTypeKind == ResourceTypeKind.EntityType) { parameters[idx] = updateProvider.GetResource((IQueryable)parameters[idx], null); } parameters[idx] = updateProvider.ResolveResource(parameters[idx]); idx++; } var methodParameters = info.Method.GetParameters(); for (; idx < parameters.Length; idx++) { ServiceActionParameter sap = action.Parameters[idx]; if (sap.ParameterType.ResourceTypeKind == ResourceTypeKind.Collection && parameters[idx] != null) { ResourceType itemResourceType = ((CollectionResourceType)sap.ParameterType).ItemType; // Need to call ResolveResource on each complex item in the collection. Type parameterType = methodParameters[idx].ParameterType; Type itemType = parameterType.GetGenericArguments()[0]; MethodInfo resolveCollectionMethod; if (parameterType.GetGenericTypeDefinition() == typeof(IQueryable <>)) { resolveCollectionMethod = DSPInvokableAction.ResolveCollectionAsQueryableMethodInfo.MakeGenericMethod(itemType); } else { resolveCollectionMethod = DSPInvokableAction.ResolveCollectionMethodInfo.MakeGenericMethod(itemType); } parameters[idx] = resolveCollectionMethod.Invoke(null, new object[] { updateProvider, parameters[idx], itemResourceType.ResourceTypeKind == ResourceTypeKind.Primitive }); } else if (sap.ParameterType.ResourceTypeKind == ResourceTypeKind.ComplexType) { parameters[idx] = updateProvider.ResolveResource(parameters[idx]); } } this.result = info.Method.Invoke(info.Instance, parameters); }; }
/// <summary> /// Invoke a Dynamic Service /// </summary> /// <param name="sa">The action of type InvokeDynamicService</param> /// <param name="dataListID">The data list ID.</param> /// <returns> /// UnlimitedObject /// </returns> public Guid DynamicService(ServiceAction sa, Guid dataListID) { ErrorResultTO errors; IDynamicServicesInvoker invoker = new DynamicServicesInvoker(); // Issue request with blank data payload return invoker.Invoke(sa.Service, (new UnlimitedObject()), dataListID, out errors); }
/// <summary> /// Tries to find the <see cref="ServiceAction"/> for the given <paramref name="serviceActionName"/>. /// </summary> /// <param name="operationContext">The data service operation context instance.</param> /// <param name="serviceActionName">The name of the service action to resolve.</param> /// <param name="serviceAction">Returns the service action instance if the resolution is successful; null otherwise.</param> /// <returns>true if the resolution is successful; false otherwise.</returns> public virtual bool TryResolveServiceAction(DataServiceOperationContext operationContext, string serviceActionName, out ServiceAction serviceAction) { this.InitializeServiceActions(operationContext); return(this.serviceActions.TryGetValue(serviceActionName, out serviceAction)); }
/// <summary> /// Invokes a plugin assembly /// </summary> /// <param name="plugin">The action of type Plugin</param> /// <param name="req">The req.</param> /// <param name="formatOutput">Indicates if the output of the plugin should be run through the formatter</param> /// <returns> /// Unlimited object /// </returns> public Guid Plugin(ServiceAction plugin, IDSFDataObject req, bool formatOutput) { Guid result = GlobalConstants.NullDataListID; Guid tmpID = GlobalConstants.NullDataListID; var errors = new ErrorResultTO(); var allErrors = new ErrorResultTO(); try { AppDomain tmpDomain = plugin.PluginDomain; //Instantiate the Remote Oject handler which will allow cross application domain access var remoteHandler = (RemoteObjectHandler) tmpDomain.CreateInstanceFromAndUnwrap(typeof(IFrameworkDataChannel).Module.Name, typeof(RemoteObjectHandler).ToString()); var dataBuilder = new StringBuilder("<Args><Args>"); foreach(ServiceActionInput sai in plugin.ServiceActionInputs) { dataBuilder.Append("<Arg>"); dataBuilder.Append("<TypeOf>"); dataBuilder.Append(sai.NativeType); dataBuilder.Append("</TypeOf>"); dataBuilder.Append("<Value>"); dataBuilder.Append(sai.Value); // Fetch value and assign dataBuilder.Append("</Value>"); dataBuilder.Append("</Arg>"); } dataBuilder.Append("</Args></Args>"); //xele.Value = (remoteHandler.RunPlugin(plugin.Source.AssemblyLocation, plugin.Source.AssemblyName, plugin.SourceMethod, data)); string exeValue = (remoteHandler.RunPlugin(plugin.Source.AssemblyLocation, plugin.Source.AssemblyName, plugin.SourceMethod, dataBuilder.ToString(), plugin.OutputDescription, formatOutput)); // TODO : Now create a new dataList and merge the result into the current dataList ;) string dlShape = ClientCompiler.ShapeDev2DefinitionsToDataList(plugin.ServiceActionOutputs, enDev2ArgumentType.Output, false, out errors); allErrors.MergeErrors(errors); tmpID = ClientCompiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML), exeValue, dlShape, out errors); ClientCompiler.SetParentID(tmpID, req.DataListID); // set parent for merge op in finally... allErrors.MergeErrors(errors); //Unload the temporary application domain //AppDomain.Unload(tmpDomain); -- throws exception when attempting to access after first unload?! -- A strange world C# / Winblows dev is } catch(Exception ex) { allErrors.AddError(ex.Message); } finally { // handle any errors that might have occured IBinaryDataListEntry be = Dev2BinaryDataListFactory.CreateEntry(enSystemTag.Error.ToString(), string.Empty); string error; be.TryPutScalar( Dev2BinaryDataListFactory.CreateBinaryItem(allErrors.MakeDataListReady(), enSystemTag.Error.ToString()), out error); errors.AddError(error); SvrCompiler.Upsert(null, req.DataListID, DataListUtil.BuildSystemTagForDataList(enSystemTag.Error, true), be, out errors); // now merge and delete tmp if(tmpID != GlobalConstants.NullDataListID) { // Travis.Frisinger - 29.01.2013 - Bug 8352 // We merge here since we never have the shape generated here in the request DL ;) Guid mergeID = ClientCompiler.Merge(req.DataListID, tmpID, enDataListMergeTypes.Union, enTranslationDepth.Data_With_Blank_OverWrite, false, out errors); if(mergeID == GlobalConstants.NullDataListID) { allErrors.AddError("Failed to merge data from Plugin Invoke"); allErrors.MergeErrors(errors); } //ClientCompiler.Shape(tmpID, enDev2ArgumentType.Output, plugin.ServiceActionOutputs, out errors); ClientCompiler.DeleteDataListByID(tmpID); result = req.DataListID; } } return result; }
/// <summary> /// Builds up an instance of <see cref="IDataServiceInvokable"/> for the given <paramref name="serviceAction"/> with the provided <paramref name="parameterTokens"/>. /// </summary> /// <param name="operationContext">The data service operation context instance.</param> /// <param name="serviceAction">The service action to invoke.</param> /// <param name="parameterTokens">The parameter tokens required to invoke the service action.</param> /// <returns>An instance of <see cref="IDataServiceInvokable"/> to invoke the action with.</returns> public virtual IDataServiceInvokable CreateInvokable(DataServiceOperationContext operationContext, ServiceAction serviceAction, object[] parameterTokens) { // This code is required by a test verifying that we can call GetQueryStringValue in an action provider method. var forceErrorValue = operationContext.GetQueryStringValue("Query-String-Header-Force-Error"); if (forceErrorValue == "yes") { throw new DataServiceException(418, "User code threw a Query-String-Header-Force-Error exception."); } return(new DSPInvokableAction(operationContext, serviceAction, parameterTokens, this.ServiceActionInvokeCallback, this.ServiceActionGetResultCallback)); }
public ServiceControlMessage() { Action = ServiceAction.NoOp; }
public RemoteWorkflowExecutionContainerMock(ServiceAction sa, IDSFDataObject dataObj, IWorkspace theWorkspace, IEsbChannel esbChannel, IResourceCatalog resourceCatalog) : base(sa, dataObj, theWorkspace, esbChannel, resourceCatalog) { }
public string BuildPost(ServiceAction action, string xmlNamesapce, object value, string commandParameter = "") { var stateString = string.Empty; foreach (var arg in action.ArgumentList) { if (arg.Direction == "out") continue; if (arg.Name == "InstanceID") stateString += BuildArgumentXml(arg, "0"); else stateString += BuildArgumentXml(arg, value.ToString(), commandParameter); } return string.Format(CommandBase, action.Name, xmlNamesapce, stateString); }
protected override IEnumerable <ServiceAction> LoadServiceActions(IDataServiceMetadataProvider dataServiceMetadataProvider) { ResourceType employeeType; dataServiceMetadataProvider.TryResolveResourceType("Microsoft.Test.OData.Services.AstoriaDefaultService.Employee", out employeeType); ResourceType computerDetailType; dataServiceMetadataProvider.TryResolveResourceType("Microsoft.Test.OData.Services.AstoriaDefaultService.ComputerDetail", out computerDetailType); ResourceType computerType; dataServiceMetadataProvider.TryResolveResourceType("Microsoft.Test.OData.Services.AstoriaDefaultService.Computer", out computerType); ResourceType customerType; dataServiceMetadataProvider.TryResolveResourceType("Microsoft.Test.OData.Services.AstoriaDefaultService.Customer", out customerType); ResourceType auditInfoType; dataServiceMetadataProvider.TryResolveResourceType("Microsoft.Test.OData.Services.AstoriaDefaultService.AuditInfo", out auditInfoType); ResourceSet computerSet; dataServiceMetadataProvider.TryResolveResourceSet("Computer", out computerSet); var increaseSalaryAction = new ServiceAction( "IncreaseSalaries", null, null, OperationParameterBindingKind.Always, new[] { new ServiceActionParameter("employees", ResourceType.GetEntityCollectionResourceType(employeeType)), new ServiceActionParameter("n", ResourceType.GetPrimitiveResourceType(typeof(int))), }); increaseSalaryAction.SetReadOnly(); yield return(increaseSalaryAction); var sackEmployeeAction = new ServiceAction( "Sack", null, null, OperationParameterBindingKind.Always, new[] { new ServiceActionParameter("employee", employeeType), }); sackEmployeeAction.SetReadOnly(); yield return(sackEmployeeAction); var getComputerAction = new ServiceAction( "GetComputer", computerType, computerSet, OperationParameterBindingKind.Always, new[] { new ServiceActionParameter("computer", computerType) }); getComputerAction.SetReadOnly(); yield return(getComputerAction); var changeCustomerAuditInfoAction = new ServiceAction( "ChangeCustomerAuditInfo", null, null, OperationParameterBindingKind.Always, new[] { new ServiceActionParameter("customer", customerType), new ServiceActionParameter("auditInfo", auditInfoType), }); changeCustomerAuditInfoAction.SetReadOnly(); yield return(changeCustomerAuditInfoAction); var resetComputerDetailsSpecificationsAction = new ServiceAction( "ResetComputerDetailsSpecifications", null, null, OperationParameterBindingKind.Always, new[] { new ServiceActionParameter("computerDetail", computerDetailType), new ServiceActionParameter("specifications", ResourceType.GetCollectionResourceType(ResourceType.GetPrimitiveResourceType(typeof(string)))), new ServiceActionParameter("purchaseTime", ResourceType.GetPrimitiveResourceType(typeof(DateTime))) }); resetComputerDetailsSpecificationsAction.SetReadOnly(); yield return(resetComputerDetailsSpecificationsAction); }
public string BuildPost(ServiceAction action, string xmlNamesapce, object value, Dictionary<string, string> dictionary) { var stateString = string.Empty; foreach (var arg in action.ArgumentList) { if (arg.Name == "InstanceID") stateString += BuildArgumentXml(arg, "0"); else if (dictionary.ContainsKey(arg.Name)) stateString += BuildArgumentXml(arg, dictionary[arg.Name]); else stateString += BuildArgumentXml(arg, value.ToString()); } return string.Format(CommandBase, action.Name, xmlNamesapce, stateString); }
/// <summary> /// Adds the <see cref="CDrivePathProvider"/> implementation of <see cref="ICDrivePathProvider"/> as a <see cref="ServiceLifetime.Singleton"/>. /// </summary> public static ServiceAction <ICDrivePathProvider> AddDefaultCDrivePathProviderAction(this IServiceCollection services, ServiceAction <ICDriveNameConvention> addCDriveNameConvention) { var serviceAction = new ServiceAction <ICDrivePathProvider>(() => services.AddDefaultCDrivePathProvider( addCDriveNameConvention)); return(serviceAction); }
/// <summary> /// Adds the <see cref="OSPlatformProvider"/> implementation of <see cref="IOSPlatformProvider"/> as a <see cref="ServiceLifetime.Singleton"/>. /// </summary> public static IServiceAction <IOSPlatformProvider> AddOSPlatformProviderAction(this IServiceCollection services) { var serviceAction = ServiceAction.New <IOSPlatformProvider>(() => services.AddOSPlatformProvider()); return(serviceAction); }
/// <summary> /// Adds the <see cref="StringlyTypedPathOperator"/> implementation of <see cref="IStringlyTypedPathOperator"/> as a <see cref="ServiceLifetime.Singleton"/>. /// </summary> public static IServiceAction <IStringlyTypedPathOperator> AddDefaultStringlyTypedPathOperatorAction(this IServiceCollection services) { var serviceAction = new ServiceAction <IStringlyTypedPathOperator>(() => services.AddDefaultStringlyTypedPathOperator()); return(serviceAction); }