Esempio n. 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);
     }
 }
Esempio n. 2
0
    public void SendTaskMessage(int fromID, int toID, string message, int ttid, string image)
    {
        MPSUser from = new MPSUser(fromID);
        MPSUser to   = new MPSUser(toID);

        TasksBot.SendMessage(to.CHATID, $"{from.PERSON_NAME}: {message}{Settings.CurrentSettings.GetTTAnchor(ttid, image)}");
    }
Esempio n. 3
0
    public void SendMessage(int fromID, int toID, string message)
    {
        MPSUser from = new MPSUser(fromID);
        MPSUser to   = new MPSUser(toID);

        TasksBot.SendMessage(to.CHATID, $"⚠️{from.PERSON_NAME}: {message}");
    }
Esempio n. 4
0
    public async Task <bool> SetGloabalDispo(int ttid, GlobalDispo dispo, string email)
    {
        var dispRef = await DefectDispo.GetDispoFromGlobal(dispo);

        string currentlock = Guid.NewGuid().ToString();
        var    user        = DefectUser.FindByEmail(email);

        if (user == null)
        {
            return(false);
        }
        LockInfo li = await Defect.LocktaskAsync(ttid.ToString(), currentlock, user.TRID.ToString(), true);

        Defect d = new Defect(ttid);

        d.SetUpdater(new MPSUser(user.TRID));
        d.DISPO = dispRef.idRecord.ToString();
        if (d.PRIMARYHOURS == null)
        {
            d.PRIMARYHOURS = d.SPENT;
        }
        d.Store();
        DefectEvent.AddEventByTask(d.IDREC, DefectEvent.Eventtype.QualityAssurance, user.ID, "Changed disposition to " + dispo);
        await Defect.UnLocktaskAsync(user.TRID.ToString(), currentlock);

        var settings = Settings.CurrentSettings;

        if (d.ID.ToString() == settings.RELEASETTID)
        {
            if (dispo == GlobalDispo.testStarted)
            {
                VersionBuilder.SendAlarm("✅Release build has been finished. Testing is starting...");
            }
            else
            {
                VersionBuilder.SendAlarm("❌Failed to build version. Please check the logs!!!");
            }
        }
        else
        {
            DefectUser du     = new DefectUser(d.AUSER);
            MPSUser    worker = new MPSUser(du.TRID);
            var        attr   = dispo.GetAttributeOfType <DisplayAttribute>();
            TasksBot.SendMessage(worker.CHATID, $"{attr.Description}. The task tests have been marked as {dispRef.Descriptor} by automation system. {settings.GetTTAnchor(ttid, attr.Name)}");
            if (dispo == GlobalDispo.testStarted)
            {
                string mess = $"New task from {user.FULLNAME} is ready for tests!{settings.GetTTAnchor(ttid, d.FIRE ? "taskfire.png" : "")}";
                await TestChannel.SendMessageAsync(mess);
            }
        }
        return(true);
    }
Esempio n. 5
0
    public static void NotifyBuildStatusChange(int id, int ttid, int userid, string message, string ttimg)
    {
        string     mess = $"Build Request:  {message}{Settings.CurrentSettings.GetTTAnchor(ttid, ttimg)}";
        DefectUser u    = new DefectUser(userid);

        if (u.TRID < 1)
        {
            return;             //assigned user is not specified - old tasks
        }
        MPSUser mpu = new MPSUser(u.TRID);

        TasksBot.SendMessage(mpu.CHATID, mess);
    }
Esempio n. 6
0
    public void addSickness(string details, int ttuserid)
    {
        if (!CurrentContext.Valid)
        {
            return;
        }

        if (string.IsNullOrEmpty(details) || ttuserid < 1)
        {
            return;
        }
        DateTime dt = DateTime.Today;
        Defect   d  = new Defect(Defect.New("SICKNESS DAY " + dt.Year));

        d.DESCR = $"{CurrentContext.User.PERSON_NAME}: {details}";
        d.AUSER = ttuserid.ToString();
        d.DISPO = DefectDispo.GetWorkingRec().ToString();
        d.ESTIM = 8;
        d.COMP  = DefectComp.GetVacationRec()[0].ToString();
        d.DATE  = dt.ToString(defDateFormat);
        d.Store();
        TasksBot.SendMessage(Settings.CurrentSettings.TELEGRAMCOMPANYCHANNEL, $"🌡{details}");
    }
