Beispiel #1
0
        private void Complete()
        {
            Versions.Save();

            if (_downloads.Count > 0)
            {
                for (int i = 0; i < _downloads.Count; i++)
                {
                    var item = _downloads[i];
                    if (!item.isDone)
                    {
                        break;
                    }
                    else
                    {
                        if (_serverVersions.ContainsKey(item.path))
                        {
                            _versions[item.path] = _serverVersions[item.path];
                        }
                    }
                }

                StringBuilder sb = new StringBuilder();
                foreach (var item in _versions)
                {
                    sb.AppendLine(string.Format("{0}:{1}", item.Key, item.Value));
                }

                var path = Utility.GetRelativePath4Update(versionsTxt);
                if (File.Exists(path))
                {
                    File.Delete(path);
                }

                File.WriteAllText(path, sb.ToString());
                Assets.Initialize(delegate
                {
                    if (completed != null)
                    {
                        completed();
                    }
                }, OnError);
                state = State.Completed;

                message = string.Format("{0} files has update.", _downloads.Count);
                return;
            }

            if (completed != null)
            {
                completed();
            }

            message = "nothing to update.";
            state   = State.Completed;
        }
Beispiel #2
0
        void Clear()
        {
            var dir = System.IO.Path.GetDirectoryName(Utility.updatePath);

            if (Directory.Exists(dir))
            {
                Directory.Delete(dir, true);
            }

            _downloads.Clear();
            _downloadIndex = 0;
            _versions.Clear();
            _serverVersions.Clear();
            message = "click Check to start.";
            state   = State.Wait;

            Versions.Clear();
            Versions.Save();
        }