public Dictionary<int, OperateLog> GetAllOperateLogs(ref string errMessage)
        {
            Database db = DatabaseFactory.CreateDatabase();
            errMessage = "";
            var list = new Dictionary<int, OperateLog>();
            try
            {

                DataSet ds = OperateLogDataAccess.GetAllOperateLogs(db);

                OperateLog operateLog;
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    operateLog = new OperateLog(ds.Tables[0].Rows[i]);
                    list.Add(operateLog.Id, operateLog);
                }
                return list;

            }
            catch (Exception ex)
            {
                errMessage = ex.Message + ex.StackTrace;
                Logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace);
                return null;
            }
        }
        private void simpleButton1AddCamera_Click(object sender, EventArgs e)
        {
            int cameraid;
            cameraid = int.Parse(treeList1DecoderCamera.FocusedNode.Tag.ToString().Split(';')[0]);
            switch(Opt1)
            {

                case Util.OptionSelect.Decoder:
                    int id= DecoderBusiness.Instance.InsertCamera(ref errMessage, DecoderID, cameraid);
                    if (-1==id)
                    {
                        XtraMessageBox.Show("对不起,您添加的摄像头已经被其他的解码器使用,请另选");
                    }
                    else
                    {
                        OperateLog ol = new OperateLog
                        {
                            HappenTime = DateTime.Now,
                            OperateTypeId = (int)(OperateLogTypeId.CameraAddInDecoder),
                            OperateTypeName = OperateLogTypeName.CameraAddInDecoder,
                            Content = id.ToString(),
                            OperateUserName = MainForm.CurrentUser.UserName,
                            ClientUserName = MainForm.CurrentUser.UserName,
                            ClientUserId = MainForm.CurrentUser.UserId
                        };
                        OperateLogBusiness.Instance.Insert(ref errMessage, ol);
                    }
                    break;
                case Util.OptionSelect.Recognizer:
                    int recognizerid = RecognizerBusiness.Instance.InsertCamera(ref errMessage, RecognizerID, cameraid);
                    if (-1 == recognizerid)
                    {
                        XtraMessageBox.Show("对不起,您添加的摄像头已经被其他的识别器使用,请另选");
                    }
                    else
                    {
                        OperateLog ol = new OperateLog
                        {
                            HappenTime = DateTime.Now,
                            OperateTypeId = (int)(OperateLogTypeId.CameraAddInRecognizer),
                            OperateTypeName = OperateLogTypeName.CameraAddInRecognizer,
                            Content = recognizerid.ToString(),
                            OperateUserName = MainForm.CurrentUser.UserName,
                            ClientUserName = MainForm.CurrentUser.UserName,
                            ClientUserId = MainForm.CurrentUser.UserId
                        };
                        OperateLogBusiness.Instance.Insert(ref errMessage, ol);
                    }
                    break;
            }
            Close();
            Dispose();
        }
