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);
     }
 }
Exemple #2
0
        public UpdateIfFieldsChangedScope()
        {
            Changes currentContext = PXContext.GetSlot <Changes>();

            if (currentContext == null)
            {
                currentContext = new Changes();
                PXContext.SetSlot <Changes>(currentContext);
            }
            currentContext.ReferenceCounter++;
        }
Exemple #3
0
        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));
     }
 }
Exemple #5
0
        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);
            }
Exemple #7
0
        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);
            }
        }
Exemple #8
0
        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);
        }
Exemple #9
0
        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);
        }
Exemple #10
0
        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);
        }
Exemple #11
0
        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);
        }
Exemple #12
0
        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());
            }
        }
Exemple #13
0
        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);
        }