public async Task <IActionResult> Edit(int id, [Bind("SubmitID,TaskID,SubmitName,SubmitDescription,SubmitTime,SubmitScore")] SubmitModel submitModel)
        {
            if (id != submitModel.SubmitID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(submitModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SubmitModelExists(submitModel.SubmitID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("SubmitList", new { TaskID = submitModel.TaskID }));
            }
            return(View(submitModel));
        }
Esempio n. 2
0
        public ActionResult Save(SubmitModel model)
        {
            SessionHelper.Temp  = model.DistrictId;
            SessionHelper.Temp2 = model.UpazillaId;
            SessionHelper.Temp3 = model.CollectedBy;
            SessionHelper.Temp4 = model.SourceId;


            DetailData entity = new DetailData();

            ModelCopier.CopyModel(model, entity);

            entity.InsertedById = SessionHelper.UserId;

            if (model.Id == 0)
            {
                sunDataService.Add(entity);
            }
            else
            {
                sunDataService.Update(entity);
            }

            unitOfWork.Commit();

            return(PartialView());

            //return PartialView("Create",GetModel(model.CollectedBy));
        }
Esempio n. 3
0
        public ActionResult CrearUsuario(SubmitModel Usuario)
        {
            try
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(hostSettings.DireccionHost);
                    //HTTP POSt
                    var JSON         = JsonConvert.SerializeObject(Usuario);
                    var Content      = new StringContent(JSON, Encoding.UTF8, "application/json");
                    var responseTask = client.PostAsync("api/Usuario/", Content);
                    var result       = responseTask.Result;
                    if (result.IsSuccessStatusCode)
                    {
                        var readTask = result.Content.ReadAsStringAsync();
                        readTask.Wait();
                        var model          = JsonConvert.DeserializeObject <SubmitModel>(readTask.Result);
                        var resultAutorize = client.GetAsync("api/LogIn/Autorizado");
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, "Server error. Please contact administrator.");
                    }
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View("Index"));
            }
        }
        public async Task <IActionResult> SubmitAsync([FromBody] SubmitModel input)
        {
            int max;

            try { max = await _context.Challenges.MaxAsync(x => x.Priority); }
            catch { max = 0; }

            var challenge = new Challenge()
            {
                Title       = input.Title.Trim(),
                Category    = input.Category.Trim(),
                Description = input.Description.Trim(),
                Attachments = input.Attachments.Trim(),
                Flag        = input.Flag.Trim(),
                Author      = input.Author.Trim(),
                Points      = input.Points,
                Writeup     = input.Writeup?.Trim(),
                State       = 0,
                Priority    = max + 1
            };
            await _context.Challenges.AddAsync(challenge);

            await _context.SaveChangesAsync();

            return(Json(new { success = true }));
        }
        public void Submit()
        {
            SubmitModel.Insert(InsertText, EndDate);

            //呼び出し元VMでリロード実行
            ParentViewModel.Reload();
        }
Esempio n. 6
0
        public ActionResult Post(SubmitModel submitModel)
        {
            HomeData = new List <HomeData>();
            HomeData.Add(new Models.HomeData()
            {
                DataId = 6, DataDetail = "Demo6"
            });
            HomeData.Add(new Models.HomeData()
            {
                DataId = 7, DataDetail = "Demo7"
            });
            HomeData.Add(new Models.HomeData()
            {
                DataId = 8, DataDetail = "Demo8"
            });
            HomeData.Add(new Models.HomeData()
            {
                DataId = 9, DataDetail = "Demo9"
            });
            HomeData.Add(new Models.HomeData()
            {
                DataId = 10, DataDetail = "Demo10"
            });

            ViewBag.GeneralData = "After Post Call Index Data";
            ViewBag.SubmitId    = submitModel.Id;
            ViewBag.SubmitData  = submitModel.Filter;
            return(View("Index", HomeData));
        }
        public ActionResult Login(BancaDeSange.Models.Utilizatori util)
        {
            using (SubmitModel sb = new SubmitModel())
            {
                var detaliiUtilizator = sb.Utilizatoris.Where(x => x.NumeUtilizator == util.NumeUtilizator && x.Parola == util.Parola && x.TipDeUtilizator == util.TipDeUtilizator).Count();
                if (detaliiUtilizator == 1)
                {
                    if (util.TipDeUtilizator == "Cere")
                    {
                        Session["UserID"] = Guid.NewGuid();

                        return(View("Logare1"));
                    }
                    else if (util.TipDeUtilizator == "Doneaza")
                    {
                        Session["UserID"] = Guid.NewGuid();
                        return(View("Login2"));
                    }

                    //else { return }
                }

                else
                {
                    ModelState.AddModelError("", "Revizuiti numele de utilizator, parola, sau tipul de utilizator ales");
                }

                return(View());
            }
        }
