public JsonResult SetThreadCount(int Count)
        {
            //todo
            // set threadcount
            var uuid = Request["uuid"];

            if (!string.IsNullOrEmpty(uuid))
            {
                CollectionOfWorkers.GetWorker(uuid).MaxImagesCountinOneThread = Count;
            }
            else
            {
                throw new Exception("uuid is not passed");
            }
            return(Json(Count));
        }
        public JsonResult AddSetting(ResizeSettingsModel model)
        {
            var uuid = Request["uuid"];

            if (!string.IsNullOrEmpty(uuid))
            {
                CollectionOfWorkers.GetWorker(uuid).Settings.Add(
                    new ResizeSettingsModel()
                {
                    Name = model.Name, Height = model.Height, Width = model.Width
                }
                    );
            }
            else
            {
                throw new Exception("uuid is not passed");
            }
            return(Json(model));
        }
        public async Task <JsonResult> Upload()
        {
            var uuid = Request["uuid"];
            ImagesAndSettingsForResizing worker;

            if (!string.IsNullOrEmpty(uuid))
            {
                worker = CollectionOfWorkers.GetWorker(uuid);
            }
            else
            {
                throw new Exception("uuid is not passed");
            }
            List <string> ImagesForWorker = new List <string>();;
            List <Image>  userImages      = GetImagesFromRequest(ref ImagesForWorker);

            worker.ImagesForWorker = ImagesForWorker;

            MessageQueue todoQueue = InitializeMQ(ConfigurationManager.AppSettings["todoQueue"], new XmlMessageFormatter(
                                                      new Type[] { typeof(ImagesAndSettingsForResizing), typeof(ResizeSettingsModel) }));
            MessageQueue doneQueue = InitializeMQ(ConfigurationManager.AppSettings["doneQueue"], new XmlMessageFormatter(
                                                      new Type[] { typeof(List <ResizedImageInfo>) }));

            using (todoQueue)
            {
                todoQueue.Send(worker);
            }
            List <ResizedImageInfo> ResizedImagesList = null;

            using (doneQueue)
            {
                do
                {
                    Message message = doneQueue.Receive();

                    ResizedImagesList = message.Body as List <ResizedImageInfo>;
                }while (ResizedImagesList == null);
            }
            HandledResizedImages(ResizedImagesList, userImages);

            return(Json(userImages));
        }