Exemple #1
0
        public IList <FollowUpGroup> GetParticipantsByLoginUser(int eventid, PHSUser loginuser, out string message)
        {
            message = string.Empty;
            using (var unitOfWork = CreateUnitOfWork())
            {
                var result         = new List <FollowUpGroup>();
                var followupconfig = unitOfWork.FollowUpConfigurations.GetDeployedFollowUpConfiguration(eventid);
                if (followupconfig == null)
                {
                    message = "No follow-up configuration is deployed!!";
                    return(result);
                }
                if (loginuser.Role == Constants.User_Role_FollowUpCommitteeMember_Code)
                {
                    return(followupconfig.FollowUpGroups.ToList());
                }
                else if (loginuser.Role == Constants.User_Role_FollowUpVolunteer_Code ||
                         loginuser.Role == Constants.User_Role_CommitteeMember_Code)
                {
                    var followupgroups = followupconfig.FollowUpGroups;

                    if (followupgroups.Count > 0)
                    {
                        foreach (var item in followupgroups)
                        {
                            var resultfollowupgroup          = new FollowUpGroup();
                            var resultparticipantcallmaplist = new List <ParticipantCallerMapping>();
                            foreach (var map in item.ParticipantCallerMappings)
                            {
                                if (map.PhaseIFollowUpVolunteer == loginuser.FullName ||
                                    map.PhaseIIFollowUpVolunteer == loginuser.FullName ||
                                    map.PhaseICommitteeMember == loginuser.FullName ||
                                    map.PhaseIICommitteeMember == loginuser.FullName)
                                {
                                    resultparticipantcallmaplist.Add(map);
                                }
                            }
                            resultfollowupgroup.ParticipantCallerMappings = resultparticipantcallmaplist;
                            result.Add(resultfollowupgroup);
                        }
                    }
                    else
                    {
                        message = "No follow-up group present!!";
                    }
                }
                return(result);
            }
        }
Exemple #2
0
        private string HandlePhaseIVolunteer(IUnitOfWork unitOfWork, string message, FollowUpGroup followupgroup, List <string> phaseOneVolunteers, int phaseOneVolunteerCount, int numberofparticipant)
        {
            if (numberofparticipant <= phaseOneVolunteerCount)
            {
                for (var count = 0; count < numberofparticipant; count++)
                {
                    var participantcallermapping = followupgroup.ParticipantCallerMappings.ElementAt(count);
                    try
                    {
                        var toupdate = unitOfWork.ParticipantCallerMappings.Get(participantcallermapping.ParticipantCallerMappingID);
                        //Util.CopyNonNullProperty(participantcallermapping, toupdate);
                        toupdate.PhaseIFollowUpVolunteer = phaseOneVolunteers[count];
                    }
                    catch (Exception ex)
                    {
                        ExceptionLog(ex);
                        message = Constants.OperationFailedDuringUpdatingValue("ParticipantCallerMappings");
                    }
                }
            }
            else
            {
                var ratio   = numberofparticipant / phaseOneVolunteerCount;
                int iCaller = 0;
                for (var count = 1; count <= numberofparticipant; count++)
                {
                    var participantcallermapping = followupgroup.ParticipantCallerMappings.ElementAt(count - 1);
                    try
                    {
                        var toupdate = unitOfWork.ParticipantCallerMappings.Get(participantcallermapping.ParticipantCallerMappingID);
                        //Util.CopyNonNullProperty(participantcallermapping, toupdate);
                        toupdate.PhaseIFollowUpVolunteer = phaseOneVolunteers[iCaller];
                    }
                    catch (Exception ex)
                    {
                        ExceptionLog(ex);
                        message = Constants.OperationFailedDuringUpdatingValue("ParticipantCallerMappings");
                    }
                    if (count % ratio == 0 && iCaller + 1 < phaseOneVolunteerCount)
                    {
                        ++iCaller;
                    }
                }
            }

            return(message);
        }
Exemple #3
0
        public ActionResult CreateFollowUpGroup(int followUpConfigurationID)
        {
            string message = string.Empty;

            using (var followUpConfigurationManager = new FollowUpConfigurationManager())
            {
                FollowUpConfiguration followupconfiguration = followUpConfigurationManager.GetFUConfigurationByID(followUpConfigurationID, out message);
                if (followupconfiguration == null)
                {
                    SetViewBagError("Invalid Follow-Up Configuratio ID. Create Follow-Up Configuration first.");
                    return(View());
                }
                FollowUpGroup followupgroup = new FollowUpGroup();
                followupgroup.FollowUpConfigurationID = followUpConfigurationID;

                return(View(followupgroup));
            }
        }