Esempio n. 8
0
        SubmitModel GetModel()
        {
            int d = 0;

            int.TryParse("" + SessionHelper.Temp, out d);

            int u = 0;

            int.TryParse("" + SessionHelper.Temp2, out u);

            SubmitModel up = new SubmitModel();

            up.Districts = standingDataService.GetDistricts().Where(r => r.IsActive).ToSelectList(d, "Id", "Name");

            int i = (d == 0 ? int.Parse(up.Districts.FirstOrDefault().Value) : d);

            up.Upazillas = standingDataService.GetUpazilla(i).Where(r => r.IsActive).ToSelectList(u, "Id", "Name");

            up.Genders = standingDataService.GetGender().Where(r => r.IsActive).ToSelectList(null, "Id", "Name");

            up.DistrictId  = d;
            up.UpazillaId  = u;
            up.Date        = DateTime.Now;
            up.CollectedBy = "" + SessionHelper.Temp3;



            return(up);
        }
Esempio n. 9
0
        public ActionResult SaveMulti(SubmitModel model)
        {
            SessionHelper.Temp  = model.DistrictId;
            SessionHelper.Temp2 = model.UpazillaId;

            foreach (var v in model.MultiDatas)
            {
                if (v.Count > 0)
                {
                    SummerizedData entity = new SummerizedData();

                    ModelCopier.CopyModel(model, entity);

                    entity.InsertedById = SessionHelper.UserId;
                    entity.SourceId     = v.Id;
                    entity.ReachCount   = v.Count;
                    entity.CollectedBy  = v.CollectedBy;

                    if (entity.Id > 0)
                    {
                        sunDataService.Update(entity);
                    }
                    else
                    {
                        sunDataService.Add(entity);
                    }
                }
            }

            unitOfWork.Commit();

            return(PartialView("Save"));
        }
Esempio n. 10
0
        public ActionResult CreateMulti()
        {
            SubmitModel up = new SubmitModel();

            //up.Sources = standingDataService.GetSource().Where(r => r.IsActive).ToSelectList(null, "Id", "Name");
            up.Districts = standingDataService.GetDistricts().Where(r => r.IsActive).ToSelectList(null, "Id", "Name");

            int i = int.Parse(up.Districts.FirstOrDefault().Value);

            up.Upazillas = standingDataService.GetUpazilla(i).Where(r => r.IsActive).ToSelectList(null, "Id", "Name");

            up.Date = DateTime.Now;

            var s = standingDataService.GetSource().ToList();

            up.MultiDatas = new List <MultiData>();

            foreach (var r in s)
            {
                up.MultiDatas.Add(new MultiData {
                    Id = r.Id, Count = 0, Src = r.Name
                });
            }

            return(PartialView(up));
        }
