private void SendCommand2Server(RdetOutChannel ch, DataSet ds) { foreach (DataRow dr in ds.Tables[0].Rows) { // build command if (!ds.Tables[0].Columns.Contains("Command")) { Program.Log.Write(LogType.Error, "Configuration File error!Cannot find column 'Command'!\r\n" + "channel name:" + ch.ChannelName + "\r\n"); return; //throw new Exception(""); } try { CmdReqBase request = null; if (CommandToken.IsNewPatient(dr["Command"].ToString())) { request = BuildCmdReqNewPatient(ch, dr); } else if (CommandToken.IsUpdatePatient(dr["Command"].ToString())) { request = BuildCmdReqUpdatePatient(ch, dr); } else if (CommandToken.IsNewImage(Convert.ToString(dr["Command"]))) { request = BuildCmdReqNewImage(ch, dr); } if (request == null) { Program.Log.Write("Invalid DataRow! Command=" + dr["Command"].ToString() + " \r\n"); continue; } // Send Command CmdRespBase resp; if (Program.bStandalone) { resp = new CmdRespBase(); resp.AddParameter(CommandToken.StudyInstanceUID, "StudyInstenceUID001"); resp.ErrorCode = "0"; } else { resp = _ClientSocket.SendCommand(request); } _ClientSocket.DisConnect(false); if (resp == null) { Program.Log.Write("There is no correct response or no response data to request ! \r\n"); continue; } if (Convert.ToInt32(resp.ErrorCode) == 0) { if (OnDataDischarge != null) { this.OnDataDischarge(new string[] { Convert.ToString(dr["Data_ID"]) }); } //Write StudyinstanceUID if (CommandToken.IsNewPatient(request.Command)) { UpdateStudyInstanceUID(Convert.ToString(dr["Data_ID"]), resp.GetParamValue(CommandToken.StudyInstanceUID), _fStudyInstanceUID); } } else { RdetError Err = RdetErrorMgt.GetRdetError(Convert.ToInt32(resp.ErrorCode.Trim())); Program.Log.Write(LogType.Error, "------------Error Exist! ----------------------------------------\r\n" + "ErrorCode=" + Err.Code.ToString() + "\r\n" + "Error Description: " + Err.ErrorDescription + "\r\n" + "Error Resolution : " + Err.ErrorDescription + "\r\n" + "----------------------------------------------------------------\r\n", true); } } catch (Exception ex) { Program.Log.Write(LogType.Error, "Unknow Error:" + ex.Message + "\r\n" + "channel Name:" + ch.ChannelName + "\r\n"); } } }