Esempio n. 1
0
        private void EditTerminal()
        {
            var id = ParseInt(Utility.Decrypt(hidID.Value));
            var t  = TerminalInstance.Find(f => (f.Number.Equals(txtNumber.Value.Trim()) || f.Sim.Equals(txtSimcard.Value.Trim())) &&
                                           f.id != id && f.Delete == false);

            if (null == t)
            {
                t = TerminalInstance.Find(f => f.id == ParseInt(Utility.Decrypt(hidID.Value)));
                if (null != t)
                {
                    BuildObject(t);
                    Update(t);

                    SaveHistory(new TB_AccountHistory
                    {
                        ActionId = ActionInstance.Find(f => f.Name.Equals("EditTerminal")).id,
                        ObjectA  = TerminalInstance.ToString(t)
                    });
                    ShowNotification("./terminal_list.aspx", "You changed terminal: " + TerminalInstance.ToString(t));
                }
                else
                {
                    ShowNotification("./terminal_list.aspx", "Error: Cannot edit null object of Terminal.", false);
                }
            }
            else
            {
                ShowNotification("./terminal_register.aspx?key=" + Utility.UrlEncode(hidID.Value),
                                 "Error: New terminal number or sim card number has exists: " + TerminalInstance.ToString(t), false);
            }
        }
Esempio n. 2
0
        private void NewTerminal()
        {
            TB_Terminal t = null;

            // 如果没有输入Sim卡号码则查询是否具有相同终端号码的记录
            if (string.IsNullOrEmpty(txtSimcard.Value.Trim()))
            {
                t = TerminalInstance.Find(f => f.Number.Equals(txtNumber.Value.Trim()) && f.Delete == false);
            }
            else
            {
                // 如果有Sim卡号码输入则查询终端或Sim卡号码是否有相同记录存在
                t = TerminalInstance.Find(f => (f.Number.Equals(txtNumber.Value.Trim()) || f.Sim.Equals(txtSimcard.Value.Trim())) && f.Delete == false);
            }

            if (null != t)
            {
                ShowNotification("./terminal_register.aspx", "Terminal exist: " + TerminalInstance.ToString(t), false);
            }
            else
            {
                t = TerminalInstance.GetObject();
                BuildObject(t);
                TerminalInstance.Add(t);

                SaveHistory(new TB_AccountHistory
                {
                    ActionId = ActionInstance.Find(f => f.Name.Equals("AddTerminal")).id,
                    ObjectA  = TerminalInstance.ToString(t)
                });

                ShowNotification("./terminal_list.aspx", "You added a new terminal: " + TerminalInstance.ToString(t));
            }
        }
Esempio n. 3
0
        protected void btDelete_Click(object sender, EventArgs e)
        {
            if (!HasSessionLose)
            {
                if ("" != hidID.Value)
                {
                    var ids  = GetIdList(hidID.Value.Split(new char[] { ',' }));
                    var list = TerminalInstance.FindList(f => ids.Contains(f.id) && f.Delete == false);
                    foreach (var terminal in list)
                    {
                        terminal.Delete = true;
                        Update(terminal);

                        SaveHistory(new TB_AccountHistory
                        {
                            ActionId = ActionInstance.Find(f => f.Name.Equals("DeleteTerminal")).id,
                            ObjectA  = TerminalInstance.ToString(terminal)
                        });
                    }
                    ShowNotification("./terminal_list.aspx", "Success: You have delete " + ids.Count() + " terminal(s).");
                }
            }
        }
Esempio n. 4
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!");
                        }
                    }
                }
            }
        }