Esempio n. 11
0
        public ActionResult SubmitProject(SubmitModel submitModel, int projectId, int userId)
        {
            if (!ModelState.IsValid)
            {
                return(View(submitModel));
            }

            byte[] uploadedFile = new byte[submitModel.File.InputStream.Length];
            string fileName     = submitModel.File.FileName.ToString();
            var    index        = fileName.LastIndexOf(".");
            string extension    = fileName.Substring(index + 1, fileName.Length - index - 1);

            submitModel.File.InputStream.Read(uploadedFile, 0, uploadedFile.Length);

            Student.Models.ApplicationDbContext dbContext = Student.Models.ApplicationDbContext.Create();

            var file = dbContext.UsersProjects.SingleOrDefault(up => up.ProjectID == projectId && up.UserID == userId);

            file.File          = uploadedFile;
            file.FileName      = submitModel.File.FileName.ToString();
            file.FileExtension = extension;

            dbContext.SaveChanges();

            dbContext.Dispose();
            return(RedirectToAction("ViewProject", "Project", new { ID = projectId }));
        }
Esempio n. 12
0
        public ActionResult Submit([FromBody] SubmitModel model)
        {
            var token = _context.Tokens.SingleOrDefault(t => t.Token == model.Token);

            if (token == null)
            {
                return(BadRequest());
            }

            GivenAnswer answer = _context.GivenAnswers.SingleOrDefault(ga => ga.Owner.Id == token.Id && ga.Question.Id == model.Id);

            if (answer != null)
            {
                return(BadRequest());                // already answered
            }
            Question question = _context.Questions.Single(q => q.Id == model.Id);

            int[] answersIds = _context.QuestionOptions.Where(qo => qo.Question.Id == question.Id).Select(qo => qo.Id).ToArray();

            answer = new GivenAnswer()
            {
                Question = question,
                Owner    = token,
                SelectedQuestionOptions = model.Answers.Where(a => a.IsSelected && answersIds.Contains(a.Id))
                                          .Select(a => new GivenAnswerToQuestionOption()
                {
                    QuestionOptionId = a.Id
                }).ToList()
            };

            _context.GivenAnswers.Add(answer);
            _context.SaveChanges();

            return(Ok());
        }
Esempio n. 13
0
        public async Task <ResultModel> Rejudge([FromBody] SubmitModel submit)
        {
            var(user, privilege) = await GetUserPrivilegeAsync();

            var ret = new ResultModel {
                IsSucceeded = true
            };

            if (user == null)
            {
                ret.IsSucceeded  = false;
                ret.ErrorMessage = "没有登录";
            }
            else
            {
                using (var db = new ApplicationDbContext(_dbContextOptions))
                {
                    var judge = await db.Judge.FindAsync(submit.Jid);

                    if (judge == null)
                    {
                        ret.IsSucceeded  = false;
                        ret.ErrorMessage = "找不到该提交";
                    }
                    else
                    {
                        if (judge.ResultType <= 0)
                        {
                            ret.IsSucceeded  = false;
                            ret.ErrorMessage = "请等待上一次评测完成";
                        }
                    }
                    if (ret.IsSucceeded)
                    {
                        judge.ResultType = -1;
                        judge.Logs       = null;
                        judge.Result     = null;
                        judge.FullScore  = 0;
                        await db.SaveChangesAsync();

                        JudgeQueue.JudgeIdQueue.Enqueue(judge.Id);
                        try
                        {
                            if (JudgeQueue.QueueSemaphore.CurrentCount < JudgeQueue.JudgeThreadCount)
                            {
                                JudgeQueue.QueueSemaphore.Release();
                            }
                        }
                        catch
                        {
                            //ignored
                        }
                    }
                }
            }
            return(ret);
        }
