Пример #1
0
        }       //	updateManualGoals

        /**
         *  Update/save Goals with Achievement
         *  @return true if updated
         */
        private Boolean UpdateAchievementGoals()
        {
            if (!MEASURETYPE_Achievements.Equals(GetMeasureType()))
            {
                return(false);
            }
            DateTime today = DateTime.Now;

            MGoal[] goals = MGoal.GetMeasureGoals(GetCtx(), GetPA_Measure_ID());
            for (int i = 0; i < goals.Length; i++)
            {
                MGoal  goal         = goals[i];
                String MeasureScope = goal.GetMeasureScope();
                String trunc        = TimeUtil.TRUNC_DAY;
                if (MGoal.MEASUREDISPLAY_Year.Equals(MeasureScope))
                {
                    trunc = TimeUtil.TRUNC_YEAR;
                }
                else if (MGoal.MEASUREDISPLAY_Quarter.Equals(MeasureScope))
                {
                    trunc = TimeUtil.TRUNC_QUARTER;
                }
                else if (MGoal.MEASUREDISPLAY_Month.Equals(MeasureScope))
                {
                    trunc = TimeUtil.TRUNC_MONTH;
                }
                else if (MGoal.MEASUREDISPLAY_Week.Equals(MeasureScope))
                {
                    trunc = TimeUtil.TRUNC_WEEK;
                }
                DateTime compare = TimeUtil.Trunc(today, trunc);
                //
                MAchievement[] achievements = MAchievement.GetOfMeasure(GetCtx(), GetPA_Measure_ID());
                Decimal        ManualActual = Env.ZERO;
                for (int j = 0; j < achievements.Length; j++)
                {
                    MAchievement achievement = achievements[j];
                    if (achievement.IsAchieved() && achievement.GetDateDoc() != null)
                    {
                        DateTime ach = TimeUtil.Trunc(achievement.GetDateDoc(), trunc);
                        if (compare.Equals(ach))
                        {
                            ManualActual = Decimal.Add(ManualActual, achievement.GetManualActual());
                        }
                    }
                }
                goal.SetMeasureActual(ManualActual);
                goal.Save();
            }
            return(true);
        }
Пример #2
0
        }       //	updateGoals

        /**
         *  Update/save Manual Goals
         *  @return true if updated
         */
        private Boolean UpdateManualGoals()
        {
            if (!MEASURETYPE_Manual.Equals(GetMeasureType()))
            {
                return(false);
            }
            MGoal[] goals = MGoal.GetMeasureGoals(GetCtx(), GetPA_Measure_ID());
            for (int i = 0; i < goals.Length; i++)
            {
                MGoal goal = goals[i];
                goal.SetMeasureActual(GetManualActual());
                goal.Save();
            }
            return(true);
        }       //	updateManualGoals
Пример #3
0
 /**
  *  Update/save Goals with Projects
  *  @return true if updated
  */
 private Boolean UpdateProjects()
 {
     if (!MEASURETYPE_Project.Equals(GetMeasureType()) ||
         GetC_ProjectType_ID() == 0)
     {
         return(false);
     }
     MGoal[] goals = MGoal.GetMeasureGoals(GetCtx(), GetPA_Measure_ID());
     for (int i = 0; i < goals.Length; i++)
     {
         MGoal goal = goals[i];
         //	Find Role
         MRole role = null;
         if (goal.GetAD_Role_ID() != 0)
         {
             role = MRole.Get(GetCtx(), goal.GetAD_Role_ID());
         }
         else if (goal.GetAD_User_ID() != 0)
         {
             MUser   user  = MUser.Get(GetCtx(), goal.GetAD_User_ID());
             MRole[] roles = user.GetRoles(goal.GetAD_Org_ID());
             if (roles.Length > 0)
             {
                 role = roles[0];
             }
         }
         if (role == null)
         {
             role = MRole.GetDefault(GetCtx(), false);   //	could result in wrong data
         }
         //
         Decimal?     ManualActual = null;
         MProjectType pt           = MProjectType.Get(GetCtx(), GetC_ProjectType_ID());
         String       sql          = pt.GetSqlPI(goal.GetRestrictions(false),
                                                 goal.GetMeasureScope(), GetMeasureDataType(), null, role);
         IDataReader idr = null;
         try             //	SQL statement could be wrong
         {
             idr = DataBase.DB.ExecuteReader(sql, null, null);
             if (idr.Read())
             {
                 ManualActual = Utility.Util.GetValueOfDecimal(idr[0]);
             }
             idr.Close();
         }
         catch (Exception e)
         {
             if (idr != null)
             {
                 idr.Close();
             }
             log.Log(Level.SEVERE, sql, e);
         }
         //	SQL may return no rows or null
         if (ManualActual == null)
         {
             ManualActual = Env.ZERO;
             log.Fine("No Value = " + sql);
         }
         goal.SetMeasureActual(ManualActual);
         goal.Save();
     }
     return(true);
 }