Exemple #1
0
        public bool downLoad(out string msg)
        {
            string      deviceId = XmlConfig.readDeviceId();
            XmlNodeList pList    = CXml.ReadList(Application.StartupPath + "\\Update.xml", "/update/fileList/file");

            CSQLite.G_CSQLite.WriteRunLogInfoDB("D03", "开始下载更新文件");
            msg = "开始下载更新文件";
            foreach (XmlNode nl in pList)
            {
                try
                {
                    FtpClient ftp = new FtpClient();
                    ftp.Server     = szAddress;
                    ftp.RemotePath = "update";
                    ftp.Login();
                    ftp.ChangeDir(deviceId);
                    long nSize = 0;
                    if ((nSize = ftp.GetFileSize(nl.Attributes[0].Value)) > 0)
                    {
                        long   nDoneSize = 0;
                        string szFile    = null;
                        do
                        {
                            ftp.Download(nl.Attributes[0].Value, Application.StartupPath + "\\Update\\" + nl.Attributes[0].Value, true);
                            szFile = Application.StartupPath + "\\Update\\" + nl.Attributes[0].Value;
                            if (File.Exists(szFile))
                            {
                                FileInfo fi = new FileInfo(szFile);
                                nDoneSize = fi.Length;
                            }
                        } while (nDoneSize != nSize);
                    }
                    ftp.Close();
                }
                catch (Exception e)
                {
                    CSQLite.G_CSQLite.WriteRunLogInfoDB("D05", "更新文件下载失败");
                    msg = nl.Attributes[0].Value + "更新文件下载失败" + e.Message;
                    return(false);
                }
            }
            CSQLite.G_CSQLite.WriteRunLogInfoDB("D04", "更新文件下载完成");
            msg = "更新文件下载完成";
            return(true);
        }
Exemple #2
0
        //----------------------------------------------------------------------------------------------------------------------
        public static int GetPerson(string[] person)
        {
            XmlNodeList pList = CXml.ReadList(Application.StartupPath + "\\person.xml", "/Config/site/person");
            int         i     = 0;

            try
            {
                foreach (XmlNode nl in pList)
                {
                    person[i] = nl.Attributes[0].Value;
                    i++;
                }
            }
            catch
            {
            }
            return(i);
        }