예제 #1
0
    public string addRef(string type, string desc)
    {
        if (!CurrentContext.Valid)
        {
            return("FAILED");
        }
        if (!CurrentContext.Admin)
        {
            return("FAILED - not admin.");
        }
        RefType rtype;

        if (!Enum.TryParse(type, out rtype))
        {
            return("Invalid argument.");
        }
        switch (rtype)
        {
        case RefType.disposition:
            return(DefectDispo.New(desc).ToString());

        case RefType.severity:
            return(DefectSeverity.New(desc).ToString());

        case RefType.component:
            return(DefectComp.New(desc).ToString());
        }
        return("Unsupported");
    }
예제 #2
0
 protected override void PreStore()
 {
     base.PreStore();
     if (IsModified())
     {
         MODIFIEDBY = GetUpdater().TTUSERID;
         MODIFIED   = DateTime.UtcNow.ToString(defDateFormat, CultureInfo.InvariantCulture);
         if (IsModifiedCol(_Disp) && !IsModifiedCol(_Date))
         {
             var com = Convert.ToInt32(COMP);
             var i   = DefectComp.GetVacationRec().FindIndex(x => x == com);
             if (i == -1)                //change date enter all except vacations.
             {
                 DATE = DateTime.Today.ToString(defDateFormat, CultureInfo.InvariantCulture);
             }
         }
         if (IsModifiedCol(_Disp))
         {
             int ival = int.Parse(DISPO);
             if (!PRIMARYESTIM.HasValue && DefectDispo.EnumWorkNow().Where(x => x.ID == ival).FirstOrDefault() != null)
             {
                 PRIMARYESTIM = ESTIM;
             }
         }
         if (IsModifiedCol(_Est))
         {
             if (PRIMARYESTIM.HasValue && PRIMARYESTIM.Value > 0 && ESTIM > 0 && ESTIM / PRIMARYESTIM.Value >= 2.0)
             {
                 TasksBot.EstimationAlarm(this.ID, PRIMARYESTIM.Value, ESTIM);
             }
         }
     }
     _HistoryChanges = "";
 }
예제 #3
0
    public static List <Statistic> EnumStatistics(DateTime start, int days)
    {
        List <Statistic> ls = new List <Statistic>();

        DateTime end = new DateTime(start.Year, start.Month, start.Day);

        end = end.AddDays(days);

        string vacs     = string.Join(",", DefectComp.GetVacationRec());
        string vacsfree = string.Join(",", DefectDispo.EnumCannotStartIDs());

        string sql = string.Format(@"
			SELECT D.{0} TTUSER, SUM(D.{2}) HOURS, COUNT(*) CNT, 1 FLAG FROM {1} D 
			WHERE D.{3} >= '{4}' AND D.{3} <= '{6}'
					AND D.IDCOMPON NOT IN ({7})
			GROUP BY {0}

			UNION ALL

			SELECT D.{0} TTUSER, COUNT(*)*8 HOURS, COUNT(*) CNT, 3 FLAG FROM {1} D 
			WHERE D.IDCOMPON IN ({7}) AND D.IDDISPOSIT IN ({9})
			GROUP BY {0}

			UNION ALL

			SELECT D.{0} TTUSER, COUNT(*)*8 HOURS, COUNT(*) CNT, 4 FLAG FROM {1} D 
			WHERE D.IDCOMPON IN ({7}) 
					AND D.IDDISPOSIT NOT IN ({9}) 
					AND UPPER(D.Summary) like '%SICK%'
					AND D.{5} >= '{4}' AND D.{5} <= '{6}'
			GROUP BY {0}

			UNION ALL

			SELECT D.{0} TTUSER, COUNT(*)*8 HOURS, COUNT(*) CNT, 5 FLAG FROM {1} D 
			WHERE D.IDCOMPON IN ({7}) 
					AND D.IDDISPOSIT NOT IN ({9}) 
					AND UPPER(D.Summary) NOT LIKE '%SICK%'
					AND D.{5} >= '{4}' AND D.{5} <= '{6}'
			GROUP BY {0}

			UNION ALL

			SELECT {0} TTUSER, SUM(D.{2}) HOURS, COUNT(*) CNT, 2 FLAG FROM {1} D 
			WHERE D.{5} >= '{4}' AND D.{5} <= '{6}'
					AND D.IDDISPOSIT IN (SELECT DI.IDRECORD FROM {8} DI WHERE DI.CANNOTSTART = 0 AND DI.REQUIREWORK = 0)
					AND D.IDCOMPON NOT IN ({7})
			GROUP BY {0}
		"        ,
                                   _AsUser, _Tabl, _Est, _Created, start.ToString(defDateFormat, CultureInfo.InvariantCulture), _Date, end.ToString(defDateFormat, CultureInfo.InvariantCulture),
                                   vacs,
                                   DefectDispo._Tabl, vacsfree);

        foreach (DataRow d in DBHelper.GetRows(sql))
        {
            ls.Add(new Statistic(d));
        }
        return(ls);
    }
예제 #4
0
    static DefectsFilter UnusedVacations()
    {
        DefectsFilter f = new DefectsFilter();

        f.components   = new List <int>(DefectComp.GetVacationRec());
        f.dispositions = new List <int>(DefectDispo.EnumCannotStartIDs());
        return(f);
    }
예제 #5
0
    public static List <DefectBase> EnumCloseVacations(string startdate, int days = 31)
    {
        DefectsFilter f = new DefectsFilter();

        f.components     = new List <int>(DefectComp.GetVacationRec());
        f.dispositions   = DefectDispo.EnumCanStartIDs();
        f.startDateEnter = startdate;
        f.endDateEnter   = DateTime.ParseExact(startdate, IdBasedObject.defDateFormat, CultureInfo.InvariantCulture).AddDays(days).ToString(IdBasedObject.defDateFormat);      //two weeks adnvance
        return((new DefectBase()).Enum(f, 2000));
    }
예제 #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}");
    }
예제 #7
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()}");
    }
예제 #8
0
 public List <DefectComp> gettaskcomps()
 {
     return(DefectComp.Enum());
 }