public IAsyncResult BeginCancelSample(int arlNumber, SampleNote note, Identification identification, AsyncCallback callback, object state) { logger.Log(LogLevel.Trace, AppLib.GetCaller(logger)); identification.UserId = AppLib.VerifyToken(identification.Token); if (identification.UserId <= 0) { throw new FaultException<ServiceFault>(new ServiceFault("Invalid Authentication", "Authorization"), new FaultReason("Unauthorized")); } if (!AppLib.IsAuthorized(identification, SysLib.GetOptionName(ModuleNames.Samples, ModelNamesEnum.Sample, ModuleAction.Cancel))) throw new FaultException<ServiceFault>(new ServiceFault("User account is not Authorized.", "Authorization"), new FaultReason("Restricted")); var task = Task<int>.Factory.StartNew(process => DoCancelSample(arlNumber, note, identification), state); return task.ContinueWith(res => callback(task)); }
public CancelOrderRequest(int arlNumber, SampleNote note) { this.arlNumber = arlNumber; this.note = note; }
public CancelSampleTestRequest(int sampleTesId, SampleNote note) { this.sampleTestId = sampleTesId; this.note = note; }
public int DoCancelSampleTest(int id, SampleNote note, Identification identification) { logger.Log(LogLevel.Trace, AppLib.GetCaller(logger)); using (SampleDAO dao = new SampleDAO()) { return dao.CancelSampleTest(id, note, identification); } }
public int DoReturnToOos(TimePoint timePoint, SampleNote note, Identification identification) { logger.Log(LogLevel.Trace, AppLib.GetCaller(logger)); using (SampleDAO dao = new SampleDAO()) { return dao.ReturnToOos(timePoint, note, identification); } }
public IAsyncResult BeginReturnToOos(TimePoint timePoint, SampleNote note, Identification identification, AsyncCallback callback, object state) { logger.Log(LogLevel.Trace, AppLib.GetCaller(logger)); identification.UserId = AppLib.VerifyToken(identification.Token); if (identification.UserId <= 0) { throw new FaultException<ServiceFault>(new ServiceFault("Invalid Authentication", "Authorization"), new FaultReason("Unauthorized")); } var task = Task<int>.Factory.StartNew(process => DoReturnToOos(timePoint, note, identification), state); return task.ContinueWith(res => callback(task)); }
public int ReturnToOos(TimePoint timePoint, SampleNote note, Identification identification) { int rowsAffected; using (DbConnection = new MsSqlPersistence(DbConnectionSettings, true)) { try { if (DbConnection.IsConnected()) { using (DbCommand) { SystemDAO.SaveChangeAudit<TimePoint>(ref dbConnection, ref dbCommand, "Return to OOS #:" + timePoint.OosId.ToString(), "Status", "Approved", "Pending Investigation", ModuleNames.Samples, timePoint.ParentId, timePoint.Pk, identification.UserId); this.SaveSampleNote(ref dbConnection, ref dbCommand, ref note, (int)timePoint.ParentId, identification); string sql = string.Empty; sql = "UPDATE orders_samples_tests_timepoints_oos " + "SET status = @Status " + "WHERE id = @ID"; DbCommand.Parameters.Clear(); DbCommand.Parameters.Add("@ID", System.Data.SqlDbType.Int).Value = timePoint.OosId; DbCommand.Parameters.Add("@Status", System.Data.SqlDbType.Int).Value = (int)EnumOosStatus.Open; DbCommand.CommandText = sql; rowsAffected = DbConnection.ExecuteCommand(DbCommand); OrderSampleTestsSetStatus(ref dbConnection, ref dbCommand, (int)timePoint.ParentId, identification); } } else { throw new Exception("Unable to Connect"); } return rowsAffected; } catch { throw; } } }
public int SaveSampleNote(ref MsSqlPersistence dbConnection, ref SqlCommand dbCommand, ref SampleNote note, int? arlNumber, Identification identification) { try { int returnValue = 0; if (note.IsDirty) { dbCommand.Parameters.Clear(); if (note.SampleNoteId <= 0 || note.SampleNoteId.IsNull()) { dbCommand.CommandText = "uspInsertSampleNote"; dbCommand.Parameters.Add("@ARLNumber", System.Data.SqlDbType.Int).Value = arlNumber; dbCommand.Parameters.Add("@CreatedBy", System.Data.SqlDbType.Int).Value = identification.UserId; dbCommand.Parameters.Add("@CreatedDate", System.Data.SqlDbType.DateTime).Value = DateTime.Now; } else { SystemDAO.SaveChangeAudit<ClientNote>(ref dbConnection, ref dbCommand, GetSampleNote(ref dbConnection, ref dbCommand, note.Pk, identification), note, ModuleNames.Samples, arlNumber, identification.UserId); dbCommand.CommandText = "uspUpdateSampleNote"; dbCommand.Parameters.Add("@SampleNoteId", System.Data.SqlDbType.Int).Value = note.SampleNoteId; dbCommand.Parameters.Add("@DeleteDate", System.Data.SqlDbType.DateTime).Value = note.DeleteDate.HasValue ? note.DeleteDate.Value : SqlDateTime.Null; dbCommand.Parameters.Add("@ModifiedBy", System.Data.SqlDbType.Int).Value = identification.UserId; dbCommand.Parameters.Add("@ModifiedDate", System.Data.SqlDbType.DateTime).Value = DateTime.Now; } dbCommand.Parameters.Add("@Note", System.Data.SqlDbType.NVarChar, 4000).Value = note.Note ?? SqlString.Null; dbCommand.Parameters.Add("@IncludeOnCOAYN", System.Data.SqlDbType.Bit).Value = note.IncludeOnCOAYN; returnValue += dbConnection.ExecuteCommand(dbCommand); } //Return Total Number of Inserted or Updated Records return returnValue; } catch { throw; } }
public int ReinstateOrderSampleTest(int id, SampleNote note, Identification identificaion) { int rowsAffected; using (DbConnection = new MsSqlPersistence(DbConnectionSettings, true)) { try { if (DbConnection.IsConnected()) { using (DbCommand) { this.SaveSampleNote(ref dbConnection, ref dbCommand, ref note, id, identificaion); string sql = string.Empty; sql = "UPDATE orders_samples_tests " + "SET status = @Status, modified_by = @ModifiedBy " + "WHERE id = @ID"; DbCommand.Parameters.Add("@ID", System.Data.SqlDbType.Int).Value = id; DbCommand.Parameters.Add("@Status", System.Data.SqlDbType.Int).Value = (int)SampleTestStatus.InProgress; DbCommand.Parameters.Add("@ModifiedBy", System.Data.SqlDbType.Int).Value = identificaion.UserId; DbCommand.CommandText = sql; rowsAffected = DbConnection.ExecuteCommand(DbCommand); } } else { throw new Exception("Unable to Connect"); } return rowsAffected; } catch { throw; } } }
public SmartCollection<SampleNote> GetSampleTestNotes(int arlNumber, int sampleTestId) { try { SmartCollection<SampleNote> resultList = new SmartCollection<SampleNote>(); using (DbConnection = new MsSqlPersistence(DbConnectionSettings)) { if (DbConnection.IsConnected()) { using (DbCommand) { DbCommand.CommandType = CommandType.StoredProcedure; DbCommand.CommandText = "uspGetSampleTestNotes"; DbCommand.Parameters.Clear(); DbCommand.Parameters.Add("@ARLNumber", System.Data.SqlDbType.Int).Value = arlNumber; DbCommand.Parameters.Add("@SampleTestId", System.Data.SqlDbType.Int).Value = sampleTestId; DataTable notesDT = DbConnection.ExecuteQuery(DbCommand); foreach (DataRow row in notesDT.Rows) { SampleNote note = new SampleNote(); note.SampleNoteId = Convert.ToInt32(row["SampleNoteID"]); note.ARLNumber = row["ARLNumber"] != DBNull.Value ? Convert.ToInt32(row["ARLNumber"]) : new Int32(); note.SampleTestId = row["SampleTestID"] != DBNull.Value ? Convert.ToInt32(row["SampleTestID"]) : new Int32(); note.Note = row["Note"].ToString(); note.IncludeOnWOYN = row["IncludeOnWOYN"] != DBNull.Value ? Convert.ToBoolean(row["IncludeOnWOYN"]) : false; note.IncludeOnCOAYN = row["IncludeOnCOAYN"] != DBNull.Value ? Convert.ToBoolean(row["IncludeOnCOAYN"]) : false; note.BillGroup = row["BillGroup"] != DBNull.Value ? Convert.ToInt32(row["BillGroup"]) : new Int32(); note.CreatedBy = row["CreatedBy"] != DBNull.Value ? Convert.ToInt32(row["CreatedBy"]) : new Int32(); note.CreatedUser = row["CreatedUser"].ToString(); note.CreatedDate = row["CreatedDate"] != DBNull.Value ? (DateTime)row["CreatedDate"] : (DateTime)SqlDateTime.Null; note.ModifiedBy = row["ModifiedBy"] != DBNull.Value ? Convert.ToInt32(row["ModifiedBy"]) : new Int32(); note.ModifiedUser = row["ModifiedUser"].ToString(); note.ModifiedDate = row["ModifiedDate"] != DBNull.Value ? (DateTime)row["ModifiedDate"] : (DateTime)SqlDateTime.Null; resultList.Add(note); } notesDT = null; } } else { throw new Exception("Unable to Connect"); } } return resultList; } catch { throw; } }
public int CancelSampleTest(int sampleTestId, SampleNote note, Identification identification) { int rowsAffected; using (DbConnection = new MsSqlPersistence(DbConnectionSettings, true)) { try { if (DbConnection.IsConnected()) { using (DbCommand) { DbCommand.CommandType = CommandType.StoredProcedure; DbCommand.CommandText = "uspCancelSampleTest"; DbCommand.Parameters.Clear(); DbCommand.Parameters.Add("@SampleTestId", System.Data.SqlDbType.Int).Value = sampleTestId; DbCommand.Parameters.Add("@Status", System.Data.SqlDbType.Int).Value = (int)SampleTestStatus.Cancelled; DbCommand.Parameters.Add("@UserId", System.Data.SqlDbType.Int).Value = identification.UserId; rowsAffected = DbConnection.ExecuteCommand(DbCommand); this.SaveSampleNote(ref dbConnection, ref dbCommand, ref note, note.ARLNumber, identification); } } else { throw new Exception("Unable to Connect"); } return rowsAffected; } catch { throw; } } }
public SampleNote GetSampleNote(ref MsSqlPersistence dbConnection, ref SqlCommand dbCommand, int? sampleNoteId, Identification identification) { try { SampleNote note = new SampleNote(); if (dbConnection.IsConnected()) { dbCommand.CommandType = CommandType.StoredProcedure; dbCommand.CommandText = "uspGetSampleNote"; dbCommand.Parameters.Clear(); dbCommand.Parameters.Add("@SampleNoteId", System.Data.SqlDbType.Int).Value = sampleNoteId; DataTable notesDT = dbConnection.ExecuteQuery(dbCommand); if (notesDT.Rows.Count == 1) { DataRow row = notesDT.Rows[0]; note.SampleNoteId = Convert.ToInt32(row["SampleNoteID"]); note.ARLNumber = row["ARLNumber"] != DBNull.Value ? Convert.ToInt32(row["ARLNumber"]) : new Int32(); note.SampleTestId = row["SampleTestID"] != DBNull.Value ? Convert.ToInt32(row["SampleTestID"]) : new Int32(); note.Note = row["Note"].ToString(); note.IncludeOnWOYN = row["IncludeOnWOYN"] != DBNull.Value ? Convert.ToBoolean(row["IncludeOnWOYN"]) : false; note.IncludeOnCOAYN = row["IncludeOnCOAYN"] != DBNull.Value ? Convert.ToBoolean(row["IncludeOnCOAYN"]) : false; note.BillGroup = row["BillGroup"] != DBNull.Value ? Convert.ToInt32(row["BillGroup"]) : new Int32(); note.CreatedBy = row["CreatedBy"] != DBNull.Value ? Convert.ToInt32(row["CreatedBy"]) : new Int32(); note.CreatedUser = row["CreatedUser"].ToString(); note.CreatedDate = row["CreatedDate"] != DBNull.Value ? (DateTime)row["CreatedDate"] : (DateTime)SqlDateTime.Null; note.ModifiedBy = row["ModifiedBy"] != DBNull.Value ? Convert.ToInt32(row["ModifiedBy"]) : new Int32(); note.ModifiedUser = row["ModifiedUser"].ToString(); note.ModifiedDate = row["ModifiedDate"] != DBNull.Value ? (DateTime)row["ModifiedDate"] : (DateTime)SqlDateTime.Null; } notesDT = null; dbCommand.Parameters.Clear(); } else { throw new Exception("Unable to Connect"); } return note; } catch { throw; } }
public SaveOrderSampleTestResultsRequest(SmartCollection<SampleTest> results, SampleNote editNote) { this.results = results; this.editNote = editNote; }