Example #1
0
        /// <summary>
        /// 根据TX300数据包更新终端和设备的在线状态
        /// </summary>
        /// <param name="tx300"></param>
        private void HandleTX300Status(TX300 tx300, AsyncUserDataBuffer data)
        {
            var sim       = GetSimFromData(tx300);
            var equipment = EquipmentInstance.Find(f => f.TB_Terminal.Sim.Equals(sim));
            var terminal  = TerminalInstance.Find(f => f.Sim.Equals(sim));

            // 终端不存在的话,不用再继续处理数据了
            if (null == terminal)
            {
                return;
            }

            HandleOnline(sim, tx300.CommandID, data);

            if (tx300.CommandID != 0xAA00)
            {
                SaveTX300History(tx300, data.ReceiveTime,
                                 (null == equipment ? "" : EquipmentInstance.GetFullNumber(equipment)));

                // TX10G的数据
                if (tx300.CommandID == 0x7010 || tx300.CommandID == 0x7020 || tx300.CommandID == 0x7030)
                {
                    HandleTX10G(tx300, data);
                }
                else
                {
                    // 根据命令的不同处理各个命令详情
                    HandleCommand(tx300, equipment, terminal);
                }
            }
        }
Example #2
0
        private void ShowWorkDetails(TB_Work work)
        {
            var html = "";

            if (null == work || work.TB_WorkDetail.Count < 1)
            {
                html = "<tr><td colspan=\"8\">No equipment(s) exist.</td></tr>";
            }
            else
            {
                var cnt = 0;
                var n   = (int?)null;
                foreach (var obj in work.TB_WorkDetail)
                {
                    cnt++;
                    html += "<tr>" +
                            "<td style=\"text-align: center;\">" + cnt + "</td>" +
                            "<td>" + (n == obj.Equipment ? "-" : EquipmentInstance.GetFullNumber(obj.TB_Equipment)) + "</td>" +
                            "<td class=\"textoverflow\">" + WorkDetailInstance.GetWorkType(obj.Type.Value) + "</td>" +
                            "<td>" + (n == obj.BookedTerminal ? "-" : obj.TB_Terminal.Number) + "</td>" +
                            "<td>" + (n == obj.BookedTerminal ? "-" : obj.TB_Terminal.Sim) + "</td>" +
                            "<td>" + (n == obj.BookedTerminal ? "-" : (n == obj.TB_Terminal.Satellite ? "-" : obj.TB_Terminal.TB_Satellite.CardNo)) + "</td>" +
                            "<td style=\"text-align: left;\">" + obj.Details + "</td>" +
                            "<td></td>" +
                            "</tr>";
                }
            }
            tbodyBody.InnerHtml = html;
        }
Example #3
0
        /// <summary>
        /// 显示我作为购买者名下的所有设备列表
        /// </summary>
        private void ShowMyDevices()
        {
            var items = EquipmentInstance.FindList(f => f.Customer == me.id && f.Deleted == false);
            var html  = "";

            foreach (var item in items)
            {
                var eng = EquipmentInstance.GetEngStatus(item);
                html += "<dl class=\"invest-type\" id=\"" + item.id.ToString() + "\">" +
                        "            <dt>" +
                        "                <span class=\"iconleft\">" +
                        "                    <img class=\"img-rounded ex\" src=\"" + item.TB_EquipmentModel.TB_EquipmentType.Image + "\">" +
                        "                </span>" + EquipmentInstance.GetFullNumber(item) +
                        "                <em class=\"status\">" + item.TB_EquipmentModel.TB_EquipmentType.Name + "</em>" +
                        "            </dt>" +
                        "            <dd>" +
                        "                <span class=\"text-" + (eng.Equals("ON") ? "success" : "danger") + "\"><span class=\"signal cell-engine\"></span> Engine " + eng + "</span>" +
                        "                <em class=\"status\"><span class=\"glyphicon glyphicon-time\"></span> " + EquipmentBLL.GetRuntime(item.Runtime + item.InitializedRuntime, item.CompensatedHours.Value) + "</em>" +
                        "            </dd>" +
                        "            <dd>" +
                        "                <span class=\"text-info\"><span class=\"signal cell-signal-" + Utility.ASU2Signal(item.Signal.Value) + "\"></span> Signal: " + Utility.ASU2DBM(item.Signal.Value) + "dBm(ASU: " + item.Signal + ")</span>" +
                        "                <div class=\"total-num\">" + Utility.GetOnlineStyle(item.OnlineStyle, item.OnlineTime, false) + "</div>" +
                        "            </dd>" +
                        "            <dd class=\"desc\"><span class=\"glyphicon glyphicon-globe\"></span> " + item.GpsAddress + "</dd>" +
                        "</dl>";
            }
            equipmentItems.InnerHtml = html;
        }
Example #4
0
        /// <summary>
        /// 查询设备的运转时间
        /// </summary>
        /// <returns></returns>
        private string HandleEquipment6004()
        {
            var ret = "{}";
            var id  = ParseInt(Utility.Decrypt(data));
            var obj = EquipmentInstance.Find(f => f.id == id && f.Deleted == false);

            if (null != obj)
            {
                var date     = DateTime.Parse(GetParamenter("date") + " 23:59:59");
                var runtimes = DataInstance.FindList(f => f.mac_id.Equals(EquipmentInstance.GetFullNumber(obj)) &&
                                                     f.command_id.Equals("0x6004") && f.receive_time < date).OrderByDescending(o => o.receive_time).FirstOrDefault();
                if (null != runtimes)
                {
                    _0x6004DX x6004 = new _0x6004DX();
                    x6004.Command     = "0x6004";
                    x6004.HexContent  = runtimes.message_content;
                    x6004.DataType    = doosan.DX;
                    x6004.MacID       = obj.TB_EquipmentModel.Code + obj.Number;
                    x6004.ReceiveTime = runtimes.receive_time.Value;
                    x6004.SimNo       = runtimes.terminal_id;
                    x6004.Unpackage();
                    ret = JsonConverter.ToJson(x6004);
                }
            }
            return(ret);
        }
        protected void btDelete_Click(object sender, EventArgs e)
        {
            // 删除设备
            var id        = ParseInt(Utility.Decrypt(_key));
            var equipment = EquipmentInstance.Find(f => f.id == id);

            if (null == equipment)
            {
                ShowNotification("./equipment_setting.aspx?key=" + Utility.UrlEncode(_key), "Not found the equipment", false);
            }
            else
            {
                string number = EquipmentInstance.GetFullNumber(equipment);
                if ((int?)null != equipment.Terminal)
                {
                    var ter = equipment.TB_Terminal.Number;
                    // 解绑终端
                    TerminalInstance.Update(f => f.id == equipment.Terminal, act =>
                    {
                        act.HasBound = false;
                    });
                    // 保存解绑终端历史
                    SaveHistory(new TB_AccountHistory()
                    {
                        ActionId = ActionInstance.Find(f => f.Name.Equals("Unbind")).id,
                        ObjectA  = "unbind terminal(delete equipment) " + ter + " and equipment " + EquipmentInstance.GetFullNumber(equipment)
                    });
                }
                // 更新Deleted=true
                EquipmentInstance.Update(f => f.id == equipment.id, act => {
                    act.Deleted        = true;
                    act.GpsAddress     = "";
                    act.IP             = "";
                    act.LastAction     = "";
                    act.LastActionBy   = "";
                    act.LastActionTime = null;
                    act.Latitude       = 0.0;
                    act.Longitude      = 0.0;
                    act.OnlineStyle    = null;
                    act.OnlineTime     = null;
                    act.Port           = 0;
                    act.Rpm            = 0;
                    act.Runtime        = 0;
                    act.ServerName     = "";
                    act.Signal         = 0;
                    act.Socket         = 0;
                    act.Terminal       = null;
                    act.Voltage        = "G0000";
                });
                // 保存删除设备历史
                SaveHistory(new TB_AccountHistory()
                {
                    ActionId = ActionInstance.Find(f => f.Name.Equals("Unbind")).id,
                    ObjectA  = "delete equipment " + number
                });
                ShowNotification("./equipment_inquiry.aspx", "You have deleted a equipment: " + number);
            }
        }
Example #6
0
        protected void btCheckoutStorage_Click(object sender, EventArgs e)
        {
            var id        = int.Parse(hidCheckEquipmentId.Value);
            var equipment = EquipmentInstance.Find(f => f.id == id && f.Deleted == false);

            if (null == equipment)
            {
                ShowNotification("./equipment_checkout.aspx", "Cannot find the equipment.", false);
                //return;
            }
            else
            {
                DateTime begin;
                try { begin = DateTime.Parse(outTime.Value.Trim()); }
                catch { begin = DateTime.Now; }

                EquipmentInstance.Update(f => f.id == equipment.id, act =>
                {
                    // 出厂时,如果是普通车辆,则直接划为车辆状态,不参与出库/入库流程
                    if (act.TB_EquipmentModel.TB_EquipmentType.IsVehicle == true)
                    {
                        act.Status = StatusInstance.Find(f => f.IsItVehicle == true).id;
                    }
                    else
                    {
                        act.Status = int.Parse(ddlOuttype.SelectedValue);
                    }
                    act.Customer = int.Parse(hidCheckCustomerId.Value);
                    // 出库时的总运转时间
                    act.OutdoorWorktime = equipment.Runtime;
                    // 出库的时间
                    act.OutdoorTime = begin;
                    // 出库后库存信息置为null
                    act.Warehouse = null;
                });
                equipment = EquipmentInstance.Find(f => f.id == equipment.id);
                // 保存出库历史记录
                var history = StoreInstance.GetObject();
                history.Equipment = equipment.id;
                history.Status    = equipment.Status;
                history.Stocktime = begin;
                // 设备的出入库次数,入库时增1,出库时不变
                history.StoreTimes = equipment.StoreTimes;
                history.Warehouse  = null;
                StoreInstance.Add(history);

                // 保存操作历史记录
                SaveHistory(new TB_AccountHistory()
                {
                    ActionId = ActionInstance.Find(f => f.Name.Equals("Deliver")).id,
                    ObjectA  = EquipmentInstance.GetFullNumber(equipment) +
                               " check out(" + ddlOuttype.SelectedItem.Text + ") to: " + equipment.TB_Customer.Name
                });

                ShowNotification("./equipment_checkout.aspx", "\"" + EquipmentInstance.GetFullNumber(equipment) + "\" has delivered.");
            }
        }