Esempio n. 14
0
        public dynamic Submit(SubmitModel model)
        {
            var query = _clientFactory.GetCustomersQueryServiceClient();

            var order = query.GetOrderById(model.OrderId);
            if (order == null)
                throw new InvalidOperationException("Order not found");

            var customer = query.GetCustomer(order.CustomerId);
            if (customer == null) throw new InvalidOperationException("Customer not found");

            var response = _checkoutService.PostOrderData(_consultantContext.Consultant, customer, order);

            switch (response.Status)
            {
                case CDSStatusCode.Success:
                    if (response.IsPaymentApproved)
                    {
                        // payment was already approved so tell the client to just redirect to the cds complete
                        // url which will ensure the order is updated
                        var baseUrl = new Uri(_appSettings.GetValue("CDS.BaseReturnUrl"));
                        var returnUrl = new Uri(baseUrl, VirtualPathUtility.ToAbsolute(string.Format("~/cds/complete/{0}", model.OrderId)));
                        return new
                        {
                            response.Status,
                            response.IsPaymentApproved,
                            response.Exception,
                            redirectUrl = returnUrl
                        };
                    }
                    else
                    {
                        // payment has not yet been completed for this order
                        // so tell the client to redirect to Express Checkout
                        return new
                        {
                            response.Status,
                            response.IsPaymentApproved,
                            redirectUrl = GetExpressCheckoutUrl(model.OrderId)
                        };
                    }

                case CDSStatusCode.Error:
                    return new
                    {
                        response.OrderId,
                        response.Status,
                        response.IsPaymentApproved,
                        response.Details,
                        response.Exception
                    };

                // should never hit this case since the json parse will fail if the status code doesnt match the enum values
                default:
                    return ApiHelpers.ServerError("Unknown express checkout code.");
            }
        }
        public async Task <IActionResult> Create([Bind("SubmitID,TaskID,SubmitName,SubmitDescription,SubmitTime,SubmitScore")] SubmitModel submitModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(submitModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(submitModel));
        }
Esempio n. 16
0
        public async Task <IActionResult> Submit(SubmitModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await _userManager.GetUserAsync(User);

                var problem = await _context.Problems.FirstOrDefaultAsync(x => x.Id == model.Id);

                var track = new Track
                {
                    AuthorId    = user.Id,
                    CreateTime  = DateTime.UtcNow,
                    ProblemId   = model.Id,
                    CodeEncoded = Base64Encode(model.Code),
                    Status      = JudgeStatus.Pending,
                    Language    = model.Language
                };

                if (problem != null)
                {
                    List <Point> points = new List <Point>();

                    var problemDirectory = Path.Combine(Directory.GetCurrentDirectory(), "JudgeDataStorage", problem.Id.ToString(), "data");
                    var subDirectories   = Directory.EnumerateDirectories(problemDirectory);
                    for (int i = 0; i < subDirectories.Count(); i++)
                    {
                        points.Add(new Point
                        {
                            Id     = i,
                            Status = PointStatus.Pending
                        });
                    }

                    var passRate = problem.GetPassRate();
                    passRate.Submit += 1;
                    problem.SetPassRate(passRate);
                    track.SetPointStatus(points);
                    _context.Problems.Update(problem);

                    _context.Tracks.Add(track);
                    await _context.SaveChangesAsync();

                    var trackNew = await _context.Tracks.FirstOrDefaultAsync(t => t.CreateTime == track.CreateTime);

                    // _logger.Log(LogLevel.Information, $"[{DateTime.UtcNow}] User (Id: {user.Id}) started a new track for problem #{problem.Id}", track);

                    return(RedirectToAction(nameof(Status), new { trackNew.Id }));
                }
            }

            return(View(model));
        }
Esempio n. 17
0
        public ActionResult Create()
        {
            SubmitModel up = new SubmitModel();

            up.Sources   = standingDataService.GetSource().Where(r => r.IsActive).ToSelectList(null, "Id", "Name");
            up.Districts = standingDataService.GetDistricts().Where(r => r.IsActive).ToSelectList(null, "Id", "Name");

            int i = int.Parse(up.Districts.FirstOrDefault().Value);

            up.Upazillas = standingDataService.GetUpazilla(i).Where(r => r.IsActive).ToSelectList(null, "Id", "Name");

            up.Date = DateTime.Now;

            return(PartialView(up));
        }