Exemple #4
0
        public ActionResult CreateFollowUpGroup([Bind(Exclude = "FollowUpGroupID")] FollowUpGroup followupgroup)
        {
            string message = string.Empty;

            using (var followUpConfigurationManager = new FollowUpConfigurationManager(GetLoginUser()))
            {
                followupgroup.Filter = "TESTFilter";
                var newFollowupgroup = followUpConfigurationManager.AddFollowUpGroup(followupgroup, out message);
                if (newFollowupgroup == null)
                {
                    SetViewBagError(message);
                    return(View(followupgroup));
                }

                SetTempDataMessage(Constants.ValueSuccessfuly("Follow-up group " + newFollowupgroup.Title + " has been added"));
                return(View(newFollowupgroup));
            }
        }
Exemple #5
0
        public void ImportCallerTest_NoRecords()
        {
            string message = string.Empty;

            PHSEvent phsEvent = new PHSEvent()
            {
                Title    = "Test",
                Venue    = "Test",
                StartDT  = DateTime.Now.AddDays(-1),
                EndDT    = DateTime.Now.AddDays(1),
                IsActive = true
            };

            FollowUpConfiguration followUpConfiguration = new FollowUpConfiguration()
            {
                Title      = "Test Configuration",
                PHSEventID = 1,
                Deploy     = true
            };

            FollowUpGroup followUpGroup = new FollowUpGroup()
            {
                Title = "Test Group"
            };

            followUpConfiguration.FollowUpGroups.Add(followUpGroup);

            phsEvent.FollowUpConfigurations.Add(followUpConfiguration);

            _unitOfWork.Events.Add(phsEvent);

            _unitOfWork.Complete();

            var projectFolder = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
            var file          = Path.Combine(projectFolder, @"Files\no data file.xlsx");

            byte[] bytes = System.IO.File.ReadAllBytes(file);
            _target.ImportCaller(bytes, 1, out message);

            Assert.AreEqual("No Volunteers/Comm Members found.", message);
        }
        public void AddFollowUpGroupTest_Success()
        {
            PHSEvent phsEvent = new PHSEvent()
            {
                Title    = "Test",
                Venue    = "Test",
                StartDT  = DateTime.Now.AddDays(-1),
                EndDT    = DateTime.Now.AddDays(1),
                IsActive = true
            };

            FollowUpConfiguration followUpConfiguration = new FollowUpConfiguration()
            {
                Title      = "Test Configuration",
                PHSEventID = 1,
                Deploy     = false
            };

            phsEvent.FollowUpConfigurations.Add(followUpConfiguration);

            _unitOfWork.Events.Add(phsEvent);

            _unitOfWork.Complete();

            FollowUpGroup followUpGroup = new FollowUpGroup()
            {
                Title = "Test Group",
                FollowUpConfigurationID = 1
            };

            string message = string.Empty;

            var result = _target.AddFollowUpGroup(followUpGroup, out message);

            Assert.IsNotNull(result);
            Assert.AreEqual("Test Group", result.Title);
        }
Exemple #7
0
        public FollowUpGroup AddFollowUpGroup(FollowUpGroup followupgroup, out string message)
        {
            message = string.Empty;
            if (followupgroup == null)
            {
                message = Constants.PleaseFillInAllRequiredFields();
                return(null);
            }
            if (string.IsNullOrEmpty(followupgroup.Title) || string.IsNullOrEmpty(followupgroup.Title.Trim()))
            {
                message = Constants.PleaseFillInAllRequiredFields();
                return(null);
            }

            try
            {
                using (var unitOfWork = CreateUnitOfWork())
                {
                    unitOfWork.FollowUpGroups.Add(followupgroup);

                    using (TransactionScope scope = new TransactionScope())
                    {
                        unitOfWork.Complete();
                        scope.Complete();
                    }
                    message = string.Empty;
                    return(followupgroup);
                }
            }
            catch (Exception ex)
            {
                ExceptionLog(ex);
                message = Constants.OperationFailedDuringAddingValue("Follow Up Group");
                return(null);
            }
        }
