当前位置: 首页>>代码示例>>C#>>正文


C# ICommunicationContext.Send方法代码示例

本文整理汇总了C#中ICommunicationContext.Send方法的典型用法代码示例。如果您正苦于以下问题:C# ICommunicationContext.Send方法的具体用法?C# ICommunicationContext.Send怎么用?C# ICommunicationContext.Send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICommunicationContext的用法示例。


在下文中一共展示了ICommunicationContext.Send方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessRequest

        public override void ProcessRequest(ICommunicationContext ctx)
        {
            var uriString = ctx.Request.Uri.OriginalString;

            if(uriString.IndexOf("wwwroot", StringComparison.InvariantCultureIgnoreCase) < 0)
            {
                // http://127.0.0.1:1234/services/"/themes/system/js/json2.js"
                new WebGetRequestHandler().ProcessRequest(ctx);
                return;
            }

            var website = GetWebsite(ctx);
            var path = GetPath(ctx);
            var extension = Path.GetExtension(uriString);

            if(string.IsNullOrEmpty(extension))
            {
                //
                // REST request e.g. http://localhost:1234/wwwroot/sources/server
                //
                const string ContentToken = "getParameterByName(\"content\")";

                var layoutFilePath = string.Format("{0}\\webs\\{1}\\layout.htm", Location, website);
                var contentPath = string.Format("\"/{0}/views/{1}.htm\"", website, path);

                ctx.Send(new DynamicFileResponseWriter(layoutFilePath, ContentToken, contentPath));
                return;
            }

            // Should get url's with the following signatures
            //
            // http://localhost:1234/wwwroot/sources/Scripts/jquery-1.7.1.js
            // http://localhost:1234/wwwroot/sources/Content/Site.css
            // http://localhost:1234/wwwroot/sources/images/error.png
            // http://localhost:1234/wwwroot/sources/Views/Dialogs/SaveDialog.htm
            // http://localhost:1234/wwwroot/views/sources/server.htm
            //
            // We support only 1 level below the Views folder 
            // If path is a string without a backslash then we are processing the following request
            //       http://localhost:1234/wwwroot/views/sources/server.htm
            // If path is a string with a backslash then we are processing the following request
            //       http://localhost:1234/wwwroot/sources/Views/Dialogs/SaveDialog.htm
            //
            if(!string.IsNullOrEmpty(path) && path.IndexOf('/') == -1)
            {
                uriString = uriString.Replace(path, "");
            }

            var result = GetFileFromPath(new Uri(uriString));

            ctx.Send(result);
        }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:52,代码来源:WebsiteResourceHandler.cs

示例2: ProcessRequest

        public override void ProcessRequest(ICommunicationContext ctx)
        {
            var postDataListID = GetDataListID(ctx);
            if(postDataListID != null)
            {
                new WebPostRequestHandler().ProcessRequest(ctx);
                return;
            }

            var serviceName = GetServiceName(ctx);
            var workspaceID = GetWorkspaceID(ctx);

            var requestTO = new WebRequestTO { ServiceName = serviceName, WebServerUrl = ctx.Request.Uri.ToString(), Dev2WebServer = String.Format("{0}://{1}", ctx.Request.Uri.Scheme, ctx.Request.Uri.Authority) };
            var data = GetPostData(ctx);

            if(!String.IsNullOrEmpty(data))
            {
                requestTO.RawRequestPayload = data;
            }
            var variables = ctx.Request.BoundVariables;
            if(variables != null)
            {
                foreach(string key in variables)
                {
                    requestTO.Variables.Add(key, variables[key]);
                }
            }
            // Execute in its own thread to give proper context ;)
            Thread.CurrentPrincipal = ctx.Request.User;

            var responseWriter = CreateForm(requestTO, serviceName, workspaceID, ctx.FetchHeaders());
            ctx.Send(responseWriter);
        }
开发者ID:ndubul,项目名称:Chillas,代码行数:33,代码来源:WebGetRequestHandler.cs

示例3: ProcessRequest

        public override void ProcessRequest(ICommunicationContext ctx)
        {
            var serviceName = GetServiceName(ctx);
            var instanceId = GetInstanceID(ctx);
            var bookmark = GetBookmark(ctx);
            var postDataListID = GetDataListID(ctx);
            var workspaceID = GetWorkspaceID(ctx);

            var requestTO = new WebRequestTO();
            var xml = GetPostData(ctx, postDataListID);

            if(!String.IsNullOrEmpty(xml))
            {
                requestTO.RawRequestPayload = xml;
            }

            requestTO.ServiceName = serviceName;
            requestTO.InstanceID = instanceId;
            requestTO.Bookmark = bookmark;
            requestTO.WebServerUrl = ctx.Request.Uri.ToString();
            requestTO.Dev2WebServer = String.Format("{0}://{1}", ctx.Request.Uri.Scheme, ctx.Request.Uri.Authority);


            // Execute in its own thread to give proper context ;)
            Thread.CurrentPrincipal = ctx.Request.User;

            var responseWriter = CreateForm(requestTO, serviceName, workspaceID, ctx.FetchHeaders(), PublicFormats, ctx.Request.User);
            ctx.Send(responseWriter);

        }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:30,代码来源:WebPostRequestHandler.cs

示例4: ProcessRequest

 public override void ProcessRequest(ICommunicationContext ctx)
 {
     if(ctx == null)
     {
         throw new ArgumentNullException("ctx");
     }
     var basePath = ctx.Request.BoundVariables["path"];
     var result = GetApisJson(basePath);
     
     ctx.Send(result);
 }
开发者ID:ndubul,项目名称:Chillas,代码行数:11,代码来源:GetApisJsonServiceHandler.cs

