Пример #1
0
        private void btnDeviceRefresh_Click(object sender, EventArgs e)
        {
            DeviceInfo[] info = DriverInterface.GetDevices();

            cbDevices.Items.Clear();
            cbDevices.Items.AddRange(info);
        }
Пример #2
0
        async void Init()
        {
            try {
                _driver = new DriverInterface();
            }
            catch (Win32Exception ex) when(ex.NativeErrorCode == 2)
            {
                // driver not loaded or not installed
                bool isAdmin = new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator);

                if (isAdmin)
                {
                    await InstallAndLoadDriverAsync();

                    Init();
                }
                else
                {
                    if (UI.MessageBoxService.ShowMessage("Requried driver is not loaded or not installed. Restart application with elevated provileges?",
                                                         App.Title, MessageBoxButton.OKCancel, MessageBoxImage.Question) == MessageBoxResult.OK)
                    {
                        var startInfo = new ProcessStartInfo(Assembly.GetExecutingAssembly().Location)
                        {
                            Verb = "runas"
                        };
                        Process.Start(startInfo);
                    }
                    Application.Current.Shutdown();
                }
            }
            catch (Exception ex) {
                UI.MessageBoxService.ShowMessage($"Error: {ex.Message}", App.Title);
                Application.Current.Shutdown(1);
            }
        }
Пример #3
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        BusAllInfo info  = null;
        ArrayList  infos = SimpleOrmOperator.QueryConditionList <BusAllInfo>(" where c_idcard='" + this.txtIdCard.Text.Trim() + "' and i_state=0");

        if (infos.Count != 0)
        {
            info = infos[0] as BusAllInfo;
            this.btnQuitBus.Enabled = true;
            this.hidLsh.Value       = info.Lsh;
        }
        else
        {
            info         = DriverInterface.GetFromUser(this.cbIdCardType.SelectedValue.ToString(), this.txtIdCard.Text.Trim(), this.txtDabh1.Text + this.txtDabh2);
            hidLsh.Value = info.Lsh;
        }

        this.lbBrithday.Text   = info.Birthday;
        this.lbDabh.Text       = info.Dabh;
        this.lbIdCard.Text     = info.IdCard;
        this.lbIDCardType.Text = info.IdCardType;
        this.lbNation.Text     = info.Nation;
        this.lbSex.Text        = info.Sex;
        this.lbXm.Text         = info.Xm;
        this.lbLearnCar.Text   = info.CarType;
        this.lbCheckDay.Text   = info.CheckDate;
        //this.lbDescription.Text

        this.imgPerson.ImageUrl = "../../ShowImage.aspx?idcard=" + this.txtIdCard.Text.Trim();
    }
Пример #4
0
    public static bool Check(int id, string optname)
    {
        bool                    isChecked = false;
        StudentApplyInfo        info      = SimpleOrmOperator.Query <StudentApplyInfo>(id);
        StudentApplyInfoChecked infoCheck = SimpleOrmOperator.Query <StudentApplyInfoChecked>(id);
        string                  glbm      = System.Configuration.ConfigurationManager.AppSettings["DrvHelperSystem_glbm"];
        TmriResponse            resp      = null;

        string[] res = new string[] {};
        try
        {
            string useold = System.Configuration.ConfigurationManager.AppSettings["Drv_Apply_Use_Old"];
            if (useold == "true")
            {
                resp = new TmriResponse();
                bool resultold = DriverInterface.WriteApplyOld(ConvertInfoToRequest(info));
                // resultold ? 0 : 2;
                if (resultold)
                {
                    resp.Code    = 0;
                    resp.Message = "更新成功";
                }
                else
                {
                    resp.Code    = 2;
                    resp.Message = "更新不成功";
                }
            }
            // resp = DriverInterface.WriteDrvBaseTmriRequest(ConvertInfoToRequest(info));
            //resp= DriverInterface.yuyueInfo(info);
            info.Hmcd = "1";

            string xml = ConvertInfoToRequest(info).ToXml();
            res = DrvNewInterface.WritePresign(xml);
        }
        catch (Exception exe)
        {
            SaveInfoCheckFail(info, optname, exe.Message);
            //info.CheckResult = exe.Message;
            // SimpleOrmOperator.Update(info);
            return(false);
        }
        if (res.Length == 2)
        //if (resp.Code == 0 || resp.Code == 1)
        {
            infoCheck.Checked     = 1;
            infoCheck.CheckResult = res[1];
            isChecked             = true;
            //DataAccessFactory.GetDataAccess().ExecuteSql("update table_student_apply_info set i_tpchecked_num=i_tpchecked_num+1 where i_tpchecked_num<i_tpused_num and id=" + info.PaibanId);
        }
        else if (res.Length == 3)
        {
            infoCheck.Checked     = 2;
            infoCheck.CheckResult = res[1];
        }
        infoCheck.CheckOperator = optname;
        SimpleOrmOperator.Update(infoCheck);
        return(isChecked);
    }
