Ejemplo n.º 1
0
Archivo: Form1.cs Proyecto: Abitech/m3o
        public bool DownloadBuild(AppBuild currentBuild, string path)
        {
            while (true)
            {
                var response = web.DownloadFile("/json/dev/maint/get/firmwarebuild/", Converter.Serialize(currentBuild), path);

                if (response == false)
                {
                    continue;
                }

                return response;
            }
        }
Ejemplo n.º 2
0
Archivo: Form1.cs Proyecto: Abitech/m3o
        public RpcResponse<AppBuild> GetNextCompatibleBuildVersion(AppBuild currentBuild)
        {
            while (true)
            {
                var response = web.GetNextCompatibleBuildVersion(currentBuild);

                if (response.error != null)
                {
                    continue;
                }

                return response;
            }
        }
Ejemplo n.º 3
0
Archivo: Form1.cs Proyecto: Abitech/m3o
        private void CheckUpdates()
        {
            I(delegate() { this.Text = i8n.strings["Build"] + " №" + configuration.Build; });

            DebugMessageBox.Show("DEBUG mode is ON");

            if (status == M3ClientInitializationStatus.ClientConfigurationMissing)
            {
                I(delegate() {
                    notificationLabel.Text = i8n.strings["technicalAssistanceNeeded"];
                    RunAndExit(directory + mainAppFilename + ".exe");
                });
                return;
            }
            else if (status == M3ClientInitializationStatus.Ok)
            {
                I(delegate(){notificationLabel.Text = i8n.strings["checkingLatestUpdate"];});
            }

            var currentBuild = new AppBuild { build = configuration.Build };

            var nextBuild = GetNextCompatibleBuildVersion(currentBuild).result;

            if (currentBuild.build == nextBuild.build
                && File.Exists(directory + mainAppFilename + ".exe")
                && ComputeHash(directory + mainAppFilename + ".exe") == nextBuild.hash
                )
            {
                I(delegate() {
                    notificationLabel.Text = i8n.strings["currentBuildMostUpdated"];
                    RunAndExit(directory + mainAppFilename + ".exe");
                });
                return;
            }
            else
            {
                I(delegate() { notificationLabel.Text = i8n.strings["downloadingNewBuild"];});
            }

            var extension = String.Empty;

            if (nextBuild.updateType == "1")
            {
                extension = ".exe";
            }
            else if (nextBuild.updateType == "2")
            {
                extension = ".cab";
            }
            var i = 1;

            while (true)
            {
                DownloadBuild(currentBuild, directory + mainAppFilename + extension);
                var downloadedBuildhash = ComputeHash(directory + mainAppFilename + extension);

                if (downloadedBuildhash == nextBuild.hash)
                {
                    I(delegate() { notificationLabel.Text = i8n.strings["startProgram"]; });
                    break;
                }
                else
                {
                    File.Delete(directory + mainAppFilename + extension);
                    I(delegate() { notificationLabel.Text = i8n.strings["crcCorrupted"] + "\n" + nextBuild.hash + "—" + downloadedBuildhash + "\n(Попытка " + i++ + ") "; });
                }
            }

            I(delegate() { RunAndExit(directory + mainAppFilename + extension); });
        }