Exemplo n.º 1
0
		public bool SaveCompletedCollection(Collection baseItem)
		{
			try
			{
				using (var connection = database.NewConnection())
				{
					using (IDbCommand command = connection.CreateCommand())
					{
						var update = DataItemExists(baseItem.Do);

						if (update)
							command.CommandText = @"UPDATE [@DEL_HIST_HEADER] 
														SET
															U_date = ?, 
															U_Address = ?, 
															U_Collection_Time = ?, 
															U_Collect_From = ?, 
															U_Phone = ?, 
															U_Notify_Email = ?, 
															U_Notify_Url = ?, 
															U_Assign_To = ?, 
															U_Instructions = ?,
															U_Zone = ?,
															U_Reason = ?,
															U_Note = ?,
															U_Sent_By = ?,
															U_Image = ?,
															U_View_Image_Url = ?,
															U_Status = ?,
															U_Time = ?,
															U_Pod_Lat = ?,
															U_Pod_Lng = ?,
															U_Pod_Address = ?
														WHERE
															U_do = ?";
						else
							command.CommandText = @"INSERT INTO [@DEL_HIST_HEADER] 
													VALUES ( 
														(SELECT MAX(CODE)+1 FROM [@DEL_HIST_HEADER]), 
														(SELECT MAX(CODE)+1 FROM [@DEL_HIST_HEADER]),
														?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";

						connection.Open();

						if (update)
							database.ExecuteNonQuery(command, baseItem.Date, baseItem.Address, baseItem.Collection_Time, baseItem.Collect_From,
													baseItem.Phone, baseItem.Notify_Email, baseItem.Notify_Url, baseItem.Assign_To, baseItem.Instructions,
													baseItem.Zone, baseItem.Reason, baseItem.Note, baseItem.Sent_By, baseItem.Image.ToString(), baseItem.View_Image_Url,
													baseItem.Status, baseItem.Time.GetValueOrDefault().ToShortTimeString(), baseItem.Pod_Lat.ToString(),
													baseItem.Pod_Lng.ToString(), baseItem.Pod_Address, int.Parse(baseItem.Do));
						else
							database.ExecuteNonQuery(command, baseItem.Date, int.Parse(baseItem.Do), baseItem.Address, null, null, baseItem.Collection_Time, baseItem.Collect_From,
													baseItem.Phone, baseItem.Notify_Email, baseItem.Notify_Url, baseItem.Assign_To, baseItem.Instructions,
													baseItem.Zone, baseItem.Reason, baseItem.Note, null, baseItem.Sent_By, baseItem.Image.ToString(), baseItem.View_Image_Url,
													baseItem.Status, baseItem.Time.GetValueOrDefault().ToShortTimeString(), baseItem.Pod_Lat.ToString(),
													baseItem.Pod_Lng.ToString(), baseItem.Pod_Address);

						foreach (var item in baseItem.Items)
						{
							SaveItems(item, baseItem.Do);
						}
					}
				}

				return true;
			}
			catch (Exception ex)
			{
				return false;
			}

		}
		public void GetSignatureImageCollection()
		{
			var repo = new DetrackRepository<Collection>("ab1d456a7296733ce90501565eaf3583058b183cb7c6df80");
			const string collectionId = "8897978";

			var collection = new Collection(new DateTime(2014, 8, 29), collectionId);

			Assert.IsNotNull(repo.GetSignatureImage(collection));
		}