Esempio n. 18
0
        // POST: api/Submit
        public HttpResponseMessage Post([FromBody] SubmitModel data)
        {
            var submit = Mapper.SubmitAPItoDomain(data);
            var ret    = dh.Submit(submit);

            //var j = new JavaScriptSerializer();
            //string str = j.Serialize(ret);
            return(Request.CreateResponse(HttpStatusCode.OK, ret));

            /*
             * When your users submit the form where you integrated reCAPTCHA, you'll get as part of the payload a string with the name "g-recaptcha-response". In order to check whether Google has verified that user, send a POST request with these parameters:
             * URL: https://www.google.com/recaptcha/api/siteverify
             * secret(required)   6LeZWiQTAAAAAJntykMv - PCeiBIk7NH8dvDARa5i
             * response(required) The value of 'g-recaptcha-response'.*/
        }
Esempio n. 19
0
        public ActionResult Upload([FromBody] SubmitModel model)
        {
            try
            {
                string path = Server.MapPath("../App_Data//Uploads//") + model.file.FileName;
                if (!System.IO.File.Exists(path))
                {
                    model.file.SaveAs(path);
                }

                return(new HttpStatusCodeResult(200));
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(400));
            }
        }
        public ActionResult Adauga(Utilizatori util)
        {
            using (SubmitModel sb = new SubmitModel()) {
                sb.Utilizatoris.Add(util);

                // var x = sb.Utilizatoris.Where(x => x.Id == 1);
                //  if(x.Count()>1)
                // foreach (var x1 in x)
                {
                    //x1.Parola = 65;
                }
                sb.SaveChanges();
            }

            ModelState.Clear();
            ViewBag.SuccesMessage = "V-ati inregistrat cu succes";
            return(View("Adauga", new Utilizatori()));
        }
Esempio n. 21
0
        SubmitModel GetModel()
        {
            int d = 0;

            int.TryParse("" + SessionHelper.Temp, out d);

            int u = 0;

            int.TryParse("" + SessionHelper.Temp2, out u);

            int s = 0;

            int.TryParse("" + SessionHelper.Temp4, out s);

            SubmitModel up = new SubmitModel();

            up.Sources   = standingDataService.GetSource().Where(r => r.IsActive).ToSelectList(null, "Id", "Name");
            up.Districts = standingDataService.GetDistricts().Where(r => r.IsActive).ToSelectList(d, "Id", "Name");

            int i = (d == 0 ? int.Parse(up.Districts.FirstOrDefault().Value) : d);

            up.Upazillas = standingDataService.GetUpazilla(i).Where(r => r.IsActive).ToSelectList(u, "Id", "Name");

            up.Genders = standingDataService.GetGender().Where(r => r.IsActive).ToSelectList(null, "Id", "Name");

            up.DistrictId  = d;
            up.UpazillaId  = u;
            up.SourceId    = s;
            up.Date        = DateTime.Now;
            up.CollectedBy = "" + SessionHelper.Temp3;


            up.Name        = "";
            up.Phone       = "";
            up.Age         = null;
            up.Description = "";
            up.IsBreadth   = false;
            up.IsContact   = false;
            up.IsDryCough  = false;
            up.IsFever     = false;


            return(up);
        }
 public async Task SubmitList(SubmitModel submitModel)
 {
     try
     {
         if (Connectivity.NetworkAccess == NetworkAccess.Internet)
         {
             await _client.InvokeApiAsync <SubmitModel, object>(
                 "SmartConnect/PostKeyList",
                 submitModel,
                 HttpMethod.Post,
                 null
                 ).ConfigureAwait(false);
         }
     }
     catch (System.Exception ex)
     {
         ex.Report();
     }
 }
        public async Task <IActionResult> Submit(SubmitModel submitModel)
        {
            // A unique scan ID for the scan
            // In case this scan ID already exists for this user Copyleaks API will return HTTP 409 Conflict result
            string scanId   = Guid.NewGuid().ToString();
            var    response = new SubmitResponse()
            {
                ScanId = scanId,
                Token  = submitModel.Token
            };

            try
            {
                using (var api = new CopyleaksScansApi())
                {
                    // Submit a file for scan in https://api.copyleaks.com
                    await api.SubmitFileAsync(scanId, new FileDocument
                    {
                        // The text to scan in base64 format
                        Base64 = TextToBase64(submitModel.Text),
                        // The file name is it will appear in the scan result
                        Filename          = "text.txt",
                        PropertiesSection = GetScanProperties(scanId, submitModel)
                    },
                                              submitModel.Token).ConfigureAwait(false);
                }
                var checkResult = new CheckResultsResponse
                {
                    ScanId = scanId
                };
                return(View("CheckResult", checkResult));
            }
            catch (CopyleaksHttpException cfe)
            {
                response.ErrorMessage = cfe.Message;
            }
            catch (Exception ex)
            {
                response.ErrorMessage = ex.Message;
            }
            return(View(response));
        }