Exemple #8
0
        public IList <FollowUpGroup> GetParticipantsByFollowUpConfiguration(int followupconfigurationid, out string message)
        {
            message = string.Empty;
            var result         = new List <FollowUpGroup>();
            var followupconfig = GetFollowUpConfiguration(followupconfigurationid);

            if (followupconfig == null)
            {
                message = "Follow-up configuration does not exist!";
                return(result);
            }

            if (followupconfig.Deploy)
            {
                result = followupconfig.FollowUpGroups.ToList();
                return(result);
            }

            var followupgroups = followupconfig.FollowUpGroups;

            if (followupgroups.Count <= 0)
            {
                message = "No follow-up groups found.";
                return(result);
            }

            var eventid = followupconfig.PHSEventID;
            var finalgroupparticipants = GetAllParticipants(eventid);

            foreach (var item in followupgroups)
            {
                using (var unitOfWork = CreateUnitOfWork())
                {
                    var participantCallerMappingList = new List <ParticipantCallerMapping>();
                    //testing
                    //var participantsbygroup = unitOfWork.Participants.FindParticipants(p => p.Language == "Mandarin" && p.PHSEvents.Any(e => e.PHSEventID == eventid));

                    /*BMI : "3#19#35#36#470#==#25.0"*/ /*"BP : 3#19#35#36#466#==#100"*/
                    var participantsbygroup = unitOfWork.Participants.SearchParticipants(item.Filter).ToList();
                    //var participantsbygroup = SearchParticipants(item.Filter);

                    //avoid overlapping participants
                    var intersectresult = finalgroupparticipants.Where(a => participantsbygroup.Select(b => b.ParticipantID).Contains(a.ParticipantID)).ToList();
                    participantsbygroup = intersectresult;
                    var exceptresult = finalgroupparticipants.Where(a => !participantsbygroup.Select(b => b.ParticipantID).Contains(a.ParticipantID)).ToList();
                    finalgroupparticipants = exceptresult;

                    foreach (var participant in participantsbygroup)
                    {
                        var participantcallermapping = new ParticipantCallerMapping();
                        participantcallermapping.Participant = participant;
                        participantCallerMappingList.Add(participantcallermapping);
                    }
                    item.ParticipantCallerMappings = participantCallerMappingList;
                    result.Add(item);
                }
            }
            var endfugroup = new FollowUpGroup();
            var endparticipantCallerMappingList = new List <ParticipantCallerMapping>();

            foreach (var participant in finalgroupparticipants.ToList())
            {
                var endparticipantcallermapping = new ParticipantCallerMapping();
                endparticipantcallermapping.Participant = participant;
                endparticipantCallerMappingList.Add(endparticipantcallermapping);
            }
            endfugroup.Title = "No Group Participants";
            endfugroup.ParticipantCallerMappings = endparticipantCallerMappingList;
            result.Add(endfugroup);

            return(result);
        }
Exemple #9
0
        private string HandlePhaseIICommMembers(IUnitOfWork unitOfWork, string message, FollowUpGroup followupgroup, List <string> phaseTwoCommMembers, int phaseTwoCommMemberCount, int numberofparticipant)
        {
            if (numberofparticipant <= phaseTwoCommMemberCount)
            {
                for (var count = 0; count < numberofparticipant; count++)
                {
                    var participantcallermapping = followupgroup.ParticipantCallerMappings.ElementAt(count);
                    try
                    {
                        var toupdate = unitOfWork.ParticipantCallerMappings.Get(participantcallermapping.ParticipantCallerMappingID);
                        //Util.CopyNonNullProperty(participantcallermapping, toupdate);
                        toupdate.PhaseIICommitteeMember = phaseTwoCommMembers[count];
                    }
                    catch (Exception ex)
                    {
                        ExceptionLog(ex);
                        message = Constants.OperationFailedDuringUpdatingValue("ParticipantCallerMappings");
                    }
                }

                if (string.IsNullOrEmpty(message))
                {
                    using (TransactionScope scope = new TransactionScope())
                    {
                        unitOfWork.Complete();
                        scope.Complete();
                    }
                }
            }
            else
            {
                var ratio       = numberofparticipant / phaseTwoCommMemberCount;
                int icommmember = 0;
                for (var count = 1; count <= numberofparticipant; count++)
                {
                    var participantcallermapping = followupgroup.ParticipantCallerMappings.ElementAt(count - 1);
                    try
                    {
                        var toupdate = unitOfWork.ParticipantCallerMappings.Get(participantcallermapping.ParticipantCallerMappingID);
                        //Util.CopyNonNullProperty(participantcallermapping, toupdate);
                        toupdate.PhaseIICommitteeMember = phaseTwoCommMembers[icommmember];
                    }

                    catch (Exception ex)
                    {
                        ExceptionLog(ex);
                        message = Constants.OperationFailedDuringUpdatingValue("ParticipantCallerMappings");
                    }

                    if (count % ratio == 0 && icommmember + 1 < phaseTwoCommMemberCount)
                    {
                        ++icommmember;
                    }
                }
            }


            return(message);
        }
