In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how to use WebService to update client software in C#. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
Train of thought:
First of all, to realize the development of the WEB side, mainly consider using C # WebService technology to provide the calling function of the remote service, return the byte content of a file, and then write an upgrade program client and distribute it to the machine used by the customer (which can be installed with the customer's software). The client program mainly connects to webserivce and then saves the file to the local machine (the client's machine). It can be realized!
Details of the implementation:
To consider providing customers with the version of the software, the lower version of the upgrade, the * version does not need to upgrade. Also consider the authentication of user name and password on the Web side!
Use technology:
ASP.Net WebService development, client-side asynchronous call WebService method. Database technology!
Begin to implement:
1. Build database, use SQLSERVER2000 1) Software item table: softlist (softid, softname, resume, loginname, loginpwd) softid: no. Softname: software name resume: introduction loginname: customer login name loginpwd: password 2) version table SoftListVersion (softid, subid, version, UpdatePath) of each software Olefile) softid: master table software number subid: each version data number version: software version filename: upgrade file name olefile: upgrade file binary content, is the image type, (I mainly store the MSI installation package file type, you can use C # to do this kind of installation package file) 3) establish a view, chkVersion, used to check the version number SELECT dbo.SoftListVersion.subid, dbo.softlist. Softname, dbo.SoftListVersion.version FROM dbo.softlist INNER JOIN dbo.SoftListVersion ON dbo.softlist.softid = dbo.SoftListVersion.softid 4) create another view, vOleFile, to download the file SELECT dbo.SoftListVersion.subid, dbo.softlist. Softname, dbo.SoftListVersion.filename, dbo.SoftListVersion.olefile, dbo.SoftListVersion.version FROM dbo.softlist INNER JOIN dbo.SoftListVersion ON dbo.softlist.softid = dbo.SoftListVersion.softid 2. Write a WEBSERVICE 1) start VS.Net2003 and set up a project called babyWebSvc, project type is (ASP.Net WEB service) 2) add a WEB service of SoftUpdate.asmx 3) add a method SearchVersion [WebMethod (Description= "returns the * version of the current software upgrade package")] public string SearchVersion (string softname) {string sVersion = "; webmod.dbConnStart () / / (connect) the author's own database connection class, and the user completes the database connection string strSQL = "select MAX (version) as MaxVerID from chkVersion where softname = @ softname"; SqlCommand sqlCmd = new SqlCommand (strSQL,webmod.sqlConn); sqlCmd.CommandTimeout = 0; sqlCmd.Parameters.Add ("@ softname", SqlDbType.VarChar). Value = softname; SqlDataReader sqlRd = sqlCmd.ExecuteReader (); if (sqlRd.HasRows) {sqlRd.Read (); sVersion = Convert.ToString (sqlRd ["MaxVerID"]);} sqlRd.Close (); webmod.dbConnEnd (); / (disconnect) the author's own connection database class, and the user completes the database connection return sVersion by himself } 4) add the method DownloadSoft [WebMethod (Description= "returns the bytes of the file to be downloaded")] public byte [] DownloadSoft (string UserName,string PassWord, string SoftDnldName,string SoftHeightVersion) {/ / (connect) the author's own connection database class, and the user completes the database connection webmod.dbConnStart (); / / check the validity of the user bool bMember = CheckAuth (UserName,PassWord) / / A function within the WebService to check the validity of the user. Users can complete if (! bMember) {webmod.dbConnEnd (); return null;} byte [] b = null; / / We take out the upgrade package string strSQL = "select olefile from vOleFile where (filename=@softname) and version=@ver" of the specified software name; SqlCommand sqlCmd = new SqlCommand (strSQL,webmod.sqlConn); sqlCmd.CommandTimeout = 0 SqlCmd.Parameters.Add (@ softname, SqlDbType.VarChar). Value = SoftDnldName; sqlCmd.Parameters.Add ("@ ver", SqlDbType.VarChar). Value = SoftHeightVersion; SqlDataReader sqlRd = sqlCmd.ExecuteReader (); if (sqlRd.HasRows) {sqlRd.Read (); b = (byte []) sqlRd ["olefile"]; / / the byte contents of the file} sqlRd.Close (); / / (disconnect) the author's own connection database class, and the user completes the database connection webmod.dbConnEnd (); return b;}
After the method of the 3.WEB service is completed, you can start and test it yourself. Let's write the client upgrade program now. Suppose the URL of your WEBSERVICE at the time of development is: http://localhost/babywebsvc/SoftUpdate.asmx, pay attention to this URL. We will refer to it on the client side.
4. Start VS.Net2003, create a Windows project for C#, and add a button to the default FORM
5. Add a new file type (application configuration file) App.config
Contents of the App.Config file
< configuration > < configuration > < appSettings > < add key= "user" value= "test" / > < add key= "pwd" value= "test" / > < add key= "babyRecordSoftName" value= "TEST.EXE" / >
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.