示例5: ProcessRequest

        public override void ProcessRequest(ICommunicationContext ctx)
        {
            var serviceName = GetServiceName(ctx);
            var instanceId = GetInstanceID(ctx);
            var bookmark = GetBookmark(ctx);
            GetDataListID(ctx);
            var workspaceID = GetWorkspaceID(ctx);
            var formData = new WebRequestTO();

            var xml = GetPostData(ctx);

            if(!String.IsNullOrEmpty(xml))
            {
                formData.RawRequestPayload = xml;
            }

            formData.ServiceName = serviceName;
            formData.InstanceID = instanceId;
            formData.Bookmark = bookmark;
            formData.WebServerUrl = ctx.Request.Uri.ToString();
            formData.Dev2WebServer = String.Format("{0}://{1}", ctx.Request.Uri.Scheme, ctx.Request.Uri.Authority);

            if(ExecutingUser == null)
            {
                throw new Exception("Null Executing User");
            }

            try
            {
                // Execute in its own thread to give proper context ;)
                var t = new Thread(() =>
                {
                    Thread.CurrentPrincipal = ExecutingUser;

                    var responseWriter = CreateForm(formData, serviceName, workspaceID, ctx.FetchHeaders(),ctx.Request.User);
                    ctx.Send(responseWriter);
                });

                t.Start();

                t.Join();
            }
            catch(Exception e)
            {
                // ReSharper disable InvokeAsExtensionMethod
                Dev2Logger.Log.Error(this, e);
                // ReSharper restore InvokeAsExtensionMethod
            }
        }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:49,代码来源:InternalServiceRequestHandler.cs

示例6: ProcessRequest

 public override void ProcessRequest(ICommunicationContext ctx)
 {
     if(ctx == null)
     {
         throw new ArgumentNullException("ctx");
     }
     var basePath = ctx.Request.BoundVariables["path"];
     bool isPublic;
     if (!bool.TryParse(ctx.Request.BoundVariables["isPublic"], out isPublic))
     {
         isPublic = false;
     }
     var result = GetApisJson(basePath,isPublic);
     
     ctx.Send(result);
 }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:16,代码来源:GetApisJsonServiceHandler.cs

示例7: ProcessRequest

        public override void ProcessRequest(ICommunicationContext ctx)
        {
            // Read post data which is expected to be JSON
            string args;
            using(var reader = new StreamReader(ctx.Request.InputStream, ctx.Request.ContentEncoding))
            {
                args = reader.ReadToEnd();
            }

            var className = GetClassName(ctx);
            var methodName = GetMethodName(ctx);
            var dataListID = GetDataListID(ctx);
            var workspaceID = GetWorkspaceID(ctx);
            dynamic result;
            try
            {
                Guid workspaceGuid;
                Guid.TryParse(workspaceID, out workspaceGuid);

                Guid dataListGuid;
                Guid.TryParse(dataListID, out dataListGuid);

                //
                // NOTE: result.ToString() MUST return JSON
                //

                // Ensure we execute as the correct user ;)
                var userPrinciple = ctx.Request.User;
                if(userPrinciple != null)
                {
                    Thread.CurrentPrincipal = userPrinciple;
                    Dev2Logger.Log.Info("WEB EXECUTION USER CONTEXT [ " + userPrinciple.Identity.Name + " ]");
                }

                result = _serviceInvoker.Invoke(className, methodName, args, workspaceGuid, dataListGuid);
            }
            catch(Exception ex)
            {
                result = new ValidationResult
                {
                    ErrorMessage = ex.Message
                };
            }
            ctx.Send(new StringResponseWriter(result.ToString(), ContentTypes.Json));
        }
开发者ID:ndubul,项目名称:Chillas,代码行数:45,代码来源:WebsiteServiceHandler.cs

示例8: ProcessRequest

        public override void ProcessRequest(ICommunicationContext ctx)
        {
            // Read post data which is expected to be JSON
            string args;
            using(var reader = new StreamReader(ctx.Request.InputStream, ctx.Request.ContentEncoding))
            {
                args = reader.ReadToEnd();
            }

            var className = GetClassName(ctx);
            var methodName = GetMethodName(ctx);
            var dataListID = GetDataListID(ctx);
            var workspaceID = GetWorkspaceID(ctx);
            dynamic result = null;
            var userPrinciple = ctx.Request.User;
            Thread.CurrentPrincipal = userPrinciple;
              
            try
            {
                Guid workspaceGuid;
                Guid.TryParse(workspaceID, out workspaceGuid);

                Guid dataListGuid;
                Guid.TryParse(dataListID, out dataListGuid);

                
                Thread.CurrentPrincipal = userPrinciple;
                Dev2Logger.Log.Info("WEB EXECUTION USER CONTEXT [ " + userPrinciple.Identity.Name + " ]");
                Common.Utilities.PerformActionInsideImpersonatedContext(userPrinciple, () => { result = _serviceInvoker.Invoke(className, methodName, args, workspaceGuid, dataListGuid); });
                

            }
            catch(Exception ex)
            {
                result = new ValidationResult
                {
                    ErrorMessage = ex.Message
                };
            }
            if(result != null)
            {
                ctx.Send(new StringResponseWriter(result.ToString(), ContentTypes.Json));
            }
        }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:44,代码来源:WebsiteServiceHandler.cs

示例9: ProcessRequest

        public override void ProcessRequest(ICommunicationContext ctx)
        {
            var result = GetFileFromPath("warewolf-Server.log");

            ctx.Send(result);
        }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:6,代码来源:GetLogFileServiceHandler.cs


注:本文中的ICommunicationContext.Send方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。