Пример #1
0
        /// <summary>
        /// 用于创建初始的Pcb
        /// </summary>
        /// <param name="carrierLength"></param>
        /// <param name="carrierWidth"></param>
        /// <param name="pcbLength"></param>
        /// <param name="pcbWidth"></param>
        /// <param name="side"></param>
        /// <returns></returns>
        public static Pcb CreatePcb(int carrierLength, int carrierWidth, int pcbLength, int pcbWidth, int sideIndex)
        {
            try
            {
                string sPath = INIHelper.Read("BaseConfig", "SavePath", Application.StartupPath + "/config.ini");
                if (!Directory.Exists(sPath))
                {
                    Directory.CreateDirectory(sPath);
                }
                string id = new Snowflake(1).nextId().ToString();
                if (carrierLength == 0 || carrierWidth == 0 || pcbLength == 0 || pcbWidth == 0)
                {
                    MessageBox.Show("长宽不可为0"); return(null);
                }
                Pcb pcb = new Pcb()
                {
                    Id            = id,
                    CarrierLength = carrierLength,
                    CarrierWidth  = carrierWidth,
                    PcbLength     = pcbLength,
                    PcbWidth      = pcbWidth,
                    PcbPath       = id,
                    SideIndex     = sideIndex,
                    results       = new List <Result>(),
                };

                int xvalue           = pcb.PcbWidth;
                int yvalue           = pcb.PcbLength;
                int xdifferencevalue = (pcb.CarrierWidth - pcb.PcbWidth) / 2;
                int ydifferencevalue = (pcb.CarrierLength - pcb.PcbLength) / 2;

                byte[] receiveData = new byte[255];
                var    frontX      = Xycoordinate.axcoordinate((int)Math.Ceiling((float)xvalue / Plc.capturePointIntervalXInMM), (int)(Plc.capturePointIntervalXInMM), xdifferencevalue);
                var    frontY      = Xycoordinate.aycoordinate((int)Math.Ceiling((float)yvalue / Plc.capturePointIntervalYInMM), (int)(Plc.capturePointIntervalYInMM), ydifferencevalue);

                bool             detectMultiScale = INIHelper.ReadBoolean("AiBaseConfig", "detectMultiScale", false, Application.StartupPath + "/config.ini");
                int              overlap          = INIHelper.ReadInteger("AiBaseConfig", "overlap", 50, Application.StartupPath + "/config.ini");
                bool             saveCropImg      = INIHelper.ReadBoolean("AiBaseConfig", "saveCropImg", false, Application.StartupPath + "/config.ini");
                int              equalDivision    = INIHelper.ReadInteger("AiBaseConfig", "equalDivision", 1, Application.StartupPath + "/config.ini");
                float            confidence       = float.Parse(INIHelper.Read("AiBaseConfig", "confidence", Application.StartupPath + "/config.ini"));
                float            scale            = float.Parse(INIHelper.Read("BaseConfig", "imgScale", Application.StartupPath + "/config.ini"));
                OneStitchSidePcb front            = new OneStitchSidePcb()
                {
                    overlap          = overlap,
                    saveCropImg      = saveCropImg,
                    equalDivision    = equalDivision,
                    detectMultiScale = detectMultiScale,
                    confidence       = confidence,

                    addressX             = 3000,
                    addressY             = 3200,
                    addressCaptureNum    = 5000,
                    addressStartCapture  = 2144,
                    addressEndCapture    = 1133,
                    addressOneSidePcbOut = 2145,

                    x = frontX,
                    y = frontY,

                    pcbId    = id,
                    savePath = sPath,

                    allRows     = frontX.Count,
                    allCols     = frontY.Count,
                    allNum      = detectMultiScale ? frontX.Count * frontY.Count * 2 : frontX.Count * frontY.Count, // 这里多尺度是需要改变总数*2的
                    currentRow  = 0,
                    currentCol  = 0,
                    zTrajectory = true,
                    dst         = null,
                    roi         = new Rectangle(),
                    scale       = scale,
                    stitchEnd   = false,
                    bitmaps     = new Queue <BitmapInfo>(),
                };

                var backX             = Xycoordinate.bxcoordinate((int)Math.Ceiling((float)xvalue / Plc.capturePointIntervalXInMM), (int)(Plc.capturePointIntervalXInMM), xdifferencevalue);
                var backY             = Xycoordinate.bycoordinate((int)Math.Ceiling((float)yvalue / Plc.capturePointIntervalYInMM), (int)(Plc.capturePointIntervalYInMM), ydifferencevalue);
                OneStitchSidePcb back = new OneStitchSidePcb()
                {
                    overlap          = overlap,
                    saveCropImg      = saveCropImg,
                    equalDivision    = equalDivision,
                    detectMultiScale = detectMultiScale,
                    confidence       = confidence,

                    addressX             = 3400,
                    addressY             = 3600,
                    addressCaptureNum    = 5002,
                    addressStartCapture  = 2146,
                    addressEndCapture    = 1135,
                    addressOneSidePcbOut = 2147,

                    x = backX,
                    y = backY,

                    pcbId    = id,
                    savePath = sPath,

                    allRows     = backX.Count,
                    allCols     = backY.Count,
                    allNum      = detectMultiScale ? backX.Count * backY.Count * 2 : backX.Count * backY.Count,
                    currentRow  = 0,
                    currentCol  = 0,
                    zTrajectory = false,
                    dst         = null,
                    roi         = new Rectangle(),
                    scale       = scale,
                    stitchEnd   = false,
                    bitmaps     = new Queue <BitmapInfo>(),
                };

                switch (sideIndex)
                {
                case 0:
                    pcb.SurfaceNumber = 2;
                    pcb.BackPcb       = back;
                    pcb.FrontPcb      = front;
                    pcb.AllPhotoNum   = back.allNum + front.allNum;
                    break;

                case 1:
                    pcb.SurfaceNumber = 1;
                    pcb.BackPcb       = null;
                    pcb.FrontPcb      = front;
                    pcb.AllPhotoNum   = front.allNum;
                    break;

                case 2:
                    pcb.SurfaceNumber = 1;
                    pcb.BackPcb       = back;
                    pcb.FrontPcb      = null;
                    pcb.AllPhotoNum   = back.allNum;
                    break;
                }
                return(pcb);
            }
            catch (Exception er) { return(null); }
        }
