public override void Run()
        {
            Trace.WriteLine("Starting processing of messages");
            WriteLog("in Run()");
            // Initiates the message pump and callback is invoked for each message that is received, calling close on the client will stop the pump.
            Client.OnMessage((receivedMessage) =>
            {
                try
                {
                    // Process the message
                    Trace.WriteLine("Processing Service Bus message: " + receivedMessage.SequenceNumber.ToString());

                    //validate the image
                    // Image image = receivedMessage.GetBody<Image>();
                    reference = receivedMessage.GetBody<string>();
                    Trace.WriteLine("Image to be validated is : " + reference);
                    string i = reference.Split('.')[0];
                    int imageId = Convert.ToInt32(i);

                    Image image = db.Images.Find(imageId);

                   // string NAME = image.User.Email;

                    bool isValidated = ValidateImage(image);

                  //  string user = System.Web.HttpContext.Current.User.Identity.Name.Substring(0, System.Web.HttpContext.Current.User.Identity.Name.IndexOf('@'));

                    if (isValidated)
                    {

                        // DBAccess.UpdateImageInDB(image);
                        image.Validated = true;
                        QueueManager.SendImageEntityToQueue(image, DateTime.Now);
                        db.SaveChanges();

                    }
                    else
                    {
                        image.Validated = false;
                        QueueManager.SendImageEntityToQueue(image, DateTime.Now);
                        // DBAccess.DeleteImageFromDB(image);
                        ImageStorage.DeleteImageFromBlob(image.Id);
                    }

                    //Trace.WriteLine(order.Customer + ": " + order.Product, "ProcessingMessage");
                    receivedMessage.Complete();
                }
                catch (Exception ex)
                {

                //    // Handle any message processing specific exceptions here
                }
            });

            CompletedEvent.WaitOne();
        }
        public override void Run()
        {
            Trace.WriteLine("Starting processing of messages");
            WriteLog("in Run()");
            // Initiates the message pump and callback is invoked for each message that is received, calling close on the client will stop the pump.
            Client.OnMessage((receivedMessage) =>
            {
                try
                {
                    // Process the message
                    Trace.WriteLine("Processing Service Bus message: " + receivedMessage.SequenceNumber.ToString());

                    //validate the image
                    Image image      = receivedMessage.GetBody <Image>();
                    bool isValidated = ValidateImage(image);

                    if (isValidated)
                    {
                        image.Valid = true;
                        DatabaseAccess.UpdateImageInDB(image);
                        QueueManager.SendImageEntityToQueue(image);
                        // image.Id =2 ;
                        //db.Images.Add(image);
                        //db.Entry(image).State = System.Data.Entity.EntityState.Added;
                        // db.SaveChanges();
                    }
                    else
                    {
                        DatabaseAccess.DeleteImageFromDB(image);
                        ImageStorage.DeleteImageFromBlob(image.Id);
                    }

                    //Trace.WriteLine(order.Customer + ": " + order.Product, "ProcessingMessage");
                    receivedMessage.Complete();
                }
                catch (Exception ex)
                {
                    // Handle any message processing specific exceptions here
                }
            });

            CompletedEvent.WaitOne();
        }