Esempio n. 1
0
        public ObjectInstanceList GetSubFoldersItems(ObjectDefinition objdefinition, PagingInformation paginginfo, string folderserverrelativeurl, string connectionname)
        {
            Log.WriteVerbose(string.Format(BeginLogMessage, CLASS_NAME, "GetSubFoldersItems(ObjectDefinition objdefinition, PagingInformation paginginfo, string folderserverrelativeurl, string connectionname)"));
            ObjectInstanceList rtnval = null;
            rtnval = (ObjectInstanceList)HttpContext.Current.Cache[GetCacheKey(objdefinition.Id, connectionname) + "," + paginginfo.CurrentPage + "," + folderserverrelativeurl];

            if (rtnval == null)
            {
                lock (_cacheobject)
                {
                    ObjectInstanceCriteriaFilter criteriafilter = new ObjectInstanceCriteriaFilter(objdefinition);
                    criteriafilter.Condition = LogicalOperator.And;
                    criteriafilter.AddFilter("FSObjType", ObjectInstanceCriteriaFilterOperator.EqualTo, 0);
                    criteriafilter.AddFilter("FileDirRef", ObjectInstanceCriteriaFilterOperator.EqualTo, folderserverrelativeurl);
                    criteriafilter.Paging = paginginfo;
                    rtnval = ContextBusClient.GetObjectInstanceList(objdefinition, criteriafilter, AdapterName);
                    HttpContext.Current.Cache.Add(GetCacheKey(objdefinition.Id, connectionname) + "," + paginginfo.CurrentPage + "," + folderserverrelativeurl, rtnval, null, CacheExpirationDateTime, Cache.NoSlidingExpiration, CacheItemPriority.Normal, null);
                }
            }
            Log.WriteVerbose(string.Format(FinishLogMessage, CLASS_NAME, "GetSubFoldersItems(ObjectDefinition objdefinition, PagingInformation paginginfo, string folderserverrelativeurl, string connectionname)"));
            return rtnval;
        }
    private static void Start()
    {
        try
        {
            CurrentPage = 1;
            TotalPages = 1;
            ContextBusThreadCount = 5;
            ObjectInstanceList spItemList = null;
            ContextBusClient contextbusClient = new ContextBusClient();
            EventManagerClient eventClient = new EventManagerClient();
            contextbusClient.Login(ConnectionId, AdapterName);
            ObjectInstanceCriteriaFilter criteria = new ObjectInstanceCriteriaFilter(SharePointObjectDefinition);
            criteria.AddFilter("FSObjType", ObjectInstanceCriteriaFilterOperator.EqualTo, 0);
            criteria.AddFilter("FileDirRef", ObjectInstanceCriteriaFilterOperator.EqualTo, "EntireListWithPagination");
            criteria.Paging = new PagingInformation();
            criteria.Paging.CurrentPage = CurrentPage;
            criteria.Paging.RecordsPerPage = ContextBusThreadCount;

            while (CurrentPage <= TotalPages)
            {
                try
                {
                    spItemList = contextbusClient.GetObjectInstanceList(SharePointObjectDefinition, criteria, AdapterName);
                    TotalPages = spItemList.Paging.TotalPages;
                }
                catch (Exception exp)
                {
                    EkException.LogException(exp);
                }
                if (spItemList != null && spItemList.Results.Any())
                {
                    foreach (ObjectInstance spItem in spItemList.Results)
                    {
                        spItem.Fields.Where(p => p.Id.Equals("DxHSource")).FirstOrDefault().Value = "FromEktron";
                        EventInstance itemEvent = new EventInstance()
                        {
                            Id = WorkflowName,
                            Payload = spItem
                        };

                        eventClient.RaiseEvent(itemEvent);
                    }
                }
                CurrentPage++;
                criteria.Paging.CurrentPage = CurrentPage;
            }

            contextbusClient.Logout(AdapterName);

            //Forcing a garbage collection
            GC.Collect();
            GC.Collect();
            GC.Collect();
        }

        catch (ThreadAbortException tx)
        {
            //Threadaborts are ok...ASP.Net aborts thread when unloading application
            EkException.LogException(tx, System.Diagnostics.EventLogEntryType.Warning);
        }
        catch (Exception ex)
        {
            EkException.LogException(ex);
        }
        Thread.Sleep(1000);
    }
Esempio n. 3
0
        public ObjectInstanceList GetListFolders(ObjectDefinition objdefinition, string connectionname)
        {
            Log.WriteVerbose(string.Format(BeginLogMessage, CLASS_NAME, "GetListFolders(ObjectDefinition objdefinition, string connectionname)"));
            ObjectInstanceList rtnval = null;
            rtnval = (ObjectInstanceList)HttpContext.Current.Cache[GetCacheKey(objdefinition.Id + "folderkey", connectionname)];

            if (rtnval == null)
            {
                lock (_cacheobject)
                {
                    ObjectInstanceCriteriaFilter criteriafilter = new ObjectInstanceCriteriaFilter(objdefinition);
                    criteriafilter.AddFilter("FSObjType", ObjectInstanceCriteriaFilterOperator.EqualTo, 1);
                    rtnval = ContextBusClient.GetObjectInstanceList(objdefinition, criteriafilter, AdapterName);
                    HttpContext.Current.Cache.Add(GetCacheKey(objdefinition.Id + "folderkey", connectionname), rtnval, null, CacheExpirationDateTime, Cache.NoSlidingExpiration, CacheItemPriority.Normal, null);
                }
            }
            Log.WriteVerbose(string.Format(FinishLogMessage, CLASS_NAME, "GetListFolders(ObjectDefinition objdefinition, string connectionname)"));
            return rtnval;
        }