public CallContext UploadedFileSave(UploadedFile entity, CallContext resultContext) { resultContext.securitySettings = ETEMEnums.SecuritySettings.UploadedFileSave; CallContext resContext = new UploadedFileBL().EntitySave<UploadedFile>(entity, resultContext); return resContext; }
public void ProcessRequest(HttpContext context) { this.CommonClientRef = new Common(); DecryptQueryString(context.Request); string path = string.Empty; if (this.queryString["UploadPath"] != null) { path = this.queryString["UploadPath"].ToString(); } HttpPostedFile fileToUpload = context.Request.Files["Filedata"]; string pathToSave = (path.EndsWith("\\") ? path : path + "\\") + fileToUpload.FileName; fileToUpload.SaveAs(pathToSave); #region Save Entity this.currentEntity = new UploadedFile(); string[] user = path.Split('_'); string[] resName = user.First().Split('\\'); FileInfo fi = new FileInfo(pathToSave); currentEntity.idResource = Convert.ToInt32(user.Last()); currentEntity.ResourceName = resName.Last(); currentEntity.FilePath = pathToSave; currentEntity.FileName = fileToUpload.FileName; currentEntity.Extension = Path.GetExtension(fileToUpload.FileName).Substring(1); currentEntity.DateUpload = DateTime.Now; currentEntity.Size = Convert.ToInt32(fi.Length / (1024));// в KБ //currentEntity.ContentType = CallContext resultContext = new CallContext(); resultContext.CurrentConsumerID = user.Last(); resultContext = CommonClientRef.UploadedFileSave(currentEntity, resultContext); #endregion }
protected void btnSave_Click(object sender, EventArgs e) { string idPerson = this.FormContext.QueryString["idResource"].ToString(); foreach (GridViewRow row in this.gvUploadedFiles.Rows) { if (row.RowType == DataControlRowType.DataRow) { //ID на прикачени файл HiddenField hdnRowMasterKey = row.FindControl("hdnIdUploadedFile") as HiddenField; //radio button RadioButton rbtn = row.FindControl("rbtnSelectedFile") as RadioButton; //описание за всеки прикачен файл TextBox tbxDescription = row.Cells[0].FindControl("tbxDescription") as TextBox; string descr = tbxDescription.Text; //Update на всички редове като записваме само описанието this.currentEntity = CommonClientRef.GetUploadFileByID(hdnRowMasterKey.Value); currentEntity.Description = descr; CallContext resultContext = new CallContext(); resultContext.CurrentConsumerID = this.UserProps.IdUser; resultContext = CommonClientRef.UploadedFileSave(currentEntity, resultContext); //update на снимката на потребителя if (rbtn.Checked) { this.personEntity = this.AdminClientRef.GetPersonByPersonID(idPerson); if (this.personEntity != null) { this.personEntity.ImagePath = this.currentEntity.FilePath.Replace("\\", "/").Replace("C:", string.Empty); CallContext resultPersontContext = new CallContext(); resultPersontContext.CurrentConsumerID = this.UserProps.IdUser; resultPersontContext = AdminClientRef.PersonSave(this.personEntity, resultPersontContext); } //refresh Parent form string script = "this.window.opener.location=this.window.opener.location;"; if (!ClientScript.IsClientScriptBlockRegistered("REFRESH_PARENT")) { ClientScript.RegisterClientScriptBlock(typeof(string), "REFRESH_PARENT", script, true); } } } } }
/// <summary> /// Create a new UploadedFile object. /// </summary> /// <param name="idUploadedFile">Initial value of the idUploadedFile property.</param> public static UploadedFile CreateUploadedFile(global::System.Int32 idUploadedFile) { UploadedFile uploadedFile = new UploadedFile(); uploadedFile.idUploadedFile = idUploadedFile; return uploadedFile; }
/// <summary> /// Deprecated Method for adding a new object to the UploadedFiles EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToUploadedFiles(UploadedFile uploadedFile) { base.AddObject("UploadedFiles", uploadedFile); }