WriteWhitespace() public method

Writes the given white space.
public WriteWhitespace ( string ws ) : void
ws string The string of white space characters.
return void
示例#1
0
        /// <summary>
        /// Writes this token to a <see cref="JsonWriter"/>.
        /// </summary>
        /// <param name="writer">A <see cref="JsonWriter"/> into which this method will write.</param>
        /// <param name="converters">A collection of <see cref="JsonConverter"/> which will be used when writing the token.</param>
        public override void WriteTo(JsonWriter writer, params JsonConverter[] converters) {
            writer.WriteStartObject();
            if (this.WithComment) {
                var lPath = writer.Path;
                var lState = writer.WriteState;
                StringBuilder lComments = new StringBuilder();
                int lLevel = (lPath.Split('.').Length + 1) * 2;
                if (lPath == "") lLevel = 2;
                writer.WriteWhitespace("\r\n");
                for (int lCount = 0; lCount < mComment.Count; lCount++) {
                    if (lLevel > 0) writer.WriteWhitespace(new string(' ', lLevel));
                    writer.WriteRaw("//" + mComment[lCount]);
                    if (lCount + 1 < mComment.Count) writer.WriteWhitespace("\r\n");
                }
            }
            var _properties = base.Properties();
            foreach (var lProperty in _properties) {
                lProperty.WriteTo(writer, converters);
            }
            writer.WriteEndObject();


            //base.WriteTo(writer, converters);
        }
 public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
 {
     //if (value is hAxis)
     //{
     //    writer.WritePropertyName("hAxis");
     //}
     //else if (value is vAxis)
     //{
     //     writer.WritePropertyName("hAxis");
     //}
     writer.WriteWhitespace(" ");
     string json = ((Axis)value).ToString();
     writer.WriteRawValue(json);
 }
