public MODEL.risk_task_resource_assignment findByTaskAutoIdResId(int taskAutoId, int resId)
        {
            MODEL.risk_task_resource_assignment taskResAssign = new MODEL.risk_task_resource_assignment();
            string sql = "select * from risk_task_resource_assignment where task_auto_id=:taskAutoId and resource_id=:resId";

            OracleParameter[] parameters = new OracleParameter[] {
                new OracleParameter(":taskAutoId", OracleDbType.Int32, 11),
                new OracleParameter(":resId", OracleDbType.Int32, 11)
            };
            parameters[0].Value = taskAutoId;
            parameters[1].Value = resId;
            try
            {
                using (OracleDataReader reader = SqlHelper.ExecuteQuery(sql, parameters))
                {
                    if (reader.Read())
                    {
                        taskResAssign.Auto_id           = Convert.ToInt32(reader["auto_id"]);
                        taskResAssign.Assignment_amount = Convert.ToInt32(reader["assignment_amount"]);
                        taskResAssign.Assignment_own    = Convert.ToInt32(reader["assignment_own"]);
                        taskResAssign.Resource_id       = resId;
                        taskResAssign.Task_auto_id      = taskAutoId;
                    }
                    return(taskResAssign);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public List <MODEL.risk_task_resource_assignment> getTaskResAssignListByPrjId(int projectId)
        {
            List <MODEL.risk_task_resource_assignment> TaskResAssignList = new List <MODEL.risk_task_resource_assignment>();
            string sql = "select * from RISK_TASK_RESOURCE_ASSIGNMENT where TASK_AUTO_ID IN (SELECT AUTO_ID from RISK_TASK WHERE TASK_PROJECT_ID =:prjId)";

            OracleParameter[] parameters = new OracleParameter[] {
                new OracleParameter(":prjId", OracleDbType.Int32, 11)
            };
            parameters[0].Value = projectId;
            try
            {
                using (OracleDataReader reader = SqlHelper.ExecuteQuery(sql, parameters))
                {
                    while (reader.Read())
                    {
                        MODEL.risk_task_resource_assignment TaskResAssign = new MODEL.risk_task_resource_assignment();
                        TaskResAssign.Auto_id           = Convert.ToInt32(reader["auto_id"]);
                        TaskResAssign.Task_auto_id      = Convert.ToInt32(reader["task_auto_id"]);
                        TaskResAssign.Resource_id       = Convert.ToInt32(reader["resource_id"]);
                        TaskResAssign.Assignment_amount = Convert.ToInt32(reader["assignment_amount"]);
                        TaskResAssign.Assignment_own    = Convert.ToInt32(reader["assignment_own"]);
                        TaskResAssignList.Add(TaskResAssign);
                    }
                }
                return(TaskResAssignList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #3
0
        public static bool deleteTaskResources(MODEL.risk_task_resource_assignment res)
        {
            try
            {
                CommonArugment.getTaskResAssign.deleteByTaskAutoIdResId(res);

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void deleteByTaskAutoIdResId(MODEL.risk_task_resource_assignment taskResAssign)
        {
            string sql = "delete risk_task_resource_assignment where task_auto_id=:taskAutoId and RESOURCE_ID=:resId";

            OracleParameter[] parameters = new OracleParameter[] {
                new OracleParameter(":taskAutoId", OracleDbType.Int32, 11),
                new OracleParameter(":resId", OracleDbType.Int32, 11)
            };
            parameters[0].Value = taskResAssign.Task_auto_id;
            parameters[1].Value = taskResAssign.Resource_id;
            try
            {
                SqlHelper.ExecuteNonQuery(sql, parameters);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #5
0
        //public static bool getBarData(int simVersionId, int scale)
        //{
        //        scale = 200;
        //        int range = 0;
        //        double myThink = 0.2;
        //        try
        //        {
        //                List<MODEL.risk_prj_instance> prjInstanceList = CommonArugment.getProjectInstance.getBySimVersion(simVersionId);
        //                double minN1 = prjInstanceList[0].Sim_project_time;
        //                double maxN1 = prjInstanceList[0].Sim_project_time;
        //                double maxN2 = prjInstanceList[0].Sim_project_time;
        //                foreach (MODEL.risk_prj_instance prjInstance in prjInstanceList)
        //                {
        //                        if (prjInstance.Sim_project_time < minN1)
        //                        {
        //                                minN1 = Math.Floor(prjInstance.Sim_project_time);
        //                        }
        //                        if (prjInstance.Sim_project_time > maxN1)
        //                        {
        //                                maxN1 = Math.Floor(prjInstance.Sim_project_time);
        //                        }
        //                }
        //                maxN2 = maxN1;
        //                while (!isSatisfCreteria(prjInstanceList, maxN2, maxN1, myThink))
        //                {
        //                        double res = 0;
        //                        foreach (MODEL.risk_prj_instance prjInstance in prjInstanceList)
        //                        {
        //                                if (prjInstance.Sim_project_time < maxN2 && prjInstance.Sim_project_time > res)
        //                                {
        //                                        res = prjInstance.Sim_project_time;
        //                                }
        //                        }
        //                        maxN2 = res;
        //                }
        //                range = (int)Math.Ceiling((maxN2 - minN1) / scale);
        //                List<MODEL.bar_data> barDataList = new List<MODEL.bar_data>();
        //                MODEL.bar_data barData0 = new MODEL.bar_data();
        //                barData0.ScFrom = 0;
        //                barData0.ScTo = (int)Math.Ceiling(minN1);

        //                barData0.ScNum = CommonArugment.getProjectInstance.getCount(simVersionId, barData0.ScTo, barData0.ScFrom);
        //                barDataList.Add(barData0);
        //                for (int i = 1; i < scale; ++i)
        //                {
        //                        MODEL.bar_data barData = new MODEL.bar_data();
        //                        barData.ScFrom = i * range + (int)Math.Ceiling(minN1);
        //                        barData.ScTo = (i + 1) * range + (int)Math.Ceiling(minN1);
        //                        barData.ScNum = CommonArugment.getProjectInstance.getCount(simVersionId, barData.ScTo, barData.ScFrom);
        //                        barDataList.Add(barData);
        //                }
        //                CommonMsg.barDataList = barDataList;
        //                return true;
        //        } catch (System.Exception ex)
        //        {
        //                throw ex;
        //        }
        //}
        public static bool getResoueceUse(int simVersionId, int scale, int resourceId)
        {
            int range = 0;

            try
            {
                MODEL.risk_prj_version_info     info            = CommonArugment.getProjectVersionInfo.getPrjVersionInfo(simVersionId);
                List <MODEL.risk_prj_instance>  prjInstanceList = CommonArugment.getProjectInstance.getBySimVersion(simVersionId);
                List <MODEL.bar_data>           barDataList     = new List <MODEL.bar_data>();
                List <MODEL.risk_task_instance> taskList        = CommonArugment.getTaskIntance.getVersionTaskInstance(info.Pri_id, simVersionId);
                double Avg_projecttime = 0;
                foreach (MODEL.risk_prj_instance prj in prjInstanceList)
                {
                    Avg_projecttime += prj.Sim_project_time;
                }
                Avg_projecttime = Avg_projecttime / info.Count;

                double maxN1 = Avg_projecttime;
                double MinN1 = 0;
                range = (int)Math.Ceiling((maxN1 - MinN1) / scale);
                for (int i = 0; i <= scale; ++i)
                {
                    MODEL.bar_data bar = new MODEL.bar_data();
                    bar.ScFrom = i * range + (int)MinN1;
                    bar.ScTo   = (i + 1) * range + (int)MinN1;
                    if (bar.ScFrom > Avg_projecttime)
                    {
                        break;
                    }
                    foreach (MODEL.risk_task_instance task in taskList)
                    {
                        if (task.Starttime == -1)    //概要任务跳过
                        {
                            break;
                        }
                        if (task.Starttime >= bar.ScFrom && task.Starttime + task.Task_actual_dur_period <= bar.ScTo)    //第一种 在中间
                        {
                            MODEL.risk_task_resource_assignment ass = CommonArugment.getTaskResAssign.findByTaskAutoIdResId(task.Task_auto_id, resourceId);
                            if (ass != null)
                            {
                                bar.Ratio += (double)ass.Assignment_amount;
                            }
                        }
                        else if (task.Starttime <= bar.ScFrom && task.Starttime + task.Task_actual_dur_period > bar.ScFrom && task.Starttime + task.Task_actual_dur_period < bar.ScTo)    //第二种
                        {
                            MODEL.risk_task_resource_assignment ass = CommonArugment.getTaskResAssign.findByTaskAutoIdResId(task.Task_auto_id, resourceId);
                            if (ass != null)
                            {
                                bar.Ratio += (double)ass.Assignment_amount / task.Task_actual_dur_period * (task.Starttime + task.Task_actual_dur_period - bar.ScFrom);
                            }
                        }
                        else if (task.Starttime > bar.ScFrom && task.Starttime < bar.ScTo && task.Starttime + task.Task_actual_dur_period > bar.ScTo)//第三种
                        {
                            MODEL.risk_task_resource_assignment ass = CommonArugment.getTaskResAssign.findByTaskAutoIdResId(task.Task_auto_id, resourceId);
                            if (ass != null)
                            {
                                bar.Ratio += (double)ass.Assignment_amount / task.Task_actual_dur_period * (bar.ScTo - task.Starttime);
                            }
                        }
                        else if (task.Starttime <= bar.ScFrom && task.Starttime + task.Task_actual_dur_period >= bar.ScTo)    //第四种
                        {
                            MODEL.risk_task_resource_assignment ass = CommonArugment.getTaskResAssign.findByTaskAutoIdResId(task.Task_auto_id, resourceId);
                            if (ass != null)
                            {
                                bar.Ratio += (double)ass.Assignment_amount / task.Task_actual_dur_period * (bar.ScTo - bar.ScFrom);
                            }
                        }
                    }
                    barDataList.Add(bar);
                }
                foreach (MODEL.bar_data bar in barDataList)
                {
                    bar.Ratio = bar.Ratio / info.Count;
                }
                CommonMsg.barDataList = barDataList;
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }