// GET: Report public ActionResult Index() { using (Muse db = new Muse()) { IEnumerable <ReportDataSourceModel> sources = db.GetAll <ReportDataSourceModel>(new string[] { "ReportDataSetModels" }, false); if (Ls.Ok(sources)) { var source = sources.First(); string cs = source.ConnectionString; string sql = source.ReportDataSets.First().Sql; MySqlHelper msHelper = new MySqlHelper(cs); DataTable a = msHelper.Select(sql, out int recordsAffected); ReportModel ri = new ReportModel() { DataTable = a, ReportOption = new ReportOptionModel() { Title = "标题XXXXXX", Type = "ECharts.BasicLineChart", Dimensions = "continent,cts,rgs", SeriesType = "bar,bar", Height = 400, } }; ViewBag.Report = ri; } } return(View()); }
public ActionResult Create(ReportDataSourceModel model) { using (Muse db = new Muse()) { model.Id = Guid.NewGuid(); model.CreateUser = User.Identity.Name; int flag = db.Add(model, true); if (flag > 0) { return(RedirectToAction("Index")); } else { return(View()); } } //try //{ // // TODO: Add insert logic here // return RedirectToAction("Index"); //} //catch //{ // return View(); //} }
public static int GetDatas(string apiKey, DateTime date) { int count = 0; var durations = GetDurations(apiKey, date); var heartbeats = GetHeartbeats(apiKey, date); List <WakaTimeDatas> datas = AssembleHeartbeats(durations, heartbeats); List <WakaTimeDatas> notExistDatas = new List <WakaTimeDatas>(); if (ListTool.HasElements(datas)) { using (Muse db = new Muse()) { foreach (var data in datas) { if (!db.Any <WakaTimeDatas>(x => x.ID == data.ID, null)) { if (!notExistDatas.Any(x => x.ID == data.ID)) { notExistDatas.Add(data); } } } if (ListTool.HasElements(notExistDatas)) { count = db.Adds(notExistDatas); } } } return(count); }
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); }
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(); //} }
/// <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) { } } } }
/// <summary> /// 统计所有编程语言使用占用情况 /// </summary> /// <param name="userId"></param> /// <returns></returns> public static List <Tuple <string, double> > LanguageCount() { List <Tuple <string, double> > rs = null; using (Muse db = new Muse()) { if (db.Any <WakaTimeDatas>(x => x.ID != null, null)) { var languageGroup = db.Do <WakaTimeDatas>().Where(x => x.Language != null).GroupBy(x => x.Language). Select(x => new { Language = x.Max(e => e.Language), Duration = x.Sum(y => y.Duration), }).OrderByDescending(x => x.Duration).Take(MAX_LANGUAGE).ToList(); if (ListTool.HasElements(languageGroup)) { rs = new List <Tuple <string, double> >(); languageGroup.ForEach(x => { Tuple <string, double> rec = new Tuple <string, double>(x.Language, x.Duration); rs.Add(rec); }); } } } return(rs); }
/// <summary> /// 获取所有年份 /// </summary> /// <returns></returns> public static List<int> AllYears() { List<int> years = new List<int>(); using (Muse db = new Muse()) { if (db.Any<WakaTimeDatas>(x => x.ID != null, null)) { var data = db.Do<WakaTimeDatas>(). GroupBy(x => new { x.BeginDate.Year }). Select(x => new { Date = x.Max(y => y.BeginDate), }).OrderByDescending(x => x.Date).ToList(); if (ListTool.HasElements(data)) { data.ForEach(x => { years.Add(x.Date.Year); }); } } } int year = DateTime.Now.Year; if (!years.Contains(year)) years.Add(year); return years; }
private void FileRestoreForm_Load(object sender, EventArgs e) { //读取该文件的备份记录 using (var db = new Muse()) { Files = db.Gets <BackupFiles>(x => x.FullPath == FilePath, null).OrderBy(x => x.Id).ToList(); } if (ListTool.HasElements(Files)) { //获取文件名及路径信息 var first = Files.FirstOrDefault(); LbFileName.Text = Path.GetFileName(first.FullPath); LbPath.Text = first.FullPath; LbVersion.Text = "共 " + Files.Count + " 版"; TtLabel.SetToolTip(LbFileName, Path.GetFileName(first.FullPath)); TtLabel.SetToolTip(LbPath, first.FullPath); //显示所有备份记录 int index = 1; foreach (var file in Files) { DgvFiles.Rows.Add(string.Format("第 {0} 版", index++), file.LastWriteTime, ByteConvertTool.Fmt(file.Size)); } } }
private void GetFileToDatabaseEvent(DriveInfo drive, List <UsnEntry> data) { List <UsnFiles> temp = new List <UsnFiles>(); if (ListTool.HasElements(data)) { for (int i = 0; i < data.Count; i++) { temp.Add(new UsnFiles() { Name = data[i].FileName, IsFolder = data[i].IsFolder, Number = NumberStringTool.ToString(data[i].FileReferenceNumber), ParentNumber = NumberStringTool.ToString(data[i].ParentFileReferenceNumber), Drive = drive.Name, Usn = data[i].Usn, CreateTime = DateTimeConvert.DetailString(DateTime.Now) }); NewFileCount++; } } using (var db = new Muse()) { db.Adds(temp); } UISetFileCount(drive.Name, NewFileCount); }
// Update is called once per frame void FixedUpdate() { float moveHorizontal = Muse.GetAccLeftRight() / 100.0f; //Debug.Log (moveHorizontal); Vector2 movement = new Vector2(moveHorizontal, 0.0f); rb2d.AddForce(movement * speed); //Debug.Log (Muse.blinks); if (Muse.blinks == 1) { Vector2 vertForce = new Vector2(0.0f, speed_blink); rb2d.AddForce(vertForce * speed); } if (moveHorizontal < 0.0f && face_flag == 1) { transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localScale.z); face_flag = 0; } if (moveHorizontal > 0.0f && face_flag == 0) { transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localScale.z); face_flag = 1; } if (Muse.jaw == 1) { GenerateBubble(); } }
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); }
static int RunRecordAndReturnExitCode(RecordOptions opts) { // create Muse instance var dataToRead = opts.Data.Aggregate((acc, x) => acc | x); var muse = new Muse() { DataToRead = dataToRead }; // print Muse info Console.WriteLine($"Muse Model = {muse.Model}"); Console.WriteLine($"Muse Name = {muse.Name}"); // create GSR/PPG sampler instance var gsrPpgSampler = new GsrPpgSampler(opts.PortName, 115200, SamplingRate.SR500Hz, SamplingRate.SR500Hz); // print GSR/PPG sampler info Console.WriteLine($"GSR/PPG Sampler COM port = {gsrPpgSampler.PortName}, baudrate = {gsrPpgSampler.BaudRate}"); Console.WriteLine($"GSR sampling rate = {gsrPpgSampler.GsrSamplingRate}"); Console.WriteLine($"PPG sampling rate = {gsrPpgSampler.PpgSamplingRate}"); var stopwatch = new Stopwatch(); bool cancelKeyPressed = false; Console.WriteLine("Press any key to start recording"); Console.ReadKey(true); muse.StartReading(); gsrPpgSampler.StartReading(); stopwatch.Start(); // wait for a key press to exit Console.CancelKeyPress += (s, e) => { e.Cancel = true; cancelKeyPressed = true; }; Console.WriteLine("Press Ctrl + C to exit"); while (!cancelKeyPressed) { Console.Write($"\r{stopwatch.Elapsed.ToString("g")}"); Thread.Sleep(100); } Console.WriteLine(); stopwatch.Stop(); muse.StopReading(); gsrPpgSampler.StopReading(); Console.WriteLine("Saving data..."); var museJson = JObject.Parse(muse.ConvertDataToJson()); var gsrPpgJson = JObject.Parse(gsrPpgSampler.ConvertDataToJson()); museJson.Merge(gsrPpgJson); File.WriteAllText(opts.OutputFile, museJson.ToString()); return(0); }
/// <summary> /// 读取备份文件总数 /// </summary> private void ReadBackupFileCount() { //统计备份文件总数 using (var db = new Muse()) { _FileCount = db.Do <BackupFiles>().Count(); } }
// 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)); } }
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); } } } }
// GET: ReportDataSet/Create public ActionResult Create() { 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; return(View()); } }
static void Main(string[] args) { var muse = new Muse() { DataToRead = MuseData.EEG | MuseData.Absolutes | MuseData.Relatives }; Console.WriteLine($"Muse Model : {muse.Model}"); Console.WriteLine($"Muse Name : {muse.Name}"); }
// GET: ReportPage public ActionResult Index() { IEnumerable <ReportPageModel> result = new List <ReportPageModel>(); using (Muse db = new Muse()) { result = db.Gets <ReportPageModel>(x => x.CreateUser == User.Identity.Name, null).OrderBy(x => x.Name); } return(View(result)); }
/// <summary> /// 读取数据库权限验证配置信息 /// </summary> private void ReadAuthsInfo() { //if (!Ls.Ok(auths)) { using (Muse db = new Muse()) { auths = db.GetAll <AuthorizeModel>(null, false).ToList(); } } }
// 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)); } }
private void SetSelectedMuse(Muse muse) { var selectedMuses = Muses.Where(x => x.IsSelected); foreach (var selectedMuse in selectedMuses) { selectedMuse.IsSelected = false; } muse.IsSelected = true; }
public static void Start() { if (IsStart) { return; } IsStart = true; Task.Factory.StartNew(() => { //设置退出条件 while (!Token.IsCancellationRequested) { //队列中存在元素 if (Queue.Any()) { //循环进行操作 for (int i = 0; i < Queue.Count; i++) { try { if (Queue.TryDequeue(out string file)) { R.Log.v("💗💗💗 准备处理文件:" + file); var pic = PictureReorganize.CreateModel(file); if (pic != null) { R.Log.v("图片信息读取成功"); using (Muse db = new Muse("pictures")) { if (db.Any <Pictures>(x => x.MD5 == pic.MD5 && x.SHA1 == pic.SHA1, null)) { R.Log.v("图片已入库,不需要在重复保存了,即将删除"); FileTool.Delete(file); } else { R.Log.v("图片未入库,准备入库并分类保存"); db.Add(pic); pic = PictureReorganize.AddLocationInfo(file, pic); pic = PictureReorganize.AddContentInfo(file, pic); PictureReorganize.ReorganizePicture(file, R.Paths.Pictures, pic); } } } } } catch { } } } Sleep.S(Interval); } }); }
/// <summary> /// 获取编程总时长 /// </summary> /// <returns></returns> public static double Career() { double career = 0; using (Muse db = new Muse()) { if (db.Any <WakaTimeDatas>(x => x.ID != null, null)) { career = db.Do <WakaTimeDatas>().Sum(x => x.Duration); } } return(career); }
/// <summary> /// 获取所有项目统计列表 /// </summary> /// <param name="userId"></param> /// <returns></returns> public static void GetProjectList(Guid userId) { using (Muse db = new Muse()) { var projectCount = db.Do <WakaTimeDatas>(). GroupBy(x => new { x.Project }). Select(x => new { Project = x.Max(y => y.Project), Duration = x.Sum(y => y.Duration), }).OrderByDescending(x => x.Duration).ToList(); } }
// GET: ReportDataSet public ActionResult Index() { IEnumerable <ReportDataSetModel> result = new List <ReportDataSetModel>(); 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; result = db.Gets <ReportDataSetModel>(x => x.CreateUser == User.Identity.Name, new[] { "ReportDataSourceModel" }); } return(View(result)); }
private void Form1_Load(object sender, EventArgs e) { using (Muse db = new Muse()) { Pigs pig = new Pigs() { Id = Guid.NewGuid().ToString(), Age = 10, Name = "Tom" }; db.Add(pig); } }
/// <summary> /// 定时处理要备份的文件任务 /// </summary> private void BackupFileTask() { while (IsStart) { if (ListTool.HasElements(BackupFiles)) { //获取要备份的文件列表并复制样本 List <string> temp; lock (BackupFiles) { temp = BackupFiles; BackupFiles = new List <string>(); } using (var db = new Muse()) { foreach (var t in temp) { //要备份的文件存在 if (File.Exists(t)) { //文件属于要备份的文件目录 string filepath = DirTool.GetFilePath(t); BackupPaths path = Paths.FirstOrDefault(x => filepath.Contains(x.Path)); if (path != null) { //文件的MD5码以前没有备份过 string md5 = FileTool.GetMD5(t); bool isback = db.Any <BackupFiles>(x => x.FullPath == t && x.Md5 == md5, null); if (!isback) { string pathname = path.Path; //备份文件夹路径 string pathalias = path.Alias; //备份文件夹别名 string pathfile = t.Substring(pathname.Length, t.Length - pathname.Length); //截取备份文件子目录(相对备份文件夹) string fileext = "." + DateTimeConvert.CompactString(DateTime.Now) + Path.GetExtension(t); //设置后缀 string fullpath = DirTool.Combine(R.Settings.FileBackup.FileManBackup, pathalias, pathfile + fileext); //组合路径 //删除冗余 DeleteExcess(t); //备份文件 BackupFile(t, fullpath, md5); _FileCount++; } } } } } } Thread.Sleep(R.Settings.FileBackup.BACK_UP_INTERVAL); } }
/// <summary> /// 获取带GPS信息的照片 /// </summary> /// <returns></returns> public static List <Pictures> GetPictures() { List <Pictures> list = new List <Pictures>(); using (Muse db = new Muse("pictures")) { var _temp = db.Gets <Pictures>(x => x.GpsLongitude != 0 && x.GpsLatitude != 0, null).ToList(); if (ListTool.HasElements(_temp)) { list = _temp; } } return(list); }