Ejemplo n.º 1
0
        public void InsertLog(cGlobalParas.LogType lType, string PlanID, string PlanName, cGlobalParas.RunTaskType rType, string FileName, string Para)
        {
            string strXml = "<LogType>" + ((int)lType).ToString() + "</LogType>" +
                            "<PlanID>" + PlanID + "</PlanID>" +
                            "<PlanName>" + PlanName + "</PlanName>" +
                            "<FileName>" + FileName + "</FileName>" +
                            "<FilePara>" + Para + "</FilePara>" +
                            "<TaskType>" + ((int)rType).ToString() + "</TaskType>" +
                            "<RunTime>" + DateTime.Now.ToString() + "</RunTime>";

            m_PlanFile.InsertElement("Logs", "Log", strXml);
            m_PlanFile.Save();
        }
Ejemplo n.º 2
0
        public void WriteLog(string TaskName, cGlobalParas.LogType LogType, string strLog)
        {
            string FileName = Program.getPrjPath() + "Log\\" + TaskName + DateTime.Now.Year;

            if (DateTime.Now.Month.ToString().Length == 1)
            {
                FileName = FileName + "0" + DateTime.Now.Month.ToString();
            }
            else
            {
                FileName = FileName + DateTime.Now.Month.ToString();
            }

            if (DateTime.Now.Day.ToString().Length == 1)
            {
                FileName = FileName + "0" + DateTime.Now.Day.ToString();
            }
            else
            {
                FileName = FileName + DateTime.Now.Day.ToString();
            }

            FileName = FileName + ".txt";

            string Log = "";

            if (!Directory.Exists(Path.GetDirectoryName(FileName)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(FileName));
            }

            FileStream   myStream = File.Open(FileName, FileMode.Append, FileAccess.Write, FileShare.Write);
            StreamWriter sw       = new StreamWriter(myStream, System.Text.Encoding.GetEncoding("gb2312"));

            if (LogType == cGlobalParas.LogType.GatherError)
            {
                Log = TaskName + "\t" + DateTime.Now.ToString() + "\t" + "采集错误" + "\t" + strLog;
                sw.WriteLine(Log);
            }
            else if (LogType == cGlobalParas.LogType.PublishError)
            {
                Log = TaskName + "\t" + DateTime.Now.ToString() + "\t" + "发布错误" + "\t" + strLog;
                sw.WriteLine(Log);
            }

            sw.Close();
            myStream.Close();
        }
Ejemplo n.º 3
0
        public void InsertOnceLog(cGlobalParas.LogType lType, string PlanID, string PlanName, cGlobalParas.RunTaskType rType, string FileName, string Para)
        {
            if (!IsExist())
            {
                NewLogFile();
            }

            cXmlIO xmlconfig = new cXmlIO(Program.getPrjPath() + "tasks\\plan\\RunLog.xml");

            string strXml = "<LogType>" + lType + "</LogType>" +
                            "<PlanID>" + PlanID + "</PlanID>" +
                            "<PlanName>" + PlanName + "</PlanName>" +
                            "<FileName>" + FileName + "</FileName>" +
                            "<FilePara>" + Para + "</FilePara>" +
                            "<TaskType>" + rType + "</TaskType>" +
                            "<RunTime>" + DateTime.Now.ToString() + "</RunTime>";

            xmlconfig.InsertElement("Logs", "Log", strXml);
            xmlconfig.Save();
            xmlconfig = null;
        }