posts - 69, comments - 46, trackbacks - 0, articles - 1
  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理

公告

2011年11月20日

创建WCF服务器
1.新建控制台程序
2.添加接口及成员方法,接口要以 [serviceContract]来修饰,[OperationContract]来修饰方法
3.添加服务提供类来实现WCF服务接口
4.添加
   using(var host=new ServiceHost(typeof(服务提供类) ) )
   {
host.Open():
Console.WriteLine("The WCF Service is running! if you want to stop the service,press any key.");
Console.Read();
   }
5,添加app.config   
6,编译
6.打开WCF 配置工具来进行配置,打开新增的app.config
7.使用Create a New Service。。。向导
7.1 Service Type 选择当前生成的DLL及服务提供类
7.2 Contract 服务提供类的接口,默认会选择一个
7.3 WCF的通信方式 默认HTTP
7.4 HTTP的通信方式 默认即可
7.5 Address http://localhost:8003/s1  随便写即可
7.6 完成
8 选择已添加的服务的Host, 添加BaseAddress  http://localhost:8003/s1
9. 添加 meta服务
9.1 点击Adanced->Service Behaviors->点击 New Service Behavior configuration
9.2 出现NewBehavior0,点击 Add...按钮,选择 serviceMetadata,点击 Add按钮
9.3 双击 serviceMetadata
9.4 将HttpGetenabled设置为true.这样添加Service 引用的时候或者 http://localhost:8003/s1?wsdl才可以有效。
10.将服务与服务行为绑定起来,再点击服务 选择行为配置为NewBehavior0,保存
11. 如果WCF宿主在VISTA或者WIN7下面,须用ADMINISTRATOR运行

posted @ 2011-11-20 00:51 God Blue Shadow 阅读(10) 评论(0) 编辑

2008年9月16日

修改select  的selectedValue或者selectedIndex或者两者,在服务器端还是默认的选择项,想想可能与元素的selected有关,试了一下,果然如此。

aspx代码如此:

 

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="txtTest" runat="server"></asp:TextBox>
        <asp:DropDownList ID="ddlTest" runat="server">
        <asp:ListItem Text="1" Value="1" Selected="true"></asp:ListItem>
        <asp:ListItem Text="2" Value="1" ></asp:ListItem>
        <asp:ListItem Text="3" Value="1"></asp:ListItem>
        <asp:ListItem Text="4" Value="4"></asp:ListItem>
        <asp:ListItem Text="5" Value="5"></asp:ListItem>
        <asp:ListItem Text="6" Value="6"></asp:ListItem>       
        </asp:DropDownList>
        <script type="text/C#" runat="server">
            private void foo()
            {
                btnReturn.Click += new EventHandler(btnReturn_Click);               
            }
        </script>
        <script type="text/javascript">
        var txt = document.getElementById("<%=txtTest.ClientID %>");
        txt.value = "asdfsdf";
        var ddl =document.getElementById("<%=ddlTest.ClientID %>");
              
       ddlSelByValue( ddl,1,0);
      
        function ddlSelByIndex( ddl, index )
        {
         var selIndex = -1;
         // check
         if( ddl.length < 1 )
         {
            return;
         }
         if( index >= ddl.length )
         {
            return;
         }
        
         for(var i=0;i<ddl.length;i++)
         {
            if( ddl[i].selected == true )
            {
                selIndex  =i;
                break;
            }
         }
        
         if( selIndex != -1 )
         {
            ddl[selIndex].selected = false;
         }        
         ddl[index].selected = true;
        }
      
        function ddlSelByValue( ddl , value ,order)
        {
            // check
            if( ddl == undefined )
            {
                return;
            }
            if( value == undefined)
            {
                return;
            }
            if ( order == undefined )
            {
               order = 0;
            }
            if( order < 0 )
            {
                return;
            }
           
           var selIndex = -1;
           var index4Value =[];
        
         // get current selectedIndex and indexs for match the input value
         for(var i=0;i<ddl.length;i++)
         {
            if( ddl[i].selected == true )
            {
                selIndex  =i;
            }
            if( ddl[i].value == value )
            {
              index4Value.push(i);             
            }
         }
        
         // process
         if( index4Value == undefined || index4Value.length < 1 )
         {
            return;
         }        
         if( order >=  index4Value.length )
         {
            return;
         }        
         if( selIndex != -1 && selIndex == index4Value[order])
         { 
            return;
         }
        
         ddl[ selIndex ].selected = false;        
         ddl[ index4Value[order] ].selected = true;        
        }
        </script>
       
        <asp:Button ID="btnReturn" runat="server" Text="return" OnClick="btnReturn_Click" />
    </div>
    </form>