Esempio n. 7
0
    static public string Push(string ttid)
    {
        CurrentContext.ValidateAdmin();
        if (!Lock())
        {
            return("Locked by another user!");
        }
        Git           git = getGit();
        List <string> res = new List <string>();

        DefectBase d = new DefectBase(ttid);

        res.AddRange(git.PushOrigin());
        git.DeleteBranch(d.BRANCH);
        res.AddRange(git.Status());

        DefectUser ttu  = new DefectUser(d.AUSER);
        MPSUser    mpu  = new MPSUser(ttu.TRID);
        string     mess = $"Task commit has been pushed to master by {CurrentContext.UserName()}{Settings.CurrentSettings.GetTTAnchor(d.ID, "git-pull-request.png")}";

        TasksBot.SendMessage(mpu.CHATID, mess);
        return(string.Join(Environment.NewLine, res.ToArray()).Replace(Environment.NewLine, "<br/>"));
    }
Esempio n. 8
0
    public void NotifyDefectWorker(string ttid, string message, string userphone)
    {
        try
        {
            MPSUser bsu = MPSUser.FindUserbyPhone(userphone);
            if (bsu == null)
            {
                Logger.Log($"Cannot update task {ttid} by testing system. User was not found by phone number: {userphone}");
                return;
            }

            Defect     d  = new Defect(ttid);
            DefectUser du = new DefectUser(d.AUSER);
            if (du.TRID > -1)
            {
                MPSUser worker = new MPSUser(du.TRID);
                TasksBot.SendMessage(worker.CHATID, message);
            }
        }
        catch (Exception e)
        {
            Logger.Log(e);
        }
    }
Esempio n. 9
0
    public void addVacation(string summary, int ttuserid, int num)
    {
        if (string.IsNullOrEmpty(summary) || ttuserid < 1 || num < 1 || num > 100)
        {
            return;
        }
        for (int i = 0; i < num; i++)
        {
            DefectBase d = new DefectBase(Defect.New(summary + " #" + (i + 1).ToString()));
            d.AUSER = ttuserid.ToString();
            d.ESTIM = 8;
            d.COMP  = DefectComp.GetVacationRec()[0].ToString();
            List <int> disp = DefectDispo.EnumCannotStartIDs();
            if (disp.Count > 0)
            {
                d.DISPO = disp[0].ToString();
            }
            d.DATE = new DateTime(DateTime.Now.Year, 12, 31).ToString(defDateFormat);
            d.Store();
        }
        MPSUser mpu = new MPSUser(new DefectUser(ttuserid).TRID);

        TasksBot.SendMessage(mpu.CHATID, $"{num} vacation tasks have been created for you by {CurrentContext.UserName()}");
    }
Esempio n. 10
0
    public void SetTaskTestStatus(string ttid, string failed, string userphone)
    {
        try
        {
            MPSUser bsu = MPSUser.FindUserbyPhone(userphone);
            if (bsu == null)
            {
                Logger.Log($"Cannot update task {ttid} by testing system. User was not found by phone number: {userphone}");
                return;
            }

            Defect d = new Defect(ttid);
            d.SetUpdater(bsu);
            string lockguid = Guid.NewGuid().ToString();
            var    lt       = Defect.Locktask(ttid.ToString(), lockguid, bsu.ID.ToString());
            bool   locked   = lt.globallock != lockguid;
            bool   testFail;
            bool   testcancel = false;
            if (!bool.TryParse(failed, out testFail))
            {
                testcancel = true;
            }
            if (locked)
            {
                MPSUser lu = new MPSUser(lt.lockedby);
                TasksBot.SendMessage(lu.CHATID, $"You was disconnected from the task by the testing system to update task status!{Settings.CurrentSettings.GetTTAnchor(int.Parse(ttid), "disconnect.png")}");
                NotifyHub.lockTaskForceUpdatePages(int.Parse(ttid), lockguid, bsu.ID);
                lt = Defect.Locktask(ttid.ToString(), lockguid, bsu.ID.ToString());
            }
            List <DefectDispo> disp = (testcancel || testFail) ? DefectDispo.EnumTestsFailed() : DefectDispo.EnumTestsPassed();
            if (disp.Count > 0)
            {
                if (!testcancel)
                {
                    d.DISPO = disp[0].ID.ToString();
                }
                else
                {
                    d.AddMessage("Test request have been ignored", bsu.ID);
                }
                d.Store();
                Defect.UnLocktask(ttid, lt.globallock);

                if (!testcancel)
                {
                    DefectUser du = new DefectUser(d.AUSER);
                    if (du.TRID > -1)
                    {
                        MPSUser worker = new MPSUser(du.TRID);
                        string  result = "Succeeded!";
                        string  img    = "taskokay.png";
                        if (testcancel)
                        {
                            result = "Cancelled!";
                            img    = "bin.png";
                        }
                        else if (testFail)
                        {
                            result = "Failed!";
                            img    = "taskfail.png";
                        }
                        TasksBot.SendMessage(worker.CHATID, $"The task tests have been marked as BST {result} by {bsu.PERSON_NAME}{Settings.CurrentSettings.GetTTAnchor(int.Parse(ttid), img)}");
                    }
                }
            }
        }
        catch (Exception e)
        {
            Logger.Log(e);
        }
    }