Exemplo n.º 1
0
        public override string ToString()
        {
            string s = $"{DateTimeConvert.StandardString(Time)}|{Long}|{AFK}|{CpuPer}|" +
                       $"{RamFree}|{SysDriveFree}|{AppCpuPer}|{AppRamUsed}";

            return(s);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 初始化时间
        /// </summary>
        private void IntiQueryTime()
        {
            //开始时间
            long startTime = -1;

            if (!string.IsNullOrEmpty(cRQViewModel.StartDay))
            {
                startTime =
                    DateTimeConvert.ToLongFromSubstract(Convert.ToDateTime(cRQViewModel.StartDay), new DateTime(1970, 1, 1));

                if (cRQViewModel.SelectedStartHour > -1)
                {
                    startTime = startTime + int.Parse(cRQViewModel.SelectedStartHour.ToString()) * 60 * 60 + combCompRecordStarTimeMinutes.SelectedIndex * 60;
                }
            }
            cRQViewModel.captureRecordQueryValue.StartDayValue = startTime;
            //结束时间
            long endTime = -1;

            if (!string.IsNullOrEmpty(cRQViewModel.EndDay))
            {
                endTime = DateTimeConvert.ToLongFromSubstract(Convert.ToDateTime(cRQViewModel.EndDay), new DateTime(1970, 1, 1));
                if (cRQViewModel.SelectedEndHour > -1)
                {
                    endTime = endTime + int.Parse(cRQViewModel.SelectedEndHour.ToString()) * 60 * 60 + combCompRecordEndTimeMinutes.SelectedIndex * 60 + 3660;
                }
            }
            else
            {
                endTime =
                    DateTimeConvert.ToLongFromSubstract(DateTime.Now, new DateTime(1970, 1, 1));
            }
            cRQViewModel.captureRecordQueryValue.EndDayValue = endTime;
        }
Exemplo n.º 4
0
        /// <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) { }
                }
            }
        }
Exemplo n.º 5
0
        protected void Application_Start()
        {
            log4net.Config.XmlConfigurator.Configure();
            AreaRegistration.RegisterAllAreas();

            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            DependencyResolver.SetResolver(new NinjectDependencyResolver());

            RegisterLocalizationAdapters();

            TimeZoneInfo brasiliaTimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("E. South America Standard Time");
            var          timeZoneResolver     = new WebAppTimeZoneResolver(brasiliaTimeZoneInfo);

            DateTimeConvert.Initialize(timeZoneResolver);

            WebAppCultureManager.Initialize(new CultureInfo("pt-BR"), new ApplicationCultureProvider());

            AutoMapperConfig.RegisterMappings();
            FileHelper.SetCurrent(AppDomain.CurrentDomain.BaseDirectory);

            // Coluna IdApplication da tabela Application, utilizado no log4net
            GlobalContext.Properties["idApplication"] = ApplicationEnum.BackOffice.GetHashCode().ToString();

            ClientDataTypeModelValidatorProvider.ResourceClassKey = nameof(Resources.ModelValidationStrings);
            DefaultModelBinder.ResourceClassKey = nameof(Resources.ModelValidationStrings);
        }
        public static TrackInfoModel ConvertModel(TrackInfo info, int i)
        {
            TrackInfoModel model = new TrackInfoModel();

            model.ID              = i;
            model.TcChannelID     = info.TcChannelID;
            model.Name            = info.Name;
            model.Channel_type    = info.Channel_type;
            model.Typestr         = info.Typestr;
            model.Channel_address = info.Channel_address;
            model.Longitude       = info.Longitude;
            model.Latitude        = info.Latitude;
            model.Capimg          = info.Capimg;
            {
                CapCount cap = new CapCount();
                for (int j = 0; j < info.Capimg.Count; j++)
                {
                    cap = info.Capimg[j];
                    if (j == Convert.ToInt32(cap.Feaid))
                    {
                        break;
                    }
                }
                model.CurrentCapimg = cap.Capimg;
                DateTime time = DateTimeConvert.LongTimeToDateTime(cap.Time);
                model.Time        = time.ToString("yyyyMMdd");
                model.InstallDate = time.ToString("HH:mm:dd");
            }
            return(model);
        }
Exemplo n.º 7
0
        public static IEnumerable <object[]> EqualTo <T>(DateTimeConvert <T> dateTimeConvert)
        {
            // all equal
            yield return(new object[] { dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), TimeComparison.All, true });

            yield return(new object[] { dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), TimeComparison.JustDate, true });

            yield return(new object[] { dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), TimeComparison.JustTime, true });

            // dates equal
            yield return(new object[] { dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), dateTimeConvert(2007, 6, 5, 4, 3, 2, 9), TimeComparison.All, false });

            yield return(new object[] { dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), dateTimeConvert(2007, 6, 5, 4, 3, 2, 9), TimeComparison.JustDate, true });

            yield return(new object[] { dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), dateTimeConvert(2007, 6, 5, 4, 3, 2, 9), TimeComparison.JustTime, false });

            // times equal
            yield return(new object[] { dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), dateTimeConvert(2007, 6, 9, 4, 3, 2, 1), TimeComparison.All, false });

            yield return(new object[] { dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), dateTimeConvert(2007, 6, 9, 4, 3, 2, 1), TimeComparison.JustDate, false });

            yield return(new object[] { dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), dateTimeConvert(2007, 6, 9, 4, 3, 2, 1), TimeComparison.JustTime, true });

            // all different
            yield return(new object[] { dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), dateTimeConvert(2007, 9, 5, 4, 3, 2, 9), TimeComparison.All, false });

            yield return(new object[] { dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), dateTimeConvert(2007, 9, 5, 4, 3, 2, 9), TimeComparison.JustDate, false });

            yield return(new object[] { dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), dateTimeConvert(2007, 9, 5, 4, 3, 2, 9), TimeComparison.JustTime, false });
        }
