An automatic upgrade program production process

xiaoxiao2021-03-06  47

Dearing this applet for a day, after doing, I feel that I really have to re-examine the days of writing procedures. I retrospectively, I didn't have a good thing in the past few years, life is really so meaningful? Overall thinking : After you have an idea of ​​automatic upgrade, you will find it online first. Seeing that the ideas of the heroes is basically: Start another one before the main program starts.

The program is connected to the server, and the current is to determine if the current version is currently a new version. If it is not the latest in the directory of the server or

Get the update file from the database, then get them down, cover the original, then start the main program. I want to be a simple to try, and then extension, then I have built a table in the server (ID) , PATH, FLAG) Path is used to store the latest version in service

The path on the server, of course, here must be a shared path, so directly copy, Flag is used to record the user-end upgrade, I have no version or file more

New time to determine if a new version, I use the FLAG field to determine if a user is upgraded successfully, record its MAC address, next time, if there is already

This MAC address indicates that it has been upgraded, you don't have to upgrade again. I want to do this to provide an upgrade of different versions of different users, and can also be upgraded

Record statistics for use, and so on.

Design Process: If you want to be real in the project, it is not as simple. I have seen online heroes to use Winsock to transfer files. I am a shrimp. I have never seen the big face, I will set it in the server. Share folder to try the program process. So start VB.NET, pull the new form, put a label on it, start writing. In the front, since the idea is already there, there is no difficulty

Let's not care how to write a code, all written in form_load, I originally think that I will automatically execute a code when Form is started.

Connected to the server, then upgrade, etc., then change the text of the Label control on several critical points to prompt the user's background process, but

After that, debug, run, that Form is not coming, (To tell the truth, I have done so many years, I don't know the true intention of form_load, and more coming.

I have never hit this thing. I'm thinking about there are so many codes. At this time, this is already sweating, I really feel that I have been wasted so much in these two years.

During the program ....), I think that when I am in Formloy, it is done, and the code is loaded after the completion of the code is complete, so that the code is not written.

The process is, the form is also loaded, and of course, I can't see the form, and I add a small button to try it first. This time I have a pull, then click the button, that process is also implemented.

Pull, but how to automatically perform a code after the form is started? I think that there is a Timer control in VB, it seems to have this function, so I have been looking for it.