Esempio n. 24
0
 // GET: LogIn/Create
 public ActionResult Create(LogInViewModel serialize)
 {
     if (ModelState.IsValid)
     {
         SubmitModel model = new SubmitModel();
         using (var client = new HttpClient())
         {
             client.BaseAddress = new Uri(hostSettings.DireccionHost);
             //HTTP GET
             var JSON         = JsonConvert.SerializeObject(serialize);
             var Content      = new StringContent(JSON, Encoding.UTF8, "application/json");
             var responseTask = client.PostAsync("api/LogIn/Authenticate", Content);
             var result       = responseTask.Result;
             if (result.IsSuccessStatusCode)
             {
                 var readTask = result.Content.ReadAsStringAsync();
                 readTask.Wait();
                 model = JsonConvert.DeserializeObject <SubmitModel>(readTask.Result);
                 client.DefaultRequestHeaders.Authorization
                     = new AuthenticationHeaderValue("Bearer", model.Token);
                 //CurrentUser = model;
                 HttpContext.Session.SetString("User", readTask.Result);
                 var resultAutorize = client.GetAsync("api/LogIn/Autorizado");
                 Token = model.Token;
                 var result2 = resultAutorize.Result;
                 if (result2.IsSuccessStatusCode)
                 {
                     ModelState.Clear();
                     return(View());
                 }
             }
             else
             {
                 ModelState.AddModelError(string.Empty, "No se pudo autenticar");
                 return(View("Index"));
             }
         }
     }
     ModelState.AddModelError(string.Empty, "No se ingreso el Usuario y Contraseña correctamente");
     return(View("Index"));
 }
Esempio n. 25
0
        public ActionResult Edit(int Id)
        {
            try
            {
                var entity = sunDataService.Get(Id);

                SubmitModel up = new SubmitModel();

                up.Districts = standingDataService.GetDistricts().Where(r => r.IsActive).ToSelectList(up.DistrictId, "Id", "Name");
                up.Upazillas = standingDataService.GetUpazilla(entity.DistrictId).Where(r => r.IsActive).ToSelectList(up.UpazillaId, "Id", "Name");
                up.Genders   = standingDataService.GetGender().Where(r => r.IsActive).ToSelectList(up.GenderId, "Id", "Name");

                ModelCopier.CopyModel(entity, up);

                return(PartialView("Create", up));
            }
            catch
            {
                return(RedirectToAction("Error", "Main"));
            }
        }
