Exemple #1
0
        protected void slkButtonDelete_Click(object sender, EventArgs e)
        {
            try
            {
                // Delete corresponding assignment folder from the drop box if exists
                if (AssignmentProperties.PackageFormat == null)
                {
                    DropBoxManager dropBoxMgr = new DropBoxManager(AssignmentProperties);
                    dropBoxMgr.DeleteAssignmentFolder();
                }

                SlkStore.DeleteAssignment(AssignmentProperties.Id);
                Response.Redirect(SPWeb.ServerRelativeUrl, true);
            }
            catch (ThreadAbortException)
            {
                // Calling Response.Redirect throws a ThreadAbortException which will
                // flag an error in the next step if we don't do this.
                throw;
            }
            catch (Exception exception)
            {
                errorBanner.AddException(SlkStore, new SafeToDisplayException(PageCulture.Resources.LobbyDeleteException));
                SlkStore.LogException(exception);
            }
        }
        public async Task <IActionResult> AddNews(CreateNewsViewModel model)
        {
            if (ModelState.IsValid)
            {
                string ImageUrl = "";
                if (model.Image != null)
                {
                    DropBoxManager dropBoxManager = new DropBoxManager(_configuration["DropBoxAccessToken"]);
                    ImageUrl = await dropBoxManager.Upload($"{model.CompanyName}/news", model.Image.FileName, model.Image);
                }

                News news = new News
                {
                    Text      = model.Text,
                    CompanyId = model.CompanyId,
                    Heading   = model.Heading,
                    Image     = ImageUrl,
                    Date      = DateTime.Now
                };
                _applicationContext.News.Add(news);
                await _applicationContext.SaveChangesAsync();

                return(RedirectToAction("Index", "Company", new { id = model.CompanyName }));
            }
            return(View(model));
        }
        public override void Initialize()
        {
            // TODO: Add your initialization logic here
            ranks = new RankManager();
            crosshair = new Crosshair(game.Content);
            h1 = new HUD();
            d1 = new DropBoxManager(game.Content);
            b1 = new background();

            cam = new CameraMan(new Vector2(0, 0));
            cam._pos.Y += service.GraphicsDevice.PresentationParameters.BackBufferHeight / 2;
            cam._pos.X += service.GraphicsDevice.PresentationParameters.BackBufferWidth / 2;
        }
Exemple #4
0
        private void FindDocumentUrl()
        {
            DropBoxManager manager = new DropBoxManager(AssignmentProperties);

            AssignmentFile[] files = manager.LastSubmittedFiles(true);
            if (files.Length == 0)
            {
                // Intial copy must have failed.
                CopyDocumentToDropBox();
            }
            else if (files.Length > 0)
            {
                assignmentFile = files[0];
            }
        }
Exemple #5
0
        /// <summary> Generates the url to view the submitted files. </summary>
        private string GenerateUrlForAssignmentReview()
        {
            DropBoxManager manager = new DropBoxManager(AssignmentProperties);

            AssignmentFile[] assignmentFiles = manager.LastSubmittedFiles(true);

            if (assignmentFiles.Length != 1)
            {
                return(string.Format("{0}{1}SubmittedFiles.aspx?LearnerAssignmentId={2}", SPWeb.Url, Constants.SlkUrlPath, LearnerAssignmentGuidId.ToString()));
            }
            else
            {
                return(assignmentFiles[0].Url);
            }
        }
        /// <summary>
        /// Checks the number of the assignment submitted files.
        /// </summary>
        /// <param name="assignmentProperties">The AssignmentProperties</param>
        /// <returns> If one assignment submitted, returns its URL.
        /// If more than one, returns an empty string.</returns>
        private string PerformFilesNumberChecking(AssignmentProperties assignmentProperties)
        {
            DropBoxManager dropBox = new DropBoxManager(assignmentProperties);

            AssignmentFile[] assignmentFiles = dropBox.LastSubmittedFiles(assignmentProperties.Results[0].User.SPUser, false);

            if (assignmentFiles.Length != 1)
            {
                return(string.Empty);
            }
            else
            {
                return(assignmentFiles[0].Url);
            }
        }
Exemple #7
0
        public HttpResponseMessage GetFile(string fileName)
        {
            HttpResponseMessage result = null;
            var task = Task.Run(() => DropBoxManager.Download(fileName));

            task.Wait();

            result = Request.CreateResponse(HttpStatusCode.OK);

            result.Content = new StreamContent(new MemoryStream(task.Result));
            result.Content.Headers.ContentDisposition =
                new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment");
            result.Content.Headers.ContentDisposition.FileName = fileName;

            return(result);
        }
