public UserController() { _dolphinApi = new Infrastructure(); _auditService = new AuditService(); _encodingService = new EncodingCharacters(); _uploadFile = new UploadAttachment(); }
private void IncludeAttachment_btn_Click(object sender, EventArgs e) { if (UploadAttachment.ShowDialog() == DialogResult.Cancel) { return; } AttachmentPath = UploadAttachment.FileName; }
public ViewResult UploadAttachment(AttachmentType type, int id) { var model = new UploadAttachment() { Type = type, Id = id, Attachments = new List <Attachment>(), AcademicYears = _coreRepository.GetAll <CohortYear>() .OrderByDescending(x => x.Name) .Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString() }) .ToList() }; return(View(model)); }
public Result Index(string token, long chatId) { var result = new Result(); if (Helpers.CheckerTokenHelper.GetUser(token) is null) { var error = new Error(); error.Code = 2; error.Message = "Неверный токен."; result.Data = error; result.Status = false; return(result); } using (var db = new DatabaseContext()) { var usr = db.Users.Single(u => u.Token == token); var upa = new UploadAttachment(); upa.User = usr.UserId; upa.ChatId = chatId; upa.TypeAttach = 3; upa.AttachmentKey = new Random().Next(0, 999999999); db.UploadAttachments.Add(upa); db.SaveChanges(); result.Status = true; var rsp = new GetUploadServer(); rsp.Id = upa.AttachmentId; rsp.Key = upa.AttachmentKey; result.Data = rsp; } return(result); }
public void UploadFile_TableRecordFileInfo_Success() { // Create var dict = testConfig.GetDefaultActivityArguments(); dict["TableID"] = attachmentTable.Id; dict["Title"] = "Upload TextFile Test Record"; var act = new CreateTableRecord(); var result = WorkflowInvoker.Invoke(act, dict); Assert.IsTrue((bool)result["Success"]); var recordId = (long)result["TableRecordID"]; Assert.IsTrue(recordId > 0); // Upload file var fileInfo = new FileInfo("TestFiles/simple-text.txt"); dict = testConfig.GetDefaultActivityArguments(); dict["OrganizationID"] = testConfig.GetCustomConfig("OrganizationID"); dict["FileInfo"] = fileInfo; var act2 = new UploadAttachment(); result = WorkflowInvoker.Invoke(act2, dict); var uploadedUrl = (string)result["FileUrl"]; Assert.IsTrue((bool)result["Success"]); Assert.IsFalse(string.IsNullOrWhiteSpace(uploadedUrl)); // Update TableRecord field dict = testConfig.GetDefaultActivityArguments(); dict["TableRecordID"] = recordId; dict["FieldID"] = "file"; dict["Value"] = new string[] { uploadedUrl }; var act3 = new SetTableRecordFieldValue(); result = WorkflowInvoker.Invoke(act3, dict); Assert.IsTrue((bool)result["Success"]); // Get dict = testConfig.GetDefaultActivityArguments(); dict["TableRecordID"] = recordId; var act4 = new GetTableRecord(); result = WorkflowInvoker.Invoke(act4, dict); Assert.IsTrue((bool)result["Success"]); var tableRecord = (JObject)result["TableRecord"]; var valuesJArray = tableRecord["record_fields"] as JArray; var valuesDict = Helper.TableRecord.FieldsJArrayToJObjectDictionary(valuesJArray); Assert.AreEqual(uploadedUrl, valuesDict["file"]["array_value"].First.Value <string>()); // Delete dict = testConfig.GetDefaultActivityArguments(); dict["TableRecordID"] = recordId; var act5 = new DeleteTableRecord(); result = WorkflowInvoker.Invoke(act5, dict); Assert.IsTrue((bool)result["Success"]); Assert.AreEqual(act5.SuccessMessage, result["Status"].ToString()); }