Exemple #1
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     QueueConnector.Initialize();
 }
Exemple #2
0
        //[RequireHttps]
        //[RefererHeader]
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            CheckAda();
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email, ADA = model.ADA
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    QueueConnector.createQueue(parseUserName(user.UserName));

                    QueueManager.SendImageEntityToQueueforuserAccount(parseUserName(user.UserName), DateTime.Now);

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Exemple #3
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            QueueConnector.Initialize();

            //Tip: Want to call the EPiServer API on startup? Add an initialization module instead (Add -> New Item.. -> EPiServer -> Initialization Module)
        }
        public ActionResult Submit()
        {
            var namespaceManager = QueueConnector.CreateNamespaceManager();
            var queue            = namespaceManager.GetQueue(QueueConnector.QueueName);

            ViewBag.MessageCount = queue.MessageCount;
            return(View());
        }
Exemple #5
0
        public override bool OnStart()
        {
            // set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 12;

            _repository    = new Repository();
            _queueClient   = QueueConnector.GetQueueClient();
            _mediaServices = new MediaServices();
            _isStopped     = false;
            return(base.OnStart());
        }
Exemple #6
0
        /// <summary>
        /// GET: /Home/Submit
        /// Controller method for for the submission form view.
        /// </summary>
        /// <returns>Submission Form View</returns>
        public ActionResult Submit()
        {
            // As usual, need to get a namespace manager for
            // management operations.
            var namespaceManager = QueueConnector.CreateNamespaceManager();

            // Get the queue and obtain the message count.
            var queue = namespaceManager.GetQueue(QueueConnector.QueueName);

            ViewBag.MessageCount = queue.MessageCount;
            return(View());
        }
        // GET: /Home/Submit.
        // Controller method for a view you will create for the submission
        // form.
        public ActionResult Submit()
        {
            // Get a NamespaceManager which allows you to perform management and
            // diagnostic operations on your Service Bus queues.
            var namespaceManager = QueueConnector.CreateNamespaceManager();

            // Get the queue, and obtain the message count.
            var queue = namespaceManager.GetQueue(QueueConnector.QueueName);

            ViewBag.MessageCount = queue.MessageCount;

            return(View());
        }
Exemple #8
0
        public ActionResult Submit(OnlineOrder order)
        {
            if (ModelState.IsValid)
            {
                // Will put code for submitting to queue here.
                var message = new BrokeredMessage(order);
                QueueConnector.Initialize();
                QueueConnector.OrdersQueueClient.Send(message);

                return(RedirectToAction("Submit"));
            }
            else
            {
                return(View(order));
            }
        }
Exemple #9
0
        public void SaveVideo(Video video)
        {
            // upload the file
            var newFileName = BlobStorage.UploadBlob(VIDEOS_CONTAINER, video.FileName, video.FileData);

            // update the file name if it's been changed
            if (video.FileName != newFileName)
            {
                video.FileName = newFileName;
            }

            // save the video to the database
            _repository.InsertOrUpdateVideo(video);

            // send the message to the video processor
            QueueConnector.SendMessage(video.VideoID);
        }
        public static async Task Main(string[] args)
        {
            queueClient = new QueueConnector(QueueName, ServiceBusConnectionStringName);

            const int numberOfMessages = 2;

            Console.WriteLine("======================================================");
            Console.WriteLine("Press ENTER key to exit after sending all the messages.");
            Console.WriteLine("======================================================");

            // Send messages.
            await SendMessagesAsync(numberOfMessages);
            await SendLargeMessagesAsync(numberOfMessages);
            await SendVeryLargeMessagesAsync(numberOfMessages);

            Console.ReadKey();

            await queueClient.CloseAsync();
        }
