FTPUpFileForm.cs 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851
  1. using LYFZ.BLL;
  2. using LYFZ.BLL.N8Process;
  3. using LYFZ.ComponentLibrary;
  4. using LYFZ.Model;
  5. using LYFZ.Network.FTPOperation;
  6. using LYFZ.Network.OssOperation;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.ComponentModel;
  10. using System.Data;
  11. using System.Drawing;
  12. using System.IO;
  13. using System.Linq;
  14. using System.Text;
  15. using System.Windows.Forms;
  16. namespace LYFZ.Software.MainBusiness.DoorCityProcess
  17. {
  18. public partial class FTPUpFileForm : LYFZ.Software.UI.DoorCityProcess.FTPUpFileForm
  19. {
  20. /// <summary>
  21. ///
  22. /// </summary>
  23. DataGridViewRow dgvr;
  24. LYFZ.DAL.DAL_ErpCompanyInfo compInfoDal = new DAL.DAL_ErpCompanyInfo();
  25. LYFZ.BLL.BLL_ErpOrder orderBll = new LYFZ.BLL.BLL_ErpOrder();
  26. BLL_ErpOrderDigital digtalBll = new BLL_ErpOrderDigital();
  27. LYFZ.Model.Model_ErpCompanyInfo compInfo = null;
  28. string _Ord_Number, _Ordv_ViceNumber, _orderType;
  29. public string dirType = "";
  30. public string tempType = "";
  31. public string frmType = "RightButton";
  32. #region 云传片
  33. private bool useOss = false;
  34. public bool UseOss
  35. {
  36. get
  37. {
  38. return useOss;
  39. }
  40. set
  41. {
  42. useOss = value;
  43. }
  44. }
  45. private List<AliyunOssLibrary.Model.SimplifyBranch> listbranch = null;
  46. public List<AliyunOssLibrary.Model.SimplifyBranch> ListBranch
  47. {
  48. get
  49. {
  50. return listbranch;
  51. }
  52. set
  53. {
  54. listbranch = value;
  55. }
  56. }
  57. #endregion
  58. /// <summary>
  59. /// 是否上传N8选版;
  60. /// </summary>
  61. private int _uploadN8Type = -1;
  62. /// <summary>
  63. ///
  64. /// </summary>
  65. /// <param name="uploadN8Type">-1表示不上传任何N8内容, 0表示上传N8完整的选版目录, 1表示上传N8选版结果(用于同步)</param>
  66. public FTPUpFileForm( int uploadN8Type = -1 )
  67. {
  68. _uploadN8Type = uploadN8Type;
  69. InitializeComponent();
  70. compInfo = compInfoDal.GetModel( LYFZ.Network.TCP_RemoteDataHandlerPassiveMode.SoftwareInfo.SDomainName.Trim() );
  71. }
  72. public override void FTPUpFileForm_Load( object sender, EventArgs e )
  73. {
  74. if ( this.UseOss )
  75. {
  76. this.labelEx4.Text = "原图相片:";
  77. this.labelEx6.Text = "上传RAW:";
  78. this.cb_ExistCheck.Text = "RAW格式";
  79. if ( !lab_FuncType.Text.Equals( "原片" ) )
  80. {
  81. this.labelEx6.Enabled = false;
  82. this.cb_ExistCheck.Checked = false;
  83. this.cb_ExistCheck.Enabled = false;
  84. }
  85. }
  86. else
  87. {
  88. LYFZ.BLL.BLL_Config cBll = new BLL.BLL_Config();
  89. LYFZ.Model.Model_Config mConfig = cBll.GetModel_SysConfig();
  90. if ( mConfig.IsOpenLocalImportPhoto && !LYFZ.WinAPI.CustomPublicMethod.CheckInternaNetworkAddress( mConfig.ServerHostOrIP ) )
  91. {
  92. MessageBoxCustom.Show( "不允许外网本地传片功能" );
  93. this.Close();
  94. }
  95. }
  96. if ( _uploadN8Type != -1 )
  97. {
  98. // 所属类型;
  99. this.lab_FuncType.Text = _uploadN8Type == 0 ? "N8选版" : "N8选版同步";
  100. // 隐藏原始照片一行;
  101. this.labelEx4.Enabled = false;
  102. this.tb_.Enabled = false;
  103. this.radioButtonEx2.Enabled = false;
  104. this.Text = _uploadN8Type == 0 ? "N8选版" : "N8选版同步";
  105. }
  106. }
  107. public void BindData( DataGridViewRow dr, string type, string ftpInfo )
  108. {
  109. dgvr = dr;
  110. lab_OrderNumber.Text = dr.Cells["Ord_Number"].Value.ToString();
  111. if ( _uploadN8Type == -1 )
  112. lab_FuncType.Text = type;
  113. else
  114. this.lab_FuncType.Text = "N8选版";
  115. lab_FtpInfo.Text = ftpInfo;
  116. tempType = type;
  117. CheckFTPUpFile();
  118. _Ord_Number = dr.Cells["Ord_Number"].Value.ToString();
  119. _Ordv_ViceNumber = dgvr.Cells["Ordv_ViceNumber"].Value.ToString();
  120. _orderType = dgvr.Cells["订单类型"].Value.ToString();
  121. }
  122. public void BindData( string Ord_Number, string Ordv_ViceNumber, string orderType, string type, string ftpInfo )
  123. {
  124. _Ord_Number = Ord_Number;
  125. _Ordv_ViceNumber = Ordv_ViceNumber;
  126. _orderType = orderType;
  127. tempType = type;
  128. lab_OrderNumber.Text = Ord_Number;
  129. lab_FuncType.Text = type.Length > 2 ? type.Substring( 0, 2 ) : type;
  130. if ( !LYFZ.BLL.BLL_ErpUser.GetRights( GetCustomAttributesType( lab_FuncType.Text ), CustomAttributes.OperatingAuthority.FTPUpLoadPhoto ) )
  131. {
  132. MessageBoxCustom.Show( "无当前权限,不可进行传片操作!!", "提示" );
  133. this.Close();
  134. }
  135. //lab_FtpInfo.Text = ftpInfo;
  136. CheckFTPUpFile();
  137. }
  138. public void CheckFTPUpFile()
  139. {
  140. LYFZ.Model.Model_ErpOrder erpOrder = orderBll.GetModel( lab_OrderNumber.Text );
  141. LYFZ.Model.Model_ErpOrderDigital orderDigital = digtalBll.GetModel( _Ordv_ViceNumber );
  142. SelectPhotoHandling handling = new LYFZ.BLL.SelectPhotoHandling( erpOrder, orderDigital );
  143. List<string> pathList = null, pathList2 = null;
  144. if ( _uploadN8Type != -1 )
  145. {// 获取N8选版订单的共享路径;
  146. string dir = BLL.N8Process.BLL_N8Process.GetN8OrderDirecotry( (EnumPublic.OrderType)Enum.Parse( typeof( EnumPublic.OrderType ), erpOrder.Ord_Type ), erpOrder.Ord_Number, "" );
  147. if ( dir == null || dir.Length == 0 )
  148. {
  149. pathList = new List<string>();
  150. }
  151. else
  152. { // 获取该共享路径下的所有文件;
  153. pathList = Directory.GetFiles( dir, "*.*", SearchOption.AllDirectories ).ToList();
  154. }
  155. }
  156. else
  157. {
  158. pathList = handling.GetSpecifyTypePhotoList( GetDirectoryType( lab_FuncType.Text ), SelectPhotoHandling.PhotoType.Original );
  159. // 阿里云传;
  160. pathList2 = handling.GetSpecifyTypePhotoList( GetDirectoryType( lab_FuncType.Text ), SelectPhotoHandling.PhotoType.RawData );
  161. }
  162. if ( lab_FuncType.Text.Equals( "原片" ) )
  163. {
  164. foreach ( var mod in cbItems )
  165. {
  166. bool b1 = (pathList.FindAll( p => p.IndexOf( "\\" + lab_OrderNumber.Text + "\\" + mod.Text + "\\" ) != -1 ).Count != 0);
  167. bool b2 = (pathList2.FindAll( p => p.IndexOf( "\\" + lab_OrderNumber.Text + "\\" + mod.Text + "\\" ) != -1 ).Count != 0);
  168. if ( this.useOss ? (!b1 && !b2) : (!b1 && !b2) )
  169. {
  170. mod.Checked = false;
  171. mod.Enabled = false;
  172. }
  173. }
  174. }
  175. else
  176. {
  177. if ( _uploadN8Type != -1 )
  178. {// 上传N8选版订单;
  179. if ( erpOrder.Ord_Type.Equals( "1" ) )
  180. {// 儿童订单;
  181. foreach ( var mod in cbItems )
  182. {
  183. bool b1 = (pathList.FindAll( p => p.IndexOf( "\\" + lab_OrderNumber.Text + "\\" + mod.Text + "\\" ) != -1 ).Count != 0);
  184. if ( !b1 )
  185. {
  186. mod.Checked = false;
  187. mod.Enabled = false;
  188. }
  189. }
  190. }
  191. else
  192. {// 非儿童订单;
  193. if ( pathList.Count == 0 )
  194. {
  195. cbItems[0].Checked = false;
  196. cbItems[0].Enabled = false;
  197. }
  198. }
  199. }
  200. else
  201. {// 上传订单相片;
  202. if ( erpOrder.Ord_Type.Equals( "1" ) )
  203. {// 儿童订单;
  204. foreach ( var mod in cbItems )
  205. {
  206. bool b1 = (pathList.FindAll( p => p.IndexOf( "\\" + lab_OrderNumber.Text + "\\" + mod.Text + "\\" ) != -1 ).Count != 0);
  207. bool b2 = (pathList2.FindAll( p => p.IndexOf( "\\" + lab_OrderNumber.Text + "\\" + mod.Text + "\\" ) != -1 ).Count != 0);
  208. if ( this.useOss ? (!b1 && !b2) : (!b1 && !b2) )
  209. {
  210. mod.Checked = false;
  211. mod.Enabled = false;
  212. }
  213. }
  214. }
  215. else
  216. {// 非儿童订单;
  217. if ( pathList.Count == 0 )
  218. {
  219. cbItems[0].Checked = false;
  220. cbItems[0].Enabled = false;
  221. }
  222. }
  223. }
  224. }
  225. }
  226. public override void ButtonUpFile( object sender, EventArgs e )
  227. {
  228. LYFZ.Model.Model_ErpOrderDigital orderDigital = digtalBll.GetModel( _Ordv_ViceNumber );
  229. if ( this.useOss )
  230. {
  231. // 新建上传任务;
  232. AliyunOssLibrary.Model.UploadTask uploadTask = new AliyunOssLibrary.Model.UploadTask();
  233. if ( uploadTask.DownloadBranchIds == null )
  234. uploadTask.DownloadBranchIds = new List<string>();
  235. // 获取选择的分店名称;
  236. int nSelCount = 0;
  237. CheckBoxEx cbEx = null;
  238. foreach ( var mod in this.cbBranchItems )
  239. {
  240. if ( mod.Checked )
  241. {
  242. cbEx = mod;
  243. AliyunOssLibrary.Model.SimplifyBranch branch = (AliyunOssLibrary.Model.SimplifyBranch)cbEx.Tag;
  244. uploadTask.DownloadBranchIds.Add( branch.branch_id );
  245. nSelCount++;
  246. }
  247. }
  248. if ( nSelCount == 0 )
  249. {
  250. MessageBoxCustom.Show( "请选择上传分店!" );
  251. return;
  252. }
  253. if ( lab_FuncType.Text.Equals( "原片" ) )
  254. {
  255. uploadTask.UploadImageType = (int)AliyunOssLibrary.Enumerate.ImageType.OImgtype;
  256. }
  257. else if ( lab_FuncType.Text.Equals( "初修" ) )
  258. {
  259. uploadTask.UploadImageType = (int)AliyunOssLibrary.Enumerate.ImageType.EImgtype;
  260. }
  261. else if ( lab_FuncType.Text.Equals( "精修" ) )
  262. {
  263. uploadTask.UploadImageType = (int)AliyunOssLibrary.Enumerate.ImageType.FImgtype;
  264. }
  265. else if ( lab_FuncType.Text.Equals( "设计" ) )
  266. {
  267. uploadTask.UploadImageType = (int)AliyunOssLibrary.Enumerate.ImageType.DImgtype;
  268. }
  269. else if ( lab_FuncType.Text.Contains( "N8选版" ) )
  270. {
  271. uploadTask.UploadImageType = (int)AliyunOssLibrary.Enumerate.ImageType.N8Imgtype;
  272. }
  273. uploadTask.UploadOrder = _Ord_Number;
  274. // 获取成长阶段;
  275. string dirTypeList = "";
  276. foreach ( var item in this.cbItems )
  277. {
  278. if ( item.Checked )
  279. {
  280. if ( dirTypeList != "" )
  281. {
  282. dirTypeList += ",";
  283. }
  284. dirTypeList += item.Text;
  285. }
  286. }
  287. if ( !string.IsNullOrEmpty( dirTypeList ) )
  288. {
  289. LYFZ.Model.Model_ErpOrder erpOrder = orderBll.GetModel( lab_OrderNumber.Text );
  290. if ( _uploadN8Type != -1 )
  291. {
  292. uploadTask.UploadImages = GetN8UploadFileList( erpOrder.Ord_Number, erpOrder.Ord_Type, dirTypeList, _uploadN8Type.IntToBool() );
  293. }
  294. else
  295. {
  296. SelectPhotoHandling handling = new LYFZ.BLL.SelectPhotoHandling( erpOrder, orderDigital );
  297. List<string> uploadfiles = null;
  298. GetUploadFile( handling, erpOrder.Ord_Type, radioButtonEx2.Checked, dirTypeList, out uploadfiles );
  299. uploadTask.UploadImages = uploadfiles;
  300. }
  301. if ( LYFZ.Network.OssOperation.OssProcess.SendOssUploadInfo( uploadTask ) )
  302. {
  303. MessageBox.Show( "任务上传成功" );
  304. // 退出程序;
  305. this.DialogResult = DialogResult.OK;
  306. this.Close();
  307. }
  308. }
  309. }
  310. else
  311. {
  312. if ( frmType.Equals( "RightButton" ) )
  313. {
  314. DataRow dr = (DataRow)dgvr.Tag;
  315. CommandData shop = new CommandData();
  316. shop.localShopInfo = compInfo.Company_Name;
  317. shop.upShopText = dr["Company_Name"].ToString();
  318. shop.upShopCode = dr["FTP_DividedShop"].ToString();
  319. shop.ftpName = dr["FTP_Name"].ToString();
  320. shop.ftpPass = dr["FTP_Pass"].ToString();
  321. shop.hostPath = dr["FTP_ServicePath"].ToString();
  322. shop.port = Convert.ToInt32( dr["FTP_Port"].ToString() );
  323. shop.CommandType = "A";
  324. shop.UpArtwork = radioButtonEx2.Checked;
  325. shop.isExist = cb_ExistCheck.Checked;
  326. string dirTypeList = "";
  327. foreach ( var item in this.cbItems )
  328. {
  329. if ( item.Checked )
  330. {
  331. if ( dirTypeList != "" )
  332. {
  333. dirTypeList += ",";
  334. }
  335. dirTypeList += item.Text;
  336. }
  337. }
  338. shop.dirTypeData = dirTypeList;
  339. if ( !string.IsNullOrEmpty( dirTypeList ) )
  340. {
  341. LYFZ.Model.Model_ErpOrder erpOrder = orderBll.GetModel( lab_OrderNumber.Text );
  342. UpFTPServiceFileGroup group = new UpFTPServiceFileGroup()
  343. {
  344. GuidKey = Guid.NewGuid().ToString().Replace( "-", "" ),
  345. DirFileType = lab_FuncType.Text,
  346. OrderNumber = lab_OrderNumber.Text,
  347. SinceOrderNumber = erpOrder.Ord_SinceOrderNumber,
  348. ViceNumber = _Ordv_ViceNumber,
  349. PhotoType = erpOrder.Ord_Type.Equals( "1" ) ? "儿童订单" : _orderType,
  350. bOpenStatus = 1,
  351. localServicePath = erpOrder.Ord_PhotoPath.Split( '?' )[0]
  352. };
  353. SelectPhotoHandling handling = new LYFZ.BLL.SelectPhotoHandling( erpOrder, orderDigital );
  354. CheckDirectoryOrFile( handling, group, shop.UpArtwork, shop.dirTypeData );
  355. shop.items.Add( group );
  356. string jsonStr = Json.JsonTool.ObjectToJson( shop );
  357. SendDataToService( jsonStr );
  358. base.ButtonUpFile( sender, e );
  359. }
  360. else
  361. {
  362. MessageBoxCustom.Show( "场景至少要选中一个。" );
  363. }
  364. }
  365. else if ( frmType.Equals( "ViewButton" ) )
  366. {
  367. RadioButtonEx rbEx = null;
  368. foreach ( var mod in this.rbFtpItems )
  369. {
  370. if ( mod.Checked )
  371. {
  372. rbEx = mod;
  373. break;
  374. }
  375. }
  376. if ( rbEx == null )
  377. {
  378. MessageBoxCustom.Show( "请选择ftp账户!" );
  379. return;
  380. }
  381. DataRow dr = (DataRow)rbEx.Tag;
  382. CommandData shop = new CommandData();
  383. shop.localShopInfo = compInfo.Company_Name;
  384. shop.upShopText = dr["Company_Name"].ToString();
  385. shop.upShopCode = dr["FTP_DividedShop"].ToString();
  386. shop.ftpName = dr["FTP_Name"].ToString();
  387. shop.ftpPass = dr["FTP_Pass"].ToString();
  388. shop.hostPath = dr["FTP_ServicePath"].ToString();
  389. shop.port = Convert.ToInt32( dr["FTP_Port"].ToString() );
  390. shop.CommandType = "A";
  391. shop.UpArtwork = radioButtonEx2.Checked;
  392. shop.isExist = cb_ExistCheck.Checked;
  393. string dirTypeList = "";
  394. foreach ( var item in this.cbItems )
  395. {
  396. if ( item.Checked )
  397. {
  398. if ( dirTypeList != "" )
  399. {
  400. dirTypeList += ",";
  401. }
  402. dirTypeList += item.Text;
  403. }
  404. }
  405. shop.dirTypeData = dirTypeList;
  406. if ( !string.IsNullOrEmpty( dirTypeList ) )
  407. {
  408. LYFZ.Model.Model_ErpOrder erpOrder = orderBll.GetModel( lab_OrderNumber.Text );
  409. UpFTPServiceFileGroup group = new UpFTPServiceFileGroup()
  410. {
  411. GuidKey = Guid.NewGuid().ToString().Replace( "-", "" ),
  412. DirFileType = lab_FuncType.Text,
  413. OrderNumber = lab_OrderNumber.Text,
  414. SinceOrderNumber = erpOrder.Ord_SinceOrderNumber,
  415. ViceNumber = _Ordv_ViceNumber,
  416. PhotoType = erpOrder.Ord_Type.Equals( "1" ) ? "儿童订单" : _orderType,
  417. bOpenStatus = 1,
  418. localServicePath = erpOrder.Ord_PhotoPath.Split( '?' )[0]
  419. };
  420. if (lab_FuncType.Text == "N8选版"||lab_FuncType.Text == "N8选版同步")
  421. {
  422. List<string> upFileList = GetN8UploadFileList(erpOrder.Ord_Number, erpOrder.Ord_Type, dirTypeList, lab_FuncType.Text == "N8选版同步" ? true : false);
  423. BindImageData(group, upFileList);
  424. }
  425. else
  426. {
  427. SelectPhotoHandling handling = new LYFZ.BLL.SelectPhotoHandling(erpOrder, orderDigital);
  428. CheckDirectoryOrFile(handling, group, shop.UpArtwork, shop.dirTypeData);
  429. }
  430. shop.items.Add( group );
  431. string jsonStr = Json.JsonTool.ObjectToJson( shop );
  432. SendDataToService( jsonStr );
  433. base.ButtonUpFile( sender, e );
  434. }
  435. }
  436. }
  437. }
  438. void CheckDirectoryOrFile( SelectPhotoHandling handling, UpFTPServiceFileGroup group, bool UpArtwork, string dirTypeData )
  439. {
  440. List<string> Raw_List = new List<string>();
  441. List<string> Original_List = new List<string>();
  442. List<string> Preview_List = new List<string>();
  443. List<string> Small_List = new List<string>();
  444. if ( UpArtwork )
  445. {
  446. Original_List = handling.GetSpecifyTypePhotoList( GetDirectoryType( group.DirFileType ), SelectPhotoHandling.PhotoType.Original );
  447. }
  448. Raw_List = handling.GetSpecifyTypePhotoList( GetDirectoryType( group.DirFileType ), SelectPhotoHandling.PhotoType.RawData );
  449. Preview_List = handling.GetSpecifyTypePhotoList( GetDirectoryType( group.DirFileType ), SelectPhotoHandling.PhotoType.Preview );
  450. Small_List = handling.GetSpecifyTypePhotoList( GetDirectoryType( group.DirFileType ), SelectPhotoHandling.PhotoType.Small );
  451. if ( group.DirFileType.Equals( "原片" ) )
  452. {
  453. ///
  454. string[] dirList = dirTypeData.Split( ',' );
  455. foreach ( string dirData in dirList )
  456. {
  457. BindImageData( group, Small_List.Where( p => p.IndexOf( "\\" + dirData + "\\" ) != -1 ).ToList() );
  458. BindImageData( group, Preview_List.Where( p => p.IndexOf( "\\" + dirData + "\\" ) != -1 ).ToList() );
  459. BindImageData( group, Original_List.Where( p => p.IndexOf( "\\" + dirData + "\\" ) != -1 ).ToList() );
  460. BindImageData( group, Raw_List.Where( p => p.IndexOf( "\\" + dirData + "\\" ) != -1 ).ToList() );
  461. }
  462. }
  463. else
  464. {
  465. if ( group.PhotoType.Equals( "儿童订单" ) )
  466. {
  467. string[] dirList = dirTypeData.Split( ',' );
  468. foreach ( string dirData in dirList )
  469. {
  470. BindImageData( group, Small_List.Where( p => p.IndexOf( "\\" + dirData + "\\" ) != -1 ).ToList() );
  471. BindImageData( group, Preview_List.Where( p => p.IndexOf( "\\" + dirData + "\\" ) != -1 ).ToList() );
  472. BindImageData( group, Original_List.Where( p => p.IndexOf( "\\" + dirData + "\\" ) != -1 ).ToList() );
  473. BindImageData( group, Raw_List.Where( p => p.IndexOf( "\\" + dirData + "\\" ) != -1 ).ToList() );
  474. }
  475. }
  476. else
  477. {
  478. BindImageData( group, Small_List );
  479. BindImageData( group, Preview_List );
  480. BindImageData( group, Original_List );
  481. BindImageData( group, Raw_List );
  482. }
  483. }
  484. }
  485. /// <summary>
  486. /// 获取要上传的相片;
  487. /// </summary>
  488. /// <param name="handling"></param>
  489. /// <param name="UpArtwork">是否要上传原始相片</param>
  490. /// <param name="dirTypeData">要上传的景点列表</param>
  491. /// <param name="listUploadfiles"></param>
  492. void GetUploadFile( SelectPhotoHandling handling, string orderType, bool UpArtwork, string dirTypeData, out List<string> listUploadfiles )
  493. {
  494. listUploadfiles = null;
  495. List<string> listRaw = new List<string>();
  496. // 原始相片(未压缩);
  497. List<string> Original_List = new List<string>();
  498. // 预览图(中图);
  499. List<string> Preview_List = new List<string>();
  500. // 小图;
  501. List<string> Small_List = new List<string>();
  502. Original_List = handling.GetSpecifyTypePhotoList( GetDirectoryType( lab_FuncType.Text ), SelectPhotoHandling.PhotoType.Original );
  503. Preview_List = handling.GetSpecifyTypePhotoList( GetDirectoryType( lab_FuncType.Text ), SelectPhotoHandling.PhotoType.Preview );
  504. Small_List = handling.GetSpecifyTypePhotoList( GetDirectoryType( lab_FuncType.Text ), SelectPhotoHandling.PhotoType.Small );
  505. if ( cb_ExistCheck.Checked == true )
  506. {// 是否上传原始格式raw;
  507. // 当单独导入原始格式时,原始相片被重命名;
  508. listRaw = handling.GetSpecifyTypePhotoList( GetDirectoryType( lab_FuncType.Text ), SelectPhotoHandling.PhotoType.RawData );
  509. // 当由jpg等相片附加导入的原始格式相片时, 原始格式相片保持原名不变;获取原始格式文件名时需要从原片中去前缀获取;
  510. string prefix = SelectPhotoHandling.PhotoType.Original.ToString().ToLower() + "_";
  511. foreach ( string file in Original_List )
  512. {
  513. if ( file.ToLower().IndexOf( prefix ) != 0 )
  514. {
  515. string rawname = System.IO.Path.GetFileNameWithoutExtension( file ).Substring( prefix.Length );
  516. string rawpath = System.IO.Path.GetDirectoryName( file );
  517. string[] arylist = System.IO.Directory.GetFiles( rawpath, rawname + ".*" );
  518. listRaw.AddRange( arylist );
  519. }
  520. }
  521. string WorryingTooExtName = ".gif|.png|.bmp|.jpg|.jpeg|.txt|.exe|.doc|.xls|.dat|.bak|.ppt|.docx|.xlsx|.pptx|.wps|.ini|.asp|.php|.jsp|.html|.css|.xml|.sql|.cs|.aspx|.rar|.zip|.7z";
  522. for ( int i = listRaw.Count - 1; i >= 0; i-- )
  523. {
  524. string ext = System.IO.Path.GetExtension( listRaw[i] ).ToLower();
  525. if ( WorryingTooExtName.Contains( ext ) )
  526. {
  527. listRaw.RemoveAt( i );
  528. }
  529. }
  530. }
  531. listUploadfiles = new List<string>();
  532. if ( lab_FuncType.Text.Equals( "原片" ) )
  533. {
  534. string[] dirList = dirTypeData.Split( ',' );
  535. foreach ( string dirData in dirList )
  536. {// 遍历每一个景点;
  537. listUploadfiles = listUploadfiles.Union( Small_List.Where( p => p.IndexOf( "\\" + dirData + "\\" ) != -1 ).ToList() ).ToList();
  538. listUploadfiles = listUploadfiles.Union( Preview_List.Where( p => p.IndexOf( "\\" + dirData + "\\" ) != -1 ).ToList() ).ToList();
  539. if ( UpArtwork )
  540. listUploadfiles = listUploadfiles.Union( Original_List.Where( p => p.IndexOf( "\\" + dirData + "\\" ) != -1 ).ToList() ).ToList();
  541. }
  542. }
  543. else
  544. {
  545. if ( orderType.Equals( "1" ) )
  546. {// 儿童订单;
  547. string[] dirList = dirTypeData.Split( ',' );
  548. foreach ( string dirData in dirList )
  549. {// 遍历每一个景点;
  550. listUploadfiles = listUploadfiles.Union( Small_List.Where( p => p.IndexOf( "\\" + dirData + "\\" ) != -1 ).ToList() ).ToList();
  551. listUploadfiles = listUploadfiles.Union( Preview_List.Where( p => p.IndexOf( "\\" + dirData + "\\" ) != -1 ).ToList() ).ToList();
  552. if ( UpArtwork )
  553. listUploadfiles = listUploadfiles.Union( Original_List.Where( p => p.IndexOf( "\\" + dirData + "\\" ) != -1 ).ToList() ).ToList();
  554. }
  555. }
  556. else
  557. {
  558. listUploadfiles = listUploadfiles.Union( Small_List ).ToList();
  559. listUploadfiles = listUploadfiles.Union( Preview_List ).ToList();
  560. if ( UpArtwork )
  561. listUploadfiles = listUploadfiles.Union( Original_List ).ToList();
  562. }
  563. }
  564. if ( cb_ExistCheck.Checked == true )
  565. listUploadfiles = listUploadfiles.Union( listRaw ).ToList();
  566. }
  567. /// <summary>
  568. /// 获取要上传的订单的N8选版文件集
  569. /// </summary>
  570. /// <param name="strOrderNumber">订单号</param>
  571. /// <param name="strOrderType">订单类型:儿童什么的</param>
  572. /// <param name="strGrowthStage">如果是儿童订单,则是成长阶段的串联,以逗号分隔; 否则为空</param>
  573. /// <param name="IsSynUploadResult">false表示上传整个订单(指定成长阶段)N8选版文件; true表示同步选版结果, 只上传选版结果即可</param>
  574. /// <returns></returns>
  575. List<string> GetN8UploadFileList( string strOrderNumber, string strOrderType, string strGrowthStage, bool IsSynUploadResult = false )
  576. {
  577. // N8是否可用;
  578. if ( !BLL_N8Process.IsN8ModelValid() )
  579. return null;
  580. EnumPublic.OrderType orderType = (EnumPublic.OrderType)Enum.Parse( typeof( EnumPublic.OrderType ), strOrderType );
  581. // 获取N8订单的根目录;
  582. string strRootDir = BLL_N8Process.GetN8OrderDirecotry( orderType, strOrderNumber );
  583. if ( string.IsNullOrEmpty( strRootDir ) )
  584. return null;
  585. List<string> listFiles = new List<string>();
  586. List<string> listAll = Directory.GetFiles( strRootDir, "*.*", SearchOption.AllDirectories ).ToList();
  587. if ( orderType == EnumPublic.OrderType.儿童订单 )
  588. {
  589. // 遍历获取成长阶段的上传文件;
  590. string[] aryGrowthStage = strGrowthStage.Split( ',' );
  591. if ( aryGrowthStage == null || aryGrowthStage.Length == 0 )
  592. return null;
  593. foreach ( string growthStage in aryGrowthStage )
  594. {
  595. if ( IsSynUploadResult )
  596. {
  597. listFiles.AddRange( listAll.Where( p => p.IndexOf( "\\" + growthStage + "\\选版结果\\" ) != -1 ).ToArray() );
  598. listFiles.AddRange( listAll.Where( p => p.IndexOf( "\\[已选]" + growthStage + "\\选版结果\\" ) != -1 ).ToArray() );
  599. }
  600. else
  601. { // 已选版 或 未选版, 都可以上传;
  602. listFiles.AddRange( listAll.Where( p => p.IndexOf( "\\" + growthStage + "\\" ) != -1 ).ToArray() );
  603. listFiles.AddRange( listAll.Where( p => p.IndexOf( "\\[已选]" + growthStage + "\\" ) != -1 ).ToArray() );
  604. }
  605. }
  606. }
  607. else
  608. {
  609. if ( IsSynUploadResult )
  610. {
  611. listFiles.AddRange( listAll.Where( p => p.IndexOf( "\\选版结果\\" ) != -1 ).ToArray() );
  612. }
  613. else
  614. {
  615. listFiles.AddRange( listAll );
  616. }
  617. }
  618. return listFiles;
  619. }
  620. void BindImageData( UpFTPServiceFileGroup group, List<string> filePathList )
  621. {
  622. foreach ( string path in filePathList )
  623. {
  624. group.items.Add( new UpFTPServiceFileItem()
  625. {
  626. localFilePath = path,
  627. serviceFilePath = path.Split( '$' ).Length > 1 ? path.Split( '$' )[1] : "",
  628. } );
  629. }
  630. /* if (Directory.Exists(dirPath + "" ))
  631. {
  632. string[] fileList = Directory.GetFiles(dirPath );
  633. foreach (string file in fileList)
  634. {
  635. string fileName = Path.GetFileName(file);
  636. group.items.Add(new UpFTPServiceFileItem()
  637. {
  638. localFilePath = file,
  639. serviceFilePath = servicePath + fileName,
  640. });
  641. }
  642. }*/
  643. }
  644. /// <summary>
  645. /// 获取文件类型
  646. /// </summary>
  647. /// <param name="type"></param>
  648. /// <returns></returns>
  649. public LYFZ.Model.Model_ErpOrder.DirectoryType GetDirectoryType( string type )
  650. {
  651. switch ( type )
  652. {
  653. case "原片":
  654. return LYFZ.Model.Model_ErpOrder.DirectoryType.PrimitivePicture;
  655. case "初修":
  656. return LYFZ.Model.Model_ErpOrder.DirectoryType.EarlyRetouch;
  657. case "精修":
  658. return LYFZ.Model.Model_ErpOrder.DirectoryType.FineRetouch;
  659. default:
  660. return LYFZ.Model.Model_ErpOrder.DirectoryType.DesignPiece;
  661. }
  662. }
  663. public LYFZ.CustomAttributes.RightsValue GetCustomAttributesType( string type )
  664. {
  665. switch ( type )
  666. {
  667. case "原片":
  668. return LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StoresPhotograph;
  669. case "初修":
  670. return LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StoresRepairPiece;
  671. case "精修":
  672. return LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StoresRefinedRepair;
  673. case "设计":
  674. return LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StoresDesign;
  675. }
  676. return null;
  677. }
  678. string GetfileDirectoryType( string type )
  679. {
  680. switch ( type )
  681. {
  682. case "原片":
  683. return LYFZ.Model.Model_ErpOrder.DirectoryType.PrimitivePicture.ToString();
  684. case "初修":
  685. return LYFZ.Model.Model_ErpOrder.DirectoryType.EarlyRetouch.ToString();
  686. case "精修":
  687. return LYFZ.Model.Model_ErpOrder.DirectoryType.FineRetouch.ToString();
  688. default:
  689. return LYFZ.Model.Model_ErpOrder.DirectoryType.DesignPiece.ToString();
  690. }
  691. }
  692. public void SendDataToService( string jsonStr )
  693. {
  694. LYFZ.Software.MainBusiness.MultipleFileImport.frmFtpThread.GetSingleton().SendDataToService( jsonStr );
  695. //LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  696. //{
  697. // backgroundWorker.ReportProgress(0, "正在提交数据...");
  698. // HPSocketCS.Extended.RequestData requestData = new HPSocketCS.Extended.RequestData((int)LYFZ.Network.TCPNetworkServer.SerializerRequestCommand.FTPCommand);
  699. // requestData.AttachedMessage = jsonStr;
  700. // HPSocketCS.Extended.ReturnData returnData = HPSocketCS.Extended.SerializerDataProcessed.HP_SendSerializerCommandToServer(requestData);
  701. // if (returnData.ReturnStatus)
  702. // {
  703. // backgroundWorker.ReportProgress(0, "数据提交成功...");
  704. // //MessageBoxCustom.Show("提交成功!!");
  705. // }
  706. // else
  707. // {
  708. // MessageBoxCustom.Show("提交失败!!");
  709. // }
  710. //});
  711. //LYFZ.Software.MainBusiness.MultipleFileImport.frmMultipFileImportThread.GetSingleton().StartFTPMsgTimer();
  712. }
  713. public override RadioButtonEx AddCheckBoxByFtpInfo( DataRow dr )
  714. {
  715. LYFZ.DAL.DAL_ErpCompanyInfo compInfoDal = new DAL.DAL_ErpCompanyInfo();
  716. LYFZ.Model.Model_ErpCompanyInfo compInfo = null;
  717. compInfo = compInfoDal.GetModel( LYFZ.Network.TCP_RemoteDataHandlerPassiveMode.SoftwareInfo.SDomainName.Trim() );
  718. frmType = "ViewButton";
  719. lab_FtpInfo.Visible = false;
  720. if ( this.useOss && listbranch != null )
  721. {
  722. this.gb_FTPInfo.Text = "云传片分店信息";
  723. foreach ( AliyunOssLibrary.Model.SimplifyBranch branch in listbranch )
  724. {
  725. CheckBoxEx cbex = new CheckBoxEx();
  726. cbex.Text = branch.branch_name + " " + branch.branch_id;
  727. cbex.AutoSize = true;
  728. cbex.Tag = branch;
  729. cbBranchItems.Add( cbex );
  730. this.gb_FTPInfo.Controls.Add( cbex );
  731. }
  732. int addheight = 0;
  733. for ( int i = 0; i < cbBranchItems.Count; i++ )
  734. {
  735. addheight = cbBranchItems[i].Height * i;
  736. cbBranchItems[i].Location = new Point( lab_FtpInfo.Location.X, lab_FtpInfo.Location.Y + cbBranchItems[i].Height * i );
  737. }
  738. gb_FTPInfo.Size = new System.Drawing.Size( gb_FTPInfo.Size.Width, (int)(gbBoxHeight + addheight) );
  739. this.Size = new Size( this.Size.Width, this.Size.Height + addheight );
  740. }
  741. else
  742. {
  743. #region 2017-03-22 杨云奕 添加 获取门店配置的ftp情况
  744. BLL.BaseBLL.BaseBLL_FTPServiceUserAccount ftpbll = new BLL.BaseBLL.BaseBLL_FTPServiceUserAccount();
  745. DataSet ftpData = ftpbll.GetList2( "" );
  746. foreach ( DataRow row in ftpData.Tables[0].Rows )
  747. {
  748. RadioButtonEx cbex = base.AddCheckBoxByFtpInfo( row );
  749. if ( compInfo.Company_DividedShop == row["FTP_DividedShop"].ToString() )
  750. {
  751. cbex.Enabled = false;
  752. }
  753. }
  754. #endregion
  755. int addheight = 0;
  756. for ( int i = 0; i < rbFtpItems.Count; i++ )
  757. {
  758. addheight = rbFtpItems[i].Height * i;
  759. rbFtpItems[i].Location = new Point( lab_FtpInfo.Location.X, lab_FtpInfo.Location.Y + rbFtpItems[i].Height * i );
  760. }
  761. gb_FTPInfo.Size = new System.Drawing.Size( gb_FTPInfo.Size.Width, (int)(gbBoxHeight + addheight) );
  762. this.Size = new Size( this.Size.Width, this.Size.Height + addheight );
  763. }
  764. return null;
  765. }
  766. }
  767. }