public void Remove(Guid blobHandler) { //This slot is set by the FileHandler graph when synchronizing local files with the remote files //This is to avoid an unnecessary callback to Box. if (!PXContext.GetSlot <bool>("BoxDisableLoad") == true) { FileHandler graph = PXGraph.CreateInstance <FileHandler>(); graph.DeleteFileFromBox(blobHandler); } }
public UpdateIfFieldsChangedScope() { Changes currentContext = PXContext.GetSlot <Changes>(); if (currentContext == null) { currentContext = new Changes(); PXContext.SetSlot <Changes>(currentContext); } currentContext.ReferenceCounter++; }
public static bool IsRunningSelecting(PXGraph graph) { RunningSelectingScope <DAC> scope = PXContext.GetSlot <RunningSelectingScope <DAC> >(); if (scope == null) { return(false); } else { return(scope._GraphList.Exists(e => e == graph.GetType().FullName)); } }
public byte[] Load(Guid blobHandler) { //This slot is set by the FileHandler graph when synchronizing local files with the remote files //This is to avoid an unnecessary callback to Box. if (PXContext.GetSlot <bool>("BoxDisableLoad") == true) { return(new byte[0]); } else { FileHandler graph = PXGraph.CreateInstance <FileHandler>(); return(graph.DownloadFileFromBox(blobHandler)); } }
public void Clear <Table>(string parentKey) where Table : class, IBqlTable, new() { var recordsKey = $"{typeof(Table).FullName}.Cache"; var store = PXContext.GetSlot <IDictionary <string, IEnumerable <Table> > >(recordsKey); if (store != null) { if (store.ContainsKey(parentKey)) { store.Remove(parentKey); } } }
public static TimeZoneInfo.AdjustmentRule GetRule(int year, string id) { var parameter = new DefinitionParameters(id, year); var key = _SLOT_KEY + year + id; Definition def = PXContext.GetSlot <Definition>(key); if (def == null) { using (new PXConnectionScope()) { def = PXDatabase.GetSlot <Definition, DefinitionParameters>(key, parameter, _tables); PXContext.SetSlot(key, def); } } return(def?.Rule); }
public void Dispose() { if (_disposed) { throw new PXObjectDisposedException(); } _disposed = true; Changes currentContext = PXContext.GetSlot <Changes>(); currentContext.ReferenceCounter--; if (currentContext.ReferenceCounter == 0) { PXContext.SetSlot <Changes>(null); } }
public RunningSelectingScope(PXGraph myGraph) { _MyGraphSelecting = myGraph.GetType().FullName; _Previous = PXContext.GetSlot <RunningSelectingScope <DAC> >(); if (_Previous == null) { _GraphList = new List <string>(); } else { _GraphList = new List <string>(_Previous._GraphList); } _GraphList.Add(_MyGraphSelecting); PXContext.SetSlot <RunningSelectingScope <DAC> >(this); }
public virtual bool IsUpdateNeeded(params Type[] changes) { var data = PXContext.GetSlot <Changes>(); if (data?.SourceOfChange == null) { return(true); } foreach (var change in changes) { if (data.SourceOfChange.Contains(change)) { return(true); } } return(false); }
public virtual UpdateIfFieldsChangedScope AppendContext(params Type[] newChanges) { var data = PXContext.GetSlot <Changes>(); if (data.SourceOfChange == null) { data.SourceOfChange = new HashSet <Type>(); } foreach (var change in newChanges) { if (!data.SourceOfChange.Contains(change)) { data.SourceOfChange.Add(change); } } return(this); }
public virtual bool IsUpdatedOnly(params Type[] fields) { var data = PXContext.GetSlot <Changes>(); if (data?.SourceOfChange == null) { return(true); } foreach (var sourceOfChange in data.SourceOfChange) { if (!fields.Contains(sourceOfChange)) { return(false); } } return(true); }
public CBAPIService(String endpoint, string version) { EntityHelper = ServiceLocator.Current.GetInstance <Func <string, string, IEntityHelper> >()(endpoint, version); string userName = "******"; if (PXDatabase.Companies.Length > 0) { var company = PXAccess.GetCompanyName(); if (string.IsNullOrEmpty(company)) { company = PXDatabase.Companies[0]; } userName = userName + "@" + company; } LoginScope = new PXLoginScope(userName, PXAccess.GetAdministratorRoles()); CultureScope = new PX.Common.PXInvariantCultureScope(); if (PXContext.GetSlot <System.Web.SessionState.ISessionStateItemCollection>() == null) { PXContext.SetSlot <System.Web.SessionState.ISessionStateItemCollection>(new System.Web.SessionState.SessionStateItemCollection()); } }
private IEnumerable GetRecords <Table>(string parentKey, Func <IEnumerable <Table> > apiMethod) where Table : class, IBqlTable, new() { var recordsKey = $"{typeof(Table).FullName}.Cache"; var store = PXContext.GetSlot <IDictionary <string, IEnumerable <Table> > >(recordsKey); if (store == null) { store = new Dictionary <string, IEnumerable <Table> >(); PXContext.SetSlot <IDictionary <string, IEnumerable <Table> > >(recordsKey, store); } IEnumerable <Table> records; if (store.TryGetValue(parentKey, out records) == false) { records = apiMethod().ToArray <Table>(); store[parentKey] = records; } return(records); }