Exemplo n.º 8
0
        public static IEnumerable <object[]> After <T>(DateTimeConvert <T> dateTimeConvert)
        {
            // all equal
            yield return(new object[] { dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), TimeComparison.All, false });

            yield return(new object[] { dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), TimeComparison.JustDate, false });

            yield return(new object[] { dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), TimeComparison.JustTime, false });

            // time before
            yield return(new object[] { dateTimeConvert(2007, 6, 5, 4, 3, 2, 0), dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), TimeComparison.All, false });

            yield return(new object[] { dateTimeConvert(2007, 6, 5, 4, 3, 2, 0), dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), TimeComparison.JustDate, false });

            yield return(new object[] { dateTimeConvert(2007, 6, 5, 4, 3, 2, 0), dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), TimeComparison.JustTime, false });

            // time after
            yield return(new object[] { dateTimeConvert(2007, 6, 5, 4, 3, 2, 9), dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), TimeComparison.All, true });

            yield return(new object[] { dateTimeConvert(2007, 6, 5, 4, 3, 2, 9), dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), TimeComparison.JustDate, false });

            yield return(new object[] { dateTimeConvert(2007, 6, 5, 4, 3, 2, 9), dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), TimeComparison.JustTime, true });

            // date before
            yield return(new object[] { dateTimeConvert(2007, 6, 1, 4, 3, 2, 1), dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), TimeComparison.All, false });

            yield return(new object[] { dateTimeConvert(2007, 6, 1, 4, 3, 2, 1), dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), TimeComparison.JustDate, false });

            yield return(new object[] { dateTimeConvert(2007, 6, 1, 4, 3, 2, 1), dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), TimeComparison.JustTime, false });

            // date after
            yield return(new object[] { dateTimeConvert(2007, 6, 9, 4, 3, 2, 1), dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), TimeComparison.All, true });

            yield return(new object[] { dateTimeConvert(2007, 6, 9, 4, 3, 2, 1), dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), TimeComparison.JustDate, true });

            yield return(new object[] { dateTimeConvert(2007, 6, 9, 4, 3, 2, 1), dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), TimeComparison.JustTime, false });

            // all before
            yield return(new object[] { dateTimeConvert(2007, 6, 1, 4, 3, 2, 0), dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), TimeComparison.All, false });

            yield return(new object[] { dateTimeConvert(2007, 6, 1, 4, 3, 2, 0), dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), TimeComparison.JustDate, false });

            yield return(new object[] { dateTimeConvert(2007, 6, 1, 4, 3, 2, 0), dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), TimeComparison.JustTime, false });

            // all after
            yield return(new object[] { dateTimeConvert(2007, 6, 9, 4, 3, 2, 9), dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), TimeComparison.All, true });

            yield return(new object[] { dateTimeConvert(2007, 6, 9, 4, 3, 2, 9), dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), TimeComparison.JustDate, true });

            yield return(new object[] { dateTimeConvert(2007, 6, 9, 4, 3, 2, 9), dateTimeConvert(2007, 6, 5, 4, 3, 2, 1), TimeComparison.JustTime, true });
        }
Exemplo n.º 9
0
        public async Task <File> UploadEmptyFile([FromQuery] string token, IFormFile file)
        {
            if (string.IsNullOrEmpty(token) && User == null)
            {
                throw new NotNullException("Token不該為空");
            }

            var tokenInfo = EzCoreKit.AspNetCore.EzJwtBearerHelper.ValidToken(token);

            var fileId = Guid.Parse(tokenInfo.Claims.SingleOrDefault(x => x.Type == "fileId")?.Value);

            var fileInstance = Database.File.Include(x => x.Repository).ThenInclude(x => x.Origin).SingleOrDefault(x => x.Id == fileId);

            if (fileInstance == null)
            {
                throw new NotFoundException("找不到指定檔案");
            }

            if (User != null &&
                fileInstance.UserId != this.User.Id &&
                fileInstance.Repository.UserId != this.User.Id &&
                fileInstance.Repository.AccessModifier == AccessModifierTypes.Private)
            {
                throw new AuthorizeException();
            }

            Response.Headers.Add("Access-Control-Allow-Origin",
                                 string.Join(",", fileInstance.Repository.Origin.Select(x => x.OriginURI)));

            var exp = tokenInfo.Claims.SingleOrDefault(x => x.Type == JwtRegisteredClaimNames.Exp).Value;

            if (DateTimeConvert.FromUnixTimestamp(long.Parse(exp)) < DateTime.UtcNow)
            {
                throw new AuthorizeException("Token過期");
            }

            if (tokenInfo.Claims.SingleOrDefault(x => x.Type == "tokenType")?.Value != FileTokenTypes.Upload.ToString())
            {
                throw new AuthorizeException();
            }

            await Models.EF.File.Append(Database, fileInstance.Id, file.OpenReadStream());

            fileInstance.Name        = file.FileName;
            fileInstance.ContentType = file.ContentType;
            fileInstance.Size        = file.Length;

            await Database.SaveChangesAsync();

            return(fileInstance);
        }
Exemplo n.º 10
0
        /// <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);
            }
        }
Exemplo n.º 11
0
        public ActionResult DemoDateConvert()
        {
            DateTimeConvert DTC = new DateTimeConvert();

            DTC.DXBDateTimeString = "2020-04-29T10:00:00.000+02:00";
            //DTC.DXBDateTimeString = "2020-04-12T10:35:00.000+04:00";

            DTC.SFODateTimeString = "2020-04-29T12:22:00.000-04:00";
            //DTC.SFODateTimeString = "2020-04-12T10:35:00.000-07:00";

            DTC.SomeDTOffsetDemoDT = DateTimeOffset.Parse("2020-04-18T20:05:00.000-04:00");

            return(View("DTCDisplay", DTC));
        }
