Example #1
0
        /// <summary>
        /// Get mail adresses of  ReleaseArea and ReleaseStakeholders employees
        /// </summary>
        /// <param name="ReleaseID"></param>
        /// <returns></returns>
        public IEnumerable <string> GetEmployeesMailAddress(int ReleaseID, bool isDraft)
        {
            using (IReleaseRepository db = new ReleaseRepository())
            {
                List <string> MailAddresses  = new List <string>();
                var           CurrentRelease = db.Where(r => r.ReleaseID == ReleaseID)
                                               .Include(ra => ra.ReleaseAreaOwners.Select(a => a.AmdocsFocalPoint1))
                                               .Include(rs => rs.ReleaseStakeholders.Select(s => s.Stakeholder))
                                               .Include(rs => rs.ReleaseStakeholders.Select(s => s.Employee1))
                                               .Include(rs => rs.ReleaseStakeholders.Select(s => s.Employee2)).First();

                MailAddresses.AddRange(CurrentRelease.ReleaseAreaOwners.Where(a => a.AmdocsFocalPoint1 != null).Select(a => a.AmdocsFocalPoint1.Email).ToList());
                if (!isDraft)
                {
                    MailAddresses.AddRange(CurrentRelease.ReleaseStakeholders.Where(a => a.Employee1 != null).Select(a => a.Employee1.Email).ToList()
                                           );
                    MailAddresses.AddRange(CurrentRelease.ReleaseStakeholders.Where(a => a.Employee2 != null).Select(a => a.Employee2.Email).ToList());
                }
                else
                {
                    MailAddresses.AddRange(CurrentRelease.ReleaseStakeholders.Where(a => (a.Stakeholder.Name != ConfigurationManager.AppSettings["ServicePartnerStakeholder"].ToString() &&
                                                                                          a.Stakeholder.Name != ConfigurationManager.AppSettings["CBEStakeholder"].ToString()) && a.Employee1 != null).Select(a => a.Employee1.Email).ToList());
                    MailAddresses.AddRange(CurrentRelease.ReleaseStakeholders.Where(a => (a.Stakeholder.Name != ConfigurationManager.AppSettings["ServicePartnerStakeholder"].ToString() &&
                                                                                          a.Stakeholder.Name != ConfigurationManager.AppSettings["CBEStakeholder"].ToString()) && a.Employee2 != null).Select(a => a.Employee2.Email).ToList());
                }

                //MailAddresses.AddRange(CurrentRelease.ReleaseAreaOwners.Where(a => a.AmdocsFocalPoint1 != null).Select(a => a.AmdocsFocalPoint1.Email).ToList());
                //MailAddresses.AddRange(CurrentRelease.ReleaseStakeholders.Where(a => a.Employee1 != null).Select(a => a.Employee1.Email).ToList());


                return(MailAddresses.Where(s => !string.IsNullOrWhiteSpace(s)).Distinct());
            }
        }
