Beispiel #1
0
        private void button8_Click(object sender, EventArgs e)
        {
            SaveFileDialog ofd      = new SaveFileDialog();
            var            templist = new NCcodeList(dbinfo);

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                templist.NCList.AddRange(unilist.NCList);
                if (comboBox1.Visible == true && checkBox3.Checked == true)
                {
                    string firstrow = "(MSG,START PROGRAM PART " + (comboBox1.SelectedIndex + 1).ToString() + " :" + comboBox1.SelectedValue + ")";

                    templist.NCList.Insert(1, firstrow);
                }

                if (comboBox1.Visible == true && checkBox3.Checked == true)
                {
                    string endrow = "(MSG,END PROGRAM PART " + (comboBox1.SelectedIndex + 1).ToString() + " :" + comboBox1.SelectedValue + ")";
                    templist.NCList.Insert(templist.NCList.Count() - 2, endrow);
                }
                templist.SaveFile(ofd.FileName, checkBox1.Checked);
                System.Diagnostics.Process pro = new System.Diagnostics.Process();
                pro.StartInfo.FileName = "notepad.exe";

                pro.StartInfo.Arguments = ofd.FileName;
                pro.Start();

                MessageBox.Show("生成完毕");
            }
        }
Beispiel #2
0
 public program_input()
 {
     InitializeComponent();
     dbinfo  = new DBInfo();
     unilist = new NCcodeList(dbinfo);
     listBox2.DataBindings.Add("DataSource", unilist, "ShowWrongList");
     listBox1.DataBindings.Add("DataSource", unilist, "ShowNCList");
 }
Beispiel #3
0
        public program_input()
        {
            InitializeComponent();
            dbinfo = new DBInfo();
            unilist = new NCcodeList(dbinfo);
            listBox2.DataBindings.Add("DataSource", unilist, "ShowWrongList");
            listBox1.DataBindings.Add("DataSource", unilist, "ShowNCList");

        }
        public NCcodeList ImportFromFileTest()
        {
           string testpath= System.Environment.CurrentDirectory + @"\TestFiles\WRONG_NC";
            NinjectDependencyResolver dd = new NinjectDependencyResolver();
            
            NCcodeList ncls = new NCcodeList((IDBInfo)dd.GetService(typeof(IDBInfo)));

            ncls.ImportFromFile(testpath);
            Assert.AreNotEqual(ncls.NCList.Count(),0);
            return ncls;
        }
Beispiel #5
0
 private string CheckAndShow(NCcodeList abc, bool report, bool productref)
 {
     try
     {
         return(abc.Check(report: report, productref: productref));
         //unilist.AddRangeToWrongList(abc.ShowWrongList);
     }
     catch (NCException ex)
     {
         MessageBox.Show("Check引发异常" + ex.GetType().ToString() + ":" + ex.Message);
     }
     return("");
 }
Beispiel #6
0
        private void CheckAll(Action <int> proc)
        {
            ClearWrongList();
            comboBox1.SelectedIndex = -1;
            // listBox1.DataSource = null;

            NCcodeList abc = new NCcodeList(dbinfo);

            for (int i = 0; i < comboBox1.Items.Count; i++)
            {
                string pppart = comboBox1.Items[i].ToString();
                proc(i);
            }
        }
Beispiel #7
0
        private void reTrimToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Action <int> proc = delegate(int i)
            {
                string pppart   = comboBox1.Items[i].ToString();
                var    templist = new NCcodeList(dbinfo);
                templist.ImportFromString(DbHelperSQL.getlist("select 程序Program from " + productnametrim + " where UUID='" + pppart + "'").First());
                CheckAndShow(templist, false, true);
                unilist.AddRangeToWrongList(templist.ShowWrongList);
                DbHelperSQL.ExecuteSql("Update " + productnametrim + " set 程序Program='" + templist.ToString() + "' where uuid='" + pppart + "'");
            };

            CheckAll(proc);
            MessageBox.Show("执行成功!");
        }
