示例#1
0
        public void WriteLineTesterTestSequenceDetailsToJSon(TestFixtureLineTesterConfigModel lightTesterModel)
        {
            string jsonstring = JsonConvert.SerializeObject(lightTesterModel);
            string json_lineTester_file_path = TestFixtureConstants.GetLineTesterSettingsFilePath();

            System.IO.File.WriteAllText(json_lineTester_file_path, jsonstring);
        }
示例#2
0
        public void WriteImgDetailsToJSon(TestFixtureProjectorImageModel aImgModel)
        {
            string jsonstring = JsonConvert.SerializeObject(aImgModel);
            string json_settingdata_file_path = TestFixtureConstants.ReadSaveImageSettingDetails();

            System.IO.File.WriteAllText(json_settingdata_file_path, jsonstring);
        }
示例#3
0
        public void WriteEolTestSequenceDetailsToJSon(TestFixtureEolTestSequenceModel eolModel)
        {
            string jsonstring         = JsonConvert.SerializeObject(eolModel);
            string json_eol_file_path = TestFixtureConstants.GetEolSequenceFilePath();

            System.IO.File.WriteAllText(json_eol_file_path, jsonstring);
        }
        public static bool fileUpload()
        {
            try
            {
                string imageDir   = TestFixtureConstants.getImageUploadDirPath();
                int    i          = 0;
                string ipaddr     = GetServerIpAddress();
                string portnumber = ":8080";
                ipaddr = "http://" + ipaddr + portnumber;
                string addiparams = "/media/image/";
                ipaddr = ipaddr + addiparams;
                string[] fileArray = Directory.GetFileSystemEntries(imageDir);
                //try
                //{
                for (i = 0; i < fileArray.Length; i++)
                {
                    //create WebClient object
                    WebClient client = new WebClient();
                    client.Proxy       = null;
                    client.Credentials = CredentialCache.DefaultCredentials;
                    //client.UploadFile(ipaddr, "POST", fileArray[i]);
                    client.UploadFile(ipaddr, "POST", @"C:\Builds\TestFixtureProject\TestFixtureProject\bin\Debug\Images\ImageShow\White--Dot.png");
                    client.Dispose();
                }
            }
            catch (Exception err)
            {
                frmTestFixture.Instance.WriteToLog(err.Message, ApplicationConstants.TraceLogType.Error);
                return(false);
            }

            return(true);
        }
示例#5
0
        public void WriteSettingDataIntoJSon(TestFixtureSettingModel modelObject)
        {
            string jsonstring = JsonConvert.SerializeObject(modelObject);
            string json_settingdata_file_path = TestFixtureConstants.GetSettingsInfoFilePath();

            System.IO.File.WriteAllText(json_settingdata_file_path, jsonstring);
        }
示例#6
0
        private void LoadSettingDetailsFromFile()
        {
            string file_path = TestFixtureConstants.GetEolSequenceFilePath();

            if (!string.IsNullOrEmpty(file_path) && (File.Exists(file_path)))
            {
                DeserializeAndSetProperties(file_path);
            }
        }
示例#7
0
        public void LoadSettingDetailsFromFile()
        {
            string file_path = TestFixtureConstants.ReadSaveImageSettingDetails();

            if (!string.IsNullOrEmpty(file_path) && (File.Exists(file_path)))
            {
                DeserializeAndSetProperties(file_path);
            }
        }
        public string GetTestSequnceName()
        {
            JObject passobject;

            string testsequencefile = TestFixtureConstants.GetTestSequenceFromJson();

            using (StreamReader file = File.OpenText(testsequencefile))
                using (JsonTextReader reader = new JsonTextReader(file))
                {
                    passobject = (JObject)JToken.ReadFrom(reader);
                }
            JToken tokenvalue = passobject.First;
            string seqname    = tokenvalue.First.ToString();

            return(seqname);
        }
        internal void ValidateToNavigate(Object p)
        {
            if (LoginPassword == null)
            {
                PasswordIncorrect = true;
                return;
            }

            //  string pass = LoginPassword.ToString();
            // int ret_val= pass.CompareTo("PASS");

            //should check the  password with the json file
            JObject passobject;
            JObject passobj;
            string  loginFileName = TestFixtureConstants.GetLoginInfoFilePath();

            using (StreamReader file = File.OpenText(loginFileName))
                using (JsonTextReader reader = new JsonTextReader(file))
                {
                    passobject = (JObject)JToken.ReadFrom(reader);
                }
            //JToken rootname = passobject.Root;
            //JToken lastelename = passobject.Last;

            //string rtname = rootname.First.ToString();
            //string ltname = lastelename.Last.ToString();

            JToken tokenvalue = passobject.First;
            string value      = tokenvalue.First.ToString();

            JToken jvalue    = passobject.Last;
            string lastvalue = jvalue.Last.ToString();


            _password = new SecureString();
            foreach (char c in value)
            {
                _password.AppendChar(c);
            }

            if (SecureStringEqual(LoginPassword, _password))
            {
                AccessGranted = true;
            }
            else if (!AccessGranted)
            {
                if (SelectedIndex >= 1 && SelectedIndex <= 2)
                {
                    _password = new SecureString();
                    foreach (char c in lastvalue)
                    {
                        _password.AppendChar(c);
                    }
                    if (SecureStringEqual(LoginPassword, _password))
                    {
                        PartialAccessGranted = true;
                    }
                }
                else if (SelectedIndex >= 3 && SelectedIndex <= 4)
                {
                    PasswordIncorrect = true;
                }
            }
            else
            {
                PasswordIncorrect = true;
            }
        }