Example #2
0
        public List <Options> GetReleaseOptions()
        {
            List <Options> Options;

            using (IReleaseRepository db = new ReleaseRepository())
            {
                Options = db.GetOptionsNoAsync(o => new Options()
                {
                    DisplayText = o.Name, Value = o.ReleaseID
                });
            }
            return(Options);
        }
        public IEnumerable <AreaScore> GetStatus(int ReleaseId)
        {
            Release currentRelease;

            using (IReleaseRepository db = new ReleaseRepository())
            {
                currentRelease = db.Where(r => r.ReleaseID == ReleaseId)
                                 .Include(r => r.ReleaseAreaOwners)
                                 .Include(r => r.ReleaseAreaOwners.Select(a => a.Area.SubAreas)).FirstOrDefault();
            }

            List <RiskLevels> RiskArr = new List <RiskLevels>()
            {
                RiskLevels.OnHold, RiskLevels.Initiated, RiskLevels.NA
            };
            IEnumerable <ReleaseChecklistAnswer> RelevantQuestions = DbSet.Where(q => q.ReleaseID == ReleaseId && !RiskArr.Contains(q.RiskLevelID))
                                                                     .Include(q => q.Question)
                                                                     .Include(q => q.SubArea)
                                                                     .Include(q => q.RiskLevel).ToList();
            List <AreaScore> AreaScores = new List <AreaScore>();

            currentRelease.ReleaseAreaOwners.OrderBy(r => r.Area.Order).ToList().ForEach(a =>
            {
                var AreaQuestions = RelevantQuestions.Where(q => q.SubArea.AreaID == a.AreaID).ToList();
                if (AreaQuestions.Count > 0)
                {
                    AreaScore Area = new AreaScore()
                    {
                        Area          = a.Area,
                        Score         = ScoreCalculation(AreaQuestions),
                        LastScore     = GetLastScore(ReleaseId, a.AreaID),
                        SubAreaScores = new List <SubAreaScore>()
                    };
                    a.Area.SubAreas.OrderBy(s => s.Order).ToList().ForEach(s =>
                    {
                        var SubAreaQuestions  = RelevantQuestions.Where(q => q.SubAreaID == s.SubAreaID).ToList();
                        SubAreaScore SubScore = new SubAreaScore()
                        {
                            SubArea   = s,
                            Score     = SubAreaQuestions.Count > 0 ? ScoreCalculation(SubAreaQuestions) : -1,
                            LastScore = GetLastScore(ReleaseId, s.AreaID, s.SubAreaID)
                        };
                        Area.SubAreaScores.Add(SubScore);
                    });
                    AreaScores.Add(Area);
                }
            });
            return(AreaScores);
        }
