Esempio n. 1
0
        public LogManager Creator(LogType logTipi)
        {
            LogManager lm = null;

            switch (logTipi)
            {
            case LogType.DatabaseLog:
                lm = new DatabaseLog();
                break;

            case LogType.MailLog:
                lm = new MailLog();
                break;

            case LogType.TxtLog:
                lm = new TxtLog();
                break;

            case LogType.XmlLog:
                lm = new XmlLog();
                break;

            default:
                return(null);
            }

            return(lm);
        }
Esempio n. 2
0
        public void LogXml(string xml, bool isRequest = false)
        {
            try
            {
                using (var db = new LogContext())
                {
                    var request = ConfigureRequest(db);

                    var log = new XmlLog
                    {
                        Message      = "Xml record",
                        Request      = request,
                        SessionToken = "8675309",
                        SystemGuid   = RequestID,
                        Username     = "******",
                        Xml          = xml,
                        Type         = isRequest ? "Request" : "Response"
                    };
                    db.XmlLogs.Add(log);
                    db.SaveChanges();
                }
            }
            catch (Exception)
            {
                // do something cool
            }
        }
Esempio n. 3
0
 public MainViewModel()
 {
     ShowLogCommand = new DelegateCommand <RoutedEventArgs>((e) =>
     {
         var l = new XmlLog();
         l.ShowDialog();
     }, () => true);
 }
Esempio n. 4
0
 public WSAgent()
 {
     _XmlLog = new XmlLog {
         Source = "SSharing.Proxy"
     };
     _PerfLog = new PerformanceLog {
         Source = "SSharing.Proxy"
     };
 }
Esempio n. 5
0
        /// <summary>
        /// 写xml日志
        /// </summary>
        /// <param name="xmlLog"></param>
        public static void Xml(XmlLog xmlLog)
        {
            var list = new List <XmlLog>();

            list.Add(xmlLog);
            var data = list.ToJson();

            HttpHelper.Post(xmlLog.Url, data);
        }
Esempio n. 6
0
        public void SignIn(object PasswordBox)
        {
            var ps       = PasswordBox as PasswordBox;
            var password = ps.SecurePassword;

            Client          = new XmppWebSocketConnection(new JID(JID), SecureStringToString(password), WebSocketUri);
            Client.Element += (sender, args) => Execute.OnUIThread(() => XmlLog.Add(args.Stanza.ToString()));
            Task.Factory.StartNew(() => Client.Connect());
        }
Esempio n. 7
0
        public override string calculate(string input)
        {
            String rtrn   = "";
            XmlLog xmlLog = getOrCreateXmlLog(varName);

            foreach (XmlNode topNode in xmlLog.xmlDocument.ChildNodes)
            {
                foreach (XmlNode node in topNode.ChildNodes)
                {
                    rtrn += node.Name + Environment.NewLine;
                }
            }
            return(rtrn);
        }
Esempio n. 8
0
    static void Main(string[] args)
    {
        var log    = new XmlLog();
        var values = new Dictionary <string, string> {
            { "Hello", "1" }, { "World", "2" }
        };

        foreach (var methodInfo in typeof(XmlLog).GetProperties(BindingFlags.Instance | BindingFlags.Public))
        {
            methodInfo.SetValue(log, values[methodInfo.Name]);
        }

        Console.WriteLine(log.Hello);
        Console.WriteLine(log.World);
    }
        public void Persist(object Object)
        {
            if (Object is StartTestInfo)
            {
                XmlLog.StartNewTest();
                XmlLog.CurrentTest.TestInfo = new XmlTestInfo((StartTestInfo)Object);

                string possibleIssuesMessage = ((StartTestInfo)Object).PossibleIssuesMessage;
                if (!string.IsNullOrEmpty(possibleIssuesMessage))
                {
                    new CommentInfoObject().Persist(new CommentInfo(possibleIssuesMessage));
                }
            }
            else
            {
                ExceptionsHelper.ThrowObjectLoggerDoesNotSupportThisObjectType(Object, typeof(StartTestInfo));
            }
        }
