/// <summary> /// 加载煤矿基本信息,用于绑定煤矿名称的下拉列表,用于插入和修改 /// </summary> public void QueryJBXX() { DataBLL bll = new DataBLL(); Response.Write(JsonConvert.SerializeObject(bll.QuereyJBXXSimple())); Response.End(); }
public ActionResult RecuperaSenhaViewer(EsqueceuSenha esqueceuSenha) { if (ModelState.IsValid) { //Concatena Data; var appData = new DataBLL(); esqueceuSenha.Data_Nascimento = appData.concatenaData(esqueceuSenha.diaNascimento, esqueceuSenha.mesNascimento, esqueceuSenha.anoNascimento); var appCPF = new CPFBLL(); esqueceuSenha.CPF = appCPF.DataBaseCPF(esqueceuSenha.CPF); /*esqueceuSenha.Data_Nascimento = esqueceuSenha.anoNascimento; esqueceuSenha.Data_Nascimento += "-"; esqueceuSenha.Data_Nascimento += esqueceuSenha.mesNascimento; esqueceuSenha.Data_Nascimento += "-"; esqueceuSenha.Data_Nascimento += esqueceuSenha.diaNascimento;*/ var professorDML = new ProfessoresDML(); int loginID = professorDML.VerificaProfessor(esqueceuSenha); if (loginID != 0) { var loginDML = new LoginDML(); esqueceuSenha.Senha = loginDML.RecuperaSenha(esqueceuSenha); ViewData["Senha"] = esqueceuSenha.Senha; return View(esqueceuSenha); } else { return RedirectToAction("EsqueceuSenhaViewer"); } } return View(esqueceuSenha); }
public override void OnViewMessageReceived(string key, object obj) { switch (key) { case CoreSettings.LoadResources: Task.Run(async() => { var errorLogs = await DataBLL.GetLogFiles <ErrorLog>(); if (errorLogs.Error == null) { ErrorLogs = errorLogs.Response.ToObservable <ErrorLog>(); } var analyticLogs = await DataBLL.GetLogFiles <AnalyticLog>(); if (analyticLogs.Error == null) { AnalyticLogs = analyticLogs.Response.ToObservable <AnalyticLog>(); } }); break; case CoreSettings.RefreshAppoints: GetDbAppointments(null); break; } }
public void ReturnRtCurverDatas(string mineCode, string time, string sensorCodes, string timeRound) { try { DataBLL bll = new DataBLL(); DateTime dt = Convert.ToDateTime(time); DataTableCollection dts = bll.RtCurver(mineCode, sensorCodes, dt, timeRound); string json = "[]"; //在对DATATABLE进行序列化的时候,规范日期格式 IsoDateTimeConverter timeConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" }; if (dts != null && dts.Count > 0) { json = JsonConvert.SerializeObject(dts, Formatting.Indented, timeConverter); } Response.Write(json); } catch (Exception e) { } Response.End(); }
public override void OnViewMessageReceived(string key, object obj) { switch (key) { case CoreSettings.LoadResources: var result = DataBLL.GetCarouselData(); if (result.Error == null) { ItemSource = result.Response.ToObservable <CarouselBindingObject>(); } CardCollection = DataBLL.GetCardViewList().ToObservable <CardViewContent>(); break; case CoreSettings.ReleaseResources: break; case CoreSettings.PhoneCallBack: Device.BeginInvokeOnMainThread(() => { DialogPrompt.ShowMessage(new Prompt() { Title = "Completed", Message = "Phone call action has been complete and action logged" }); }); break; } }
/// <summary> /// 加载煤矿基本信息,用于绑定煤矿名称的下拉列表,用于查询 /// </summary> public void QueryJBXXAll() { DataBLL bll = new DataBLL(); Response.Write(JsonConvert.SerializeObject(bll.QuereyJBXXSimple()).Insert(1, "{\"id\":\"\",\"minecode\":\"\",\"simplename\":\"全部\"},")); Response.End(); }
public override void OnViewMessageReceived(string key, object obj) { switch (key) { case CoreSettings.LoadResources: Task.Run(async() => { var result = await DataBLL.GetFileData <Animal>("animal"); if (result.Error == null) { AnimalDescription = result.Response?.Description; } }); break; case CoreSettings.ReleaseResources: Task.Run(async() => { await DataBLL.SaveFileData <Animal>("animal", new Animal() { Description = "Dog" }); }); break; } }
private void ClearErrorEntriesMethod(object obj) { Task.Run(async() => { var result = await DataBLL.ClearLogFiles(LogType.Error); if (result.Success) { ErrorLogs = new ObservableCollection <ErrorLog>(); } }); }
public void ProcessRequest(HttpContext context) { HttpResponse response = HttpContext.Current.Response; response.ClearContent(); response.ClearHeaders(); response.Clear(); if (HttpContext.Current.Request.QueryString.GetValues(null)?.Contains("record") ?? false) { response.StatusCode = 404; return; } long recordID = Convert.ToInt64(HttpContext.Current.Request.QueryString["record"]); Record record = new DataBLL().GetRecord(recordID); if (record == null || !record.IsFileSafe()) { response.StatusCode = 404; } else { if (record.fileExtension.Equals(".jpeg")) { response.ContentType = "image/jpeg"; } else if (record.fileExtension.Equals(".jpg")) { response.ContentType = "image/jpg"; } else if (record.fileExtension.Equals(".png")) { response.ContentType = "image/png"; } else if (record.fileExtension.Equals(".txt")) { response.ContentType = "text/plain"; } else if (record.fileExtension.Equals(".csv")) { response.ContentType = "text/csv"; } else if (record.fileExtension.Equals(".mp4")) { response.ContentType = "video/mp4"; } response.AddHeader("Content-Disposition", "attachment; filename=\"" + record.id + record.fileExtension + "\""); response.WriteFile(record.fullpath); } response.Flush(); response.Close(); }
private void CreateErrorEntryMethod(object obj) { Task.Run(async() => { DataBLL.CreateFictiousError(); var result = await DataBLL.GetLogFiles <ErrorLog>(); if (result.Error == null) { ErrorLogs = result.Response.ToObservable <ErrorLog>(); } }); }
/// <summary> /// 查询日志 /// </summary> /// <param name="BeingTime">开始时间</param> /// <param name="EndTime">结束时间</param> /// <returns></returns> public string ProcessLogInfoQuery(string BeingTime, string EndTime, string ProcessUserName) { DataBLL bll = new DataBLL(); DataTable dt = bll.ProcessLogInfo_Query(BeingTime, EndTime, ProcessUserName); IsoDateTimeConverter timeConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" }; return("{\"total\":" + dt.Rows.Count.ToString() + ",\"rows\":" + JsonConvert.SerializeObject(dt, Formatting.Indented, timeConverter).Replace("shine998", "<br>") + "}"); }
private void SearchCommandMethod(object obj) { if (obj != null) { var peopleResults = DataBLL.GetPeople((string)obj); if (peopleResults.Error == null) { People = peopleResults.Response.ToObservable(); } } }
/// <summary> /// 使用nodeID nodeName参数刷新 listView_Properties /// </summary> /// <param name="nodeID_str"></param> /// <param name="nodeName"></param> private void Refresh_listView_Properties(string nodeID_str, string nodeName) { DataBLL dataBLL = new DataBLL(); ModelLayer.Nodes nodeSel = null; int nodeID = System.Convert.ToInt32(nodeID_str); nodeSel = dataBLL.getNodeInfo(nodeID);//获取node的详细信息 nodeSel.nodeName = nodeName; nodeSel.nodeID = nodeID; listView_AddItems(listView_Properties, nodeSel.getNodeDic()); }
public override void OnViewMessageReceived(string key, object obj) { switch (key) { case CoreSettings.LoadResources: var peopleResults = DataBLL.GetPeople(null); if (peopleResults.Error == null) { People = peopleResults.Response.ToObservable(); } break; } }
private async Task SaveToDatabase() { var result = await DataBLL.SaveAppointment(this.Appt); if (result.Error == null) { SendViewMessage <DataExampleViewModel>(CoreSettings.RefreshAppoints, this.Appt); Appt = new Appointment(); Device.BeginInvokeOnMainThread(async() => { await CoreSettings.AppNav.PopAsync(); }); } }
/// <summary> /// 处理查询命令发送状态的请求 /// </summary> /// <returns></returns> private string HandleQueryCommandStatusRequest() { string ret = ""; using (var bll = new CommandBLL()) { var cmd = bll.Find(f => f.id == ParseInt(data)); if (null == cmd) { ret = ResponseMessage(-1, "No such command record exists."); } else { byte status = cmd.Status.Value; CommandStatus state = (CommandStatus)status; if (state == CommandStatus.Returned) { using (var dbll = new DataBLL()) { var list = dbll.FindList <TB_HISTORIES>(f => f.command_id.Equals(cmd.Command) && f.terminal_id.Equals(cmd.DestinationNo) && f.receive_time > cmd.ActualSendTime, "receive_time", true); var data = list.FirstOrDefault(); var desc = CommandUtility.GetCommandStatus(state); if (null != data) { desc += GetCommandData(data); } ret = ResponseMessage(status, desc); } } else { ret = ResponseMessage(status, CommandUtility.GetCommandStatus(state)); if (cmd.Command == "0x4000" && (state == CommandStatus.SentBySMS || state == CommandStatus.SentByTCP)) { // 将重置终端连接的命令状态改成不需要回复的状态 bll.Update(f => f.id == cmd.id, act => { act.Status = (byte)CommandStatus.NotNeedReturn; }); } } } } return(ret); }
public void ReturnSwitchDatas(string mineCode, string sensorCodes, string BeginTime, string EndTime) { DataBLL bll = new DataBLL(); DataTableCollection dts = bll.ReturnSwitchDatas(mineCode, sensorCodes, BeginTime, EndTime); string json = "[]"; //在对DATATABLE进行序列化的时候,规范日期格式 IsoDateTimeConverter timeConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" }; if (dts != null && dts.Count > 0) { json = JsonConvert.SerializeObject(dts, Formatting.Indented, timeConverter); } Response.Write(json); Response.End(); }
public SimpleViewModel() { PushButtonLabel = "Register Push Notification"; var radioOptions = new List <string>( new string[] { "Blue", "Red", "Green" } ); RadioOptions = radioOptions.ToObservable <string>(); var stateResults = DataBLL.GetAllStates(); if (stateResults.Error == null) { States = stateResults.Response.ToObservable(); } DialogClick = new CoreCommand(DialogClickMethod); NotificationClick = new CoreCommand(NotificationClickMethod); OverlayClick = new CoreCommand(OverlayClickMethod); Blur = new CoreCommand(BlurNewMethod); CreateCalendar = new CoreCommand(CreateCalendarMethod); PushRegister = new CoreCommand(PushRegisterMethod); ShowSnack = new CoreCommand(ShowSnackMethod); PlaySound = new CoreCommand(PlaySoundMethod); CommTest = new CoreCommand(CommTestMethod); ContextMenu = new CoreCommand(ContextMenuMethod); BindingTextChanged = new CoreCommand(BindingTextChangedMethod); SendSMS = new CoreCommand(SendSMSMethod); SendEmail = new CoreCommand(SendEmailMethod); MakeCall = new CoreCommand(MakeCallMethod); MakeCallEvent = new CoreCommand(MakeCallEventMethod); FABClicked = new CoreCommand(FABClickedMethod); ClickEvent = new CoreCommand((obj) => { ClickCount++; }); /* * This is an example of command validators. ValidateTextFields is part of the CommonCore * extensions and validators can be chained with more complex rules for numbers and dates */ CanExecute = new CoreCommand(CanExecuteMethod, () => { return(this.ValidateTextFields(this.FirstName)); }, this); }
/// <summary> /// 获取人员实时轨迹 /// </summary> /// <param name="MineCode">煤矿编号</param> /// <param name="JobCardCode">人员标示卡号</param> public void GetRTTrack(string MineCode, string JobCardCode) { DataBLL bll = new DataBLL(); string ResponseText = "[]"; IsoDateTimeConverter timeConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" }; DataTable dt = bll.GetRTTrack(MineCode, JobCardCode); if (dt != null && dt.Rows.Count > 0) { ResponseText = JsonConvert.SerializeObject(dt, Formatting.Indented, timeConverter); } ResponseText = "{\"total\":" + dt.Rows.Count.ToString() + ",\"rows\":" + ResponseText + "}"; Response.Write(ResponseText); Response.End(); }
/// <summary> /// 双击系统树节点 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void sysTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { if (e.Node.LastNode == null) { DataBLL dataBLL = new DataBLL(); ModelLayer.Nodes nodeSel = null; int nodeID = System.Convert.ToInt32(e.Node.Name); nodeSel = dataBLL.getNodeInfo(nodeID);//获取node的详细信息 device,signalType,chNO nodeSel.nodeName = e.Node.Text; nodeSel.nodeID = nodeID; listView_AddItems(listView_Properties, nodeSel.getNodeDic()); if (nodeSel.device == null || nodeSel.device == "") { //没有nodeinfo 使用自定义layoutpanel布局 MyUserControl.MyTableLayoutPanel tlp = new MyUserControl.MyTableLayoutPanel(); tlp.SetNodeConfigPanel(nodeID, nodeSel.nodeName); tlp.save.Click += new System.EventHandler(this.tpl_save_Click); Ctab_MainTab.PageAdd(tlp, nodeID, nodeSel.nodeName, tabPageList); } else { if (nodeSel.device.ToUpper() == "WIFI") { //有nodeinfo 添加曲线图 MyUserControl.TCPWave tcpWave = new MyUserControl.TCPWave(); tcpWave.Dock = DockStyle.Fill; Ctab_MainTab.PageAdd(tcpWave, nodeID, nodeSel.nodeName, tabPageList); } else { //有nodeinfo 添加曲线图 CANModels.ADForm.ADForm fm = new CANModels.ADForm.ADForm(nodeSel.chNO); fm.FormBorderStyle = FormBorderStyle.None; // 取消窗体边框 fm.TopLevel = false; // 取消最顶层窗体 fm.Dock = DockStyle.Fill; Ctab_MainTab.PageAdd(fm, nodeID, nodeSel.nodeName, tabPageList); fm.Show(); } } } }
/// <summary> /// 保存数据到历史记录表 /// </summary> /// <param name="tx300"></param> private void SaveTX300History(TX300 tx300, string mac_id) { var DataInstance = new DataBLL(); TB_HISTORIES obj = DataInstance.GetObject(); obj.command_id = "0x" + CustomConvert.IntToDigit(tx300.CommandID, CustomConvert.HEX, 4); obj.mac_id = mac_id; obj.message_content = CustomConvert.GetHex(tx300.MsgContent); obj.message_type = 1; obj.package_id = tx300.PackageID; obj.protocol_type = tx300.ProtocolType; obj.protocol_version = tx300.ProtocolVersion; obj.receive_time = DateTime.Now; obj.sequence_id = tx300.SequenceID.ToString(); obj.server_port = 31875; obj.terminal_id = tx300.TerminalID; obj.terminal_type = tx300.TerminalType; obj.total_length = (short)tx300.TotalLength; obj.total_package = tx300.TotalPackage; DataInstance.Add(obj); }
/// <summary> /// 保存数据到历史记录表 /// </summary> /// <param name="tx300"></param> private void SaveTX300History(TX300 tx300, DateTime receiveTime, string mac_id) { using (var bll = new DataBLL()) { TB_HISTORIES obj = bll.GetObject(); obj.command_id = "0x" + CustomConvert.IntToDigit(tx300.CommandID, CustomConvert.HEX, 4); obj.mac_id = mac_id; obj.message_content = CustomConvert.GetHex(tx300.MsgContent); obj.message_type = 1; obj.package_id = tx300.PackageID; obj.protocol_type = tx300.ProtocolType; obj.protocol_version = tx300.ProtocolVersion; obj.receive_time = receiveTime; obj.sequence_id = tx300.SequenceID.ToString(); obj.server_port = (short)(tx300.ProtocolType == Protocol.ProtocolTypes.SATELLITE ? 10800 : tx300.ProtocolType == Protocol.ProtocolTypes.SMS ? 0 : 31875); obj.terminal_id = tx300.TerminalID; obj.terminal_type = tx300.TerminalType; obj.total_length = (short)tx300.TotalLength; obj.total_package = tx300.TotalPackage; bll.Add(obj); } }
/// <summary> /// 用户登录 /// </summary> /// <returns></returns> public string Login() { DataBLL bll = new DataBLL(); string secrityPassword = ToolModel.GetMd5Hash(PassWord); DataTable dt = bll.getUserInfo_IsExists(UserName, secrityPassword); if (dt.Rows.Count > 0) { dt = bll.getUserInfo_IsPassword(UserName, secrityPassword); if (dt.Rows.Count > 0) { return("[\"正确\",{\"message\":[{\"userID\":\"" + dt.Rows[0]["UserID"].ToString() + "\",\"userName\":\"" + dt.Rows[0]["UserName"].ToString() + "\",\"mineCode\":\"" + dt.Rows[0]["MineCode"].ToString() + "\"}]}]"); } else { return("[\"错误\",{\"message\":\"输入密码有误,请重新填写!\"}]"); } } else { return("[\"错误\",{\"message\":\"用户名不存在,请重新填写!\"}]"); } }
public void BuildResourceList() { switch (FontType) { case FontType.FontAwesome: Items = DataBLL.GetFontList(FontAwesome.Icons, FontAwesome.FontFamily).ToObservable <FontItemRow>(); break; case FontType.EntypoPlus: Items = DataBLL.GetFontList(EntypoPlus.Icons, EntypoPlus.FontFamily).ToObservable <FontItemRow>(); break; case FontType.Ionicons: Items = DataBLL.GetFontList(Ionicons.Icons, Ionicons.FontFamily).ToObservable <FontItemRow>(); break; case FontType.Material: Items = DataBLL.GetFontList(Material.Icons, Material.FontFamily).ToObservable <FontItemRow>(); break; case FontType.Meteocons: Items = DataBLL.GetFontList(Meteocons.Icons, Meteocons.FontFamily).ToObservable <FontItemRow>(); break; case FontType.SimpleLineIcons: Items = DataBLL.GetFontList(SimpleLineIcons.Icons, SimpleLineIcons.FontFamily).ToObservable <FontItemRow>(); break; case FontType.Typicons: Items = DataBLL.GetFontList(Typicons.Icons, Typicons.FontFamily).ToObservable <FontItemRow>(); break; case FontType.WeatherIcons: Items = DataBLL.GetFontList(WeatherIcons.Icons, WeatherIcons.FontFamily).ToObservable <FontItemRow>(); break; } }
public void GetDbAppointments(object obj) { Task.Run(async() => { this.LoadingMessageHUD = "Sqlite loading..."; this.IsLoadingHUD = true; var result = await DataBLL.GetAllAppointments(); this.IsLoadingHUD = false; if (result.Error == null) { Appointments = result.Response.ToObservable(); } else { Device.BeginInvokeOnMainThread(() => { DialogPrompt.ShowMessage(new Prompt() { Title = "Error", Message = result.Error.Message }); }); } }); }
/// <summary> /// 查询历史记录并开始画图 /// </summary> /// <param name="target"></param> private void chart(Stream target) { byte[,] times = new byte[24, 60 / _interval]; Int64 total_seconds = 0; // 初始化数组 for (int i = 0; i < times.GetLength(0); i++) { for (int j = 0; j < times.GetLength(1); j++) { times[i, j] = 10; } } // 获取数据库中今日启动情况 var data = new DataBLL(); var list = data.FindList(h => h.receive_time >= _start && h.receive_time <= _end && h.mac_id.Equals(_equipment) && (h.command_id.Equals("0x5000") || h.command_id.Equals("0x1000"))).OrderBy(o => o.receive_time); // 当日开机时间默认为凌晨零点。 TimeSpan lastOpen = new TimeSpan(_start.Ticks), lastClose; var lastIsOpen = true; var terType = 0; foreach (var obj in list) { // 非卫星方式回来的1000命令不处理 if (obj.command_id.Equals("0x1000")) { if (obj.protocol_type != ProtocolTypes.SATELLITE) { continue; } if (obj.message_content.Substring(0, 2) != "01") { continue; } } if (terType == 0) { var t = new TerminalBLL().Find(find => obj.terminal_id.IndexOf(find.Sim) >= 0); if (null != t) { terType = (byte)t.Type; } } string str = ""; DateTime dt; int hh, mm; //while (sdr.Read()) //{ if (obj.protocol_type == ProtocolTypes.SATELLITE) { byte[] msgc = CustomConvert.GetBytes(obj.message_content); string bin = CustomConvert.IntToDigit(msgc[4], CustomConvert.BIN, 8); msgc = null; str = bin[6] == '1' ? "F000" : "0000"; } else { str = terType == TerminalTypes.DX ? obj.message_content.Substring(0, 4) : (obj.message_content.Substring(8, 2) == "00" ? "F000" : "0000"); } dt = obj.receive_time.Value; hh = Convert.ToInt32(dt.ToString("HH")); mm = Convert.ToInt32(dt.ToString("mm")) / _interval; // 开机 if (0 < str.CompareTo("0000")) { times[hh, mm] = 1; lastOpen = new TimeSpan(dt.Ticks); lastIsOpen = true; } else { times[hh, mm] = 0; lastClose = new TimeSpan(dt.Ticks); if (lastIsOpen) { lastIsOpen = false; total_seconds += (long)(lastClose - lastOpen).Duration().TotalSeconds; } } //} } // 格式化显示今日的总开机时间 total_seconds = total_seconds / 60; string total_runtime = (total_seconds / 60) + " h " + (total_seconds % 60) + " m"; // 添加表格 bool is_open = false; int hn, mn; // 查看日期是否跟今天相同 DateTime date = DateTime.Parse(_date); if (date < DateTime.Now) { hn = 23; mn = 60 / _interval; } else { hn = Convert.ToInt32(DateTime.Now.ToString("HH")); mn = Convert.ToInt32(DateTime.Now.ToString("mm")) / _interval; } Bitmap b = new Bitmap(_width, _height); Graphics g = Graphics.FromImage(b); // 填充白色背景 g.Clear(Color.White); Pen p = new Pen(Color.FromArgb(0x00, 0x99, 0xCC)); Font f = new System.Drawing.Font("Arial", 9); Brush br = new SolidBrush(Color.FromArgb(0x00, 0x99, 0xCC)); int font_height = (int)g.MeasureString(_date, f).Height; // 画日期提示 g.DrawString(_date + ": " + total_runtime, f, br, 0, 0); // 画方框 g.DrawRectangle(p, 0, font_height, b.Width + 1, _barHeight); // 每一个区域块的宽度 int per_width = b.Width / (times.GetLength(0) * times.GetLength(1)); int ct = 0; bool kedu = false; for (int i = 0; i < times.GetLength(0); i++) { kedu = false; for (int j = 0; j < times.GetLength(1); j++) { if (times[i, j] == 1) { is_open = true; } if (times[i, j] == 0) { is_open = false; } if (i == hn) { if (j >= mn) { is_open = false; } } Rectangle r = new Rectangle(ct * per_width, font_height, per_width, _barHeight); if (is_open) { // 填充为实心区域 g.FillRectangle(br, r); // 画底部实线 g.DrawLine(p, r.Left, r.Top + _barHeight, r.Left + r.Width, r.Top + _barHeight); } else { // 画顶部实线 g.DrawLine(p, r.Left, r.Top, r.Left + r.Width, r.Top); // 画底部实线 g.DrawLine(p, r.Left, r.Top + _barHeight, r.Left + r.Width, r.Top + _barHeight); } //if (i % 4 == 0) { if (!kedu) { kedu = true; // 画刻度 g.DrawLine(p, r.Left, r.Top + _barHeight, r.Left, b.Height); // 显示刻度数字 g.DrawString(i.ToString("00"), new Font("tahoma", 8), br, r.Left + 1, r.Top + _barHeight + 1); } } // 画最右边的竖线 if (i == times.GetUpperBound(0) && j == times.GetUpperBound(1)) { g.DrawLine(p, r.Left + r.Width, r.Top, r.Left + r.Width, b.Height); } ct++; } } b.Save(target, ImageFormat.Png); p.Dispose(); g.Dispose(); b.Dispose(); }
/// <summary> /// 插入日志 /// </summary> public void ProcessLogInfo_Insert() { DataBLL bll = new DataBLL(); bll.ProcesslogInfo_Insert(this); }
public void LoadMenuDynamic(string UserName, string MineCode) { DataBLL bll = new DataBLL(); ReturnMenus = bll.getUserMenu(UserName, MineCode); }
/// <summary> /// 查询指定条件 /// </summary> /// <param name="query"></param> /// <param name="time1"></param> /// <param name="time2"></param> private void Query(Work query) { var cmds = new List <string>(); cmds.Add("0x1000"); cmds.Add("0x600B"); using (var bll = new DataBLL()) { Expression <Func <TB_HISTORIES, bool> > expression = PredicateExtensions.True <TB_HISTORIES>(); if (!string.IsNullOrEmpty(query.MacId)) { expression = expression.And(a => a.mac_id.Contains(query.MacId)); } expression = expression.And(a => cmds.Contains(a.command_id)); expression = expression.And(a => a.receive_time >= query.Time1 && a.receive_time <= query.Time2); var list = bll.FindList <TB_HISTORIES>(expression, "receive_time").ToList <TB_HISTORIES>(); var html = ""; int TotalAddedMinutes = 0, TotalWorkedMinutes = 0, TotalUsedHour = 0; if (null == list || list.Count() < 1) { html = "<tr><td colspan=\"13\" class=\"in-tab-title-b\">No records, you can change condition and try again.</td></tr>"; } else { uint lastworktime = 0; string macid = ""; byte maccount = 0; for (int i = 0, len = list.Count(); i < len; i++) { var obj = list[i]; if (!macid.Equals(obj.mac_id)) { macid = obj.mac_id; maccount++; } var data = CustomConvert.GetBytes(obj.message_content); var worktime = BitConverter.ToUInt32(data, obj.command_id.Equals("0x1000") ? 13 : 0); int interval = (int)(i == 0 ? 0 : (worktime - lastworktime)); // 两条数据之间接收时间之差 long minInterval = (long)((i == 0) ? 0 : (obj.receive_time.Value - list[i - 1].receive_time.Value).TotalSeconds); if (interval > minInterval) { // 如果这条数据与上一条数据的工作时间之差大于了这两条数据的接收时间之差则将其算做0 interval = 0; } TotalWorkedMinutes += obj.command_id.Equals("0x600B") ? 0 : (interval > 0 ? interval : 0); var bin = obj.command_id.Equals("0x600B") ? "00000000" : CustomConvert.IntToDigit(data[4], CustomConvert.BIN, 8); string eng, engflag; if (obj.command_id.Equals("0x600B")) { eng = EquipmentBLL.eng_off; engflag = "0"; } else if (data[1] == 0x40 || data[1] == 0x0F || data[1] == 0xFF) { eng = EquipmentBLL.eng_lock; engflag = "0"; } else { eng = (bin[6] == '1' ? EquipmentBLL.eng_on : EquipmentBLL.eng_off); engflag = (bin[6] == '1' ? "1" : "0"); } int added = (interval > 0 ? (obj.command_id.Equals("0x600B") ? 0 : (interval > 60 ? interval / 60 : 1)) : 0) + (engflag.Equals("1") ? 1 : 0); TotalAddedMinutes += added; TotalUsedHour += interval > 0 ? (obj.command_id.Equals("0x600B") ? 0 : (interval > 60 ? interval / 60 : 1)) : 0; html += "<tr>" + "<td class=\"in-tab-title-b\">" + (i + 1) + "</td>" + "<td class=\"in-tab-title-rb textoverflow\" style=\"text-align: left; \">" + obj.receive_time.Value.ToString("yyyy/MM/dd HH:mm:ss") + "</td>" + "<td class=\"in-tab-title-b\" style=\"text-align: right;\">" + EquipmentBLL.GetRuntime((int?)worktime) + "</td>" + "<td class=\"in-tab-title-b\" style=\"text-align: right;\">" + string.Format("{0:0,00}", worktime) + "</td>" + "<td class=\"in-tab-title-b\" style=\"text-align: right;\">" + (interval > 60 ? ("<font color=\"#FF0000\">" + interval + "</font>") : interval.ToString()) + "</td>" + "<td class=\"in-tab-title-rb\" style=\"text-align: right;\">" + added + "</td>" + "<td class=\"in-tab-title-b\" style=\"text-align: left;\">" + obj.command_id + "</td>" + "<td class=\"in-tab-title-b\" style=\"text-align: left;\">" + obj.terminal_id + "</td>" + "<td class=\"in-tab-title-rb textoverflow\" style=\"text-align: left;\">" + obj.mac_id + "</td>" + "<td class=\"in-tab-title-b\" style=\"text-align: center; width: 30px;\">" + eng + "</td>" + "<td class=\"in-tab-title-b\" style=\"text-align: center; width: 30px;\">" + engflag + "</td>" + "<td class=\"in-tab-title-b\" style=\"text-align: left;\">" + obj.message_content + "</td>" + "<td class=\"in-tab-title-b\"></td>" + "</tr>"; lastworktime = worktime; if (i == len - 1) { var compensate = (TotalWorkedMinutes / 60.0) / TotalUsedHour; var finalAdded = TotalAddedMinutes / 60.0 * compensate; var finalWork = worktime / 60.0 + finalAdded; string summary = "<tr>" + "<td class=\"in-tab-title-rb textoverflow\">" + obj.mac_id + "</td>" + "<td class=\"in-tab-title-rb\" style=\"text-align: right;\">" + EquipmentBLL.GetRuntime((int?)worktime) + "</td>" + "<td class=\"in-tab-title-b\" style=\"text-align: right;\">" + EquipmentBLL.GetRuntime(TotalWorkedMinutes) + "</td>" + "<td class=\"in-tab-title-b\" style=\"text-align: right;\">" + TotalUsedHour + "</td>" + "<td class=\"in-tab-title-rb\" style=\"text-align: right;\">" + compensate + "</td>" + "<td class=\"in-tab-title-b\" style=\"text-align: right;\">" + TotalAddedMinutes + "/" + EquipmentBLL.GetRuntime((int?)TotalAddedMinutes) + "</td>" + "<td class=\"in-tab-title-b\" style=\"text-align: right;\">" + finalAdded + "</td>" + "<td class=\"in-tab-title-rb\" style=\"text-align: right;\">" + finalWork + "</td>" + "<td class=\"in-tab-title-b\"></td>" + "</tr>"; tbodySummary.InnerHtml += summary; if (query.Id > 0) { // 只查询到一个设备时才更新统计数据,否则不需要更新 if (maccount <= 1) { new EquipmentBLL().Update(f => f.id == query.Id, act => { // 实际工作小时数 act.WorkHours = TotalWorkedMinutes / 60.0; // 粗略计算工作小时数 act.UsedHours = TotalUsedHour; // 工作效率 act.HourWorkEfficiency = compensate; // 补偿的小时数 act.AddedHours = TotalAddedMinutes / 60.0; // 实际补偿的小时数 act.CompensatedHours = finalAdded; }); } } } } } if (checkAnalyseDailyWork.Checked) { tbodyBody.InnerHtml = html; } } }