Exemplo n.º 12
0
        public async Task <FileStreamResult> Download(
            [FromRoute] Guid fileId,
            [FromQuery] string token = null)
        {
            var file = Database.File.Include(x => x.Repository).ThenInclude(x => x.Origin)
                       .SingleOrDefault(x => x.Id == fileId);

            if (file == null)
            {
                throw new NotFoundException("找不到指定的檔案");
            }

            Response.Headers.Add("Access-Control-Allow-Origin", string.Join(",", file.Repository.Origin.Select(x => x.OriginURI)));

            if (token == null)   // 未使用存取權障
            // 非公開且未登入,必定無法存取
            {
                if (file.AccessModifier != AccessModifierTypes.Public && User == null)
                {
                    throw new AuthorizeException();
                }

                // 設定為私人,但不是儲存庫擁有者也不是檔案擁有者也不是超級使用者
                if (file.AccessModifier == AccessModifierTypes.Private &&
                    User.Id != file.Repository.UserId &&
                    User.Id != file.UserId &&
                    !User.IsSuperUser())
                {
                    throw new AuthorizeException();
                }
            }
            else     // 檢查權杖
            {
                var tokenInfo = EzCoreKit.AspNetCore.EzJwtBearerHelper.ValidToken(token);
                if (fileId != Guid.Parse(tokenInfo.Claims.SingleOrDefault(x => x.Type == "fileId")?.Value) &&
                    tokenInfo.Claims.SingleOrDefault(x => x.Type == "tokenType")?.Value != FileTokenTypes.Download.ToString())
                {
                    throw new AuthorizeException();
                }

                var exp = tokenInfo.Claims.SingleOrDefault(x => x.Type == JwtRegisteredClaimNames.Exp).Value;
                if (DateTimeConvert.FromUnixTimestamp(long.Parse(exp)) < DateTime.UtcNow)
                {
                    throw new AuthorizeException("Token過期");
                }
            }

            return(File(file.GetFileStream(), file.ContentType, file.Name));
        }
 private void WriteTask()
 {
     if (!IsWrite)
     {
         Task.Factory.StartNew(() =>
         {
             IsWrite = true;
             while (!IsDisposed)
             {
                 //处理输出过长(截断到一半)
                 UIConsoleCut();
                 if (Lines.Any() && Lines.Count > 0)
                 {
                     try
                     {
                         StringBuilder sb = new StringBuilder();
                         for (int i = 0; i < Lines.Count; i++)
                         {
                             if (Lines.TryDequeue(out string s))
                             {
                                 ConsoleLine++;
                                 //显示行号
                                 if (CBNumber.Checked)
                                 {
                                     sb.Append($"【{ConsoleLine}】");
                                 }
                                 //显示时间
                                 if (CBTime.Checked)
                                 {
                                     sb.Append($"【{DateTimeConvert.StandardString(DateTime.Now)}】");
                                 }
                                 sb.Append(s);
                                 sb.Append(Environment.NewLine);
                             }
                         }
                         if (sb.Length > 0)
                         {
                             UIConsole(sb.ToString());
                         }
                     }
                     catch { }
                 }
                 Thread.Sleep(WriteInterval);
             }
         });
     }
 }
Exemplo n.º 14
0
        private void 保存屏幕ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Bitmap screen = null;

            try
            {
                string file = DirTool.Combine(R.Paths.App, DateTimeConvert.CompactString(DateTime.Now) + ".jpg");
                screen = ScreenCapture.Capture();
                screen.Save(file, System.Drawing.Imaging.ImageFormat.Jpeg);
                ToastForm.Display("保存", "保存屏幕成功:" + Path.GetFileName(file), ToastForm.ToastType.info);
            }
            catch { ToastForm.Display("保存", "保存屏幕失败", ToastForm.ToastType.error); }
            finally
            {
                screen?.Dispose();
            }
        }
Exemplo n.º 15
0
        public ActionResult MobileRegister(MobileViewModel MobileView)
        {
            MobileModels MobileModel = new MobileModels();
            var          AMobile     = MobileModel.ConvertMobileViewToMobile(MobileView);

            MobileModel.InsertMobile(AMobile);

            var brand = MobileModel.GetBrand();

            ViewBag.brand = brand;

            DateTimeConvert DateModel = new DateTimeConvert();
            var             dateText  = DateModel.ConvertDateTimeToString(MobileView.ProductionDate);

            MobileView.DateText = dateText;

            return(View(MobileView));
        }
Exemplo n.º 16
0
        /// <summary>
        /// 初始化查询时间
        /// </summary>
        /// <param name="corViewModel"></param>
        private void IntiQueryTime(CompOfRecordsViewModel corViewModel)
        {
            try
            {
                long startDate = -1;
                if (!string.IsNullOrEmpty(corViewModel.StartDay))
                {
                    startDate =
                        DateTimeConvert.ToLongFromSubstract(Convert.ToDateTime(corViewModel.StartDay), new DateTime(1970, 1, 1));

                    if (corViewModel.SelectedStartHour != -1)
                    {
                        startDate =
                            startDate + int.Parse(corViewModel.SelectedStartHour.ToString()) * 60 * 60 + SelectedStartMinutes * 60;
                    }
                }
                corViewModel.CompOfRecordsValueObj.StartDayValue = startDate;
                //结束时间
                long endDate = -1;
                if (!string.IsNullOrEmpty(corViewModel.EndDay))
                {
                    endDate =
                        DateTimeConvert.ToLongFromSubstract(Convert.ToDateTime(corViewModel.EndDay), new DateTime(1970, 1, 1));

                    if (corViewModel.SelectedEndHour != -1)
                    {
                        endDate =
                            endDate + int.Parse(corViewModel.SelectedEndHour.ToString()) * 60 * 60 + SelectedEndMinutes * 60 + 3660;
                    }
                }
                else
                {
                    endDate =
                        DateTimeConvert.ToLongFromSubstract(DateTime.Now, new DateTime(1970, 1, 1));
                }

                corViewModel.CompOfRecordsValueObj.EndDayValue = endDate;
            }
            catch (Exception ex)
            {
                Logger <CompOfRecordsViewModel> .Log.Error("IntiQueryTime", ex);
            }
        }
        public ApplicationLogProfile()
        {
            CreateMap <ApplicationLog, ApplicationLogDetailsViewModel>()
            .ForMember(x => x.ApplicationName, op => op.MapFrom(x => MapApplicationEnum(Convert.ToInt32(x.IdApplication))))
            .ForMember(x => x.Created, op => op.MapFrom(x => DateTimeConvert.FromUtc(x.Created).ToSessionTime()));

            CreateMap <ApplicationLogTableRow, ApplicationLogListItemViewModel>()
            .ForMember(x => x.Created, op => op.MapFrom(x => DateTimeConvert.FromUtc(x.Created).ToSessionTime()))
            .AfterMap((entity, model) =>
            {
                if (model.Message != null && model.Message.Length > 75)
                {
                    model.Message = string.Concat(model.Message.Substring(0, 75), "...");
                }
            });

            CreateMap <ApplicationLogFilterViewModel, ApplicationLogFilter>()
            .ForMember(x => x.CreatedStart, op => op.MapFrom(x => DateTimeConvert.FromSessionTime(x.CreatedStart).ToUtc()))
            .ForMember(x => x.CreatedEnd, op => op.MapFrom(x => DateTimeConvert.FromSessionTime(x.CreatedEnd).ToUtc()));
        }