</body>
</html>
CS代码如下:

 

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

 }
 protected void btnReturn_Click(object sender, EventArgs e)
 {
  this.Request.SaveAs("c:\\a.txt", true);
 }
}

打开C:\a.txt,我们将会看到以下内容:

 

POST /WebSite1/Default.aspx HTTP/1.1
Cache-Control: no-cache
Connection: Keep-Alive
Content-Length: 254
Content-Type: application/x-www-form-urlencoded
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*
Accept-Encoding: gzip, deflate
Accept-Language: zh-cn
Host: localhost:1230
Referer: http://localhost:1230/WebSite1/Default.aspx
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)

__VIEWSTATE=%2FwEPDwUKLTgxOTUxNjU1N2RkD74GTaa7YkYEXnEtKp8fUvs%2Fo10%3D&txtTest=asdfsdf&ddlTest=6&btnReturn=return&__EVENTVALIDATION=%2FwEWCQK6tuK0AwL9h%2FmcCQKK6%2BCJCAKK6%2BCJCAKK6%2BCJCAKJ6%2BCJCAKO6%2BCJCAKP6%2BCJCAL02tCyAsYjRYHRHKh5VciUq%2FsNDu9bmDaK

 

__ViewState以前是头部信息,__ViewState及其后面是控件的值,我们可以看到ddlTest=6,6为Value值,如果我们选择第二项或第三项,这个值永远是1,那么在服务器端,ddlTest.SelectedItem永远是第一个。

 

posted @ 2008-09-16 15:28 God Blue Shadow 阅读(77) 评论(0) 编辑

2008年9月8日

对于ArcGIS的框架,我相信网上介绍得更多了,现在主要讲怎样安装ArcGIS组件来进行.net二次开发.

我们要装的组件有:ArcSDE,ArcIMS,ArcIMS.ADF.DotNet。

 

数据库我们采取主流的Oracle9i,我们选择Oracle9.2,但是不能选择Oracle9.0,因为它不能与SDE很好的协作,其它的版本未测试过。Oracle的安装过程略。

 

有了这个数据库基础了,我们可以来安装ArcSDE,选择ArcSDE for Oracle9i。按照默认的配置安装就可以了。当然,授权文件是必不可少,如果没有,上网找吧。

 

有了ArcSDE这个数据桥,我们来接着装ArcIMS这个大块头。

1.我们要装JRE,在ArcIMS的安装盘中可以找到I:\ArcExplorer_Java\Disk1\InstData\VM\Support\JRE\jre-1_5_0_06-windows-i586-p.exe,安装它。

对系统进行配置:添加系统变量 java_home , 值为C:\Program Files\Java\jre1.5.0_06

追加Path变量,值为:%java_home%\bin;

这样,ArcIMS就可以轻松的找到JRE了。

2.装ServletExec,可以在ArcIMS的安装盘中可以找到:I:\ServletExec\ServletExec_ISAPI_50013.exe,与Windows IIS打交道,肯定要选择ISAP啦。安装的过程中会让你设置用户名和密码的,安装完成后链接http://localhost/servletexec/admin ,如果可以用你刚才用户名和密码登陆就表示你ServletExec安装OK了。

 

3.安装ArcIMS,默认安装就可以了,在安装的过程中,提示你输入当前登录密码之类的;出现很多选择项的对话框,什么IIS,Apach,Tomcat之类的,选择 IIS + ServletExec。其它的地方按照提示默认安装就可以了。

4,安装完成后,重启IIS.

5.测试ArcIMS安装是否成功,选择开始->程序->ArcGIS->ArcIMS->Diagnostics,点击“1”按钮和“2”按钮,如果都出现Success字样,表明安装已经完成OK了。

 

6,为了将ArcSDE与ArcIMS协作好,必须定义系统变量:

 

对系统进行配置:添加系统变量 SDEHOME, 值为D:\arcgis\ArcIMS\Server (ArcIMS的安装目录下的Server)