Пример #5
0
        public Dumper()
        {
            InitializeComponent();

            driver = new DriverInterface("\\\\.\\KsDumper");
            dumper = new ProcessDumper(driver);
            LoadProcessList();
        }
Пример #6
0
 public void StopDriverInterface()
 {
     if (m_Driver != null)
     {
         m_Driver.Disconnect();
         m_Driver = null;
     }
 }
Пример #7
0
        public void StartDriverInterface()
        {
            //Console.WriteLine("Starting driver interface.");
            log.LogInformation("StartDriverInterface has been called.");

            //m_Driver = new DriverInterface(_config.ServiceNode, _config.LiveDataCloudNode, _config.PortNumber, _config.MachineName, _config.StoreAndForward, _config.Username, _config.Password, _registerHead.DeviceType, _registerHead);
            m_Driver = new DriverInterface(_config, _registerHead, _transloadWS);
        }
Пример #8
0
        private void cbDevices_SelectedIndexChanged(object sender, EventArgs e)
        {
            groupPicture.Enabled = (cbDevices.SelectedIndex != -1);

            if (groupPicture.Enabled && !DriverInterface.SelectDevice(((DeviceInfo)cbDevices.SelectedItem).Path))
            {
                cbDevices.SelectedIndex = -1;
                MessageBox.Show("Failed to select device!");
                return;
            }
        }
