private static List<int> RemoveOddTimesOccuringNumbers(List<int> sequence)
        {
            var dictionary = new Dictionary<int, int>();

            foreach (var number in sequence)
            {
                if (dictionary.ContainsKey(number))
                {
                    dictionary[number]++;
                }
                else
                {
                    dictionary.Add(number, 1);
                }
            }

            foreach (var pair in dictionary)
            {
                if (pair.Value % 2 != 0)
                {
                    sequence.RemoveAll(x => x == pair.Key);
                }
            }

            return sequence;
        }
        public static GetCustomerRankQualificationsResponse GetCustomerRankQualifications(GetCustomerRankQualificationsRequest request)
        {
            // Get the rank qualifications from the API
            var apiResponse = new GetRankQualificationsResponse();
            try
            {
                var apiRequest = new GetRankQualificationsRequest
                {
                    CustomerID = request.CustomerID,
                    PeriodType = request.PeriodTypeID
                };
                if (request.RankID != null) apiRequest.RankID = (int)request.RankID;

                apiResponse = Exigo.WebService().GetRankQualifications(apiRequest);

                if(apiResponse == null || apiResponse.RankID == 0)
                {
                    return new GetCustomerRankQualificationsResponse()
                    {
                        IsUnavailable = true,
                        ErrorMessage = "UNAVAILABLE"
                    };
                }
            }
            catch(Exception exception)
            {
                return new GetCustomerRankQualificationsResponse()
                {
                    IsUnavailable = exception.Message.ToUpper().Contains("UNAVAILABLE"),
                    ErrorMessage = exception.Message
                };
            }

            // Create the response
            var response = new GetCustomerRankQualificationsResponse()
            {
                TotalPercentComplete = apiResponse.Score,
                IsQualified          = (apiResponse.Qualifies || (apiResponse.QualifiesOverride != null && ((bool)apiResponse.QualifiesOverride) == true)),
                Rank                 = new Rank()
                {
                    RankID           = apiResponse.RankID,
                    RankDescription  = apiResponse.RankDescription
                }
            };
            if (apiResponse.BackRankID != null)
            {
                response.PreviousRank = new Rank()
                {
                    RankID          = (int)apiResponse.BackRankID,
                    RankDescription = apiResponse.BackRankDescription
                };
            }
            if (apiResponse.NextRankID != null)
            {
                response.NextRank = new Rank()
                {
                    RankID          = (int)apiResponse.NextRankID,
                    RankDescription = apiResponse.NextRankDescription
                };
            }

            // Loop through each leg and create our responses
            var legs = new List<RankQualificationLeg>();
            foreach (var qualificationLeg in apiResponse.PayeeQualificationLegs)
            {
                var leg = new RankQualificationLeg();

                // Assemble the requirements
                var results = new List<RankRequirement>();
                foreach (var definition in RankQualificationDefinitions)
                {
                    var requirement = GetRequirement(qualificationLeg, definition);
                    if (requirement != null)
                    {
                        requirement.RequirementDescription  = GlobalUtilities.MergeFields(requirement.RequirementDescription, requirement, "UNABLE TO MERGE FIELDS");
                        requirement.QualifiedDescription    = GlobalUtilities.MergeFields(requirement.QualifiedDescription, requirement, "UNABLE TO MERGE FIELDS");
                        requirement.NotQualifiedDescription = GlobalUtilities.MergeFields(requirement.NotQualifiedDescription, requirement, "UNABLE TO MERGE FIELDS");

                        results.Add(requirement);
                    }
                }

                // Clean up nulls
                results.RemoveAll(c => string.IsNullOrEmpty(c.RequiredValue));
                leg.Requirements = results;

                legs.Add(leg);
            }
            response.QualificationLegs = legs;

            return response;
        }
        //r
        /// <summary>
        /// This method deletes questions
        /// </summary>
        /// <param name="oListQuestion"> It takes List<Question> Object </param>
        /// <param name="iarrChecked"> It takes integer array indicates the marked questions </param>
        /// <returns> It returns Result Object </returns>
        public Result DeleteQuestionList(List<Question> oListQuestion, int[] iarrChecked)
        {
            logger.Info("Start DeleteQuestionList QuestionDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            List<String> oListString = new List<String>();
            String sDelete = String.Empty;

            List<Question> oListQuestion1 = new List<Question>();

            int i = 0;

            try
            {
                for (i = 0; i < iarrChecked.Length; i++)
                {
                    if (iarrChecked[i] == 1 && !oListQuestion[i].QuestionIsUsed)
                    {
                        // Before delete, check that, is it used at the time of SETUP Question.
                        // If it is used, then u cannot delete it.

                        if (oListQuestion[i].QuestionQuestionType.QuestionTypeID==1)
                        {
                            sDelete = "delete from EX_Question where QuestionID='" + oListQuestion[i].QuestionID + "'";
                            oListQuestion1.Add(null);
                            oListString.Add(sDelete);

                        }
                        else
                        {
                            //first delete from EX_Objective, then from EX_Question
                            sDelete = "delete from EX_Objective where ObjectiveQuestionID='" + oListQuestion[i].QuestionID+"'";
                            oListString.Add(sDelete);
                            //sDelete = "delete from EX_Question where QuestionID='" + oListQuestion[i].QuestionID + "' and QuestionTypeName='" + oListQuestion[i].QuestionObjectiveType.TypeName + "'";
                            sDelete = "delete from EX_Question where QuestionID='" + oListQuestion[i].QuestionID + "'";
                            oListQuestion1.Add(null);
                            oListString.Add(sDelete);
                        }

                    }
                    else
                    {
                        oListQuestion1.Add(oListQuestion[i]);
                    }
                }

                oListQuestion1.RemoveAll(delegate(Question oQuestion) { if (oQuestion != null) { return false; } return true; });

                if (oDAOUtil.ExecuteNonQuery(oListString))
                {
                    oResult.ResultObject = oListQuestion1;

                    if (oListQuestion1.Count < oListQuestion.Count)
                    {
                        oResult.ResultMessage = "Question Delete Success...";
                    }
                    else if(oListQuestion1.Count==oListQuestion.Count)
                    {
                        oResult.ResultMessage = "Your selected questions are used...";
                    }

                    oResult.ResultIsSuccess = true;
                }
                else
                {
                    oResult.ResultIsSuccess = false;
                    oResult.ResultMessage = "Question Delete Failed...";
                }
            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultException = oEx;
                oResult.ResultMessage = "Exception occured during Question Delete...";

                logger.Info("Exception DeleteQuestionList QuestionDAO+DAO", oEx);
            }

            logger.Info("End DeleteQuestionList QuestionDAO+DAO");

            return oResult;
        }
        /// <summary>
        /// This method remove the selected questions for an exam 
        /// </summary>
        /// <param name="oListQuestionSetup"> It takes List<QuestionSetup> Object </param>
        /// <param name="iarrChecked"> It takes integer array to indicates the marked questions </param>
        /// <returns> It returns Result Object </returns>
        public Result QuestionSetupRemove(List<QuestionSetup> oListQuestionSetup, int[] iarrChecked)
        {
            logger.Info("Start QuestionSetupRemove QuestionDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            List<String> oListString = new List<String>();
            String sDelete = String.Empty;

            List<QuestionSetup> oListQuestionSetup1 = new List<QuestionSetup>();

            try
            {
                int i = 0;

                for (i = 0; i < iarrChecked.Length; i++)
                {
                    if (iarrChecked[i] == 1)
                    {
                        sDelete = "delete from EX_QuestionGeneration where ExamID='" + oListQuestionSetup[i].QuestionSetupExam.ExamID + "' and QuestionID='" + oListQuestionSetup[i].QuestionSetupQuestion.QuestionID + "' and GeneratorID='" + oListQuestionSetup[i].QuestionSetupSystemUser.SystemUserID + "'";
                        oListQuestionSetup1.Add(null);
                        oListString.Add(sDelete);
                    }
                    else
                    {
                        oListQuestionSetup1.Add(oListQuestionSetup[i]);
                    }
                }

                oListQuestionSetup1.RemoveAll(delegate(QuestionSetup oQuestionSetup) { if (oQuestionSetup != null) { return false; } return true; });

                if (oDAOUtil.ExecuteNonQuery(oListString))
                {
                    oResult.ResultObject = oListQuestionSetup1;
                    oResult.ResultMessage = "Question Setup Remove Success...";
                    oResult.ResultIsSuccess = true;
                }
                else
                {
                    oResult.ResultIsSuccess = false;
                    oResult.ResultMessage = "Question Setup Remove Failed...";
                }
            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultMessage = "Exception occured during Question Setup Remove...";
                oResult.ResultException = oEx;

                logger.Info("Exception QuestionSetupRemove QuestionDAO+DAO", oEx);
            }

            logger.Info("End QuestionSetupRemove QuestionDAO+DAO");

            return oResult;
        }
        /// <summary>
        /// This method update the systemuser delete time, indicating that, the systemuser is deleted.
        /// </summary>
        /// <param name="oListSystemUser"> It takes List<SystemUser> Object </param>
        /// <param name="iArrCheck"> It takes integer array which indicates the marked system user</param>
        /// <returns> It returns Result Object </returns>
        public Result SystemUserDelete(List<SystemUser> oListSystemUser, int[] iArrCheck)
        {
            logger.Info("Start SystemUserDelete SystemUserDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            List<SystemUser> oListSystemUser1 = new List<SystemUser>();

            List<String> oListString = new List<String>();

            String sUpdate = String.Empty;

            int i = 0;

            try
            {
                for (i = 0; i < iArrCheck.Length; i++)
                {
                    if (iArrCheck[i] == 1)
                    {
                        sUpdate = "update EX_SystemUser set DeleteTime='" + DateTime.Now + "' where SystemUserID='" + oListSystemUser[i].SystemUserID + "'";
                        oListString.Add(sUpdate);
                        oListSystemUser1.Add(null);
                    }
                    else
                    {
                        oListSystemUser1.Add(oListSystemUser[i]);
                    }
                }

                oListSystemUser1.RemoveAll(delegate(SystemUser oSystemUser) { if (oSystemUser != null) { return false; } return true; });

                if (oDAOUtil.ExecuteNonQuery(oListString))
                {
                    oResult.ResultObject = oListSystemUser1;
                    oResult.ResultMessage = "System User Delete Success...";
                    oResult.ResultIsSuccess = true;
                }
                else
                {
                    oResult.ResultIsSuccess = false;
                    oResult.ResultMessage = "System User Delete Failed...";
                }
            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultException = oEx;
                oResult.ResultMessage = "Exception occured during System User Delete...";

                logger.Info("Exception SystemUserDelete SystemUserDAO+DAO", oEx);
            }

            logger.Info("End SystemUserDelete SystemUserDAO+DAO");

            return oResult;
        }
Exemplo n.º 6
0
        public List<Player> GetRangedPlayer(Object Obj, int Range)
        {
            List<Player> Objs = new List<Player>();
            if (!Obj.IsInWorld())
                return Objs;

            List<CellMgr> Cells = GetCells(Obj.XOffset, Obj.YOffset, Range);
            foreach (CellMgr Cell in Cells)
                Objs.AddRange(Cell._Players);

            Objs.RemoveAll(Dist => Dist != null && Obj.GetDistanceTo(Dist) > MAX_VISIBILITY_RANGE);

            return Objs;
        }
        /// <summary>
        /// This Method remove a candidate if he has not appeared for an exam. 
        /// </summary>
        /// <param name="oListCandidateForExam"> It takes List<CandidateForExam> Object </param>
        /// <param name="iArrCheck"> It is an array of Integer which indicates the marked candidates to remove</param>
        /// <returns> It returns Result Object </returns>
        public Result RemoveCandidate(List<CandidateForExam> oListCandidateForExam, int[] iArrCheck)
        {
            //new CLogger("Start RemoveCandidate CandidateDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Start RemoveCandidate CandidateDAO+DAO", ELogLevel.Debug);

            logger.Info("Start RemoveCandidate CandidateDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            List<CandidateForExam> oListCandidateForExam1 = new List<CandidateForExam>();

            List<String> oListString = new List<String>();

            String sDelete = String.Empty;

            int i=0;

            try
            {
                for (i = 0; i < iArrCheck.Length; i++)
                {
                    if (iArrCheck[i] == 1)
                    {
                        sDelete = "delete from EX_CandidateForExam where"
                        + " EX_CandidateForExam.ExamID='" + oListCandidateForExam[i].CadidateCandidateExam.CandiadteExamExam.ExamID + "'"
                        + " and EX_CandidateForExam.CandidateID='" + oListCandidateForExam[i].CandidateForExamCandidate.CandidateCompositeID + "'"
                        + " and EX_CandidateForExam.CandidateID not in (select EX_CandidateExam.CandidateID"
                        + " from EX_CandidateExam where EX_CandidateExam.ExamID='" + oListCandidateForExam[i].CadidateCandidateExam.CandiadteExamExam.ExamID + "'"
                        + " and EX_CandidateExam.CandidateID='" + oListCandidateForExam[i].CandidateForExamCandidate.CandidateCompositeID + "')"
                        + " ; delete from EX_Candidate where CompositeCandidateID='" + oListCandidateForExam[i].CandidateForExamCandidate.CandidateCompositeID + "'"
                        + " and CompositeCandidateID not in"
                        + " (select CandidateID from EX_CandidateForExam where CandidateID='" + oListCandidateForExam[i].CandidateForExamCandidate.CandidateCompositeID + "')";

                        oListString.Add(sDelete);

                        oListCandidateForExam1.Add(null);
                    }
                    else
                    {
                        oListCandidateForExam1.Add(oListCandidateForExam[i]);
                    }
                }

                oListCandidateForExam1.RemoveAll(delegate(CandidateForExam oCandidateForExam) { if (oCandidateForExam != null) { return false; } return true; });

                if (oDAOUtil.ExecuteNonQuery(oListString))
                {
                    oResult.ResultObject = oListCandidateForExam1;
                    oResult.ResultMessage = "Candidate Remove Success...";
                    oResult.ResultIsSuccess = true;
                }
                else
                {
                    oResult.ResultIsSuccess = false;
                    oResult.ResultMessage = "Candidate Delete Failed...";
                }
            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultException = oEx;
                oResult.ResultMessage = "Exception occured during Candidate Remove...";

                logger.Info("Exception RemoveCandidate CandidateDAO+DAO", oEx);

                //new CLogger("Exception RemoveCandidate CandidateDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Exception RemoveCandidate CandidateDAO+DAO", ELogLevel.Debug, oEx);
            }

            //new CLogger("Out RemoveCandidate CandidateDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Out RemoveCandidate CandidateDAO+DAO", ELogLevel.Debug);

            logger.Info("End RemoveCandidate CandidateDAO+DAO");

            return oResult;
        }