コード例 #1
0
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     ifoldprogram  = true;
     textBox1.Text = "";
     if (comboBox1.SelectedIndex != -1)
     {
         string pppart = comboBox1.SelectedValue.ToString();
         unilist.ImportFromString(DbHelperSQL.getlist("select 程序Program from " + productnametrim + " where UUID='" + pppart + "'").First());
         CheckAndShow();
     }
 }
コード例 #2
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("执行成功!");
        }
コード例 #3
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("执行成功!");
        }
コード例 #4
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);
            //}



            
        }
コード例 #5
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);

                }
            }




        }
コード例 #6
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);
            //}
        }
コード例 #7
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);
                }
            }
        }