Пример #1
0
 public bool Contains(LdapQueueItem ldapQueueItem)
 {
     return ldapQueue.Contains(ldapQueueItem);
 }
        public ActionResult Images(string id)
        {
            if (id != null)
            {
                string contentType = "image/jpeg";
                byte[] image;
                string imageHardDisk = HttpContext.Server.MapPath(@"~/Content/LDAP/" + id + ".jpg");
                if (!System.IO.File.Exists(imageHardDisk))
                {
                    QueueManager queueManager = QueueManager.GetInstance();

                    LdapQueueItem ldapQueueItem = new LdapQueueItem();
                    ldapQueueItem.id = new Guid().ToString();
                    ldapQueueItem.name = id;

                    queueManager.AddImageRequest(ldapQueueItem);

                    while (queueManager.Contains(ldapQueueItem))
                    {
                        queueManager.ProcessImage(HttpContext);
                    }

                    // finished dequeueing guy at this point
                    image = System.IO.File.ReadAllBytes(imageHardDisk);
                    return this.File(image, contentType);
                }
                else
                {
                    image = System.IO.File.ReadAllBytes(imageHardDisk);
                }

                return this.File(image, contentType);
            }
            return null;
        }
Пример #3
0
 public void AddImageRequest(LdapQueueItem ldapQueueItem)
 {
     Debug.WriteLine(ldapQueue.Count);
     ldapQueue.Enqueue(ldapQueueItem);
     Debug.WriteLine(ldapQueue.Count);
 }