Esempio n. 1
0
        /// <summary>
        /// 压缩
        /// </summary>
        private void Pack(PublishInfo publishInfo)
        {
            FastZip fz = new FastZip {
                CreateEmptyDirectories = true
            };

            fz.CreateZip(publishInfo.FileName, $@"publish\{publishInfo.AppInfo.AppName}", true, publishInfo.FileFilter, publishInfo.DirFilter);
        }
Esempio n. 2
0
        private PublishInfo CreatePublishInfo(DataGridViewRow row)
        {
            PublishInfo publishInfo = new PublishInfo
            {
                AppInfo = GetAppInfoFromGrid()
            };
            string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $@"upload\{publishInfo.AppInfo.AppName}");

            if (Directory.Exists(path) == false)
            {
                Directory.CreateDirectory(path);
            }

            publishInfo.FileName = Path.Combine(path, $"{publishInfo.AppInfo.AppName}.zip");

            publishInfo.FileFilter = null;
            publishInfo.DirFilter  = null;
            return(publishInfo);
        }
Esempio n. 3
0
 /// <summary>
 /// 上传
 /// </summary>
 private void Upload(PublishInfo publishInfo)
 {
     using (HttpClient client = new HttpClient())
     {
         client.BaseAddress = new Uri(publishInfo.AppInfo.ServerAddress);
         string apiUrl = "api/publish/upload";
         MultipartFormDataContent content = new MultipartFormDataContent();
         HttpResponseMessage      result;
         using (FileStream fs = new FileStream(publishInfo.FileName, FileMode.Open, FileAccess.Read))
         {
             content.Add(new StreamContent(fs), "file", Path.GetFileName(publishInfo.FileName));
             content.Add(new StringContent(JsonConvert.SerializeObject(publishInfo.AppInfo)), nameof(AppInfo));
             result = client.PostAsync(apiUrl, content).Result;
         }
         if (result.StatusCode == System.Net.HttpStatusCode.OK)
         {
             return;
         }
         throw new Exception(result.Content.ReadAsStringAsync().Result);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// 发布
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button2_Click_1(object sender, EventArgs e)
 {
     try
     {
         if (dgv.SelectedRows.Count == 0)
         {
             return;
         }
         PublishInfo publishInfo   = CreatePublishInfo(dgv.SelectedRows[0]);
         bool        publishDllRes = PublishDll(publishInfo.AppInfo);
         if (publishDllRes == false)
         {
             throw new Exception("发布dll失败");
         }
         Pack(publishInfo);
         Upload(publishInfo);
         MessageBox.Show("成功");
     }
     catch (Exception ex)
     {
         MessageBox.Show($"失败:{ex}");
     }
 }