Beispiel #8
0
        private void reTrimToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Action<int> proc = delegate (int i)
            {
                string pppart = comboBox1.Items[i].ToString();
                var templist = new NCcodeList(dbinfo);
                templist.ImportFromString(DbHelperSQL.getlist("select 程序Program from " + productnametrim + " where UUID='" + pppart + "'").First());
                CheckAndShow(templist, false, true);
                unilist.AddRangeToWrongList(templist.ShowWrongList);
                DbHelperSQL.ExecuteSql("Update " + productnametrim + " set 程序Program='" + templist.ToString() + "' where uuid='" + pppart + "'");
            };

            CheckAll(proc);
            MessageBox.Show("执行成功!");
        }
Beispiel #9
0
        private void outputAllToolStripMenuItem_Click(object sender, EventArgs e)
        {

            //fetch the part quantity

          var partDic=  DbHelperSQL.getDic("select UUID,CONCAT(胶嘴Sealant_Tip,';',下铆头Lower_Anvil) from " + productnametrim );
            int partnum = 0;
            string lastpartname = "";
            //try
            //{
                List<string> tempabc = new List<string>();

              
                string savefolder = localMethod.GetConfigValue("InfoPath") +prodchnname+"_"+ productnametrim.Replace("process","-001") + "\\NC\\";

                if (!System.IO.Directory.Exists(savefolder))
                {
                    System.IO.Directory.CreateDirectory(savefolder);
                }
                //Do not look through sub dictionary
                List<FileInfo> rm = new List<FileInfo>();
                rm.WalkTree(savefolder, false);
                string newfolder = savefolder + "old";
                rm.moveto(newfolder);

                ClearWrongList();
                comboBox1.SelectedIndex = -1;


                ClearWrongList();
                comboBox1.SelectedIndex = -1;
               // listBox1.DataSource = null;

                NCcodeList wholelist = new NCcodeList(dbinfo);

                Action<int> proc = delegate (int i)
                {
                    string pppart = comboBox1.Items[i].ToString();
                    var templist = new NCcodeList(dbinfo);

                    //   templist.Check(true, false, true);
                    List<string> head = new List<string>();
                    head.Add(productnametrim.Replace("process", "").Replace("C0", "O") + (i + 1).ToString());

                    if (partDic.Values.ElementAt(i) != lastpartname)
                    {
                        if (partnum != 0)
                        {
                            head.Add("(Part" + partnum.ToString() + " END)");
                        }

                        partnum = partnum + 1;
                        head.Add("(PART" + partnum.ToString() + " START)");
                        lastpartname = partDic.Values.ElementAt(i);
                    }
                    head.Add("(MSG,START PROGRAM SEGMENT " + (i + 1).ToString() + " :" + pppart + ")");
                    head.Add("(MSG,MAKE SURE THE SEALANT TIP AND LOWER ANVIL:" + partDic[pppart] + ")");
                    templist.ImportFromString(DbHelperSQL.getlist("select 程序Program from " + productnametrim + " where UUID='" + pppart + "'").First(),false);
                    if (templist.NCList.Count == 0)
                    {
                        return;
                    }
                    templist.NCList.InsertRange(1, head);
                    
                   
                    templist.NCList.Insert(templist.NCList.Count-2,"(MSG,END PROGRAM SEGMENT " + (comboBox1.SelectedIndex + 1).ToString() + " :" + comboBox1.SelectedValue + ")");
                    string filename = "SEG_" + (i + 1).ToString() + "_" + pppart;
                    string filepath = savefolder + filename;
                    wholelist.NCList.AddRange(templist.NCList);
                   if(!templist.SaveFile(filepath))
                    {
                        throw new NCException("写入文件" + filename + "失败");
                    }

                    
                };
                //Look through all parts and output them
               CheckAll(proc);

                //2015.9.4 change the name to the formal program num.
                string filenameall = this.Text;
                string NCpath = savefolder + filenameall;
                wholelist.SaveFile(NCpath);
                if (!wholelist.NCList.WriteFile(NCpath))
                {
                    throw new NCException("写入文件" + filenameall + "失败");
                }
                DateTime edittime= System.IO.Directory.GetLastWriteTime(savefolder);
                //DateTime nowtime=

               TimeSpan ts1 = new TimeSpan(edittime.Ticks);

               TimeSpan ts2 = new TimeSpan(DateTime.Now.Ticks);

               TimeSpan ts = ts1.Subtract(ts2).Duration();

               System.Diagnostics.Process.Start("explorer.exe", savefolder);
               if( ts.TotalSeconds>5)
               {
                   MessageBox.Show("输出失败");
               }
               else
               {
                    //Update the MD5 and the creation time in database

                    string fileMD5=  localMethod.GetMD5HashFromFile(NCpath);
                    string creationtime = edittime.ToString();
                    Dictionary<string, string> dic = new Dictionary<string, string>();
                    dic.Add("TIME", creationtime);
                    dic.Add("MD5", fileMD5);
                    string jsontext=   localMethod.ToJson(dic);
                  //  string prodchnname = autorivet_op.queryno(productnametrim, "名称");
                    DbHelperSQL.ExecuteSql("update 产品数模 set 备注='"+jsontext+"' where 产品名称='"+prodchnname+ "' and 文件类型='Process'");
                    MessageBox.Show("执行成功!已于"+ creationtime + "更新");
               }

               
            //}
            //catch(Exception ee)
            //{
               
            //    MessageBox.Show("输出失败:"+ee.Message);
            //}



            
        }