追加Path变量,值为:%SDEHOME%\bin;

 

 

7,安装ADF.Dotnet

posted @ 2008-09-08 15:43 God Blue Shadow 阅读(581) 评论(0) 编辑

2008年8月19日

摘要: 将SqlHelper转化为OraHelper,发现代码冗余量太多了,故修改之。调用示例如下: string spName = "foo.fmonthsignstatdata";//"Usefreqmonthstat"; string spName2 = "foo.test2";//无参数 string connStr = "Data Source=ip3;user id=foo;password=...阅读全文

posted @ 2008-08-19 18:49 God Blue Shadow 阅读(429) 评论(1) 编辑

2008年3月13日

  SendKeys模拟键盘的操作,设置一定的键值,便可以自动控制。但是我们在使用的过程中,发现SendKeys不支持空格键,在很多的应用场景,都需要使用空格键,所以只好通过反射的方式将其调整。
代码如下:

            Type typeForKeywords = Type.GetType("System.Windows.Forms.SendKeys+KeywordVk[], System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");


            Type typeForKeywordItem = Type.GetType("System.Windows.Forms.SendKeys+KeywordVk, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
            object objNewKey = Activator.CreateInstance(typeForKeywordItem, "SPACE", 0x20);

            Type typeForSendKeys = typeof(SendKeys);

            FieldInfo fieldForkeywords = typeForSendKeys.GetField("keywords", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Static);
            object objKeys = fieldForkeywords.GetValue(null);


            Type typeForlistForKeyword = Type.GetType("System.Collections.Generic.List`1[[System.Windows.Forms.SendKeys+KeywordVk, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
            object objForTmpKeyWords = Activator.CreateInstance(typeForlistForKeyword);

            MethodInfo mi = typeForlistForKeyword.GetMethod("Add");

            foreach (object var in (Array)objKeys)
            {
                //list.Add(var);
                mi.Invoke(objForTmpKeyWords, new object[] { var });
            }

            //list.Add(key);
            mi.Invoke(objForTmpKeyWords, new object[] { objNewKey });

            mi = typeForlistForKeyword.GetMethod("ToArray");
            object objArray = mi.Invoke(objForTmpKeyWords, null);
            fieldForkeywords.SetValue(null, objArray);

posted @ 2008-03-13 15:26 God Blue Shadow 阅读(764) 评论(1) 编辑

2008年2月18日

摘要: ~ tilde! exclamation mark @ at # hash (sharp, number sign)$ dollar % percent ^ caret (uparrow, to the power of, hat, control)& ampersand (and) * star (asterisk, times) ( left bracket (left parenth...阅读全文

posted @ 2008-02-18 10:36 God Blue Shadow 阅读(200) 评论(0) 编辑

2007年10月24日

摘要: class QueueHashtable<TKey, TValue> { List<TKey> _keys = new List<TKey>(); Hashtable ht = new Hashtable(); public ICollection Keys { get { return _keys; } } public ICollection Values ...阅读全文

posted @ 2007-10-24 16:49 God Blue Shadow 阅读(1062) 评论(1) 编辑

2007年7月5日

摘要: 在开发PDA程序的过程中要使用dataGrid控件,必须要指定GridColumnStyle的MappingName通过UI 设计的方式,不能在后台代码中指定,也就是说必须在InitializeComponent里完成所有映射工作,否则会出现数据表无法绑定到dataGrid控件之上。阅读全文

posted @ 2007-07-05 21:48 God Blue Shadow 阅读(413) 评论(1) 编辑

2007年6月28日

摘要: /// <summary> /// 将日期转化成指定格式,24制。YYYY: 年;MM:月;DD:日;HH:小时;mm:分钟;SS:秒;MS:毫秒。 /// </summary> /// <param name="format"></param> /// <returns></returns> public static st...阅读全文

posted @ 2007-06-28 18:02 God Blue Shadow 阅读(99) 评论(0) 编辑

2007年6月26日

摘要: using System;using System.Collections.Generic;using System.Text;using Newtonsoft.Json.Converters;using Newtonsoft.Json;using System.Data;using System.Data.SQLite;namespace ConsoleApplication2{ class P...阅读全文

posted @ 2007-06-26 14:48 God Blue Shadow 阅读(1913) 评论(0) 编辑