Ejemplo n.º 1
0
        /// <summary>
        /// �������ļ�
        /// </summary>
        /// <param name="serverXmlFile"></param>
        /// <param name="localXmlFile"></param>
        /// <param name="updateFileList"></param>
        /// <returns></returns>
        public int CheckForUpdate(string serverXmlFile,string localXmlFile,out Hashtable updateFileList)
        {
            updateFileList = new Hashtable();
            if(!File.Exists(localXmlFile) || !File.Exists(serverXmlFile))
            {
                return -1;
            }

            XmlFiles serverXmlFiles = new XmlFiles(serverXmlFile);
            XmlFiles localXmlFiles = new XmlFiles(localXmlFile);

            XmlNodeList newNodeList = serverXmlFiles.GetNodeList("AutoUpdater/Files");
            XmlNodeList oldNodeList = localXmlFiles.GetNodeList("AutoUpdater/Files");

            int k = 0;
            for(int i = 0;i < newNodeList.Count;i++)
            {
                string [] fileList = new string[3];

                string newFileName = newNodeList.Item(i).Attributes["Name"].Value.Trim();
                string newVer = newNodeList.Item(i).Attributes["Ver"].Value.Trim();

                ArrayList oldFileAl = new ArrayList();
                for(int j = 0;j < oldNodeList.Count;j++)
                {
                    string oldFileName = oldNodeList.Item(j).Attributes["Name"].Value.Trim();
                    string oldVer = oldNodeList.Item(j).Attributes["Ver"].Value.Trim();

                    oldFileAl.Add(oldFileName);
                    oldFileAl.Add(oldVer);

                }
                int pos = oldFileAl.IndexOf(newFileName);
                if(pos == -1)
                {
                    fileList[0] = newFileName;
                    fileList[1] = newVer;
                    updateFileList.Add(k,fileList);
                    k++;
                }
                else if(pos > -1 && newVer.CompareTo(oldFileAl[pos+1].ToString())>0 )
                {
                    fileList[0] = newFileName;
                    fileList[1] = newVer;
                    updateFileList.Add(k,fileList);
                    k++;
                }

            }
            return k;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// �������ļ�
        /// </summary>
        /// <param name="serverXmlFile"></param>
        /// <param name="localXmlFile"></param>
        /// <param name="updateFileList"></param>
        /// <returns></returns>
        public int CheckForUpdate()
        {
            string localXmlFile = Application.StartupPath + "\\UpdateList.xml";
            if(!File.Exists(localXmlFile))
            {
                return -1;
            }

            XmlFiles updaterXmlFiles = new XmlFiles(localXmlFile );

            string tempUpdatePath = Environment.GetEnvironmentVariable("Temp") + "\\"+ "_"+ updaterXmlFiles.FindNode("//Application").Attributes["applicationId"].Value+"_"+"y"+"_"+"x"+"_"+"m"+"_"+"\\";
            this.UpdaterUrl = updaterXmlFiles.GetNodeValue("//Url") + "/UpdateList.xml";
            this.DownAutoUpdateFile(tempUpdatePath);

            string serverXmlFile = tempUpdatePath  +"\\UpdateList.xml";
            if(!File.Exists(serverXmlFile))
            {
                return -1;
            }

            XmlFiles serverXmlFiles = new XmlFiles(serverXmlFile);
            XmlFiles localXmlFiles = new XmlFiles(localXmlFile);

            XmlNodeList newNodeList = serverXmlFiles.GetNodeList("AutoUpdater/Files");
            XmlNodeList oldNodeList = localXmlFiles.GetNodeList("AutoUpdater/Files");

            int k = 0;
            for(int i = 0;i < newNodeList.Count;i++)
            {
                string [] fileList = new string[3];

                string newFileName = newNodeList.Item(i).Attributes["Name"].Value.Trim();
                string newVer = newNodeList.Item(i).Attributes["Ver"].Value.Trim();

                ArrayList oldFileAl = new ArrayList();
                for(int j = 0;j < oldNodeList.Count;j++)
                {
                    string oldFileName = oldNodeList.Item(j).Attributes["Name"].Value.Trim();
                    string oldVer = oldNodeList.Item(j).Attributes["Ver"].Value.Trim();

                    oldFileAl.Add(oldFileName);
                    oldFileAl.Add(oldVer);

                }
                int pos = oldFileAl.IndexOf(newFileName);
                if(pos == -1)
                {
                    fileList[0] = newFileName;
                    fileList[1] = newVer;
                    k++;
                }
                else if(pos > -1 && newVer.CompareTo(oldFileAl[pos+1].ToString())>0 )
                {
                    fileList[0] = newFileName;
                    fileList[1] = newVer;
                    k++;
                }

            }
            return k;
        }
        private int ComputeFibonacci(object sender, DoWorkEventArgs e)
        {
            #region 判断是否能够连接数据库
            try
            {
                string ip = System.Configuration.ConfigurationManager.AppSettings["ServerIP"];
                if (GetCmdPingResult(ip) == "1")
                    DbHelperSQL.connection = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"];
                else
                    DbHelperSQL.connection = "User ID=sa;pwd=" + CommonMethod.DecryptDES(ini.IniReadValue("Connection", "LPsw"), "EncryDes").ToLower() + ";Data Source=" + ini.IniReadValue("Connection", "LServer") + ";Initial Catalog=" + ini.IniReadValue("Connection", "LDataBase") + ";";
                #region 是否存在该数据库
                string strsql = "Select Name From Master..SysDataBases Where DbId=(Select Dbid From Master..SysProcesses Where Spid = @@spid)";
                object ODataName = DbHelperSQL.GetSingle(strsql);
                #endregion

                string strSystemName = ini.IniReadValue("SysInfo", "SystemName");
                labSysName.Text = strSystemName;

                string strRoomCode = ini.IniReadValue("RoomSetting", "RoomCode");

                CommonMethod.ComboxBind(cbxRoom, "TT_Room", "RoomName", "RoomCode", " IsForbid='0' and Remark !='0' and RoomType = '" + StaticParameter.FormType + "'", "RoomName asc", "超级管理部门", "0");

                try
                {
                    this.cbxRoom.SelectedValue = strRoomCode;

                    if (cbxRoom.SelectedValue.ToString() != "")
                    {
                        string strOrgCode = cbxRoom.SelectedValue.ToString();
                        if (strOrgCode != "0")
                        {
                            CommonMethod.ComboxBind(cbxUserName, "VSys_Operator", "UserName", "UserCode", "IsForbid='0' and TypeCode='" + strOrgCode + "' and OrgType='1'", "UserName asc");
                        }
                        else
                        {
                            CommonMethod.ComboxBind(cbxUserName, "VSys_Operator", "UserName", "UserCode", "IsForbid='0' and TypeCode='" + strOrgCode + "' and OrgType='1'", "UserName asc", "超级管理员", "0");
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("该站点已经被禁用,请用管理员登录系统并修改磅房");
                    cbxRoom.SelectedValue = "0";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("数据库连接失败!" + ex.Message.ToString(), "天大天科调运系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
                new Settings.DataBaseInitial().ShowDialog();
                Application.Exit();

                return -1;
            }
            #endregion

            #region 判断是否有升级版本
            //获取本地的程序版本文件
            string localXmlFile = Application.StartupPath + "\\UpdateList.xml";
            string serverXmlFile = string.Empty;

            #region 与服务器连接,下载更新配置文件
            try
            {
                //从本地读取更新配置文件信息
                updaterXmlFiles = new XmlFiles(localXmlFile);
            }
            catch
            {
            }
            #endregion

            //获取服务器地址
            updateUrl = updaterXmlFiles.GetNodeValue("//Url");

            //获取服务器地址IP
            string strServerIp = updateUrl.Split('/')[2].ToString().Split(':')[0].ToString();

            //网络状态
            string strNetWorkState = GetCmdPingResult(strServerIp);

            if (strNetWorkState == "1")//连接状态
            {
                #region 下载服务器的版本文件,并判断是否有更新文件
                AppUpdater appUpdater = new AppUpdater();
                appUpdater.UpdaterUrl = updateUrl + "/UpdateList.xml";

                #region 与服务器连接,下载更新配置文件
                //try
                //{
                //    tempUpdatePath = Environment.GetEnvironmentVariable("Temp") + "\\" + "_" + updaterXmlFiles.FindNode("//Application").Attributes["applicationId"].Value + "_" + "y" + "_" + "x" + "_" + "m" + "_" + "\\";
                //    appUpdater.DownAutoUpdateFile(tempUpdatePath);
                //}
                //catch
                //{
                //}
                #endregion

                //获取更新文件列表
                Hashtable htUpdateFile = new Hashtable();

                #region 检查是否有更新的文件
                //serverXmlFile = tempUpdatePath + "\\UpdateList.xml";
                //if (!File.Exists(serverXmlFile))
                //{
                //}

                ////检查是否有更新的文件
                //availableUpdate = appUpdater.CheckForUpdate(serverXmlFile, localXmlFile, out htUpdateFile);
                #endregion

                //if (availableUpdate > 0)
                //{
                //    try
                //    {
                //        //删除临时文件夹
                //        System.IO.Directory.Delete(tempUpdatePath, true);
                //    }
                //    catch (Exception ex)
                //    {
                //        MessageBox.Show(ex.Message.ToString());
                //    }

                //    System.Diagnostics.Process.Start("AutoUpdate.exe");
                //}
                //else
                //{
                //    try
                //    {
                //        //删除临时文件夹
                //        System.IO.Directory.Delete(tempUpdatePath, true);
                //    }
                //    catch (Exception ex)
                //    {
                //        MessageBox.Show(ex.Message.ToString());
                //    }

                //}
                #endregion
            }

            #endregion

            return -1;
        }