Example #1
0
 public void NotifyDefect(string ttid, string message, string img, bool alsoteam)
 {
     try
     {
         if (!CurrentContext.Valid)
         {
             throw new Exception("NotifyDefect called without loggin in!");
         }
         Defect     d  = new Defect(ttid);
         DefectUser du = new DefectUser(d.AUSER);
         if (du.TRID > -1)
         {
             MPSUser worker    = new MPSUser(du.TRID);
             string  mess2send = $"TT{ttid} update from {CurrentContext.UserName()}:  {message.Replace("<", "&#60;").Replace(">", "&#62;")}{Settings.CurrentSettings.GetTTAnchor(int.Parse(ttid), img)}";
             TasksBot.SendMessage(worker.CHATID, mess2send);
             if (alsoteam)
             {
                 TestChannel.SendMessage(mess2send);
             }
         }
     }
     catch (Exception e)
     {
         Logger.Log(e);
     }
 }
Example #2
0
    public void FinishBuild(int id, string requestguid)
    {
        try
        {
            DefectBuild b = new DefectBuild(id)
            {
                STATUS = DefectBuild.BuildStatus.finishedok.ToString(), TESTGUID = requestguid
            };
            b.Store();

            if (Settings.CurrentSettings.RELEASETTID == b.TTID.ToString() && b.TYPE == (int)DefectBuild.BuildType.releasebuild)
            {
                //release builder sends its own notifications
                return;
            }

            Defect     d = new Defect(b.TTID);
            DefectUser u = new DefectUser(b.TTUSERID);
            d.SetUpdater(new MPSUser(u.TRID));
            List <DefectDispo> dsps = DefectDispo.EnumTestsStarted();
            if (dsps.Count > 0)
            {
                string   currentlock = Guid.NewGuid().ToString();
                LockInfo li          = Defect.Locktask(b.TTID.ToString(), currentlock, u.TRID.ToString(), true);
                d.DISPO = dsps[0].ID.ToString();
                if (d.PRIMARYHOURS == null)
                {
                    d.PRIMARYHOURS = d.SPENT;
                }
                d.Store();
                DefectEvent.AddEventByTask(id, DefectEvent.Eventtype.QualityAssurance, b.TTUSERID, "Sent for QA Automation");
                Defect.UnLocktask(u.TRID.ToString(), currentlock);
            }

            if (Settings.CurrentSettings.RELEASETTID == b.TTID.ToString())
            {
                VersionBuilder.SendAlarm("✅New internal release build has been finished. Testing is starting...");
            }
            else
            {
                try
                {
                    string mess = $"New task from {u.FULLNAME} is ready for tests!{Settings.CurrentSettings.GetTTAnchor(b.TTID, d.FIRE ? "taskfire.png" : "")}";
                    TestChannel.SendMessage(mess);
                }
                catch (Exception e)
                {
                    Logger.Log(e);
                }
            }

            string bst_b = d.BSTBATCHES.Trim();
            string bst_c = d.BSTCOMMANDS.Trim();
            if (!string.IsNullOrEmpty(bst_b) || !string.IsNullOrEmpty(bst_c))
            {
                string batches  = string.Join(",", bst_b.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries));
                string commands = string.Join(",", bst_c.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries));
                using (var wcClient = new WebClient())
                {
                    var reqparm = new NameValueCollection();
                    reqparm.Add("guid", requestguid);
                    reqparm.Add("commaseparatedbatches", batches);
                    reqparm.Add("commaseparatedcommands", commands);
                    reqparm.Add("priority", d.TESTPRIORITY);
                    //reqparm.Add("branch", d.BRANCHBST);
                    wcClient.UploadValues(Settings.CurrentSettings.BSTSITESERVICE + "/StartTest", reqparm);
                }
            }
        }
        catch (Exception e)
        {
            Logger.Log(e);
        }
    }