Пример #2
0
 private void cbUseHotKey_Unchecked(object sender, RoutedEventArgs e)
 {
     INIHelper.IniWriteValue("BaseConfig", "UseHotKey", "false", AppDomain.CurrentDomain.BaseDirectory + "\\config.ini");
 }
Пример #3
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     INIHelper.WriteString(Constants.INI_ServicePort, txtPort.Text.Trim(), DirectoryManage.GetINIFullPath());
     MessageBox.Show("端口已保存成功");
 }
Пример #4
0
 private void CheckBox_Checked(object sender, RoutedEventArgs e)
 {
     INIHelper.IniWriteValue("BaseConfig", "Topmost", "true", AppDomain.CurrentDomain.BaseDirectory + "\\config.ini");
 }
Пример #5
0
        public void Alert()
        {
            try
            {
                if (!isRunning)
                {
                    isRunning = true;

                    var AlertTimes = int.Parse(System.Configuration.ConfigurationManager.AppSettings["AlertTimes"]);
                    using (var db = new Model1())
                    {
                        SqlParameter[] sqlParms = new SqlParameter[1];
                        sqlParms[0] = new SqlParameter("@alerttimes", AlertTimes);
                        alertData   = db.Database.SqlQuery <SaleRecord>("exec QuerySaleRecrod @alerttimes", sqlParms).ToList();

                        var vipInfos  = db.t_rm_vip_info.ToList();
                        var ignoretxt = INIHelper.ReadString("IgnoreVIP", DirectoryManage.GetINIFullPath());


                        var ignoreList = ignoretxt.Split(',');

                        var mode = System.Configuration.ConfigurationManager.AppSettings["Mode"] == "debug";

                        if (mode)
                        {
                            MessageBox.Show("vip数量:" + vipInfos.Count.ToString());
                        }

                        foreach (var vipinfo in vipInfos)
                        {
                            try
                            {
                                //if (vipinfo.vip_start_date.HasValue && vipinfo.vip_start_date.Value.Month == DateTime.Now.Month)
                                //{//当月不反积分

                                //    if (mode)
                                //    {
                                //        MessageBox.Show("当月不反积分");
                                //    }
                                //    continue;
                                //}


                                if (db.t_rm_vip_acclist.Where(o => o.oper_des == "活动##送积分" && o.memo == "活动##送积分" && o.card_no == vipinfo.card_no).Count() > 15)
                                {
                                    if (mode)
                                    {
                                        MessageBox.Show("已经超过送积分次数 则跳过");
                                    }
                                    continue;
                                }


                                var accnum = int.Parse(System.Configuration.ConfigurationManager.AppSettings["VipAccnum"]);

                                var acclist = db.t_rm_vip_acclist.Where(o => o.oper_des == "活动##送积分" && o.memo == "活动##送积分" && o.card_no == vipinfo.card_no).ToList();
                                if (acclist.Count > 0)
                                {
                                    var date1 = acclist.OrderByDescending(o => o.ope_date).FirstOrDefault().ope_date.Value.AddDays(30);
                                    if (date1 >= DateTime.Now)
                                    {
                                        if (mode)
                                        {
                                            MessageBox.Show("距离上次送积分还不到30天 则跳过");
                                        }
                                        continue;
                                    }
                                }


                                if (ignoreList.Contains(vipinfo.card_no))
                                {
                                    if (mode)
                                    {
                                        MessageBox.Show("如果会员忽略列表里存在这个会员卡号,择跳过");
                                    }
                                    //如果会员忽略列表里存在这个会员卡号,择跳过
                                    continue;
                                }

                                if (mode)
                                {
                                    MessageBox.Show("vip数量:" + vipInfos.Count.ToString());
                                }
                                vipinfo.acc_num     = vipinfo.acc_num + accnum;
                                vipinfo.now_acc_num = vipinfo.now_acc_num + accnum;

                                db.t_rm_vip_acclist.Add(new t_rm_vip_acclist
                                {
                                    card_no    = vipinfo.card_no,
                                    card_id    = vipinfo.card_id,
                                    card_type  = vipinfo.card_type,
                                    branch_no  = "000",
                                    oper_type  = "2",
                                    oper_id    = "1001",
                                    ope_date   = DateTime.Now,
                                    flow_no    = "",
                                    consum_amt = 0,
                                    acc_num    = accnum,
                                    oper_des   = "活动##送积分",
                                    memo       = "活动##送积分"
                                });
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("错误:" + ex.ToString());
                            }
                        }

                        db.SaveChanges();


                        if (alertData.Count > 0)
                        {
                            MaintainenceAlertForm form = new MaintainenceAlertForm(alertData);
                            form.ShowDialog();
                        }

                        isRunning = false;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("错误:" + ex.ToString());
            }
        }
Пример #6
0
        private void init()
        {
            string dirs = INIHelper.Read(BaseConfig.INFO_NODE, "tempList", "[]", BaseConfig.INFO_PATH);

            array = JArray.Parse(dirs);
        }
 private void button1_Click(object sender, EventArgs e)
 {
     INIHelper.WriteString(IgnoreVIP, textBox1.Text.Trim(), DirectoryManage.GetINIFullPath());
     MessageBox.Show("保存成功");
 }
Пример #8
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            //string loginPath = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "user.ini");
            //INIHelper.CheckPath(loginPath);
            //string loginName = INIHelper.Read("LoginName", "1", "001", loginPath);
            //if (true)
            //{
            //    dataGridView1.CommitEdit((DataGridViewDataErrorContexts)123);
            //    dataGridView1.BindingContext[dataGridView1.DataSource].EndCurrentEdit();
            //    DataTable dtChange = dt.GetChanges();

            //    foreach (DataRow dr in dtChange.Rows)
            //    {
            //        string strChange = "";
            //        if (dr.RowState == System.Data.DataRowState.Added)
            //        {
            //            strChange = @"INSERT INTO [dbo].[QCnotes]
            //                                   ([QCId]
            //                                    ,[QCtime]
            //                                   ,[QCnum]
            //                                   ,[QCcoding]
            //                                   ,[QCname]
            //                                   ,[QClever]
            //                                   ,[QCclassify]
            //                                   ,[QCdescribe]
            //                                   ,[QCresult]
            //                                   ,[QCover]
            //                                   ,[QCresultDes])
            //                             VALUES
            //                                   ('"+dataGridView1.Rows.Count.ToString()+@"'
            //                                    ,'" + DateTime.Now.ToString("yyyy/MM/dd ") + @"'
            //                                   ,'" + dr["QCnum"].ToString() + @"'
            //                                   ,'" + dr["QCcoding"].ToString() + @"'
            //                                   ,'" + dr["QCname"].ToString() + @"'
            //                                   ,'" + dr["QClever"].ToString() + @"'
            //                                   ,'" + dr["QCclassify"].ToString() + @"'
            //                                   ,'" + dr["QCdescribe"].ToString() + @"'
            //                                   ,'" + dr["QCresult"].ToString() + @"'
            //                                   ,'" + "F" + @"'
            //                                   ,'" + dr["QCresultDes"].ToString() + @"')";
            //        }
            //        else if (dr.RowState == System.Data.DataRowState.Deleted)
            //        {
            //            strChange = @"DELETE FROM [dbo].[QCnotes]
            //                         WHERE QCtime = '" + dr["QCtime", DataRowVersion.Original].ToString() + @"'
            //                           AND QCnum ='" + dr["QCnum", DataRowVersion.Original].ToString() + "'";
            //        }
            //        else if (dr.RowState == System.Data.DataRowState.Modified)
            //        {
            //            strChange = @"UPDATE [dbo].[QCnotes]
            //                           SET [QCnum] = '" + dr["QCnum"].ToString() + @"'
            //                               ,[QCcoding] = '" + dr["QCcoding"].ToString() + @"'
            //                              ,[QCname] = '" + dr["QCname"].ToString() + @"'
            //                              ,[QClever] = '" + dr["QClever"].ToString() + @"'
            //                              ,[QCclassify] = '" + dr["QCclassify"].ToString() + @"'
            //                              ,[QCdescribe] = '" + dr["QCdescribe"].ToString() + @"'
            //                              ,[QCresult] = '" + dr["QCresult"].ToString() + @"'
            //                              ,[QCover] = '" + dr["QCover"].ToString() + @"'
            //                              ,[QCresultDes] = '" + dr["QCresultDes"].ToString() + @"'
            //                   WHERE    QCId= '" + dr["QCId"].ToString() + "'";
            //        }
            //        int Rows = SQLHelper2.Update(strChange);
            //        //if (Rows.ToString() != null)
            //        //{
            //        //    MessageBox.Show("提交成功");
            //        //}
            //        //else
            //        //{
            //        //    MessageBox.Show("提交失败");
            //        //}
            //        //MessageBox.Show(SQLHelper2.Update(strChange).ToString());
            //    }
            //    MessageBox.Show("提交成功");
            //    LoadTable();
            //}
            //else
            //{
            //    MessageBox.Show("无权限!");
            //}
            string loginPath = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "user.ini");

            INIHelper.CheckPath(loginPath);
            string loginName = INIHelper.Read("LoginName", "1", "001", loginPath);
            string strChange;

            if (true)
            {
                string strChd;
                if (checkBox1.Checked == true)
                {
                    strChd = "T";
                }
                else
                {
                    strChd = "F";
                }
                string strSearch = @"SELECT COUNT(QCtime) FROM [YouliData].[dbo].[QCnotes] WHERE QCtime ='" + textBox7.Text.Trim() + "'";
                if (SQLHelper2.GetSingleResult(strSearch).ToString() != "0") //修改
                {
                    strChange = @"UPDATE [dbo].[QCnotes]
                                       SET [QCnum] = '" + textBox1.Text.Trim() + @"'
                                           ,[QCcoding] = '" + textBox2.Text.Trim() + @"'
                                          ,[QCname] = '" + textBox3.Text.Trim() + @"'
                                          ,[QClever] = '" + comboBox1.Text.Trim() + @"'
                                          ,[QCclassify] = '" + comboBox2.Text.Trim() + @"'
                                          ,[QCdescribe] = '" + textBox4.Text.Trim() + @"'
                                          ,[QCresult] = '" + textBox5.Text.Trim() + @"'
                                          ,[QCover] = '" + strChd.Trim() + @"'
                                          ,[QCresultDes] = '" + textBox6.Text.Trim() + @"'
                               WHERE    QCtime= '" + textBox7.Text.Trim() + "'";
                }
                else //新增
                {
                    strChange = @"INSERT INTO [dbo].[QCnotes]
                                               ([QCtime]
                                               ,[QCnum]
                                               ,[QCcoding]
                                               ,[QCname]
                                               ,[QClever]
                                               ,[QCclassify]
                                               ,[QCdescribe]
                                               ,[QCresult]
                                               ,[QCover]
                                               ,[QCresultDes])
                                         VALUES
                                               ('" + textBox7.Text.Trim() + @"'
                                               ,'" + textBox1.Text.Trim() + @"'
                                               ,'" + textBox2.Text.Trim() + @"'
                                               ,'" + textBox3.Text.Trim() + @"'
                                               ,'" + comboBox1.Text.Trim() + @"'
                                               ,'" + comboBox2.Text.Trim() + @"'
                                               ,'" + textBox4.Text.Trim() + @"'
                                               ,'" + textBox5.Text.Trim() + @"'
                                               ,'" + strChd.Trim() + @"'
                                               ,'" + textBox6.Text.Trim() + @"')";
                }

                try
                {
                    SQLHelper2.Update(strChange);
                    MessageBox.Show("修改完成");
                    this.panel1.Size = new System.Drawing.Size(1182, 10);
                    LoadTable();
                }
                catch
                {
                    MessageBox.Show("修改失败");
                }
            }
            else
            {
                MessageBox.Show("无权限");
            }
        }