Exemplo n.º 1
0
        private void AddDecoderButton(object sender, EventArgs e)
        {
            if (!dxValidationProvider1.Validate())
            {
                return;
            }

            //string errMessage = "";
            DecoderInfo di = new DecoderInfo();
            di.id = Id;
            di.Name = textEditname.Text;
            di.Port = int.Parse(textEditport.Text);
            di.Ip = textEditIp.Text;
            di.MaxDecodeChannelNo = int.Parse(textEditmax.Text);
            switch(Opt)
            {
                case Util.Operateion.Add:

                    DecoderBusiness.Instance.Insert(ref errMessage, di);
                    OperateLog ol = new OperateLog
                    {
                        HappenTime = DateTime.Now,
                        OperateTypeId = (int)(OperateLogTypeId.DecoderAdd),
                        OperateTypeName = OperateLogTypeName.DecoderAdd,
                        Content = di.ToString(),
                        Id = di.id,
                        OperateUserName = MainForm.CurrentUser.UserName,
                        ClientUserName = MainForm.CurrentUser.UserName,
                        ClientUserId = MainForm.CurrentUser.UserId
                    };
                    OperateLogBusiness.Instance.Insert(ref errMessage, ol);
                    break;
                case Util.Operateion.Update:
                    di = DecoderBusiness.Instance.GetDecoderInfoByDecoderId(ref errMessage, Id);
                    di.Name = textEditname.Text;
                    di.Port = int.Parse(textEditport.Text);
                    di.Ip = textEditIp.Text;
                    di.MaxDecodeChannelNo = int.Parse(textEditmax.Text);
                    Id = DecoderBusiness.Instance.Update(ref errMessage, di);
                    OperateLogBusiness.Instance.Insert(ref errMessage, new OperateLog
                    {
                        HappenTime = DateTime.Now,
                        OperateTypeId = (int)(OperateLogTypeId.DecoderUpdate),
                        OperateTypeName = OperateLogTypeName.DecoderUpdate,
                        Content = di.ToString(),
                        Id = di.id,
                        OperateUserName = MainForm.CurrentUser.UserName,
                        ClientUserName = MainForm.CurrentUser.UserName,
                        ClientUserId = MainForm.CurrentUser.UserId
                    });
                    break;
                case Util.Operateion.Delete:
                    break;
                default:
                    break;

            }
            Close();
            Dispose();
        }
 public DecoderClientConnection(Socket socket)
 {
     string errMessage = "";
     _socket = socket;
     Ip = ((IPEndPoint) socket.RemoteEndPoint).Address.ToString();
     Port = ((IPEndPoint)socket.RemoteEndPoint).Port;
     DecoderInfo = DecoderBusiness.Instance.GetDecoderInfoByDecoderIP(ref errMessage, Ip);
     _networkStream = new NetworkStream(socket);
     LiveDecoderPacketHandle = new LiveDecoderPacketHandle();
     DecoderStateHandle = new DecoderStateHandle();
     _handlers = new IPacketHandler[] { LiveDecoderPacketHandle, DecoderStateHandle };
 }
Exemplo n.º 3
0
 public frmDecoder(DecoderInfo decoderInfo)
 {
     InitializeComponent();
     this.Text = "更新解码器";
     simpleButtonOk.TabIndex = 0;
     this.textEditname.Text = decoderInfo.Name;
     this.textEditIp.Text = decoderInfo.Ip;
     this.textEditport.Text = decoderInfo.Port.ToString();
     this.textEditmax.Text = decoderInfo.MaxDecodeChannelNo.ToString();
     Opt = Util.Operateion.Update;
     decoderOldName = decoderInfo.Name;
     InitValidationRules();
 }
Exemplo n.º 4
0
        public int Update(ref string errMessage, DecoderInfo DecoderInfo)
        {
            Database db = DatabaseFactory.CreateDatabase();
            errMessage = "";
            try
            {
                return DecoderDataAccess.Update(db, DecoderInfo);

            }
            catch (Exception ex)
            {
                errMessage = ex.Message + ex.StackTrace;
                logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace);
                return -1;
            }
        }
Exemplo n.º 5
0
        public Dictionary<int, DecoderInfo> GetDecoderInfoByName(ref string errMessage, string Name)
        {
            Database db = DatabaseFactory.CreateDatabase();
            errMessage = "";
            Dictionary<int, DecoderInfo> mylist = new Dictionary<int, DecoderInfo>();
            try
            {

                DataSet ds = DecoderDataAccess.GetDecoderInfoByName(db, Name);

                DecoderInfo decoderInfo;
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    decoderInfo = new DecoderInfo(ds.Tables[0].Rows[i]);
                    DataSet dsCamera;
                    CameraInfo oCamera;
                    dsCamera = DecoderDataAccess.GetCameraInfoByDecoderId(db, decoderInfo.id);
                    //DecoderDataAccess.GetCamInfoByCameraId(db,dsCamera.Tables[0].Rows[i].)
                    decoderInfo.ListCameras = new Dictionary<int, CameraInfo>();
                    foreach (DataRow dr in dsCamera.Tables[0].Rows)
                    {

                        oCamera = new CameraInfo(dr);
                        decoderInfo.ListCameras.Add(oCamera.CameraId, oCamera);
                    }

                    mylist.Add(decoderInfo.id, decoderInfo);
                }
                return mylist;

            }
            catch (Exception ex)
            {
                errMessage = ex.Message + ex.StackTrace;
                logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace);
                return null;
            }
        }
