Example #1
0
        //更新服务器的版本
        private void UpdateServerVersion()
        {
            if (txtSourceDIR.Text.Trim() == String.Empty ||
                txtTargetDIR.Text.Trim() == String.Empty)
            {
                return;
            }
            object obj = getServerVersion();

            if (lblNewVersion.Text.IndexOf("无需更新") < 0)
            {
                string sql = String.Empty;
                if (obj == null)
                {
                    sql = "insert into TBLCSUPDATER (CSVERSION,LOCATION,ISAVIABLE) values ('"
                          + lblNewVersion.Text.Trim() + "','"
                          + txtTargetDIR.Text.Trim() + "',1)";
                }
                else
                {
                    sql = "update TBLCSUPDATER set CSVERSION = '" + lblNewVersion.Text.Trim()
                          + "',LOCATION ='" + txtTargetDIR.Text.Trim() + "',ISAVIABLE=1 where ISAVIABLE = 1";
                }

                _domainDataProvider.BeginTransaction();
                try
                {
                    _domainDataProvider.CustomExecute(
                        new SQLCondition(sql));

                    _domainDataProvider.CommitTransaction();

                    FileLog.FileLogOut(lblNewVersion.Text + "\tOK");
                }
                catch (Exception ex)
                {
                    Log.Error(ex.Message);
                    _domainDataProvider.RollbackTransaction();
                    throw ex;
                }
                finally
                {
                    (_domainDataProvider as SQLDomainDataProvider).PersistBroker.CloseConnection();
                }
            }
        }