Example #7
0
        protected void confirmRental_Click(object sender, EventArgs e)
        {
            // 租赁出库
            if (!HasSessionLose)
            {
                var id        = ParseInt(Utility.Decrypt(hiddenRentalId.Value));
                var equipment = EquipmentInstance.Find(f => f.id == id && f.Deleted == false);
                if (null == equipment)
                {
                    ShowNotification("./equipment_rental.aspx", "Cannot find the equipment.", false);
                }
                else
                {
                    DateTime begin;
                    try { begin = DateTime.Parse(beginAt.Value.Trim()); }
                    catch { begin = DateTime.Now; }

                    EquipmentInstance.Update(f => f.id == equipment.id, act =>
                    {
                        act.Status          = StatusInstance.Find(f => f.IsItRental == true).id;
                        act.Customer        = int.Parse(hiddenCustomer.Value);
                        act.OutdoorTime     = begin;
                        act.OutdoorWorktime = equipment.Runtime;
                        act.Warehouse       = null;
                        act.ReclaimTime     = DateTime.Parse(deadLine.Value + " 00:00:00");
                    });

                    equipment = EquipmentInstance.Find(f => f.id == equipment.id);
                    // 保存出库历史记录
                    var history = StoreInstance.GetObject();
                    history.Equipment = equipment.id;
                    history.Status    = equipment.Status;
                    history.Stocktime = begin;
                    // 设备的出入库次数,入库时增1,出库时不变
                    history.StoreTimes = equipment.StoreTimes;
                    history.Warehouse  = (int?)null;
                    StoreInstance.Add(history);

                    // 保存操作历史记录
                    SaveHistory(new TB_AccountHistory()
                    {
                        ActionId = ActionInstance.Find(f => f.Name.Equals("Rental")).id,
                        ObjectA  = EquipmentInstance.GetFullNumber(equipment) +
                                   " rent to: " + equipment.TB_Customer.Name + ", " +
                                   equipment.OutdoorTime.Value.ToString("yyyy/MM/dd") +
                                   " to " + equipment.ReclaimTime.Value.ToString("yyyy/MM/dd")
                    });

                    ShowNotification("./equipment_rental.aspx", "\"" +
                                     EquipmentInstance.GetFullNumber(equipment) + "\" has rent to " + equipment.TB_Customer.Name + ".");
                }
            }
        }
        private void SaveNewEquipment()
        {
            var value     = hidNewInstorage.Value;
            var equipment = JsonConverter.ToObject <TB_Equipment>(value);
            // 查找是否有相同型号的相同设备号码
            var exist = EquipmentInstance.Find(f => f.Model == equipment.Model && f.Number.Equals(equipment.Number) && f.Deleted == false);

            if (null == exist)
            {
                var model  = ModelInstance.Find(f => f.id == equipment.Model);
                var newOne = EquipmentInstance.GetObject();
                newOne.Model = equipment.Model;
                if (model.TB_EquipmentType.IsVehicle == true)
                {
                    // 新增的设备是普通车辆时,直接划为车辆,不参与出库/入库流程
                    newOne.Status = StatusInstance.Find(f => f.IsItVehicle == true).id;
                }
                else
                {
                    newOne.Status = StatusInstance.Find(f => f.IsItInventory == true).id;
                }
                newOne.Warehouse  = equipment.Warehouse;
                newOne.Number     = equipment.Number;
                newOne.StoreTimes = equipment.StoreTimes;
                newOne.Functional = equipment.Functional;
                newOne            = EquipmentInstance.Add(newOne);

                // 保存入库信息
                var history = StoreInstance.GetObject();
                history.Equipment = newOne.id;
                history.Status    = newOne.Status;
                history.Stocktime = DateTime.Parse(inDate.Value);
                // 默认第1次入库
                history.StoreTimes = newOne.StoreTimes;
                history.Warehouse  = newOne.Warehouse;
                StoreInstance.Add(history);

                // 保存入库操作历史记录
                SaveHistory(new TB_AccountHistory()
                {
                    ActionId = ActionInstance.Find(f => f.Name.Equals("InStore")).id,
                    ObjectA  = EquipmentInstance.ToString(newOne)
                });

                ShowNotification("./equipment_new_product.aspx",
                                 "New equipment \"" + EquipmentInstance.GetFullNumber(exist) + "\" has been saved.");
            }
            else
            {
                ShowNotification("./equipment_new_product.aspx",
                                 "There has a same number of \"" + EquipmentInstance.GetFullNumber(exist) + "\" exist.", false);
            }
        }
Example #9
0
 protected void bt_Test_Click(object sender, EventArgs e)
 {
     if (!HasSessionLose)
     {
         if ("" != hidID.Value)
         {
             var id       = int.Parse(Utility.Decrypt(hidID.Value));
             var terminal = TerminalInstance.Find(f => f.id == id && f.Delete == false);
             if (null != terminal)
             {
                 if (terminal.HasBound.Value == false)
                 {
                     ShowNotification("./terminal_list.aspx", "No equipment bind on this terminal.", false);
                 }
                 else
                 {
                     var test = StatusInstance.Find(f => f.IsItTesting == true);
                     if (null == test)
                     {
                         ShowNotification("Situation code is not exist.", "", false);
                     }
                     else
                     {
                         var equip = terminal.TB_Equipment.FirstOrDefault();
                         if (null != equip)
                         {
                             EquipmentInstance.Update(f => f.id == equip.id, act =>
                             {
                                 act.Status = StatusInstance.Find(f => f.IsItTesting == true).id;
                             });
                             SaveHistory(new TB_AccountHistory
                             {
                                 ActionId = ActionInstance.Find(f => f.Name.Equals("EditTerminal")).id,
                                 ObjectA  = EquipmentInstance.GetFullNumber(equip) + ", " + terminal.Number + ", set to test mode"
                             });
                             ShowNotification("./terminal_list.aspx", EquipmentInstance.GetFullNumber(equip) + ", " + terminal.Number + ", set to test mode");
                         }
                         else
                         {
                             ShowNotification("./terminal_list.aspx", "No equipment bind on this terminal.", false);
                         }
                     }
                 }
             }
             else
             {
                 ShowNotification("./terminal_list.aspx", "Terminal is not exist.", false);
             }
         }
     }
 }
Example #10
0
        private string GetEquipment(TB_Terminal terminal, TB_Equipment equipment)
        {
            if (null == equipment)
            {
                return("<a href=\"./equipment_terminal.aspx?key=" + Utility.UrlEncode(Utility.Encrypt(terminal.id.ToString())) + "\">bind</a>");
            }

            if (string.IsNullOrEmpty(terminal.Sim))
            {
                return("no sim card");
            }

            return("<a href=\"#unbind_" + terminal.id + "\">" + EquipmentInstance.GetFullNumber(equipment) + "</a>");
        }
Example #11
0
 private void GetLastReceiveDate()
 {
     if (!string.IsNullOrEmpty(_key))
     {
         var id  = ParseInt(Utility.Decrypt(_key));
         var obj = EquipmentInstance.Find(f => f.id == id && f.Deleted == false);
         if (null != obj)
         {
             MacId = EquipmentInstance.GetFullNumber(obj);
             hiddenLastDate.Value = (DateTime?)null == obj.LastActionTime ? DateTime.Now.ToString("yyyy/MM/dd") :
                                    obj.LastActionTime.Value.ToString("yyyy/MM/dd");
         }
         divWorkTime.Visible = (null != obj && obj.Functional == (byte)EquipmentFunctional.Mechanical);
     }
 }
Example #12
0
        private void ShowEquipmentInformations()
        {
            var obj = EquipmentInstance.Find(f => f.id == int.Parse(_key) && f.Deleted == false);

            if (null == obj)
            {
                ShowNotification("/mobile/devices.aspx", "No such equipment exist: paramenter error.", false);
            }
            else
            {
                equipmentId.InnerText = EquipmentInstance.GetFullNumber(obj);
                spanLat.InnerText     = obj.Latitude.ToString();
                spanLon.InnerText     = obj.Longitude.ToString();
            }
        }
        protected void btSave_Click(object sender, EventArgs e)
        {
            if (!HasSessionLose)
            {
                // 设备出库
                if (!string.IsNullOrEmpty(hidCustomerId.Value.Trim()) &&
                    !string.IsNullOrEmpty(hidEquipmentId.Value.Trim()))
                {
                    var obj = EquipmentInstance.Find(f => f.id == ParseInt(hidEquipmentId.Value.Trim()) && f.Deleted == false);
                    if (obj.TB_EquipmentStatusName.IsItInventory == false)
                    {
                        // 如果不在库存状态则提示失败
                        ShowNotification("./equipment_delivery.aspx", "Error: equipment \"" +
                                         obj.TB_EquipmentModel.Code + obj.Number + "\" is not in inventory.", false);
                    }
                    else
                    {
                        EquipmentInstance.Update(f => f.id == obj.id && f.Deleted == false, act =>
                        {
                            act.Status = ParseInt(ddlSituation.SelectedValue);
                            // 出库后库存信息置为null
                            act.Warehouse = (int?)null;
                            act.Customer  = ParseInt(hidCustomerId.Value);
                        });

                        // 保存出库历史记录
                        var history = StoreInstance.GetObject();
                        history.Equipment = obj.id;
                        history.Status    = ParseInt(ddlSituation.SelectedValue);
                        history.Stocktime = DateTime.Now;
                        // 设备的出入库次数,入库时增1,出库时不变
                        history.StoreTimes = obj.StoreTimes;
                        history.Warehouse  = (int?)null;
                        StoreInstance.Add(history);

                        // 保存操作历史记录
                        SaveHistory(new Database.TB_AccountHistory()
                        {
                            ActionId = ActionInstance.Find(f => f.Name.Equals("Deliver")).id,
                            ObjectA  = ""
                        });

                        ShowNotification("./equipment_deliver.aspx", "\"" + EquipmentInstance.GetFullNumber(obj) + "\" has delivered.");
                    }
                }
            }
        }
