private void CopyToSyncFolder(SyncFromDeptToDept fromDeptToDept) { EnsureSyncInternalPath(); CopyToExportFolder(fromDeptToDept); }
void deptStockOutView_DispatchDepartmentStockOut(object sender, DepartmentStockOutEventArgs e) { Department destDept = DepartmentLogic.FindById(e.DepartmentStockOut.OtherDepartmentId); if (destDept != null) { foreach (DepartmentStockOutDetail detail in e.DepartmentStockOut.DepartmentStockOutDetails) { string prdMasterId = detail.Product.ProductMaster.ProductMasterId; DepartmentPricePK pricePk = new DepartmentPricePK { DepartmentId = 0, ProductMasterId = prdMasterId }; detail.DepartmentPrice = DepartmentPriceLogic.FindById(pricePk); } SyncFromDeptToDept fromDeptToDept = new SyncFromDeptToDept { DestinationDept = destDept }; fromDeptToDept.DepartmentStockOutList = new ArrayList(); fromDeptToDept.DepartmentStockOutList.Add(e.DepartmentStockOut); CopyToSyncFolder(fromDeptToDept); ServerServiceClient serverService = new ServerServiceClient(new InstanceContext(this), ClientSetting.ServiceBinding); serverService.MakeRawDepartmentStockOut(destDept,e.DepartmentStockOut,new DepartmentPrice()); } }
private void CopyToExportFolder(SyncFromDeptToDept fromDeptToDept) { string rootPath = Application.CommonAppDataPath; string internalPath = ClientSetting.SyncInternalPath; if (!internalPath.StartsWith(@"\")) internalPath = @"\" + internalPath; rootPath = rootPath + internalPath; string syncExportPath = rootPath + ClientSetting.SyncExportPath; string syncImportPath = rootPath + ClientSetting.SyncImportPath; string syncSuccessPath = rootPath + ClientSetting.SyncSuccessPath; string syncErrorPath = rootPath + ClientSetting.SyncErrorPath; try { string fileName = syncExportPath + "\\" + fromDeptToDept.DestinationDept + "_SyncDown_" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss") + CommonConstants.SERVER_SYNC_FORMAT; Stream stream = File.Open(fileName, FileMode.Create); BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(stream, fromDeptToDept); stream.Flush(); stream.Close(); InformationBox.Show("Chép file vào thư mục đồng bộ thành công !", new AutoCloseParameters(3)); } catch(Exception ex) { InformationBox.Show("Chép file vào thư mục đồng bộ thất bại !", new AutoCloseParameters(3)); } }