예제 #1
0
        public async Task <int> changeCheckListStakeholder(int ReleaseID, List <int> changedStakeholderIds, Release newRelease)
        {
            int count = 0, employeeId;
            var histories = new List <History>();

            using (IEmployeeRepository db = new EmployeeRepository())
            {
                employeeId = db.GetEmployee(ConfigurationManager.AppSettings["SystemUserNtnet"]);
            }
            using (IReleaseChecklistAnswerRepository db = new ReleaseChecklistAnswerRepository())
            {
                var releaseChecklistAnswer = db.Where(cl => cl.ReleaseID == ReleaseID).Include(cl => cl.Question).Where(cl => changedStakeholderIds.Where(s => s == cl.Question.QuestionOwnerID).Count() > 0);



                foreach (ReleaseChecklistAnswer cl in releaseChecklistAnswer)
                {
                    var history = new History();
                    history.ReleaseID = cl.ReleaseID;
                    history.ItemID    = cl.ReleaseChecklistAnswerID;
                    history.TableID   = 26;
                    //  history.ActivityLogID = activityLog.ActivityLogID;
                    history.OldValue   = cl.QuestionOwnerID.ToString();
                    history.FieldName  = "QuestionOwner";
                    cl.QuestionOwnerID = newRelease.ReleaseStakeholders.Where(s => s.StakeholderID == cl.Question.QuestionOwnerID).FirstOrDefault().EmployeeID1;
                    history.NewValue   = cl.QuestionOwnerID.ToString();
                    histories.Add(history);
                }
                count += await db.SaveAsync(null, true, histories);
            }
            return(count);
        }