Esempio n. 10
0
        /// <summary>
        /// reads and shows log
        /// </summary>
        public void ReadAndRefreshLog()
        {
            XmlWriterSettings writerSettings = new XmlWriterSettings();

            writerSettings.Indent = true;

            //lets save log file
            using (XmlWriter xmlLogFile = XmlTextWriter.Create(GetXmlLogFilePath(), writerSettings))
            {
                XmlLog.GetTestRunXml(xmlLogFile);
            }

            //delete all test log files
            string[] testLogFiles = Directory.GetFiles(Path.GetTempPath(), GetTempFilesPrefix() + "." + constTestLogFileNamePrefix + "*.xml", SearchOption.TopDirectoryOnly);
            foreach (string testLogFile in testLogFiles)
            {
                File.Delete(testLogFile);
            }

            //lets save log for each test
            foreach (XmlTest test in XmlLog.Tests)
            {
                using (XmlWriter xmlTestLogFile = XmlTextWriter.Create(GetXmlTestFilePath(test.Id), writerSettings))
                {
                    xmlTestLogFile.WriteProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"" + GetTemplateFileName(LogTypes.TestLog) + "\"");
                    test.ToXml(xmlTestLogFile);
                }
            }

            this._logFilesGenerated = false;

            //TODO: remove _webBrowser history
            //_webBrowser.

            RefreshLog();
        }
Esempio n. 11
0
        /// <summary>
        /// This is the method to write common exception to xml log and display in console
        /// </summary>
        /// <param name="exception">Exception</param>
        /// <param name="stepNo">Step Number</param>
        /// <param name="stepDescription">Description</param>
        /// <returns></returns>
        public static void WriteExceptionLog(KryptonException exception, int stepNo, string stepDescription)
        {
            Console.WriteLine(exception.Message);
            try
            {
                Property.InitializeStepLog();
            }
            catch (Exception ex)
            {
                KryptonException.ReportException(ex.Message + "Initializesteplog()");
            }
            Property.StepNumber      = stepNo.ToString();
            Property.StepDescription = stepDescription;
            Property.Status          = ExecutionStatus.Fail;
            Property.Remarks         = exception.Message;
            Property.ExecutionDate   = DateTime.Now.ToString(Utility.GetParameter("DateFormat"));
            Property.ExecutionTime   = DateTime.Now.ToString(Utility.GetParameter("TimeFormat"));
            try
            {
                XmlLog.WriteExecutionLog();
                XmlLog.SaveXmlLog();
            }
            catch (Exception e)
            {
                KryptonException.ReportException(e.Message + "--->" + e.StackTrace + "--->" + e.Source);
            }

            if (Utility.GetParameter("closebrowseroncompletion").ToLower().Trim().Equals("true"))
            {
                if (TestStepAction != null)
                {
                    TestStepAction.Do("closeallbrowsers");
                }
            }

            try
            {
                if (stepDescription.IndexOf("Execute Test Case", StringComparison.OrdinalIgnoreCase) < 0)
                {
                    //Execution end date and time set
                    DateTime dtNow = DateTime.Now;
                    Property.ExecutionEndDateTime = dtNow.ToString(Property.Date_Time);

                    CreateHtmlReportSteps();

                    if (Utility.GetParameter("closebrowseroncompletion").ToLower().Trim().Equals("true"))
                    {
                        if (TestStepAction != null && !Utility.GetParameter("RunRemoteExecution").Equals("true", StringComparison.OrdinalIgnoreCase))
                        {
                            TestStepAction.Do("shutdowndriver"); //shutdown driver
                        }
                    }
                }
            }
            catch (Exception ex) {
                TestEngine.Logwriter.WriteLog("Data" + ex.Data + "Stacktrace" + ex.StackTrace + "Message" + ex.Message);
            }
            //Wait for user input at the end of the execution is handled by configuration file
            if (!string.Equals(Utility.GetParameter("EndExecutionWaitRequired"), "false", StringComparison.OrdinalIgnoreCase) &&
                stepDescription.IndexOf("Execute Test Case", StringComparison.OrdinalIgnoreCase) < 0)
            {
                Console.WriteLine(ConsoleMessages.MSG_DASHED);
                Console.WriteLine(ConsoleMessages.MSG_TERMINATE_WITH_EXCEPTION);
                while (true)
                {
                    ConsoleKeyInfo inf = Console.ReadKey(true); // Key output not shown
                    if (inf.Key == ConsoleKey.Enter)
                    {
                        break;
                    }

                    Console.WriteLine("Please press [Enter]" + inf.Key);
                }
            }
            TestSuiteResult = 1;
        }
Esempio n. 12
0
 /// <summary>
 /// clears the log
 /// </summary>
 private void ClearTestRunLog()
 {
     XmlLog.ClearTestRunLog();
 }
Esempio n. 13
0
 public XmlTest()
 {
     this.Id = XmlLog.GetUniqueTestId();
 }