Ejemplo n.º 1
0
        public static void WriteCSV(string path)
        {
            if (!IsRecordTackTimeLogger)
            {
                return;
            }
            object[] headObjs = new object[_tackTimeItemCollection.Count + 2];
            headObjs[0] = "DateTime";
            headObjs[1] = "Millisecond";
            for (int i = 0; i < _tackTimeItemCollection.Count; i++)
            {
                headObjs[i + 2] = string.Format("{0}({1})", _tackTimeItemCollection[i].Name, _tackTimeItemCollection[i].TackTimeInfoCollection.Count);
            }
            string dateTime = DateTime.Now.ToString("yyyyMMdd_HHmmss");

            SimpleCsvHelper.AddData(path, string.Format("TackTime_{0}.csv", dateTime), headObjs);
            for (int j = 0; j < _tackTimeItemCollection[0].TackTimeInfoCollection.Count; j++)
            {
                object[] objs = new object[_tackTimeItemCollection.Count + 2];
                objs[0] = _tackTimeItemCollection[0].TackTimeInfoCollection[j].TimeSpan.ToString();
                objs[1] = _tackTimeItemCollection[0].TackTimeInfoCollection[j].TimeSpan.TotalMilliseconds;
                for (int i = 0; i < _tackTimeItemCollection.Count; i++)
                {
                    objs[i + 2] = _tackTimeItemCollection[i].TackTimeInfoCollection[j].TaskName;
                }
                SimpleCsvHelper.AddData(path, string.Format("TackTime_{0}.csv", dateTime), objs);
            }
        }
Ejemplo n.º 2
0
        private void Save(string folderPath, string fileName, string cultureName)
        {
            //ErrorCode error = new ErrorCode()
            //{
            //    ErrorType = ErrorType.Alarm,
            //    Code = -1,
            //    Message = "Unknow Error",
            //    Remark = "中文測試"
            //};
            //ErrorCode error2 = new ErrorCode()
            //{
            //    ErrorType = ErrorType.Warning,
            //    Code = -2,
            //    Message = "Unknow Error",
            //    Remark = "English Test"
            //};
            //_dicAlarmCodeCollection.Add(error.Code, error);
            //_dicWarningCodeCollection.Add(error2.Code, error2);

            string filePath = string.Format(@"{0}\{1}", folderPath, fileName);

            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }
            SimpleCsvHelper.AddData(folderPath, fileName, "{0},{1},{2},{3}", "ErrorType", "Code", "Message", "Remark");
            foreach (var item in _dicAlarmCodeCollection)
            {
                ErrorCode errorCode = item.Value;
                SimpleCsvHelper.AddData(folderPath, fileName, errorCode.ErrorType, errorCode.Code, errorCode.Message, errorCode.Remark);
            }
            foreach (var item in _dicWarningCodeCollection)
            {
                ErrorCode errorCode = item.Value;
                SimpleCsvHelper.AddData(folderPath, fileName, errorCode.ErrorType, errorCode.Code, errorCode.Message, errorCode.Remark);
            }
        }