Example #1
0
        }        //

        public static List <WM.Import_PendingRequest> SelectAllPendingDeletes()
        {
            WM.Import_PendingRequest        entity = new WM.Import_PendingRequest();
            List <WM.Import_PendingRequest> list   = new List <WM.Import_PendingRequest>();

            try
            {
                string prevCTID = "";
                using (var context = new EntityContext())
                {
                    //actually REGISTRY_ACTION_PURGE_ALL should be handled separately
                    var search = context.Import_PendingRequest
                                 .Where(s => s.WasChanged == true &&
                                        s.WasProcessed == false &&
                                        (s.PublishMethodURI == REGISTRY_ACTION_DELETE ||
                                         s.PublishMethodURI == REGISTRY_ACTION_PURGE ||
                                         s.PublishMethodURI == REGISTRY_ACTION_PURGE_ALL
                                        )
                                        )
                                 .OrderBy(s => s.PublishingEntityType)
                                 .ThenBy(s => s.EntityCtid)
                                 .ThenBy(x => x.Created)
                                 .ToList();

                    if (search != null && search.Count > 0)
                    {
                        foreach (var item in search)
                        {
                            entity = new WM.Import_PendingRequest
                            {
                                Id                   = item.Id,
                                EnvelopeId           = item.EnvelopeId,
                                Environment          = item.Environment,
                                EntityName           = item.EntityName,
                                EntityCtid           = item.EntityCtid,
                                PublisherCTID        = item.PublisherCTID,
                                PublishMethodURI     = item.PublishMethodURI,
                                PublishingEntityType = item.PublishingEntityType
                                                       //EnvelopeLastUpdated = item.EnvelopeLastUpdated
                            };
                            //entity.EntityTypedId = item.EntityTypedId; //derive??
                            if (prevCTID != entity.EntityCtid.ToLower())
                            {
                                list.Add(entity);
                            }

                            prevCTID = entity.EntityCtid.ToLower();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.LogError(ex, thisClassName + ".SelectPendingList");
            }
            return(list);
        }        //
Example #2
0
        }        //

        /// <summary>
        /// Select pending records except excludeEntityType
        /// </summary>
        /// <param name="excludeEntityType"></param>
        /// <param name="maxRecords"></param>
        /// <returns></returns>
        public static List <WM.Import_PendingRequest> SelectAllPendingExceptList(string excludeEntityType, int maxRecords = 100)
        {
            WM.Import_PendingRequest        entity = new WM.Import_PendingRequest();
            List <WM.Import_PendingRequest> list   = new List <WM.Import_PendingRequest>();

            /*
             *
             *      Assessment
             *      CompetencyFramework
             *      ConceptScheme
             *      ConditionManifest
             *      CostManifest
             *      Credential
             *      LearningOpportunity
             *      Organization
             */
            try
            {
                string prevCTID = "";
                using (var context = new EntityContext())
                {
                    var search = context.Import_PendingRequest
                                 .Where(s => s.WasChanged == true &&
                                        s.WasProcessed == false &&
                                        s.PublishMethodURI != "Registry Delete" && s.PublishMethodURI != "Transfer of Owner" &&
                                        (s.PublishingEntityType != excludeEntityType)
                                        )
                                 .Take(maxRecords)
                                 .OrderBy(s => s.PublishingEntityType)
                                 .ThenBy(s => s.EntityCtid)
                                 .ThenBy(x => x.Created)
                                 .ToList();

                    if (search != null && search.Count > 0)
                    {
                        foreach (var item in search)
                        {
                            entity = new WM.Import_PendingRequest
                            {
                                Id                   = item.Id,
                                EnvelopeId           = item.EnvelopeId,
                                Environment          = item.Environment,
                                EntityName           = item.EntityName,
                                EntityCtid           = item.EntityCtid,
                                PublishMethodURI     = item.PublishMethodURI,
                                PublishingEntityType = item.PublishingEntityType,
                                PublisherCTID        = item.PublisherCTID,
                                DataOwnerCTID        = item.DataOwnerCTID
                                                       //EnvelopeLastUpdated = item.EnvelopeLastUpdated
                            };
                            //entity.EntityTypedId = item.EntityTypedId; //derive??
                            if (prevCTID != entity.EntityCtid.ToLower())
                            {
                                list.Add(entity);
                            }

                            prevCTID = entity.EntityCtid.ToLower();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.LogError(ex, thisClassName + ".SelectAllPendingExceptList");
            }
            return(list);
        }        //
Example #3
0
        }        //

        #endregion

        #region Import.PendingRequest
        /// <summary>
        /// Select specific entity type.
        /// Only return records not already processed, and have wasChanged = true
        /// TODO- should deletes also be returned and have caller process as found?
        /// </summary>
        /// <param name="entityType">If blank, will select all</param>
        /// <param name="maxRecords">Number of records to process</param>
        /// <returns></returns>
        public static List <WM.Import_PendingRequest> SelectPendingList(string entityType, int maxRecords = 100)
        {
            WM.Import_PendingRequest        entity = new WM.Import_PendingRequest();
            List <WM.Import_PendingRequest> list   = new List <WM.Import_PendingRequest>();

            /*
             *
             *      Assessment
             *      CompetencyFramework
             *      ConceptScheme
             *      ConditionManifest
             *      CostManifest
             *      Credential
             *      LearningOpportunity
             *      Organization
             */
            //may not want to depend upon WasChanged yet!!!
            bool onlySelectIfWasChanged = UtilityManager.GetAppKeyValue("onlySelectIfWasChanged", true);

            try
            {
                string prevCTID = "";
                using (var context = new EntityContext())
                {
                    var search = context.Import_PendingRequest
                                 .Where(s => (s.WasChanged == true || onlySelectIfWasChanged == false) &&
                                        s.WasProcessed == false
                                        //may want an registry action property instead
                                        && s.PublishMethodURI != "DELETE" && s.PublishMethodURI != "Transfer of Owner" &&
                                        (s.PublishingEntityType == entityType)
                                        )
                                 .Take(maxRecords)
                                 .OrderBy(s => s.PublishingEntityType)
                                 .ThenBy(s => s.EntityCtid)
                                 .ThenBy(x => x.Created)
                                 .ToList();
                    //  || string.IsNullOrWhiteSpace( entityType )
                    if (search != null && search.Count > 0)
                    {
                        foreach (var item in search)
                        {
                            entity = new WM.Import_PendingRequest
                            {
                                Id                   = item.Id,
                                EnvelopeId           = item.EnvelopeId,
                                Environment          = item.Environment,
                                EntityName           = item.EntityName,
                                EntityCtid           = item.EntityCtid,
                                PublishMethodURI     = item.PublishMethodURI,
                                PublishingEntityType = item.PublishingEntityType
                                                       //EnvelopeLastUpdated = item.EnvelopeLastUpdated
                            };
                            //entity.EntityTypedId = item.EntityTypedId; //derive??
                            if (prevCTID != entity.EntityCtid.ToLower())
                            {
                                list.Add(entity);
                            }

                            prevCTID = entity.EntityCtid.ToLower();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.LogError(ex, thisClassName + ".SelectPendingList");
            }
            return(list);
        }        //