public void ActionAdd(ModDataBackupModel model) { if (model.RecordID > 0) { entity = ModDataBackupService.Instance.GetByID(model.RecordID); // khoi tao gia tri mac dinh khi update } else { entity = new ModDataBackupEntity(); // khoi tao gia tri mac dinh khi insert } ViewBag.Data = entity; ViewBag.Model = model; string s = HttpQueryString.GetValues("Url").ToString(); string rawUrl = HttpContext.Current.Request.RawUrl; string[] urls = { }; if (!string.IsNullOrEmpty(rawUrl)) { urls = rawUrl.Split('/'); } int c = urls.Length; string url = urls[c - 1]; if (!string.IsNullOrEmpty(url)) { SendFileToClient(url); } }
private bool ValidSave(ModDataBackupModel model) { TryUpdateModel(entity); //chong hack entity.ID = model.RecordID; ViewBag.Data = entity; ViewBag.Model = model; CPViewPage.Message.MessageType = Message.MessageTypeEnum.Error; //kiem tra quyen han if ((model.RecordID < 1 && !CPViewPage.UserPermissions.Add) || (model.RecordID > 0 && !CPViewPage.UserPermissions.Edit)) { CPViewPage.Message.ListMessage.Add("Quyền hạn chế."); } if (CPViewPage.Message.ListMessage.Count == 0) { //save ModDataBackupService.Instance.Save(entity); return(true); } return(false); }
public void ActionSaveNew(ModDataBackupModel model) { if (ValidSave(model)) { SaveNewRedirect(model.RecordID, entity.ID); } }
public void ActionApply(ModDataBackupModel model) { if (ValidSave(model)) { ApplyRedirect(model.RecordID, entity.ID); } }
public void ActionSave(ModDataBackupModel model) { if (ValidSave(model)) { SaveRedirect(); } }
public void ActionIndex(ModDataBackupModel model) { FtpWebRequest ftpRequest = (FtpWebRequest)WebRequest.Create("ftp://27.0.12.229"); ftpRequest.Credentials = new NetworkCredential("backup", "golvn3008"); ftpRequest.Method = WebRequestMethods.Ftp.ListDirectory; FtpWebResponse response = (FtpWebResponse)ftpRequest.GetResponse(); StreamReader streamReader = new StreamReader(response.GetResponseStream()); List <ModDataBackupEntity> directories = new List <ModDataBackupEntity>(); string line = streamReader.ReadLine(); int i = 0; while (!string.IsNullOrEmpty(line)) { if (System.IO.Path.GetExtension(line) != "") { ModDataBackupEntity entity = new ModDataBackupEntity(); entity.ID = i; entity.Url = line; directories.Add(entity); } line = streamReader.ReadLine(); i++; entity = null; } streamReader.Close(); // sap xep tu dong string orderBy = AutoSort(model.Sort); // tao danh sach var dbQuery = ModDataBackupService.Instance.CreateQuery() .Take(model.PageSize) .OrderBy(orderBy) .Skip(model.PageIndex * model.PageSize); ViewBag.Data = directories.ToList(); model.TotalRecord = dbQuery.TotalRecord; ViewBag.Model = model; }