It is found that it is said that how to perform the List of the same code segment with Timer every other time, (the program is at this time, I will come again, sweat, I have done so many years, I don't know.

How to use a small Timer control to achieve the features you need, then come back from a few Timer's properties, find some attributes to make it do every time you do one or time for a while Afterward

Once the choice of this, this is not what I want? So I pulled a Timer Control, put it in Formload in Formloy, and finally

After a few seconds, the program is automatically launched, (but when using this Timer to implement this process, I feel a little not to twist, I think the software level has developed to today.

This time, this Timer's function is also too much, how to make it perform different blocks in the same interval? Maybe I am too stupid, it may be good to achieve

So, I sweat once ...) until this time I found that the text on the label has not changed until it launched the master program, closing this form, has not changed, I used to do BS programs before Touch

I have had similar problems, and there have been when doing progress bars. After performing the entire code, the interactive control on each form will change, such as before reading data.

Let the Label content on the form changes, the actual effect is after the data is completed, Label will pull. At this time, it has been unable to pull so much, I am casually

I found a social form of the me.update property, I put it up, I found a little change, but I was too fast, I passed, so I checked it online, I found a SYSTEM.THREA.

Ding.Thread.sleep () hangs the process, one trial, (.... You can not yell, I am actually awkward, like this kind of problem, the person who is procedure should be very Experience, but I don't know what kind of way to solve the best, ... Khan sweat .... Just use the SLEEP first through ....) then add to each key point This time, huh, I tried it on another machine, start; check the update; update the program; the program is updated,

In the start of the main program; it is still the idea that the adheres started.

At this time, I have been completely discouraged, and the small procedure of such a few lines of code has appeared so many questions, and I still want to get it, I have returned.

Head to think about the experience of the programmer, every time there is always a project, you will write it, write it, change it, change it, it will never think about it.

I have learned to write the program, after graduation, I will sway with people, in fact, the procedure is here, I have done it, and I have finished the hand on the hand, I think I have

I really understand that it is a fur, which has accumulated a bunch of fur, or a fur, thinking of from VB, ASP, .NET, C, SQL, Oracle, Java, also used

There are a lot, and I have seen a lot, but I still don't really understand a little program. I really sweat .... What is going on, what do I do? ....

There are still many problems with this program, such as: Do not let users start the main program directly; transfer the server with the user file with the user-end file, or put the text

The pieces are stored in the blob, downloaded through the database; how to better handle the downloaded version and the original version of the original version? Also ... there are a lot of problems, my head is getting more and more

Big, look at the computer in front of you, think about my future, I am really embarrassing .......

Code: Private Sub MAINDISPLAY_LOAD (ByVal Sender As System.Object, Byval E AS System.Eventargs) Handles MyBase.Load

Timer1.AutoreSet = false timer1.enabled = true timer1.interval = 5000

End Sub

Public Sub Updatev ()

DIM newver_path as string

'MessageBox.Show ( "Application.UserAppDataPath" & Application.UserAppDataPath)' MessageBox.Show ( "application.StartupPath" & Application.StartupPath) 'MessageBox.Show ( "Application.ProductName" & Application.ProductName)' MessageBox.Show ( "Application.ProductVersion" & Application.ProductVersion "'MessageBox.show (" LDTER Path: "& Application.Startuppath &" /../../ldter/bin/ldter.exe ")

'============= Check if there is a new version, such as the log design: Sys_newuPdate, the version number corresponding to the version number of the record number

'???????????? Can you press the client's IP or MAC address as an update flag in the local area network?

'========= read this machine IP or MAC address =================ManagementObjectSearcher ("Select * from win32_networkadapterconfiguration) Dim Macaddress As String for Each Wmiobj As ManagementObject In WMI.Getif CBool ​​(WMIOBJ ("iPenabled")) "" & WMIOBJ ("Macaddress") & ")" 'MessageBox.show ("IP (" & WMIOBJ ("ipaddress") (0) & ") | Mac (" & WMIOBJ ("Macaddress") & ")" & vbrlf) end if next

'============================================

DIM CONN AS ORACLECONNECTION DIM CM As OracleCommand Dim Reader As OracleDataReader

CONN = New OracleConnection (Global.GetoDBServer ()) cm = new oracleCommand ("SELECT * from Sys_NewUpdate a where sys_nu_id in (SELECT MAX (SYS_NU_ID) from Sys_Newupdate B)", CONN) conn.open ()

Try reader = cm.executeReader While Reader.Read Dim Flag As String

'FLAG = IIF (Reader.Item ("Sys_NU_FLAG") is nothing, "hh", reader.Item ("sys_nu_flag"). TOSTRING) FLAG = Reader.Item ("sys_nu_flag"). Tostring if INSTR (Flag, MacAddress) = 0 THEN 'The latest version of the program is not on the machine, COPY latest EXE' COPY, DELETE, RENAME EXE file 'is updating the program ... Label1.text = "Find new version, updating program ... ... "me.update () system.threading.thread.sleep (3000) newver_path = trim (Reader.Item (" Sys_nu_path "). TOSTRING) If Changeit (newver_path) Then 'Signature Local Information' Dim Sqlstr As StringBuilder = new StringBuilder 'SQLSTR.AppendFormat ( "UPDATE SYS_NEWUPDATE SET SYS_NU_FLAG: = SYS_NU_FLAG ||' {0} 'WHERE SYS_NU_ID IN (SELECT MAX (SYS_NU_ID) FROM SYS_NEWUPDATE B)", ": MACADDYSL")' cm = new OracleCommand (sQLSTR. Tostring, conn) cm = new oracleCommand ("Update sys_newupdate set sys_nu_flag = sys_nu_ Flag || '"& Macaddress &"' Where sys_nu_id in (SELECT MAX (SYS_NU_ID) from Sys_Newupdate B) ", CONN) 'cm.parameters.add (": macaddysl ", System.Data.OracleClient.Oracletype.varchar, Len (Macaddress)). Value = macaddress if not conn.state = connectionState.open the conn () endiff

cm.executenonQuery () Conn.close () 'has been upgraded to the latest version, starting the program ... label1.text = "has been upgraded to the latest version, starting the program ..." me.update () System.threading.thread.sleep (5000) shell (Application.Startuppath & "/LDTER.EXE")

Exit While else 'upgrade failed, please contact your administrator. Launcher ... label1.text = "upgrade failed, starting the old version of the program ..."

Me.Update () system.threading.thread.sleep (5000) shell (Application.Startuppath & "/LDTER.exe")

Exit While End if else 'existing version does not need to be upgraded, starting the program ... label1.text = "You are already the latest version, starting the program ..."

Me.Update () system.threading.thread.sleep (2000) shell (Application.Startuppath & "/LDTER.EXE")

EXIT While End If End While Catch EX AS Exception Label1.ForeColor = System.drawing.color.Red Label1.Text = "Warning: The program cannot start, please contact the system administrator." Me.Update () System.threading.Thread .Sleep (5000) finally conn.close () Application.exit () end try

End Sub

Private function changeit (byval spath as string) as boolean

DIM FL AS File Dim NfileName As String

'Delete first, replicate try fl.delete (Application.StartupPath & "&" LDTER.EXE ") NFileName =" ldter.exe "first copy, now remove, rename" ldter_update_tempfile.ysl "fl.copy (Spath, Application.startuppath & "/" & nfileName) Catch exception 'Messagebox.Show (ex.Message) Return False Endreeturn TRUE

END FUNCTION

PRIVATE SUB TIMER1_ELAPSED (BYVAL E AS System.Timers.Eval EventArgs) Handles Timer1.Elapsed Updatev () End Sub

转载请注明原文地址:https://www.9cbs.com/read-81821.html

New Post(0)