Example #14
0
        protected void btSaveChangeWarehouse_Click(object sender, EventArgs e)
        {
            if (!HasSessionLose)
            {
                var id  = ParseInt(Utility.Decrypt(hidWarehouseEquipmentId.Value));
                var obj = EquipmentInstance.Find(f => f.id == id);
                var tmp = JsonConverter.ToObject <TB_Equipment>(hidWarehouseTo.Value);
                if (obj.TB_EquipmentStatusName.IsItInventory == false)
                {
                    ShowNotification("./equipment_change_warehouse.aspx", "The equipment is not in storage status.", false);
                }
                else if (obj.Warehouse == tmp.Warehouse)
                {
                    ShowNotification("./equipment_change_warehouse.aspx", "The equipment in same warehouse you selected.", false);
                }
                else
                {
                    //var transfer = CodeInstance.Find(f =>
                    //        f.TB_EquipmentStatusName.IsInventory == true && f.Code.Equals("T"));
                    EquipmentInstance.Update(f => f.id == obj.id && f.Deleted == false, act =>
                    {
                        act.Warehouse = tmp.Warehouse;
                        // 状态变为库存转移状态
                        //act.Status = transfer.id;
                    });

                    // 保存转库信息
                    var history = StoreInstance.GetObject();
                    history.Equipment = obj.id;
                    history.Status    = obj.Status;//transfer.id;// 移库状态
                    history.Stocktime = DateTime.Now;
                    // 入库次数
                    history.StoreTimes = obj.StoreTimes;
                    history.Warehouse  = tmp.Warehouse;// 保持目的仓库
                    StoreInstance.Add(history);

                    SaveHistory(new TB_AccountHistory()
                    {
                        ActionId = ActionInstance.Find(f => f.Name.Equals("Transfer")).id,
                        ObjectA  = EquipmentInstance.GetFullNumber(obj) + ", \"" + obj.TB_Warehouse.Name + "\" to \"" +
                                   WarehouseInstance.Find(f => f.id == tmp.Warehouse).Name + "\""
                    });

                    ShowEquipments();
                }
            }
        }
Example #15
0
        private void ShowNotbindEquipments()
        {
            var totalRecords = 0;
            var pageIndex    = "" == hidPageIndex.Value ? 1 : int.Parse(hidPageIndex.Value);
            var list         = EquipmentInstance.FindPageList <TB_Equipment>(pageIndex, PageSize, out totalRecords,
                                                                             f => f.Terminal == (int?)null && f.Number.IndexOf(txtEquipment.Value.Trim()) >= 0 &&
                                                                             f.Functional == GetEquipmentTypeByTerminalType() && f.Deleted == false, null);
            var totalPages = totalRecords / PageSize + (totalRecords % PageSize > 0 ? 1 : 0);

            string html = "";

            if (totalRecords < 1)
            {
                html = "<tr><td colspan=\"9\">No equipment has unbind terminal.</td></tr>";
            }
            else
            {
                var cnt = (pageIndex - 1) * PageSize;
                var n   = (int?)null;
                foreach (var obj in list)
                {
                    cnt++;
                    html += "<tr style=\"cursor: pointer;\">" +
                            "<td style=\"text-align: center;\">" +
                            "    <input type=\"radio\" name=\"bind\" id=\"radio_" + obj.id + "\" />" +
                            "</td>" +
                            "<td style=\"text-align: center;\">" + cnt + "</td>" +
                            "<td>" + (n == obj.Model ? "-" : obj.TB_EquipmentModel.TB_EquipmentType.Code) + "</td>" +
                            "<td>" + EquipmentInstance.GetFullNumber(obj) + "</td>" +
                            "<td style=\"text-align: right;\">" + EquipmentBLL.GetRuntime(obj.Runtime + obj.InitializedRuntime, obj.CompensatedHours.Value) + "</td>" +
                            "<td style=\"text-align: center;\" title=\"" + EquipmentInstance.GetStatusTitle(obj) + "\">" + EquipmentInstance.GetStatus(obj) + "</td>" +
                            "<td>" + (n == obj.Terminal ? "not bind" : obj.TB_Terminal.Number) + "</td>" +
                            "<td>" + (n == obj.Warehouse ? "-" : obj.TB_Warehouse.Name) + "</td>" +
                            "<td>" + obj.GpsAddress + "</td>" +
                            "<td></td>" +
                            "</tr>";
                }
            }
            tbodyBody.InnerHtml  = html;
            divPagging.InnerHtml = "";
            if (totalRecords > 0)
            {
                ShowPaggings(pageIndex, totalPages, totalRecords, "./equipment_terminal.aspx", divPagging);
            }
        }
Example #16
0
        protected void btRepairComplete_Click(object sender, EventArgs e)
        {
            if (!HasSessionLose)
            {
                var id        = int.Parse(hidRepairId.Value);
                var equipment = EquipmentInstance.Find(f => f.id == id && f.Deleted == false);
                if (null == equipment)
                {
                    ShowNotification("./equipment_overhaul.aspx", "Cannot find the equipment: object is not exist.", false);
                }
                else
                {
                    EquipmentInstance.Update(f => f.id == equipment.id && f.Deleted == false, act =>
                    {
                        act.Status = StatusInstance.Find(f => f.IsItInventory == true).id;
                    });
                    //RepairOK
                    equipment = EquipmentInstance.Find(f => f.id == equipment.id && f.Deleted == false);

                    var history = StoreInstance.GetObject();
                    history.Equipment = equipment.id;
                    // 先保存维修状态
                    history.Status = equipment.Status;
                    // 保存维修完成信息
                    history.Stocktime = DateTime.Now;
                    // 入库次数不变
                    history.StoreTimes = equipment.StoreTimes;
                    history.Warehouse  = equipment.Warehouse;
                    StoreInstance.Add(history);

                    // 保存维修完毕操作历史记录
                    SaveHistory(new TB_AccountHistory()
                    {
                        ActionId = ActionInstance.Find(f => f.Name.Equals("RepairOK")).id,
                        ObjectA  = EquipmentInstance.ToString(equipment)
                    });

                    ShowNotification("./equipment_overhaul.aspx", "Equipment \"" +
                                     EquipmentInstance.GetFullNumber(equipment) + "\" inspection & repair complete, and re-store in warehouse.");
                }
            }
        }
Example #17
0
 protected void btUnbind_Click(object sender, EventArgs e)
 {
     if (!HasSessionLose)
     {
         var id        = ParseInt(Utility.Decrypt(_key));
         var equipment = EquipmentInstance.Find(f => f.id == id && f.Deleted == false);
         if (null == equipment)
         {
             ShowNotification("./equipment_setting.aspx?key=" + Utility.UrlEncode(_key), "Not found the equipment", false);
         }
         else
         {
             var ter = equipment.TB_Terminal.Number;
             TerminalInstance.Update(f => f.id == equipment.Terminal, act => { act.HasBound = false; });
             EquipmentInstance.Update(f => f.id == equipment.id, act =>
             {
                 act.Terminal       = null;
                 act.OnlineStyle    = null;
                 act.OnlineTime     = null;
                 act.Socket         = 0;
                 act.IP             = "";
                 act.LastAction     = "";
                 act.LastActionBy   = "";
                 act.LastActionTime = null;
                 act.Latitude       = 0.0;
                 act.Longitude      = 0.0;
                 act.GpsAddress     = "";
                 act.Rpm            = 0;
                 act.ServerName     = "";
                 act.Voltage        = "G0000";
             });
             // 保存解绑终端历史
             SaveHistory(new TB_AccountHistory()
             {
                 ActionId = ActionInstance.Find(f => f.Name.Equals("Unbind")).id,
                 ObjectA  = "unbind terminal " + ter + " and equipment " + EquipmentInstance.GetFullNumber(equipment)
             });
             ShowNotification("./equipment_setting.aspx?key=" + Utility.UrlEncode(_key), "You have unbind terminal & equipment.");
         }
     }
 }