Exemplo n.º 6
0
        public DecoderInfo GetDecoderInfoByDecoderIP(ref string errMessage, string IP)
        {
            Database db = DatabaseFactory.CreateDatabase();
            errMessage = "";
            try
            {
                DataSet ds = DecoderDataAccess.GetDecoderInfoByDecoderIP(db, IP);
                if (ds.Tables[0].Rows.Count == 0)
                {
                    return null;
                }
                DecoderInfo decoderInfo = new DecoderInfo(ds.Tables[0].Rows[0]);
                DataSet dsCamera;
                CameraInfo oCamera;
                dsCamera = DecoderDataAccess.GetCameraInfoByDecoderId(db, decoderInfo.id);
                //DecoderDataAccess.GetCamInfoByCameraId(db,dsCamera.Tables[0].Rows[i].)
                decoderInfo.ListCameras = new Dictionary<int, CameraInfo>();
                foreach (DataRow dr in dsCamera.Tables[0].Rows)
                {

                    oCamera = new CameraInfo(dr);
                    decoderInfo.ListCameras.Add(oCamera.CameraId, oCamera);
                }
                return decoderInfo;

            }
            catch (Exception ex)
            {
                errMessage = ex.Message + ex.StackTrace;
                logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace);
                return null;
            }
        }
Exemplo n.º 7
0
        public static int Update(Database db, DecoderInfo oDecoderInfo)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("update DecoderInfo set");
            sb.AppendFormat(" Name='{0}'", oDecoderInfo.Name);
            //sb.AppendFormat(",id='{0}'", oDecoderInfo.id);
            sb.AppendFormat(",Ip='{0}'", oDecoderInfo.Ip);
            sb.AppendFormat(",Port={0}", oDecoderInfo.Port);
            sb.AppendFormat(",MaxDecodeChannelNo={0}", oDecoderInfo.MaxDecodeChannelNo);
            sb.AppendFormat(" where id={0}", oDecoderInfo.id);
            string cmdText = sb.ToString();
            try
            {
                return db.ExecuteNonQuery(CommandType.Text, cmdText);

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
Exemplo n.º 8
0
        public static int Insert(Database db, DecoderInfo oDecoderInfo)
        {
            /* StringBuilder sbField = new StringBuilder();
            StringBuilder sbValue = new StringBuilder();
            sbField.Append("INSERT INTO DecoderInfo(");
            sbValue.Append("values(");
            sbField.Append("id");
            sbValue.AppendFormat("{0}", oDecoderInfo.id);
            sbField.Append(",Name");
            sbValue.AppendFormat(",'{0}'", oDecoderInfo.Name);
            sbField.Append(",Ip");
            sbValue.AppendFormat(",'{0}'", oDecoderInfo.Ip);
            sbField.Append(",Port");
            sbValue.AppendFormat(",{0}", oDecoderInfo.Port);
            sbField.Append(",MaxDecodeChannelNo");
            sbValue.AppendFormat(",{0}", oDecoderInfo.MaxDecodeChannelNo);

            string cmdText = sbField.ToString() + " " + sbValue.ToString();
            try
            {
               // cmdText = cmdText.Replace("\r\n", "");
                return db.ExecuteNonQuery(CommandType.Text, cmdText);

            }
            catch (Exception ex)
            {

                throw ex;
            }*/
            StringBuilder sbField = new StringBuilder();
            StringBuilder sbValue = new StringBuilder();
            sbField.Append("INSERT INTO  [DecoderInfo](");
            sbValue.Append("values (");
            //sbField.Append("[id]");
            //sbValue.AppendFormat("'{0}'", oDecoderInfo.id);
            sbField.Append("[Name]");
            sbValue.AppendFormat("'{0}'", oDecoderInfo.Name);
            sbField.Append(",[Ip]");
            sbValue.AppendFormat(",'{0}'", oDecoderInfo.Ip);
            sbField.Append(",[Port]");
            sbValue.AppendFormat(",{0}", oDecoderInfo.Port);
            sbField.Append(",[MaxDecodeChannelNo])");
            sbValue.AppendFormat(",'{0}')", oDecoderInfo.MaxDecodeChannelNo);

            string cmdText = sbField.ToString() + " " + sbValue.ToString();

            try
            {
                cmdText = cmdText.Replace("\r\n", "");
                return db.ExecuteNonQuery(CommandType.Text, cmdText);

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }