public bool ImportFile(string sFile, DTDataDestination dest, bool bSilent) { bool bOK = false; System.Data.DataTable tblSrc = null; System.IO.FileStream stream = null; IFormatter formatter = new BinaryFormatter(); try { stream = new System.IO.FileStream(sFile, System.IO.FileMode.Open, System.IO.FileAccess.Read); tblSrc = (System.Data.DataTable)formatter.Deserialize(stream); bOK = true; } catch (Exception er) { _error = ExceptionLimnorDatabase.FormExceptionText(er, "Error importing file [{0}].", sFile); TraceLogClass.TraceLog.ShowMessageBox = !bSilent; TraceLogClass.TraceLog.Log(er); } finally { if (stream != null) { stream.Close(); } } if (bOK) { _error = dest.ReceiveData(tblSrc, bSilent); } return(bOK); }
void startDT() { _error = null; bool bSilent = Silent; enumDTType tp = this.EndPointType; if (tp == enumDTType.Both || tp == enumDTType.Sender) { IEPDataSource dtsSrc = DataSource; ClientDate cp = new ClientDate(ID); cp.LoadSettings(); dtsSrc.Timestamp = cp.dt; if (tp == enumDTType.Both) { DTDataDestination dest = this.DataDestination; if (dest.IsReady) { if (StartedDataTransfer != null) { StartedDataTransfer(this, EventArgs.Empty); } DataTable tblSrc = dtsSrc.DataSource; if (tblSrc != null) { _error = dest.ReceiveData(tblSrc, bSilent); } else { _error = dtsSrc.LastError; } if (string.IsNullOrEmpty(_error)) { if (FinishedDataTransfer != null) { FinishedDataTransfer(); } } else { if (ErrorDataTransfer != null) { ErrorDataTransfer(this, EventArgs.Empty); } } } } else { if (StartedDataTransfer != null) { StartedDataTransfer(this, EventArgs.Empty); } System.Data.DataTable tblSrc = dtsSrc.DataSource; if (tblSrc != null) { TransMethod method = DataTransferMethod; if (method.SendFile(tblSrc, Name, bSilent)) { if (FinishedDataTransfer != null) { FinishedDataTransfer(); } } else { _error = method.ErrorMessage; if (ErrorDataTransfer != null) { ErrorDataTransfer(this, EventArgs.Empty); } } } } if (string.IsNullOrEmpty(_error)) { cp.dt = dtsSrc.Timestamp; cp.SaveSettings(); } dtsSrc.ClearData(); } else { DTDataDestination dest = DataDestination; if (dest.IsReady) { if (StartedDataTransfer != null) { StartedDataTransfer(this, EventArgs.Empty); } TransMethod method = DataTransferMethod; if (method.ReceiveFile(Name, dest, bSilent)) { if (FinishedDataTransfer != null) { FinishedDataTransfer(); } } else { _error = method.ErrorMessage; if (ErrorDataTransfer != null) { ErrorDataTransfer(this, EventArgs.Empty); } } } } }