public VnptAsmTestFunctionLogInfo()
        {
            Software_Version = "1.0.0.0";
            Machine_Name     = System.Environment.MachineName;
            Operator         = MyGlobal.MySetting.Operator;

            Date_Time = Mac_Address = Product_Serial = Total_Result = Error_Message = System_Log = "";

            FORMAT = new VnptTestItemInfo();  //ok

            PRINTED = new VnptTestItemInfo(); //ok

            WEIGHT = new VnptTestItemInfo();  //ok
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="logInfo"></param>
        /// <returns></returns>
        public bool To_CSV_File(VnptAsmTestFunctionLogInfo logInfo)
        {
            try {
                string title = "Date_Time_Create,MacAddress,ProductCode,NhanVien,TestSubject,LowerLimit,UpperLimit,GiaTriDo,PhanDinh";
                logInfo.Mac_Address = logInfo.Mac_Address == null || logInfo.Mac_Address == "" || logInfo.Mac_Address == string.Empty ? "NULL" : logInfo.Mac_Address.Replace(":", "");
                this._file_Name     = string.Format("{0}_{1}_{2}_{3}_{4}.csv", this._file_Name, logInfo.Mac_Address, DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss"), logInfo.Total_Result);
                string fileFullName = Path.Combine(_dir_Log_Single, _file_Name);

                //write data to file
                using (StreamWriter sw = new StreamWriter(fileFullName, true, Encoding.Unicode)) {
                    //write title
                    sw.WriteLine(title);

                    foreach (PropertyInfo propertyInfo in logInfo.GetType().GetProperties())
                    {
                        if (propertyInfo.PropertyType == typeof(VnptTestItemInfo))
                        {
                            VnptTestItemInfo itemInfo = (VnptTestItemInfo)propertyInfo.GetValue(logInfo, null);

                            string content = string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8}",
                                                           DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss ffff"),
                                                           logInfo.Mac_Address.Replace(":", "").ToUpper().Replace(",", ";"),
                                                           logInfo.Product_Serial.Replace(",", ";"),
                                                           logInfo.Operator.Replace(",", ";"),
                                                           propertyInfo.Name.Replace(",", ";"),
                                                           itemInfo.Lower_Limit.Replace(",", ";"),
                                                           itemInfo.Upper_Limit.Replace(",", ";"),
                                                           itemInfo.Actual_Value.Replace(",", ";"),
                                                           itemInfo.Result.Replace(",", ";")
                                                           );

                            //write content
                            sw.WriteLine(content);
                        }
                    }
                }

                return(true);
            } catch {
                return(false);
            }
        }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="logInfo"></param>
        /// <param name="moreInfo"></param>
        /// <returns></returns>
        public bool To_CSV_File(VnptAsmTestFunctionLogInfo logInfo, VnptLogMoreInfo moreInfo)
        {
            try {
                string title         = "DATE_TIME,WORK_ORDER,OPERATOR,PN,UID1,UID2,TESTNAME,L_LIMIT,U_LIMIT,MEASURE_VAL,RESULT,INFO1,INFO2,INFO3,INFO4,INFO5,INFO6,INFO7,INFO8,INFO9,INFO10";
                string fileFullName  = Path.Combine(_dir_Log_Total, _file_Name);
                bool   IsCreateTitle = !File.Exists(fileFullName);

                //write data to file
                using (StreamWriter sw = new StreamWriter(fileFullName, true, Encoding.Unicode)) {
                    //write title
                    if (IsCreateTitle == true)
                    {
                        sw.WriteLine(title);
                    }

                    foreach (PropertyInfo propertyInfo in logInfo.GetType().GetProperties())
                    {
                        if (propertyInfo.PropertyType == typeof(VnptTestItemInfo))
                        {
                            VnptTestItemInfo itemInfo = (VnptTestItemInfo)propertyInfo.GetValue(logInfo, null);

                            //check save log NONE
                            if (MyGlobal.MySetting.SaveLogNoMeaning == "No")
                            {
                                if (itemInfo.Result.ToLower().Contains("none") == true)
                                {
                                    continue;
                                }
                            }

                            //check save log format
                            if (MyGlobal.MySetting.IsSaveLogFormat == false)
                            {
                                if (propertyInfo.Name.ToLower().Equals("format") == true)
                                {
                                    continue;
                                }
                            }

                            //check save log printed
                            if (MyGlobal.MySetting.IsSaveLogPrinted == false)
                            {
                                if (propertyInfo.Name.ToLower().Equals("printed") == true)
                                {
                                    continue;
                                }
                            }

                            //check save log weight
                            if (MyGlobal.MySetting.IsSaveLogWeight == false)
                            {
                                if (propertyInfo.Name.ToLower().Equals("weight") == true)
                                {
                                    continue;
                                }
                            }

                            //save log
                            string content = string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18},{19},{20}",
                                                           DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss ffff"),
                                                           logInfo.Production_Command.Replace(",", ";"),
                                                           logInfo.Operator.Replace(",", ";"),
                                                           logInfo.ProductCode.Replace(",", ";"),
                                                           logInfo.Mac_Address.Replace(":", "").ToUpper().Replace(",", ";"),
                                                           logInfo.Product_Serial.Replace(",", ";"),
                                                           propertyInfo.Name.Replace(",", ";"),
                                                           itemInfo.Lower_Limit.Replace(",", ";"),
                                                           itemInfo.Upper_Limit.Replace(",", ";"),
                                                           itemInfo.Actual_Value.Replace(",", ";"),
                                                           itemInfo.Result.Replace(",", ";"),
                                                           logInfo.ProductionLot.Replace(",", ";"),
                                                           logInfo.LotProgress.Replace(",", ";"),
                                                           moreInfo.Info3,
                                                           moreInfo.Info4,
                                                           moreInfo.Info5,
                                                           moreInfo.Info6,
                                                           moreInfo.Info7,
                                                           moreInfo.Info8,
                                                           moreInfo.Info9,
                                                           moreInfo.Info10
                                                           );

                            //write content
                            sw.WriteLine(content);
                        }
                    }
                }
                return(true);
            }
            catch {
                return(false);
            }
        }