Ejemplo 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);
     }
 }
Ejemplo n.º 2
0
    public BuildRequest getInstallRequest(string machine)
    {
        DefectBuild  b = DefectBuild.GetTask2Build(machine, DefectBuild.BuildType.releasebuild);
        BuildRequest r = new BuildRequest();

        if (b != null)
        {
            DefectBase def  = new DefectBase(Defect.GetTTbyID(b.DEFID));
            DefectUser user = new DefectUser(int.Parse(def.AUSER));
            r.ID   = b.ID;
            r.TTID = def.ID;
            r.COMM = b.NOTES;
            string em = user.EMAIL.Trim();
            if (string.IsNullOrEmpty(em))
            {
                r.USER = "******";
            }
            else
            {
                r.USER = em.Substring(0, em.IndexOf("@")).ToUpper();
            }
            r.SUMMARY = def.SUMMARY;
            r.BRANCH  = def.BRANCH;
        }
        return(r);
    }
Ejemplo n.º 3
0
 protected override void OnChangeColumn(string col, string val)
 {
     if ((col == _pname || col == _cli) && TTUSERID > -1)
     {
         DefectUser du = new DefectUser(TTUSERID);
         if (col == _pname)
         {
             val = val.Replace("\'", "");
             string[] vals = val.Split(' ');
             if (vals.Length == 2)
             {
                 du.FIRSTNAME = vals[0];
                 du.LASTNAME  = vals[1];
             }
             else
             {
                 du.FIRSTNAME = val;
             }
         }
         else if (col == _cli)
         {
             du.CUSTOMER = (val != "0");
         }
         du.Store();
     }
     else if (col == _ret && TTUSERID > -1)
     {
         DefectUser du = new DefectUser(TTUSERID);
         du.ACTIVE = !RETIRED;
         du.Store();
     }
     base.OnChangeColumn(col, val);
 }
Ejemplo n.º 4
0
    public string GetTaskUserName()
    {
        if (AUSER == "")
        {
            return("Unassigned");
        }
        DefectUser u = new DefectUser(AUSER);

        return(u.FULLNAME);
    }
Ejemplo n.º 5
0
    public static void UpdateEDD()
    {
        //one mass update per time
        lock (_lockEDD)
        {
            if (DateTime.Compare(_EDDDate, DefectBase.LastGlobalModifier) > 0)
            {
                return;
            }

            //cache all vacations
            List <DefectBase> vacs = Vacations.EnumCloseVacations(DateTime.Today, 365);

            DefectBase d = new DefectBase();
            foreach (var u in DefectUser.Enum())
            {
                if (!u.ACTIVE)
                {
                    continue;
                }
                string          sid      = u.ID.ToString();
                List <DateTime> vacDates = new List <DateTime>();
                foreach (var v in vacs)
                {
                    if (v.AUSER == sid)
                    {
                        vacDates.Add(DateTime.ParseExact(v.DATE, IdBasedObject.defDateFormat, CultureInfo.InvariantCulture));
                    }
                }

                DateTime dat = DateTime.Today.AddDays(1);

                foreach (var task in d.EnumPlan(u.ID))
                {
                    while (dat.DayOfWeek == DayOfWeek.Saturday || dat.DayOfWeek == DayOfWeek.Sunday)
                    {
                        dat = dat.AddDays(1);
                    }
                    while (vacDates.Exists(x => dat.Date.CompareTo(x) == 0))
                    {
                        dat = dat.AddDays(1);
                    }
                    int hours = Math.Max(task.ESTIM - task.SPENT, 0) + dat.Hour;
                    dat = dat.AddHours(-dat.Hour);
                    int days = hours / 8;
                    hours = hours % 8;
                    dat   = dat.AddDays(days);
                    dat   = dat.AddHours(hours);
                    task.SetEDD(dat.Date);
                }
            }
            _EDDDate = DateTime.Now;
        }
    }
Ejemplo n.º 6
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);
    }
Ejemplo n.º 7
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);
    }
Ejemplo n.º 8
0
    public DisplayUser getUser(int id)
    {
        CurrentContext.Validate();
        if (id < 1)
        {
            return(new DisplayUser());
        }
        DefectUser u = new DefectUser(id);

        return(new DisplayUser()
        {
            FULLNAME = u.FULLNAME, TRID = u.TRID
        });
    }
