/// <summary> /// 下载文件 /// </summary> /// <param name="fileName"></param> /// <returns></returns> public virtual byte[] Download(string fileName) { var dataServiceGroup = GetDataServiceGroup(fileName); if (dataServiceGroup == null || dataServiceGroup.DataServices == null) { return(null); } return(WcfService.Invoke <IFileContract>(dataServiceGroup.DataServices.Select(it => it.EndPoint).ToList(), DownloadFiles, fileName) as byte[]); }
/// <summary> /// 开启异常处理 /// </summary> protected virtual void StartSaveExceptionHandle() { var path = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, SaveExceptionPath); var di = new DirectoryInfo(path); if (!di.Exists) { return; } lock (SaveLocker) { var files = di.GetFiles(); foreach (var file in files) { byte[] fileByte; var fileName = Path.GetFileName(file.FullName).Replace("%", "/").Replace(".txt", ""); var fullfileName = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, fileName); using (var filestream = new FileStream(fullfileName, FileMode.Open)) { fileByte = new byte[filestream.Length]; filestream.Read(fileByte, 0, fileByte.Length); } var endpoits = File.ReadAllLines(file.FullName); var endPointNames = new List <string>(); foreach (var endpoit in endpoits) { try { WcfService.Invoke <IFileContract>(new List <EndPointInfo> { new EndPointInfo { Name = endpoit } }, SaveFiles, fileName, fileByte); } catch { endPointNames.Add(endpoit); } } if (endPointNames.Count > 0) { AddSaveException(fileName, endPointNames); } else { File.Delete(file.FullName); } } } }
/// <summary> /// 执行 /// </summary> public virtual void Execute() { if (Product == null) { return; } var rev = WcfService.Invoke <IProductContract>(SaveProduct, GetEndPoints, Product); if (rev == null) { throw new Exception("ProductCountNotEnough"); } }
/// <summary> /// 删除文件 /// </summary> /// <param name="fileName"></param> /// <returns></returns> public virtual void Remove(string fileName) { var hashValue = GetHashValue(); var dataServiceGroup = GetDataServiceGroup(fileName); if (dataServiceGroup == null || dataServiceGroup.DataServices == null) { return; } var dataService = GetMasterDataService(dataServiceGroup, hashValue); var endpoints = dataServiceGroup.DataServices.Select(it => it.EndPoint.Name).ToList(); WcfService.Invoke <IFileContract>(new[] { dataService.EndPoint }, RemoveFiles, null, true, endpoints, fileName); }
/// <summary> /// 开启异常处理 /// </summary> protected virtual void StartRemoveExceptionHandle() { var path = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, RemoveExceptionPath); var di = new DirectoryInfo(path); if (!di.Exists) { return; } lock (RemoveLocker) { var files = di.GetFiles(); foreach (var file in files) { var endpoits = File.ReadAllLines(file.FullName); var endPointNames = new List <string>(); var fileName = Path.GetFileName(file.FullName).Replace("%", "/").Replace(".txt", ""); foreach (var endpoit in endpoits) { try { WcfService.Invoke <IFileContract>( new List <EndPointInfo> { new EndPointInfo { Name = endpoit } }, RemoveFiles, fileName); } catch { endPointNames.Add(endpoit); } } if (endPointNames.Count > 0) { AddRemoveException(fileName, endPointNames); } else { File.Delete(file.FullName); } } } }
/// <summary> /// 执行 /// </summary> public virtual void Execute() { var rev = WcfService.Invoke <IPaylineContract>(SavePayline, GetEndPoint, Payline); if (rev == null) { throw new Exception("ResiterAccountError"); } var accountIdentity = rev.ToString().DeserializeJson <AccountIdentityEntity>(); if (accountIdentity == null) { throw new Exception("ResiterAccountError"); } if (accountIdentity.Id == 0 || accountIdentity.Errors != null && accountIdentity.Errors.Count > 0) { var errorMsg = string.Join(",", accountIdentity.Errors.Select(r => r.Message)); throw new Exception(errorMsg); } }