예제 #1
0
        //重写CSV文件
        public static void RewrteCSV(string WriteString, string strFile, bool bAppendEnter)
        {
            try
            {
                StreamWriter swf = new StreamWriter(strFile, true, Encoding.Default);
                if (bAppendEnter)
                {
                    swf.Write(WriteString + "\r\n");
                }
                else
                {
                    swf.Write(WriteString);
                }

                swf.Close();
            }
            catch (System.Exception ex)
            {
                FormMessage.MesssageShowOnce("csv文件操作出错:" + ex.Message + " 请不要在运行中打开csv文件", FormMessage.MSG.CSV);
                RewrteCSV(WriteString, strFile, bAppendEnter);
                //HintMessageInfo.MessageTopMost("csv文件操作出错," +ex.Message+ " 请不要在运行中打开csv文件");
            }
        }
예제 #2
0
        //write csv log
        public static void WriteCSVDate(string WriteString, int checkNum, bool bAppendEnter = true, string path = CConst.SAVE_DATA_PATH)
        {
            //path = Application.StartupPath + "\\Data";
            if (checkNum == 1)
            {
                CConst.Save_Folder_Name = "\\CamData1";
            }
            else if (checkNum == 2)
            {
                CConst.Save_Folder_Name = "\\CamData2";
            }
            else if (checkNum == 3)
            {
                CConst.Save_Folder_Name = "\\CamData3";
            }
            else if (checkNum == 4)
            {
                CConst.Save_Folder_Name = "\\CPK";
            }
            else if (checkNum == 5)
            {
                CConst.Save_Folder_Name = "\\PRODUCT";
            }
            path = path + CConst.Save_Folder_Name;
            if (Directory.Exists(path) == false)
            {
                Directory.CreateDirectory(path);
            }
            StreamWriter swf     = null;
            string       strFile = path + "\\" + DateTime.Now.ToString("yyyyMMdd") + ".csv";

            if (File.Exists(strFile) == false)
            {
                swf = new StreamWriter(strFile, true, Encoding.Default);
                if (checkNum == 3 || checkNum == 2)
                {
                    swf.Write("时间,指令,数量,穴3,穴6,穴9,穴12,穴2,穴5,穴8,穴11,穴1,穴4,穴7,穴10,NO1_1,NO1_2,NO1_3,NO1_4,NO1_5,NO2_1,NO2_2,NO2_3,NO2_4,NO2_5,NO3_1,NO3_2,NO3_3,NO3_4,NO3_5,NO4_1,NO4_2,NO4_3,NO4_4,NO4_5,NO5_1,NO5_2,NO5_3,NO5_4,NO5_5,NO6_1,NO6_2,NO6_3,NO6_4,NO6_5,NO7_1,NO7_2,NO7_3,NO7_4,NO7_5,NO8_1,NO8_2,NO8_3,NO8_4,NO8_5,NO9_1,NO9_2,NO9_3,NO9_4,NO9_5,NO10_1,NO10_2,NO10_3,NO10_4,NO10_5,NO11_1,NO11_2,NO11_3,NO11_4,NO11_5,NO12_1,NO12_2,NO12_3,NO12_4,NO12_5,\r\n");
                }
                else if (checkNum == 4 || checkNum == 5)
                {
                    swf.Write("Time,Carrier_SN,Cavity,Machine_ID,MLB_SN,Pin1_Gap_X,Pin1_Gap_Y,Pin2_Gap_X,Pin2_Gap_Y,Angle,Press_Force,Press_Time,Tossing,Cycle_Time,Flex_VENDOR,CM_VENDOR,Operator_ID,Mode,TestSeriesID,Priority");
                }
            }

            try
            {
                if (swf == null)
                {
                    swf = new StreamWriter(strFile, true, Encoding.Default);
                }
                if (bAppendEnter)
                {
                    swf.Write(WriteString + "\r\n");
                }
                else
                {
                    swf.Write(WriteString);
                }

                swf.Close();
            }
            catch (System.Exception ex)
            {
                FormMessage.MesssageShowOnce("csv文件操作出错:" + ex.Message + " 请不要在运行中打开csv文件", FormMessage.MSG.CSV);
                RewrteCSV(WriteString, strFile, bAppendEnter);
            }
        }