Example #18
0
        private void BindEquipment(int terminal, int equipment)
        {
            var ter = TerminalInstance.Find(f => f.id == terminal);

            if (null == ter)
            {
                ShowNotification("./terminal_list.aspx", "Error: Cannot find the terminal.", false);
                return;
            }
            else if (ter.HasBound == true)
            {
                ShowNotification("./terminal_list.aspx", "Error: The terminal \"" + ter.Number + "\" has been bound before this time.", false);
                return;
            }
            var equ = EquipmentInstance.Find(f => f.id == equipment && f.Deleted == false);

            if (null == equ)
            {
                ShowNotification("./terminal_list.aspx", "Error: Cannot find the equipment.", false);
                return;
            }
            else if (equ.Terminal > 0)
            {
                ShowNotification("./terminal_list.aspx", "Error: The equipment \"" +
                                 EquipmentInstance.GetFullNumber(equ) + "\" has bound an other terminal: \"" + equ.TB_Terminal.Number + "\".", false);
                return;
            }

            // 开始绑定流程
            var storage = StatusInstance.Find(f => f.IsItInventory == true);

            EquipmentInstance.Update(f => f.id == equ.id && f.Deleted == false, act =>
            {
                act.Terminal = ter.id;
                // 更新设备的相应信息为终端的信息
                act.OnlineStyle = ter.OnlineStyle;
                act.OnlineTime  = ter.OnlineTime;
                act.Socket      = ter.Socket;
                // 新品等待入库的,绑定终端之后直接确定为库存状态
                act.Status = storage.id;
            });
            TerminalInstance.Update(f => f.id == ter.id, act => { act.HasBound = true; });

            // 保存入库信息
            var history = StoreInstance.GetObject();

            history.Equipment = equ.id;
            history.Status    = storage.id;
            history.Stocktime = DateTime.Now;
            // 绑定终端时,入库次数不变
            history.StoreTimes = equ.StoreTimes;
            history.Warehouse  = equ.Warehouse;
            StoreInstance.Add(history);

            // 保存操作历史记录
            SaveHistory(new TB_AccountHistory()
            {
                ActionId = ActionInstance.Find(f => f.Name.Equals("Bind")).id,
                ObjectA  = "bind equipment " + EquipmentInstance.GetFullNumber(equ) + " and terminal " + ter.Number
            });

            ShowNotification("./terminal_list.aspx", "You have bound \"" + ter.Number + "\" on equipment \"" +
                             EquipmentInstance.GetFullNumber(equ) + "\"");
        }
Example #19
0
        private void ShowFlow()
        {
            var month = int.Parse(selectedMonths.Value);

            spanMonthly.InnerText = string.Format("for {0}{1:00}", selectedYears.Value, (month == 0 ? " full year" : ("/" + month.ToString("00"))));

            var query = txtQueryNumber.Value.Trim();

            // 模糊查询时页码置为空
            if (!string.IsNullOrEmpty(query))
            {
                hidPageIndex.Value = "";
            }

            var totalRecords = 0;
            var pageIndex    = "" == hidPageIndex.Value ? 1 : int.Parse(hidPageIndex.Value);
            var list         = TerminalInstance.FindPageList <TB_Terminal>(pageIndex, PageSize, out totalRecords,
                                                                           f => f.Delete == false && (f.Sim.Contains(query) || f.TB_Satellite.CardNo.Contains(query)), "Number");
            var totalPages = totalRecords / PageSize + (totalRecords % PageSize > 0 ? 1 : 0);

            var    monthly = int.Parse(string.Format("{0}{1:00}", selectedYears.Value, month));
            string html    = "";

            if (totalRecords < 1)
            {
                html = "<tr><td colspan=\"13\">No records, Change condition and try again.</td></tr>";
            }
            else
            {
                var cnt = (pageIndex - 1) * PageSize;
                var n   = (int?)null;
                foreach (var obj in list)
                {
                    cnt++;
                    // var id = Utility.UrlEncode(Utility.Encrypt(obj.id.ToString()));
                    // 查找绑定的设备信息
                    var equipment = obj.TB_Equipment.FirstOrDefault();
                    // 查找选定月的流量统计
                    var flow = obj.TB_TerminalFlow.Where <TB_TerminalFlow>(o => (month == 0 ?
                                                                                 (o.Monthly >= monthly && o.Monthly <= monthly + 100) :
                                                                                 o.Monthly == monthly));

                    var _flow = FlowInstance.GetObject();
                    _flow.GPRSDeliver = flow.Select(s => s.GPRSDeliver).Sum();
                    _flow.GPRSReceive = flow.Select(s => s.GPRSReceive).Sum();
                    _flow.SMSDeliver  = flow.Select(s => s.SMSDeliver).Sum();
                    _flow.SMSReceive  = flow.Select(s => s.SMSReceive).Sum();
                    // 查找选定月的铱星流量
                    var _sat = IridiumInstance.GetObject();
                    if (obj.Satellite != n)
                    {
                        var sat = obj.TB_Satellite.TB_IridiumFlow.Where(w => (month == 0 ?
                                                                              (w.Monthly >= monthly && w.Monthly <= monthly + 100) : w.Monthly == monthly));
                        _sat.MOPayload = sat.Select(s => s.MOPayload).Sum();
                        _sat.MOTimes   = sat.Select(s => s.MOTimes).Sum();
                        _sat.MTPayload = sat.Select(s => s.MTPayload).Sum();
                        _sat.MTTimes   = sat.Select(s => s.MTTimes).Sum();
                    }

                    html += "<tr>" +
                            "<td class=\"in-tab-txt-b\">" + cnt + "</td>" +
                            "<td class=\"in-tab-txt-b\" style=\"text-align: left;\">" + (null == equipment ? "not bind" : EquipmentInstance.GetFullNumber(equipment)) + "</td>" +
                            "<td class=\"in-tab-txt-rb\" style=\"text-align: left;\">" + obj.Number + "</td>" +
                            "<td class=\"in-tab-txt-b\">" + CustomConvert.FormatSize(_flow.GPRSReceive.Value) + "</td>" +
                            "<td class=\"in-tab-txt-rb\">" + CustomConvert.FormatSize(_flow.GPRSDeliver.Value) + "</td>" +
                            "<td class=\"in-tab-txt-b\">" + _flow.SMSReceive.Value.ToString() + "</td>" +
                            "<td class=\"in-tab-txt-rb\">" + _flow.SMSDeliver.Value.ToString() + "</td>" +
                            "<td class=\"in-tab-txt-rb\" style=\"text-align: left;\">" + (n == obj.Satellite ? "not bind" : obj.TB_Satellite.CardNo) + "</td>" +
                            "<td class=\"in-tab-txt-b\">" + _sat.MOTimes.Value.ToString() + "</td>" +
                            "<td class=\"in-tab-txt-rb\">" + CustomConvert.FormatSize(_sat.MOPayload.Value) + "</td>" +
                            "<td class=\"in-tab-txt-b\">" + _sat.MTTimes.Value.ToString() + "</td>" +
                            "<td class=\"in-tab-txt-b\">" + CustomConvert.FormatSize(_sat.MTPayload.Value) + "</td>" +
                            "<td class=\"in-tab-txt-b\"></td>" +
                            "</tr>";
                }
            }
            tbodyBody.InnerHtml  = html;
            divPagging.InnerHtml = "";
            if (totalRecords > 0)
            {
                ShowPaggings(pageIndex, totalPages, totalRecords, "./terminal_flow.aspx", divPagging);
            }
        }