Beispiel #10
0
        private void checkAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ClearWrongList();
            comboBox1.SelectedIndex = -1;
         //   listBox1.DataSource = null;
            
            NCcodeList abc = new NCcodeList(dbinfo);

          Action<int> proc = delegate (int i)
               {
                   string pppart = comboBox1.Items[i].ToString();
                   var templist=new NCcodeList(dbinfo);
                   templist.ImportFromString(DbHelperSQL.getlist("select 程序Program from " + productnametrim + " where UUID='" + pppart + "'").First());
                 
                   CheckAndShow(templist, false, true);
                  
                   abc.NCList.AddRange(templist.NCList);

               };
           
           CheckAll(proc);

            unilist.NCList = abc.NCList;
             CheckAndShow();
            comboBox1.SelectedIndex = -1;

            var fastcom = from kk in dbinfo.DBfastlist.AsEnumerable()
                     join ll in unilist.fastList.AsEnumerable()
                     on kk.Key equals ll.Key
                     select new
                     {
                         fstName=kk.Key,
                         tvaqty=kk.Value,
                         fstqty=ll.Value

                     };
            var drillcom = from kk in dbinfo.DBdrilllist.AsEnumerable()
                           join ll in unilist.drillList.AsEnumerable()
                           on kk.Key equals ll.Key
                           select new
                           {
                               fstName = kk.Key,
                               tvaqty = kk.Value,
                               drlqty = ll.Value

                           };
            foreach (var pp in fastcom)
            {
                if(pp.fstqty!=pp.tvaqty)
                {
                    string errmsg = pp.fstName + "铆接数量错误!TVA数量:" + pp.tvaqty + ";NC代码数量:" + pp.fstqty;
                    SetWrong(0, errmsg);
                    MessageBox.Show(errmsg);

                }
            }

            foreach (var pp in drillcom)
            {
                if (pp.drlqty!= pp.tvaqty)
                {
                    string errmsg = pp.fstName + "钻孔数量错误!TVA数量:" + pp.tvaqty + ";NC代码数量:" + pp.drlqty;
                    SetWrong(0, errmsg);
                    MessageBox.Show(errmsg);

                }
            }




        }
Beispiel #11
0
        private void CheckAll(Action<int> proc)
        {
            ClearWrongList();
            comboBox1.SelectedIndex = -1;
           // listBox1.DataSource = null;

            NCcodeList abc = new NCcodeList(dbinfo);
            for (int i = 0; i < comboBox1.Items.Count; i++)
            {
                string pppart = comboBox1.Items[i].ToString();
                proc(i);
            }


        }
