示例#1
0
 /// <summary>
 /// 返回状态信息
 /// </summary>
 /// <param name="status"></param>
 /// <param name="text"></param>
 /// <param name="json"></param>
 private void ResponseData(int status, string text, bool json = false)
 {
     SatelliteInstance.Close();
     TerminalInstance.Close();
     ResponseJson(string.Format("{0}\"State\":{1},\"Type\":\"{2}\",\"Data\":{3}{4}{5}{6}",
                                "{", status, type, (json ? "" : "\""), text, (json ? "" : "\""), "}"));
 }
示例#2
0
        private void EditSatellite()
        {
            var num = txtNumber.Value.Trim();
            var t   = SatelliteInstance.Find(f => f.id == ParseInt(Utility.Decrypt(hidID.Value)));

            if (null != t)
            {
                var old = SatelliteInstance.Find(f => f.CardNo.Equals(num));
                if (null != old && old.id != t.id)
                {
                    ShowNotification("./satellite_manage.aspx", "Cannot edit the satellite object: The number has exist.", false);
                }
                else
                {
                    SatelliteInstance.Update(f => f.id == t.id, act => { act.CardNo = num; });
                    SaveHistory(new TB_AccountHistory()
                    {
                        ActionId = ActionInstance.Find(f => f.Name.Equals("EditSat")).id,
                        ObjectA  = SatelliteInstance.ToString(t)
                    });
                    ShowNotification("./satellite_manage.aspx", "You saved the satellite information.");
                }
            }
            else
            {
                ShowNotification("./satellite_manage.aspx", "Cannot edit the satellite object: no record exist.", false);
            }
        }
示例#3
0
        /// <summary>
        /// 解绑终端和卫星模块
        /// </summary>
        private void UnboundSatellite()
        {
            var id = int.Parse(hidBoundSatellite.Value.Trim());
            var t  = TerminalInstance.Find(f => f.id == id);

            if (null == t)
            {
                ShowNotification("./terminal_list.aspx", "Unbind fail: Terminal not exists.", false);
            }
            else
            {
                if ((int?)null == t.Satellite)
                {
                    ShowNotification("./terminal_list.aspx", "Unbind fail: No Satellite bound on it.", false);
                }
                else
                {
                    string satno = t.TB_Satellite.CardNo;
                    TerminalInstance.Update(f => f.id == t.id, act =>
                    {
                        act.Satellite = (int?)null;
                        // 更新终端的链接为OFF
                        if (act.OnlineStyle == (byte)LinkType.SATELLITE)
                        {
                            act.OnlineStyle = (byte?)null;
                        }
                        // 更新卫星功能为false
                        act.SatelliteStatus = false;
                    });
                    // 更新设备的链接为OFF
                    EquipmentInstance.Update(f => f.Terminal == t.id, act =>
                    {
                        if (act.OnlineStyle == (byte)LinkType.SATELLITE)
                        {
                            act.OnlineStyle = (byte?)null;
                        }
                        act.SatelliteStatus = false;
                    });
                    SatelliteInstance.Update(f => f.id == t.Satellite, act => { act.Bound = false; });
                    // 发送解绑卫星模块的命令
                    SendDD02Command(false, t);
                    SaveHistory(new TB_AccountHistory()
                    {
                        ActionId = ActionInstance.Find(f => f.Name.Equals("UnbindSat")).id,
                        ObjectA  = "Ter: " + t.Number + " unbind Sat: " + satno
                    });
                    ShowNotification("./terminal_list.aspx", "Ter: " + t.Number + " unbind Sat: " + satno + " OK!");
                }
            }
        }
