Exemple #1
0
		/// <summary>
		/// 下载
		/// </summary>
		/// <param name="configId">
		/// 
		/// @return </param>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @RequestMapping(value = "/download/{configId}", method = org.springframework.web.bind.annotation.RequestMethod.GET) public org.springframework.http.HttpEntity<byte[]> downloadDspBill(@PathVariable long configId)
		public virtual HttpEntity<sbyte[]> downloadDspBill(long configId)
		{

			// 业务校验
			configValidator.valideConfigExist(configId);

			ConfListVo config = configMgr.getConfVo(configId);

			HttpHeaders header = new HttpHeaders();
			sbyte[] res = config.Value.GetBytes();
			if (res == null)
			{
				throw new DocumentNotFoundException(config.Key);
			}

			string name = null;

			try
			{
				name = URLEncoder.encode(config.Key, "UTF-8");
			}
			catch (UnsupportedEncodingException e)
			{
				Console.WriteLine(e.ToString());
				Console.Write(e.StackTrace);
			}

			header.set("Content-Disposition", "attachment; filename=" + name);
			header.ContentLength = res.Length;
			return new HttpEntity<sbyte[]>(res, header);
		}
Exemple #2
0
		/// <summary>
		/// 批量下载配置文件
		/// </summary>
		/// <param name="confListForm">
		/// 
		/// @return </param>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @RequestMapping(value = "/downloadfilebatch", method = org.springframework.web.bind.annotation.RequestMethod.GET) public org.springframework.http.HttpEntity<byte[]> download2(@Valid com.baidu.disconf.web.service.config.form.ConfListForm confListForm)
		public virtual HttpEntity<sbyte[]> download2(ConfListForm confListForm)
		{

			LOG.info(confListForm.ToString());

			//
			// get files
			//
			IList<File> fileList = configMgr.getDisconfFileList(confListForm);

			//
			// prefix
			//
			string prefixString = "APP" + confListForm.AppId + "_" + "ENV" + confListForm.EnvId + "_" + "VERSION" + confListForm.Version;

			HttpHeaders header = new HttpHeaders();

			string targetFileString = "";
			File targetFile = null;
			sbyte[] res = null;
			try
			{
				targetFileString = TarUtils.tarFiles("tmp", prefixString, fileList);
				targetFile = new File(targetFileString);
				res = IOUtils.toByteArray(new System.IO.FileStream(targetFile, System.IO.FileMode.Open, System.IO.FileAccess.Read));
			}
			catch (Exception)
			{
				throw new DocumentNotFoundException("");
			}

			header.set("Content-Disposition", "attachment; filename=" + targetFile.Name);
			header.ContentLength = res.Length;
			return new HttpEntity<sbyte[]>(res, header);
		}
Exemple #3
0
		/// <summary>
		/// 下载
		/// </summary>
		/// <param name="fileName">
		/// 
		/// @return </param>
		public virtual HttpEntity<sbyte[]> downloadDspBill(string fileName, string value)
		{

			HttpHeaders header = new HttpHeaders();
			sbyte[] res = value.GetBytes();

			string name = null;

			try
			{
				name = URLEncoder.encode(fileName, "UTF-8");
			}
			catch (UnsupportedEncodingException e)
			{
				Console.WriteLine(e.ToString());
				Console.Write(e.StackTrace);
			}

			header.set("Content-Disposition", "attachment; filename=" + name);
			header.ContentLength = res.Length;
			return new HttpEntity<sbyte[]>(res, header);
		}