public static List <Inspection> GetInspections(UserAccess UA) { string query = @" SELECT RBL ,RME ,REL ,RPL ,CBL ,CME ,CEL ,CPL ,Fire ,LookupKey ,AddressNumber ,StreetName ,ProjClass ,ProjPreDir ,ProjPostDir ,StreetAddressCombined ,City ,Zip ,InspectorName ,Color ,InspectionDescription ,PermitNo ,ResultADC ,InspectionCode ,ScheduledDate ,MasterPermitNumber ,PropUseInfo ,ParcelNo ,InspReqID ,InspDateTime ,Project_Address_X ,Project_Address_Y ,Parcel_Centroid_X ,Parcel_Centroid_Y ,IsCommercial ,PrivateProviderInspectionRequestId ,NTUsername ,Sort_Order ,PreviousInspectionRemarks FROM WATSC.dbo.vwInspectionViewList ORDER BY LTRIM(RTRIM(InspectorName)) ASC, ISNULL(Sort_Order, 0) ASC, StreetName, ProjClass, ProjPreDir, ProjPostDir, AddressNumber"; try { var li = Constants.Get_Data <Inspection>(query, Constants.csWATSC); int badPointCount = 0; if (UA.current_access == UserAccess.access_type.contract_access) { var contractors = Inspector.GetCachedContractInspectors(); var names = (from c in contractors select c.Name).ToList().Distinct(); li.RemoveAll((i) => !names.Contains(i.InspectorName)); } foreach (Inspection i in li) { i.myInspection = (i.NTUsername.Length > 0 && UA.user_name.ToLower() == i.NTUsername.ToLower()); i.AddressPoint = new Point(i.Project_Address_X, i.Project_Address_Y); i.ParcelPoint = new Point(i.Parcel_Centroid_X, i.Parcel_Centroid_Y); i.PointToUse = i.AddressPoint.IsValid ? i.AddressPoint : i.ParcelPoint; if (!i.PointToUse.IsValid) { i.PointToUse = new Point(440000, 2100000 - (25 * badPointCount)); badPointCount += 1; } if (UA.current_access == UserAccess.access_type.inspector_access || UA.current_access == UserAccess.access_type.admin_access) { if (i.ResultADC == "") { i.CanBeAssigned = true; } } } return(li); } catch (Exception ex) { new ErrorLog(ex, query); return(null); } }
public Inspector Insert() { string sql = @" INSERT INTO bp_INSPECTORS ( PhoneNbr, Name, Intl, Active, Vehicle, RBL, CBL, REL, CEL, RME, CME, RPL, CPL, PrivateProvider, Fire, Color ) VALUES ( '', @Name, @Intl, @Active, @Vehicle, @RBL, @CBL, @REL, @CEL, @RME, @CME, @RPL, @CPL, @PrivateProvider, @Fire, @Color ); SELECT id, Active, Intl, LTRIM(RTRIM(Name)) Name, ISNULL(Color, '') Color, Vehicle, RBL, CBL, REL, CEL, RME, CME, RPL, CPL, PrivateProvider, Fire FROM bp_INSPECTORS WHERE Id = @@IDENTITY;"; var inspectors = Constants.Get_Data <Inspector>(sql, this, Constants.csWATSC); if (inspectors.Count() == 1) { Inspector.UpdateInspectorCache(); return(inspectors.First()); } return(null); }