示例#4
0
        private void ShowEdit()
        {
            var t = SatelliteInstance.Find(f => f.id == ParseInt(Utility.Decrypt(hidID.Value)));

            if (null != t)
            {
                txtNumber.Value = t.CardNo;
                btSave.Text     = "Save";
            }
            else
            {
                ShowNotification("./satellite_manage.aspx", "Error: Cannot edit null object of <a>Satellite Item</a>.", false);
            }
        }
        protected void btSave_Click(object sender, EventArgs e)
        {
            // 保存新的铱星模块号码
            var number = txtQueryNumber.Value.Trim();
            var len    = number.Length;

            if (len != 6 && len != 15)
            {
                ShowNotification("/iridium_model_register.aspx", "Your input is not a Iridium IMEI number.", false);
            }
            else
            {
                var pre = number.Substring(0, 3);
                if (pre != "306" && pre != "300")
                {
                    ShowNotification("/iridium_model_register.aspx", "Your input is not a Iridium IMEI number.", false);
                }
                else
                {
                    var obj = SatelliteInstance.Find(f => f.CardNo.Equals(number));
                    if (null != obj)
                    {
                        ShowNotification("/iridium_model_register.aspx", "There have a SAME satellite IMEI number exist.", false);
                    }
                    else
                    {
                        var old       = SatelliteInstance.FindList <TB_Satellite>(f => f.PcbNumber.Contains("Satellite"), "PcbNumber", true).FirstOrDefault();
                        var newNumber = "Satellite";
                        var num       = 0;
                        if (null != old)
                        {
                            var tmp = old.PcbNumber.ToLower().Replace("satellite", "");
                            num = int.Parse(tmp);
                        }
                        newNumber = string.Format("{0}{1:0000}", newNumber, num + 1);
                        var n = SatelliteInstance.GetObject();
                        n.CardNo    = number;
                        n.PcbNumber = newNumber;
                        SatelliteInstance.Add(n);
                        ShowSatellites();
                    }
                }
            }
        }
        /// <summary>
        /// 显示已经登记了的卫星号码列表
        /// </summary>
        private void ShowSatellites()
        {
            var number = txtQueryNumber.Value.Trim();

            number = string.IsNullOrEmpty(number) ? "" : number;
            var totalRecords = 0;
            var pageIndex    = "" == hidPageIndex.Value ? 1 : int.Parse(hidPageIndex.Value);
            var list         = SatelliteInstance.FindPageList <TB_Satellite>(pageIndex, PageSize, out totalRecords,
                                                                             f => f.CardNo.IndexOf(number) >= 0 && f.CardNo.Length > 10, "RegisterDate", true);
            var totalPages = totalRecords / PageSize + (totalRecords % PageSize > 0 ? 1 : 0);

            string html = "";

            if (totalRecords < 1)
            {
                html = "<tr><td colspan=\"7\">No records, you can change condition and try again, or " +
                       " <a>Add</a> some new one.</td></tr>";
            }
            else
            {
                var cnt = (pageIndex - 1) * PageSize;
                foreach (var obj in list)
                {
                    cnt++;
                    //var id = Utility.UrlEncode(Utility.Encrypt(obj.id.ToString()));
                    html += "<tr>" +
                            "<td style=\"text-align: center;\">" + cnt + "</td>" +
                            "<td><a style=\"cursor: pointer;\" data-toggle=\"modal\" data-target=\"#modalManufacturing\" data-whatever=\"" + obj.CardNo + "\" data-id=\"" + obj.id + "\">" + obj.CardNo + "</a></td>" +
                            "<td>" + obj.RegisterDate.Value.ToString("yyyy/MM/dd HH:mm:ss") + "</td>" +
                            "<td style=\"text-align: center;\">" + (obj.Bound.Value ? "Yes" : "No") + "</td>" +
                            "<td>" + (string.IsNullOrEmpty(obj.PcbNumber) ? "-" : obj.PcbNumber) + "</td>" +
                            "<td>" + (string.IsNullOrEmpty(obj.ManufactureDate) ? "-" : obj.ManufactureDate) + "</td>" +
                            "<td></td>" +
                            "</tr>";
                }
            }
            tbodyBody.InnerHtml  = html;
            divPagging.InnerHtml = "";
            if (totalRecords > 0)
            {
                ShowPaggings(pageIndex, totalPages, totalRecords, "iridium_model_register.aspx", divPagging);
            }
        }
示例#7
0
        /// <summary>
        /// 显示未绑定终端的卫星号码列表
        /// </summary>
        private void ShowSatellites()
        {
            var totalRecords = 0;
            var pageIndex    = "" == hidPageIndex.Value ? 1 : int.Parse(hidPageIndex.Value);
            var list         = SatelliteInstance.FindPageList <TB_Satellite>(pageIndex, _page_size, out totalRecords,
                                                                             f => f.Bound == false, "CardNo");
            var totalPages = totalRecords / _page_size + (totalRecords % _page_size > 0 ? 1 : 0);

            string html = "";

            if (totalRecords < 1)
            {
                html = "<tr><td colspan=\"6\">No records</td></tr>";
            }
            else
            {
                var cnt = (pageIndex - 1) * _page_size;
                foreach (var obj in list)
                {
                    cnt++;
                    var id = Utility.UrlEncode(Utility.Encrypt(obj.id.ToString()));
                    html += "<tr>" +
                            "<td style=\"text-align: center;\">" +
                            "<input type=\"radio\" name=\"satId\" id=\"cb_" + id + "\" /></td>" +
                            "<td style=\"text-align: center;\">" + cnt + "</td>" +
                            "<td>" + obj.CardNo + "</td>" +
                            "<td>" + obj.Bound.Value + "</td>" +
                            "<td>" + obj.RegisterDate.Value.ToString("yyyy-MM-dd") + "</td>" +
                            "<td></td>" +
                            "</tr>";
                }
            }
            tbodyBody.InnerHtml  = html;
            divPagging.InnerHtml = "";
            if (totalRecords > 0)
            {
                ShowPaggings(pageIndex, totalPages, totalRecords, "./terminal_satellite.aspx", divPagging);
            }
        }
