private void GetFileToDatabase() { var drives = FileQueryEngine.GetReadyNtfsDrives().OrderBy(x => x.Name); if (ListTool.HasElements(drives)) { foreach (var drive in drives) { NewFileCount = 0; //if (!drive.Name.Contains("J")) continue;//测试只读取D盘 //if (drive.Name.Contains("D")) continue;//测试时跳过D盘 //if (drive.Name.Contains("F")) continue;//测试时跳过F盘 using (var db = new Muse()) { //检测磁盘是否格式化,如果格式化则清空USN记录 DateTime dt1 = DriveTool.GetLastFormatTime(drive.Name); var ds = db.Get <UsnDrives>(x => x.Name == drive.Name, null); if ((ds == null) || (ds != null && ds.LastFormatTime != dt1.ToString())) { var deleteSql = db.Context.Database.ExecuteSqlCommand("DELETE FROM usnfiles WHERE drive = @p0;", drive.Name); if (ds == null) { db.Add(new UsnDrives() { Name = drive.Name, LastFormatTime = dt1.ToString() }); } else { ds.LastFormatTime = dt1.ToString(); db.Update(ds, true); } } //查询上次读取到的位置(最后一条记录) ulong filenumber = 0; long usn = 0; if (db.Any <UsnFiles>(x => x.Drive == drive.Name, null)) { int lastId = db.Do <UsnFiles>().Where(x => x.Drive == drive.Name).Max(x => x.Id); UsnFiles lastRec = db.Get <UsnFiles>(x => x.Id == lastId, null); usn = lastRec.Usn; filenumber = NumberStringTool.ToUlong(lastRec.Number); //usn = db.Do<UsnFiles>().Where(x => x.Drive == drive.Name).Max(x => x.Usn); //string filenumberstr = db.Do<UsnFiles>().Where(x => x.Drive == drive.Name).Max(x => x.Number); //filenumber = NumberStringTool.ToUlong(filenumberstr); } //从上次FileNumber记录开始读取 var usnOperator = new UsnOperator(drive); usnOperator.GetEntries(usn, filenumber, GetFileToDatabaseEvent, 1000); } } } }
/// <summary> /// 初始读取文件并备份 /// </summary> public void DefaultBackupFile(string path) { //读取本地文件夹中的所有文件列表 List <string> files = FileTool.GetAllFile(path); if (ListTool.HasElements(files)) { foreach (var file in files) { try { string lastwritetime = DateTimeConvert.StandardString(File.GetLastWriteTime(file)); using (var db = new Muse()) { BackupFiles backfile = db.Get <BackupFiles>(x => x.FullPath == file && x.LastWriteTime == lastwritetime, null); if (backfile == null) { AddToBackupFiles(file); } } } catch (Exception e) { } } } }
public Rs Share(object paramses) { //格式化参数 Dictionary <string, string> p = JsonConvert.DeserializeObject <Dictionary <string, string> >(paramses.ToString()); Rs rs = Rs.Ok(); if (p.TryGetValue("__id", out string _id) && Guid.TryParse(_id, out Guid id)) { using (Muse db = new Muse()) { var record = db.Get <ReportDataSetModel>(x => x.ShareId == id && id != Guid.Empty, new[] { "ReportDataSourceModel" }); string cs = record.ReportDataSourceModel.ConnectionString; string sql = record.Sql; MySqlHelper msHelper = new MySqlHelper(cs); DataTable dt = msHelper.Select(sql, out int recordsAffected); var dic = TableConvert.Table2Dictionary(dt); rs.Add("table", dic); rs.Add("recordsAffected", recordsAffected); return(rs); } } else { rs = Rs.Error(); } return(rs); }
public bool SaveInfo() { using (var db = new Muse()) { FaultLogs fl = db.Get <FaultLogs>(x => x.Id == Id, null); if (fl != null) { fl.Address = TbAddress.Text; fl.Ip = TbIp.Text; fl.Phone = TbPhone.Text; fl.Postscript = TbPostscript.Text; fl.Problem = TbProblem.Text; fl.Solution = TbSolution.Text; fl.System = CbSystem.Text; if (CbIsFinish.Checked && !fl.IsFinish) { fl.IsFinish = true; fl.FinishTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); } if (!CbIsFinish.Checked && fl.IsFinish) { fl.IsFinish = false; fl.FinishTime = ""; } int flag = db.Update(fl, true); return(flag > 0); } } return(false); }
// GET: ReportDataSource/Details/5 public ActionResult Details(Guid id) { using (Muse db = new Muse()) { var record = db.Get <ReportDataSourceModel>(x => x.Id == id && x.CreateUser == User.Identity.Name, null); return(View(record)); } }
// GET: ReportDataSet/Details/5 public ActionResult Details(Guid id) { using (Muse db = new Muse()) { var record = db.Get <ReportDataSetModel>(x => x.Id == id, null); return(View(record)); } }
// GET: ReportDataSet/Edit/5 public ActionResult Edit(Guid id) { using (Muse db = new Muse()) { List <ReportDataSourceModel> DataSourceList = db.Gets <ReportDataSourceModel>(x => x.CreateUser == User.Identity.Name, null).OrderBy(x => x.Name).ToList(); ViewBag.DataSourceList = DataSourceList; var record = db.Get <ReportDataSetModel>(x => x.Id == id, null); return(View(record)); } }
public ActionResult Delete(Guid id, ReportDataSetModel model) { using (Muse db = new Muse()) { var record = db.Get <ReportDataSetModel>(x => x.Id == id, null); int flag = db.Del(record, true); if (flag > 0) { return(RedirectToAction("Index")); } else { return(View()); } } }
// GET: ReportPage/Details/5 public ActionResult Details(Guid id) { using (Muse db = new Muse()) { ReportPageModel record = db.Get <ReportPageModel>(x => x.Id == id, new[] { "ReportOptionModels", "ReportOptionModels.ReportDataSetModel", "ReportOptionModels.ReportDataSetModel.ReportDataSourceModel" }); record.ReportOptions = record.ReportOptions.OrderBy(x => x.Row).ThenBy(x => x.Column).ToList(); List <ReportDataSourceModel> DataSourceList = db.Gets <ReportDataSourceModel>(x => x.CreateUser == User.Identity.Name, new[] { "ReportDataSetModels" }).ToList(); ViewBag.DataSourceList = DataSourceList; ViewBag.ReportOptionTypeList = ReportOptionTypeList; return(View(record)); } }
public ActionResult DeleteOption(Guid id) { using (Muse db = new Muse()) { var record = db.Get <ReportOptionModel>(x => x.Id == id, null); int flag = db.Del(record, true); if (flag > 0) { return(RedirectToAction("Details", new { id = record.ReportPageModelId })); } else { return(View()); } } }
public ActionResult Table(Guid id) { var a = Request.QueryString; using (Muse db = new Muse()) { var record = db.Get <ReportDataSetModel>(x => x.ShareId == id && id != Guid.Empty, new[] { "ReportDataSourceModel" }); string cs = record.ReportDataSourceModel.ConnectionString; string sql = record.Sql; MySqlHelper msHelper = new MySqlHelper(cs); DataTable dt = msHelper.Select(sql, out int recordsAffected); var dic = TableConvert.Table2Dictionary(dt); return(View(dic)); } }
public JsonResult SetShare(Guid id) { Rs rs = Rs.Ok("共享成功"); using (Muse db = new Muse()) { var record = db.Get <ReportDataSetModel>(x => x.Id == id && id != Guid.Empty, null); record.ShareId = Guid.NewGuid(); if (db.Update(record, true) > 0) { rs.Add("record", record); } else { rs = Rs.Error("共享失败"); rs.Add("record", record); } return(Json(rs, JsonRequestBehavior.AllowGet)); } }
private void BtDelPath_Click(object sender, EventArgs e) { if (DgvPath.CurrentRow != null) { int row = DgvPath.CurrentRow.Index; string path = R.Services.FBS.Paths[row].Path; if (row >= 0) { using (var db = new Muse()) { BackupPaths bp = db.Get <BackupPaths>(x => x.Path == path, null); if (bp != null) { db.Del(bp, true); } R.Services.FBS.Paths.RemoveAt(row); } UIDgvPathDel(row); } } }
private void FaultLogInputPartial_Load(object sender, EventArgs e) { UICleanInput(); Task.Factory.StartNew(() => { using (var db = new Muse()) { var first = db.Get <FaultLogs>(x => x.Id > 0, null); List <FaultLogs> fls = db.Do <FaultLogs>().SqlQuery("SELECT * FROM faultlogs WHERE createtime LIKE @p0", DateTime.Now.ToString("yyyy-MM-dd") + "%").ToList(); if (ListTool.HasElements(fls)) { foreach (var f in fls) { UIAddRow(f); } } } }); }
public ActionResult Preview(Guid id) { NameValueCollection values = Request.QueryString; List <ReportModel> ReportModels = new List <ReportModel>(); using (Muse db = new Muse()) { var record = db.Get <ReportPageModel>(x => x.Id == id, new[] { "ReportOptionModels", "ReportOptionModels.ReportDataSetModel", "ReportOptionModels.ReportDataSetModel.ReportDataSourceModel" }); if (record != null && Ls.Ok(record.ReportOptions)) { foreach (var option in record.ReportOptions) { string cs = option.ReportDataSetModel.ReportDataSourceModel.ConnectionString; string sql = option.ReportDataSetModel.Sql; MySqlHelper msHelper = new MySqlHelper(cs); DataTable dt = msHelper.Select(sql, out int recordsAffected); if (Str.Ok(option.DataName, option.DataGroup, option.DataValue)) { dt = msHelper.Group(dt, option.DataName, option.DataValue, option.DataGroup); } ReportModels.Add(new ReportModel() { DataTable = dt, ReportOption = option, }); } ReportModels = ReportModels.OrderBy(x => x.ReportOption.Row).ThenBy(x => x.ReportOption.Column).ToList(); ViewBag.ReportModels = ReportModels; } return(View(record)); } }
public void InitInfo(int id) { Id = id; using (var db = new Muse()) { FaultLogs faultLog = db.Get <FaultLogs>(x => x.Id == id, null); if (faultLog != null) { TbIp.Text = faultLog.Ip; TbPhone.Text = faultLog.Phone; TbAddress.Text = faultLog.Address; TbProblem.Text = faultLog.Problem; TbSolution.Text = faultLog.Solution; TbPostscript.Text = faultLog.Postscript; CbSystem.Text = faultLog.System; if (faultLog.IsFinish) { CbIsFinish.Checked = true; } } } }
private void DgvData_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { //int id = (int)DgvData.Rows[e.RowIndex].Cells["DgvDataId"].Value; //MessageBox.Show(id.ToString()); try { int id = (int)DgvData.Rows[e.RowIndex].Cells["DgvDataId"].Value; if (new ModifyForm(id).ShowDialog() == DialogResult.OK) { using (var db = new Muse()) { FaultLogs f = db.Get <FaultLogs>(x => x.Id == id, null); if (f != null) { UIRefreshRow(e.RowIndex, f); } } } } catch (Exception ex) { } } }