public RoadFlow.Data.Model.Organize GetDeptByUserID(Guid userID) { string key = Keys.CacheKeys.UserDept.ToString(); object obj = Opation.Get(key); System.Collections.Generic.Dictionary <Guid, RoadFlow.Data.Model.Organize> dictionary = new System.Collections.Generic.Dictionary <Guid, RoadFlow.Data.Model.Organize>(); if (obj is System.Collections.Generic.Dictionary <Guid, RoadFlow.Data.Model.Organize> ) { dictionary = (System.Collections.Generic.Dictionary <Guid, RoadFlow.Data.Model.Organize>)obj; if (dictionary.ContainsKey(userID)) { return(dictionary[userID]); } } Guid mainStation = this.GetMainStation(userID); if (mainStation == Guid.Empty) { return((RoadFlow.Data.Model.Organize)null); } List <RoadFlow.Data.Model.Organize> allParent = new Organize().GetAllParent(mainStation); allParent.Reverse(); foreach (RoadFlow.Data.Model.Organize organize in allParent) { if (organize.Type == 2) { dictionary.Add(userID, organize); Opation.Set(key, (object)dictionary); return(organize); } } return((RoadFlow.Data.Model.Organize)null); }
public RoadFlow.Data.Model.Organize GetDeptByUserID(Guid userID) { string key = 13.ToString(); object obj = Opation.Get(key); Dictionary <Guid, RoadFlow.Data.Model.Organize> dictionary = new Dictionary <Guid, RoadFlow.Data.Model.Organize>(); if (obj is Dictionary <Guid, RoadFlow.Data.Model.Organize> ) { dictionary = (Dictionary <Guid, RoadFlow.Data.Model.Organize>)obj; if (dictionary.ContainsKey(userID)) { return(dictionary[userID]); } } Guid mainStation = GetMainStation(userID); if (mainStation == Guid.Empty) { return(null); } List <RoadFlow.Data.Model.Organize> allParent = new Organize().GetAllParent(mainStation); allParent.Reverse(); foreach (RoadFlow.Data.Model.Organize item in allParent) { if (item.Type == 2) { dictionary.Add(userID, item); Opation.Set(key, dictionary); return(item); } } return(null); }