public object FindbyColumnIDs(IConnectToDB _Connect, string objectlayer, string _column, List <string> _ids) { DataTable dt = new DataTable(); DictionaryHelper dictionary; switch (objectlayer.ToLower()) { case "object": case "objects": ObjectsHelper objects = new ObjectsHelper(); dt = objects.FindbyColumnIDs(_Connect, _column, _ids); break; case "identity": case "identities": case "id": IdentityHelper identity = new IdentityHelper(); dt = identity.FindbyColumnIDs(_Connect, _column, _ids); break; case "core": case "cores": CoreHelper core = new CoreHelper(); dt = core.FindbyColumnIDs(_Connect, _column, _ids); break; case "application": case "applications": AppHelper application = new AppHelper(); dt = application.FindbyColumnIDs(_Connect, _column, _ids); break; case "stage": case "stages": StagesHelper stages = new StagesHelper(); dt = stages.FindbyColumnIDs(_Connect, _column, _ids); break; case "grip": case "grips": GripsHelper grips = new GripsHelper(); dt = grips.FindbyColumnIDs(_Connect, _column, _ids); break; case "objectset": case "objectsets": ObjectSetsHelper objectsets = new ObjectSetsHelper(); dt = objectsets.FindbyColumnIDs(_Connect, _column, _ids); break; case "objectpropset": case "objectpropsets": ObjectPropSetsHelper objectpropsets = new ObjectPropSetsHelper(); dt = objectpropsets.FindbyColumnIDs(_Connect, _column, _ids); break; case "tables": case "table": dictionary = new DictionaryHelper(); dt = dictionary.FindbyColumnIDs(_Connect, "tables", _column, _ids); break; case "views": case "view": dictionary = new DictionaryHelper(); dt = dictionary.FindbyColumnIDs(_Connect, "views", _column, _ids); break; case "primary": case "primary keys": case "primary key": case "pk": case "pkey": case "pkeys": dictionary = new DictionaryHelper(); dt = dictionary.FindbyColumnIDs(_Connect, "pkeys", _column, _ids); break; case "foreign": case "foreign keys": case "foreign key": case "fk": case "fkey": case "fkeys": dictionary = new DictionaryHelper(); dt = dictionary.FindbyColumnIDs(_Connect, "fkeys", _column, _ids); break; case "unqiue": case "unqiue keys": case "unqiue key": case "uk": case "ukey": case "ukeys": dictionary = new DictionaryHelper(); dt = dictionary.FindbyColumnIDs(_Connect, "ukeys", _column, _ids); break; } ConvertData jsonstring = new ConvertData(); var json = jsonstring.ConvertDataTabletoString(dt); var myojb = new object(); object myObjs = new object(); switch (objectlayer) { case "object": case "objects": myojb = new ViewObjectModel(); List <ViewObjectModel> myObjsObjects = new List <ViewObjectModel>(); myObjsObjects = JsonConvert.DeserializeObject <List <ViewObjectModel> >(json); myObjs = myObjsObjects; break; case "identity": case "identities": case "id": myojb = new ViewIdentityModel(); List <ViewIdentityModel> myID = new List <ViewIdentityModel>(); myID = JsonConvert.DeserializeObject <List <ViewIdentityModel> >(json); myObjs = myID; break; case "core": case "cores": myojb = new ViewCoreModel(); List <ViewCoreModel> myObjsCore = new List <ViewCoreModel>(); myObjsCore = JsonConvert.DeserializeObject <List <ViewCoreModel> >(json); myObjs = myObjsCore; break; case "application": case "applications": myojb = new ViewApplicationModel(); List <ViewApplicationModel> myObjsApplication = new List <ViewApplicationModel>(); myObjsApplication = JsonConvert.DeserializeObject <List <ViewApplicationModel> >(json); myObjs = myObjsApplication; break; case "stage": case "stages": myojb = new ViewStageModel(); List <ViewStageModel> myObjsStage = new List <ViewStageModel>(); myObjsStage = JsonConvert.DeserializeObject <List <ViewStageModel> >(json); myObjs = myObjsStage; break; case "grip": case "grips": myojb = new ViewGripModel(); List <ViewGripModel> myObjsGrip = new List <ViewGripModel>(); myObjsGrip = JsonConvert.DeserializeObject <List <ViewGripModel> >(json); myObjs = myObjsGrip; break; case "objectset": case "objectsets": myojb = new ViewObjectSetModel(); List <ViewObjectSetModel> myObjsObjectSets = new List <ViewObjectSetModel>(); myObjsObjectSets = JsonConvert.DeserializeObject <List <ViewObjectSetModel> >(json); myObjs = myObjsObjectSets; break; case "objectpropset": case "objectpropsets": myojb = new ViewObjectPropSetsModel(); List <ViewObjectPropSetsModel> myObjsObjectPropSets = new List <ViewObjectPropSetsModel>(); myObjsObjectPropSets = JsonConvert.DeserializeObject <List <ViewObjectPropSetsModel> >(json); myObjs = myObjsObjectPropSets; break; case "tables": case "table": myojb = new ViewTablesDictionary(); List <ViewTablesDictionary> myTableDictionary = new List <ViewTablesDictionary>(); myTableDictionary = JsonConvert.DeserializeObject <List <ViewTablesDictionary> >(json); myObjs = myTableDictionary; break; case "views": case "view": myojb = new ViewViewsDictionary(); List <ViewViewsDictionary> myViewDictionary = new List <ViewViewsDictionary>(); myViewDictionary = JsonConvert.DeserializeObject <List <ViewViewsDictionary> >(json); myObjs = myViewDictionary; break; case "primary": case "primary keys": case "primary key": case "pk": case "pkey": case "pkeys": myojb = new ViewPrimaryKeysDictionary(); List <ViewPrimaryKeysDictionary> myPKDictionary = new List <ViewPrimaryKeysDictionary>(); myPKDictionary = JsonConvert.DeserializeObject <List <ViewPrimaryKeysDictionary> >(json); myObjs = myPKDictionary; break; case "foreign": case "foreign keys": case "foreign key": case "fk": case "fkey": case "fkeys": myojb = new ViewForeignKeysDictionary(); List <ViewForeignKeysDictionary> myFKDictionary = new List <ViewForeignKeysDictionary>(); myFKDictionary = JsonConvert.DeserializeObject <List <ViewForeignKeysDictionary> >(json); myObjs = myFKDictionary; break; case "unqiue": case "unqiue keys": case "unqiue key": case "uk": case "ukey": case "ukeys": myojb = new ViewUniqueKeysDictionary(); List <ViewUniqueKeysDictionary> myUKDictionary = new List <ViewUniqueKeysDictionary>(); myUKDictionary = JsonConvert.DeserializeObject <List <ViewUniqueKeysDictionary> >(json); myObjs = myUKDictionary; break; default: List <object> defaultlist = new List <object>(); defaultlist = null; myObjs = defaultlist; break; } return(myObjs); }
public SessionObjects handleSession(IConnectToDB _Connect, SessionObjects SO, string _desiredstate, string username, bool ValidSession, string _JsonTimeoutInterval, string _MemoryTracking, string _InstallType) { //_SessionObjects.SessionIdentity.username = username; //_SessionObjects.SessionIdentity.password = password; Boolean _userIsValid = ValidSession; //Create an is user valid method. Int64 JsonTimeoutInterval = 15; try { JsonTimeoutInterval = Convert.ToInt64(_JsonTimeoutInterval); JsonTimeoutInterval = JsonTimeoutInterval > 0 ? JsonTimeoutInterval : 15; } catch { JsonTimeoutInterval = 15; } switch (_desiredstate.ToLower()) { case "new": case "preserve": if (SO != null || SO == null) { try { if (SO.SessionStartTime != null) { //No need to reset Starttime, just check last load time. SO.LastLoad = DateTime.Now; SO.SessionEndTime = DateTime.Now.AddMinutes(JsonTimeoutInterval); } else { SO = new SessionObjects(); SO.LastLoad = DateTime.Now; SO.SessionStartTime = DateTime.Now; SO.SessionEndTime = DateTime.Now.AddMinutes(JsonTimeoutInterval); } } catch { SO = new SessionObjects(); SO.SessionStartTime = DateTime.Now; SO.LastLoad = DateTime.Now; SO.SessionEndTime = DateTime.Now.AddMinutes(JsonTimeoutInterval); } long?tempUserID = 0; //If user is valid then proceed with loading the first core. if (_userIsValid) { //Hardcoded user for now //Instantiate Sub Model of Session. SO.SessionStartTime = DateTime.Now; if (SO.NextReload == null || SO.NextReload < DateTime.Now || _desiredstate.ToLower() == "new") { SO.SessionIdentity = new IdentityModels(); SO.SessionIdentity.Identity = new IdentityModel(); SessionsHelper SH = new SessionsHelper(); SecurityHelper SECH = new SecurityHelper(); DataTable thisUser = SH.GetIDviaUserName(_Connect, username); SO.SessionIdentity.Identity.username = username; SO.SessionIdentity.Identity.user_name = username; SO.SessionIdentity.Identity.identities_id = thisUser.Rows[0].Field <long?>("IDENTITIES_ID"); SO.SessionIdentity.Identity.identities_uuid = thisUser.Rows[0].Field <Guid?>("BASE_Identities_UUID"); SO._IdentityModel = new IdentityModel(); SO._IdentityModel.username = username; SO._IdentityModel.user_name = username; SO._IdentityModel.identities_id = SO.SessionIdentity.Identity.identities_id; SO._IdentityModel.identities_uuid = SO.SessionIdentity.Identity.identities_uuid; tempUserID = SO.SessionIdentity.Identity.identities_id; // SO.SessionIdentity.ApplicationPermissions = SECH.SourceSecPermList(new List<ViewSourceSecPerm>(), SECH.FindbyColumnID(_Connect, "identities_id", SO.SessionIdentity.Identity.identities_id.ToString(), "appaccess"), "Applications"); //ProfileHelper PH = new ProfileHelper(); // SO.SessionIdentity.Profile = new ViewProfileModel(); // SO.SessionIdentity.Profile.profile_image = PH.GetProfileImage(SO.SessionIdentity.Identity.identities_id); } DictionaryHelper DH = new DictionaryHelper(); ActivityHelper _AH = new ActivityHelper(); if ((SO.NextReload == null || SO.NextReload < DateTime.Now || _desiredstate.ToLower() == "new") && new SecurityHelper().DoesIdentityHavePrivilege(_Connect, tempUserID.ToString(), "VIEW DICTIONARY")) { SO.ERDictionary = new ERDictionaryModels(); //SO.ERDictionary.tablesView = DH.GetTables(new List<ViewTablesDictionary>(), DH.FindAll(_Connect, "table")); //SO.ERDictionary.ukeysViews = DH.GetUKeys(new List<ViewUniqueKeysDictionary>(), DH.FindAll(_Connect, "ukeys")); //SO.ERDictionary.fkeysViews = DH.GetFKeys(new List<ViewForeignKeysDictionary>(), DH.FindAll(_Connect, "fkeys")); //SO.ERDictionary.viewsView = DH.GetViews(new List<ViewViewsDictionary>(), DH.FindAll(_Connect, "views")); //SO.ERDictionary.pkeysViews = DH.GetPKeys(new List<ViewPrimaryKeysDictionary>(), DH.FindAll(_Connect, "pkeys")); //SO.ERDictionary.indexes = DH.GetIndexes(new List<ViewIndexesDictionary>(), DH.FindAll(_Connect, "indexes")); } if (SO.NextReload == null || SO.NextReload < DateTime.Now || _desiredstate.ToLower() == "new") { SO.ActivityList = new Activity(); SO.ActivityList.ActivityView = _AH.ActivityList(new List <ActivityModelView>(), _AH.FindAllbyIDforDays(_Connect, "All", SO.SessionIdentity.Identity.identities_id, 7)); SO.ActivityList.ActivityViewTitle = "My Personal Activity"; } //_SessionObjects.SessionIdentity.cores = GetsCoreForUserID(new List<CoreModels>(), _SessionObjects.SessionIdentity.identities_id); if (SO.NextReload == null || SO.NextReload < DateTime.Now || _desiredstate.ToLower() == "new") { // SO.SessionNotification = GetNotifications(_Connect, new NotificationsModel(), SO.SessionIdentity.Identity.identities_id); SO.SessionNotification = new NotificationsModel(); } SO.Notifications = new Activity(); SO.Notifications.newActivityCount = ""; if (_InstallType != null) { if (_InstallType.ToLower() == "saas") { SO.Notifications.ActivityView = _AH.ActivityList(new List <ActivityModelView>(), _AH.FindMemberNotifications(_Connect, SO.SessionIdentity.Identity.identities_id.ToString())); } else { SO.Notifications.ActivityView = _AH.ActivityList(new List <ActivityModelView>(), _AH.FindNotifications(_Connect)); } } else { SO.Notifications.ActivityView = _AH.ActivityList(new List <ActivityModelView>(), _AH.FindNotifications(_Connect)); } SO.Notifications.newActivityCount = _AH.NewNotificationCount(_Connect, SO.SessionIdentity.Identity.identities_id.ToString()); if (SO.NextReload == null || SO.NextReload < DateTime.Now.AddMinutes(-5)) { SO.NextReload = DateTime.Now.AddMinutes(5); } SO.ERCharts = new ERChartsModels(); SO.ERCharts.Charts = new List <DynamicChartModel>(); SO._PageFeatures = new PageFeatures(); } } //Only run this if you need to know Session Memory Related Stuff if (_MemoryTracking.ToUpper() == "ON") { SO.ERMemory = new MemoryUsage(); SO.ERMemory.GCTotalMemory = GC.GetTotalMemory(false); SO.ERMemory.GCTotalMemoryMB = (SO.ERMemory.GCTotalMemory / 1024) / 1024; SO.ERMemory.SOGetGenerationID = GC.GetGeneration(SO); GC.Collect(SO.ERMemory.SOGetGenerationID); SO.ERMemory.SOTotalMemory = GC.GetTotalMemory(false); SO.ERMemory.SOTotalMemoryMB = (SO.ERMemory.SOTotalMemory / 1024) / 1024; } break; case "clear": SO = new SessionObjects(); SO.SessionIdentity = new IdentityModels(); //SO.SessionIdentity.Profile = new ViewProfileModel(); SO.SessionNotification = new NotificationsModel(); SO.SessionNotification.Apps_View = new List <VW__APPLICATIONS_NTFY>(); SO.SessionNotification.Cores_View = new List <VW__CORES_NTFY>(); SO.SessionNotification.Forms_View = new List <VW__FORMS_NTFY>(); SO.ERDictionary = new ERDictionaryModels(); SO.ERDictionary.fkeysViews = new List <ViewForeignKeysDictionary>(); SO.ERDictionary.pkeysViews = new List <ViewPrimaryKeysDictionary>(); SO.ERDictionary.tablesView = new List <ViewTablesDictionary>(); SO.ERDictionary.ukeysViews = new List <ViewUniqueKeysDictionary>(); SO.ERDictionary.viewsView = new List <ViewViewsDictionary>(); SO.SessionEndTime = DateTime.Now; break; } return(SO); }