Esempio n. 26
0
        public ActionResult Index(SubmitModel submitModel)
        {
            HomeData = new List <HomeData>();
            HomeData.Add(new Models.HomeData()
            {
                DataId = 11, DataDetail = "Demo11"
            });
            HomeData.Add(new Models.HomeData()
            {
                DataId = 12, DataDetail = "Demo12"
            });
            HomeData.Add(new Models.HomeData()
            {
                DataId = 13, DataDetail = "Demo13"
            });

            ViewBag.SubmitId    = submitModel.Id;
            ViewBag.SubmitData  = submitModel.Filter;
            ViewBag.GeneralData = "After Another Post Call Index Data";
            return(View("Index", HomeData));
        }
        public async Task <IActionResult> Submit(SubmitModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new ResultModel
                {
                    Success = false,
                    Errors = ModelState.Values.SelectMany(m => m.Errors).Select(m => m.ErrorMessage)
                }));;
            }

            if (!_searchEngine.IsValidSearchEngine(model.Url))
            {
                var urls = new List <string>
                {
                    $"Available search engines -"
                };

                urls.AddRange(_searchEngine.GetSearchEngines().Select(s => s.Url));

                return(Json(new ResultModel
                {
                    Success = false,
                    Errors = urls,
                }));
            }

            var hits = await _searchEngine.FindHits(model.Url, model.SearchTerms.Split(' '));

            var result = new ResultModel
            {
                Hits    = string.Join(", ", hits).Trim(),
                Success = true
            };

            return(Json(result));
        }
        private ScanProperties GetScanProperties(string scanId, SubmitModel submitModel)
        {
            ScanProperties scanProperties = new ClientScanProperties();

            // The action to perform
            // Possible values:
            // 1. checkCredits - return the number of credits that will be consumed by the scan.
            //                   The Result of the request will be returned to the 'Completion' callback
            // 2. Scan - Scan the submitted text
            //           The Result of the request will be returned to the 'Completion' callback
            // 3. Index - Upload the submitted text to Copyleaks internal database to be compared against feture scans
            //            The Result of the request will be returned to the 'Completion' callback
            scanProperties.Action   = eSubmitAction.Scan;
            scanProperties.Webhooks = new Webhooks
            {
                // Copyleaks API will POST the scan results to the 'completed' callback
                // See 'CompletedProcess' method for more details
                Status = new Uri($"{submitModel.WebHookHost}/{scanId}/{{status}}")
            };
            // Sandbox mode does not take any credits
            scanProperties.Sandbox = submitModel.Sandbox;

            return(scanProperties);
        }
Esempio n. 29
0
        public async Task <IActionResult> End(SubmitModel submitModel)
        {
            var result = JsonConvert.DeserializeObject <List <ValueModel> >(submitModel.result);

            var thePaper = paperManager.FindPaperById(submitModel.paperId);

            var topicIdList = JsonConvert.DeserializeObject <List <TopicId> >(thePaper.body);

            if (result.Count == topicIdList.Count)
            {
                int sum = 0;
                for (int i = 0; i < result.Count; i++)
                {
                    var theTopic = topicManager.FindTopicById(topicIdList[i].id);
                    if (theTopic.answe.Equals(result[i].value))
                    {
                        sum += theTopic.scores;
                    }
                }
                var flag = await successManager.CreateSuccessAsync(new SuccessModel {
                    userName = User.Identity.Name,
                    paper    = thePaper.title,
                    scores   = sum,
                    subtotal = thePaper.subtotal
                });

                if (flag)
                {
                    ViewBag.Subtotal = thePaper.subtotal;
                    return(View(sum));
                }
            }
            return(View("Error", new ErrorViewModel {
                RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier
            }));
        }
Esempio n. 30
0
        public ActionResult Save(SubmitModel model)
        {
            SessionHelper.Temp  = model.DistrictId;
            SessionHelper.Temp2 = model.UpazillaId;

            SummerizedData entity = new SummerizedData();

            ModelCopier.CopyModel(model, entity);

            entity.InsertedById = SessionHelper.UserId;

            if (model.Id == 0)
            {
                sunDataService.Add(entity);
            }
            else
            {
                sunDataService.Update(entity);
            }

            unitOfWork.Commit();

            return(PartialView());
        }
        public async Task <IActionResult> CreateSubmit([Bind("SubmitID,TaskID,SubmitName,ContentFile,SubmitTime,SubmitScore")] SubmitModel submitModel)
        {
            if (ModelState.IsValid)
            {
                //Save to File
                string wwwRootPath = _hostEnvironment.WebRootPath;
                string fileName    = Path.GetFileNameWithoutExtension(submitModel.ContentFile.FileName);
                string extension   = Path.GetExtension(submitModel.ContentFile.FileName);
                //contentModel.ContentDescription = fileName = fileName + DateTime.Now.ToString("yymmssffff") + extension;
                submitModel.SubmitDescription = fileName = fileName + extension;
                submitModel.SubmitTime        = DateTime.Now.ToString("dd MMMM yyyy");
                string path = Path.Combine(wwwRootPath + "/File", fileName);
                using (var fileStream = new FileStream(path, FileMode.Create))
                {
                    await submitModel.ContentFile.CopyToAsync(fileStream);
                }
                //Insert record
                _context.Add(submitModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction("SubmitList", new { TaskID = submitModel.TaskID }));
            }
            return(View(submitModel));
        }