Exemplo n.º 18
0
        static void Main(string[] args)
        {
            var utcNow    = DateTime.UtcNow;
            var utcNowStr = DateTimeConvert.ToIso8601ShortFormatString(utcNow);

            Console.WriteLine($"ISO 8601 DateTime UtcNow = {utcNowStr}");

            var nowStr = DateTimeConvert.ToIso8601ShortFormatString(utcNow.ToLocalTime());

            Console.WriteLine($"ISO 8601 DateTime    Now = {nowStr}");

            var convertedUtcNow = DateTimeConvert.ParseIso8601(utcNowStr);

            Console.WriteLine($"Using Built-in DateTime.Compare() = {DateTime.Compare(utcNow, convertedUtcNow)}");

            var customCompareResult = new DateTimeComparator(DateTimeComparator.Precision.Milliseconds).Compare(utcNow, convertedUtcNow);

            Console.WriteLine($"Using custom Comparator = {customCompareResult}");

            Console.WriteLine("Press Enter to exit");
            Console.ReadLine();
        }
Exemplo n.º 19
0
        /// <summary>
        /// 获取新闻具体内容
        /// </summary>
        /// <param name="token"></param>
        /// <param name="model"></param>
        public void GetNewsContnt(JToken token, Domain.Coin.CoinArticel.CoinArticel model)
        {
            try
            {
                var htmlWeb = new HtmlWeb();

                var document = htmlWeb.Load(token["topic_url"].ToString());

                var node = document.DocumentNode.SelectSingleNode("//div[@class='js-article-detail']") ??
                           document.DocumentNode.SelectSingleNode("//div[@class='js-article']");

                if (node != null)
                {
                    foreach (var item in node.ChildNodes)
                    {
                        if (item.InnerText.Contains("文|") || item.InnerText.Contains("编辑|"))
                        {
                            item.InnerHtml = "";
                        }
                    }

                    model.Content = node.InnerHtml;
                }

                model.CreateTime = DateTimeConvert.ConvertDateTime(token["published_at"].ToString());
                var logo = "http://pic.51yuansu.com/pic3/cover/02/61/11/59fc30d0b8598_610.jpg";
                if (!string.IsNullOrWhiteSpace(token["thumbnail_pic"].ToString()))
                {
                    logo = token["thumbnail_pic"].ToString();
                }

                model.Logo   = logo;
                model.Author = token["author"].ToString();
            }
            catch (Exception ex)
            {
                _logger.LogError(new EventId(ex.HResult), ex, "---GetNewsContnt Exception---");
            }
        }
        async void LoadData(List <TrackInfo> TrackInfos)
        {
            await Task.Run(() =>
            {
                ListItemSourceObj = new List <CameraSnapPerson>();
                int row           = 0;
                foreach (var item in TrackInfos)
                {
                    CameraSnapPerson csp = new CameraSnapPerson();

                    csp.RowNumber            = ++row;
                    csp.CameraInfo           = new Camera();
                    csp.CameraInfo.Name      = item.Name;
                    csp.Datetime             = item.Capimg != null ? DateTimeConvert.LongTimeToString(item.Capimg[0].Time) : "";
                    csp.CameraInfo.Location  = item.Channel_address;
                    csp.CameraInfo.Longitude = item.Longitude;
                    csp.CameraInfo.Latitude  = item.Latitude;
                    ListItemSourceObj.Add(csp);
                }
                ListItemSourceObj.Add(null);
            }).ConfigureAwait(false);
        }
Exemplo n.º 21
0
        /// <summary>
        /// 获取K线
        /// </summary>
        /// <param name="time"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        public List <CoinKLineData> GetKLine(string coin, string quote, string time, int size)
        {
            try
            {
                var http   = new WebClient();
                var result = http.DownloadString($"https://api.huobiasia.vip/market/history/kline?period={time}&size={size}&symbol={coin + quote}");

                if (string.IsNullOrWhiteSpace(result))
                {
                    return(null);
                }

                var jobject = JObject.Parse(result);

                var json = jobject?["data"];

                var kline = json?.Select(item => new CoinKLineData
                {
                    Id         = Guid.NewGuid().ToString(),
                    IsDelete   = 0,
                    Platform   = (int)Platform.Huobi,
                    Coin       = coin,
                    DataTime   = DateTimeConvert.ConvertDateTime(item["id"].ToString()),
                    Open       = Convert.ToDouble(item["open"]),
                    Close      = Convert.ToDouble(item["close"]),
                    Low        = Convert.ToDouble(item["low"]),
                    High       = Convert.ToDouble(item["high"]),
                    CreateTime = DateTime.Now
                }).ToList();
                return(kline);
            }
            catch (WebException ex)
            {
                _logger.LogError(new EventId(ex.HResult), ex, $"---GetKLine {DateTime.Now}---");
                throw;
            }
        }