Пример #9
0
        private void ActiveCamera_LiveViewUpdated(Camera sender, Stream img)
        {
            if (!hasDevice)
            {
                return;
            }

            using (Bitmap rawInput = new Bitmap(img))
            {
                Bitmap videoBuffer = null;

                if (rawInput.Width != DriverInterface.Width || rawInput.Height != DriverInterface.Height)
                {
                    videoBuffer = new Bitmap(DriverInterface.Width, DriverInterface.Height);
                    Graphics gfx = Graphics.FromImage(videoBuffer);

                    float scaleX = 1.0f;
                    if (rawInput.Width != DriverInterface.Width)
                    {
                        scaleX = DriverInterface.Width / (float)rawInput.Width;
                    }

                    float scaleY = 1.0f;
                    if (rawInput.Height != DriverInterface.Height)
                    {
                        scaleY = DriverInterface.Height / (float)rawInput.Height;
                    }

                    float scale = Math.Min(scaleX, scaleY);

                    int newWidth  = (int)Math.Floor(scale * rawInput.Width);
                    int newHeight = (int)Math.Floor(scale * rawInput.Height);

                    gfx.Clear(Color.Black);
                    gfx.DrawImage(rawInput, new Rectangle((videoBuffer.Width / 2) - (newWidth / 2), (videoBuffer.Height / 2) - (newHeight / 2), newWidth, newHeight));

                    gfx.Dispose();
                }
                else
                {
                    videoBuffer = rawInput;
                }

                BitmapData imageLock = videoBuffer.LockBits(new Rectangle(0, 0, videoBuffer.Width, videoBuffer.Height), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
                DriverInterface.SetData(imageLock.Scan0, imageLock.Stride, imageLock.Width, imageLock.Height);
                videoBuffer.UnlockBits(imageLock);

                if (videoBuffer != rawInput)
                {
                    videoBuffer.Dispose();
                }
                rawInput.Dispose();
            }
        }
Пример #10
0
        private void cbDevices_SelectedIndexChanged(object sender, EventArgs e)
        {
            hasDevice = false;

            if (!DriverInterface.SelectDevice(((DeviceInfo)cbDevices.SelectedItem).Path))
            {
                cbDevices.SelectedIndex = -1;
                MessageBox.Show("Failed to select device!");
                return;
            }

            hasDevice = (cbDevices.SelectedIndex > -1);
        }
Пример #11
0
        public MemoryMapViewModel(ProcessViewModel process, DriverInterface driver, IList <TabItemViewModelBase> tabs, IUIServices ui)
        {
            _process  = process;
            _tabs     = tabs;
            _ui       = ui;
            _hProcess = driver.OpenProcessHandle(ProcessAccessMask.AllAccess, process.Id);
            if (_hProcess == null)
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }

            _memoryMap = new MemoryMap(_hProcess);

            Text = $"Map - {process.Name} ({process.Id})";
            Icon = "/icons/memory.ico";
        }
Пример #12
0
        protected override void DoTask()
        {
            string    sql    = "select idacard,c_new_phone,c_new_postcode,c_new_address,c_old_phone,c_email,id from table_person_change_info where i_syn=0";
            DataTable dt     = DataAccessFactory.GetDataAccess().SelectDataTable(sql, "tmpdb");
            string    logstr = string.Empty;
            string    id     = string.Empty;

            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DrvPresonInfoChangeRequest request = new DrvPresonInfoChangeRequest();
                    request.sfzmhm = dt.Rows[i][0] == null ? "" : dt.Rows[i][0].ToString();
                    request.lxdh   = dt.Rows[i][1] == null ? "" : dt.Rows[i][1].ToString();
                    request.yzbm   = dt.Rows[i][2] == null ? "" : dt.Rows[i][2].ToString();
                    request.lxzs   = dt.Rows[i][3] == null ? "" : dt.Rows[i][3].ToString();
                    request.sjhm   = dt.Rows[i][4] == null ? "" : dt.Rows[i][4].ToString();
                    request.dzyx   = dt.Rows[i][5] == null ? "" : dt.Rows[i][5].ToString();
                    logstr         = "正在处理身份证号码为:" + request.sfzmhm + "的信息本案变更!";
                    this.SetHintText(logstr);
                    this.CreateLog(logstr);
                    TmriResponse response = DriverInterface.WritePersonInfoChange(request);
                    id = dt.Rows[i][6].ToString();
                    if (response.Code == 0)
                    {
                        logstr = "成功处理身份证号码:" + request.sfzmhm;
                        this.SetHintText(logstr);
                        this.CreateLog(logstr);
                        sql = "update table_person_change_info set  i_syn=1,I_CHECKED=1,C_CHECK_DATE='" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',C_CHECK_RESULT='" + response.Message + "',C_CHECK_OPERATOR='" + this.monitorname + "'";
                    }
                    else
                    {
                        logstr = "失败处理身份证号码:" + request.sfzmhm + ";code:" + response.Code;
                        this.SetHintText(logstr);
                        this.CreateLog(logstr);
                        sql = "update table_person_change_info set  i_syn=1,I_CHECKED=0,C_CHECK_DATE='" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',C_CHECK_RESULT='" + response.Message + "',C_CHECK_OPERATOR='" + this.monitorname + "'";
                    }
                    sql += " where id=" + id;

                    DataAccessFactory.GetDataAccess().ExecuteSql(sql);
                }
            }
        }