Beispiel #12
0
        private void button8_Click(object sender, EventArgs e)
        {
            SaveFileDialog ofd = new SaveFileDialog();
            var templist = new NCcodeList(dbinfo);
           if( ofd.ShowDialog() == DialogResult.OK)
           {

                templist.NCList.AddRange(unilist.NCList);
            if (comboBox1.Visible==true&& checkBox3.Checked==true)
            {
                string firstrow = "(MSG,START PROGRAM PART " + (comboBox1.SelectedIndex + 1).ToString() + " :"+comboBox1.SelectedValue+")";

                    templist.NCList.Insert(1,firstrow);
            }

            if (comboBox1.Visible == true && checkBox3.Checked == true)
            {
                string endrow = "(MSG,END PROGRAM PART " + (comboBox1.SelectedIndex + 1).ToString() + " :" + comboBox1.SelectedValue + ")";
                    templist.NCList.Insert(templist.NCList.Count()-2, endrow);
             }
                templist.SaveFile(ofd.FileName,checkBox1.Checked);
            System.Diagnostics.Process pro = new System.Diagnostics.Process();
            pro.StartInfo.FileName = "notepad.exe";
            
            pro.StartInfo.Arguments = ofd.FileName;
            pro.Start();
               
            MessageBox.Show("生成完毕");

        }
        }
Beispiel #13
0
        private string CheckAndShow(NCcodeList abc,bool report, bool productref)
        {
            try
            {
                return abc.Check(report: report, productref: productref);
                //unilist.AddRangeToWrongList(abc.ShowWrongList);
              
            }
            catch (NCException ex)
            {
                MessageBox.Show("Check引发异常" + ex.GetType().ToString() + ":" + ex.Message);

            }
            return "";
        }
Beispiel #14
0
        private void outputAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //fetch the part quantity

            var    partDic      = DbHelperSQL.getDic("select UUID,CONCAT(胶嘴Sealant_Tip,';',下铆头Lower_Anvil) from " + productnametrim);
            int    partnum      = 0;
            string lastpartname = "";
            //try
            //{
            List <string> tempabc = new List <string>();


            string savefolder = localMethod.GetConfigValue("InfoPath") + prodchnname + "_" + productnametrim.Replace("process", "-001") + "\\NC\\";

            if (!System.IO.Directory.Exists(savefolder))
            {
                System.IO.Directory.CreateDirectory(savefolder);
            }
            //Do not look through sub dictionary
            List <FileInfo> rm = new List <FileInfo>();

            rm.WalkTree(savefolder, false);
            string newfolder = savefolder + "old";

            rm.moveto(newfolder);

            ClearWrongList();
            comboBox1.SelectedIndex = -1;


            ClearWrongList();
            comboBox1.SelectedIndex = -1;
            // listBox1.DataSource = null;

            NCcodeList wholelist = new NCcodeList(dbinfo);

            Action <int> proc = delegate(int i)
            {
                string pppart   = comboBox1.Items[i].ToString();
                var    templist = new NCcodeList(dbinfo);

                //   templist.Check(true, false, true);
                List <string> head = new List <string>();
                head.Add(productnametrim.Replace("process", "").Replace("C0", "O") + (i + 1).ToString());

                if (partDic.Values.ElementAt(i) != lastpartname)
                {
                    if (partnum != 0)
                    {
                        head.Add("(Part" + partnum.ToString() + " END)");
                    }

                    partnum = partnum + 1;
                    head.Add("(PART" + partnum.ToString() + " START)");
                    lastpartname = partDic.Values.ElementAt(i);
                }
                head.Add("(MSG,START PROGRAM SEGMENT " + (i + 1).ToString() + " :" + pppart + ")");
                head.Add("(MSG,MAKE SURE THE SEALANT TIP AND LOWER ANVIL:" + partDic[pppart] + ")");
                templist.ImportFromString(DbHelperSQL.getlist("select 程序Program from " + productnametrim + " where UUID='" + pppart + "'").First(), false);
                if (templist.NCList.Count == 0)
                {
                    return;
                }
                templist.NCList.InsertRange(1, head);


                templist.NCList.Insert(templist.NCList.Count - 2, "(MSG,END PROGRAM SEGMENT " + (comboBox1.SelectedIndex + 1).ToString() + " :" + comboBox1.SelectedValue + ")");
                string filename = "SEG_" + (i + 1).ToString() + "_" + pppart;
                string filepath = savefolder + filename;
                wholelist.NCList.AddRange(templist.NCList);
                if (!templist.SaveFile(filepath))
                {
                    throw new NCException("写入文件" + filename + "失败");
                }
            };

            //Look through all parts and output them
            CheckAll(proc);

            //2015.9.4 change the name to the formal program num.
            string filenameall = this.Text;
            string NCpath      = savefolder + filenameall;

            wholelist.SaveFile(NCpath);
            if (!wholelist.NCList.WriteFile(NCpath))
            {
                throw new NCException("写入文件" + filenameall + "失败");
            }
            DateTime edittime = System.IO.Directory.GetLastWriteTime(savefolder);
            //DateTime nowtime=

            TimeSpan ts1 = new TimeSpan(edittime.Ticks);

            TimeSpan ts2 = new TimeSpan(DateTime.Now.Ticks);

            TimeSpan ts = ts1.Subtract(ts2).Duration();

            System.Diagnostics.Process.Start("explorer.exe", savefolder);
            if (ts.TotalSeconds > 5)
            {
                MessageBox.Show("输出失败");
            }
            else
            {
                //Update the MD5 and the creation time in database

                string fileMD5                  = localMethod.GetMD5HashFromFile(NCpath);
                string creationtime             = edittime.ToString();
                Dictionary <string, string> dic = new Dictionary <string, string>();
                dic.Add("TIME", creationtime);
                dic.Add("MD5", fileMD5);
                string jsontext = localMethod.ToJson(dic);
                //  string prodchnname = autorivet_op.queryno(productnametrim, "名称");
                DbHelperSQL.ExecuteSql("update 产品数模 set 备注='" + jsontext + "' where 产品名称='" + prodchnname + "' and 文件类型='Process'");
                MessageBox.Show("执行成功!已于" + creationtime + "更新");
            }


            //}
            //catch(Exception ee)
            //{

            //    MessageBox.Show("输出失败:"+ee.Message);
            //}
        }