示例#10
0
 public TestFixtureProjectorModel(bool canAccessallPages)
 {
     _mfolderPath = TestFixtureConstants.CreateDirectoryIfNotExists("Images");
 }
        public static bool DeleteUploadedFile(string fileType)
        {
            string[] allDir       = null;
            string   imageDir     = null;
            string   bandwidthDir = null;
            int      i            = 0;

            string[] fileNames  = null;
            string   ipaddr     = null;
            string   portnumber = null;
            string   addiparams;

            if (fileType.Equals("image"))
            {
                imageDir  = TestFixtureConstants.getImageUploadDirPath();
                fileNames = GetFileNames(imageDir);
                i         = 0;
                for (i = 0; i < fileNames.Length; i++)
                {
                    WebRequest request = null;
                    HttpClient client  = null;

                    HttpWebResponse response = null;
                    ipaddr     = GetServerIpAddress();
                    portnumber = ":8080";
                    ipaddr     = "http://" + ipaddr + portnumber;
                    addiparams = "/media/image";
                    ipaddr     = ipaddr + addiparams;
                    try
                    {
                        //client.DeleteAsync("");
                        request = WebRequest.Create(ipaddr + "/" + fileNames[i]);
                        //request.ContentType = @"application/x-www-form-urlencoded";
                        request.Method = @"DELETE";
                        response       = (HttpWebResponse)request.GetResponse();
                    }
                    catch (Exception err)
                    {
                        // if(err.)
                        return(true);
                    }
                }
                return(true);
            }
            else if (fileType.Equals("bandwidth"))
            {
                bandwidthDir = TestFixtureConstants.getBandwidthUploadDirPath();
                fileNames    = GetFileNames(bandwidthDir);
                i            = 0;
                for (i = 0; i < fileNames.Length; i++)
                {
                    ipaddr     = GetServerIpAddress();
                    portnumber = ":8080";
                    ipaddr     = "http://" + ipaddr + portnumber;
                    addiparams = "/media/update";
                    ipaddr     = ipaddr + addiparams;
                    try
                    {
                        WebRequest request = WebRequest.Create(ipaddr + "/" + fileNames[i]);
                        request.ContentType = @"application/x-www-form-urlencoded";
                        request.Method      = @"DELETE";

                        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                    }
                    catch (Exception err)
                    {
                        return(false);
                    }
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public static double[] checkBandwidth()
        {
            double[] data = null;
            _numberOfRetry = 0;
            while (_numberOfRetry <= 3)
            {
                data    = new double[2];
                data[0] = 0;
                data[1] = 0;
                string bandwidthDir = TestFixtureConstants.getBandwidthUploadDirPath();
                //string[] fileNames = GetFileNames(bandwidthDir);
                int    i          = 0;
                string ipaddr     = GetServerIpAddress();
                string portnumber = ":8080";
                ipaddr = "http://" + ipaddr + portnumber;
                string addiparams = "/media/update/";
                ipaddr = ipaddr + addiparams;
                double    bw     = 0;
                WebClient client = new WebClient();


                string[] fileArray = Directory.GetFileSystemEntries(bandwidthDir);

                try
                {
                    for (i = 0; i < fileArray.Length; i++)
                    {
                        client.Credentials = CredentialCache.DefaultCredentials;
                        //client.Encoding = Encoding.UTF8;
                        //request.ContentType = @"application/x-www-form-urlencoded";
                        // client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
                        //client.Headers.Add();
                        //MessageBox.Show(DateTime.Now.ToShortTimeString().ToString());
                        DateTime start = DateTime.Now;
                        client.UploadFile(ipaddr, @"POST", fileArray[i]);

                        DateTime end      = DateTime.Now;
                        TimeSpan timeDiff = end - start;
                        //MessageBox.Show (timeDiff.TotalMilliseconds.ToString());
                        bw             = (fileArray[i].Length * 8) / (timeDiff.TotalSeconds * 1000);
                        data[0]        = timeDiff.TotalSeconds;
                        data[1]        = bw;
                        _isOuterloop   = true;
                        _isInnerloop   = true;
                        _numberOfRetry = 4;
                        _retvalue      = true;
                        client.Dispose();
                    }
                }
                catch (Exception e)
                {
                    Thread.Sleep(1500);
                    string msg = e.ToString();
                    _isOuterloop = false;
                    _isInnerloop = false;
                    _numberOfRetry++;
                    if (_numberOfRetry > 3)
                    {
                        _isOuterloop = true;
                        _isInnerloop = true;
                        _retvalue    = false;
                    }
                    _mexceptionMessage = e.Message.ToString();
                }
            }

            return(data);
        }
示例#13
0
 public TestFixtureProjectorImageModel()
 {
     LoadSettingDetailsFromFile();
     _mfolderPath = TestFixtureConstants.CreateDirectoryIfNotExists("Images");
     //LoadConvertedImages();
 }