首页 文章 精选 留言 我的

精选列表

搜索[快速入门],共10000篇文章
优秀的个人博客,低调大师

Rafy 领域实体框架演示(3) - 快速使用 C/S 架构部署

前言 截止到上一篇,我们开发的应用程序都是采用直接连接数据库的模式: 接下来,将通过一些简单的调整,使得这个应用程序支持以 C/S 架构部署。整个过程只需要少量的代码: 包含以下步骤: 添加服务端控制台应用程序项目 修改客户端应用程序连接方式 配置客户端应用程序 运行示例 代码下载 添加服务端控制台应用程序项目 在整个解决方案中添加一个新的控制台应用程序,取名为 ServerConsole: 为项目添加所有 Rafy 程序集、CS 实体程序集以及 System.ServiceModel 程序集的引用: 在 Main 函数中添加以下代码,启动服务端领域项目,并开始监听 WCF 端口: 1: using System; 2: using System.Collections.Generic; 3: using System.Linq; 4: using System.ServiceModel; 5: using System.Text; 6: using CS; 7: using Rafy; 8: using Rafy.Domain; 9: 10: namespace ServerConsole 11: { 12: class Program 13: { 14: static void Main(string[] args) 15: { 16: PluginTable.DomainLibraries.AddPlugin<CSPlugin>(); 17: new DomainApp().Startup(); 18: 19: using (ServiceHost serviceHost = new ServiceHost(typeof(Rafy.DataPortal.WCF.ServerPortal))) 20: { 21: serviceHost.Open(); 22: Console.WriteLine("Press <enter> to terminate service"); 23: Console.ReadLine(); 24: serviceHost.Close(); 25: } 26: } 27: } 28: } 然后,为本项目添加应用程序配置文件 App.config,代码如下: 1: <?xml version="1.0" encoding="utf-8" ?> 2: <configuration> 3: <appSettings> 4: <add key="SQL_TRACE_FILE" value="D:\SQLTraceLog.txt"/> 5: </appSettings> 6: <connectionStrings> 7: <add name="CS" connectionString="server=.\SQLExpress;database=ClothesSys;uid=sa;pwd=GIX4" providerName="System.Data.SqlClient"/> 8: </connectionStrings> 9: <system.serviceModel> 10: <services> 11: <service name="Rafy.DataPortal.WCF.ServerPortal" behaviorConfiguration="includesException"> 12: <endpoint address="/Text" binding="basicHttpBinding" contract="Rafy.DataPortal.WCF.IWcfPortal"/> 13: <host> 14: <baseAddresses> 15: <add baseAddress="http://localhost:8000/RafyServer" /> 16: </baseAddresses> 17: </host> 18: </service> 19: </services> 20: <behaviors> 21: <serviceBehaviors> 22: <behavior name="includesException"> 23: <serviceMetadata httpGetEnabled="true" /> 24: <serviceDebug includeExceptionDetailInFaults="true" /> 25: </behavior> 26: </serviceBehaviors> 27: </behaviors> 28: </system.serviceModel> 29: </configuration> 修改客户端应用程序连接方式 接下来需要把界面程序变更为连接服务端。打开 ClothesSys 项目中的 Program.cs 文件,修改为以下代码: 1: static class Program 2: { 3: /// <summary> 4: /// 应用程序的主入口点。 5: /// </summary> 6: [STAThread] 7: static void Main() 8: { 9: PluginTable.DomainLibraries.AddPlugin<CSPlugin>(); 10: new ClientDomainApp().Startup(); 11: 12: Application.EnableVisualStyles(); 13: Application.SetCompatibleTextRenderingDefault(false); 14: Application.Run(new formLogin()); 15: } 16: } 17: 18: /// <summary> 19: /// 客户端使用的应用程序类型。 20: /// </summary> 21: public class ClientDomainApp : DomainApp 22: { 23: protected override void InitEnvironment() 24: { 25: RafyEnvironment.Location.DataPortalMode = DataPortalMode.ThroughService; 26: 27: base.InitEnvironment(); 28: } 29: } RafyEnvironment.Location.DataPortalMode 表示连接数据的模式,默认值是DataPortalMode.ConnectDirectly(直接连接数据库),ClientDomainApp 类把该值变更为 DataPortalMode. ThroughService(通过服务连接数据)。 配置客户端应用程序 在客户端配置文件中,删除数据库连接配置,并添加 WCF 连接配置,如下: 1: <?xml version="1.0"?> 2: <configuration> 3: <configSections> 4: <section name="rafy" type="Rafy.Configuration.RafyConfigurationSection, Rafy" /> 5: </configSections> 6: <rafy 7: dataPortalProxy="Rafy.DataPortal.WCF.ClientProxy, Rafy.Domain" 8: collectDevLanguages="IsDebugging"> 9: </rafy> 10: <system.serviceModel> 11: <client> 12: <endpoint name="ClientProxyEndPoint" address="http://localhost:8000/RafyServer/Text" 13: binding="basicHttpBinding" bindingConfiguration="basicHttpBindingConfig" 14: contract="Rafy.DataPortal.WCF.IWcfPortal" /> 15: </client> 16: <bindings> 17: <basicHttpBinding> 18: <binding name="basicHttpBindingConfig" receiveTimeout="00:20:00" sendTimeout="02:00:00" maxReceivedMessageSize="1000000000"> 19: <readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384"/> 20: </binding> 21: </basicHttpBinding> 22: </bindings> 23: </system.serviceModel> 24: </configuration> 运行程序 先运行 ServerConsole,成功运行界面: 再运行 ClothesSys,点击登录。登录成功,即说明已经成功使用 C/S 进行部署。 代码下载 下载地址:http://pan.baidu.com/s/1AB9TL 本文的代码在“3.使用 CS 部署程序”文件夹中。 本文转自BloodyAngel博客园博客,原文链接:http://www.cnblogs.com/zgynhqf/p/3421517.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

iOS-三步快速集成社交化分享工具ShareSDK

1.前言 作为现在App里必不可少的用户分享需要,社交化分享显然是我们开发app里较为常用的。 最近因为公司App有社交化分享的需要,就特此研究了会,拿出来与大家分享。 想要集成社交会分享,我们可以使用 ShareSDK - 优点功能丰富,缺点体积较大 百度分享SDK - 缺点功能相对ShareSDK较少,优点体积较小 这是现在较为常用的两种社交化分享工具。 使用哪一种,就看个人的app的需要来决定了。 今天我主要说的是ShareSDK的简单集成和使用。 2.集成前的准备工作 2.1. 拿自己的Appkey 去下载ShareSDK 下载地址:http://sharesdk.cn/Download 2.2. 申请分享工具的Appkey 例如: 新浪微博、 腾讯微博、豆瓣应用、人人网、QQ空间 去各大社交网站的开发者平台,进行注册申请即可。 获取如下: //新浪微博: //App Key:2258477553 //App Secret:1e2f275afc375109e456f550fb3918e8 //腾讯微博: //App key:2620460989 //App secret:58c55f572d5ae35e0c355f4c0ee11283 3.集成ShareSDK 3.1.注册使用ShareSDK - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { //注册ShareSDK [ShareSDK registerApp:@"1983bf0916db”]; return YES; } 3.2.添加要集成的分享平台 注意: 新浪微博需要提供回调地址才行 回调地址去新浪开发者平台获取 如图: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { //注册ShareSDK [ShareSDK registerApp:@"1983bf0916db”]; //添加新浪微博应用 [ShareSDK connectSinaWeiboWithAppKey:@"2620460989" appSecret:@"58c55f572d5ae35e0c355f4c0ee11283" redirectUri:@"http://weibo.cn/ext/share?ru=http%3A%2F%2F16kxs.com%2Fwap%2FBook%2FShow.aspx%3Fid%3D7983%26lmid%3D0%26uid%3D0%26ups%3D0&rt=%E9%83%BD%E5%B8%82%E7%89%A7%E9%AC%BC%E4%BA%BA&st=1301645308&appkey=2620460989”]; //添加腾讯微博应用 [ShareSDK connectTencentWeiboWithAppKey:@"801307650" appSecret:@"ae36f4ee3946e1cbb98d6965b0b2ff5c" redirectUri:@"http://www.sharesdk.cn"]; //添加豆瓣应用 [ShareSDK connectDoubanWithAppKey:@"07d08fbfc1210e931771af3f43632bb9" appSecret:@"e32896161e72be91" redirectUri:@"http://dev.kumoway.com/braininference/infos.php"]; //添加人人网应用 [ShareSDK connectRenRenWithAppKey:@"fc5b8aed373c4c27a05b712acba0f8c3" appSecret:@"f29df781abdd4f49beca5a2194676ca4"]; //添加Facebook应用 [ShareSDK connectFacebookWithAppKey:@"107704292745179" appSecret:@"38053202e1a5fe26c80c753071f0b573"]; } 3.3.弹出分享View a.初始化默认分享内容 NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"123" ofType:@"png"]; //构建优秀的SDK //构造分享内容 id<ISSContent> publishContent = [ShareSDK content:@"iOS社交化分享测试内容。" defaultContent:@"默认分享内容,没内容时显示" image:[ShareSDK imageWithPath:imagePath] title:@"ShareSDK" url:@"http://www.sharesdk.cn" description:@"这是一条测试信息" mediaType:SSPublishContentMediaTypeNews]; b.弹出分享View [ShareSDK showShareActionSheet:nil shareList:nil content:publishContent statusBarTips:YES authOptions:nil shareOptions: nil result:^(ShareType type, SSResponseState state, id<ISSPlatformShareInfo> statusInfo, id<ICMErrorInfo> error, BOOL end) { if (state == SSResponseStateSuccess) { NSLog(@"分享成功"); } else if (state == SSResponseStateFail) { NSLog(@"分享失败,错误码:%d,错误描述:%@", [error errorCode], [error errorDescription]); } }]; 效果图: 最新内容请见作者的GitHub页:http://qaseven.github.io/

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册