예제 #2
0
        public async Task <JsonResult> publishCP(int CPID, int ReleaseID, bool ChangeRiskLevel = false)
        {
            try
            {
                CP currentCP;
                IEnumerable <ReleaseChecklistAnswer> InitiatedQuestion = null;
                int count = 0;
                using (ICPRepository db = new CPRepository())
                {
                    currentCP = db.Where(cp => cp.CPID == CPID).Include(cp => cp.Milestone).Include(cp => cp.Milestone.ReleaseMilestones).FirstOrDefault();
                }
                using (IReleaseChecklistAnswerRepository db = new ReleaseChecklistAnswerRepository())
                {
                    var cpDate = currentCP.Milestone.ReleaseMilestones.Where(rm => rm.ReleaseID == ReleaseID).FirstOrDefault().MilestoneDate;
                    InitiatedQuestion = cpDate != null?db.Where(s => s.RiskLevelID == RiskLevels.Initiated && s.HandlingStartDate <= cpDate && s.ReleaseID == ReleaseID).ToList() : null;

                    int AllQuestion = db.Where(s => s.HandlingStartDate <= cpDate && s.ReleaseID == ReleaseID).Count();
                    if (InitiatedQuestion != null && InitiatedQuestion.Count() > 0)
                    {
                        if (ChangeRiskLevel)
                        {
                            InitiatedQuestion.ToList().ForEach(q => { q.RiskLevelID = RiskLevels.High; q.HandlingStartDate = DateTime.Today; });
                            count += await db.SaveAsync((WindowsPrincipal)User);

                            //(WindowsPrincipal)User);
                            // ViewStatus(ReleaseID);
                        }
                        return(Json(new { Result = "ExistQuestions", IsChanged = ChangeRiskLevel, IsUpdated = true }));
                    }
                    return(Json(new { Result = "NotExistQuestions", TotalCPQuestion = AllQuestion }));
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
예제 #3
0
        public async Task <int> changeCheckListHandlingStartDate(int ReleaseID, List <int> changedMilestonesIds, Release newRelease)
        {
            int count = 0, employeeId;
            var histories = new List <History>();

            using (IReleaseChecklistAnswerRepository db = new ReleaseChecklistAnswerRepository())
            {
                IEnumerable <ReleaseChecklistAnswer> releaseChecklistAnswer = db.Where(cl => cl.ReleaseID == ReleaseID).Include(cl => cl.Question).Where(cl => changedMilestonesIds.Where(m => m == cl.Question.MilestoneID || m == cl.Question.PreviousMilestoneID).Count() > 0);

                if (releaseChecklistAnswer != null && releaseChecklistAnswer.ToList().Count() > 0)
                {
                    using (IEmployeeRepository current_db = new EmployeeRepository())
                    {
                        employeeId = current_db.GetEmployee(ConfigurationManager.AppSettings["SystemUserNtnet"]);
                    }

                    //ActivityLog activityLog = new ActivityLog(employeeId, ActivityType.Edit);
                    //using (IActivityLogRepository current_db = new ActivityLogRepository())
                    //{
                    //    current_db.Add(activityLog);
                    //    await current_db.SaveChangesAsync();
                    //}

                    foreach (ReleaseChecklistAnswer cl in releaseChecklistAnswer)
                    {
                        var history = new History();
                        history.ReleaseID = cl.ReleaseID;
                        history.ItemID    = cl.ReleaseChecklistAnswerID;
                        history.TableID   = StaticResources.GetTableID(ConfigurationManager.AppSettings["ReleaseChecklistAnswer"]);
                        //  history.ActivityLogID = activityLog.ActivityLogID;
                        history.OldValue     = cl.HandlingStartDate.ToString();
                        history.FieldName    = "HandlingStartDate";
                        cl.HandlingStartDate = new QuestionRepository().HandlingStartDatecalculation(newRelease, cl.Question.MilestoneID, cl.Question.PreviousMilestoneID, cl.Question.RatioBetweenMilestones);
                        history.NewValue     = cl.HandlingStartDate.ToString();
                        if (history.OldValue != history.NewValue)
                        {
                            histories.Add(history);
                        }
                    }



                    //    var history = new History();
                    //    history.OldValue = cl.HandlingStartDate.ToString();
                    //    history.FieldName = "HandlingStartDate";
                    //    cl.HandlingStartDate = new QuestionRepository().HandlingStartDatecalculation(newRelease, cl.Question.MilestoneID, cl.Question.PreviousMilestoneID, cl.Question.RatioBetweenMilestones);
                    //    history.NewValue = cl.HandlingStartDate.ToString();
                    //    histories.Add(history);
                    //    history.ActivityLogs = new List<ActivityLog>() { new ActivityLog(employeeId,
                    //            cl.ReleaseChecklistAnswerID, cl.ReleaseID, 26 , ActivityType.Edit)};
                    //});



                    //await releaseChecklistAnswer.ForEachAsync(cl =>
                    //{

                    //});
                    count += await db.SaveAsync(null, true, histories);
                }
            }

            return(count);
        }
예제 #4
0
        //private void addToChangedQuestionOwnerIDs(int updatedID, int newID, List<int> questionOwnerID)
        //{
        //    if (updatedID != newID)


        //}
        public async Task <int> SaveEditRelease(int ReleaseID, ReleaseTabs UpdateRelease, IDictionary <string, bool> ListUpdated)
        {
            // bool isExecuteAsyncTask = false;
            List <int?>             questionOwnerIds      = new List <int?>();
            int                     Count                 = 0;
            List <int>              changedMilestonesIds  = null;
            List <int>              changedStakeholderIds = null;
            List <ReleaseAreaOwner> changedAreaOwnersIds  = new List <ReleaseAreaOwner>();
            Release                 newRelease            = null;

            using (IReleaseRepository db = new ReleaseRepository())
            {
                StringBuilder includeProperty = new StringBuilder();
                if (ListUpdated["ReleaseStakeholders"])
                {
                    includeProperty.Append("ReleaseStakeholders,");
                }
                if (ListUpdated["AreaOwners"])
                {
                    includeProperty.Append("ReleaseAreaOwners,");
                }
                if (ListUpdated["ReleaseMilestones"])
                {
                    includeProperty.Append("ReleaseMilestones,");
                }
                if (ListUpdated["ReleaseCharacteristics"])
                {
                    includeProperty.Append("ReleaseCharacteristics,");
                }
                if (ListUpdated["ProductsInScope"])
                {
                    includeProperty.Append("ReleaseFamilyProducts,");
                    includeProperty.Append("ReleaseProducts,");
                }
                newRelease           = db.Get(r => r.ReleaseID == ReleaseID, null, includeProperty.ToString()).FirstOrDefault();
                newRelease.AccountID = UpdateRelease.GeneralDetails.AccountID;
                newRelease.Name      = UpdateRelease.GeneralDetails.Name;
                newRelease.Size      = UpdateRelease.GeneralDetails.Size;
                newRelease.LOB       = UpdateRelease.GeneralDetails.LOB;
                if (ListUpdated["ReleaseMilestones"])
                {
                    changedMilestonesIds = UpdateRelease.ReleaseMilestones.Where(rv => !DateTime.Equals(newRelease.ReleaseMilestones.First(rm => rm.MilestoneID == rv.MilestoneID).MilestoneDate, rv.MilestoneDate)).Select(m => (int)m.MilestoneID).ToList();
                    UpdateRelease.ReleaseMilestones.ToList().ForEach(rv => newRelease.ReleaseMilestones.First(rm => rm.MilestoneID == rv.MilestoneID).MilestoneDate = rv.MilestoneDate);
                }
                if (ListUpdated["ReleaseCharacteristics"])
                {
                    UpdateRelease.ReleaseCharacteristic.ToList().ForEach(rv => newRelease.ReleaseCharacteristics.First(rm => rm.CharacteristicID == rv.CharacteristicID).IsChecked = rv.IsChecked);
                }
                if (ListUpdated["ReleaseStakeholders"])
                {
                    changedStakeholderIds = UpdateRelease.ReleaseStakeholders.Where(rn => !(newRelease.ReleaseStakeholders.First(rs => rs.StakeholderID == rn.StakeholderID).EmployeeID1 == rn.EmployeeID1)).Select(s => (int)s.StakeholderID).ToList();
                    UpdateRelease.ReleaseStakeholders.ToList().ForEach(rs =>
                    {
                        var rsh = newRelease.ReleaseStakeholders.First(rm => rm.ReleaseStakeholderID == rs.ReleaseStakeholderID);
                        if (rsh.EmployeeID1 != rs.EmployeeID1)
                        {
                            rsh.EmployeeID1 = rs.EmployeeID1;
                            if (!questionOwnerIds.Contains(rs.EmployeeID1))
                            {
                                questionOwnerIds.Add(rs.EmployeeID1);
                            }
                        }
                        if (rsh.EmployeeID2 != rs.EmployeeID2)
                        {
                            rsh.EmployeeID2 = rs.EmployeeID2;
                            if (!questionOwnerIds.Contains(rs.EmployeeID2))
                            {
                                questionOwnerIds.Add(rs.EmployeeID2);
                            }
                        }
                    });
                }
                if (ListUpdated["AreaOwners"])
                {
                    UpdateRelease.AreaOwners.ToList().ForEach(r =>
                    {
                        var current = newRelease.ReleaseAreaOwners.FirstOrDefault(rm => rm.AreaID == r.AreaID);
                        if (current != null)
                        {
                            if (!r.IsChecked)
                            {
                                current.CustomerFocalpoint1 = string.Empty;
                                current.CustomerFocalPoint2 = string.Empty;
                                current.Resposibility       = Responsibility.Amdocs;
                                current.AmdocsFocalPoint1ID = current.AmdocsFocalPoint2ID = null;
                                current.AmdocsFocalPoint1   = current.AmdocsFocalPoint2 = null;
                            }
                            else
                            {
                                current.Resposibility = r.Resposibility;
                                if (current.AmdocsFocalPoint1ID != r.AmdocsFocalPoint1ID)
                                {
                                    current.AmdocsFocalPoint1ID = r.AmdocsFocalPoint1ID;
                                    changedAreaOwnersIds.Add(current);
                                }


                                current.AmdocsFocalPoint2ID = r.AmdocsFocalPoint2ID;
                                current.CustomerFocalpoint1 = r.CustomerFocalPoint1;
                                current.CustomerFocalPoint2 = r.CustomerFocalPoint2;
                            }
                            current.IsChecked = r.IsChecked;
                        }
                    });
                }

                if (ListUpdated["ProductsInScope"])
                {
                    UpdateRelease.ProductsInScope.FamilyProducts.ToList().ForEach(rf =>
                    {
                        var current = newRelease.ReleaseFamilyProducts.FirstOrDefault(f => f.FamilyProductID == rf.ID);
                        if (current != null)
                        {
                            current.IsChecked = rf.IsChecked;
                            if (rf.Products != null)
                            {
                                rf.Products.ForEach(rp =>
                                {
                                    var currentrp = newRelease.ReleaseProducts.FirstOrDefault(p => p.ProductID == rp.ID);
                                    if (currentrp != null)
                                    {
                                        currentrp.IsChecked = rp.IsChecked;
                                    }
                                });
                            }
                        }
                    });
                    newRelease.AdditionalProducts = UpdateRelease.ProductsInScope.Release.AdditionalProducts;
                }

                Count += await db.SaveAsync((WindowsPrincipal)User);
            }
            //Release Release, Milestone mileston, Milestone prevMilestone, double ratio
            if (ListUpdated["ReleaseMilestones"])
            {
                if (changedMilestonesIds != null && changedMilestonesIds.Count() > 0)
                {
                    using (IReleaseChecklistAnswerRepository db = new ReleaseChecklistAnswerRepository())
                    {
                        try
                        {
                            IEnumerable <ReleaseChecklistAnswer> releaseChecklistAnswer = db.Where(cl => cl.ReleaseID == ReleaseID).Include(cl => cl.Question).Where(cl => changedMilestonesIds.Where(m => m == cl.Question.MilestoneID || m == cl.Question.PreviousMilestoneID).Count() > 0).ToList();
                            Session["isExecuteAsyncTask"] = releaseChecklistAnswer.Count() > 0;
                        }
                        catch (Exception ex)
                        {
                            string s = ex.Message;
                        }
                    }

                    await changeCheckListHandlingStartDate(ReleaseID, changedMilestonesIds, newRelease);
                }
            }
            if (ListUpdated["ReleaseStakeholders"])
            {
                if (changedStakeholderIds != null && changedStakeholderIds.Count() > 0)
                {
                    using (IReleaseChecklistAnswerRepository db = new ReleaseChecklistAnswerRepository())
                    {
                        IEnumerable <ReleaseChecklistAnswer> releaseChecklistAnswer = db.Where(cl => cl.ReleaseID == ReleaseID).Include(cl => cl.Question).Where(cl => changedStakeholderIds.Where(s => s == cl.Question.QuestionOwnerID).Count() > 0).ToList();
                        Session["isExecuteAsyncTask"] = releaseChecklistAnswer.Count() > 0;
                    }
                    await changeCheckListStakeholder(ReleaseID, changedStakeholderIds, newRelease);
                }
            }

            if (ListUpdated["AreaOwners"] && changedAreaOwnersIds != null && changedAreaOwnersIds.Count() > 0)
            {
                int count = 0, employeeId;
                var histories = new List <History>();
                using (IReleaseChecklistAnswerRepository db = new ReleaseChecklistAnswerRepository())
                {
                    try
                    {
                        IEnumerable <ReleaseChecklistAnswer> releaseChecklistAnswer = db.Where(cl => cl.ReleaseID == ReleaseID).Include(cl => cl.Question);
                        releaseChecklistAnswer = releaseChecklistAnswer.Where(cl => cl.Question.QuestionOwnerID == null && changedAreaOwnersIds.Where(ao => cl.AreaID == ao.AreaID).Count() > 0);
                        if (releaseChecklistAnswer != null && releaseChecklistAnswer.ToList().Count() > 0)
                        {
                            Session["isExecuteAsyncTask"] = true;
                            using (IEmployeeRepository current_db = new EmployeeRepository())
                            {
                                employeeId = current_db.GetEmployee(ConfigurationManager.AppSettings["SystemUserNtnet"]);
                            }
                            foreach (ReleaseChecklistAnswer cl in releaseChecklistAnswer)
                            {
                                var history = new History();
                                history.ReleaseID  = cl.ReleaseID;
                                history.ItemID     = cl.ReleaseChecklistAnswerID;
                                history.TableID    = 26;
                                history.OldValue   = cl.QuestionOwnerID.ToString();
                                history.FieldName  = "QuestionOwnerID";
                                cl.QuestionOwnerID = changedAreaOwnersIds.FirstOrDefault(ao => cl.AreaID == ao.AreaID).AmdocsFocalPoint1ID;
                                history.NewValue   = cl.QuestionOwnerID.ToString();
                                histories.Add(history);
                            }
                            count += await db.SaveAsync(null, true, histories);
                        }
                    }
                    catch (Exception ex)
                    {
                        Errors.Write(ex.Message);
                    }
                }
            }

            //if (ListUpdated["AreaOwners"] || ListUpdated["ReleaseStakeholders"])
            //{
            //    if (changedMilestonesIds != null && changedMilestonesIds.Count() > 0)
            //    {
            //        using (IReleaseChecklistAnswerRepository db = new ReleaseChecklistAnswerRepository())
            //        {
            //            IEnumerable<ReleaseChecklistAnswer> releaseChecklistAnswer = db.Where(cl => cl.ReleaseID == ReleaseID).Include(cl => cl.Question).Where(cl => changedMilestonesIds.Where(m => m == cl.Question.MilestoneID || m == cl.Question.PreviousMilestoneID).Count() > 0).ToList();
            //            Session["isExecuteAsyncTask"] = releaseChecklistAnswer.Count() > 0;
            //        }
            //        changeCheckListHandlingStartDate(ReleaseID, changedMilestonesIds, newRelease);
            //    }
            //}
            //  OutputDebug.Write("Savemilestone end");
            // OutputDebug.WriteToOutput();
            return(Count);
        }