Beispiel #15
0
        private void checkAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ClearWrongList();
            comboBox1.SelectedIndex = -1;
            //   listBox1.DataSource = null;

            NCcodeList abc = new NCcodeList(dbinfo);

            Action <int> proc = delegate(int i)
            {
                string pppart   = comboBox1.Items[i].ToString();
                var    templist = new NCcodeList(dbinfo);
                templist.ImportFromString(DbHelperSQL.getlist("select 程序Program from " + productnametrim + " where UUID='" + pppart + "'").First());

                CheckAndShow(templist, false, true);

                abc.NCList.AddRange(templist.NCList);
            };

            CheckAll(proc);

            unilist.NCList = abc.NCList;
            CheckAndShow();
            comboBox1.SelectedIndex = -1;

            var fastcom = from kk in dbinfo.DBfastlist.AsEnumerable()
                          join ll in unilist.fastList.AsEnumerable()
                          on kk.Key equals ll.Key
                          select new
            {
                fstName = kk.Key,
                tvaqty  = kk.Value,
                fstqty  = ll.Value
            };
            var drillcom = from kk in dbinfo.DBdrilllist.AsEnumerable()
                           join ll in unilist.drillList.AsEnumerable()
                           on kk.Key equals ll.Key
                           select new
            {
                fstName = kk.Key,
                tvaqty  = kk.Value,
                drlqty  = ll.Value
            };

            foreach (var pp in fastcom)
            {
                if (pp.fstqty != pp.tvaqty)
                {
                    string errmsg = pp.fstName + "铆接数量错误!TVA数量:" + pp.tvaqty + ";NC代码数量:" + pp.fstqty;
                    SetWrong(0, errmsg);
                    MessageBox.Show(errmsg);
                }
            }

            foreach (var pp in drillcom)
            {
                if (pp.drlqty != pp.tvaqty)
                {
                    string errmsg = pp.fstName + "钻孔数量错误!TVA数量:" + pp.tvaqty + ";NC代码数量:" + pp.drlqty;
                    SetWrong(0, errmsg);
                    MessageBox.Show(errmsg);
                }
            }
        }