Esempio n. 1
0
        XmlNodeList mNewXnl;//新版本文件

        /// <summary>
        /// 下载版本文件
        /// </summary>
        public IEnumerator VersionFile(string varURl, SelectUpdate varSelectUpdate)
        {
            while (true)
            {
                WWW tempVersion = new WWW(varURl);
                yield return(tempVersion);

                if (tempVersion.error != null)
                {
                    tempVersion.Dispose();
                    tempVersion = null;
                    yield return(new WaitForSeconds(1));
                }
                else
                {
                    XmlDocument  tempXmlDoc = new XmlDocument();
                    StringReader tempSR     = new StringReader(tempVersion.text);
                    Debug.Log(tempVersion.text);
                    tempXmlDoc.LoadXml(tempSR.ReadToEnd());
                    mNewXnl = tempXmlDoc.GetElementsByTagName("file");
                    tempSR.Close();
                    tempSR.Dispose();
                    tempVersion.Dispose();
                    tempVersion = null;
                    Project.CreateDirectory(ProjectPath.GetPersistent + "/Resources");
                    GetUpdateFile(ProjectPath.GetPersistent + "/Resources", varSelectUpdate);
                    break;
                }
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack || firstRun)
     {
         SelectUpdate.DataBind();
     }
     firstRun = false;
 }
 protected void DeleteCatBtn_Click(object sender, EventArgs e)
 {
     CatDataSetTableAdapters.CatsTableAdapter catsAdapter = new CatDataSetTableAdapters.CatsTableAdapter();
     catsAdapter.Delete(DropDownDelete.SelectedValue);
     GridView1.DataBind();
     SelectUpdate.DataBind();
     DropDownDelete.DataBind();
 }
Esempio n. 4
0
        /// <summary>
        /// 获取更新资源
        /// </summary>
        public void GetUpdateFile(string varPath, SelectUpdate varSelectUpdate)
        {
            DirectoryInfo tempDirInfo = new DirectoryInfo(varPath);//资源文件夹

            //获取文件夹下所有文件(包括子文件夹下)
            FileInfo[] tempFileInfoList = tempDirInfo.GetFiles("*", SearchOption.AllDirectories);
            Dictionary <string, FileInfo> templocalFileDic = new Dictionary <string, FileInfo>();

            foreach (FileInfo v in tempFileInfoList)
            {
                string tempFileName = v.FullName.Remove(0, varPath.Length + 1);
                Debug.Log(tempFileName);
                if (!templocalFileDic.ContainsKey(tempFileName))
                {
                    templocalFileDic.Add(tempFileName, v);
                }
            }
            mUpdateFile = new List <XmlNode>();
            string tempFile       = ""; //文件名
            string tempOldVersion = ""; //本地版本号
            string tempNewVersion = ""; //服务器版本号

            for (int i = 0; i < mNewXnl.Count; i++)
            {
                tempFile = mNewXnl[i].Attributes["name"].InnerText;
                if (!templocalFileDic.ContainsKey(tempFile))
                {
                    if (varSelectUpdate == SelectUpdate.ExistingResources)
                    {
                        continue;
                    }
                    mUpdateFile.Add(mNewXnl[i]);//本地不存在
                    Debug.Log("本地不存在");
                }
                else
                {
                    tempOldVersion = GetLocalVersion(templocalFileDic[tempFile].FullName);
                    tempNewVersion = mNewXnl[i].Attributes["version"].InnerText;
                    if (tempOldVersion != tempNewVersion)
                    {
                        mUpdateFile.Add(mNewXnl[i]);//本地存在但版本不同
                        Debug.Log("本地存在但版本不同");
                    }
                }
            }

            StartCoroutine(UpdateFile());
        }