public LastModification GetLastModification(Module module) { LastModification lastModification = new LastModification(); lastModification.Timestamp = null; using (SqlCommand command = new SqlCommand()) { using (SqlConnection connection = new SqlConnection()) { connection.ConnectionString = ConnectionString; command.Connection = connection; command.CommandText = "spGetLastModification"; command.Parameters.Add("@ModuleId", SqlDbType.Int).Value = module; command.CommandType = CommandType.StoredProcedure; connection.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader.Read()) { lastModification.Module = (Module)int.Parse(reader["ModuleId"].ToString()); lastModification.Timestamp = reader["Timestamp"] != null?DateTime.Parse(reader["Timestamp"].ToString()) : (DateTime?)null; } connection.Close(); } } return(lastModification); }
protected override void DoExecute(CodeActivityContext context) { devlog.Debug(string.Format("Entered for '{0}' and '{1}' and '{2}'", Consumer, Result, LastModification)); var myConsumer = Consumer.Get(context); var lastModification = LastModification.Get(context); devlog.Debug(string.Format("Got '{0}' and '{1}'", myConsumer, lastModification)); var modifiedItems = AppointmentRepository.ModifiedThroughAdapter(myConsumer, lastModification); List <Models.AppointmentDTO> resultItems = new List <Models.AppointmentDTO>(modifiedItems); devlog.DebugFormat("resultItems:'{0}'", resultItems.Count); Result.Set(context, resultItems.ToArray()); }
public void TestSetAndGetLastModification() { LastModificationBL bl = new LastModificationBL(connectionString); DateTime startTime = DateTime.Now; bl.SetLastModification(new LastModification() { Module = Module.Producers }); LastModification modification = bl.GetLastModification(Module.Producers); Assert.IsTrue(modification.Timestamp.HasValue); Assert.IsTrue(modification.Timestamp.Value.Subtract(startTime).TotalSeconds < 4); }
public IHttpActionResult GetLastModification(Module module) { GetLastModificationResponse response = new GetLastModificationResponse(); try { List <LastModification> lastModifications = new List <LastModification>(); LastModification lastModification = lastModificationBL.GetLastModification(module); lastModifications.Add(lastModification); response.LastModifications = lastModifications; response.Success = true; } catch (Exception ex) { response.ErrorMessage = "Error. " + ex.Message; response.Success = false; } return(Ok(response)); }
public bool SetLastModification(LastModification lastModification) { bool success = false; using (SqlCommand command = new SqlCommand()) { using (SqlConnection connection = new SqlConnection()) { connection.ConnectionString = ConnectionString; command.Connection = connection; command.CommandText = "spSetLastModification"; command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@ModuleId", SqlDbType.Int).Value = lastModification.Module; command.Parameters.Add("@Timestamp", SqlDbType.DateTime).Value = DateTime.Now; //ignore the value connection.Open(); object id = command.ExecuteScalar(); success = (int)id > 0; connection.Close(); } return(success); } }
public bool SetLastModification(LastModification lastModification) { return(lastModificationDL.SetLastModification(lastModification)); }