星空网 > 软件开发 > ASP.net

WebService的创建和使用——文件名称生成器

简介

      之前做过一个文件名称生成器,通过Webservice读取

涉及到的编程内容

    webservice,

Webservice的创建

      (1)创建空Web应用程序WebService的创建和使用——文件名称生成器     (2)添加Web服务(asmx)

WebService的创建和使用——文件名称生成器

    (3)在[WebMethod]下写要使用的方法

WebService的创建和使用——文件名称生成器   (4)通过浏览器查看是否创建好服务

WebService的创建和使用——文件名称生成器   (5)发现已经建立了该服务

WebService的创建和使用——文件名称生成器Webservice的使用

  (1)创建一个新窗体,添加服务引用

WebService的创建和使用——文件名称生成器 

   (2)点击“发现”找到相应的websevice,再点击“高级”

WebService的创建和使用——文件名称生成器    (3)点击“添加Web引用”

WebService的创建和使用——文件名称生成器    (4)点击“此解决方案中的Web服务”

WebService的创建和使用——文件名称生成器    (5)点击“添加引用”

WebService的创建和使用——文件名称生成器   (6)在窗体中引用即可

WebService的创建和使用——文件名称生成器

WebService的创建和使用——文件名称生成器

数据库表的字段:

WebService的创建和使用——文件名称生成器

Winform程序界面:

WebService的创建和使用——文件名称生成器             WebService的创建和使用——文件名称生成器

Webservice调用类的方法:

      (1)在webservice中调用类的方法来完成某些操作,而不是直接写在webservice里。