示例#8
0
        private void ShowSatellites()
        {
            var totalRecords = 0;
            var pageIndex    = "" == hidPageIndex.Value ? 1 : int.Parse(hidPageIndex.Value);
            var list         = SatelliteInstance.FindPageList <TB_Satellite>(pageIndex, PageSize, out totalRecords, null, "CardNo");
            var totalPages   = totalRecords / PageSize + (totalRecords % PageSize > 0 ? 1 : 0);

            string html = "";

            if (totalRecords < 1)
            {
                html = "<tr><td colspan=\"6\">No records, you can change condition and try again, or " +
                       " <a>Add</a> some new one.</td></tr>";
            }
            else
            {
                var cnt = (pageIndex - 1) * PageSize;
                foreach (var obj in list)
                {
                    cnt++;
                    var id = Utility.UrlEncode(Utility.Encrypt(obj.id.ToString()));
                    html += "<tr>" +
                            // 系统默认角色无法删除
                            "<td style=\"width: 40px; text-align: center;\"><input type=\"checkbox\" id=\"cb_" + id + "\" /></td>" +
                            "<td style=\"width: 40px; text-align: center;\">" + cnt + "</td>" +
                            "<td><a href=\"./satellite_manage.aspx?key=" + id + "\" >" + obj.CardNo + "</a></td>" +
                            "<td>" + obj.RegisterDate.Value.ToString("yyyy-MM-dd") + "</td>" +
                            "<td>" + obj.Bound.ToString() + "</td>" +
                            "<td></td>" +
                            "</tr>";
                }
            }
            tbodyBody.InnerHtml  = html;
            divPagging.InnerHtml = "";
            if (totalRecords > 0)
            {
                ShowPaggings(pageIndex, totalPages, totalRecords, "./satellite_manage.aspx", divPagging);
            }
        }
示例#9
0
        private void NewSatellite()
        {
            var num = txtNumber.Value.Trim();
            var t   = SatelliteInstance.Find(f => f.CardNo.Equals(num));

            if (null != t)
            {
                ShowNotification("./satellite_manage.aspx", "Error: A old one has the same card number <a>" + num + "</a>.", false);
                return;
            }
            else
            {
                var obj = SatelliteInstance.GetObject();
                obj.CardNo = num;
                SatelliteInstance.Add(obj);

                SaveHistory(new TB_AccountHistory()
                {
                    ActionId = ActionInstance.Find(f => f.Name.Equals("AddSat")).id,
                    ObjectA  = SatelliteInstance.ToString(obj)
                });
                ShowNotification("./satellite_manage.aspx", "You add a new satellite object.");
            }
        }
示例#10
0
        protected void btBoundSatellite_Click(object sender, EventArgs e)
        {
            var value = hidBoundSatellite.Value.Trim();

            if (string.IsNullOrEmpty(value))
            {
                return;
            }
            // 为终端绑定卫星模块
            var index = value.IndexOf(',');

            if (index < 0)
            {
                // 没有,分割的是解绑卫星模块
                UnboundSatellite();
                return;
            }
            var tid = value.Substring(0, index);
            var gid = value.Substring(index + 1);

            gid = Utility.Decrypt(gid);
            var t = TerminalInstance.Find(f => f.id == int.Parse(tid));

            if (null == t)
            {
                ShowNotification("./terminal_list.aspx", "Bound fail: Terminal not exists.", false);
            }
            else
            {
                if (t.Satellite != (int?)null)
                {
                    ShowNotification("./terminal_list.aspx", "Terminal \"" + t.Number + "\" has bound Satellite: " + t.TB_Satellite.CardNo, false);
                }
                else
                {
                    var g = SatelliteInstance.Find(f => f.id == int.Parse(gid));
                    if (null == g)
                    {
                        ShowNotification("./terminal_list.aspx", "No Satellite info exists.", false);
                    }
                    else
                    {
                        if (g.Bound == true)
                        {
                            var gt = TerminalInstance.Find(f => f.TB_Satellite.id == g.id);
                            ShowNotification("./terminal_list.aspx", "Satellite \"" + g.CardNo + "\" has bound on Terminal: " + gt.Number, false);
                        }
                        else
                        {
                            TerminalInstance.Update(f => f.id == t.id, act =>
                            {
                                act.Satellite = g.id;
                            });
                            t = TerminalInstance.Find(f => f.id == t.id);
                            SatelliteInstance.Update(f => f.id == g.id, act => { act.Bound = true; });
                            // 发送绑定卫星模块的命令
                            SendDD02Command(true, t);
                            // 保存绑定卫星模块的历史记录
                            SaveHistory(new TB_AccountHistory()
                            {
                                ActionId = ActionInstance.Find(f => f.Name.Equals("BindSat")).id,
                                ObjectA  = TerminalInstance.ToString(t)
                            });
                            //ShowTerminals();
                            ShowNotification("./terminal_list.aspx", "Terminal \"" + t.Number + "\" bound Satellite \"" + g.CardNo + "\" OK!");
                        }
                    }
                }
            }
        }