Пример #13
0
        private async Task InstallAndLoadDriverAsync()
        {
            var status = await DriverInterface.LoadDriverAsync("KExplore");

            if (status == null)
            {
                var ok = await DriverInterface.InstallDriverAsync("KExplore", Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\KExplore.sys");

                if (!ok)
                {
                    UI.MessageBoxService.ShowMessage("Failed to install driver. Exiting", App.Title);
                    Application.Current.Shutdown(1);
                }
                status = await DriverInterface.LoadDriverAsync("KExplore");
            }
            if (status != ServiceControllerStatus.Running)
            {
                UI.MessageBoxService.ShowMessage("Failed to start driver. Exiting", App.Title);
                Application.Current.Shutdown(1);
            }
        }
Пример #14
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (!DriverInterface.Init())
            {
                MessageBox.Show("Unable to init DriverInterface!");

                return;
            }

            Thread sta = new Thread(new ThreadStart(() =>
            {
                Application.Run(new MainForm());
            }));

            sta.SetApartmentState(ApartmentState.STA);
            sta.Start();
            sta.Join();

            DriverInterface.Free();
        }
Пример #15
0
    public static void Check(int id, string name)
    {
        try
        {
            // throw new Exception("测试异常");
            YuyueInfo info   = SimpleOrmOperator.Query <YuyueInfo>(id);
            string    glbm   = System.Configuration.ConfigurationManager.AppSettings["DrvHelperSystem_glbm"];
            int       bkjg   = int.Parse(ConfigurationManager.AppSettings["DrvHelperSystem_bkjg"].ToString());
            string    idcard = info.IdCard;
            DateTime  yyrq   = Convert.ToDateTime(info.Ksrq);
            int       km     = info.Km;

            /*
             * TempStudentInfo student = DrvQueryHelper.QueryStudent(glbm, info.IdCard);
             * if (student == null)
             * {
             *  SaveInfoCheckFail(info, name, "该学员不是本地车管所报名的!");
             *  return;
             * }
             * info.Dlr = student.jxmc;
             * info.DlrCode = student.jxdm;
             * info.JlyIdCard = student.jly;
             * info.Km = km;
             * info.Lsh = student.lsh;
             * info.Xm = student.name;
             * info.Zjcx = student.zkcx;
             * /*
             * try
             * {
             *  if (DateTime.Parse(student.yxqz).CompareTo(yyrq) < 0)
             *  {
             *      SaveInfoCheckFail(info, name, "身份证明号码" + idcard + "的准考证明有效期到" + student.yxqz + "截止!");
             *      return;
             *
             *  }
             * }
             * catch (System.Exception e)
             * {
             *
             * }
             *
             *
             * if (student.jxdm != null && student.jxdm != info.DlrCode)
             * {
             *  SaveInfoCheckFail(info, name, "驾校学员只能通过相关驾校帮您预约!");
             *  return;
             *
             * }
             * */


            //ArrayList daylimits = SimpleOrmOperator.QueryConditionList<YuyueDayLimit>(" where c_cartype like '%" + student.zkcx + "%' and i_km=" + km);
            ArrayList     daylimits = SimpleOrmOperator.QueryConditionList <YuyueDayLimit>(" where c_cartype like '%" + "C1" + "%' and i_km=" + km);
            TempKscjInfo  kscj      = DrvQueryHelper.QueryKscj(glbm, idcard);
            YuyueDayLimit daylimit  = null;
            if (daylimits != null && daylimits.Count > 0)
            {
                daylimit = daylimits[0] as YuyueDayLimit;
            }
            if (kscj != null)
            {
                if (km == 1)
                {
                    if (kscj.km1 == 1)
                    {
                        SaveInfoCheckFail(info, name, "身份证明号码" + idcard + "的科目一已经合格!");
                        return;
                    }
                }
                else if (km == 2)
                {
                    if (kscj.km2yyrq != null)
                    {
                        if (kscj.km2 == 1)
                        {
                            SaveInfoCheckFail(info, name, "身份证明号码" + idcard + "的科目二已经合格!");
                            return;
                        }
                        if (kscj.km2 == 2)
                        {
                            if (yyrq.CompareTo(DateTime.Parse(kscj.km2yyrq).AddDays(bkjg)) < 0)
                            {
                                SaveInfoCheckFail(info, name, "身份证明号码" + idcard + "上次考试时间为:" + kscj.km2yyrq + ",科目二补考必须在上一次考试" + bkjg + "天之后!");
                                return;
                            }
                        }
                    }
                    else if (kscj.km1 == 1 && daylimit != null)
                    {
                        if (yyrq.CompareTo(DateTime.Parse(kscj.km1yyrq).AddDays(daylimit.Days)) < 0)
                        {
                            SaveInfoCheckFail(info, name, "身份证明号码" + idcard + "科目一考试时间为:" + kscj.km1yyrq + ",申请" + daylimit.CarType + "牌照的科目二考试必须在" + daylimit.Days + "天之后!");
                            return;
                        }
                    }
                    else
                    {
                        SaveInfoCheckFail(info, name, "身份证明号码" + idcard + "科目一还没有合格!");
                        return;
                    }
                }

                else if (km == 3)
                {
                    if (kscj.km3yyrq != null)
                    {
                        if (kscj.km3 == 1)
                        {
                            SaveInfoCheckFail(info, name, "身份证明号码" + idcard + "的科目三已经合格!");
                            return;
                        }
                        if (kscj.km3 == 2)
                        {
                            if (yyrq.CompareTo(DateTime.Parse(kscj.km3yyrq).AddDays(bkjg)) < 0)
                            {
                                SaveInfoCheckFail(info, name, "身份证明号码" + idcard + "上次考试时间为:" + kscj.km2yyrq + ",科目三补考必须在上一次考试" + bkjg + "天之后!");
                                return;
                            }
                        }
                    }
                    else if (kscj.km2 == 1 && daylimit != null)
                    {
                        if (yyrq.CompareTo(DateTime.Parse(kscj.km1yyrq).AddDays(daylimit.Days)) < 0)
                        {
                            SaveInfoCheckFail(info, name, "身份证明号码" + idcard + "科目一考试时间为:" + kscj.km1yyrq + ",申请" + daylimit.CarType + "牌照的科目三考试必须在" + daylimit.Days + "天之后!");
                            return;
                        }
                    }
                    else
                    {
                        SaveInfoCheckFail(info, name, "身份证明号码" + idcard + "科目二还没有合格!");
                        return;
                    }
                }
            }

            //&& info.Checked == 0
            if (info != null)
            {
                info.CheckOperator = name;
                info.Jbr           = name;
                TmriResponse resp = null;
                try
                {
                    string useold = System.Configuration.ConfigurationManager.AppSettings["Drv_Yuyue_Use_Old"];
                    if (useold == "true")
                    {
                        resp = new TmriResponse();
                        bool resultold = DriverInterface.WritePreasignOld(ConvertInfoToRequest(info));
                        // resultold ? 0 : 2;
                        if (resultold)
                        {
                            resp.Code    = 0;
                            resp.Message = "更新成功";
                        }
                        else
                        {
                            resp.Code    = 2;
                            resp.Message = "更新不成功";
                        }
                    }
                    else
                    {
                        resp = DriverInterface.WriteDrvBaseTmriRequest(ConvertInfoToRequest(info));
                    }
                    //resp= DriverInterface.yuyueInfo(info);
                }
                catch (Exception exe)
                {
                    SaveInfoCheckFail(info, name, exe.Message);
                    //info.CheckResult = exe.Message;
                    // SimpleOrmOperator.Update(info);
                    return;
                }
                if (resp.Code == 0 || resp.Code == 1)
                {
                    info.Checked     = 1;
                    info.CheckResult = resp.Message;
                    SimpleOrmOperator.Update(info);
                    if (!DataAccessFactory.GetDataAccess().ExecuteSql("update table_yuyue_limit set i_checked_num=i_checked_num+1 where i_checked_num<i_used_num and id=" + info.PaibanId))
                    {
                        DataAccessFactory.GetDataAccess().ExecuteSql("update table_yuyue_limit set i_tpchecked_num=i_tpchecked_num+1 where i_tpchecked_num<i_tpused_num and id=" + info.PaibanId);
                    }
                }
                else
                {
                    SaveInfoCheckFail(info, name, resp.Message);
                    //info.Checked = 2;
                    //info.CheckResult = resp.Message;
                    // SimpleOrmOperator.Update(info);
                }
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
Пример #16
0
        private void btnLoadImage_Click(object sender, EventArgs e)
        {
            OpenFileDialog opf = new OpenFileDialog();

            opf.Filter = "Image files|*.bmp;*.jpg;*.png";
            if (opf.ShowDialog(this) == DialogResult.OK)
            {
                Bitmap rawInput    = new Bitmap(opf.FileName);
                Bitmap videoBuffer = null;

                if (rawInput.Width != DriverInterface.Width || rawInput.Height != DriverInterface.Height)
                {
                    videoBuffer = new Bitmap(DriverInterface.Width, DriverInterface.Height);
                    Graphics gfx = Graphics.FromImage(videoBuffer);

                    float scaleX = 1.0f;
                    if (rawInput.Width != DriverInterface.Width)
                    {
                        scaleX = DriverInterface.Width / (float)rawInput.Width;
                    }

                    float scaleY = 1.0f;
                    if (rawInput.Height != DriverInterface.Height)
                    {
                        scaleY = DriverInterface.Height / (float)rawInput.Height;
                    }

                    float scale = Math.Min(scaleX, scaleY);

                    int newWidth  = (int)Math.Floor(scale * rawInput.Width);
                    int newHeight = (int)Math.Floor(scale * rawInput.Height);

                    gfx.Clear(Color.Black);
                    gfx.DrawImage(rawInput, new Rectangle((videoBuffer.Width / 2) - (newWidth / 2), (videoBuffer.Height / 2) - (newHeight / 2), newWidth, newHeight));

                    gfx.Dispose();
                }
                else
                {
                    videoBuffer = rawInput;
                }

                if (picView.Image != null)
                {
                    picView.Image.Dispose();
                }
                picView.Image = (Bitmap)videoBuffer.Clone();

                Stopwatch  sw        = new Stopwatch();
                BitmapData imageLock = videoBuffer.LockBits(new Rectangle(0, 0, videoBuffer.Width, videoBuffer.Height), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
                sw.Start();
                DriverInterface.SetData(imageLock.Scan0, imageLock.Stride, imageLock.Width, imageLock.Height);
                sw.Stop();
                videoBuffer.UnlockBits(imageLock);

                Console.WriteLine(sw.Elapsed.ToString());

                if (videoBuffer != rawInput)
                {
                    videoBuffer.Dispose();
                }
                rawInput.Dispose();
            }
        }
 public SelectProcessesViewModel(Window dialog, DriverInterface driver) : base(dialog)
 {
     _driver = driver;
 }
 public SelectProcessesViewModel(Window dialog, DriverInterface driver) : base(dialog)
 {
     _driver             = driver;
     CanExecuteOKCommand = () => SelectedProcesses.Count > 0;
     OKCommand           = OKCommand.ObservesProperty(() => SelectedItem);
 }
Пример #19
0
 public ProcessDumper(DriverInterface kernelDriver)
 {
     this.kernelDriver = kernelDriver;
 }