Exemple #11
0
        public ActionResult Index()
        {
            try
            {
                // Get a NamespaceManager which allows you to perform management and
                // diagnostic operations on your Service Bus queues.
                var namespaceManager = QueueConnector.CreateNamespaceManager();

                // Get the queue, and obtain the message count.
                var queue = namespaceManager.GetQueue(QueueConnector.QueueName);
                ViewBag.MessageCount = queue.MessageCount;
            }
            catch (Exception e)
            {
                ViewBag.Result       = "Error: " + e.Message;
                ViewBag.MessageCount = 0;
            }
            return(View());
        }
        public ActionResult Receive()
        {
            var namespaceManager = QueueConnector.CreateNamespaceManager();
            var queue            = namespaceManager.GetQueue(QueueConnector.QueueName);

            OnlineOrder        order  = null;
            List <OnlineOrder> orders = new List <OnlineOrder>();

            if (queue.MessageCount != 0)
            {
                BrokeredMessage message = QueueConnector.OrdersQueueClient.Receive();
                order = message.GetBody <OnlineOrder>();
                Debug.WriteLine("Message body: {0}  {1}", order.Customer, order.Product);
                Debug.WriteLine("Message id: {0}", message.MessageId);
                message.Complete();

                return(View(order));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
Exemple #13
0
        protected void Seed(ApplicationDbContext db)
        {
            RoleStore <IdentityRole>    roleStore = new RoleStore <IdentityRole>(db);
            UserStore <ApplicationUser> userStore = new UserStore <ApplicationUser>(db);

            RoleManager <IdentityRole>    rm = new RoleManager <IdentityRole>(roleStore);
            UserManager <ApplicationUser> um = new UserManager <ApplicationUser>(userStore);

            IdentityResult ir;

            ApplicationUser nobody = createUser("*****@*****.**");
            ApplicationUser jfk    = createUser("*****@*****.**");
            ApplicationUser nixon  = createUser("*****@*****.**");
            ApplicationUser fdr    = createUser("*****@*****.**");

            ir = um.Create(nobody, "nobody1234");

            ir = um.Create(jfk, "jfk1234");

            ir = um.Create(nixon, "nixon1234");

            ir = um.Create(fdr, "fdr1234");


            rm.Create(new IdentityRole("User"));
            rm.Create(new IdentityRole("Supervisor"));

            if (!um.IsInRole(nobody.Id, "User"))
            {
                um.AddToRole(nobody.Id, "User");
            }
            if (!um.IsInRole(jfk.Id, "User"))
            {
                um.AddToRole(jfk.Id, "User");
            }
            if (!um.IsInRole(nixon.Id, "User"))
            {
                um.AddToRole(nixon.Id, "User");
            }

            if (!um.IsInRole(fdr.Id, "User"))
            {
                um.AddToRole(fdr.Id, "User");
            }

            rm.Create(new IdentityRole("Admin"));
            if (!um.IsInRole(nixon.Id, "Admin"))
            {
                um.AddToRole(nixon.Id, "Admin");
            }

            rm.Create(new IdentityRole("Approver"));
            if (!um.IsInRole(jfk.Id, "Approver"))
            {
                um.AddToRole(jfk.Id, "Approver");
            }

            rm.Create(new IdentityRole("Supervisor"));
            if (!um.IsInRole(fdr.Id, "Supervisor"))
            {
                um.AddToRole(fdr.Id, "Supervisor");
            }

            db.Tags.Add(new Tag {
                Name = "portrait"
            });
            db.Tags.Add(new Tag {
                Name = "architecture"
            });


            db.SaveChanges();



            db.Images.Add(new Image
            {
                Caption     = "jelly fish",
                Description = "lives in sea and ocean",
                DateTaken   = new DateTime(1946, 12, 14),
                //  UserId = jfk.Id,
                UserId    = jfk.Id,
                TagId     = 1,
                Validated = true,
                Approved  = true
            });
            LogContext.CreateTable();
            db.SaveChanges();

            QueueConnector.createQueue(parseUserName(jfk.UserName));
            QueueConnector.createQueue(parseUserName(nobody.UserName));
            QueueConnector.createQueue(parseUserName(nixon.UserName));
            QueueConnector.createQueue(parseUserName(fdr.UserName));

            //base.Seed(db);



            //     base.Seed(db);
        }
Exemple #14
0
        public ActionResult Upload(ImageView image,
                                   HttpPostedFileBase ImageFile)
        {
            CheckAda();

            TryUpdateModel(image);


            if (ModelState.IsValid)
            {
                // HttpCookie cookie = Request.Cookies.Get("ImageSharing");
                ApplicationUser userid = GetLoggedInUser();

                if (userid != null)
                {
                    ApplicationUser user = db.Users.SingleOrDefault(u => u.Id.Equals(userid.Id));
                    if (user != null)
                    {
                        //save image information in the database.

                        Image imageEntity = new Image();
                        imageEntity.Caption     = image.Caption;
                        imageEntity.Description = image.Description;
                        imageEntity.DateTaken   = image.DateTaken;
                        imageEntity.UserId      = user.UserName;
                        imageEntity.Approved    = false;
                        imageEntity.Valid       = false;
                        imageEntity.TagId       = image.TagId;
                        if (ImageFile != null && ImageFile.ContentLength > 0 && ImageFile.ContentType.Equals("image/jpeg"))
                        {
                            db.Images.Add(imageEntity);
                            db.SaveChanges();

                            ImageStorage.SaveFile(Server, ImageFile, imageEntity.Id);
                            QueueConnector.SendToQueue(imageEntity);

                            // image.Id = imageEntity.Id;
                            //return View("Details", image);
                            return(RedirectToAction("Details", new { Id = imageEntity.Id }));
                        }
                        else
                        {
                            ViewBag.Message = "No image file specified!";
                            return(View());
                        }
                    }
                    else
                    {
                        ViewBag.Message = "No such userid registered!";
                        return(View());
                    }
                }
                else
                {
                    ViewBag.Message = "No such userid registered!";
                    return(View());
                }
            }
            else
            {
                ViewBag.Message = "Please correct the errors in the form!";
                return(View());
            }
        }
        //  [RequireHttps]
        public ActionResult Upload(ImageView image, HttpPostedFileBase ImageFile)
        {
            CheckAda();
            TryUpdateModel(image);

            if (ModelState.IsValid)
            {
                ApplicationUser user = GetLoggedInUser();

                if (user != null)
                {
                    /*
                     * Save image information in the database.
                     */

                    Image imageEntity = new Image();
                    imageEntity.Caption     = image.Caption;
                    imageEntity.Description = image.Description;
                    imageEntity.DateTaken   = image.DateTaken;
                    imageEntity.User        = user;
                    imageEntity.TagId       = image.TagId;
                    imageEntity.Validated   = false;
                    imageEntity.Approved    = false;

                    // currentuser = imageEntity.User.Email.Split('@')[0];

                    if (ImageFile != null && ImageFile.ContentLength > 0)
                    {
                        //if (ImageFile.ContentLength < 3000000)
                        //{
                        String imgPath = ImageFile.ContentType.ToString();

                        //if (imgPath == "image/JPEG" || imgPath == "image/JPG" || imgPath == "image/jpeg" || imgPath == "image/jpg")
                        //{

                        this.ApplicationDbContext.Images.Add(imageEntity);
                        this.ApplicationDbContext.SaveChanges();


                        ImageStorage.SaveFile(Server, ImageFile, imageEntity.Id);
                        QueueConnector.SendToQueue(imageEntity.UserId, imageEntity.Id);


                        return(RedirectToAction("Details", new { Id = imageEntity.Id }));
                        //  }
                        //else
                        //{
                        //    ViewBag.Message = "Please enter only JPEG image file !";
                        //    SelectList tags = new SelectList(db.Tags, "Id", "Name", 1);
                        //    return View(tags);
                        //}
                        //}


                        //else
                        //{
                        //    ViewBag.Message = "Please enter the image with the content size less than 3 MB !";
                        //    SelectList tags = new SelectList(db.Tags, "Id", "Name", 1);
                        //    return View(tags);

                        //}
                    }

                    else
                    {
                        ViewBag.Message = "No image file specified ! ";
                        SelectList tags = new SelectList(db.Tags, "Id", "Name", 1);
                        return(View(tags));
                    }
                }

                else
                {
                    ViewBag.Message = "No such uerid registered !";
                    SelectList tags = new SelectList(db.Tags, "Id", "Name", 1);
                    return(View(tags));
                }
            }
            else
            {
                ViewBag.Message = "Please correct the errors in the form ! ";
                SelectList tags = new SelectList(db.Tags, "Id", "Name", 1);
                return(View(tags));
            }
        }
Exemple #16
0
 public static void Initialize(TestContext context)
 {
     queueClient = new QueueConnector(QueueName, ServiceBusConnectionStringName);
 }
Exemple #17
0
 public HomeController()
 {
     QueueConnector.Initialize();
 }