Exemplo n.º 22
0
 /// <summary>
 /// 备份文件
 /// </summary>
 /// <param name="path"></param>
 /// <param name="newpath"></param>
 private void BackupFile(string path, string newpath, string md5)
 {
     using (var db = new Muse())
     {
         try
         {
             if (DirTool.Create(DirTool.GetFilePath(newpath)))
             {
                 string lastwritetime = DateTimeConvert.StandardString(File.GetLastWriteTime(path));
                 File.Copy(path, newpath, true);
                 db.Add(new BackupFiles()
                 {
                     FullPath       = path,
                     BackupFullPath = newpath,
                     Size           = FileTool.Size(path),
                     BackupTime     = DateTimeConvert.StandardString(DateTime.Now),
                     LastWriteTime  = lastwritetime,
                     Md5            = md5,
                 });
             }
         }
         catch (Exception e) { }
     }
 }
Exemplo n.º 23
0
        /// <summary>
        /// 确定按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDetermineAddTemplate_Click(object sender, RoutedEventArgs e)
        {
            List <ErrorInfo> ListErrorInfo;

            ThriftServiceNameSpace.ThriftService thirft = new ThriftServiceNameSpace.ThriftService();

            try
            {
                /**
                 * 姓名
                 * 性别
                 * 年龄
                 * 类型:普通、黑名单
                 * 备注
                 * 1张主照片
                 * 4张附属照片 均为模板照片,指向一个人
                 * **/

                #region 验证
                if (string.IsNullOrEmpty(txtName.Text.Trim()))
                {
                    MyMessage.showYes("名称必填!");
                    return;
                }
                if (string.IsNullOrEmpty(txtAge.Text.Trim()))
                {
                    MyMessage.showYes("年龄必填!");
                    return;
                }
                #endregion

                #region 添加输入项

                tIPViewModel._FaceObj.TcUuid = guid;
                tIPViewModel._FaceObj.TcName = txtName.Text.Trim();
                string message = _validationRule.intValidationRule(this.txtAge.Text.Trim());
                if (message != "")
                {
                    MyMessage.showYes(message);
                    return;
                }
                tIPViewModel._FaceObj.NAge = int.Parse(txtAge.Text.Trim());
                tIPViewModel._FaceObj.NSex = combSex.SelectedIndex;
                //暂时没确定
                tIPViewModel._FaceObj.NType =
                    (GlobalCache.FaceTypeList.Cast <STypeInfo>().FirstOrDefault(x => x.Description == tIPViewModel.Type[combType.SelectedIndex]) ?? new STypeInfo()).Type;
                tIPViewModel._FaceObj.TcRemarks = txtRemarks.Text.Trim();
                #endregion

                tIPViewModel._FaceObj.Tmplate = new List <FaceObjTemplate>();
                //遍历照片存放数组,必须添加至少一张照片
                var isExistPhoto = templateData.FirstOrDefault(x => x != null) ?? null;
                if (isExistPhoto == null)
                {
                    MyMessage.showYes("至少要一张照片才能注册成功!");
                    return;
                }

                int nj = -1;

                for (int i = 0; i < 5; i++)
                {
                    if (templateData[i] != null)
                    {
                        FaceObjTemplate templateObj = new FaceObjTemplate();
                        templateObj.TcUuid  = System.Guid.NewGuid().ToString().Replace("-", "");;
                        templateObj.TcObjid = tIPViewModel._FaceObj.TcUuid;

                        //判断前面是不是有空位置,有那么排到前面去
                        for (int j = 0; j < i; j++)
                        {
                            if (templateData[j] == null)
                            {
                                templateObj.NIndex = j;
                                nj = j;
                                break;
                            }
                        }
                        if (templateObj.NIndex == 0)
                        {
                            if (nj == -1)
                            {
                                templateObj.NIndex = i;
                            }
                            else
                            {
                                templateObj.NIndex = nj;
                            }
                        }
                        //时间
                        long addDateTime =
                            DateTimeConvert.ToLongFromSubstract(DateTime.Now, new DateTime(1970, 1, 1));

                        templateObj.DTm = addDateTime;//模板时间
                        if (tIPViewModel._FaceObj.DTm == 0)
                        {
                            tIPViewModel._FaceObj.DTm = addDateTime;
                        }

                        if (_mainTemplateStream != null)
                        {
                            if (_mainTemplateStream.Equals(templateData[i]))
                            {
                                tIPViewModel._FaceObj.NMain_ftID = i;//主照片ID
                            }
                            else if (i == tIPViewModel._FaceObj.NMain_ftID)
                            {
                                tIPViewModel._FaceObj.NMain_ftID = templateObj.NIndex;//主照片ID
                            }
                        }
                        else
                        {
                            tIPViewModel._FaceObj.NMain_ftID = 0;//主模板ID为 0
                        }
                        templateObj.Img = templateData[i];
                        tIPViewModel._FaceObj.Tmplate.Add(templateObj);//Add Template to db.face_template/db.face_object

                        if (nj != -1)
                        {
                            templateData[nj] = templateData[i];
                            templateData[i]  = null;
                            nj = -1;
                        }
                    }
                }
                //具体的操作(添加,修改)
                if (tIPViewModel.Title.Contains("添加"))
                {
                    ListErrorInfo = thirft.AddFaceObj(tIPViewModel._FaceObj);
                }
                else
                {
                    ListErrorInfo = thirft.ModifyFaceObj(tIPViewModel.Id, tIPViewModel._FaceObj);
                }
                //判断是否成功
                if (ListErrorInfo.Count == 0)//判断成功,提示成功
                {
                    MyMessage.showYes("成功!");
                    this.Close();
                }
                else//添加不成功,显示错误
                {
                    if ("Add Face To Compare Server Failed, Because img repeat".Equals(ListErrorInfo[0].ID))
                    {
                        MyMessage.Show("模板照片已存在,请取消并重新添加模板");
                        return;
                    }
                    else
                    {
                        MyMessage.showYes("添加模板ID:" + ListErrorInfo[0].ID + "失败,\n失败信息:" + ListErrorInfo[0].ErrCode);
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger <TempleteInfoPop> .Log.Error("AddTemplate:btnRemove_Click", ex);
            }
        }
Exemplo n.º 24
0
        public ActionResult recipeDetail(Guid id)
        {
            double rate      = 0;
            int    rateCount = 0;
            var    recipe    = db.recipe.Find(id);

            if (recipe.enabled == false)
            {
                return(RedirectToAction("index", "home"));
            }
            var type = recipe.type;

            if (type != "Free")
            {
                if (Session["userId"] != null)
                {
                    var u = db.user.Find(Session["userId"]);
                    if (u.expireDate < DateTime.Now && u.role != "ROLE_ADMIN")
                    {
                        return(RedirectToAction("error", "home", new { msg = "Only vip user can see this recipe, go to profile to buy vip access!" }));
                    }
                }
                else
                {
                    return(RedirectToAction("error", "home", new { msg = "Only vip user can see this recipe, go to profile to buy vip access!" }));
                }
            }
            ViewBag.manager = db.user.Find(recipe.manager).email;
            var srate = db.ratting.Where(m => m.recipe_id == recipe.id).Select(m => m.rate);

            if (srate.Count() > 0)
            {
                rate      = srate.Average();
                rateCount = srate.Count();
            }
            //random 3 recipe with same category
            var relate = db.recipe.Where(m => m.category == recipe.category).OrderBy(x => Guid.NewGuid()).Take(3);

            var comment = db.feedBack.Where(m => m.recipe_id == recipe.id).ToArray();

            foreach (var item in comment)
            {
                item.ago  = DateTimeConvert.TimeAgo(item.createAt);
                item.name = db.user.Find(item.own).name;
            }
            ViewBag.comment   = comment;
            ViewBag.rateCount = rateCount;
            ViewBag.rate      = rate;
            ViewBag.recipeId  = id;
            ViewBag.relate    = relate;
            //view count
            if (Request.Cookies["ViewedPage"] != null)
            {
                if (Request.Cookies["ViewedPage"][string.Format("pId_{0}", id)] == null)
                {
                    HttpCookie cookie = (HttpCookie)Request.Cookies["ViewedPage"];
                    cookie[string.Format("pId_{0}", id)] = "1";
                    cookie.Expires = DateTime.Now.AddDays(1);
                    Response.Cookies.Add(cookie);
                    recipe.viewCount = recipe.viewCount + 1;
                    db.SaveChanges();
                }
            }
            else
            {
                HttpCookie cookie = new HttpCookie("ViewedPage");
                cookie[string.Format("pId_{0}", id)] = "1";
                cookie.Expires = DateTime.Now.AddDays(1);
                Response.Cookies.Add(cookie);

                recipe.viewCount = recipe.viewCount + 1;
                db.SaveChanges();
            }
            return(View(recipe));
        }
Exemplo n.º 25
0
        /// <summary>
        /// 推送一条
        /// </summary>
        /// <param name="signleObj"></param>
        public static int SendOneResultInfo(MyCmpFaceLogWidthImgModel signleObj)
        {
            int res = -1;

            ThriftServiceNameSpace.ThriftService thirft = new ThriftServiceNameSpace.ThriftService();
            try
            {
                RealtimeCmpInfoLBS newRci = new RealtimeCmpInfoLBS();
                newRci.CapID     = signleObj.ID;
                newRci.ObjID     = signleObj.tcUuid;
                newRci.Name      = signleObj.name;
                newRci.Channel   = signleObj.channelName;
                newRci.Longitude = signleObj.Longitude;
                newRci.Latitude  = signleObj.Latitude;
                newRci.Address   = signleObj.Address;
                List <byte[]> snapImgStream = thirft.QueryCmpLogImageH(
                    signleObj.ID,
                    DataConvert.DatetimeConvertToStr.ConvertToString(Convert.ToDateTime(signleObj.time), "yyyyMMdd")
                    );
                if (snapImgStream.Count > 0 && snapImgStream[0].Length > 0)
                {
                    newRci.CapImg = snapImgStream[0];
                }
                List <FaceObj> templateList = thirft.QueryFaceObj(signleObj.tcUuid);
                if (templateList.Count > 0)
                {
                    newRci.Name += "|" + templateList[0].TcRemarks;
                    if (templateList[0].NMain_ftID > 0)
                    {
                        newRci.ObjImg = templateList[0].Tmplate.FirstOrDefault(x => x.NIndex == templateList[0].NMain_ftID - 1).Img;
                    }
                    else
                    {
                        newRci.ObjImg = templateList[0].Tmplate[0].Img;
                    }
                }

                #region old
                //RealtimeCmpInfo info = new RealtimeCmpInfo();
                //info.CapID = signleObj.ID;
                //info.ObjID = signleObj.tcUuid;
                //info.Name = signleObj.name;
                //info.Channel = signleObj.channelName;
                //List<byte[]> listImageBytes = thirft.QueryCmpLogImageH(signleObj.ID, DataConvert.DatetimeConvertToStr.ConvertToString(Convert.ToDateTime(signleObj.time), "yyyyMMdd"));
                //if (listImageBytes.Count > 0 && listImageBytes[0].Length > 0)
                //{
                //    info.CapImg = listImageBytes[0];
                //    Console.WriteLine("抓拍照片大小为:" + listImageBytes[0].Length);
                //}
                //List<FaceObj> ListFaceObj = thirft.QueryFaceObj(signleObj.tcUuid);
                //if (ListFaceObj.Count > 0)
                //{
                //    info.Name += "|" + ListFaceObj[0].TcRemarks;
                //    if (ListFaceObj[0].NMain_ftID > 0)
                //    {
                //        for (int i = 0; i < ListFaceObj[0].Tmplate.Count; i++)//遍历查找主模板照片
                //        {
                //            if (ListFaceObj[0].NMain_ftID - 1 == ListFaceObj[0].Tmplate[i].NIndex)
                //            {
                //                info.ObjImg = ListFaceObj[0].Tmplate[i].Img;
                //                Console.WriteLine("模版照片大小为:" + ListFaceObj[0].Tmplate[i].Img.Length);
                //            }
                //        }
                //    }
                //    else
                //    {
                //        info.ObjImg = ListFaceObj[0].Tmplate[0].Img;
                //        Console.WriteLine("模版照片大小为:" + ListFaceObj[0].Tmplate[0].Img.Length);
                //    }
                //}
                #endregion
                newRci.Time =
                    DateTimeConvert.ToLongFromSubstract(Convert.ToDateTime(signleObj.time), new DateTime(1970, 1, 1));
                //info.Type = cORViewModel.Type.IndexOf(cmpface.type) + 1;
                newRci.Type  = 2;
                newRci.Score = signleObj.score;
                res          = SendCmpToClient(newRci);
            }
            catch (Exception ex)
            {
                MB_MODULES.Views.MyMessage.showYes(ex.Message);
            }
            return(res);
        }
Exemplo n.º 26
0
        public static IEnumerable <object[]> BetweenOrEqualTo <T>(DateTimeConvert <T> dateTimeConvert)
        {
            // all equal
            yield return(new object[] { dateTimeConvert(2000, 10, 10, 10, 10, 10, 10), dateTimeConvert(2000, 10, 10, 10, 10, 10, 10), dateTimeConvert(2000, 10, 10, 10, 10, 10, 10), TimeComparison.All, true });

            yield return(new object[] { dateTimeConvert(2000, 10, 10, 10, 10, 10, 10), dateTimeConvert(2000, 10, 10, 10, 10, 10, 10), dateTimeConvert(2000, 10, 10, 10, 10, 10, 10), TimeComparison.JustDate, true });

            yield return(new object[] { dateTimeConvert(2000, 10, 10, 10, 10, 10, 10), dateTimeConvert(2000, 10, 10, 10, 10, 10, 10), dateTimeConvert(2000, 10, 10, 10, 10, 10, 10), TimeComparison.JustTime, true });

            // all between
            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 10, 10, 10, 10, 10), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.All, true });

            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 10, 10, 10, 10, 10), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.JustDate, true });

            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 10, 10, 10, 10, 10), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.JustTime, true });

            // dates equal min
            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 9, 10, 10, 10, 10), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.All, true });

            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 9, 10, 10, 10, 10), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.JustDate, true });

            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 9, 10, 10, 10, 10), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.JustTime, true });

            // dates equal max
            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 11, 10, 10, 10, 10), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.All, true });

            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 11, 10, 10, 10, 10), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.JustDate, true });

            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 11, 10, 10, 10, 10), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.JustTime, true });

            // time equal min
            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 10, 10, 10, 10, 9), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.All, true });

            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 10, 10, 10, 10, 9), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.JustDate, true });

            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 10, 10, 10, 10, 9), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.JustTime, true });

            // time equal max
            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 10, 10, 10, 10, 11), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.All, true });

            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 10, 10, 10, 10, 11), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.JustDate, true });

            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 10, 10, 10, 10, 11), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.JustTime, true });

            // dates before min
            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 8, 10, 10, 10, 10), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.All, false });

            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 8, 10, 10, 10, 10), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.JustDate, false });

            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 8, 10, 10, 10, 10), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.JustTime, true });

            // dates after max
            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 12, 10, 10, 10, 10), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.All, false });

            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 12, 10, 10, 10, 10), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.JustDate, false });

            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 12, 10, 10, 10, 10), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.JustTime, true });

            // time before min
            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 10, 10, 10, 10, 8), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.All, true });

            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 10, 10, 10, 10, 8), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.JustDate, true });

            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 10, 10, 10, 10, 8), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.JustTime, false });

            // time after max
            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 10, 10, 10, 10, 12), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.All, true });

            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 10, 10, 10, 10, 12), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.JustDate, true });

            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 10, 10, 10, 10, 12), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.JustTime, false });

            // all before min
            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 8, 10, 10, 10, 8), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.All, false });

            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 8, 10, 10, 10, 8), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.JustDate, false });

            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 8, 10, 10, 10, 8), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.JustTime, false });

            // all after max
            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 12, 10, 10, 10, 12), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.All, false });

            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 12, 10, 10, 10, 12), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.JustDate, false });

            yield return(new object[] { dateTimeConvert(2000, 10, 9, 10, 10, 10, 9), dateTimeConvert(2000, 10, 12, 10, 10, 10, 12), dateTimeConvert(2000, 10, 11, 10, 10, 10, 11), TimeComparison.JustTime, false });
        }
