Ejemplo n.º 1
0
 //get all subjects from project
 private List<string> GetAllSubjects(TestApp testApp)
 {
     var subjStr =
         webClient.DownloadString(dmsUrl + "/modules/StormDb/extract/subjectswithcode?" + service.User.UniqueHash +
                                  "&projectCode=" + testApp.ProjectName);
     var lines = subjStr.Split(new[] {"\r\n", "\n"}, StringSplitOptions.None);
     return new List<string>(lines);
 }
Ejemplo n.º 2
0
        public TabControl(MainUI parent, TestApp testApp)
        {
            InitializeComponent();
            this.parent = parent;
            this.testApp = testApp;

            if (testApp is ZTree)
            {
                inited = true;

                ztreeCtrl = new ZtreeControl((ZTree) testApp);
                ztreeControls.Children.Add(ztreeCtrl);
                btnDelResults.IsEnabled = true;
                btnGetResults.IsEnabled = true;
            }
        }
Ejemplo n.º 3
0
        public void DmsTransfer(string projPath, TestApp testApp)
        {
            var subjects = new DirectoryInfo(projPath).GetDirectories();
            var zipsForUpload = new List<string>();

            //iterate through all subjects and their results
            foreach (var subject in subjects)
            {
                foreach (var timeline in subject.GetDirectories())
                {
                    foreach (var modality in timeline.GetDirectories())
                    {
                        if (modality.Name != testApp.ApplicationName)
                        {
                            continue;
                        }

                        var subjId = CreateSubject(subject.Name, testApp);
                        var appName = testApp.ApplicationName;

                        if (testApp is CustomRunTestApp)
                        {
                            appName = customRunDmsModality;
                        }
                        var dirToZip = Path.Combine(projPath, subject.Name, timeline.Name, testApp.ApplicationName);
                        var zipFileName = testApp.ProjectName + "." + subjId + "." + timeline.Name + "." + appName +
                                          ".zip";
                        var zipPath = Path.Combine(projPath, zipFileName);

                        ZipDirectory(dirToZip, zipPath);
                        zipsForUpload.Add(zipPath);
                    }
                }
            }
            bool result = false;
            UploadZips(zipsForUpload);

            foreach (var subject in subjects)
            {
                foreach (var timeline in subject.GetDirectories())
                {
                    foreach (var modality in timeline.GetDirectories())
                    {
                        if (modality.Name != testApp.ApplicationName)
                        {
                            continue;
                        }
                        if(ValidateEachResultFolder(testApp.ProjectName, timeline.Name, testApp.ApplicationName, projPath))
                        {
                            result = true;  
                        }
                        else
                        {
                            result = false;
                        }
                    }
                }
            }

            if (result == true)
            {
                service.NotifyStatus("All your files have been successful validated.");
            }
            else
            {
                service.NotifyStatus("Could't validate all the files. Check the reconciled files for errors " + Path.GetTempPath());
            }

        }
Ejemplo n.º 4
0
        //creates subject and returns subject number
        private string CreateSubject(string boothNo, TestApp testApp)
        {
            var subjId = "";
            var subjectName = "Booth" + boothNo;

            if (testApp is ZTree)
            {
                var exists = false;
                subjectName = "ztree_subject";
                var subjects = GetAllSubjects(testApp);
                foreach (var subject in subjects)
                {
                    //subject number structure: "0001_ABC"
                    if (subject.Length != 8)
                        continue;
                    var subjNoStr = subject.Remove(subject.Length - 4).TrimStart('0');

                    //ztree_subject reserved number is 1 (can be any number though)
                    if (subjNoStr == "1")
                    {
                        subjId = subject;
                        exists = true;
                        break;
                    }
                }

                if (exists)
                {
                    return subjId;
                }
            }

            //Creates subject in DMS. If successful returns new subject's id,
            //else returns a string containing "error" keyword
            var url = dmsUrl + "/modules/StormDb/extract/createsubject?subjectName=" + subjectName + "&" +
                      service.User.UniqueHash + "&projectCode=" + testApp.ProjectName;
            var result = webClient.DownloadString(url);

            //cut "\n" - new line seperators from result
            result = Regex.Replace(result, @"\n", string.Empty);
            subjId = result;
            if (subjId.Contains("error"))
                throw new Exception("Failed to create new subject for BoothNo " + boothNo);

            return subjId;
        }
Ejemplo n.º 5
0
        public void BackupDMSTransfer(string projpath, TestApp testApp)
        {
            string cs = @"Data Source=YLGW036487\SQLEXPRESS;Initial Catalog=LabRun;Persist Security Info=True;User ID=sa;Password=Test1234";

         
            using (SqlConnection con = new SqlConnection(cs))       
            {
                con.Open();
                foreach (var file in Directory.GetFiles(@projpath, ".", SearchOption.AllDirectories))
                {
                    byte[] data = File.ReadAllBytes(file);
                    string sql = "INSERT INTO Files VALUES (@Files, default)";
                    SqlCommand cmd = new SqlCommand(sql, con);
                    cmd.Parameters.Add("@Files", data);
                    cmd.ExecuteNonQuery();
                }
                con.Close();
            }
        }
Ejemplo n.º 6
0
        public void DmsTransfer(string projPath, TestApp testApp)
        {
            var subjects      = new DirectoryInfo(projPath).GetDirectories();
            var zipsForUpload = new List <string>();

            //iterate through all subjects and their results
            foreach (var subject in subjects)
            {
                foreach (var timeline in subject.GetDirectories())
                {
                    foreach (var modality in timeline.GetDirectories())
                    {
                        if (modality.Name != testApp.ApplicationName)
                        {
                            continue;
                        }

                        var subjId  = CreateSubject(subject.Name, testApp);
                        var appName = testApp.ApplicationName;

                        if (testApp is CustomRunTestApp)
                        {
                            appName = customRunDmsModality;
                        }
                        var dirToZip    = Path.Combine(projPath, subject.Name, timeline.Name, testApp.ApplicationName);
                        var zipFileName = testApp.ProjectName + "." + subjId + "." + timeline.Name + "." + appName +
                                          ".zip";
                        var zipPath = Path.Combine(projPath, zipFileName);

                        ZipDirectory(dirToZip, zipPath);
                        zipsForUpload.Add(zipPath);
                    }
                }
            }
            bool result = false;

            UploadZips(zipsForUpload);

            foreach (var subject in subjects)
            {
                foreach (var timeline in subject.GetDirectories())
                {
                    foreach (var modality in timeline.GetDirectories())
                    {
                        if (modality.Name != testApp.ApplicationName)
                        {
                            continue;
                        }
                        if (ValidateEachResultFolder(testApp.ProjectName, timeline.Name, testApp.ApplicationName, projPath))
                        {
                            result = true;
                        }
                        else
                        {
                            result = false;
                        }
                    }
                }
            }

            if (result == true)
            {
                service.NotifyStatus("All your files have been successful validated.");
            }
            else
            {
                service.NotifyStatus("Could't validate all the files. Check the reconciled files for errors " + Path.GetTempPath());
            }
        }