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"); }
protected override void OnProcessComplexColumn(string col, object val) { if (col == _sModTRID) { return; //readonly } else if (col == _BackOrder) { //do not change order of unassigned tasks. skip order modification if (string.IsNullOrEmpty(AUSER) || IsModifiedCol(_Order)) { return; } string sqlupdate = string.Format("UPDATE {0} SET {1} = {2} WHERE {3} = {4}", _Tabl, _Order, BACKORDER, _idRec, IDREC); SQLExecute(sqlupdate); return; } if (col == _Order) { if (string.IsNullOrEmpty(AUSER)) { return; } if (val == DBNull.Value) { string sqlupdate = string.Format("UPDATE {0} SET {1} = NULL WHERE {3} = {4}", _Tabl, _Order, val, _idRec, IDREC); SQLExecute(sqlupdate); } else { int ord = Convert.ToInt32(val); string where1 = DefectDispo.PlanableDefectFilter(); string where2 = DefectSeverity.PlanableDefectFilter(); string sql = $@" SELECT MIN({_Order}) FROM ( SELECT TOP {ord} * FROM (SELECT {_Order} FROM {_Tabl} WHERE {_AsUser} = {AUSER} AND {_Order} IS NOT NULL {where1} {where2} AND {_idRec} <> {IDREC} GROUP BY {_Order}) T ORDER BY 1 DESC ) A" ; object o = GetValue(sql); if (o != DBNull.Value) { string sqlupdate = $"UPDATE {_Tabl} SET {_Order} = {_Order} + 1 WHERE {_Order} > {Convert.ToInt32(o)} AND {_AsUser} = {AUSER} {where1} {where2}"; SQLExecute(sqlupdate); sqlupdate = string.Format("UPDATE {0} SET {1} = {2} WHERE {3} = {4}", _Tabl, _Order, Convert.ToInt32(o) + 1, _idRec, IDREC); SQLExecute(sqlupdate); } else { string sqlupdate = string.Format("UPDATE {0} SET {1} = {2} WHERE {3} = {4}", _Tabl, _Order, ord, _idRec, IDREC); SQLExecute(sql); } } return; } base.OnProcessComplexColumn(col, val); }
public static string PlanableDefectFilter() { lock (_lock) { if (_planwhere != null) { return(_planwhere); } List <int> pl = DefectSeverity.EnumPlanable(); if (pl.Count > 0) { _planwhere = string.Format(" AND ({0} in ({1}))", Defect._Seve, string.Join(",", pl)); } return(_planwhere); } }
public List <DefectBase> EnumUnPlan(int userid) { string w_where1 = DefectDispo.PlanableDefectFilter(); string w_where2 = DefectSeverity.PlanableDefectFilter(); List <DefectBase> ls = new List <DefectBase>(); string where = string.Format(" WHERE (({0} = {1}) AND ({2} is null) {3} {4}) ORDER BY {5} DESC", _AsUser, userid, _Order, w_where1, w_where2, _ID); foreach (DataRow r in GetRecords(where)) { DefectBase d = new DefectBase(); d.Load(r); d._id = r[_ID].ToString(); ls.Add(d); } return(ls); }
public List <DefectBase> EnumPlanLim(int userid, int max) //zero for unlimited number { string w_where = DefectDispo.PlanableDefectFilter(); string w_where2 = DefectSeverity.PlanableDefectFilter(); List <DefectBase> ls = new List <DefectBase>(); string where = string.Format(" WHERE (({0} = {1}) AND ({2} is not null) {3} {5}) ORDER BY {4}.{2} DESC", _AsUser, userid, _Order, w_where, _Tabl, w_where2); foreach (DataRow r in GetRecords(where, max)) { DefectBase d = new DefectBase(); d.Load(r); d._id = r[_ID].ToString(); ls.Add(d); } return(ls); }
protected override string OnTransformCol(string col) { if (col == _sModTRID) { return(string.Format("(SELECT P.{0} FROM {1} P WHERE UPPER(P.{2}) = UPPER({3})) {4}", MPSUser._pid, MPSUser._Tabl, MPSUser._email, _sMod, _sModTRID)); } else if (col == _EstId) { return(_EstId); } else if (col == _Order) { string where1 = DefectDispo.PlanableDefectFilter(); string where2 = DefectSeverity.PlanableDefectFilter(); return($"(CASE WHEN {_Tabl}.{_Order} IS NULL THEN NULL ELSE (SELECT COUNT(*) + 1 FROM {_Tabl} D2 WHERE D2.IDUSR = {_Tabl}.IDUSR AND D2.{_Order} > {_Tabl}.{_Order} {where1} {where2})END) {_Order}"); } else if (col == _BackOrder) { return(string.Format("({0}) {1}", _Order, _BackOrder)); } return(base.OnTransformCol(col)); }
public List <DefectSeverity> gettasksevers() { return(DefectSeverity.Enum()); }