Exemplo n.º 27
0
        /// <summary>
        /// 查询方法
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="cORViewModel"></param>
        private void GetAllInfo(int pageIndex, CompOfRecordsViewModel cORViewModel)
        {
            cORViewModel.LoadingVisiblity = Visibility.Visible;

            try
            {
                int _pageSize = cORViewModel.CompOfRecordsValueObj.PageSize;

                List <int> dailyPageSum = new List <int>();
                int        pageSum      = 0;
                int        index        = 0;
                List <MyCapFaceLogWithImg> listMyCapFaceLogWithImg = new List <MyCapFaceLogWithImg>();
                List <SCountInfo>          resultCount             = new List <SCountInfo>();

                if (GlobalCache.AppType == 0)//筛选端
                {
                    resultCount = thirft.QueryCmpRecordTotalCountH(cORViewModel.CompOfRecordsValueObj) ?? null;
                }
                else//接收端
                {
                    resultCount = thirft.QueryCmpRecordTotalCountHSX(cORViewModel.CompOfRecordsValueObj, GlobalCache.AppRegion) ?? null;
                }

                if (resultCount == null)
                {
                    return;
                }

                //按日拆分后的数据
                resultCount[0].Dayarr.Reverse();
                foreach (SCountInfoOneDay item in resultCount[0].Dayarr)
                {
                    pageSum += (item.Count / _pageSize + (item.Count % _pageSize == 0 ? 0 : 1));
                    dailyPageSum.Add(pageSum);
                }

                cORViewModel.CurrPage     = pageIndex;//currentPageIndex
                cORViewModel.MaxPage      = pageSum;
                cORViewModel.MaxDataCount = resultCount[0].Count;

                //根据页数判断是属于哪一天
                for (int i = 0; i < dailyPageSum.Count; i++)
                {
                    if (pageIndex <= dailyPageSum[i])
                    {
                        index = i;
                        //修改当前的时间 和 最大的结果数量
                        DateTime dt1 = Convert.ToDateTime(resultCount[0].Dayarr[i].Daystr.Insert(6, "/").Insert(4, "/"));

                        long _date = DateTimeConvert.ToLongFromSubstract(dt1, new DateTime(1970, 1, 1));

                        if (_date > cORViewModel.CompOfRecordsValueObj.StartDayValue)
                        {
                            cORViewModel.CompOfRecordsValueObj.StartDayValue = _date;
                        }
                        if (pageIndex != cORViewModel.MaxPage)
                        {
                            long endTime      = _date + 24 * 60 * 60;
                            var  todayEndtime = DateTimeConvert.ToLongFromSubstract(dt1.AddDays(1), new DateTime(1970, 1, 1));

                            if (endTime > todayEndtime)
                            {
                                endTime = todayEndtime;
                            }
                            cORViewModel.CompOfRecordsValueObj.EndDayValue = endTime;
                        }
                        cORViewModel.CompOfRecordsValueObj.MaxDataCount = resultCount[0].Dayarr[i].Count;
                        break;
                    }
                }

                if (pageIndex > 1)
                {
                    int pageTem = 0;
                    if (index == 0)
                    {
                        pageTem = 0;
                    }
                    else
                    {
                        pageTem = dailyPageSum[index - 1];
                    }
                    cORViewModel.CompOfRecordsValueObj.PageStartRow = cORViewModel.CompOfRecordsValueObj.MaxDataCount - ((pageIndex - pageTem) * _pageSize);
                    if (cORViewModel.CompOfRecordsValueObj.PageStartRow < 0)
                    {
                        cORViewModel.CompOfRecordsValueObj.PageStartRow = 0;
                    }
                }
                else
                {
                    cORViewModel.CompOfRecordsValueObj.PageStartRow = cORViewModel.CompOfRecordsValueObj.MaxDataCount - _pageSize;
                    if (cORViewModel.CompOfRecordsValueObj.PageStartRow < 0)
                    {
                        cORViewModel.CompOfRecordsValueObj.PageStartRow = 0;
                    }
                }

                int countTem = 0;
                resultCount[0].Dayarr.Reverse();
                for (int n = 0; n <= index; n++)
                {
                    var dayary = resultCount[0].Dayarr[resultCount[0].Dayarr.Count - 1 - n].Count;
                    countTem += dayary;
                }

                cORViewModel.CompOfRecordsValueObj.MaxDataCount = countTem;
                if (GlobalCache.AppType == 0)
                {
                    cORViewModel.ListMyCmpFaceLogWidthImgs = thirft.QueryCmpLog(cORViewModel.CompOfRecordsValueObj);
                }
                else
                {
                    cORViewModel.ListMyCmpFaceLogWidthImgs = thirft.QueryCmpLogSX(cORViewModel.CompOfRecordsValueObj, GlobalCache.AppRegion);
                }
            }
            catch (Exception ex)
            {
                Logger <CompOfRecordsViewModel> .Log.Error("GetAllInfo(int pageIndex, CompOfRecordsViewModel cORViewModel)", ex);
            }
            finally
            {
                cORViewModel.LoadingVisiblity = Visibility.Collapsed;
            }
        }
 public void FromUnixTimestamp_Test()
 {
     Assert.Equal(DateTimeConvert.FromUnixTimestamp(0), new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc));
 }
 public void ToUnixTimestamp_Test()
 {
     Assert.Equal(DateTimeConvert.ToUnixTimestamp(new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc)), 0);
 }
        async void SearchResult(object sender, RoutedEventArgs e, ObservableCollection <PointLatLngImg> Points)
        {
            LoadingVisiblity = Visibility.Visible;

            await Task.Run(() =>
            {
                long start = DateTimeConvert.ToTotalSeconds(true, StartDay, StartHour, StartMinute);
                long end   = DateTimeConvert.ToTotalSeconds(false, EndDay, EndHour, EndMinute);

                try
                {
                    List <TrackInfo> TrackInfos = new List <TrackInfo>();
                    if (SnapPersonInfo != null)
                    {
                        TrackInfos = AsyncSelectTrack(SnapPersonInfo.SnapId, SnapPersonInfo.PhotoByteArray, start, end).Result;
                        //thirft.QueryTrackPlayback(SnapPersonInfo.SnapId, SnapPersonInfo.PhotoByteArray, start, end);
                    }
                    else
                    {
                        comServer.SocketOpter.ExceptionMsgFromSTAThread("请添加照片");
                    }

                    this.LoadData(TrackInfos);//async

                    foreach (TrackInfo item in TrackInfos)
                    {
                        PointLatLngImg ipoint = new PointLatLngImg();
                        if (!string.IsNullOrEmpty(item.Latitude) && !string.IsNullOrEmpty(item.Longitude))
                        {
                            ipoint.Point = new GMap.NET.PointLatLng(Convert.ToDouble(item.Latitude), Convert.ToDouble(item.Longitude));
                        }
                        ipoint.Img                = ImageConvert.ToBitmapImage(SnapPersonInfo.PhotoByteArray);
                        ipoint.ImgVisibility      = Visibility.Visible;
                        ipoint.ImgframeVisibility = Visibility.Visible;
                        Points.Add(ipoint);
                    }

                    if (TrackInfos.Count > 0)
                    {
                        this.MainMap.IsDisplayPolyline = true;
                        this.MainMap.Points            = Points;

                        if (MainMap.Points.Count > 0)
                        {
                            MainMap.CurrentPosition = MainMap.Points[MainMap.Points.Count - 1].Point;
                        }
                        else
                        {
                            MainMap.CurrentPosition = new GMap.NET.PointLatLng(GlobalCache.Latitude, GlobalCache.Longitude);
                        }
                    }
                    else
                    {
                        this.MainMap.IsDisplayPolyline = true;
                        this.MainMap.Points            = new ObservableCollection <PointLatLngImg>();
                    }
                }
                catch (Exception ex)
                {
                    Logger <MainTraceAnalysisView> .Log.Error("SearchResult", ex);
                }
                finally
                {
                    LoadingVisiblity = Visibility.Collapsed;
                }
            });
        }