Example #20
0
        /// <summary>
        /// 保存设备的更改信息
        /// </summary>
        private void SaveChanges()
        {
            var    id = ParseInt(Utility.Decrypt(_key));
            var    equipment = EquipmentInstance.Find(f => f.id == id && f.Deleted == false);
            bool   needSave = false;
            string msg = "";
            int    wh = 0, md = 0;

            if (null != equipment)
            {
                msg = EquipmentInstance.GetFullNumber(equipment);
                var tmp = int.Parse(hidWarehouse.Value);
                if (tmp > 0)
                {
                    var oh = WarehouseInstance.Find(f => f.id == equipment.Warehouse);
                    var nh = WarehouseInstance.Find(f => f.id == tmp && f.Delete == false);
                    msg += ", " + oh.Name + " to " + nh.Name;
                    //equipment.Warehouse = tmp;
                    wh       = tmp;
                    needSave = true;
                }
                tmp = int.Parse(selectedModel.Value);
                if (tmp > 0)
                {
                    var om = ModelInstance.Find(f => f.id == equipment.Model);
                    var nm = ModelInstance.Find(f => f.id == tmp && f.Delete == false);
                    msg += ", " + om.Code + " to " + nm.Code;
                    //equipment.Model = tmp;
                    md       = tmp;
                    needSave = true;
                }
                tmp = int.Parse(hidFunctional.Value);
                if (tmp != 0 && tmp != int.Parse(oldFunc.Value))
                {
                    msg += ", " + Utility.GetEquipmentFunctional(equipment.Functional.Value) + " to " + Utility.GetEquipmentFunctional((byte)tmp);
                    equipment.Functional = (byte)tmp;
                    needSave             = true;
                }
                var num = number.Value.Trim();
                if (!string.IsNullOrEmpty(num))
                {
                    if (!num.Equals(equipment.Number))
                    {
                        msg += ", Number: " + equipment.Number + " to " + num;
                        equipment.Number = num;
                        needSave         = true;
                    }
                }
                //tmp = int.Parse(Utility.Decrypt(Utility.UrlDecode(oldTerminal.Value)));
                var         n      = string.IsNullOrEmpty(newTerminal.Value) ? 0 : int.Parse(Utility.Decrypt(Utility.UrlDecode(newTerminal.Value)));
                TB_Terminal newOne = null;
                if (n > 0)
                {
                    msg += ", Terminal: ";
                    // 更新旧终端为未绑定状态
                    if ((int?)null != equipment.Terminal)
                    {
                        var ter = equipment.TB_Terminal.Number;
                        TerminalInstance.Update(f => f.id == equipment.Terminal, act =>
                        {
                            act.HasBound = false;
                        });
                        // 保存旧终端的解绑状态
                        SaveHistory(new TB_AccountHistory()
                        {
                            ActionId = ActionInstance.Find(f => f.Name.Equals("Unbind")).id,
                            ObjectA  = "unbind terminal " + ter + " and equipment " + EquipmentInstance.GetFullNumber(equipment)
                        });
                        msg += ter + "(unbind) to ";
                    }
                    newOne             = TerminalInstance.Find(f => f.id == n);
                    msg               += newOne.Number + "(bind)";
                    equipment.Terminal = n;
                    // 更新新终端的绑定状态
                    TerminalInstance.Update(f => f.id == n, act => { act.HasBound = true; });
                    // 保存新终端的绑定状态
                    SaveHistory(new TB_AccountHistory()
                    {
                        ActionId = ActionInstance.Find(f => f.Name.Equals("Unbind")).id,
                        ObjectA  = "bind terminal " + newOne.Number + " and equipment " + EquipmentInstance.GetFullNumber(equipment)
                    });
                    needSave = true;
                }
                if (needSave)
                {
                    EquipmentInstance.Update(f => f.id == equipment.id && f.Deleted == false, act =>
                    {
                        if (md > 0)
                        {
                            //if (act.Model != equipment.Model)
                            act.Model = md;
                        }
                        if (wh > 0)
                        {
                            //if (act.Warehouse != equipment.Warehouse)
                            act.Warehouse = wh;
                        }
                        if (!act.Number.Equals(equipment.Number))
                        {
                            act.Number = equipment.Number;
                        }
                        if (act.Functional != equipment.Functional)
                        {
                            act.Functional = equipment.Functional;
                        }
                        if (act.Terminal != equipment.Terminal)
                        {
                            act.Terminal    = equipment.Terminal;
                            act.Socket      = newOne.Socket;
                            act.OnlineTime  = newOne.OnlineTime;
                            act.OnlineStyle = newOne.OnlineStyle;
                        }
                    });
                    // 保存更改设备信息的历史
                    SaveHistory(new TB_AccountHistory()
                    {
                        ActionId = ActionInstance.Find(f => f.Name.Equals("EditEquipmentInfo")).id,
                        ObjectA  = msg
                    });
                    ShowNotification("./equipment_setting.aspx?key=" + Utility.UrlEncode(_key), "You have saved the equipment info.", true);
                }
            }
            else
            {
                ShowNotification("./equipment_setting.aspx?key=" + Utility.UrlEncode(_key), "Not found the equipment", false);
            }
        }
        /// <summary>
        /// 查询指定日期范围内的运转时间并补偿相应的数量
        /// </summary>
        /// <param name="averagable"></param>
        /// <returns></returns>
        private string HandleQueryEquipmentWorktime(bool averagable = true)
        {
            var ret = "{}";
            var id  = ParseInt(Utility.Decrypt(data));
            var obj = EquipmentInstance.Find(f => f.id == id && f.Deleted == false);

            if (null != obj)
            {
                var date = DateTime.Parse(GetParamenter("date") + " 00:00:00");
                // 如果不是求平均值则将日期往前推一天
                //if (!averagable) { date = date.AddDays(-1); }
                var date1 = DateTime.Parse(GetParamenter("date1") + " 23:59:59");
                List <WorktimeChart> avg  = new List <WorktimeChart>();
                List <WorktimeChart> work = new List <WorktimeChart>();
                DateTime             dt   = date;
                // 循环每天一个节点
                while (dt.Ticks < date1.Ticks)
                {
                    avg.Add(new WorktimeChart()
                    {
                        date = dt.ToString("yyyy/MM/dd"), x = Utility.DateTimeToJavascriptDate(dt.Date), y = 0, min = 0
                    });
                    work.Add(new WorktimeChart()
                    {
                        date = dt.ToString("yyyy/MM/dd"), x = Utility.DateTimeToJavascriptDate(dt.Date), y = 0, min = 0
                    });
                    dt = dt.AddDays(1);
                }
                var macid    = EquipmentInstance.GetFullNumber(obj);
                var cmds     = new string[] { "0x1000", "0x600B" };
                var runtimes = DataInstance.FindList(f => f.mac_id.Equals(macid) && cmds.Contains(f.command_id) &&
                                                     f.receive_time >= date && f.receive_time <= date1).OrderBy(o => o.receive_time);
                var list = new List <Worktime>();
                if (null != runtimes)
                {
                    long today        = 0;
                    long timeInterval = 0;
                    foreach (var r in runtimes)
                    {
                        bool gps = r.command_id.Equals("0x1000");
                        if (today == 0)
                        {
                            dt = r.receive_time.Value;
                        }
                        else
                        {
                            // 计算与上一条数据的实际接收时间之间的时间差
                            timeInterval = (long)(r.receive_time.Value - dt).TotalSeconds;
                        }
                        var t = Utility.DateTimeToJavascriptDate(r.receive_time.Value.Date);
                        // 日期不同则重置日期和运转时间
                        if (today != t)
                        {
                            today = t;
                        }

                        byte[] temp  = null;
                        int    index = 0;
                        if (gps)
                        {
                            if (r.protocol_type == ProtocolTypes.SATELLITE)
                            {
                                temp  = CustomConvert.GetBytes(r.message_content);
                                index = 13;
                            }
                        }
                        else
                        {
                            temp  = CustomConvert.GetBytes(r.message_content);
                            index = 0;
                        }

                        // 增加一个节点
                        Worktime wt = new Worktime();
                        wt.date     = r.receive_time.Value.ToString("yyyy/MM/dd HH:mm:ss");
                        wt.worktime = null == temp ? 0 : BitConverter.ToUInt32(temp, index);
                        var bin = !gps ? "00000000" : CustomConvert.IntToDigit(temp[4], CustomConvert.BIN, 8);
                        // 如果list已经有数据则计算与上一条数据之间的差值
                        var cnt = list.Count;
                        if (cnt > 0)
                        {
                            if (wt.worktime < list[cnt - 1].worktime)
                            {
                                // 当前运转时间小于前一条时,小计为0
                                wt.interval = 0;
                            }
                            else
                            {
                                // 差值
                                wt.interval = !gps ? 0 : (wt.worktime - list[cnt - 1].worktime);
                                // 计算差值与实际两条数据的接收时间差值的对比
                                if (wt.interval > timeInterval)
                                {
                                    // 如果运转时间差超过了这两条数据接收时间的差值,则记为0
                                    wt.interval = 0;
                                }
                                // 计算运转时间之间的差值  2016/08/15 15:00
                                if (wt.interval > 0)
                                {
                                    uint hour = (uint)r.receive_time.Value.Hour, min = (uint)r.receive_time.Value.Minute;
                                    // 凌晨0点的运转时间需要分开到两个日期里
                                    if (hour == 0)
                                    {
                                        // 时间间隔大于0点已过的分钟数,则需要把时间差分开到两个日期里
                                        if (wt.interval > min)
                                        {
                                            list[cnt - 1].interval += wt.interval - min;
                                            wt.interval             = min;
                                        }
                                    }
                                }
                                // 补偿的分钟
                                if (wt.interval > 0)
                                {
                                    uint ad = 0;
                                    if (wt.interval > 60)
                                    {
                                        ad = wt.interval / 60;
                                    }
                                    else
                                    {
                                        ad = 1;
                                    }
                                    if (bin[6] == '1')
                                    {
                                        ad += 1;
                                    }
                                    wt.added = ad;
                                }
                                else
                                {
                                    wt.interval = 0;
                                }
                                // 所用的小时
                                wt.hours = wt.interval > 0 ? (wt.interval > 60 ? wt.interval / 60 : 1) : 0;
                            }
                        }
                        else
                        {
                            // 第一条数据小计为0
                            wt.interval = 0;
                        }
                        list.Add(wt);

                        // 更新本日最后的运转时间
                        var wk = work.FirstOrDefault(f => f.x == today);
                        if (null != wk)
                        {
                            //if (wk.min == 0) { wk.min = run; }
                            wk.min = wt.worktime;
                        }
                    }// end of foreach

                    // 工作时间总计
                    var totalWorkMins = list.Sum(s => s.interval);
                    // 补偿的分钟
                    var totalAddMins = list.Sum(s => s.added);
                    // 所用的小时数
                    var totalUsedHours = list.Sum(s => s.hours);
                    // 工作效率
                    var compensate = totalWorkMins / 60.0 / totalUsedHours;
                    // 最终增加的小时数
                    var finalAdded = totalAddMins / 60.0 * compensate;

                    // 计算每日运转时间
                    foreach (var f in work)
                    {
                        f.y   = Math.Round(list.Where(w => w.date.Contains(f.date)).Sum(s => s.interval) / 60.0, 2);
                        f.add = finalAdded;
                    }
                    // 有工作时间的天数里平均加入补偿的小时数
                    var per = finalAdded / work.Count(c => c.y > 0);
                    //per = Math.Round(per, 2);
                    // 加入补偿
                    foreach (var w in work)
                    {
                        //if (!averagable)
                        {
                            w.y += w.y > 0 ? per : 0;
                            // 如果超过24小时则直接设为24小时  2016/08/15 15:16
                            if (w.y >= 24)
                            {
                                w.y = 24;
                            }
                        }
                        if (averagable)
                        {
                            w.y = Math.Round(w.y, 2);
                        }
                    }

                    // 计算平均值
                    var avgg = Math.Round(work.Sum(s => s.y) * 1.0 / work.Count, 2);
                    foreach (var a in avg)
                    {
                        a.y = avgg;
                    }
                }
                if (averagable)
                {
                    ret = string.Format("{0}\"Average\":{1},\"Worktime\":{2}{3}", "{", JsonConverter.ToJson(avg), JsonConverter.ToJson(work), "}");
                }
                else
                {
                    ret = JsonConverter.ToJson(work);
                }
            }
            return(ret);
        }
