protected void asyncUpload_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e) { List <t_LanguageTranslate> list = languageBL.FindAll(x => x.Language == language && x.Noted.Contains("/Supervisor/Device/All.aspx")).ToList(); var up_download_upload_confirm = list.Where(x => x.ControlId.Contains("up_download_upload_confirm")).FirstOrDefault(); lblMessage.Visible = true; if (string.IsNullOrEmpty(txtSerial.Text)) { lblMessage.Text = "Please input seri ."; txtSerial.Focus(); return; } string targetFolder = asyncUpload.TargetFolder; string newName = "_" + txtSerial.Text + "_" + _stringUT.RemoveSign4VietnameseString(e.File.GetName()); e.File.SaveAs(System.IO.Path.Combine(Server.MapPath(targetFolder), newName)); var dbMeterFile = _meterFileBL.GetMeterFile(newName); t_Meter_Files meterFile = new t_Meter_Files(); meterFile.FileName = newName; meterFile.MIMEType = e.File.ContentType; meterFile.Path = System.IO.Path.Combine(Server.MapPath(targetFolder), meterFile.FileName); meterFile.MeterSerial = txtSerial.Text; meterFile.Size = (int)e.File.ContentLength; meterFile.UploadDate = DateTime.Now; if (dbMeterFile != null) { try { _meterFileBL.UpdateMeterFile(meterFile, dbMeterFile); //lblMessage.Text = "Đã upload file mới."; lblMessage.Text = up_download_upload_confirm.Contents; } catch (Exception ex) { lblMessage.Text = "Lỗi: " + ex.Message; //throw; } } else { try { _meterFileBL.InsertMeterFile(meterFile); lblMessage.Text = "File uploaded."; } catch (Exception ex) { lblMessage.Text = ex.Message; //throw; } } BindFile(); }
public void DeleteMeterFile(t_Meter_Files meterFile) { try { meterFileRepository.DeleteMeterFile(meterFile); } catch (Exception ex) { // throw ex; } }
public void UpdateMeterFile(t_Meter_Files meterFile, t_Meter_Files orgiMeterFile) { try { meterFileRepository.UpdateMeterFile(meterFile, orgiMeterFile); } catch (Exception ex) { // throw ex; } }
public void InsertMeterFile(t_Meter_Files meterFile) { try { context.t_Meter_Files.Add(meterFile); context.SaveChanges(); } catch (Exception ex) { // throw ex; } }
public void DeleteMeterFile(t_Meter_Files meterFile) { try { context.t_Meter_Files.Attach(meterFile); context.t_Meter_Files.Remove(meterFile); context.SaveChanges(); } catch (Exception ex) { // throw ex; } }
public void UpdateMeterFile(t_Meter_Files meterFile, t_Meter_Files orgiMeterFile) { try { context.t_Meter_Files.Attach(orgiMeterFile); orgiMeterFile.FileName = meterFile.FileName; orgiMeterFile.MeterSerial = meterFile.MeterSerial;; orgiMeterFile.MIMEType = meterFile.MIMEType; orgiMeterFile.Path = meterFile.Path; orgiMeterFile.Size = meterFile.Size; orgiMeterFile.UploadDate = meterFile.UploadDate; context.SaveChanges(); } catch (Exception ex) { // throw ex; } }