Exemple #10
0
        private DataTable CreateDataTable(FollowUpGroup followUpGroup)
        {
            var dt = new DataTable(followUpGroup.Title);

            dt.Columns.Add(new DataColumn("NRIC"));
            dt.Columns.Add(new DataColumn("Salutation"));
            dt.Columns.Add(new DataColumn("FullName"));
            dt.Columns.Add(new DataColumn("Language"));
            dt.Columns.Add(new DataColumn("Contact"));

            dt.Columns.Add(new DataColumn("Phase I Follow-up Volunteer"));
            dt.Columns.Add(new DataColumn("Phase I Follow-up Volunteer Call Status"));
            dt.Columns.Add(new DataColumn("Phase I Follow-up Volunteer Call Date"));
            dt.Columns.Add(new DataColumn("Phase I Follow-up Volunteer Remarks"));

            dt.Columns.Add(new DataColumn("Phase I Committee Member"));
            dt.Columns.Add(new DataColumn("Phase I Committee Member Call Status"));
            dt.Columns.Add(new DataColumn("Phase I Committee Member Call Date"));
            dt.Columns.Add(new DataColumn("Phase I Committee Member Remarks"));

            dt.Columns.Add(new DataColumn("Phase II Follow-up Volunteer"));
            dt.Columns.Add(new DataColumn("Phase II Follow-up Volunteer Call Status"));
            dt.Columns.Add(new DataColumn("Phase II Follow-up Volunteer Call Date"));
            dt.Columns.Add(new DataColumn("Phase II Follow-up Volunteer Remarks"));

            dt.Columns.Add(new DataColumn("Phase II Committee Member"));
            dt.Columns.Add(new DataColumn("Phase II Committee Member Call Status"));
            dt.Columns.Add(new DataColumn("Phase II Committee Member Call Date"));
            dt.Columns.Add(new DataColumn("Phase II Committee Member Remarks"));

            foreach (var item in followUpGroup.ParticipantCallerMappings)
            {
                DataRow row = dt.NewRow();
                row[0] = item.Participant.Nric;
                row[1] = item.Participant.Salutation;
                row[2] = item.Participant.FullName;
                row[3] = item.Participant.Language;
                row[4] = item.Participant.MobileNumber;

                row[5] = item.PhaseIFollowUpVolunteer;
                row[6] = item.PhaseIFollowUpVolunteerCallStatus;
                row[7] = item.PhaseIFollowUpVolunteerCallDateTime;
                row[8] = item.PhaseIFollowUpVolunteerCallRemark;

                row[9]  = item.PhaseICommitteeMember;
                row[10] = item.PhaseICommitteeMemberCallStatus;
                row[11] = item.PhaseICommitteeMemberCallDateTime;
                row[12] = item.PhaseICommitteeMemberCallRemark;

                row[13] = item.PhaseIIFollowUpVolunteer;
                row[14] = item.PhaseIIFollowUpVolunteerCallStatus;
                row[15] = item.PhaseIIFollowUpVolunteerCallDateTime;
                row[16] = item.PhaseIIFollowUpVolunteerCallRemark;

                row[17] = item.PhaseIICommitteeMember;
                row[18] = item.PhaseIICommitteeMemberCallStatus;
                row[19] = item.PhaseIICommitteeMemberCallDateTime;
                row[20] = item.PhaseIICommitteeMemberCallRemark;

                dt.Rows.Add(row);
            }


            DataView dv = new DataView(dt);

            return(dv.ToTable());
        }