示例#3
0
        private List<TestResult> GetTestResultFromOpsDB(SqlCommand command, JsonWriter serializer, DateTime dateToDump)
        {
            var compName = Environment.GetEnvironmentVariable("COMPUTERNAME") ?? "";
            var envName = Environment.GetEnvironmentVariable("AS_ENV") ?? "";
            var startTime = Formator.FormatDateTime(dateToDump.AddMinutes(-ConfigUtil.JobDumpIntervalMinute));
            var endTime = Formator.FormatDateTime(dateToDump);

            ALogger.LogInfo("GetTestResultFromOpsDB: Start {0} to {1} - Input {2}", startTime, endTime, dateToDump.ToString("yyyy-MM-dd HH:mm:ss"));

            if (command == null || serializer == null)
            {
                ALogger.LogError("Not allowed to pass null to this method");
                throw new NoNullAllowedException("Not allowed to pass null to this method");
            }

            var limit = "";

            if (_recordLimit != null && _recordLimit > 0)
            {
                limit = " TOP " + _recordLimit + " ";
            }

            command.CommandTimeout = ConfigUtil.DBQueryTimeout;
            command.CommandText = string.Format(
                //"WAITFOR DELAY '000:01:10';" +
                "SELECT " + limit + " m.UUID as 'uuid', " +
                    "'SystemTestApp' AS 'capb.name', " +
                    "'1.0' AS 'capb.version', " +
                    "'" + compName + "' AS 'capb.server', " +                    
                    //"*** '62' **** AS 'prod.name',  " +
                    //"*** '127EIKON' ***** AS 'prod.vers', " +
                    "'RST' AS 'prod.component.name', " +
                    //"*** '127ST' **** AS 'prod.component.vers',  " +
                    //"'' AS 'testID', => null" +
                    "m.UUID AS 'userProfile.uuid', " +
                    /* UserProfileAccountDomain => null*/
                    // "*** 61 **** AS 'userProfile.userName',  " +
                    //"*** UIS **** AS 'userProfile.email', " +
                    //UserProfileContactName = (string)record["userProfile.contactName"],
                    //UserProfileLocation = (string)record["userProfile.location"],
                    //UserProfileCID = (string)record["userProfile.CID"],
                    //"*** UIS **** AS 'userProfile.geoCountry', " +
                    "'SystemTestApp' AS 'server.name', " +
                    "'1.0' AS 'server.version', " +
                    "'" + compName + "' AS 'server.compName', " +
                    "'" + envName + "' AS 'server.dataCenter', " +
                    "s.LastSeen AS 'server.wasDateTime', " +
                    "s.LastSeen AS 'server.dbsDateTime', " +
                    "'RST' AS 'client.name', " +
                    //"*** '127ST' ****  AS 'client.version', " +
                    "m.MachineGUID AS 'machineID', " +
                    "'' AS 'runningMode', " +
                    //"*** 73 **** AS 'localDateTime', " +
                   
                    "s.StatCode AS 'testcase.id', " +
                    "'' AS 'testcase.group', " +
                    "'' AS 'testcase.title', " +
                    "'' AS 'testcase.valid', " +
                    "s.StatValue AS 'testcase.value', " +
                    "'' AS 'testcase.description', " +
                    "'' AS 'testcase.rphURL', " +
                    "'' AS 'testcase.resultID', " +
                    "'' AS 'testcase.recommendation' " +

                "FROM UserStats s LEFT JOIN UserMachineInstallations m " +
                "ON (s.UserMachineInstallationID = m.UserMachineInstallationID) " +
                "WHERE m.Product = 'est' " +
                    "AND s.LastSeen >= convert(datetime, '" + startTime + "') " +
                    "AND s.LastSeen <= convert(datetime, '" + endTime + "') "
                );

            var numberOfTestID = 0;
            List<TestResult> testResult = null;
            using (var dataReader = command.ExecuteReader())
            {
                var previousTestReferenceID = new DateTime(0);

                while (dataReader.Read())
                {
                    var record = dataReader as IDataRecord;
                    var timeStamp = (DateTime)record["server.dbsDateTime"];
                    if (timeStamp != previousTestReferenceID)
                    {                        
                        if (testResult == null)
                        {
                            testResult = new List<TestResult>();
                        }
                        var userDetails = UserInfo.GetUserDetails((string) record["uuid"]);
                        testResult.Add(new TestResult
                        {
                            UUID = (string)record["uuid"],
                            CapbName = (string)record["capb.name"],
                            CapbVers = (string)record["capb.version"],
                            CapbServer = (string)record["capb.server"],
                            //ProdName = (string)record["prod.name"], //  62
                            //ProdVers = (string)record["prod.vers"], // 127EIKON
                            ProdComponentName = (string)record["prod.component.name"],
                            //ProdComponentVers = (string)record["prod.component.vers"], // 127ST
                            //TestID = Convert.ToInt32(record["testID"]), null
                            UserProfileUUID = (string)record["userProfile.uuid"],
                            //UserProfileAccountDomain = (string)record["userProfile.accountDomain"],  null
                            UserProfileUserName = (userDetails != null) ? userDetails.UserID : "",// UIS
                            UserProfileEmail = (userDetails != null) ? userDetails.Email : "", // UIS
                            //UserProfileContactName = (string)record["userProfile.contactName"], => null
                            //UserProfileLocation = (string)record["userProfile.location"], => null
                            //UserProfileCID = (string)record["userProfile.CID"], => null
                            UserProfileGeoCountry = (userDetails != null) ? userDetails.Country : "", // UIS
                            ServerName = (string)record["server.name"],
                            ServerVersion = (string)record["server.version"],
                            ServerCompName = (string)record["server.compName"],
                            ServerDatacenter = (string)record["server.dataCenter"],
                            ServerWasDateTime = (DateTime)record["server.wasDateTime"],
                            ServerDbsDateTime = (DateTime)record["server.dbsDateTime"],
                            ClientName = (string)record["client.name"],
                            //ClientVersion = (string)record["client.version"], // 127ST
                            MachineID = record["machineID"].ToString(),
                            RunningMode = (string)record["runningMode"], // blank
                            //LocalDateTime = (DateTime)record["localDateTime"], // 73
                            TestCases = new List<TestCase>()
                        });

                        previousTestReferenceID = timeStamp;
                        numberOfTestID++;
                    }

                    var statCode = DataMapper.MapStatCode((string)record["testcase.id"]);
                    var statValue = (string)record["testcase.value"];
                    testResult[numberOfTestID - 1].TestCases.Add(
                        new TestCase
                        {
                            ID = statCode,
                            Title = (string)record["testcase.title"], // blank
                            Group = (string)record["testcase.group"], // blank
                            Valid = (string)record["testcase.valid"], // blank
                            Value = statValue,
                            Description = (string)record["testcase.description"], // blank
                            Recommendation = (string)record["testcase.recommendation"], // blank
                            RphURL = (string)record["testcase.rphURL"], // blank
                            ResultID = (string)record["testcase.resultID"] // blank
                        }
                    );

                    switch (statCode)
                    {
                        case "62":
                            testResult[numberOfTestID - 1].ProdName = statValue;
                            break;
                        case "127EIKON":
                            testResult[numberOfTestID - 1].ProdVers = statValue;
                            break;
                        case "127ST":
                            testResult[numberOfTestID - 1].ProdComponentVers = statValue;
                            testResult[numberOfTestID - 1].ClientVersion = statValue;                            
                            break;
                        case "27": // timezone                            
                            testResult[numberOfTestID - 1].LocalDateTime = GetLocalTestTime(testResult[numberOfTestID - 1].ServerWasDateTime, statValue);
                            break;
                        /*case "73": // local time
                            
                            break;*/
                    }
                }

                if (numberOfTestID == 0)
                {
                    ALogger.LogWarn("DataDumper.GetTestResultFromOpsDB(): no any test data in specific peroid [{0} until {1}]", startTime, endTime);
                    return testResult;
                }
                    
                for (var i = 0; i < numberOfTestID; i++)
                {
                    var json = JsonConvert.SerializeObject(testResult[i]);
                    serializer.WriteStartObject();
                    serializer.WriteRaw(json);
                    serializer.WriteEndObject();
                    serializer.WriteWhitespace(Environment.NewLine);
                }
            }

            return testResult;
        }                
