Beispiel #1
0
        private ISysTreeNode GetTargetNode(SubjectNode subjectNode, string folderPath)
        {
            string[]     nodes = folderPath.Split(System.Char.Parse(@"\"));
            ISysTreeNode root  = subjectNode;

            foreach (var node in nodes)
            {
                List SubNodes = root.NewList();
                bool exists   = false;

                foreach (SubjectNode sub in SubNodes)
                {
                    if (sub.Name == node)
                    {
                        exists = true;
                        continue;
                    }
                }



                if (!exists) //not exists
                {
                    root = root.AddNode(node);
                    root.Post();
                }
                else
                {
                    root = root.FindChildNode(node);
                }
            }

            return(root);
        }
Beispiel #2
0
        /// <summary>
        /// This method will download an attachment from a folder in Quality Center
        /// </summary>
        /// <param name="qcFolderLocation">Folder Location from where attachment needs to be downloaded</param>
        /// <param name="strFileName">Name of the file that needs to be downloaded from specified location.
        /// Name should be specified along with extenstion </param>
        /// <returns>Location of local (usually temp) path where file has been downloaded. Returns empty string if file could not be downloaded.</returns>
        public string DownloadAttachment(string qcFolderLocation, string strFileName)
        {
            //Connect with Quality Center
            TDConnection qctd = new TDConnection();

            qctd.InitConnectionEx(qcServer);
            qctd.ConnectProjectEx(strDomainName, strProjectName, strQCUserName, strQCUserPassword);

            if (qctd.Connected)
            {
                //Define objects that will be used to download files
                SubjectNode       otaSysTreeNode       = new SubjectNode();
                AttachmentFactory otaAttachmentFactory = new AttachmentFactory();
                TDFilter          otaAttachmentFilter  = new TDFilter();
                List            otaAttachmentList      = new List();
                ExtendedStorage attStorage             = new ExtendedStorage();

                otaSysTreeNode       = qctd.TreeManager.NodeByPath(qcFolderLocation); //Returns node object from test plan in Quality Center
                otaAttachmentFactory = otaSysTreeNode.Attachments();                  //Returns all attachments for the folder in QC
                otaAttachmentFilter  = otaAttachmentFactory.Filter();                 //Can be used to filter list of attachments
                otaAttachmentList    = otaAttachmentFilter.NewList();                 //Creates list of attached files

                //Check if there is any attachment available for the specified folder
                if (otaAttachmentList.Count > 0)
                {
                    foreach (Attachment otaAttachment in otaAttachmentList)
                    {
                        //Check if file names are same
                        if (otaAttachment.FileName.ToLower() == strFileName.ToLower())
                        {
                            attStorage         = otaAttachment.AttachmentStorage();
                            _localFileLocation = otaAttachment.DirectLink;

                            //Load method will download file to local workstation. true to used for synchronised download.
                            attStorage.Load(_localFileLocation, true);

                            //Client path refers to local path where file has been downloaded
                            _localFileLocation = attStorage.ClientPath;
                            break;
                        }
                    }
                }
            }

            //Return empty string if connection to QC was not successfull.
            else
            {
                _localFileLocation = string.Empty;
            }

            return(_localFileLocation);
        }
Beispiel #3
0
        public void ImportQC(TestScript ts)
        {
            TreeManager treeM = TdOLE.TreeManager;
            SubjectNode node  = treeM.get_NodeByPath("Subject") as SubjectNode;

            SubjectNode TargetNode = (SubjectNode)GetTargetNode(node, ts.QcFolderPath);

            TestFactory TstFac = TargetNode.TestFactory;

            List existingTests = TstFac.NewList("");

            bool exists  = false;
            Test tarTest = null;

            foreach (Test tst in existingTests)
            {
                if (tst.Name == ts.TestCaseName)
                {
                    exists  = true;
                    tarTest = tst;
                    continue;
                }
            }



            if (exists) // checkout and update
            {
                VCS vcs = tarTest.VCS;
                if (vcs.IsLocked)
                {
                    vcs.UndoCheckout(true);
                    vcs.CheckOut("-1", "Test Update " + DateTime.Now.ToString(), true);
                }
                else
                {
                    vcs.CheckOut("-1", "Test Update " + DateTime.Now.ToString(), true);
                }



                AssignValue2Test(tarTest, ts);
                vcs.CheckIn("", "");
                tarTest.Post();
            }
            else   // new creation
            {
                tarTest = TstFac.AddItem(DBNull.Value);
                AssignValue2Test(tarTest, ts);
                tarTest.Post();
            }
        }
Beispiel #4
0
        /// <summary>
        /// This method will download an attachment from a folder in Quality Center
        /// </summary>
        /// <param name="qcFolderLocation">Folder Location from where attachment needs to be downloaded</param>
        /// <param name="strFileName">Name of the file that needs to be downloaded from specified location. 
        /// Name should be specified along with extenstion </param>
        /// <returns>Location of local (usually temp) path where file has been downloaded. Returns empty string if file could not be downloaded.</returns>
        public string DownloadAttachment(string qcFolderLocation, string strFileName)
        {
            //Connect with Quality Center
            TDConnection qctd = new TDConnection();
            qctd.InitConnectionEx(qcServer);
            qctd.ConnectProjectEx(strDomainName, strProjectName, strQCUserName, strQCUserPassword);

            if (qctd.Connected)
            {
                //Define objects that will be used to download files
                SubjectNode otaSysTreeNode = new SubjectNode();
                AttachmentFactory otaAttachmentFactory = new AttachmentFactory();
                TDFilter otaAttachmentFilter = new TDFilter();
                List otaAttachmentList = new List();
                ExtendedStorage attStorage = new ExtendedStorage();

                otaSysTreeNode = qctd.TreeManager.NodeByPath(qcFolderLocation);     //Returns node object from test plan in Quality Center
                otaAttachmentFactory = otaSysTreeNode.Attachments();                //Returns all attachments for the folder in QC
                otaAttachmentFilter = otaAttachmentFactory.Filter();                //Can be used to filter list of attachments
                otaAttachmentList = otaAttachmentFilter.NewList();                  //Creates list of attached files

                //Check if there is any attachment available for the specified folder
                if (otaAttachmentList.Count > 0)
                {
                    foreach (Attachment otaAttachment in otaAttachmentList)
                    {
                        //Check if file names are same
                        if (otaAttachment.FileName.ToLower() == strFileName.ToLower())
                        {
                            attStorage = otaAttachment.AttachmentStorage();
                            _localFileLocation = otaAttachment.DirectLink;

                            //Load method will download file to local workstation. true to used for synchronised download.
                            attStorage.Load(_localFileLocation, true);

                            //Client path refers to local path where file has been downloaded
                            _localFileLocation = attStorage.ClientPath;
                            break;
                        }
                    }
                }
            }

            //Return empty string if connection to QC was not successfull.
            else
            {
                _localFileLocation = string.Empty;
            }

            return _localFileLocation;
        }
Beispiel #5
0
        //get test plan explorer(tree view)
        public static List <string> GetTestPlanExplorer(string PathNode)
        {
            TreeManager treeM = (TreeManager)mTDConn.TreeManager;

            SubjectNode   SubjRoot         = treeM.get_NodeByPath(PathNode);
            List          SubjectNodeList  = SubjRoot.NewList();
            List <string> testPlanPathList = new List <string>();

            foreach (SubjectNode oSubjectNode in SubjectNodeList)
            {
                testPlanPathList.Add(oSubjectNode.Name);
            }

            return(testPlanPathList);
        }
Beispiel #6
0
        private void PrintResult(SubjectNode node, IGraphContext service, int level)
        {
            if (node.Nodes == null)
            {
                Console.Write("".PadLeft(level, '-'));
                Console.WriteLine("Issuer: {1} trust subject {2}", level, node.NodeIndex, node.Id.ConvertToHex());
                return;
            }

            foreach (var child in node.Nodes)
            {
                Console.Write("".PadLeft(level, '-'));
                Console.WriteLine("Issuer: {1} trust subject {2}", level, node.NodeIndex, child.NodeIndex);

                PrintResult(child, service, level + 1);
            }
        }
        TrigEvent(GameObject other)
        {
            if (TrigTags.Contains(other.tag))
            {
                OtherNode = Utils.GetBottomLevelArenaNodeInGameObject(other);
                ThisNode  = Utils.GetBottomLevelArenaNodeInGameObject(gameObject);

                ArenaNode SubjectNode;
                if (SubjectType == SubjectTypes.This)
                {
                    SubjectNode = ThisNode;
                }
                else
                {
                    SubjectNode = OtherNode;
                }

                if (SubjectNode == null)
                {
                    return;
                }

                if (IsMatchNodeCoordinate)
                {
                    if ((ThisNode == null) || (OtherNode == null))
                    {
                        return;
                    }
                    else
                    {
                        List <int> ThisNodeCoordinate  = ThisNode.GetCoordinate_ParentToChild();
                        List <int> OtherNodeCoordinate = OtherNode.GetCoordinate_ParentToChild();
                        if (!Utils.IsListEqual(ThisNodeCoordinate, OtherNodeCoordinate,
                                               Mathf.Min(ThisNodeCoordinate.Count, OtherNodeCoordinate.Count)))
                        {
                            return;
                        }
                    }
                }

                if (IsKill)
                {
                    BeforeTrigKill();
                    SubjectNode.Kill();
                }

                foreach (string Attribute_ in IncrementAttributes.Keys)
                {
                    if (float.Parse(IncrementAttributes[Attribute_]) != 0f)
                    {
                        float Scale_ = 1f;
                        if (CompareTag("Eatable"))
                        {
                            Scale_ = transform.localScale.y;
                        }
                        SubjectNode.IncrementAttribute(Attribute_,
                                                       float.Parse(IncrementAttributes[Attribute_]) * Scale_);
                    }
                }

                if (IsCarried)
                {
                    ToFollow         = other;
                    RelativePosition = transform.position - ToFollow.transform.position;
                }
            }
        } // TrigEvent
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public bool ResetProcess()
        {
            bool blnResult = false;

            ProcessFactory = null;
            ProcessFolder = FindFolder(Framework.ActiveProcess.QCTestPlan);

            if (ProcessFolder != null)
            {
                try
                {
                    ProcessFactory = (TestFactory)ProcessFolder.TestFactory;
                }
                catch (Exception ex)
                {
                    Message = "Could not set Process Factory '" + Framework.ActiveProcess.QCTestPlan + "' in ALM.\n" + ex.Message;
                }

                if (ProcessFactory != null)
                {
                    ProcessList = ProcessFactory.NewList("");
                    ProcessIndex = 1;
                    ProcessMax = ProcessList.Count;

                    blnResult = true;
                }
            }
            else
            {
                Message = "Cannot find Process folder '" + Framework.ActiveProcess.QCTestPlan + "' in ALM Testplan'";
            }

            return blnResult;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public bool ReadProject()
        {
            bool blnResult = false;

            ProjectFactory = null;
            ProjectFolder = null;
            ProjectList = null;

            ProjectFolder = FindFolder(Framework.ActiveApplication.QCTestPlan);

            if (ProjectFolder != null)
            {
                ProjectFactory = (TestFactory)ProjectFolder.TestFactory;

                if (ProjectFactory != null)
                {
                    TDFilter filter = (TDFilter)ProjectFactory.Filter;
                    filter["TS_NAME"] = "Process_template";
                    ProjectList = ProjectFactory.NewList(filter.Text);

                    if (ProjectList.Count >= 1)
                    {
                        foreach (object item in ProjectList)
                        {
                            if (item is Test)
                            {
                                ProcessTemplate = item as Test;
                                blnResult = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        Message = "Cannnot find Process_Template in '" + Framework.ActiveProcess.QCTestPlan + "' in ALM Testplan.";
                    }
                }
                else
                {
                    Message = "Cannot determine project factory '" + Framework.ActiveProcess.QCTestPlan + "'.";
                }
            }
            else
            {
                Message = "Cannot find Project folder '" + Framework.ActiveProcess.QCTestPlan + "' in ALM Testplan.'";
            }

            return blnResult;
        }
Beispiel #10
0
        public List <SubjectNode> BuildResultNode(QueryContext context)
        {
            var results      = new List <SubjectNode>();
            var nodelist     = new Dictionary <Int64Container, SubjectNode>();
            var subjectNodes = new List <SubjectNode>();

            foreach (var item in context.Results)
            {
                var tn = new SubjectNode();
                tn.NodeIndex   = item.Edge.SubjectId;
                tn.ParentIndex = item.NodeIndex;
                var visited = context.Visited[item.NodeIndex];

                tn.EdgeIndex = new Int64Container(item.NodeIndex, visited.EdgeIndex);
                GraphService.InitSubjectModel(tn, item.Edge);

                subjectNodes.Add(tn);
            }

            while (results.Count == 0)
            {
                var currentLevelNodes = new List <SubjectNode>();
                foreach (var subject in subjectNodes)
                {
                    var parentNode = new SubjectNode();
                    parentNode.NodeIndex = subject.ParentIndex;

                    var visited = context.Visited[subject.NodeIndex];
                    parentNode.ParentIndex = context.Visited[subject.ParentIndex].ParentIndex;
                    parentNode.EdgeIndex   = new Int64Container(parentNode.NodeIndex, visited.EdgeIndex);

                    if (nodelist.ContainsKey(parentNode.EdgeIndex))
                    {
                        // A previouse node in the collection has already created this
                        nodelist[parentNode.EdgeIndex].Nodes.Add(subject);
                        continue;
                    }

                    var address = GraphService.Graph.Address[parentNode.NodeIndex];
                    parentNode.Id = address.Id;

                    if (visited.EdgeIndex >= 0)
                    {
                        var edge = address.Edges[visited.EdgeIndex];
                        GraphService.InitSubjectModel(parentNode, edge);
                    }
                    parentNode.Nodes = new List <SubjectNode>();
                    parentNode.Nodes.Add(subject);

                    currentLevelNodes.Add(parentNode);
                    nodelist.Add(parentNode.EdgeIndex, parentNode);

                    if (context.IssuerIndex.Contains(parentNode.NodeIndex))
                    {
                        results.Add(parentNode);
                        continue;
                    }
                }
                subjectNodes = currentLevelNodes;
            }

            return(results);
        }