示例#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("生成完毕");
            }
        }
示例#2
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);
            //}



            
        }
示例#3
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("生成完毕");

        }
        }
示例#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);
            //}
        }