Пример #1
0
        /// <summary>
        /// Adds the integration service generic method.
        /// </summary>
        /// <param name="assemblyCode">
        /// The assembly code.
        /// </param>
        /// <param name="process">
        /// The process.
        /// </param>
        /// <param name="service">
        /// The service.
        /// </param>
        /// <param name="method">
        /// The method.
        /// </param>
        private void AddIntegrationServiceGenericMethod(
            StringBuilder assemblyCode,
            IProcessDefinition process,
            IntegrationServiceDefinition service,
            IntegrationServiceMethodDefinition method)
        {
            var parametersString = new StringBuilder("Cebos.Veyron.SharedTypes.Integration.ActionType action");
            var callParametersString = new StringBuilder("action");
            
            if (method.Parameters.Any())
            {
                parametersString.AppendFormat(", {0}", GetMethodParameters(method));
                callParametersString.AppendFormat(", {0}", GetMethodCallParameters(method));
            }

            assemblyCode.AppendFormat(
                @"
        [System.Web.Services.WebMethodAttribute]
        [System.Web.Services.Protocols.SoapHeaderAttribute(""Credentials"")]
        {3}
        {4}
        public {5} @{0}({1})
        {{
            var result = {0}Internal({2});
",
                method.Name,
                parametersString,
                callParametersString,
                GetSoapDocumentMethodAttribute(method),
                GetSoapExtensionAttribute(process, service),
                GetIntegrationServiceMethodReturnType(method));

            AddIntegrationServiceMethodReturn(assemblyCode, method);

            assemblyCode.AppendFormat(@"
        }}
");
        }
Пример #2
0
 private string GetSoapExtensionAttribute(IProcessDefinition process, IntegrationServiceDefinition service)
 {
     return string.Format(
         "[Cebos.Veyron.SharedTypes.Integration.LogIntegrationEventExtensionAttribute({0}, {1})]",
         process.DisplayName.ToLiteral(),
         service.ServiceName.ToLiteral());
 }
Пример #3
0
        /// <summary>
        /// Adds the integration service class.
        /// </summary>
        /// <param name="assemblyCode">The assembly code.</param>
        /// <param name="process">The process.</param>
        /// <param name="service">The service.</param>
        private void AddIntegrationServiceClass(StringBuilder assemblyCode, IProcessDefinition process, IntegrationServiceDefinition service)
        {
            assemblyCode.AppendFormat(@"
    [System.Web.Services.WebServiceAttribute(Namespace = {1})]
    public class @{0} : System.Web.Services.WebService
    {{
        private Cebos.Veyron.SharedTypes.Integration.IIntegrationServiceMethodFactory _methodFactory;

        private Cebos.Veyron.SharedTypes.Integration.IIntegrationServiceMethodFactory MethodFactory
        {{
            get
            {{
                return _methodFactory ?? (_methodFactory = Cebos.Veyron.SharedTypes.MEF.Ioc.GetExportedValue<Cebos.Veyron.SharedTypes.Integration.IIntegrationServiceMethodFactory>());
            }}
        }}

        private Cebos.Veyron.SharedTypes.Logging.ILogger _logger;

        private Cebos.Veyron.SharedTypes.Logging.ILogger Logger
        {{
            get
            {{
                return _logger ?? (_logger = Cebos.Veyron.SharedTypes.MEF.Ioc.GetExportedValue<Cebos.Veyron.SharedTypes.Logging.ILogger>());
            }}
        }}

        public Cebos.Veyron.SharedTypes.Integration.CredentialsHeader Credentials;

        private void CheckCredentials(string username, string password)
        {{
            if (Credentials == null || Credentials.Username != username || Credentials.Password != password)
                throw new System.Security.SecurityException(""Authentication failed."");
        }}

", service.ServiceName, service.Namespace.ToLiteral());

            foreach (var type in service.Types)
                AddIntegrationServiceType(assemblyCode, type);

            foreach (var method in service.Methods)
            {
                AddIntegrationServiceMethodRequestType(assemblyCode, method);
            }

            foreach (var method in service.Methods)
            {
                assemblyCode.AppendFormat(@"
        private Cebos.Veyron.SharedTypes.Integration.IIntegrationServiceMethod _{0}Method;

        private Cebos.Veyron.SharedTypes.Integration.IIntegrationServiceMethod {0}Method
        {{
            get
            {{
                return _{0}Method ?? (_{0}Method = MethodFactory.CreateMethod(Get{0}Definition()));
            }}
        }}
", method.Name);

                AddMethodDefinition(assemblyCode, process, method);
                AddIntegrationServiceInternalMethod(assemblyCode, method);
                AddIntegrationServiceGenericMethod(assemblyCode, process, service, method);

                if (method.CanInsert)
                    AddIntegrationServiceActionSpecificMethod(assemblyCode, process, service, method, ActionType.Insert);

                if (method.CanUpdate)
                    AddIntegrationServiceActionSpecificMethod(assemblyCode, process, service, method, ActionType.Update);

                if (method.CanInsertOrUpdate)
                    AddIntegrationServiceActionSpecificMethod(assemblyCode, process, service, method, ActionType.InsertOrUpdate);

                if (method.CanRemove)
                    AddIntegrationServiceActionSpecificMethod(assemblyCode, process, service, method, ActionType.Remove);

                if (method.CanSelect)
                    AddIntegrationServiceActionSpecificMethod(assemblyCode, process, service, method, ActionType.Select);
            }

            assemblyCode.AppendFormat(@"
    }}
");
        }