public ActionResult Edit(ReportDataSourceModel model)
        {
            using (Muse db = new Muse())
            {
                int flag = db.Update(model, true);
                if (flag > 0)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View());
                }
            }
            //try
            //{
            //    // TODO: Add update logic here

            //    return RedirectToAction("Index");
            //}
            //catch
            //{
            //    return View();
            //}
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
                    }
                }
            }
        }
Exemplo n.º 4
0
 public ActionResult Edit(ReportDataSetModel model)
 {
     using (Muse db = new Muse())
     {
         int flag = db.Update(model, true);
         if (flag > 0)
         {
             return(RedirectToAction("Index"));
         }
         else
         {
             return(View());
         }
     }
 }
 public ActionResult EditOption(ReportOptionModel model)
 {
     using (Muse db = new Muse())
     {
         int flag = db.Update(model, true);
         if (flag > 0)
         {
             return(RedirectToAction("Details", new { id = model.ReportPageModelId }));
         }
         else
         {
             return(View());
         }
     }
 }
Exemplo n.º 6
0
        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));
            }
        }