Exemple #8
0
        private void LoadLastAssignmentAttempt()
        {
            DropBoxManager dropBoxManager = new DropBoxManager(AssignmentProperties);

            AssignmentFile[] files = dropBoxManager.LastSubmittedFiles(true);

            if (files.Length > 0)
            {
                LiteralControl literal = new LiteralControl(string.Format("<table><tr><th>{0}</th><th>{1}</th></tr>", PageCulture.Resources.IncludeTitle, PageCulture.Resources.CtrlLabelUploadDocumentName));
                pnlOldFiles.Controls.Add(literal);

                foreach (AssignmentFile file in files)
                {
                    pnlOldFiles.Controls.Add(new LiteralControl("<tr><td>"));

                    CheckBox check = new CheckBox();
                    check.ID      = "check" + file.Id.ToString(CultureInfo.InvariantCulture);
                    check.Checked = false;
                    includes.Add(check);
                    pnlOldFiles.Controls.Add(check);

                    pnlOldFiles.Controls.Add(new LiteralControl("</td><td>"));

                    HyperLink fileLink = new HyperLink();
                    fileLink.Text = file.Name;

                    DropBoxEditMode    editMode    = DropBoxEditMode.Edit;
                    DropBoxEditDetails editDetails = dropBoxManager.GenerateDropBoxEditDetails(file, SPWeb, editMode, Page.Request.RawUrl);
                    fileLink.NavigateUrl = editDetails.Url;
                    if (string.IsNullOrEmpty(editDetails.OnClick) == false)
                    {
                        fileLink.Attributes.Add("onclick", editDetails.OnClick + "return false;");
                    }

                    pnlOldFiles.Controls.Add(fileLink);

                    pnlOldFiles.Controls.Add(new LiteralControl("</td></tr>"));
                }

                pnlOldFiles.Controls.Add(new LiteralControl("</table>"));
            }
        }
Exemple #9
0
        private void SetupFileAction(AssignmentFile file, SlkButton button, bool includeReload)
        {
            DropBoxManager dropBoxMgr = new DropBoxManager(AssignmentProperties);

            DropBoxEditMode editMode = DropBoxEditMode.Edit;

            switch (LearnerAssignmentProperties.Status)
            {
            case LearnerAssignmentState.Completed:
            case LearnerAssignmentState.Final:
                editMode = DropBoxEditMode.View;
                break;
            }

            DropBoxEditDetails editDetails = dropBoxMgr.GenerateDropBoxEditDetails(file, SPWeb, editMode, Page.Request.RawUrl);

            string script = editDetails.OnClick;

            if (string.IsNullOrEmpty(script))
            {
                if (includeReload)
                {
                    script = string.Format(CultureInfo.InvariantCulture, "window.location='{0}&{1}=true';", CurrentUrl, startQueryStringName);
                }
            }
            else
            {
                if (LearnerAssignmentProperties.Status == LearnerAssignmentState.NotStarted && includeReload)
                {
                    script = string.Format(CultureInfo.InvariantCulture, "{0}window.location='{1}&{2}=true';return false;", script, CurrentUrl, startQueryStringName);
                }
                else
                {
                    script = script + "return false;";
                }
            }

            button.OnClientClick = script;
            button.NavigateUrl   = editDetails.Url;
        }
