FrmMicroShare.cs 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249
  1. using Aliyun.OSS;
  2. using LYFZ.ComponentLibrary;
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using System.Collections.Specialized;
  7. using System.ComponentModel;
  8. using System.Data;
  9. using System.Drawing;
  10. using System.IO;
  11. using System.Linq;
  12. using System.Net;
  13. using System.Text;
  14. using System.Windows.Forms;
  15. namespace LYFZ.Software.MainBusiness.MicroShare
  16. {
  17. public partial class FrmMicroShare : LYFZ.Software.UI.MicroShare.FrmMicroShare
  18. {
  19. private delegate void UpdateControl();
  20. public FrmMicroShare()
  21. {
  22. this.buttonExit.Click += buttonExit_Click;
  23. // this.rdo_yxb1.CheckedChanged += rdo_photo_type_CheckedChanged;
  24. // this.rdo_yxb_kb.CheckedChanged += rdo_photo_type_CheckedChanged;
  25. // this.rdo_yxb_la_1.CheckedChanged += rdo_photo_type_CheckedChanged;
  26. this.likSelect.Click += likSelect_Click;
  27. this.cbxTemplates.SelectedIndexChanged += cbxTemplates_SelectedIndexChanged;
  28. this.btnWebMp3.Click += btnWebMp3_Click;
  29. // testOSS();
  30. }
  31. /// <summary>
  32. /// 测试
  33. /// </summary>
  34. void testOSS()
  35. {
  36. var client = new OssClient("oss-cn-shanghai.aliyuncs.com", "LTAI4AxacSz3Y3tt", "xCDW8AtaqmYqZMNzszFEHChfIp26E0");
  37. try
  38. {
  39. string photoFile = @"D:\Original_IMG_9961.jpg";
  40. string imgMd5 = LYFZ.WinAPI.SDKSecurity.GetMD5HashFromFile(photoFile);
  41. //customer-photos/<date>
  42. string key = imgMd5;
  43. bool retBl = client.DoesObjectExist("lyfz-enterprise-photocache", key);
  44. // client.DeleteObject("lyfz-enterprise-photocache", key);
  45. if (!retBl)
  46. {
  47. PutObjectResult ret = client.PutObject("lyfz-enterprise-photocache", key, photoFile);
  48. }
  49. string imgurl = "https://lyfz-enterprise-photocache.oss-cn-shanghai.aliyuncs.com/" + key;
  50. }
  51. catch (Exception ex)
  52. {
  53. MessageBoxCustom.Show("上传相片时失败,原因:" + ex.Message);
  54. }
  55. }
  56. string webMP3Path = "";
  57. bool isWebMP3 = false;
  58. void btnWebMp3_Click(object sender, EventArgs e)
  59. {
  60. frmWebMp3 webMP3 = new frmWebMp3();
  61. if (webMP3.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  62. {
  63. webMP3Path = webMP3.WebMP3Path;
  64. this.txtMusieUpload.Text = "网络MP3:"+webMP3.Mp3Name;
  65. isWebMP3 = true;
  66. }
  67. }
  68. void cbxTemplates_SelectedIndexChanged(object sender, EventArgs e)
  69. {
  70. try
  71. {
  72. if (this.cbxTemplates.SelectedItem != null)
  73. {
  74. ItemValue item = (ItemValue)this.cbxTemplates.SelectedItem;
  75. LYFZ.Model.MicroShareTemplate msTemplate = (LYFZ.Model.MicroShareTemplate)item.Value;
  76. this._photo_type = msTemplate.TemplateCode.Trim();
  77. }
  78. }
  79. catch {
  80. this._photo_type = "yxb_kb";
  81. }
  82. }
  83. void likSelect_Click(object sender, EventArgs e)
  84. {
  85. LYFZ.Software.MainBusiness.SMSManagement.frmSelectSmsInfo selectInfo = new LYFZ.Software.MainBusiness.SMSManagement.frmSelectSmsInfo();
  86. if (selectInfo.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  87. {
  88. if (selectInfo.SmsModel.ID > 0)
  89. {
  90. this.txtGreetings.Text = selectInfo.SmsModel.ST_SMSContent;
  91. }
  92. }
  93. }
  94. static string accessKeyId = "0";
  95. static string accessKeySecret = "0";
  96. static string endpoint = "https://oss-cn-shenzhen.aliyuncs.com";//Config.Endpoint;
  97. static string securityToken = "0";
  98. static string bucketName = "lyfz-yxb";
  99. /// <summary>
  100. /// 获取阿里云服务器上文件地址
  101. /// </summary>
  102. /// <param name="key"></param>
  103. /// <returns></returns>
  104. static string GetAliyunOSSServerPath(string key)
  105. {
  106. //https://lyfz-yxb.oss-cn-shenzhen.aliyuncs.com/customer-musics/JSB
  107. return endpoint.ToLower().Replace("https://", "https://" + bucketName + ".")
  108. .Replace("http://", "http://" + bucketName + ".").Trim('/')+"/"+key;
  109. }
  110. /// <summary>
  111. /// 获取阿里云
  112. /// </summary>
  113. void GetAliyunOSSAccessKey()
  114. {
  115. try
  116. {
  117. try
  118. {
  119. string retEndpoint = LYFZ.WinAPI.CustomPublicMethod.HttpWebRequestGET(domainName + "/api/alioss/get.php", Encoding.UTF8, myCookieContainer, isUrlDecode: false);
  120. dynamic EndpointJson = Newtonsoft.Json.JsonConvert.DeserializeObject(retEndpoint);
  121. endpoint = EndpointJson.endpoint;
  122. bucketName = EndpointJson.bucketname;
  123. }
  124. catch { }
  125. string retAccessKey = LYFZ.WinAPI.CustomPublicMethod.HttpWebRequestGET(domainName + "/api/alioss/getSTSaccess.php", Encoding.UTF8, myCookieContainer, isUrlDecode: false);
  126. dynamic AccessKeyJson = Newtonsoft.Json.JsonConvert.DeserializeObject(retAccessKey);
  127. accessKeyId = AccessKeyJson.Credentials.AccessKeyId.ToString().Trim();
  128. accessKeySecret = AccessKeyJson.Credentials.AccessKeySecret.ToString().Trim();
  129. securityToken = AccessKeyJson.Credentials.SecurityToken.ToString().Trim();
  130. }
  131. catch {
  132. }
  133. }
  134. LYFZ.Model.MicroShareTemplates microTemplate = new Model.MicroShareTemplates();
  135. void LoadMicroShareTemplates()
  136. {
  137. try
  138. {
  139. string retTemplates = LYFZ.WinAPI.CustomPublicMethod.HttpWebRequestGET(domainName+"/index.php?m=Photo&a=template", Encoding.UTF8);
  140. dynamic TemplatesJson = Newtonsoft.Json.JsonConvert.DeserializeObject(retTemplates);
  141. if (TemplatesJson.status.ToString() == "200")
  142. {
  143. string defaultTemplate = TemplatesJson.data.defaults.ToString();
  144. foreach (dynamic Template in TemplatesJson.data.templates)
  145. {
  146. LYFZ.Model.MicroShareTemplate msTemplate = new Model.MicroShareTemplate();
  147. if (Template.value.ToString() == defaultTemplate)
  148. {
  149. msTemplate.IsDefault = true;
  150. microTemplate.DefaultTemplate = msTemplate;
  151. }
  152. msTemplate.TemplateName = Template.text.ToString();
  153. msTemplate.TemplateCode = Template.value.ToString();
  154. microTemplate.MicroShareTemplateList.Add(msTemplate);
  155. }
  156. }
  157. else {
  158. MessageBoxCustom.Show("获取相册模板失败:" + TemplatesJson.info.ToString());
  159. }
  160. }
  161. catch (Exception ex){
  162. MessageBoxCustom.Show("获取相册模板失败:"+ex.Message);
  163. }
  164. }
  165. public static string domainName = "http://yxb.lyfz.net";//"yxb.lyfz.net"ayafafa.com;
  166. string _photo_type = "yxb_kb";
  167. /// <summary>
  168. /// 相册类型
  169. /// </summary>
  170. public string Photo_type
  171. {
  172. get { return _photo_type; }
  173. set { _photo_type = value; }
  174. }
  175. /* void rdo_photo_type_CheckedChanged(object sender, EventArgs e)
  176. {
  177. try
  178. {
  179. this._photo_type = ((RadioButtonEx)sender).Tag.ToString();
  180. }
  181. catch {
  182. this._photo_type = "yxb_kb";
  183. }
  184. }*/
  185. void buttonExit_Click(object sender, EventArgs e)
  186. {
  187. this.Close();
  188. }
  189. /// <summary>
  190. /// 像片集合
  191. /// </summary>
  192. public List<string> SPhotoList = new List<string>();
  193. /// <summary>
  194. /// 客户姓名
  195. /// </summary>
  196. public string F_CusName;
  197. private string _F_Attractions;
  198. /// <summary>
  199. /// 拍摄景点
  200. /// </summary>
  201. public string F_Attractions
  202. {
  203. get { return _F_Attractions; }
  204. set { _F_Attractions = value; }
  205. }
  206. /// <summary>
  207. /// 化妆师
  208. /// </summary>
  209. public string F_MakeupArtist;
  210. /// <summary>
  211. /// 订单号
  212. /// </summary>
  213. public string F_Number;
  214. #region 显示图片与数据
  215. protected override void FrmMicroShare_Shown(object sender, EventArgs e)
  216. {
  217. try
  218. {
  219. ImageList ImageList1 = new ImageList();
  220. List<string> listName = new List<string>();
  221. List<string> listPath = new List<string>();
  222. ImageList1.ColorDepth = ColorDepth.Depth32Bit;
  223. ImageList1.ImageSize = new Size(95, 100);
  224. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  225. {
  226. backgroundWorker.ReportProgress(0, "正在获取模板...");
  227. LoadMicroShareTemplates();
  228. backgroundWorker.ReportProgress(0, "正在加载相片...");
  229. // this.Invoke(new UpdateControl(delegate()
  230. // {
  231. for (int i = 0; i < SPhotoList.Count; i++)
  232. {
  233. string PhotoPath = SPhotoList[i].Trim();
  234. string aa = LYFZ.BLL.SelectPhotoHandling.SmallPathToOriginalPath(PhotoPath);
  235. string bb = LYFZ.BLL.SelectPhotoHandling.ServerFileNameToOriginalName(BLL.SelectPhotoHandling.PhotoType.Preview, System.IO.Path.GetFileName(aa));
  236. string PhotoName = System.IO.Path.GetFileNameWithoutExtension(PhotoPath);
  237. using (System.IO.FileStream fs = new System.IO.FileStream(PhotoPath, System.IO.FileMode.Open, System.IO.FileAccess.Read))
  238. {
  239. Image image = System.Drawing.Image.FromStream(fs);
  240. ImageList1.Images.Add(PhotoPath, image);
  241. listName.Add(LYFZ.BLL.SelectPhotoHandling.SmallNameToOriginalName(PhotoName));
  242. listPath.Add(PhotoPath);
  243. fs.Close();
  244. }
  245. }
  246. // }));
  247. });
  248. #region 显示图片
  249. this.lstPic.LargeImageList = ImageList1;
  250. this.lstPic.View = View.LargeIcon;
  251. for (int i = 0; i < ImageList1.Images.Count; i++)
  252. {
  253. ListViewItem lvi = new ListViewItem();
  254. lvi.ImageIndex = i;
  255. lvi.Text = listName[i];
  256. lvi.Tag = listPath[i];
  257. lvi.ToolTipText = listName[i];
  258. this.lstPic.Items.Add(lvi);
  259. }
  260. #endregion
  261. #region 显示内容
  262. txtCustomerName.Text = F_CusName;
  263. txtShootingAttractions.Text = F_Attractions;
  264. txtMakeupArtist.Text = F_MakeupArtist;
  265. #endregion
  266. txtCount.Text = "0";
  267. foreach (LYFZ.Model.MicroShareTemplate msTemplate in this.microTemplate.MicroShareTemplateList)
  268. {
  269. ItemValue item=new ItemValue(msTemplate, msTemplate.TemplateName);
  270. this.cbxTemplates.Items.Add(item);
  271. if (msTemplate.IsDefault)
  272. {
  273. this.cbxTemplates.SelectedItem = item;
  274. }
  275. }
  276. if (this.cbxTemplates.Items.Count>0&&this.cbxTemplates.SelectedItem == null)
  277. {
  278. this.cbxTemplates.SelectedIndex = 0;
  279. }
  280. }
  281. catch (Exception ex)
  282. {
  283. MessageBoxCustom.Show(ex.Message);
  284. }
  285. }
  286. #endregion
  287. #region 上传
  288. protected override void btnUpload_Click(object sender, EventArgs e)
  289. {
  290. try
  291. {
  292. #region 判断
  293. if (lstPic.CheckedItems.Count == 0)
  294. {
  295. MessageBoxCustom.Show("请勾选你要分享的图片!");
  296. return;
  297. }
  298. int ZhangSum = Convert.ToInt32(txtCount.Text);
  299. if (ZhangSum >20)
  300. {
  301. MessageBoxCustom.Show("请分享的图片超过最大张数!");
  302. return;
  303. }
  304. if (string.IsNullOrEmpty(txtAlbumTitle.Text))
  305. {
  306. MessageBoxCustom.Show("相册标题不能为空!");
  307. return;
  308. }
  309. if (string.IsNullOrEmpty(txtCustomerName.Text))
  310. {
  311. MessageBoxCustom.Show("客户姓名不能为空!");
  312. return;
  313. }
  314. if (txtAlbumTitle.Text.Trim().Length>10)
  315. {
  316. MessageBoxCustom.Show("相册标题不能大于10个字符!");
  317. return;
  318. }
  319. if (txtAlbumItroduction.Text.Trim().Length > 150)
  320. {
  321. MessageBoxCustom.Show("相册介绍不能大于150个字符!");
  322. return;
  323. }
  324. if (txtGreetings.Text.Trim().Length > 100)
  325. {
  326. MessageBoxCustom.Show("祝福语不能大于100个字符!");
  327. return;
  328. }
  329. #endregion
  330. #region 获取赢销宝接口
  331. //检查赢销宝登录
  332. if (CheckYxbLogin())
  333. {
  334. //创建图片 并上传
  335. CreatePic();
  336. }
  337. #endregion
  338. }
  339. catch (Exception ex)
  340. {
  341. MessageBoxCustom.Show(ex.Message);
  342. }
  343. }
  344. #endregion
  345. #region 选中项改变事件
  346. protected override void lstPic_ItemChecked(object sender, ItemCheckedEventArgs e)
  347. {
  348. try
  349. {
  350. if (lstPic.CheckedItems.Count > 0)
  351. {
  352. txtCount.Text = lstPic.CheckedItems.Count.ToString();
  353. }
  354. else { txtCount.Text = "0"; }
  355. }
  356. catch (Exception ex)
  357. {
  358. MessageBoxCustom.Show(ex.Message);
  359. }
  360. }
  361. #endregion
  362. #region 全选
  363. protected override void btnAll_Click(object sender, EventArgs e)
  364. {
  365. try
  366. {
  367. for (int i = 0; i < lstPic.Items.Count; i++)
  368. {
  369. lstPic.Items[i].Checked = true;
  370. }
  371. }
  372. catch (Exception ex)
  373. {
  374. MessageBoxCustom.Show(ex.Message);
  375. }
  376. }
  377. #endregion
  378. #region 取消
  379. protected override void btnCancel_Click(object sender, EventArgs e)
  380. {
  381. try
  382. {
  383. for (int i = 0; i < lstPic.Items.Count; i++)
  384. {
  385. lstPic.Items[i].Checked = false;
  386. }
  387. }
  388. catch (Exception ex)
  389. {
  390. MessageBoxCustom.Show(ex.Message);
  391. }
  392. }
  393. #endregion
  394. #region 右键菜单事件
  395. /// <summary>
  396. /// 取消
  397. /// </summary>
  398. /// <param name="sender"></param>
  399. /// <param name="e"></param>
  400. protected override void toolCancel_Click(object sender, EventArgs e)
  401. {
  402. if (lstPic.SelectedItems.Count > 0)
  403. {
  404. for (int i = 0; i < lstPic.SelectedItems.Count; i++)
  405. {
  406. lstPic.SelectedItems[i].Checked = false;
  407. }
  408. }
  409. }
  410. /// <summary>
  411. /// 选中
  412. /// </summary>
  413. /// <param name="sender"></param>
  414. /// <param name="e"></param>
  415. protected override void toolSelected_Click(object sender, EventArgs e)
  416. {
  417. if (lstPic.SelectedItems.Count > 0)
  418. {
  419. for (int i = 0; i < lstPic.SelectedItems.Count; i++)
  420. {
  421. lstPic.SelectedItems[i].Checked = true;
  422. }
  423. }
  424. }
  425. #endregion
  426. #region 浏览上传背景音乐
  427. string PhotoFilePath = "";
  428. string MiuseUpLoadName = "";
  429. protected override void btnBrowse_Click(object sender, EventArgs e)
  430. {
  431. #region 判断
  432. /* if (lstPic.CheckedItems.Count == 0)
  433. {
  434. MessageBoxCustom.Show("请打勾你要分享的图片!");
  435. return;
  436. }
  437. int ZhangSum = Convert.ToInt32(txtCount.Text);
  438. if (ZhangSum > 20)
  439. {
  440. MessageBoxCustom.Show("请分享的图片超过最大张数!");
  441. return;
  442. }
  443. if (string.IsNullOrEmpty(txtAlbumTitle.Text))
  444. {
  445. MessageBoxCustom.Show("相册标题不能为空!");
  446. return;
  447. }
  448. if (string.IsNullOrEmpty(txtCustomerName.Text))
  449. {
  450. MessageBoxCustom.Show("客户姓名不能为空!");
  451. return;
  452. }*/
  453. #endregion
  454. openFileDialog1.Filter = "mp3文件(*.mp3)|*.mp3";
  455. openFileDialog1.FileName = "";
  456. if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  457. {
  458. PhotoFilePath = openFileDialog1.FileName;
  459. txtMusieUpload.Text = PhotoFilePath;
  460. isWebMP3 = false;
  461. //判断文件大小
  462. FileInfo fileInfo = new FileInfo(PhotoFilePath);
  463. int ShowFileSize = Convert.ToInt32(fileInfo.Length) / Convert.ToInt32(1024);//文件大小
  464. if (ShowFileSize > 2048)
  465. {
  466. MessageBoxCustom.Show("由于文件过大将影响相册打开速度和浪费客户流量,所以不能超过2MB,建意上传小于1MB以下的MP3!");
  467. txtMusieUpload.Text = "";
  468. }
  469. /* else
  470. {
  471. //WaitForm wf = new WaitForm();
  472. //wf.ShowForm(this);
  473. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  474. {
  475. CheckYxbLogin();
  476. // this.Invoke(new UpdateControl(delegate()
  477. // {
  478. backgroundWorker.ReportProgress(0, "正在上传音乐请稍等...");
  479. string ResponseHtmlUpLoad = null;
  480. string FormUrl = null;
  481. #region 获取上传文件音频路径
  482. FormUrl = "http://yxb.lyfz.net/index.php?m=Photo&a=upload_file";
  483. Hashtable hastable = new Hashtable();
  484. string file = PhotoFilePath;
  485. hastable["file1"] = file;
  486. ResponseHtmlUpLoad = SendHttpRequestPost(FormUrl, null, hastable, Encoding.UTF8).Replace("\"", "").Replace("\\", "").Replace(",info", "|").Replace("{data:[", "").Replace("]", "");
  487. MiuseUpLoadName = ResponseHtmlUpLoad.Split('|')[0];
  488. //wf.CloseForm();
  489. //wf = null;
  490. #endregion
  491. // MessageBoxCustom.Show(MiuseUpLoadName);
  492. // }));
  493. });
  494. if (MiuseUpLoadName.Trim().Length > 0)
  495. {
  496. }
  497. else { }
  498. }*/
  499. }
  500. }
  501. #endregion
  502. bool uploadMP3(string mp3Path)
  503. {
  504. if (mp3Path.Length <= 0) { return false; }
  505. if (isWebMP3)
  506. {
  507. MiuseUpLoadName = this.webMP3Path;
  508. return true;
  509. }
  510. else
  511. {
  512. var client = new OssClient(endpoint, accessKeyId, accessKeySecret, securityToken);
  513. try
  514. {
  515. string fileToUpload = mp3Path;//@"C:\Users\Administrator\Downloads\记事本.mp3";
  516. string mp3Md5 = LYFZ.WinAPI.SDKSecurity.GetMD5HashFromFile(fileToUpload);
  517. string key = "customer-musics/" + mp3Md5;
  518. bool retBl = client.DoesObjectExist(bucketName, key);
  519. if (!retBl)
  520. {
  521. PutObjectResult ret = client.PutObject(bucketName, key, fileToUpload);
  522. }
  523. MiuseUpLoadName = GetAliyunOSSServerPath(key);
  524. return true;
  525. }
  526. catch
  527. {
  528. return false;
  529. }
  530. }
  531. //旧版上传接口
  532. //string ResponseHtmlUpLoad = null;
  533. // string FormUrl = null;
  534. #region 获取上传文件音频路径
  535. // FormUrl = domainName + "/index.php?m=Photo&a=upload_file";
  536. // Hashtable hastable = new Hashtable();
  537. //string file = PhotoFilePath;
  538. //hastable["file1"] = file;
  539. /* ResponseHtmlUpLoad = SendHttpRequestPost(FormUrl, null, hastable, Encoding.UTF8).Replace("\"", "").Replace("\\", "").Replace(",info", "|").Replace("{data:[", "").Replace("]", "");
  540. MiuseUpLoadName = ResponseHtmlUpLoad.Split('|')[0];
  541. if (MiuseUpLoadName.Trim().Length > 0)
  542. {
  543. return true;
  544. }
  545. else {
  546. return false;
  547. }*/
  548. #endregion
  549. }
  550. #region 赢销宝接口
  551. #region 检查赢销宝登录
  552. /// <summary>
  553. /// 检查赢销宝登录
  554. /// </summary>
  555. public bool CheckYxbLogin()
  556. {
  557. try
  558. {
  559. LYFZ.BLL.BaseBLL.BaseBLL_ErpCompanyInfo CompanyInfoBll = new BLL.BaseBLL.BaseBLL_ErpCompanyInfo();
  560. DataTable dt = CompanyInfoBll.GetList("Company_DividedShop='" + LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetCompanyInfoID() + "'").Tables[0];
  561. string password = "";
  562. string uid = "";
  563. if (dt.Rows.Count > 0)
  564. {
  565. uid = dt.Rows[0]["Company_MicroShareAccount"].ToString();
  566. password = dt.Rows[0]["Company_MicroSharePassword"].ToString();
  567. }
  568. string FormData = null;
  569. string FormUrl = null;
  570. FormData = string.Format("username={0}&password={1}", uid, password); // 要发放的数据
  571. FormUrl = domainName + "/index.php?m=Photo&a=login";
  572. string ResponseHtml = HttpPost(FormUrl, FormData);
  573. if (ResponseHtml == "2")
  574. {
  575. MessageBoxCustom.Show("登陆失败!请在本店信息设置账户与密码是否正确!");
  576. return false;
  577. }
  578. if (ResponseHtml == "3")
  579. {
  580. MessageBoxCustom.Show("账号未开通权限!");
  581. return false;
  582. }
  583. return true;
  584. //创建图片
  585. // CreatePic();
  586. //switch (ResponseHtml)
  587. //{
  588. // //case "1":
  589. // // MessageBoxCustom.Show("登录成功!");
  590. // // break;
  591. // case "2":
  592. // MessageBoxCustom.Show("登陆失败!");
  593. // break;
  594. // case "3":
  595. // MessageBoxCustom.Show("账号未开通权限!");
  596. // break;
  597. //}
  598. }
  599. catch (Exception ex)
  600. {
  601. MessageBoxCustom.Show("赢销宝帐号登录失败:" + ex.Message);
  602. return false;
  603. }
  604. }
  605. #endregion
  606. #region 创建图片
  607. /// <summary>
  608. /// 创建图片
  609. /// </summary>
  610. public void CreatePic()
  611. {
  612. try
  613. {
  614. // string ResponseHtmlUpLoad = "";
  615. /*if (myCookieContainer == null)
  616. {
  617. CheckYxbLogin();
  618. }*/
  619. string FormData = "";
  620. string FormUrl = domainName+"/index.php?m=Photo&a=upload_file";
  621. string UpLoadName = "";
  622. #region 获取上传图片文件音频路径
  623. Hashtable hastable = new Hashtable();
  624. // int fileSum = 0;
  625. //获取选中图片上传
  626. try
  627. {
  628. string MP3Path = txtMusieUpload.Text.Trim();
  629. int FolderImageCount = this.lstPic.CheckedItems.Count;
  630. List<string> uploadphotoList = new List<string>();
  631. for (int i = 0; i < FolderImageCount; i++)
  632. {
  633. ListViewItem lv = lstPic.CheckedItems[i];
  634. if (lv != null)
  635. {
  636. string file = LYFZ.BLL.SelectPhotoHandling.SmallPathToPreviewPath(lv.Tag.ToString());
  637. uploadphotoList.Add(file);
  638. }
  639. }
  640. LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  641. {
  642. backgroundWorker.ReportProgress(0, "正在验证上传请求...");
  643. GetAliyunOSSAccessKey();
  644. backgroundWorker.ReportProgress(0, "准备上传文件...");
  645. if (MP3Path.Trim().Length > 0)
  646. {
  647. backgroundWorker.ReportProgress(60, "正在上传音乐,需要时间较长...");
  648. if (uploadMP3(MP3Path))
  649. {
  650. backgroundWorker.ReportProgress(100, "音乐上传成功...");
  651. }
  652. else
  653. {
  654. // MessageBoxCustom.Show("音乐上传失败",backgroundWorker:backgroundWorker);
  655. throw new Exception("上传背景音乐文件时失败");
  656. }
  657. }
  658. int ForCount = 0;
  659. backgroundWorker.ReportProgress(10, "正在上传相片,请稍等...");
  660. var client = new OssClient(endpoint, accessKeyId, accessKeySecret, securityToken);
  661. try
  662. {
  663. foreach (string photoPath in uploadphotoList)
  664. {
  665. string photoFile = photoPath;
  666. string imgMd5 = LYFZ.WinAPI.SDKSecurity.GetMD5HashFromFile(photoFile);
  667. //customer-photos/<date>
  668. string key = "customer-photos/" + SDateTime.Now.ToString("yyyyMM") + "/" + imgMd5;
  669. bool retBl = client.DoesObjectExist(bucketName, key);
  670. if (!retBl)
  671. {
  672. if (".jpg,.png.jpge".Contains(System.IO.Path.GetExtension(photoPath).ToLower().Trim()))
  673. {
  674. Bitmap bmp = LYFZ.BLL.SelectPhotoHandling.GeneratePreviewBitmap(photoPath, 640, 960);
  675. photoFile = LYFZ.ImageFunction.ThumbImgae.SaveTemporaryCompressionImage(bmp, System.IO.Path.GetFileName(photoPath));
  676. }
  677. PutObjectResult ret = client.PutObject(bucketName, key, photoFile);
  678. if (".jpg,.png.jpge".Contains(System.IO.Path.GetExtension(photoFile).ToLower().Trim()))
  679. {
  680. LYFZ.ImageFunction.ThumbImgae.DeleteTemporaryCompressionImage(photoFile);
  681. }
  682. }
  683. UpLoadName += GetAliyunOSSServerPath(key) + "|";
  684. try
  685. { backgroundWorker.ReportProgress(Convert.ToInt32(1000 / FolderImageCount * (ForCount + 1))); ForCount++; }
  686. catch { }
  687. }
  688. }
  689. catch(Exception ex)
  690. {
  691. MessageBoxCustom.Show("上传相片时失败,原因1:" + ex.Message,backgroundWorker:backgroundWorker);
  692. }
  693. }, width: 500);
  694. }
  695. catch (Exception ex)
  696. {
  697. MessageBoxCustom.Show("上传相片时失败,原因2:" + ex.Message);
  698. return;
  699. }
  700. #endregion
  701. #region 截取封面图片,创建图片
  702. string[] strUpLoadName = UpLoadName.Split('|');
  703. FormUrl = domainName + "/index.php?m=Photo&a=add";
  704. //获取参数数据
  705. string title = txtAlbumTitle.Text.Trim().Replace("&", "&");
  706. string customer_name = txtCustomerName.Text.Trim().Replace("&", "&").Replace("/", "&");
  707. string location = txtShootingAttractions.Text.Trim().Replace("&", "&");
  708. string picurl = strUpLoadName[0].ToString().Replace("{data:[", "").Replace("}", "").Replace("]", "").Split(',')[0];
  709. string info = txtAlbumItroduction.Text.Trim().Replace("&", "&");
  710. string dresser = txtMakeupArtist.Text.Trim().Replace("&", "&");
  711. string bg_audio_url = MiuseUpLoadName;// MuiseUpLoad.Split(',')[0].ToString().Replace("{data:[", "").Replace("}", "").Replace("]", "");
  712. string comment_text1 = txtGreetings.Text.Trim().Replace("&", "&");
  713. FormData = string.Format("title={0}&customer_name={1}&location={2}&picurl={3}&info={4}&dresser={5}&bg_audio_url={6}&photo_type={7}&comment_text1={8}", title, customer_name, location, picurl, info, dresser, bg_audio_url, Photo_type, comment_text1); // 要发放的数据
  714. string ResponseHtml = HttpPost(FormUrl, FormData);
  715. try
  716. {
  717. dynamic AccessKeyJson = Newtonsoft.Json.JsonConvert.DeserializeObject(ResponseHtml);
  718. if (AccessKeyJson.status != 200)
  719. {
  720. MessageBoxCustom.Show("添加相册时失败:" + AccessKeyJson.info);
  721. return;
  722. }
  723. }
  724. catch (Exception ex){
  725. MessageBoxCustom.Show("添加相册时出错:"+ex.Message);
  726. return;
  727. }
  728. // 插入数据与获取返回状态
  729. string[] str = ResponseHtml.Split(',');
  730. if (str.Length >= 3 && ResponseHtml.Contains("\"data\":"))
  731. {
  732. string str_data = str[0].ToString().Replace("{\"data\":", "");
  733. string str_info = str[1].ToString().Replace("info\":\"", "").Replace("\"", "");
  734. string str_status = str[2].ToString().Replace("\"status\":", "").Replace("}", "");
  735. switch (str_status)
  736. {
  737. //case "200":
  738. // MessageBoxCustom.Show("创建成功!");
  739. // break;
  740. case "201":
  741. MessageBoxCustom.Show("创建失败!");
  742. break;
  743. case "202":
  744. MessageBoxCustom.Show("时间超长,请关闭后在打开窗体!");
  745. break;
  746. case "203":
  747. MessageBoxCustom.Show("出现异常,可能是参数不正确");
  748. break;
  749. }
  750. #endregion
  751. #region 创建成功后上传图片获取二维码
  752. if (str_status == "200")
  753. {
  754. try
  755. {
  756. #region 上传图片
  757. FormUrl = domainName + "/index.php?m=Photo&a=upload";
  758. //string[] strUpload = ResponseHtmlUpLoad.Split(',');
  759. string pid = str_data;
  760. string strAdd = "pid=" + pid + "";
  761. for (int t = 0; t < strUpLoadName.Length - 1; t++)
  762. {
  763. int u = t + 1;
  764. string str_dataUpdate = strUpLoadName[t]; //strUpload[t].ToString().Replace("{data:[", "").Replace("}", "").Replace("]", "");
  765. // str_dataUpdate = str_dataUpdate.Split(',')[0].ToString().Replace("info\":\"", "").Replace("\"", "");
  766. string url = str_dataUpdate;
  767. string description = "";
  768. strAdd += "&photoid[]=" + Convert.ToInt32(u) + "&url[]=" + url + "&description=" + description + "";
  769. }
  770. ResponseHtml = HttpPost(FormUrl, strAdd);
  771. #endregion
  772. #region 获取二维码
  773. Random rad = new Random();
  774. FormUrl = domainName + "/index.php?m=Photo&a=getQrcode";
  775. pid = str_data;
  776. FormData = string.Format("pid={0}", pid); // 要发放的数据
  777. // string FileName = GetQrcodePath() + "\\" + F_Number + "(" + rad.Next(1000, 10000) + ")" + ".png";
  778. try
  779. {
  780. Bitmap retBmp = SavePhotoFromUrl(FormUrl, FormData);
  781. if (retBmp != null)
  782. {
  783. picTwoDimensionalCode.Image = retBmp;
  784. }
  785. else
  786. {
  787. MessageBoxCustom.Show("获取二维码失败");
  788. }
  789. }
  790. catch (Exception ex)
  791. {
  792. MessageBoxCustom.Show("显示二维码时出错:" + ex.Message);
  793. }
  794. #endregion
  795. }
  796. catch (Exception ex)
  797. {
  798. MessageBoxCustom.Show("提交相片信息时出错:"+ex.Message);
  799. }
  800. }
  801. }
  802. else
  803. {
  804. MessageBoxCustom.Show("上传出错:" + ResponseHtml);
  805. }
  806. #endregion
  807. }
  808. catch (Exception ex)
  809. {
  810. MessageBoxCustom.Show("上传失败,原因:" + ex.Message);
  811. }
  812. }
  813. #endregion
  814. #endregion
  815. #region post提交方法
  816. #region URL请求数据
  817. CookieContainer myCookieContainer = new CookieContainer();
  818. #region URL请求数据
  819. /// <summary>
  820. /// HTTP POST方式请求数据
  821. /// </summary>
  822. /// <param name="url">URL.</param>
  823. /// <param name="param">POST的数据</param>
  824. /// <returns></returns>
  825. public string HttpPost(string url, string param)
  826. {
  827. HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
  828. request.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/x-silverlight, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-silverlight-2-b1, */*";
  829. request.Method = "POST";
  830. request.ContentType = "application/x-www-form-urlencoded";
  831. request.Accept = "*/*";
  832. request.Timeout = 15000;
  833. request.AllowAutoRedirect = false;
  834. StreamWriter requestStream = null;
  835. WebResponse response = null;
  836. string responseStr = "";
  837. request.CookieContainer = myCookieContainer;
  838. try
  839. {
  840. requestStream = new StreamWriter(request.GetRequestStream());
  841. requestStream.Write(param);
  842. requestStream.Close();
  843. response = request.GetResponse();
  844. if (response != null)
  845. {
  846. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  847. responseStr = reader.ReadToEnd();
  848. reader.Close();
  849. }
  850. }
  851. catch (Exception ex)
  852. {
  853. throw new Exception(ex.Message);
  854. }
  855. finally
  856. {
  857. request = null;
  858. requestStream = null;
  859. response = null;
  860. }
  861. return responseStr;
  862. }
  863. #endregion
  864. #endregion
  865. #region 向指定的URL地址发起一个POST请求,同时可以上传一些数据项以及上传文件。
  866. /// <summary>
  867. /// 向指定的URL地址发起一个POST请求,同时可以上传一些数据项以及上传文件。
  868. /// </summary>
  869. /// <param name="url">要请求的URL地址</param>
  870. /// <param name="keyvalues">要上传的数据项</param>
  871. /// <param name="fileList">要上传的文件列表</param>
  872. /// <param name="encoding">发送数据项,接收的字符编码方式</param>
  873. /// <returns>服务器的返回结果</returns>
  874. public string SendHttpRequestPost(string url, Hashtable keyvalues, Hashtable fileList, Encoding encoding)
  875. {
  876. //if (fileList == null)
  877. // return SendHttpRequestPost(url, keyvalues, encoding);
  878. if (string.IsNullOrEmpty(url))
  879. throw new ArgumentNullException("url");
  880. if (encoding == null)
  881. encoding = Encoding.UTF8;
  882. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
  883. request.Method = "POST"; // 要上传文件,一定要是POST方法
  884. // 数据块的分隔标记,用于设置请求头,注意:这个地方最好不要使用汉字。
  885. string boundary = "---------------------------" + Guid.NewGuid().ToString("N");
  886. // 数据块的分隔标记,用于写入请求体。
  887. // 注意:前面多了一段: "--" ,而且它们将独占一行。
  888. byte[] boundaryBytes = Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n");
  889. // 设置请求头。指示是一个上传表单,以及各数据块的分隔标记。
  890. request.ContentType = "multipart/form-data; boundary=" + boundary;
  891. request.CookieContainer = myCookieContainer;
  892. // 先得到请求流,准备写入数据。
  893. Stream stream = request.GetRequestStream();
  894. //if (keyvalues != null && keyvalues.Count > 0)
  895. //{
  896. // // 写入非文件的keyvalues部分
  897. // //foreach (KeyValuePair<string, string> kvp in keyvalues)
  898. // foreach (DictionaryEntry kvp in keyvalues)
  899. // {
  900. // // 写入数据块的分隔标记
  901. // stream.Write(boundaryBytes, 0, boundaryBytes.Length);
  902. // // 写入数据项描述,这里的Value部分可以不用URL编码
  903. // string str = string.Format(
  904. // "Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}",
  905. // kvp.Key, kvp.Value);
  906. // byte[] data = encoding.GetBytes(str);
  907. // stream.Write(data, 0, data.Length);
  908. // }
  909. //}
  910. // 写入要上传的文件
  911. foreach (DictionaryEntry kvp in fileList)//KeyValuePair<string, string> kvp
  912. {
  913. // 写入数据块的分隔标记
  914. stream.Write(boundaryBytes, 0, boundaryBytes.Length);
  915. string photoFile = kvp.Value.ToString();
  916. if (".jpg,.png.jpge".Contains(System.IO.Path.GetExtension(photoFile).ToLower().Trim()))
  917. {
  918. Bitmap bmp = LYFZ.BLL.SelectPhotoHandling.GeneratePreviewBitmap(photoFile, 640, 960);
  919. photoFile = LYFZ.ImageFunction.ThumbImgae.SaveTemporaryCompressionImage(bmp, System.IO.Path.GetFileName(photoFile));
  920. }
  921. // 写入文件描述,这里设置一个通用的类型描述:application/octet-stream,具体的描述在注册表里有。
  922. string description = string.Format(
  923. "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\n" +
  924. "Content-Type: application/octet-stream\r\n\r\n",
  925. kvp.Key, Path.GetFileName(photoFile.Trim()));
  926. // 注意:这里如果不使用UTF-8,对于汉字会有乱码。
  927. byte[] header = Encoding.UTF8.GetBytes(description);
  928. stream.Write(header, 0, header.Length);
  929. // 写入文件内容
  930. byte[] body = File.ReadAllBytes(photoFile.Trim());
  931. stream.Write(body, 0, body.Length);
  932. if (".jpg,.png.jpge".Contains(System.IO.Path.GetExtension(photoFile).ToLower().Trim()))
  933. {
  934. LYFZ.ImageFunction.ThumbImgae.DeleteTemporaryCompressionImage(photoFile);
  935. }
  936. }
  937. // 写入结束标记
  938. boundaryBytes = Encoding.ASCII.GetBytes("\r\n--" + boundary + "--\r\n");
  939. stream.Write(boundaryBytes, 0, boundaryBytes.Length);
  940. stream.Close();
  941. try
  942. {
  943. // 开始发起请求,并获取服务器返回的结果。
  944. using (WebResponse response = request.GetResponse())
  945. {
  946. request.Timeout = 300000;
  947. using (StreamReader reader = new StreamReader(response.GetResponseStream(), encoding))
  948. {
  949. return reader.ReadToEnd();
  950. }
  951. }
  952. }
  953. catch { return ""; }
  954. }
  955. #endregion
  956. #region 获取二维码方法
  957. #region 获取二维码方法Post
  958. /// <summary>
  959. /// 获取二维码方法
  960. /// </summary>
  961. /// <param name="ToLocalPath">图片本地磁盘地址</param>
  962. /// <param name="Url">图片网址</param>
  963. /// <returns></returns>
  964. public Bitmap SavePhotoFromUrl(string Url, string param)
  965. {
  966. Bitmap Value = null;
  967. WebResponse response = null;
  968. // Stream stream = null;
  969. try
  970. {
  971. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
  972. request.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/x-silverlight, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-silverlight-2-b1, */*";
  973. request.Method = "POST";
  974. request.ContentType = "application/x-www-form-urlencoded";
  975. request.Accept = "*/*";
  976. request.Timeout = 15000;
  977. request.AllowAutoRedirect = false;
  978. request.CookieContainer = myCookieContainer;
  979. StreamWriter requestStream = null;
  980. requestStream = new StreamWriter(request.GetRequestStream());
  981. requestStream.Write(param);
  982. requestStream.Close();
  983. response = request.GetResponse();
  984. // stream = response.GetResponseStream();
  985. if (!response.ContentType.ToLower().StartsWith("text/"))
  986. {
  987. //Value = SaveBinaryFile(response, FileName);
  988. MemoryStream ImageMS = GetBinaryFileMemoryStream(response);
  989. if (ImageMS != null)
  990. {
  991. Bitmap tempBmp = new Bitmap(ImageMS);
  992. Value = new Bitmap(tempBmp);
  993. tempBmp.Dispose();
  994. ImageMS.Close();
  995. ImageMS.Dispose();
  996. }
  997. response.Close();
  998. }
  999. }
  1000. catch
  1001. {
  1002. }
  1003. return Value;
  1004. }
  1005. private static MemoryStream GetBinaryFileMemoryStream(WebResponse response)
  1006. {
  1007. byte[] buffer = new byte[1024];
  1008. MemoryStream ImageMS = new MemoryStream();
  1009. try
  1010. {
  1011. Stream inStream = response.GetResponseStream();
  1012. int l;
  1013. do
  1014. {
  1015. l = inStream.Read(buffer, 0, buffer.Length);
  1016. if (l > 0)
  1017. ImageMS.Write(buffer, 0, l);
  1018. }
  1019. while (l > 0);
  1020. inStream.Close();
  1021. }
  1022. catch
  1023. {
  1024. ImageMS = null;
  1025. }
  1026. return ImageMS;
  1027. }
  1028. #endregion
  1029. #region 获取二维码方法Post
  1030. /// <summary>
  1031. /// 获取二维码方法
  1032. /// </summary>
  1033. /// <param name="ToLocalPath">图片本地磁盘地址</param>
  1034. /// <param name="Url">图片网址</param>
  1035. /// <returns></returns>
  1036. public bool SavePhotoFromUrl(string FileName, string Url, string param)
  1037. {
  1038. bool Value = false;
  1039. WebResponse response = null;
  1040. Stream stream = null;
  1041. try
  1042. {
  1043. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
  1044. request.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/x-silverlight, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-silverlight-2-b1, */*";
  1045. request.Method = "POST";
  1046. request.ContentType = "application/x-www-form-urlencoded";
  1047. request.Accept = "*/*";
  1048. request.Timeout = 15000;
  1049. request.AllowAutoRedirect = false;
  1050. request.CookieContainer = myCookieContainer;
  1051. StreamWriter requestStream = null;
  1052. requestStream = new StreamWriter(request.GetRequestStream());
  1053. requestStream.Write(param);
  1054. requestStream.Close();
  1055. response = request.GetResponse();
  1056. stream = response.GetResponseStream();
  1057. if (!response.ContentType.ToLower().StartsWith("text/"))
  1058. {
  1059. Value = SaveBinaryFile(response, FileName);
  1060. }
  1061. }
  1062. catch (Exception err)
  1063. {
  1064. string aa = err.ToString();
  1065. }
  1066. return Value;
  1067. }
  1068. #endregion
  1069. #region 将二进制文件保存到磁盘
  1070. private static bool SaveBinaryFile(WebResponse response, string FileName)
  1071. {
  1072. bool Value = true;
  1073. byte[] buffer = new byte[1024];
  1074. try
  1075. {
  1076. if (File.Exists(FileName))
  1077. File.Delete(FileName);
  1078. Stream outStream = System.IO.File.Create(FileName);
  1079. Stream inStream = response.GetResponseStream();
  1080. int l;
  1081. do
  1082. {
  1083. l = inStream.Read(buffer, 0, buffer.Length);
  1084. if (l > 0)
  1085. outStream.Write(buffer, 0, l);
  1086. }
  1087. while (l > 0);
  1088. outStream.Close();
  1089. inStream.Close();
  1090. }
  1091. catch
  1092. {
  1093. Value = false;
  1094. }
  1095. return Value;
  1096. }
  1097. #endregion
  1098. #endregion
  1099. #endregion
  1100. #region 获取二维码目录
  1101. /// <summary>
  1102. /// 获取二维码目录
  1103. /// </summary>
  1104. public string GetQrcodePath()
  1105. {
  1106. LYFZ.Model.Model_Config mConfig = new LYFZ.BLL.BLL_Config().GetModel_SysConfig();
  1107. string tempPath = "\\\\" + mConfig.ServerHostOrIP + "\\ShareDirectory$\\Qrcode\\" + F_Number;
  1108. if (!System.IO.Directory.Exists(tempPath))
  1109. {
  1110. System.IO.Directory.CreateDirectory(tempPath);
  1111. }
  1112. return tempPath;
  1113. }
  1114. #endregion
  1115. }
  1116. }