Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="testInfo"></param>
        /// <param name="info"></param>
        /// <returns></returns>
        public bool SaveToFile(VNPTTestInfo testInfo, VNPTLogMoreInfo info)
        {
            try {
                string title         = "Date_Time_Create,MacAddress,ProductCode,NhanVien,Infor1,Infor2,Infor3,Infor4,Infor5,TestSubject,LowerLimit,UpperLimit,GiaTriDo,PhanDinh";
                string fileFullName  = Path.Combine(this.dirLogTotal, this.fileName);
                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 testInfo.GetType().GetProperties())
                    {
                        if (propertyInfo.PropertyType == typeof(VNPTTestItemInfo))
                        {
                            VNPTTestItemInfo itemInfo = (VNPTTestItemInfo)propertyInfo.GetValue(testInfo, null);

                            if (itemInfo.Result != "--")
                            {
                                string content = string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13}",
                                                               DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss ffff"),
                                                               testInfo.MacAddress.Replace(":", "").ToUpper().Replace(",", ";"),
                                                               testInfo.ProductSerial.Replace(",", ";"),
                                                               testInfo.Operator.Replace(",", ";"),
                                                               info.Info1,
                                                               info.Info2,
                                                               info.Info3,
                                                               info.Info4,
                                                               info.Info5,
                                                               propertyInfo.Name.Replace(",", ";"),
                                                               itemInfo.LowerLimit.Replace(",", ";"),
                                                               itemInfo.UpperLimit.Replace(",", ";"),
                                                               itemInfo.Value.Replace(",", ";"),
                                                               itemInfo.Result.Replace(",", ";")
                                                               );

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

                return(true);
            } catch (Exception ex) {
                throw new Exception(ex.Message);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Function lưu kết quả test của sản phẩm vào log detail (định dạng theo yêu cầu BCN).
        /// </summary>
        /// <param name="SoftwareVersion"></param>
        /// <param name="MacAddress"></param>
        /// <param name="TotalResult"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool SaveToFile(VNPTTestInfo testInfo)
        {
            try {
                testInfo.MacAddress = testInfo.MacAddress == null || testInfo.MacAddress == "" || testInfo.MacAddress == string.Empty ? "NULL" : testInfo.MacAddress.Replace(":", "");
                this.fileName       = string.Format("{0}_{1}_{2}_{3}_{4}.txt", this.fileName, testInfo.MacAddress, DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss"), testInfo.TotalResult);
                string fileFullName = Path.Combine(this.dirLogDetail, this.fileName);

                using (StreamWriter sw = new StreamWriter(fileFullName, true, Encoding.Unicode)) {
                    sw.WriteLine(testInfo.SoftwareVersion);
                    sw.WriteLine(testInfo.SystemLog);
                }

                return(true);
            } catch (Exception ex) {
                throw new Exception(ex.Message);
            }
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="testInfo"></param>
        /// <returns></returns>
        public bool SaveToFile(VNPTTestInfo testInfo)
        {
            try {
                VNPTTestInfo info = new VNPTTestInfo();
                info          = testInfo;
                this.fileName = string.Format("{0}_{1}_{2}_{3}_{4}.xml", this.fileName, info.MacAddress, DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss"), info.TotalResult);
                string fileFullName = Path.Combine(this.dirLogSingle, this.fileName);

                //remove SystemLog from testInfo
                var property = info.GetType().GetProperty("SystemLog");
                property.SetValue(info, null, null);

                //save to xml file
                IO.XmlHelper <VNPTTestInfo> .ToXmlFile(info, fileFullName);

                return(true);
            } catch (Exception ex) {
                throw new Exception(ex.Message);
            }
        }