Esempio n. 3
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            string errMessage = "";
            if (!dxValidationProvider1.Validate())
            {
                return;
            }
            var ui = new UserInfo
                         {
                             UserName = textEditUserName.Text,
                             Password = textEditPassword.Text,
                             CreateDateTime = DateTime.Now,
                             UserTypeName = comboBoxEditUserType.Text,
                             UserTypeId = comboBoxEditUserType.Text == "管理员" ? 1 : 2
                         };
            switch (userMode)
            {
                case UserMode.Add:
                    UserBusiness.Instance.Insert(ref errMessage, ui);
                    ui = UserBusiness.Instance.GetUserInfo(ref errMessage, ui.UserName);
                    OperateLog ol = new OperateLog
                                        {
                                            HappenTime = DateTime.Now,
                                            OperateTypeId = (int)(OperateLogTypeId.UserAdd),
                                            OperateTypeName = OperateLogTypeName.UserAdd,
                                            Content = ui.ToString(),
                                            OperateUserName = MainForm.CurrentUser.UserName,
                                            ClientUserName = MainForm.CurrentUser.UserName,
                                            ClientUserId = MainForm.CurrentUser.UserId
                                        };
                    OperateLogBusiness.Instance.Insert(ref errMessage, ol);
                    break;

                case UserMode.UPDATE:
                    UserBusiness.Instance.UpdatePassword(ref errMessage, userInfo.UserId, textEditPassword.Text);
                    OperateLogBusiness.Instance.Insert(ref errMessage, new OperateLog
                                       {
                                           HappenTime = DateTime.Now,
                                           OperateTypeId = (int)(OperateLogTypeId.UserUpdate),
                                           OperateTypeName = OperateLogTypeName.SynGroupUpdate,
                                           Content = ui.ToString(),
                                           OperateUserName = MainForm.CurrentUser.UserName,
                                           ClientUserName = MainForm.CurrentUser.UserName,
                                           ClientUserId = MainForm.CurrentUser.UserId
                                       });

                    break;
                default:
                    break;

            }
            Close();
            Dispose();
        }
        public static int Insert(Database db, OperateLog operateLog)
        {
            StringBuilder sbField = new StringBuilder();
            StringBuilder sbValue = new StringBuilder();
            sbField.Append("INSERT INTO  OperateLog(");
            sbValue.Append("values(");
            sbField.Append("GroupID");
            sbValue.AppendFormat("{0}", operateLog.GroupId);
            sbField.Append(",DeviceID");
            sbValue.AppendFormat(",{0}", operateLog.DeviceId);
            sbField.Append(",CameraId");
            sbValue.AppendFormat(",{0}", operateLog.CameraId);
            sbField.Append(",Happentime");
            sbValue.AppendFormat(",'{0}'", operateLog.HappenTime);
            sbField.Append(",operatetypeid");
            sbValue.AppendFormat(",{0}", operateLog.OperateTypeId);
            sbField.Append(",operatetypename");
            sbValue.AppendFormat(",'{0}'", operateLog.OperateTypeName);
            sbField.Append(",content");
            sbValue.AppendFormat(",'{0}'", operateLog.Content);
            sbField.Append(",operateusername");
            sbValue.AppendFormat(",'{0}'", operateLog.OperateUserName);
            sbField.Append(",clientusername");
            sbValue.AppendFormat(",'{0}'", operateLog.ClientUserName);
            sbField.Append(",clientuserid)");
            sbValue.AppendFormat(",{0})", operateLog.ClientUserId);

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

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

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
        public int Insert(ref string errMessage, OperateLog operateLog)
        {
            Database db = DatabaseFactory.CreateDatabase();
            errMessage = "";
            try
            {
                return OperateLogDataAccess.Insert(db, operateLog);

            }
            catch (Exception ex)
            {
                errMessage = ex.Message + ex.StackTrace;
                Logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace);
                return -1;
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 增加识别器
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void simpleButtonOk_Click(object sender, EventArgs e)
        {
            if (!dxValidationProvider1.Validate())
            {
                return;
            }
            RecognizerInfo ri = new RecognizerInfo();
            ri.Id = Id;
            ri.Name = textEditname.Text;
            ri.Port = int.Parse(textEditport.Text);
            ri.Ip = textEditIp.Text;
            ri.MaxRecogNumber = int.Parse(textEditmax.Text);
            if (comboBoxEdit_Type.Text == "Event")
                ri.RecogType = (int)E_Type.E_Event;
            if (comboBoxEdit_Type.Text == "Vehicle")
                ri.RecogType = (int)E_Type.E_Vehicle;
            if (comboBoxEdit_Type.Text == "Face")
                ri.RecogType = (int)E_Type.E_Face;
            switch (Opt)
            {
                case Util.Operateion.Add:
                    RecognizerBusiness.Instance.Insert(ref errMessage, ri);
                    OperateLog ol = new OperateLog
                    {
                        HappenTime = DateTime.Now,
                        OperateTypeId = (int)(OperateLogTypeId.RecognizerAdd),
                        OperateTypeName = OperateLogTypeName.RecognizerAdd,
                        Content = ri.ToString(),
                        Id = ri.Id,
                        OperateUserName = MainForm.CurrentUser.UserName,
                        ClientUserName = MainForm.CurrentUser.UserName,
                        ClientUserId = MainForm.CurrentUser.UserId
                    };
                    OperateLogBusiness.Instance.Insert(ref errMessage, ol);
                    break;
                case Util.Operateion.Update:
                    ri = RecognizerBusiness.Instance.GetRecognizerInfoByRecognizerId(ref errMessage,Id);
                    ri.Name = textEditname.Text;
                    ri.Port = int.Parse(textEditport.Text);
                    ri.Ip = textEditIp.Text;
                    ri.MaxRecogNumber = int.Parse(textEditmax.Text);
                    Id = RecognizerBusiness.Instance.Update(ref errMessage, ri);
                    OperateLogBusiness.Instance.Insert(ref errMessage, new OperateLog
                    {
                        HappenTime = DateTime.Now,
                        OperateTypeId = (int)(OperateLogTypeId.RecognizerUpdate),
                        OperateTypeName = OperateLogTypeName.RecognizerUpdate,
                        Content = ri.ToString(),
                        Id = ri.Id,
                        OperateUserName = MainForm.CurrentUser.UserName,
                        ClientUserName = MainForm.CurrentUser.UserName,
                        ClientUserId = MainForm.CurrentUser.UserId
                    });
                    break;
                case Util.Operateion.Delete:
                    break;
                default:
                    break;

            }
            Close();
            Dispose();
        }
Esempio n. 7
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();
        }