Esempio n. 32
0
 public ContactFormSubmitContext(SubmitModel data, EmailSender mailer, MailResultModel result)
 {
     this.Data = data;
     this.Emailer = mailer;
     this.Result = result;
 }
Esempio n. 33
0
        public ActionResult Submit(int NewEstimate = 0, string team = "Default", string name = "", int estimation=0)
        {
            if (TeamsThreadPool.Instance.tasks == null
                || TeamsThreadPool.Instance.tasks.Any(k => k.IsFaulted)
                || TeamsThreadPool.Instance.tasks.Any(k => k.IsCompleted)
                || TeamsThreadPool.Instance.tasks.Any(k => k.IsCanceled))
            {
                log.Info("Some of tasks was removed or canceled or faulted, creating threads one more time ");
                TeamsThreadPool.Instance.AddTeamsToThreadPool();
            }

            Response.Expires = -1;
            var teamModel = db.Query<Team>().FirstOrDefault(k => k.Name == team);
            teamModel.Results = db.Query<Result>().Where(k => k.TeamId == teamModel.Id).ToList();

            if (NewEstimate == 1)
            {
                foreach (var table in teamModel.Results.ToList())
                {
                    db.Remove(table);
                }

                db.Save();
            }

            bool cookieIsSaved = false;

            if (name != "")
            {
                saveNameInCookie(name);
                cookieIsSaved = true;
            }

            if (Request.Cookies["name"] != null && estimation == 0)
            {
                var cookieName = Request.Cookies["name"];
                var nameValue = cookieIsSaved ? name : cookieName.Value;
                var model = new SubmitModel
                {
                    Name = nameValue,
                    Team = team
                };

                return View(model);
            }

            var count = teamModel.Amount;
            if (teamModel.Results.Count() >= count && teamModel.Results.All(b => b.Nickname != name))
            {
                var rmIndex = new ReturnModel
                {
                    Team = teamModel,
                    Name = name
                };

                return View("Toomany", rmIndex);
            }

            if (estimation != 0 && name != "" && team != "")
            {
                var returnModel = new SubmitModel
                {
                    estimate = (Estimation)estimation,
                    Name = name,
                    Team = team
                };

                var returnTeam = db.Query<Team>().FirstOrDefault(k => k.Name == returnModel.Team);
                returnTeam.Results = db.Query<Result>().Where(k => k.TeamId == returnTeam.Id).ToList();

                var result = returnTeam.Results.FirstOrDefault(k => k.Nickname == returnModel.Name);
                if (result != null)
                {
                    result.Estimate = returnModel.estimate;
                    db.Update(result);
                }
                else
                {
                    var returnResult = new Result
                    {
                        Estimate = returnModel.estimate,
                        Nickname = returnModel.Name
                    };

                    returnTeam.Results.Add(returnResult);

                    db.Update(returnTeam);
                }

                if (ModelState.IsValid)
                {
                    db.Save();

                    return RedirectToAction("Index", "Result", new { team = returnTeam.Name, name });
                }

                return View("Submit", returnModel);
            }

            var m = new SubmitModel
            {
                Name = name,
                Team = team
            };

            return View(m);
        }