/// <summary>
        /// retrieves the run logs for the test when the steps are not reported to Qc (like in ST)
        /// </summary>
        /// <param name="currentTest"></param>
        /// <returns>the test run log</returns>
        private string GetTestRunLog(ITSTest currentTest)
        {
            string TestLog = "log\\vtd_user.log";

            IRun   lastrun = currentTest.LastRun as IRun;
            string retVal  = "";

            if (lastrun != null)
            {
                try
                {
                    IExtendedStorage storage = lastrun.ExtendedStorage as IExtendedStorage;

                    List   list;
                    bool   wasFatalError;
                    var    path    = storage.LoadEx(TestLog, true, out list, out wasFatalError);
                    string logPath = Path.Combine(path, TestLog);

                    if (File.Exists(logPath))
                    {
                        retVal = File.ReadAllText(logPath).TrimEnd();
                    }
                }
                catch
                {
                    retVal = "";
                }
            }
            retVal = ConsoleWriter.FilterXmlProblematicChars(retVal);
            return(retVal);
        }
Beispiel #2
0
        private static void ExportRequirements()
        {
            string server_url = ConfigurationManager.AppSettings["SERVER_URL"];
            string username   = ConfigurationManager.AppSettings["USER_NAME"];
            string password   = ConfigurationManager.AppSettings["PASSWORD"];
            string domain     = ConfigurationManager.AppSettings["DOMAIN"];
            string project    = ConfigurationManager.AppSettings["PROJECT"];

            string req_file = ConfigurationManager.AppSettings["REQUIREMENTS_FILE"];
            string att_file = ConfigurationManager.AppSettings["ATTACHMENTS_FILE"];
            string att_path = ConfigurationManager.AppSettings["ATTACHMENTS_PATH"];

            if (!Directory.Exists(att_path))
            {
                Directory.CreateDirectory(att_path);
            }

            TDConnection tdc = new TDConnection();

            tdc.InitConnectionEx(server_url);
            tdc.ConnectProjectEx(domain, project, username, password);

            Console.WriteLine("Connected to QC Server");

            ReqFactory req_factory = (ReqFactory)tdc.ReqFactory;
            TDFilter   req_filter  = (TDFilter)req_factory.Filter;


            /**
             *  Set your own filters for requirements below
             */

            // req_filter["RQ_REQ_PATH"] = "AAAAAGAAE*";


            StreamWriter rfs = new StreamWriter(File.Open(req_file, FileMode.Create),
                                                Encoding.Default,
                                                1024);

            StreamWriter afs = new StreamWriter(File.Open(att_file, FileMode.Create),
                                                Encoding.Default,
                                                1024);

            foreach (Req r in req_filter.NewList())
            {
                string name = r.Name.Replace("\"", "").Replace("\t", "").Trim();

                Console.WriteLine("Req \"{0}\"", name);

                rfs.WriteLine(String.Join("\t", new String[] {
                    r.ID.ToString(),
                    r.ParentId.ToString(),
                    r["RQ_REQ_PATH"],
                    name,
                    r["RQ_VTS"].ToString()
                }));

                if (!r.HasAttachment)
                {
                    continue;
                }

                AttachmentFactory att_factory = r.Attachments;

                foreach (Attachment a in att_factory.NewList(""))
                {
                    Console.WriteLine("Attachment \"{0}\"", a.Name);

                    afs.WriteLine(String.Join("\t", new String[] {
                        r.ID.ToString(),
                        a.ID.ToString(),
                        a.Name,
                        a.FileSize.ToString(),
                        a.LastModified.ToShortDateString()
                    }));

                    IExtendedStorage storage = a.AttachmentStorage;
                    storage.ClientPath = Path.GetFullPath(att_path) + "\\";
                    storage.Load(a.Name, true);
                }
            }

            rfs.Close();
            afs.Close();

            tdc.Disconnect();
            tdc.Logout();

            Console.WriteLine("Disconnected.");
        }
 /// <summary>
 /// Creates distributed counter.
 /// </summary>
 /// <param name="storage">Storage which will be used to save counter state and synchronize threads.</param>
 /// <param name="key">Unique counter identifier. All counters in the same storage with the same identifier share value.</param>
 public DistributedCounter(IExtendedStorage storage, string key, int value = 0)
 {
     this.storage = storage;
     this.key = key;
     this.Initialize(value);
 }
Beispiel #4
0
        public static DateTime AssureTimeMonotonicity(DateTime currentTime, IExtendedStorage storage, string storageKey)
        {
            using (var l = storage.AcquireLock(string.Format("{0}_lock", storageKey)))
            {
                var previousTime = default(DateTime);
                try
                {
                    previousTime = storage.Retrieve<DateTime>(storageKey);
                }
                catch
                {
                }

                if (currentTime <= previousTime)
                {
                    currentTime = previousTime.AddMilliseconds(1);
                }

                storage.StoreOrUpdate(storageKey, currentTime);
            }

            return currentTime;
        }