Example #4
0
        public async Task SetInitiateQuestions(Release CurrentRelease, List <int> ReleaseQuestion, WindowsPrincipal User)
        {
            try
            {
                List <ReleaseChecklistAnswer> ReleaseChecklistAnswers = new List <ReleaseChecklistAnswer>();

                if (ReleaseQuestion != null && ReleaseQuestion.Count() > 0)
                {
                    var Questions = DbSet.Where(q => ReleaseQuestion.Contains(q.QuestionID))
                                    .Include(p => p.SubArea.Area)
                                    .Include(p => p.Milestone)
                                    .Include(p => p.Stakeholder)
                                    .Include(P => P.PreviousMilestone)
                                    .Select(q => new
                    {
                        QuestionID             = q.QuestionID,
                        QuestionText           = q.QuestionText,
                        QuestionInfo           = q.QuestionInfo,
                        Order                  = q.Order,
                        PreviousMilestoneID    = q.PreviousMilestoneID,
                        MilestoneID            = q.MilestoneID,
                        QuestionOwnerID        = q.QuestionOwnerID,
                        SubArea                = q.SubArea,
                        RatioBetweenMilestones = q.RatioBetweenMilestones
                    }).ToList();

                    Questions.ForEach(q =>
                    {
                        var newCheclistAnswer = new ReleaseChecklistAnswer()
                        {
                            QuestionID     = q.QuestionID,
                            ReleaseID      = CurrentRelease.ReleaseID,
                            QuestionText   = q.QuestionText,
                            QuestionInfo   = q.QuestionInfo,
                            SubAreaID      = q.SubArea.SubAreaID,
                            AreaID         = q.SubArea.AreaID,
                            Responsibility = CurrentRelease.ReleaseAreaOwners.FirstOrDefault(a => a.AreaID == q.SubArea.AreaID).Resposibility
                        };

                        //var PrevMilestone = CurrentRelease.ReleaseMilestones.First(m => m.MilestoneID == q.PreviousMilestone.MilestoneID);
                        //var Milestone = CurrentRelease.ReleaseMilestones.First(m => m.MilestoneID == q.Milestone.MilestoneID);
                        //DateTime PrevMilestoneDate = PrevMilestone != null && PrevMilestone.MilestoneDate != null ? (DateTime)PrevMilestone.MilestoneDate : new DateTime(1753,1,1);
                        //DateTime MilestoneDate = Milestone != null && Milestone.MilestoneDate != null ? (DateTime)Milestone.MilestoneDate : new DateTime(1753, 1, 1);


                        //// Calculate HandlingStartDate & RiskLevel just if Milastones Dates Exist.
                        //if (!DateTime.Equals(PrevMilestoneDate, new DateTime(1753, 1, 1)) && !DateTime.Equals(MilestoneDate, new DateTime(1753, 1, 1)))
                        //{
                        //    double MilestomeDaysDiff = (MilestoneDate - PrevMilestoneDate).TotalDays;
                        //    DateTime HandlingStartDate = PrevMilestoneDate.AddDays(MilestomeDaysDiff * q.RatioBetweenMilestones);
                        //    newCheclistAnswer.HandlingStartDate = HandlingStartDate;
                        //    newCheclistAnswer.RiskLevelID = HandlingStartDate > DateTime.Today ? RiskLevels.Initiated : RiskLevels.High;
                        //}
                        //else
                        //{
                        //    newCheclistAnswer.HandlingStartDate = null;
                        //    newCheclistAnswer.RiskLevelID = RiskLevels.Initiated;
                        //}
                        newCheclistAnswer.HandlingStartDate = HandlingStartDatecalculation(CurrentRelease, q.MilestoneID, q.PreviousMilestoneID, q.RatioBetweenMilestones);
                        newCheclistAnswer.RiskLevelID       = newCheclistAnswer.HandlingStartDate > DateTime.Today || newCheclistAnswer.HandlingStartDate == null ? RiskLevels.Initiated : RiskLevels.High;
                        // Calculate QuestionOwner According to Question -> QuestionOwner value : AmdocsFocalPoint / Stakeholder
                        int?OwnerID;

                        if (q.QuestionOwnerID == null) //Area Focal Point
                        {
                            var AreaOwner = CurrentRelease.ReleaseAreaOwners.First(a => a.AreaID == q.SubArea.AreaID);
                            OwnerID       = AreaOwner != null ? AreaOwner.AmdocsFocalPoint1ID ?? null : null;
                        }
                        else
                        {
                            var StakeholderOwner = CurrentRelease.ReleaseStakeholders.FirstOrDefault(s => s.StakeholderID == q.QuestionOwnerID);
                            OwnerID = StakeholderOwner != null ? StakeholderOwner.EmployeeID1 ?? null : null;
                        }
                        newCheclistAnswer.QuestionOwnerID = OwnerID;

                        ReleaseChecklistAnswers.Add(newCheclistAnswer);
                    });
                }

                CurrentRelease.ReleaseChecklistAnswers = ReleaseChecklistAnswers;

                using (IReleaseRepository db = new ReleaseRepository())
                {
                    await db.EditReleaseChecklistAnswer(CurrentRelease, User);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #5
0
        public async Task GetVendorQuestions(int VendorID, Release currentRelease, WindowsPrincipal User)
        {
            try
            {
                Release updatedRelease;
                using (IReleaseRepository db = new ReleaseRepository())
                {
                    updatedRelease = db.WhereAndInclude(r => r.ReleaseID == currentRelease.ReleaseID, r => r.ReleaseVendors).FirstOrDefault();
                }
                var vendorIDs = updatedRelease.ReleaseVendors.Select(rv => rv.VendorID).ToArray();
                IEnumerable <Vendor> Vendors = DbSet.Where(v => vendorIDs.Contains(v.VendorID))
                                               .Include(v => v.VendorAreass)
                                               .Include(v => v.VendorAreass.Select(a => a.Area.QuestionAreas)).ToList();

                List <int> AreaIDs          = new List <int>();
                List <int> ReleaseQuestions = new List <int>();

                Vendors.ToList().ForEach(v =>
                                         v.VendorAreass.ToList().ForEach(e =>
                {
                    var IsReleaseArea = currentRelease.ReleaseAreaOwners.Any(a => a.AreaID == e.AreaID && a.IsChecked == true);
                    if (IsReleaseArea)
                    {
                        AreaIDs.Add(e.AreaID);
                    }
                }));

                List <int> ReleaseQuestion = new List <int>();
                if (AreaIDs.Count > 0)
                {
                    using (IQuestionRepository db = new QuestionRepository())
                    {
                        ReleaseQuestions = db.Where(q => AreaIDs.Contains(q.SubArea.AreaID)).Select(q => q.QuestionID).ToList();
                    }

                    var Qustions      = QuestionClasifications.SelectQuestionClasificationsView(Context);
                    var AreaQuestions = Qustions.Where(q => ReleaseQuestions.Contains(q.QuestionID)).ToList();
                    List <QuestionAreaView> arrQuestions = new List <QuestionAreaView>();
                    AreaQuestions.ToList().ForEach(e =>
                    {
                        AdminValue userValue = AdminValue.NO;
                        switch (e.TableName)
                        {
                        case "Product":
                            {
                                var obj   = currentRelease.ReleaseProducts.Count > 0 ? currentRelease.ReleaseProducts.FirstOrDefault(p => p.ProductID == e.ParameterID) : null;
                                userValue = obj != null && obj.IsChecked ? AdminValue.YES : AdminValue.NO;
                                break;
                            }

                        case "FamilyProduct":
                            {
                                var obj   = currentRelease.ReleaseFamilyProducts.Count > 0 ? currentRelease.ReleaseFamilyProducts.FirstOrDefault(p => p.FamilyProductID == e.ParameterID) : null;
                                userValue = obj != null && obj.IsChecked ? AdminValue.YES : AdminValue.NO;
                                break;
                            }

                        case "Characteristic":
                            {
                                var obj   = currentRelease.ReleaseCharacteristics.Count > 0 ? currentRelease.ReleaseCharacteristics.FirstOrDefault(p => p.CharacteristicID == e.ParameterID) : null;
                                userValue = obj != null && obj.IsChecked ? AdminValue.YES : AdminValue.NO;
                                break;
                            }

                        case "Area":
                            {
                                var obj   = currentRelease.ReleaseAreaOwners.Count > 0 ? currentRelease.ReleaseAreaOwners.FirstOrDefault(p => p.AreaID == e.ParameterID) : null;
                                userValue = obj != null && obj.IsChecked ? AdminValue.YES : AdminValue.NO;
                                break;
                            }

                        case "Stakeholder":
                            {
                                var obj   = currentRelease.ReleaseStakeholders.Count > 0 ? currentRelease.ReleaseStakeholders.FirstOrDefault(p => p.StakeholderID == e.ParameterID && p.EmployeeID1 != null) : null;
                                userValue = obj != null ? AdminValue.YES : AdminValue.NO;
                                break;
                            }

                        default:
                            break;
                        }
                        ;

                        arrQuestions.Add(new QuestionAreaView()
                        {
                            TableName     = e.TableName,
                            ParameterID   = e.ParameterID,
                            AdminValue    = e.AdminValue,
                            ParameterType = e.ParameterType,
                            QuestionID    = e.QuestionID,
                            UserValue     = userValue
                        });
                    });

                    var AddQuestion     = arrQuestions.Where(q => q.ParameterType == ParameterType.Add && (q.UserValue == AdminValue.YES && q.AdminValue == AdminValue.YES)).Select(q => q.QuestionID).Distinct();
                    var removeQuestions = arrQuestions.Where(q => q.ParameterType == ParameterType.Remove && (q.AdminValue != q.UserValue)).Select(q => q.QuestionID).Distinct();
                    ReleaseQuestion = AddQuestion.Where(q => !removeQuestions.Contains(q)).ToList();
                    //if (ReleaseQuestion.Count > 0)
                    //{

                    //}
                }
                using (IQuestionRepository db = new QuestionRepository())
                {
                    await db.SetInitiateQuestions(currentRelease, ReleaseQuestion, (WindowsPrincipal)User);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }