public static void SyncFileGroupValuationTemplate() { var rowVersionList = RpcFacade.Call <IList <RpcObject> >("/MainSystem/B3HR/Rpcs/FileGroupValuationRpc/GetRowVersion", SysConfig.Current.AccountingUnit_ID).Select(obj => new Tuple <long, int>(obj.Get <long>("ID"), obj.Get <int>("RowVersion"))).ToList(); var folder = Path.Combine(Util.DataFolder, typeof(ClientFileGroupValuation).Name); BeforeWriteFile(rowVersionList, folder); var templateList = RpcFacade.Call <IList <RpcObject> >("/MainSystem/B3HR/Rpcs/FileGroupValuationRpc/GetFileGroupValuationTemplate", rowVersionList.Select(x => new long?(x.Item1)).ToArray()); foreach (var template in templateList) { var clientBill = new ClientFileGroupValuation(); clientBill.ID = template.Get <long>("ID"); clientBill.Name = template.Get <string>("Name"); clientBill.Department_ID = template.Get <long>("Department_ID"); clientBill.Department_Name = template.Get <string>("Department_Name"); var rowVersion = template.Get <int>("RowVersion"); var fileGroupDetailList = template.Get <IList <RpcObject> >("FileGroupDetails"); foreach (var detail in fileGroupDetailList) { var fileGroupDetail = new ClientFileGroupValuation_FileGroupDetail(); fileGroupDetail.FileGroup_ID = detail.Get <long>("FileGroup_ID"); fileGroupDetail.FileGroup_Name = detail.Get <string>("FileGroup_Name"); fileGroupDetail.FileGroupCode = detail.Get <string>("FileGroup_Code"); clientBill.FileGroupDetails.Add(fileGroupDetail); } var pieceItemDetailList = template.Get <IList <RpcObject> >("PieceItemDetails"); foreach (var detail in pieceItemDetailList) { var pieceItemDetail = new ClientFileGroupValuation_PieceItemDetail(); pieceItemDetail.PieceItem_ID = detail.Get <long>("PieceItem_ID"); pieceItemDetail.PieceItem_Name = detail.Get <string>("PieceItem_Name"); pieceItemDetail.PieceItem_Code = detail.Get <string>("PieceItem_Code"); clientBill.PieceItemDetails.Add(pieceItemDetail); } XmlSerializer serializer = new XmlSerializer(typeof(ClientFileGroupValuation)); using (var stream = File.Open(Path.Combine(folder, clientBill.ID + ".xml"), FileMode.Create)) { serializer.Serialize(stream, clientBill); } using (var stream = File.CreateText(Path.Combine(folder, clientBill.ID + ".ver"))) { stream.Write(rowVersion); } } }
public FileGroupValuationDialog(long departMentID, long template) { InitializeComponent(); Util.SetSceen(this); fileGroupValuation = new ClientFileGroupValuationBillSave { AccountingUnit_ID = SysConfig.Current.AccountingUnit_ID.Value, Department_ID = departMentID, Domain_ID = SysConfig.Current.Domain_ID, User_ID = SysConfig.Current.User_ID, CreateTime = DateTime.Now, IsHandsetSend = true }; comboBoxFileGroup.Items.Add(""); comboBoxPieceItem.Items.Add(""); string file = Path.Combine(Path.Combine(Util.DataFolder, typeof(ClientFileGroupValuation).Name), template.ToString() + ".xml"); XmlSerializer serializer = new XmlSerializer(typeof(ClientFileGroupValuation)); using (var stream = File.Open(file, FileMode.Open)) { fileGroupValuationTemplate = serializer.Deserialize(stream) as ClientFileGroupValuation; } foreach (var fileGroupDetail in fileGroupValuationTemplate.FileGroupDetails) { if (fileGroupDetail.FileGroup_ID != 0) { comboBoxFileGroup.Items.Add(new Option(fileGroupDetail.FileGroup_Name, fileGroupDetail.FileGroup_ID)); } } foreach (var pieceItemDetail in fileGroupValuationTemplate.PieceItemDetails) { if (pieceItemDetail.PieceItem_ID != 0) { comboBoxPieceItem.Items.Add(new Option(pieceItemDetail.PieceItem_Name, pieceItemDetail.PieceItem_ID)); } } comboBoxFileGroup.Focus(); HardwareUtil.Device.ScannerReader += new EventHandler <ScanEventArgs>(Device_ScannerReaders); }