Example #22
0
        protected void btRentalEdit_Click(object sender, EventArgs e)
        {
            if (!HasSessionLose)
            {
                var id        = ParseInt(Utility.Decrypt(hiddenEditId.Value));
                var equipment = EquipmentInstance.Find(f => f.id == id && f.Deleted == false);
                if (null == equipment)
                {
                    ShowNotification("./equipment_rental.aspx", "Cannot find the equipment.", false);
                }
                else
                {
                    // 延期
                    if (optionExtend.Checked == true)
                    {
                        EquipmentInstance.Update(f => f.id == equipment.id, act =>
                        {
                            act.ReclaimTime = DateTime.Parse(deadLineExtend.Value);
                        });
                        equipment = EquipmentInstance.Find(f => f.id == id && f.Deleted == false);
                        // 保存操作历史记录
                        SaveHistory(new TB_AccountHistory()
                        {
                            ActionId = ActionInstance.Find(f => f.Name.Equals("ExtendRental")).id,
                            ObjectA  = EquipmentInstance.ToString(equipment) + ", Extend rental to: " +
                                       equipment.ReclaimTime.Value.ToString("yyyy/MM/dd")
                        });

                        ShowNotification("./equipment_rental.aspx", "You have extended the rental date.");
                    }
                    else if (optionReclaim.Checked == true)
                    {
                        // 保存之前的状态
                        var history = StoreInstance.GetObject();
                        history.Equipment = equipment.id;
                        history.Status    = equipment.Status;

                        // 更新
                        EquipmentInstance.Update(f => f.id == equipment.id, act =>
                        {
                            // 保存仓库信息
                            act.Warehouse = int.Parse(hiddenWarehouse.Value);
                            // 清除出厂日期和出厂时运转时间
                            act.OutdoorWorktime = 0;
                            act.OutdoorTime     = (DateTime?)null;
                            // 清除到期时间
                            act.ReclaimTime = (DateTime?)null;
                            // 客户信息清除
                            act.Customer   = (int?)null;
                            act.StoreTimes = equipment.StoreTimes + 1;
                            // 需要维修
                            if (cbRepair.Checked)
                            {
                                act.Status = StatusInstance.Find(f => f.IsItOverhaul == true).id;
                            }
                            else
                            {
                                act.Status = StatusInstance.Find(f => f.IsItInventory == true).id;
                            }
                        });
                        // 重新查询
                        equipment = EquipmentInstance.Find(f => f.id == id && f.Deleted == false);
                        // 保存入库信息
                        history.Stocktime = DateTime.Now;
                        // 入库次数加1
                        history.StoreTimes = equipment.StoreTimes;
                        history.Warehouse  = equipment.Warehouse;
                        StoreInstance.Add(history);

                        // 保存入库操作历史记录
                        SaveHistory(new TB_AccountHistory()
                        {
                            ActionId = ActionInstance.Find(f => f.Name.Equals("InStoreOld")).id,
                            ObjectA  = EquipmentInstance.GetFullNumber(equipment) + " recovered"
                        });

                        ShowNotification("./equipment_rental.aspx", "Equipment has been recovered.");
                    }
                }
            }
        }
Example #23
0
        private void ShowEquipments()
        {
            var totalRecords = 0;
            var pageIndex    = "" == hidPageIndex.Value ? 1 : int.Parse(hidPageIndex.Value);

            pageIndex = (0 >= pageIndex ? 1 : pageIndex);
            var model = ParseInt(selectedModels.Value);
            var house = ParseInt(hidQueryWarehouse.Value);
            var list  = EquipmentInstance.FindPageList <TB_Equipment>(pageIndex, PageSize, out totalRecords,
                                                                      f => f.Terminal == (int?)null && f.Deleted == false && (model <= 0 ? f.Model >= 0 : f.Model == model) &&
                                                                      (house <= 0 ? (f.Warehouse >= 0 || f.Warehouse == (int?)null) : f.Warehouse == house) &&
                                                                      (f.Number.IndexOf(txtQueryNumber.Value.Trim()) >= 0), null);
            var totalPages = totalRecords / PageSize + (totalRecords % PageSize > 0 ? 1 : 0);

            string html = "";

            if (totalRecords < 1)
            {
                html = "<tr><td colspan=\"11\">No records, You can change the condition and try again.</td></tr>";
            }
            else
            {
                var cnt = (pageIndex - 1) * PageSize;
                var n   = (int?)null;
                foreach (var obj in list)
                {
                    cnt++;
                    // 入库记录
                    var _in = StoreInstance.GetStoreInfo(obj.id, obj.StoreTimes.Value, true);
                    // 出库记录
                    var _out = StoreInstance.GetStoreInfo(obj.id, obj.StoreTimes.Value, false);

                    var id = Utility.UrlEncode(Utility.Encrypt(obj.id.ToString()));

                    html += "<tr title=\"click to dispatch work\">" +
                            "<td class=\"in-tab-txt-b\">" + cnt + "</td>" +
                            "<td class=\"in-tab-txt-b\">" + (n == obj.Model ? "-" : obj.TB_EquipmentModel.TB_EquipmentType.Code) + "</td>" +
                            "<td class=\"in-tab-txt-b textoverflow\" style=\"text-align: left !important;\">" + (n == obj.Model ? "-" : ("<a>" + EquipmentInstance.GetFullNumber(obj) + "</a>")) + "</td>" +
                            "<td class=\"in-tab-txt-b\" style=\"text-align: left !important;\">" + Utility.GetEquipmentFunctional(obj.Functional.Value) + "</td>" +
                            "<td class=\"in-tab-txt-rb\" title=\"" + EquipmentInstance.GetStatusTitle(obj) + "\">" + EquipmentInstance.GetStatus(obj) + "</td>" +
                            "<td class=\"in-tab-txt-b textoverflow\">" + (null == _in ? "-" : _in.Stocktime.Value.ToString("yyyy/MM/dd")) + "</td>" +
                            "<td class=\"in-tab-txt-b\" title=\"" + StoreInstance.GetStatusTitle(_in) + "\">" + StoreInstance.GetStatus(_in) + "</td>" +
                            "<td class=\"in-tab-txt-b textoverflow\">" + (null == _out ? "-" : _out.Stocktime.Value.ToString("yyyy/MM/dd")) + "</td>" +
                            "<td class=\"in-tab-txt-b\" title=\"" + StoreInstance.GetStatusTitle(_out) + "\">" + StoreInstance.GetStatus(_out) + "</td>" +
                            "<td class=\"in-tab-txt-b textoverflow\">" + (n == obj.Warehouse ? "-" : obj.TB_Warehouse.Name) + "</td>" +
                            "<td class=\"in-tab-txt-b\"></td>" +
                            "</tr>";
                }
            }
            tbodyBody.InnerHtml  = html;
            divPagging.InnerHtml = "";
            if (totalRecords > 0)
            {
                ShowPaggings(pageIndex, totalPages, totalRecords, "./equipment_inquiry.aspx", divPagging);
            }
        }
        /// <summary>
        /// 按照查询条件显示设备列表
        /// </summary>
        private void ShowEquipments()
        {
            var query = txtQueryNumber.Value.Trim();

            // 模糊查询时页码置为空
            if (!string.IsNullOrEmpty(query))
            {
                hidPageIndex.Value = "";
            }

            var totalRecords = 0;
            var pageIndex    = "" == hidPageIndex.Value ? 1 : int.Parse(hidPageIndex.Value);

            pageIndex = (0 >= pageIndex ? 1 : pageIndex);
            var type  = ParseInt(selectedTypes.Value);
            var model = ParseInt(selectedModels.Value);
            var house = ParseInt(hidQueryWarehouse.Value);
            // 表达式
            Expression <Func <TB_Equipment, bool> > expression = PredicateExtensions.True <TB_Equipment>();

            expression = expression.And(a => a.TB_EquipmentStatusName.IsItInventory == true && a.Deleted == false && a.StoreTimes == 1 && a.Terminal != (int?)null);
            if (type > 0)
            {
                expression = expression.And(a => a.TB_EquipmentModel.Type == type);
            }
            if (model > 0)
            {
                expression = expression.And(a => a.Model == model);
            }
            if (house > 0)
            {
                expression = expression.And(a => a.Warehouse == house);
            }
            if (!string.IsNullOrEmpty(query))
            {
                pageIndex  = 1;
                expression = expression.And(a => a.Number.Contains(query));
            }
            var list       = EquipmentInstance.FindPageList <TB_Equipment>(pageIndex, PageSize, out totalRecords, expression, null);
            var totalPages = totalRecords / PageSize + (totalRecords % PageSize > 0 ? 1 : 0);

            hidTotalPages.Value = totalPages.ToString();

            string html = "";

            if (totalRecords < 1)
            {
                html = "<tr><td colspan=\"18\">No records, You can change the condition and try again.</td></tr>";
            }
            else
            {
                var cnt = (pageIndex - 1) * PageSize;
                var n   = (int?)null;
                foreach (var obj in list)
                {
                    cnt++;
                    // 入库记录
                    //var _in = StoreInstance.GetStoreInfo(obj.id, obj.StoreTimes.Value, true);
                    // 出库记录
                    //var _out = StoreInstance.GetStoreInfo(obj.id, obj.StoreTimes.Value, false);
                    var id = Utility.UrlEncode(Utility.Encrypt(obj.id.ToString()));
                    html += "<tr>" +
                            "<td class=\"in-tab-txt-b\">" + cnt + "</td>" +
                            "<td class=\"in-tab-txt-b\">" + (n == obj.Model ? "-" : obj.TB_EquipmentModel.TB_EquipmentType.Code) + "</td>" +
                            "<td class=\"in-tab-txt-b textoverflow\" style=\"text-align: left !important;\">" + (n == obj.Model ? "-" : ("<a href=\"./equipment_position.aspx?key=" + id + "\">" + EquipmentInstance.GetFullNumber(obj) + "</a>")) + "</td>" +
                            "<td class=\"in-tab-txt-b\" style=\"text-align: left !important;\">" + Utility.GetEquipmentFunctional(obj.Functional.Value) + "</td>" +
                            "<td class=\"in-tab-txt-b\" style=\"text-align: right !important;\">" + EquipmentBLL.GetRuntime(obj.Runtime + obj.InitializedRuntime, obj.CompensatedHours.Value) + "</td>" +
                            "<td class=\"in-tab-txt-b\">" + EquipmentInstance.GetEngStatus(obj) + "</td>" +
                            "<td class=\"in-tab-txt-b textoverflow\" title=\"" + obj.GpsAddress + "\">" + obj.GpsAddress + "</td>" +
                            "<td class=\"in-tab-txt-rb\" title=\"" + EquipmentInstance.GetStatusTitle(obj) + "\">" + EquipmentInstance.GetStatus(obj) + "</td>" +
                            "<td class=\"in-tab-txt-b\">" + EquipmentInstance.GetOutdoorDays(obj) + "</td>" +
                            "<td class=\"in-tab-txt-rb textoverflow\">" + EquipmentInstance.GetAverageWorktime(obj) + "</td>" +
                            //"<td class=\"in-tab-txt-b textoverflow\">" + (null == _in ? "-" : _in.Stocktime.Value.ToString("yyyy/MM/dd")) + "</td>" +
                            //"<td class=\"in-tab-txt-b\" title=\"" + StoreInstance.GetStatusTitle(_in) + "\">" + StoreInstance.GetStatus(_in) + "</td>" +
                            //"<td class=\"in-tab-txt-b textoverflow\">" + (null == _out ? "-" : _out.Stocktime.Value.ToString("yyyy/MM/dd")) + "</td>" +
                            //"<td class=\"in-tab-txt-b\" title=\"" + StoreInstance.GetStatusTitle(_out) + "\">" + StoreInstance.GetStatus(_out) + "</td>" +
                            "<td class=\"in-tab-txt-rb textoverflow\">" + obj.TB_Warehouse.Name + "</td>" +
                            //"<td class=\"in-tab-txt-b\">" + ((byte?)null == obj.Signal ? "-" : obj.Signal.ToString()) + "</td>" +
                            "<td class=\"in-tab-txt-b\">" + Utility.GetOnlineStyle(obj.OnlineStyle, obj.OnlineTime, false) + "</td>" +
                            "<td class=\"in-tab-txt-b textoverflow\">" + ((DateTime?)null == obj.LastActionTime ? "" : obj.LastActionTime.Value.ToString("yyyy/MM/dd HH:mm")) + "</td>" +
                            "<td class=\"in-tab-txt-b textoverflow\" title=\"" + EquipmentInstance.GetTerinalTitleInfo(obj) + "\">" + (n == obj.Terminal ? "-" : obj.TB_Terminal.Number) + "</td>" +
                            "</tr>";
                }
            }
            tbodyBody.InnerHtml  = html;
            divPagging.InnerHtml = "";
            if (totalRecords > 0)
            {
                ShowPaggings(pageIndex, totalPages, totalRecords, "./equipment_in_storage.aspx", divPagging);
            }
        }