示例#4
0
        private List<TestResult> GetTestResultFromSTDB(SqlCommand command, JsonWriter serializer, DateTime dateToDump)
        {
            var startTime = Formator.FormatDateTime(dateToDump.AddMinutes(-ConfigUtil.JobDumpIntervalMinute));
            var endTime = Formator.FormatDateTime(dateToDump);

            ALogger.LogInfo("GetTestResultFromSTDB: Start {0} to {1} - Input {2}", startTime, endTime, dateToDump.ToString("yyyy-MM-dd HH:mm:ss"));

            if (command == null || serializer == null)
            {
                ALogger.LogError("Not allowed to pass null to this method");
                throw new NoNullAllowedException("Not allowed to pass null to this method");
            }

            var limit = "";

            if (_recordLimit != null && _recordLimit > 0)
            {
                limit = " TOP " + _recordLimit + " ";
            }

            command.CommandTimeout = ConfigUtil.DBQueryTimeout;
            command.CommandText = string.Format(
                //"WAITFOR DELAY '000:01:10';" +
                "SELECT "+ limit +" US.userID AS 'uuid', " +
                    "SE.serverName AS 'capb.name'," +
                    "SE.serverVersion AS 'capb.version', " +
                    "SE.serverCompName AS 'capb.server', " +
                    "(select case when PD.productName is null then '' else PD.productName end) AS 'prod.name', " +
                    "(select case when PD.productVersion is null then '' else PD.productVersion end) AS 'prod.vers', " +
                    "'RST' AS 'prod.component.name', " +
                    "((select case when CL.clientName is null then '' else CL.clientName end) + ' ' + (select case when " +
                    "CL.clientVersion is null then '' else CL.clientVersion end)) AS 'prod.component.vers',  " +
                    "CONVERT(varchar(10),TR.testID) AS 'testID', " +
                    "US.userID AS 'userProfile.uuid', " +
                    "(select case when US.userName is null then '' else US.userName end) AS 'userProfile.userName', " +
                    "(select case when US.userName is null then '' else US.userName end) AS 'userProfile.email', " +
                    "(select case when GL.geoCountry is null then '' else GL.geoCountry end) AS 'userProfile.geoCountry', " +
                    "SE.serverName AS 'server.name', " +
                    "SE.serverVersion AS 'server.version', " +
                    "SE.serverCompName AS 'server.compName', " +
                    "DC.dcSite AS 'server.dataCenter', " +
                    "'RST' AS 'client.name', " +
                    "((select case when CL.clientName is null then '' else CL.clientName end) + ' ' + (select case when CL.clientVersion is null then '' else CL.clientVersion end)) AS 'client.version',  " +
                    "(select case when CL.machineID is null then '' else CL.machineID end) AS 'machineID', " +
                    "(select case when RU.runMOdeKey is null then '' else RU.runMOdeDesc end) AS 'runningMode'," +
                    "(select case when TR.localDateTime is null then '' else TR.localDateTime end) AS 'localDateTime', " +
                    "(select case when TR.wasDateTime is null then '' else TR.wasDateTime end) AS 'server.wasDateTime', " +
                    "(select case when TR.dbsDateTime is null then '' else TR.dbsDateTime end) AS 'server.dbsDateTime', " +
                    "(select case when RU.runModeKey is null then '' else RU.runModeDesc end) AS 'runningMode', " +

                    "TC.testCaseID AS 'testcase.id', " +
                    "isnull(TG.testGroupID,'') AS 'testcase.group', " +
                    "isnull(TC.testCaseName,'') AS 'testcase.title', " +
                    "isnull(VL.validDesc,'') AS 'testcase.valid', " +
                    "isnull(TCS.tcValue,'') AS 'testcase.value', " +
                    "(select case when isnull(TCS.tcDesc,'') = '-' then TCS.tcValue else isnull(TCS.tcDesc,'') end) AS 'testcase.description', " +
                    "isnull(TC.rphURL,'') AS 'testcase.rphURL', " +
                    "isnull(TCS.resultID,'') AS 'testcase.resultID', " +
                    "isnull(TCS.tcRecom,'') AS 'testcase.recommendation' " +

                "FROM	master_dataCenter DC, " +
                    "rstTestResult TR, " +
                    "master_user US, " +
                    "master_geoLocation GL, " +
                    "master_product PD, " +
                    "master_client CL, " +
                    "master_runMode RU, " +
                    "master_server SE, " +
                    "rstTestCases TCS, " +
                    "master_testGroup TG, " +
                    "master_testCase TC, " +
                    "master_valid VL " +
                "WHERE TR.dcKey = DC.dcKey " +
                    "AND TR.userKey = US.userKey " +
                    "AND TR.geoLocationKey = GL.geoLocationKey " +
                    "AND TR.productKey = PD.productKey " +
                    "AND TR.clientKey = CL.clientKey " +
                    "AND TR.runMOdeKey = RU.runMOdeKey " +
                    "AND TR.serverKey = SE.serverKey " +
                    "AND TR.testKey          = TCS.testKey " +
                    "AND TCS.validKey     = VL.validKey " +
                    "AND TCS.testGroupKey = TG.testGroupKey " +
                    "AND TCS.testCaseKey     = TC.testCaseKey " +
                    "AND TR.dbsDateTime >= convert(datetime, '" + startTime + "') " +
                    "AND TR.dbsDateTime <= convert(datetime, '" + endTime + "') " +
                    "ORDER BY TR.testID,testCaseOrd,testCaseName "
                );

            int numberOfTestID = 0;
            List<TestResult> testResult = null;
            using (var dataReader = command.ExecuteReader())
            {
                var previousTestReferenceID = string.Empty;
                
                while (dataReader.Read())
                {
                    var record = dataReader as IDataRecord;
                    var testID = (string)record["testID"];

                    if (testID != previousTestReferenceID)
                    {
                        if (testResult == null)
                        {
                            testResult = new List<TestResult>();
                        }

                        testResult.Add(new TestResult
                        {
                            UUID = (string)record["uuid"],
                            CapbName = (string)record["capb.name"],
                            CapbVers = (string)record["capb.version"],
                            CapbServer = (string)record["capb.server"],
                            ProdName = (string)record["prod.name"],
                            ProdVers = (string)record["prod.vers"],
                            ProdComponentName = (string)record["prod.component.name"],
                            ProdComponentVers = (string)record["prod.component.vers"],
                            TestID = Convert.ToInt32(record["testID"]),
                            UserProfileUUID = (string)record["userProfile.uuid"],
                            //UserProfileAccountDomain = (string)record["userProfile.accountDomain"],
                            UserProfileUserName = (string)record["userProfile.userName"],
                            UserProfileEmail = (string)record["userProfile.email"],
                            //UserProfileContactName = (string)record["userProfile.contactName"],
                            //UserProfileLocation = (string)record["userProfile.location"],
                            //UserProfileCID = (string)record["userProfile.CID"],
                            UserProfileGeoCountry = (string)record["userProfile.geoCountry"],
                            ServerName = (string)record["server.name"],
                            ServerVersion = (string)record["server.version"],
                            ServerCompName = (string)record["server.compName"],
                            ServerDatacenter = (string)record["server.dataCenter"],
                            ServerWasDateTime = (DateTime)record["server.wasDateTime"],
                            ServerDbsDateTime = (DateTime)record["server.dbsDateTime"],
                            ClientName = (string)record["client.name"],
                            ClientVersion = (string)record["client.version"],
                            MachineID = (string)record["machineID"],
                            RunningMode = (string)record["runningMode"],
                            LocalDateTime = (DateTime)record["localDateTime"],
                            TestCases = new List<TestCase>()
                        });

                        previousTestReferenceID = testID;
                        numberOfTestID++;
                    }

                    testResult[numberOfTestID - 1].TestCases.Add(
                        new TestCase
                        {
                            ID = (string) record["testcase.id"],
                            Title = (string) record["testcase.title"],
                            Group = (string) record["testcase.group"],
                            Valid = (string) record["testcase.valid"],
                            Value = (string) record["testcase.value"],
                            Description = (string) record["testcase.description"],
                            Recommendation = (string) record["testcase.recommendation"],
                            RphURL = (string) record["testcase.rphURL"],
                            ResultID = (string) record["testcase.resultID"]
                        }
                    );
                }

                if (numberOfTestID != 0)
                {
                    for (var i = 0; i < numberOfTestID; i++)
                    {
                        var json = JsonConvert.SerializeObject(testResult[i]); 
                        serializer.WriteStartObject();
                        serializer.WriteRaw(json);
                        serializer.WriteEndObject();
                        serializer.WriteWhitespace(Environment.NewLine);
                    }
                }
            }

            return testResult;
        }