Ejemplo n.º 1
0
        ///<summary>Gets logs from the passed in datetime and before.</summary>
        public static List <InsEditLog> GetLogsForPlan(long planNum, long carrierNum, long employerNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <List <InsEditLog> >(MethodBase.GetCurrentMethod(), planNum, carrierNum, employerNum));
            }
            List <long> listCarrierNums = InsEditLogs.GetAssociatedCarrierNums(planNum);

            listCarrierNums.Add(carrierNum);
            List <InsEditLog> retVal  = new List <InsEditLog>();
            string            command = @"SELECT PlanNum FROM insplan WHERE PlanNum = " + POut.Long(planNum);
            long insPlanNum           = Db.GetLong(command);

            command         = @"SELECT CarrierNum FROM carrier WHERE CarrierNum IN (" + string.Join(",", listCarrierNums) + @")";
            listCarrierNums = Db.GetListLong(command);
            command         = @"SELECT EmployerNum FROM employer WHERE EmployerNum=" + POut.Long(employerNum);
            long          empNum       = Db.GetLong(command);
            List <string> listWhereOrs = new List <string>();

            if (insPlanNum > 0)
            {
                listWhereOrs.Add("(LogType=" + POut.Int((int)InsEditLogType.InsPlan) + " AND FKey = " + POut.Long(insPlanNum) + ")");
            }
            if (listCarrierNums.Count > 0)
            {
                listWhereOrs.Add("(LogType=" + POut.Int((int)InsEditLogType.Carrier) + " AND FKey IN (" + string.Join(",", listCarrierNums) + "))");
            }
            if (empNum > 0)
            {
                listWhereOrs.Add("(LogType=" + POut.Int((int)InsEditLogType.Employer) + " AND FKey=" + POut.Long(empNum) + ")");
            }
            listWhereOrs.Add("(LogType=" + POut.Int((int)InsEditLogType.Benefit) + " AND ParentKey=" + POut.Long(planNum) + ")");
            command = @"SELECT * FROM inseditlog
				WHERE "                 + string.Join(@"
				OR "                , listWhereOrs);
            List <InsEditLog> listLogs = Crud.InsEditLogCrud.SelectMany(command);           //get all of the logs

            //get any logs that show that InsPlan's PlanNum changed
            return(GetChangedLogs(listLogs).OrderBy(x => x.DateTStamp)
                   .ThenBy(x => x.LogType != InsEditLogType.InsPlan)
                   .ThenBy(x => x.LogType != InsEditLogType.Carrier)
                   .ThenBy(x => x.LogType != InsEditLogType.Employer)
                   .ThenBy(x => x.LogType != InsEditLogType.Benefit)
                   .ThenBy(x => x.FKey)
                   //primary keys first
                   .ThenBy(x => x.LogType == InsEditLogType.Benefit?(x.FieldName != "BenefitNum")
                                        :x.LogType == InsEditLogType.Carrier?(x.FieldName != "CarrierNum")
                                        :x.LogType == InsEditLogType.Employer?(x.FieldName != "EmployerNum")
                                        :(x.FieldName != "PlanNum")).ToList());
        }
Ejemplo n.º 2
0
        ///<summary>Gets logs from the passed in datetime and before.</summary>
        public static List <InsEditLog> GetLogsForPlan(long planNum, long carrierNum, long employerNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <List <InsEditLog> >(MethodBase.GetCurrentMethod(), planNum, carrierNum, employerNum));
            }
            List <long> listCarrierNums = InsEditLogs.GetAssociatedCarrierNums(planNum);

            listCarrierNums.Add(carrierNum);
            List <InsEditLog> retVal  = new List <InsEditLog>();
            string            command = @"SELECT inseditlog.* FROM inseditlog ";

            command += @"LEFT JOIN insplan ON insplan.PlanNum = inseditlog.FKey 
					AND insplan.PlanNum LIKE '"                     + POut.Long(planNum) + @"%'
					AND inseditlog.LogType = "                     + POut.Int((int)InsEditLogType.InsPlan) + @" 
				LEFT JOIN carrier ON carrier.CarrierNum = inseditlog.FKey
					AND carrier.CarrierNum IN( "                     + string.Join(",", listCarrierNums) + @")
					AND inseditlog.LogType = "                     + POut.Int((int)InsEditLogType.Carrier) + @" 
				LEFT JOIN employer ON employer.EmployerNum = inseditlog.FKey
					AND employer.EmployerNum = "                     + POut.Long(employerNum) + @"
					AND inseditlog.LogType = "                     + POut.Int((int)InsEditLogType.Employer) + @" 
				WHERE (insplan.PlanNum IS NOT NULL OR carrier.CarrierNum IS NOT NULL OR employer.EmployerNum IS NOT NULL 
					OR (inseditlog.LogType = "                     + POut.Int((int)InsEditLogType.Benefit) + " AND inseditlog.ParentKey = " + POut.Long(planNum) + "))";
            List <InsEditLog> listLogs = Crud.InsEditLogCrud.SelectMany(command);           //get all of the logs

            //get any logs that show that InsPlan's PlanNum changed
            return(GetChangedLogs(listLogs).OrderBy(x => x.DateTStamp)
                   .ThenBy(x => x.LogType != InsEditLogType.InsPlan)
                   .ThenBy(x => x.LogType != InsEditLogType.Carrier)
                   .ThenBy(x => x.LogType != InsEditLogType.Employer)
                   .ThenBy(x => x.LogType != InsEditLogType.Benefit)
                   .ThenBy(x => x.FKey)
                   //primary keys first
                   .ThenBy(x => x.LogType == InsEditLogType.Benefit ? x.FieldName != "BenefitNum"
                                        : x.LogType == InsEditLogType.Carrier ? x.FieldName != "CarrierNum"
                                        : x.LogType == InsEditLogType.Employer ? x.FieldName != "EmployerNum"
                                        : x.FieldName != "PlanNum").ToList());
        }