Exemple #10
0
        private void SetUpForFinal()
        {
            slkButtonBegin.Text    = PageCulture.Resources.LobbyReviewAssignmentText;
            slkButtonBegin.ToolTip = PageCulture.Resources.LobbyReviewAssignmentToolTip;

            pageTitle.Text            = PageCulture.Resources.LobbyReviewAssignmentText;
            pageTitleInTitlePage.Text = PageCulture.Resources.LobbyReviewAssignmentText;

            //Check if non-elearning content
            if (AssignmentProperties.RootActivityId == null)
            {
                slkButtonReviewSubmitted.Text     = PageCulture.Resources.LobbyReviewSubmittedText;
                slkButtonReviewSubmitted.ToolTip  = PageCulture.Resources.LobbyReviewSubmittedToolTip;
                slkButtonReviewSubmitted.ImageUrl = Constants.ImagePath + Constants.NewDocumentIcon;
                slkButtonReviewSubmitted.Visible  = true;

                DropBoxManager manager = new DropBoxManager(AssignmentProperties);

                AssignmentFile[] assignmentFiles = manager.LastSubmittedFiles(true);

                if (assignmentFiles.Length != 1)
                {
                    string script = string.Format("openSubmittedFiles('{0}');return false;", LearnerAssignmentGuidId);
                    slkButtonReviewSubmitted.OnClientClick = script;
                    slkButtonBegin.OnClientClick           = script;
                }
                else
                {
                    SetupFileAction(assignmentFiles[0], slkButtonReviewSubmitted, false);
                    SetupFileAction(assignmentFiles[0], slkButtonBegin, false);
                }
            }

            SetUpSubmitButtons(false, false);
            slkButtonSubmit.Visible = false;
            ShowNavigationOptions();
            ShowLearnerComments();
        }
        public async Task <IActionResult> CreateCompany(string id, CreateCompanyViewModel model)
        {
            if (ModelState.IsValid)
            {
                DropBoxManager dropBoxManager = new DropBoxManager(_configuration["DropBoxAccessToken"]);
                string         FotoUrl        = await dropBoxManager.Upload(model.Name, model.Foto.FileName, model.Foto);



                Company user = new Company {
                    UserId   = _userManager.Users.FirstOrDefault(u => u.UserName.Equals(id)).Id,
                    Name     = model.Name, Description = model.Description, Foto = FotoUrl,
                    Deadline = model.Deadline, TargetAmount = model.TargetAmount,
                    Category = model.Category
                };

                _applicationContext.Add(user);
                await _applicationContext.SaveChangesAsync();

                return(RedirectToAction("Companies", "Account", new { id }));
            }
            return(View(model));
        }
        /// <summary>
        /// Builds the content displayed in the page
        /// </summary>
        protected void BuildPageContent()
        {
            dropBox = new DropBoxManager(AssignmentProperties);

            AssignmentFile[] files = dropBox.LastSubmittedFiles(LearnerAssignmentProperties.User.SPUser, true);

            returnUrl = Request.QueryString["source"];
            if (string.IsNullOrEmpty(returnUrl))
            {
                returnUrl = Page.Request.RawUrl; 
            }
            else
            {
                returnUrl = HttpUtility.UrlDecode(returnUrl);
            }

            int counter = 0;
            foreach (AssignmentFile file in files)
            {
                DisplayFileLink(file, counter);
                counter++;
            }
        }
Exemple #13
0
        public IHttpActionResult Post()
        {
            var httpRequest   = HttpContext.Current.Request;
            var file          = httpRequest.Files[0];
            var fileExtension = file.FileName.Split('.').Last();
            var uniqueName    = this.CurrentUserId + Guid.NewGuid() + "." + fileExtension;

            byte[] buffer = null;
            using (var fs = file.InputStream)
            {
                buffer = new byte[fs.Length];
                fs.Read(buffer, 0, (int)fs.Length);
            }

            var task = Task.Run(() => DropBoxManager.Upload(uniqueName, buffer));

            task.Wait();

            var link       = "http://viber.azurewebsites.net/api/File?fileName=" + uniqueName;
            var receiverId = this.CurrentUser.CurrentChatId;
            var receiver   = this.Data.Users.All()
                             .FirstOrDefault(u => u.Id == receiverId);
            var message = new PrivateMessage()
            {
                Text       = link,
                ReceiverId = receiverId,
                SenderId   = this.CurrentUserId,
                IsFileLink = true
            };

            var currentUsers = ConnectionManager.Users.Keys;

            if (currentUsers.Contains(receiver.UserName) && receiver.CurrentChatId == this.CurrentUser.Id)
            {
                message.Status = MessageStatus.Seen;
            }
            else if (currentUsers.Contains(receiver.UserName))
            {
                message.Status = MessageStatus.Sent;
            }
            else
            {
                message.Status = MessageStatus.NotDelivered;
            }

            this.Data.Messages.Add(message);
            this.Data.SaveChanges();

            var messageView =
                new
            {
                message.Id,
                message.Text,
                Sender     = this.CurrentUserUserName,
                Receiver   = receiver.UserName,
                Status     = message.Status.ToString(),
                SenderId   = this.CurrentUserId,
                ReceiverId = receiver.Id,
                MessageId  = message.Id,
                IsFileLink = true
            };

            this.HubContex.Clients.User(receiver.UserName).pushMessageToClient(messageView);
            this.HubContex.Clients.User(this.CurrentUserUserName).pushSelfMessage(messageView);

            return(this.Ok());
        }
Exemple #14
0
        private void CopyDocumentToDropBox()
        {
            DropBoxManager manager = new DropBoxManager(AssignmentProperties);

            assignmentFile = manager.CopyFileToDropBox();
        }