Example #25
0
        protected void btUnbindEquipment_Click(object sender, EventArgs e)
        {
            var value = hidBoundSatellite.Value.Trim();

            if (string.IsNullOrEmpty(value))
            {
                return;
            }
            var id       = int.Parse(value);
            var terminal = TerminalInstance.Find(f => f.id == id);

            if (null == terminal)
            {
                return;
            }

            var equipment = EquipmentInstance.Find(f => f.Terminal == id && f.Deleted == false);

            // 更新设备的终端为空并清空设备的相应值
            EquipmentInstance.Update(f => f.Terminal == id && f.Deleted == false, act =>
            {
                act.Terminal       = (int?)null;
                act.GpsAddress     = "";
                act.LastAction     = "";
                act.LastActionBy   = "";
                act.LastActionTime = (DateTime?)null;
                act.Latitude       = 0.0;
                act.Longitude      = 0.0;
                act.OnlineStyle    = (byte?)null;
                act.OnlineTime     = (DateTime?)null;
                act.Runtime        = 0;
                act.Socket         = 0;
                act.Port           = 0;
                act.IP             = "";
                act.LockStatus     = "00";
                act.Rpm            = 0;
                act.Signal         = 0;
                act.Voltage        = "G0000";
            });
            // 更新终端的绑定状态为false
            TerminalInstance.Update(f => f.id == id, act =>
            {
                act.HasBound = false;
            });
            // 保存解绑终端历史
            SaveHistory(new TB_AccountHistory()
            {
                ActionId = ActionInstance.Find(f => f.Name.Equals("Unbind")).id,
                ObjectA  = "unbind terminal " + terminal.Number + " and equipment " + EquipmentInstance.GetFullNumber(equipment)
            });

            ShowNotification("./terminal_list.aspx", "You have unbind the terminal and equipment.");
        }
Example #26
0
        /// <summary>
        /// 查询指定设备在指定日期范围内每日运转时间
        /// </summary>
        /// <returns></returns>
        private string HandleEquipmentWorktime(bool averagable = true)
        {
            var ret = "{}";
            var id  = ParseInt(Utility.Decrypt(data));
            var obj = EquipmentInstance.Find(f => f.id == id && f.Deleted == false);

            if (null != obj)
            {
                var date = DateTime.Parse(GetParamenter("date") + " 00:00:00");
                // 如果不是求平均值则将日期往前推一天
                //if (!averagable) { date = date.AddDays(-1); }
                var date1 = DateTime.Parse(GetParamenter("date1") + " 23:59:59");
                List <WorktimeChart> avg  = new List <WorktimeChart>();
                List <WorktimeChart> work = new List <WorktimeChart>();
                DateTime             dt   = date;
                // 循环每天一个节点
                while (dt.Ticks < date1.Ticks)
                {
                    avg.Add(new WorktimeChart()
                    {
                        date = dt.ToString("yyyy/MM/dd"), x = Utility.DateTimeToJavascriptDate(dt.Date), y = 0, min = 0
                    });
                    work.Add(new WorktimeChart()
                    {
                        date = dt.ToString("yyyy/MM/dd"), x = Utility.DateTimeToJavascriptDate(dt.Date), y = 0, min = 0
                    });
                    dt = dt.AddDays(1);
                }
                var macid    = EquipmentInstance.GetFullNumber(obj);
                var cmds     = new string[] { "0x1000", "0x1001", "0x5000", "0x6004", "0x600B", "0xCC00" };
                var runtimes = DataInstance.FindList(f => f.mac_id.Equals(macid) && cmds.Contains(f.command_id) &&
                                                     f.receive_time >= date.AddDays(-1) && f.receive_time <= date1.AddDays(1)).OrderBy(o => o.receive_time);
                var list = new List <WorkTime>();
                if (null != runtimes)
                {
                    long today = 0;
                    foreach (var r in runtimes)
                    {
                        var t = Utility.DateTimeToJavascriptDate(r.receive_time.Value.Date);
                        // 日期不同则重置日期和运转时间
                        if (today != t)
                        {
                            today = t;
                        }

                        byte[] temp  = null;
                        int    index = 0;
                        if (r.command_id.Equals("0x1000"))
                        {
                            if (r.protocol_type == ProtocolTypes.SATELLITE)
                            {
                                temp  = CustomConvert.GetBytes(r.message_content);
                                index = 13;
                            }
                        }
                        else if (r.command_id.Equals("0x1001"))
                        {
                            temp  = CustomConvert.GetBytes(r.message_content);
                            index = 37;
                        }
                        else if (r.command_id.Equals("0x5000"))
                        {
                            // 只有装载机和电装的挖掘机才能有5000命令的总运转时间
                            if (r.terminal_type >= TerminalTypes.DXE)
                            {
                                temp  = CustomConvert.GetBytes(r.message_content);
                                index = 0;
                            }
                        }
                        else if (r.command_id.Equals("0x600B"))
                        {
                            temp  = CustomConvert.GetBytes(r.message_content);
                            index = 0;
                        }
                        else if (r.command_id.Equals("0xCC00"))
                        {
                            temp  = CustomConvert.GetBytes(r.message_content);
                            index = 12;
                        }
                        else
                        {
                            temp = CustomConvert.GetBytes(r.message_content);

                            byte tp = r.terminal_type.Value;
                            index = tp == TerminalTypes.DH ? 2 : (tp == TerminalTypes.DX ? 5 : 1);
                        }

                        // 增加一个节点
                        WorkTime wt = new WorkTime();
                        wt.date = r.receive_time.Value.ToString("yyyy/MM/dd HH:mm:ss");
                        wt.time = null == temp ? 0 : BitConverter.ToUInt32(temp, index);
                        // 如果list已经有数据则计算与上一条数据之间的差值
                        var cnt = list.Count;
                        if (cnt > 0)
                        {
                            if (wt.time < list[cnt - 1].time)
                            {
                                // 当前运转时间小于前一条时,小计为0
                                wt.subtotal = 0;
                            }
                            else
                            {
                                // 否则小计为差值
                                wt.subtotal = wt.time - list[cnt - 1].time;
                                // 每日凌晨1点之前,如果计算的时间差超过了当前时间的分钟数,则只计算分钟数
                                if (r.receive_time.Value.Hour < 1 && wt.subtotal > r.receive_time.Value.Minute)
                                {
                                    // 每日1时之前计算的时间差大于已经过去了的分钟数则将差值算到前一天最后一条数据里
                                    if (cnt > 0)
                                    {
                                        list[cnt - 1].subtotal += (uint)(wt.subtotal - r.receive_time.Value.Minute);
                                    }
                                    wt.subtotal = (uint)r.receive_time.Value.Minute;
                                }
                                // 小于0时算作0
                                if (wt.subtotal < 0)
                                {
                                    wt.subtotal = 0;
                                }
                                // 如果与上一条日期的分钟数相差12个小时以上则记为0
                                DateTime lst = DateTime.Parse(list[cnt - 1].date);
                                if ((lst - r.receive_time.Value).Duration().TotalMinutes >= DAY_MINUTES / 2)
                                {
                                    wt.subtotal = 0;
                                }
                                // 大于24小时算作0
                                if (wt.subtotal >= DAY_MINUTES)
                                {
                                    wt.subtotal = 0;
                                }
                            }
                        }
                        else
                        {
                            // 第一条数据小计为0
                            wt.subtotal = 0;
                        }
                        list.Add(wt);

                        // 更新本日最后的运转时间
                        var wk = work.FirstOrDefault(f => f.x == today);
                        if (null != wk)
                        {
                            //if (wk.min == 0) { wk.min = run; }
                            wk.min = wt.time;
                        }
                    }// end of foreach

                    // 计算每日运转时间
                    foreach (var f in work)
                    {
                        f.y = Math.Round(list.Where(w => w.date.Contains(f.date)).Sum(s => s.subtotal) / 60.0, 2);
                    }

                    // 计算平均值
                    var avgg = Math.Round(work.Sum(s => s.y) * 1.0 / work.Count, 2);
                    foreach (var a in avg)
                    {
                        a.y = avgg;
                    }
                }
                if (averagable)
                {
                    ret = string.Format("{0}\"Average\":{1},\"Worktime\":{2}{3}", "{", JsonConverter.ToJson(avg), JsonConverter.ToJson(work), "}");
                }
                else
                {
                    ret = JsonConverter.ToJson(work);
                }
            }
            return(ret);
        }