Ejemplo n.º 9
0
    public static MPSUser NewUser()
    {
        string name  = DateTime.Now.Ticks.ToString();
        string email = name + "@domain.com";

        AddObject(_Tabl, new string[] { _login, _pname, _pass, _isAdm, _ret, _birth, _lvl, _email }, new object[] { name, name, "", 0, 0, DateTime.Now, 3, email }, "");
        DefectUser.NewUser(name, "", email);
        ReferenceVersion.Updatekey();
        foreach (int i in EnumRecords(_Tabl, _pid, new string[] { _login }, new object[] { name }))
        {
            return(new MPSUser(i));
        }
        return(null);
    }
Ejemplo n.º 10
0
    static public List <Tracker> Enum(int user)
    {
        if (user < 0)
        {
            return(new List <Tracker>());
        }
        DefectUser     usr    = new DefectUser(user);
        MPSUser        mpu    = new MPSUser(usr.TRID);
        string         filter = mpu.ISCLIENT ? $"WHERE {_Own} = {user} OR {_Cli} = {user} ORDER BY {_Nam} asc" : $"WHERE {_Own} = {user} OR {_Cli} is not null ORDER BY {_Nam} asc";
        List <Tracker> res    = new List <Tracker>();

        foreach (DataRow r in (new Tracker()).GetRecords(filter))
        {
            Tracker d = new Tracker();
            d.Load(r);
            res.Add(d);
        }
        return(res);
    }
Ejemplo n.º 11
0
    public static MPSUser FindUser(string name, string pass)
    {
        bool domain = name.Contains("@");

        if (domain)
        {
            bool   valid        = false;
            string dispUserName = name;
            using (PrincipalContext context = new PrincipalContext(ContextType.Domain, Settings.CurrentSettings.COMPANYDOMAIN))
            {
                valid = context.ValidateCredentials(name, pass);
                if (valid)
                {
                    var usr = UserPrincipal.FindByIdentity(context, name);
                    if (usr != null)
                    {
                        dispUserName = usr.GivenName + " " + usr.Surname;
                    }
                }
            }
            if (!valid)
            {
                return(null);
            }
            foreach (int i in EnumRecords(_Tabl, _pid, new string[] { _login }, new object[] { name }))
            {
                return(new MPSUser(i));
            }
            AddObject(_Tabl, new string[] { _login, _pname, _pass, _isAdm, _ret, _birth, _lvl, _email }, new object[] { name, dispUserName, "", 0, 0, DateTime.Now, 3, name }, "");
            DefectUser.NewUser(name, "", name);
            ReferenceVersion.Updatekey();
            foreach (int i in EnumRecords(_Tabl, _pid, new string[] { _login }, new object[] { name }))
            {
                return(new MPSUser(i));
            }
            return(null);
        }
        foreach (int i in EnumRecords(_Tabl, _pid, new string[] { _login, _pass }, new object[] { name, pass }))
        {
            return(new MPSUser(i));
        }
        return(null);
    }
Ejemplo n.º 12
0
    public static List <DefectBase> EnumModified(string date, string email)
    {
        DefectsFilter f = new DefectsFilter();

        f.startDateModified = date;
        f.endDateModified   = DateTime.ParseExact(date, defDateFormat, CultureInfo.InvariantCulture).AddDays(1).ToString(defDateFormat);
        DefectUser u = DefectUser.FindByEmail(email);

        if (u != null)
        {
            f.modifiedUsers = new List <int>()
            {
                u.ID
            };
        }
        DefectBase temp = new DefectBase();

        return(temp.Enum(f, 100));
    }
Ejemplo n.º 13
0
 public static List <Vacation> TodayVacations()
 {
     lock (_lock)
     {
         if (_TodayVacs == null || (DateTime.Now - _loadDT).TotalMinutes > 5)
         {
             _TodayVacs = new List <Vacation>();
             var tasks = EnumCloseVacations(DateTime.Now.ToString(IdBasedObject.defDateFormat, CultureInfo.InvariantCulture), 0);
             foreach (var t in tasks)
             {
                 DefectUser u = new DefectUser(t.AUSER);
                 _TodayVacs.Add(new Vacation()
                 {
                     UserId = u.TRID, Sick = t.SICK, TTUserId = u.ID
                 });
             }
         }
         return(new List <Vacation>(_TodayVacs));
     }
 }
Ejemplo n.º 14
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/>"));
    }
Ejemplo n.º 15
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);
        }
    }
Ejemplo n.º 16
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);
        }
    }
Ejemplo n.º 17
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);
        }
    }
Ejemplo n.º 18
0
 public List <DefectUser> gettaskusers()
 {
     return(DefectUser.Enum());
 }