public async Task AddDataFilesAsync_UploadsTheFiles_Returns_Ok() { var mocks = Mocks(); var dataFile = MockFile("datafile.csv"); var metaFile = MockFile("metafile.csv"); var dataFileInfo = new DataFileInfo { Name = "Subject name", Path = "datafile.csv" }; mocks.ReleaseDataFilesService .Setup(service => service.Upload(_releaseId, dataFile, metaFile, "*****@*****.**", null, "Subject name")) .ReturnsAsync(dataFileInfo); // Call the method under test var controller = ReleasesControllerWithMocks(mocks); var result = await controller.AddDataFilesAsync(releaseId : _releaseId, replacingFileId : null, subjectName : "Subject name", file : dataFile, metaFile : metaFile); var dataFileInfoResult = AssertOkResult(result); Assert.Equal("Subject name", dataFileInfoResult.Name); Assert.Equal("datafile.csv", dataFileInfoResult.Path); }
private void modeAddFile(string[] obj) { //correct use: rds File -AddFile {filepath} [delim] if (obj.Length < 3 || obj.Length > 4) { Console.Error.WriteLine("Correct usage: rds File -AddFile {filePath} [delimiter]"); return; } string path = obj[2]; if (!File.Exists(path)) { Console.Error.WriteLine($"Could not find file {path}"); return; } FileInfo inf = new FileInfo(path); DataFileInfo DFInfo = new DataFileInfo(inf); if (obj.Length == 4) { DFInfo.Delimiter = obj[3]; ReDetermineColumns(DFInfo); } Save(DFInfo); Console.Out.WriteLine($"Added file {path}.\r\nDelimiter: {DFInfo.Delimiter}"); }
public void SerializeAndDeSerializeAsBaseClass() { string path = $"{Environment.CurrentDirectory}\\testfileinfofile.txt"; try { DataFileInfo dfi = new DataFileInfo(); dfi.Columns = new string[] { "Col1" }; dfi.Delimiter = "|"; DataSourceInformation baseclass = dfi as DataSourceInformation; baseclass.SaveToFile(path); Assert.IsTrue(File.Exists(path)); DataSourceInformation loadedFromFile = DataSourceInformation.LoadFromFile(path); DataFileInfo dfi2 = loadedFromFile as DataFileInfo; Assert.AreEqual(expected: dfi.Delimiter, actual: dfi2.Delimiter); Assert.AreEqual(expected: dfi.Columns[0], actual: dfi2.Columns[0]); } catch (Exception) { throw; } finally { if (File.Exists(path)) { File.Delete(path); } } }
protected T ParseXmlFileSharedRead(Func <XDocument, T> parser) { using (var textStream = DataFileInfo.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.Read)) { return(parser(XDocument.Load(textStream, LoadOptions.PreserveWhitespace))); } }
private void ReDetermineColumns(DataFileInfo f) { using (StreamReader reader = new StreamReader(f.Info.FullName)) { string firstLine = reader.ReadLine(); f.Columns = firstLine.Delimit(f.Delimiter, null); } }
public AbstractProcess() { DataFileInfo = new DataFileInfo(); Contract = new Contract(); ProcessState = ProcessState.Stopped; LogBuffer = new List <string>(); TotalError = 0; }
private void Save(DataFileInfo f) { string ext = Properties.Settings.DataSourceFileExtension; string settingsdir = $"{Environment.CurrentDirectory}\\.rds"; int idx = f.Info.Name.LastIndexOf('.'); string nameWithoutExtension = f.Info.Name.Substring(0, idx); f.SaveToFile($"{settingsdir}\\{nameWithoutExtension}{ext}"); }
public void IsValidTest() { string dataFileName = "database.owner.table"; // TODO: Initialize to an appropriate value DataFileInfo target = new DataFileInfo(dataFileName); // TODO: Initialize to an appropriate value bool expected = false; // TODO: Initialize to an appropriate value bool actual; actual = target.IsValid(); Assert.AreEqual(expected, actual); }
public void DataFileInfoConstructorTest() { string dataFileName = "database.owner.table.txt"; // TODO: Initialize to an appropriate value DataFileInfo target = new DataFileInfo(dataFileName); Assert.AreEqual("database", target.Database); Assert.AreEqual("owner", target.Owner); Assert.AreEqual("table", target.Table); Assert.AreEqual(true, target.IsValid()); }
public void MarkAsDoneTest() { string dataFileName = @"D:\CTPEnlist\cp-work\Private\tests\RiskManagement\Tools\RulePerf\RulePerf\bin\Debug\ExternalData1_R.dbo.global_message.txt"; DataFileInfo target = new DataFileInfo(dataFileName); // TODO: Initialize to an appropriate value string expected = @"D:\CTPEnlist\cp-work\Private\tests\RiskManagement\Tools\RulePerf\RulePerf\bin\Debug\Success\ExternalData1_R.dbo.global_message.txt"; string actual; actual = target.MarkAsDone(); Assert.AreEqual(expected, actual); }
private void _CreateSubset(DataTable dt, DataSourceInformation info) { if (info.GetType() == typeof(DataFileInfo)) { DataFileInfo dfinfo = info as DataFileInfo; _CreateSubsetDataFileInfo(dt, dfinfo); } if (info.GetType() == typeof(SourceTableInfo)) { SourceTableInfo stinfo = info as SourceTableInfo; _CreateSubsetSourceTableInfo(dt, stinfo); } }
private void _CreateSubset(IEnumerable <DataRow> dt, DataSourceInformation info, DataColumnCollection header) { if (info.GetType() == typeof(DataFileInfo)) { DataFileInfo dfinfo = info as DataFileInfo; _CreateSubsetDataFileInfo(dt, dfinfo, header); } if (info.GetType() == typeof(SourceTableInfo)) { SourceTableInfo stinfo = info as SourceTableInfo; _CreateSubsetSourceTableInfo(dt, stinfo, header); } }
private void _CreateSubsetDataFileInfo(IEnumerable <DataRow> dt, DataFileInfo info, DataColumnCollection header) { string path = $"{m_Options.TargetPath}\\{info.Info.Name}"; if (path.Equals(info.Info.FullName)) { Console.Error.WriteLine("Error: subset creation would overwrite original files, please specify a different targetpath."); return; } string delim = info.Delimiter; dt.ExportToDelimitedText(path, delim, header); }
/// <summary> /// 客先担当選択.Model /// </summary> /// <param name="dataFile">ファイル情報</param> public SelectedStaff(DataFileInfo dataFile) { switch (dataFile.Kind) { case DataKind.Quotation: var file = new QuotationFile(dataFile); MakeClientStaffs(file.ClientName, file.ClientStaffs); _File = file; break; } }
/// <summary> /// 客先担当選択.View /// </summary> /// <param name="dataFile">ファイル情報</param> public SelectedStaff(DataFileInfo dataFile) { InitializeComponent(); if (DataContext is IDisposable dispose) { dispose.Dispose(); } var viewModel = new ViewModel::SelectedStaff(dataFile); viewModel.PropertyChanged += OnPropertyChanged; DataContext = viewModel; }
/// <summary> /// 見積書.View /// </summary> /// <param name="dataFile">見積情報</param> /// <param name="nowPage">現在ページ数</param> /// <param name="maxPage">最大ページ数</param> public Quotation(DataFileInfo dataFile, int nowPage, int maxPage) { InitializeComponent(); if (DataContext is IDisposable dispose) { dispose.Dispose(); } var viewModel = new ViewModel::Quotation(dataFile, nowPage, maxPage); viewModel.PropertyChanged += OnPropertyChanged; DataContext = viewModel; }
/// <summary> /// 見積書.ViewModel /// </summary> /// <param name="dataFile">見積情報</param> public Quotation(DataFileInfo dataFile) { _Model = new Model::Quotation(dataFile); foreach (var summary in _Model.File.Summaries) { summary.SetCalcTotalPrice(new Action(() => { CalcSubTotalPrice(); CalcTotalPrice(); })); } CalcSubTotalPrice(); CalcTotalPrice(); }
public static bool FileExists(DataFileInfo fileInfo, out FileProcessInfo inProcess) { if (fileInfo == null) { throw new ArgumentNullException(nameof(fileInfo)); } bool result = false; inProcess = null; using (var db = new FileUploadDbEntities()) { var existingFile = db.EFDataFileInfoes .FirstOrDefault(f => f.Hash == fileInfo.Hash); if (existingFile != null) { result = true; if (!existingFile.FileProcessInfoes.IsLoaded) { existingFile.FileProcessInfoes.Load(); } var processInfo = existingFile.FileProcessInfoes.FirstOrDefault(); if (processInfo != null) { inProcess = new FileProcessInfo(); inProcess.Id = processInfo.Id; inProcess.FileInfo = new DataFileInfo() { CreationTime = existingFile.CreationTime, Hash = existingFile.Hash, Name = existingFile.Name, Size = existingFile.Size, }; inProcess.Result = (ProcessResult)processInfo.Result; inProcess.StartTime = processInfo.StartTime; inProcess.State = (ProcessState)processInfo.State; } } } return(result); }
public StartFileProcessViewModel(ISynchronizeInvoke context, FileInfo fileInfo) : base(context, null) { FileInfo = fileInfo ?? throw new ArgumentNullException(nameof(fileInfo)); var dataFileInfo = new DataFileInfo(); dataFileInfo.Name = fileInfo.Name; dataFileInfo.Size = fileInfo.Length; dataFileInfo.CreationTime = fileInfo.CreationTime; var processInfo = new FileProcessInfo(); processInfo.UniqueId = Guid.NewGuid(); processInfo.FileInfo = dataFileInfo; processInfo.StartTime = DateTime.Now; processInfo.State = ProcessState.None; processInfo.Result = ProcessResult.None; Info = processInfo; }
/// <summary> /// ジョブ.Model /// </summary> /// <param name="job">ジョブファイル</param> public JobDetail(Job job) { _JobFile = job; _ClientsFile = new ClientsFile(); // 保存されている取引先を取得し、選択中にする for (int iLoop = 0; iLoop < _ClientsFile.Clients.Count; iLoop++) { if (_ClientsFile.Clients[iLoop].Name.Equals(_JobFile.Client)) { _SelectedClient = _ClientsFile.Clients[iLoop]; break; } } // 各書類は最新を選択している状態とする SelectedQuotation = Quotations.Count.Equals(0) ? null : Quotations[Quotations.Count - 1]; SelectedDelivery = Deliveries.Count.Equals(0) ? null : Deliveries[Deliveries.Count - 1]; SelectedInvoice = Invoices.Count.Equals(0) ? null : Invoices[Invoices.Count - 1]; }
public void Run() { string[] extensionWhiteList = new string[] { ".txt" , ".csv" }; string ext = Properties.Settings.DataSourceFileExtension; string settingsFileName = Properties.Settings.RdsSubsettingSettingsFileName; string keyrelationFileName = Properties.Settings.KeyRelationshipFileName; string rdsDir = Properties.Settings.RdsDirectoryName; string dir = Environment.CurrentDirectory; Console.Out.WriteLine($"Initializing in {dir}"); DirectoryInfo directoryInfo = new DirectoryInfo(dir); var settingsdir = directoryInfo.CreateSubdirectory($".\\{rdsDir}"); settingsdir.Attributes = settingsdir.Attributes | FileAttributes.Hidden; //set folder to hidden var files = directoryInfo.EnumerateFiles(). Where(leFile => leFile.Extension.InList(extensionWhiteList)). ToList(); foreach (var f in files) { Console.Out.WriteLine($"Found file {f.Name}"); DataFileInfo df = new DataFileInfo(f); int idx = f.Name.LastIndexOf('.'); string nameWithoutExtension = f.Name.Substring(0, idx); df.SaveToFile($"{settingsdir.FullName}\\{nameWithoutExtension}{ext}"); } List <KeyRelationship> keyRelationships = new List <KeyRelationship>(); keyRelationships.SaveToFile($"{settingsdir.FullName}\\{keyrelationFileName}"); SubsettingOptions subsettingOptions = new SubsettingOptions(); subsettingOptions.TargetPath = dir + "\\subset"; Directory.CreateDirectory(subsettingOptions.TargetPath); subsettingOptions.SaveToFile($"{settingsdir.FullName}\\{settingsFileName}"); }
/// <summary> /// 見積書改訂 /// </summary> public void RevisionQuotation() { if (Quotations.Count.Equals(0)) { Quotations.Add(new DataFileInfo(DataKind.Quotation, 0, DateTime.Now, 1, false)); } else { Quotations.Add(new DataFileInfo(DataKind.Quotation, Quotations[Quotations.Count - 1].Revision + 1, DateTime.Now, 1, false)); } SelectedQuotation = Quotations[Quotations.Count - 1]; var file = new QuotationFile(SelectedQuotation) { JobName = Name, QuoteNo = new DocumentNoFile().UpdateDocumentNo(DataKind.Quotation), ClientName = SelectedClient?.Name }; file.Save(); }
/// <summary> /// 見積書.ViewModel /// </summary> /// <param name="dataFile">見積情報</param> /// <param name="nowPage">現在ページ数</param> /// <param name="maxPage">最大ページ数</param> public Quotation(DataFileInfo dataFile, int nowPage, int maxPage) { _Model = new Model::Quotation(dataFile) { IsPrintMode = true, NowPage = nowPage, MaxPage = maxPage }; foreach (var summary in _Model.File.Summaries) { summary.SetCalcTotalPrice(new Action(() => { CalcSubTotalPrice(); CalcTotalPrice(); })); } _Model.SetPrintSummaries(); CalcSubTotalPrice(); CalcTotalPrice(); }
/// <summary> /// 見積書.Model /// </summary> /// <param name="dataFile">見積情報</param> public Quotation(DataFileInfo dataFile) { DataFile = dataFile; File = new QuotationFile(DataFile); }
protected List <OrderEntity> ResolveOrders_ABC(DataTable excelTable, DataFileInfo file, List <OrderEntity> items) { OrderDTO orderDTO = new OrderDTO(); orderDTO.orderStatus = OrderStatus.Confirmed; orderDTO.fileName = file.FullName; orderDTO.orderType = 0; orderDTO.orderStatus = OrderStatus.Confirmed; for (int i = 0; i < excelTable.Rows.Count; i++) { var row = excelTable.Rows[i]; var orderDateStr = Convert.ToString(row[1]); //订单创建时间 20200411 23:03:32 orderDTO.createdDate = DateTime.ParseExact(orderDateStr, "yyyyMMdd HH:mm:ss", CultureInfo.InvariantCulture); orderDTO.source = this.Name; orderDTO.sourceDesc = Util.Helpers.Reflection.GetDescription <OrderSource>(this.Name); orderDTO.sourceSN = Convert.ToString(row[0]); //订单号 if (string.IsNullOrEmpty(orderDTO.sourceSN)) { InputExceptionOrder(orderDTO, ExceptionType.SourceSnIsNull); continue; } orderDTO.productName = Convert.ToString(row["商品名称"]); //商品名称 // orderDTO.productsku = Convert.ToString(row[2]); //商品编号 orderDTO.orderSN = string.Format("{0}-{1}_{2}", orderDTO.source, orderDTO.sourceSN, orderDTO.createdDate.ToString("yyyyMMdd")); if (CheckOrderInDataBase(orderDTO))//是否是重复订单 { continue; } var item = items.Find(o => o.OrderSn == orderDTO.orderSN); if (item == null) { orderDTO.count = Convert.ToInt32(row["数量"]); //数量 orderDTO.consigneeName = Convert.ToString(row["收件人姓名"]); //收件人 orderDTO.consigneePhone = Convert.ToString(row["收件人联系方式"]); //联系电话 orderDTO.consigneePhone2 = string.Empty; orderDTO.consigneeProvince = string.Empty; orderDTO.consigneeCity = string.Empty; orderDTO.consigneeCounty = string.Empty; orderDTO.consigneeAddress = Convert.ToString(row["收件人地址"]); //收货地区+详细地址 // orderDTO.consigneeZipCode = Convert.ToString(row[9]); //邮编 // if (string.IsNullOrEmpty(orderDTO.consigneeProvince) && string.IsNullOrEmpty(orderDTO.consigneeCity) && !string.IsNullOrEmpty(orderDTO.consigneeAddress)) { var addrInfo = DistrictService.DistrictService.ResolveAddress(orderDTO.consigneeAddress); orderDTO.consigneeProvince = addrInfo.Province; orderDTO.consigneeCity = addrInfo.City; orderDTO.consigneeCounty = addrInfo.County; // consigneeAddress = addrInfo.Address; } OrderEntity orderItem = OrderEntityService.CreateOrderEntity(orderDTO); using (var db = new OMSContext()) { //查找联系人 if (!string.IsNullOrEmpty(orderItem.Consignee.Phone)) { OrderEntityService.InputConsigneeInfo(orderItem, db); } else //异常订单 { InputExceptionOrder(orderDTO, ExceptionType.PhoneNumOrPersonNameIsNull); continue; } if (!InputProductInfoWithoutSaveChange(db, orderDTO, orderItem)) { continue; } items.Add(orderItem); if (orderItem.OrderRepurchase == null) { orderItem.OrderRepurchase = new OrderRepurchase(); } db.OrderRepurchases.Add(orderItem.OrderRepurchase); db.OrderDateInfos.Add(orderItem.OrderDateInfo); db.SaveChanges(); } } else { orderDTO.consigneeName = Convert.ToString(row["收件人姓名"]); //收件人 orderDTO.consigneePhone = Convert.ToString(row["收件人联系方式"]); //联系电话 orderDTO.count = Convert.ToInt32(row["数量"]); //数量 using (var db = new OMSContext()) { InputProductInfoWithoutSaveChange(db, orderDTO, item); } } } return(items); }
protected List <OrderEntity> ResolveOrders(DataTable excelTable, DataFileInfo file, List <OrderEntity> items) { OrderDTO orderDTO = new OrderDTO(); orderDTO.orderStatus = OrderStatus.Confirmed; orderDTO.fileName = file.FullName; orderDTO.orderType = 0; orderDTO.orderStatus = OrderStatus.Confirmed; for (int i = 0; i < excelTable.Rows.Count; i++) { var row = excelTable.Rows[i]; var orderDateStr = Convert.ToString(row["制单时间"]); //订单创建时间 orderDTO.createdDate = DateTime.Parse(orderDateStr); // orderDTO.createdDate = file.FileDate; /*金文的订单整合在一个EXCEL中。 * 根据店铺名称解析为银行-金文科技代发和银行-金文(工行代发) */ string shopName = Convert.ToString(row["店铺"]); if (shopName == "金文网络-中国工商银行积分商城" || shopName == "金文网络-工商银行工银e生活合作项目(积分模块)".Trim()) { orderDTO.source = OrderSource.ICBC_JINWEN; orderDTO.sourceDesc = Util.Helpers.Reflection.GetDescription <OrderSource>(OrderSource.ICBC_JINWEN); } else { orderDTO.source = OrderSource.BANK_JINWEN; orderDTO.sourceDesc = Util.Helpers.Reflection.GetDescription <OrderSource>(OrderSource.BANK_JINWEN); } orderDTO.sourceSN = Convert.ToString(row["交易号"]); //订单号 if (string.IsNullOrEmpty(orderDTO.sourceSN)) { InputExceptionOrder(orderDTO, ExceptionType.SourceSnIsNull); continue; } orderDTO.productName = Convert.ToString(row["商品名称"]); //商品名称 // orderDTO.productsku = Convert.ToString(row[2]); //商品编号 try { orderDTO.count = Convert.ToInt32(row["通知数量"]); //数量 } catch (Exception) { orderDTO.count = Convert.ToInt32(row["数量"]); //数量 } orderDTO.orderSN = string.Format("{0}-{1}_{2}", orderDTO.source, orderDTO.sourceSN, orderDTO.createdDate.ToString("yyyyMMdd")); if (CheckOrderInDataBase(orderDTO))//是否是重复订单 { continue; } var item = items.Find(o => o.OrderSn == orderDTO.orderSN); if (item == null) { orderDTO.consigneeName = Convert.ToString(row["收货人"]); //收件人 orderDTO.consigneePhone = Convert.ToString(row["手机"]); //联系电话 orderDTO.consigneePhone2 = string.Empty; orderDTO.consigneeProvince = string.Empty; orderDTO.consigneeCity = string.Empty; orderDTO.consigneeCounty = string.Empty; orderDTO.consigneeAddress = Convert.ToString(row["地址"]); //收货地区+详细地址 // orderDTO.consigneeZipCode = Convert.ToString(row[9]); //邮编 // if (string.IsNullOrEmpty(orderDTO.consigneeProvince) && string.IsNullOrEmpty(orderDTO.consigneeCity) && !string.IsNullOrEmpty(orderDTO.consigneeAddress)) { var addrInfo = DistrictService.DistrictService.ResolveAddress(orderDTO.consigneeAddress); orderDTO.consigneeProvince = addrInfo.Province; orderDTO.consigneeCity = addrInfo.City; orderDTO.consigneeCounty = addrInfo.County; // consigneeAddress = addrInfo.Address; } OrderEntity orderItem = OrderEntityService.CreateOrderEntity(orderDTO); using (var db = new OMSContext()) { //查找联系人 if (!string.IsNullOrEmpty(orderItem.Consignee.Phone)) { OrderEntityService.InputConsigneeInfo(orderItem, db); } else //异常订单 { InputExceptionOrder(orderDTO, ExceptionType.PhoneNumOrPersonNameIsNull); continue; } if (!InputProductInfoWithoutSaveChange(db, orderDTO, orderItem)) { continue; } items.Add(orderItem); if (orderItem.OrderRepurchase == null) { orderItem.OrderRepurchase = new OrderRepurchase(); } db.OrderRepurchases.Add(orderItem.OrderRepurchase); db.OrderDateInfos.Add(orderItem.OrderDateInfo); db.SaveChanges(); } } else { orderDTO.consigneeName = Convert.ToString(row["收货人"]); //收件人 orderDTO.consigneePhone = Convert.ToString(row["手机"]); //联系电话 try { orderDTO.count = Convert.ToInt32(row["通知数量"]); //数量 } catch (Exception) { orderDTO.count = Convert.ToInt32(row["数量"]); //数量 } using (var db = new OMSContext()) { InputProductInfoWithoutSaveChange(db, orderDTO, item); } } } return(items); }
/// <summary> /// 客先担当選択.ViewModel /// </summary> /// <param name="dataFile">ファイル情報</param> public SelectedStaff(DataFileInfo dataFile) { _Model = new Model::SelectedStaff(dataFile); }
/// <summary> /// 見積書情報ファイル /// </summary> /// <param name="dataFile">作成書類情報</param> public QuotationFile(DataFileInfo dataFile) : base(new PathInfo().Files.Quotation.Replace(PathInfo.Wild, dataFile.GetFileNameParts()), "Quote") { }