Example #27
0
        private void ShowEquipments()
        {
            var query = txtQueryNumber.Value.Trim();

            // 模糊查询时页码置为空
            if (!string.IsNullOrEmpty(query))
            {
                hidPageIndex.Value = "";
            }

            var totalRecords = 0;
            var pageIndex    = "" == hidPageIndex.Value ? 1 : int.Parse(hidPageIndex.Value);

            pageIndex = (0 >= pageIndex ? 1 : pageIndex);
            var type     = ParseInt(selectedTypes.Value);
            var model    = ParseInt(selectedModels.Value);
            var house    = 0;//ParseInt(hidQueryWarehouse.Value);
            var customer = ParseInt(hiddenCustomer.Value);

            // 表达式
            Expression <Func <TB_Equipment, bool> > expression = PredicateExtensions.True <TB_Equipment>();

            // 设备类型
            if (type > 0)
            {
                expression = expression.And(a => a.TB_EquipmentModel.Type == type);
            }
            // 设备型号
            if (model > 0)
            {
                expression = expression.And(a => a.Model == model);
            }
            // 仓库
            if (house > 0)
            {
                expression = expression.And(a => a.Warehouse == house);
            }
            // 查询号码
            if (!string.IsNullOrEmpty(query))
            {
                expression = expression.And(a => a.Number.Contains(query) || a.TB_Customer.Code.Contains(query));
            }
            // 客户号码
            switch (customer)
            {
            case 3:
                // None
                expression = expression.And(a => a.Customer == (int?)null);
                break;

            case 2:
                // Bound
                expression = expression.And(a => a.Customer != (int?)null);
                //if (!string.IsNullOrEmpty(query))
                //{
                //    expression = expression.And(a => a.TB_Customer.Code.Contains(query));
                //}
                break;

            default:
                // Default
                break;
            }
            // 终端绑定状态
            var terminal = ParseInt(hiddenTerminal.Value.Trim());

            switch (terminal)
            {
            case 2:
                // 绑定终端了
                expression = expression.And(a => a.Terminal != (int?)null);
                break;

            case 3:
                // 未绑定终端
                expression = expression.And(a => a.Terminal == (int?)null);
                break;

            default:
                // 忽略的话就是不查询终端的绑定状态
                break;
            }
            expression = expression.And(a => a.Deleted == false);

            var list       = EquipmentInstance.FindPageList <TB_Equipment>(pageIndex, PageSize, out totalRecords, expression, null);
            var totalPages = totalRecords / PageSize + (totalRecords % PageSize > 0 ? 1 : 0);

            hidTotalPages.Value = totalPages.ToString();

            string html = "";

            if (totalRecords < 1)
            {
                html = "<tr><td colspan=\"16\">No records, You can change the condition and try again.</td></tr>";
            }
            else
            {
                var cnt = (pageIndex - 1) * PageSize;
                var n   = (int?)null;
                foreach (var obj in list)
                {
                    cnt++;
                    // 入库记录
                    //var _in = StoreInstance.GetStoreInfo(obj.id, obj.StoreTimes.Value, true);
                    // 出库记录
                    //var _out = StoreInstance.GetStoreInfo(obj.id, obj.StoreTimes.Value, false);

                    var  id  = Utility.UrlEncode(Utility.Encrypt(obj.id.ToString()));
                    bool sat = n != obj.Terminal && n != obj.TB_Terminal.Satellite;

                    // 锁车状态和报警信息
                    string arms = EquipmentInstance.GetLockEffectedStatus(obj);
                    if (string.IsNullOrEmpty(arms))
                    {
                        arms = EquipmentInstance.GetAlarmStatus(obj.Alarm);
                    }

                    html += "<tr>" +
                            "<td class=\"in-tab-txt-b\">" + cnt + "</td>" +
                            "<td class=\"in-tab-txt-b\">" + (n == obj.Model ? "-" : obj.TB_EquipmentModel.TB_EquipmentType.Code) + "</td>" +
                            "<td class=\"in-tab-txt-b textoverflow\" style=\"text-align: left !important;\">" + (n == obj.Model ? "-" : ("<a href=\"./equipment_position.aspx?key=" + id + "\">" + EquipmentInstance.GetFullNumber(obj) + "</a>")) + "</td>" +
                            "<td class=\"in-tab-txt-b\" style=\"text-align: left !important;\">" + Utility.GetEquipmentFunctional(obj.Functional.Value) + "</td>" +
                            "<td class=\"in-tab-txt-b\" style=\"text-align: right !important;\">" + EquipmentBLL.GetRuntime(obj.Runtime + obj.InitializedRuntime, obj.CompensatedHours.Value) + "</td>" +
                            "<td class=\"in-tab-txt-b\" style=\"padding: 2px !important; vertical-align: middle !important;\">" + EquipmentInstance.GetEngStatus(obj) + "</td>" +
                            "<td class=\"in-tab-txt-b textoverflow\" title=\"" + obj.GpsAddress + "\" style=\"text-align: left !important;\">" + obj.GpsAddress + "</td>" +
                            "<td class=\"in-tab-txt-rb\" title=\"" + EquipmentInstance.GetStatusTitle(obj) + "\">" + EquipmentInstance.GetStatus(obj) + "</td>" +
                            //"<td class=\"in-tab-txt-b\">" + EquipmentInstance.GetOutdoorDays(obj) + "</td>" +
                            //"<td class=\"in-tab-txt-rb textoverflow\">" + EquipmentInstance.GetAverageWorktime(obj) + "</td>" +
                            "<td class=\"in-tab-txt-b\">" + (n == obj.Customer ? "-" : obj.TB_Customer.Code) + "</td>" +
                            "<td class=\"in-tab-txt-rb textoverflow\" style=\"text-align: left !important;\" title=\"" + (n == obj.Customer ? "-" : obj.TB_Customer.Name) + "\">" + (n == obj.Customer ? "-" : obj.TB_Customer.Name) + "</td>" +
                            //"<td class=\"in-tab-txt-b\">" + ((byte?)null == obj.Signal ? "-" : obj.Signal.ToString()) + "</td>" +
                            "<td class=\"in-tab-txt-b\">" + Utility.GetOnlineStyle(obj.OnlineStyle, obj.OnlineTime) + "</td>" +
                            "<td class=\"in-tab-txt-b\">" + arms + "</td>" +
                            "<td class=\"in-tab-txt-b textoverflow\">" + ((DateTime?)null == obj.LastActionTime ? "" : obj.LastActionTime.Value.ToString("yyyy/MM/dd HH:mm")) + "</td>" +
                            "<td class=\"in-tab-txt-b textoverflow\" title=\"" + EquipmentInstance.GetTerinalTitleInfo(obj) + "\">" + (n == obj.Terminal ? "-" : obj.TB_Terminal.Number) + "</td>" +
                            "<td class=\"in-tab-txt-rb\" title=\"" + EquipmentInstance.GetSatelliteTitleInfo(obj) + "\"><span class=\"glyphicon glyphicon-" + (sat ? "ok" : "remove") + " text-" + (sat ? "success" : "danger") + "\" aria-hidden=\"true\"></span></td>" +
                            //"<td class=\"in-tab-txt-b textoverflow\">" + (null == _in ? "-" : _in.Stocktime.Value.ToString("yyyy/MM/dd")) + "</td>" +
                            //"<td class=\"in-tab-txt-b\" title=\"" + StoreInstance.GetStatusTitle(_in) + "\">" + StoreInstance.GetStatus(_in) + "</td>" +
                            //"<td class=\"in-tab-txt-b textoverflow\">" + (null == _out ? "-" : _out.Stocktime.Value.ToString("yyyy/MM/dd")) + "</td>" +
                            //"<td class=\"in-tab-txt-b\" title=\"" + StoreInstance.GetStatusTitle(_out) + "\">" + StoreInstance.GetStatus(_out) + "</td>" +
                            "<td class=\"in-tab-txt-b textoverflow\">" + (n == obj.Warehouse ? "-" : obj.TB_Warehouse.Name) + "</td>" +
                            //"<td class=\"in-tab-txt-b\">" + (n == obj.Terminal ? "-" : (n == obj.TB_Terminal.Satellite ? "-" : obj.TB_Terminal.TB_Satellite.CardNo)) + "</td>" +
                            //"<td class=\"in-tab-txt-rb\">" + (n == obj.Terminal ? "-" : obj.TB_Terminal.Sim) + "</td>" +
                            "</tr>";
                }
            }
            tbodyBody.InnerHtml  = html;
            divPagging.InnerHtml = "";
            if (totalRecords > 0)
            {
                ShowPaggings(pageIndex, totalPages, totalRecords, "./equipment_inquiry.aspx", divPagging);
            }
        }