WebService的创建和使用——文件名称生成器

      (2)从WebService的创建和使用——文件名称生成器WebService的创建和使用——文件名称生成器

 public List<string> BackSchemaList()    {      List<string> name = new List<string>();      = new @"F:\Winform Project\Namer\FieldList.");      = doc.SelectSingleNode("FieldList");      = xn.ChildNodes;      foreach (in xnl)     {          string fieldvalue = "";                = (string listnumber = xe.GetAttribute("number").ToString();          string listtype = xe.GetAttribute("type").ToString();          = xe.ChildNodes;        foreach (in xnl0)        {          = (+= xe1.GetAttribute("Value").ToString();                  }        name.Add(fieldvalue);        name.Add(listtype);     }         return name;    }

View Code

      (3)选取一个模板进行模糊查询,给新生成的文件名称加上个序列号:

WebService的创建和使用——文件名称生成器WebService的创建和使用——文件名称生成器
 public string generatedata(string s1,string s2)    {      string str_provider = "Provider=Microsoft.Ace.OLEDB.12.0;";      string str_source = "Data Source=F:/Winform Project/Namer/Namer.accdb;Persist Security Info=False;"; //数据源路径      string str_connection = str_provider + str_source; //连接字符串      int xuliehao = 1;      OleDbConnection cnn;      OleDbCommand cmd;      OleDbDataReader datar;      string str_sql1 = "SELECT name FROM T_name WHERE name Like '"+s1+"%';";      cnn = new OleDbConnection(str_connection);      cmd = new OleDbCommand(str_sql1, cnn);      cnn.Open();      datar = cmd.ExecuteReader();      while (datar.Read())      {        if (datar["name"].ToString() == null)        {          break;        }        else { xuliehao++; }      }      cnn.Close();      string number = string.Format("{0:000}", xuliehao);      s1 += number;      string dt = DateTime.Now.ToString();      string str_sql2 = "insert into T_name (name,code,timeNow,type) values ('"+s1+"','"+number+"','"+dt+"','"+s2+"');";      cnn = new OleDbConnection(str_connection);      cmd = new OleDbCommand(str_sql2, cnn);      cnn.Open();      int i = cmd.ExecuteNonQuery();      cnn.Close();      string newname = s1;      return newname;       }

View Code

      (4)读取一条信息并显示其详细字段:

WebService的创建和使用——文件名称生成器WebService的创建和使用——文件名称生成器
 public List<List<string>> Backonelist(int int_index,string str_type)    {      List<List<string>> documentlist = new List<List<string>>();      = new @"F:\Winform Project\Namer\FieldList.");      = doc.SelectSingleNode("FieldList");      = xn.ChildNodes;      foreach (in xnl)      {        = (= xe.ChildNodes;        if (xe.GetAttribute("number").ToString() == (int_index + 1).ToString() && xe.GetAttribute("type").ToString() == str_type)        {          foreach (in xnl0)          {            List<string> field = new List<string>();            = ("Index").ToString());            field.Add(xe1.GetAttribute("Type").ToString());            field.Add(xe1.GetAttribute("Name").ToString());            field.Add(xe1.GetAttribute("Value").ToString());            documentlist.Add(field);          }             }      }                return documentlist;    }

View Code

      (5)对WebService的创建和使用——文件名称生成器WebService的创建和使用——文件名称生成器

 public bool insert(string s)    {      bool state = true;      int i = 1;      List<List<string>> one_document = new List<List<string>>();      one_document = JsonConvert.DeserializeObject<List<List<string>>>(s);          = new @"F:\Winform Project\Namer\FieldList.");      = doc.SelectSingleNode("FieldList");       = doc.CreateElement("list");      foreach (in xn.ChildNodes)      {        = (if (xe.GetAttribute("type").ToString() == one_document[0][0])        {          i++;        }      }      element.SetAttribute("number", i.ToString());      element.SetAttribute("type", one_document[0][0]);            foreach (List<string> list in one_document)      {          string fieldindex = list[1];          string fieldtype = list[2];          string fieldname = list[3];          string fieldvalue = list[4];          = doc.CreateElement("Field");          element.AppendChild(element2);          element2.SetAttribute("Index", fieldindex);          element2.SetAttribute("Type", fieldtype);          element2.SetAttribute("Name", fieldname);          element2.SetAttribute("Value", fieldvalue);                }      xn.AppendChild(element);       doc.Save(@"F:\Winform Project\Namer\FieldList.");            return state;    }

View Code

      (6)对WebService的创建和使用——文件名称生成器WebService的创建和使用——文件名称生成器

 public bool EditDATA(string str_s)    {      bool flag = true;      int temp = 1;      List<List<string>> one_document = new List<List<string>>();      one_document = JsonConvert.DeserializeObject<List<List<string>>>(str_s);      List<string> basicinfo = new List<string>();      basicinfo=one_document[0];      string typename = basicinfo[0];      string preview = basicinfo[1];      int temp_documentindex = Convert.ToInt32(basicinfo[2]);      int int_documentindex = temp_documentindex + temp;      string documentindex = int_documentindex.ToString();      one_document.Remove(one_document[0]);      = new @"F:\Winform Project\Namer\FieldList.");      = doc.SelectSingleNode("//list[@ number='" + documentindex + "'][@ type='" + typename + "']");      = xn.ChildNodes;      List<new List<();      foreach (in xnl)      {        foreach (in foreach (List<string> list in one_document)      {        string fieldindex = list[0];        string fieldtype = list[1];        string fieldname = list[2];        string fieldvalue = list[3];        = doc.CreateElement("Field");        xn.AppendChild(element2);        element2.SetAttribute("Index", fieldindex);        element2.SetAttribute("Type", fieldtype);        element2.SetAttribute("Name", fieldname);        element2.SetAttribute("Value", fieldvalue);        if (element2.GetAttribute("Name").ToString() == "category")        {          = doc.CreateElement("CodeList");          element2.AppendChild(element3);          for (int i = 1; i <= 4; i++)          {            string[] array = { "personal", "work", "play", "trans" };            = doc.CreateElement("CodeWord");            element3.AppendChild(element4);            element4.SetAttribute("Code", i.ToString());            element4.SetAttribute("Description", array[i - 1]);          }        }      }      doc.Save(@"F:\Winform Project\Namer\FieldList.");       return flag;    }

View Code

最后效果:

WebService的创建和使用——文件名称生成器WebService的创建和使用——文件名称生成器WebService的创建和使用——文件名称生成器

本文中对部分相对比较重要的代码进行了交代,希望对大家有点帮助。

 




原标题:WebService的创建和使用——文件名称生成器

关键词:web

web
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

义乌泰国货运:https://www.goluckyvip.com/tag/88514.html
深圳寄泰国:https://www.goluckyvip.com/tag/88515.html
北京到泰国快递:https://www.goluckyvip.com/tag/88517.html
上海运输到泰国:https://www.goluckyvip.com/tag/88518.html
南宁快递到泰国:https://www.goluckyvip.com/tag/88519.html
上海寄快递到泰国:https://www.goluckyvip.com/tag/88520.html
长治婚庆女司仪和主持人:https://www.vstour.cn/a/366176.html
北京丰台区水上乐园哪家好玩?:https://www.vstour.cn/a/366177.html
我的浏览记录
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流