Beispiel #1
0
        public void Put(string name, [FromBody] JoeySoftVersion value)
        {
            var joeySoft = this.joeySoftVersions.FirstOrDefault(n => n.JoeySoftName == name);

            if (joeySoft != null)
            {
                joeySoft.Version = value.Version;
            }

            //todo 保存到json中
            JsonHelper.WriteJson(this.joeySoftVersions, "VersionJson/Version.json");
        }
Beispiel #2
0
        public IActionResult Post([FromBody] JoeySoftVersion value)
        {
            var joeySoft = this.joeySoftVersions.FirstOrDefault(n => n.JoeySoftName == value.JoeySoftName);

            if (joeySoft == null)
            {
                this.joeySoftVersions.Add(value);
                JsonHelper.WriteJson(this.joeySoftVersions, "VersionJson/Version.json");
                return(Ok());
            }
            else
            {
                return(BadRequest("当前软件已存在不可以新增!"));
            }
        }
Beispiel #3
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            if (string.IsNullOrEmpty(api))
            {
                MessageBox.Show("配置UpdateServiceAddress更新服务器地址!");
                return;
            }
            if (string.IsNullOrEmpty(joeySofyName))
            {
                MessageBox.Show("配置joeySofyName更新软件名称!");
                return;
            }
            Uri uir = new Uri(api + "/" + versionAddress + "/" + joeySofyName);

            joeySoftVersion = new JoeySoftVersion();
            using (HttpClient httpClient = new HttpClient())
            {
                joeySoftVersion = JsonConvert.DeserializeObject <JoeySoftVersion>
                                      (httpClient.GetAsync(uir).Result.Content.ReadAsStringAsync().Result);
                httpClient.Dispose();
            }
            Logging.WriteLog("获取服务器最新版本:" + joeySoftVersion.Version);
            joeySoftTfsToolPath = Path.GetDirectoryName(Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory));
            string exeFileName = Path.Combine(joeySoftTfsToolPath, "JoeySoftTfsTool.exe");

            Logging.WriteLog("读取exe:" + exeFileName);
            if (!File.Exists(exeFileName))
            {
                RunWork();
            }
            else
            {
                FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(exeFileName);
                if (VersionHelper.CompareVersion(myFileVersionInfo, joeySoftVersion) == false)
                {
                    MessageBox.Show("已经是最新版本" + myFileVersionInfo.FileVersion);
                    return;
                }
                if (joeySoftVersion.Version != myFileVersionInfo.FileVersion)
                {
                    RunWork();
                }
            }
        }
Beispiel #4
0
 /// <summary>
 /// 检查最新版本号判断是否需要更新
 /// </summary>
 public static JoeySoftVersion CheckUpdateClientVersion()
 {
     try
     {
         Uri             uir             = new Uri(api + "/" + versionActionName + "/" + updateClientJoeySofyName);
         JoeySoftVersion joeySoftVersion = new JoeySoftVersion();
         using (HttpClient httpClient = new HttpClient())
         {
             joeySoftVersion = JsonConvert.DeserializeObject <JoeySoftVersion>
                                   (httpClient.GetAsync(uir).Result.Content.ReadAsStringAsync().Result);
             httpClient.Dispose();
         }
         Logging.WriteLog("开始检查更新工具的最新版本:" + joeySoftVersion.Version);
         return(joeySoftVersion);
     }
     catch (Exception ex)
     {
         Logging.WriteErrorLog(ex);
         return(null);
     }
 }
Beispiel #5
0
        /// <summary>
        /// 检查最新版本号判断是否需要更新
        /// </summary>
        public static JoeySoftVersion CheckTfsDevelopVersion()
        {
            Uri             uri             = new Uri(api + "/" + versionActionName + "/" + tfsDevelopJoeySofyName);
            JoeySoftVersion joeySoftVersion = new JoeySoftVersion();

            using (HttpClient httpClient = new HttpClient())
            {
                HttpResponseMessage httpResponseMessage = httpClient.GetAsync(uri).Result;
                if (httpResponseMessage.StatusCode == HttpStatusCode.OK)
                {
                    joeySoftVersion = JsonConvert.DeserializeObject <JoeySoftVersion>(httpResponseMessage.Content.ReadAsStringAsync().Result);
                }
                else
                {
                    httpClient.Dispose();
                    throw new Exception("无法连接服务器URL:" + uri.AbsoluteUri + ",请联系管理员QQ:764578566");
                }
                httpClient.Dispose();
            }
            return(joeySoftVersion);
        }