コード例 #1
0
        //Refactor - Generalize if possible!!!
        private IBqlTable GetItemRecord(EPAssignmentRule rule, IBqlTable item)
        {
            PXGraph graph    = this.processGraph;
            Type    itemType = item.GetType();
            Type    ruleType = GraphHelper.GetType(rule.Entity);

            if (ruleType.IsAssignableFrom(itemType))
            {
                return(item);
            }
            if (processMapType.IsAssignableFrom(ruleType) && graph != null)
            {
                return(graph.Caches[processMapType].Current as IBqlTable);
            }

            if (graph != null)
            {
                foreach (CacheEntityItem entry in EMailSourceHelper.TemplateEntity(this, null, item.GetType().FullName, graph.GetType().FullName))
                {
                    Type entityType = GraphHelper.GetType(entry.SubKey);
                    if (ruleType.IsAssignableFrom(entityType) && graph.Views.ContainsKey(entry.Key))
                    {
                        PXView view   = graph.Views[entry.Key];
                        object result = view.SelectSingleBound(new object[] { item });
                        return((result is PXResult ? ((PXResult)result)[0] : result) as IBqlTable);
                    }
                }
            }
            return(item);
        }
コード例 #2
0
 protected IEnumerable entityItems(string parent)
 {
     if (Base.AssigmentMap.Current != null)
     {
         var  entityType = GraphHelper.GetType(Base.AssigmentMap.Current.EntityType);
         Type primaryGraphType;
         if (Base.AssigmentMap.Current.GraphType == null)
         {
             if (entityType == null && parent != null)
             {
                 yield break;
             }
             primaryGraphType = EntityHelper.GetPrimaryGraphType(Base, entityType);
         }
         else
         {
             primaryGraphType = GraphHelper.GetType(Base.AssigmentMap.Current.GraphType);
         }
         var cacheEntityItems = EMailSourceHelper.TemplateEntity(Base, parent, entityType?.FullName,
                                                                 primaryGraphType?.FullName);
         foreach (CacheEntityItem cacheEntityItem in cacheEntityItems)
         {
             if (primaryGraphType == typeof(SubcontractEntry))
             {
                 cacheEntityItem.Name = cacheEntityItem.GetSubcontractViewName();
             }
             yield return(cacheEntityItem);
         }
     }
 }
コード例 #3
0
        protected IEnumerable entityItems(string parent)
        {
            if (this.AssigmentMap.Current == null)
            {
                yield break;
            }
            Type type = GraphHelper.GetType(this.AssigmentMap.Current.EntityType);;
            Type graphType;

            if (AssigmentMap.Current.GraphType == null)
            {
                if (type == null && parent != null)
                {
                    yield break;
                }
                graphType = EntityHelper.GetPrimaryGraphType(this, type);
            }
            else
            {
                graphType = GraphHelper.GetType(this.AssigmentMap.Current.GraphType);
            }

            foreach (CacheEntityItem e in EMailSourceHelper.TemplateEntity(this, parent, type.FullName, graphType != null ? graphType.FullName : null))
            {
                yield return(e);
            }
        }
コード例 #4
0
        protected PXFieldState CreateFieldStateForFieldName(object returnState, string entityType, string graphType, string cacheName)
        {
            Type type = GraphHelper.GetType(entityType);

            if (type != null)
            {
                Type gType = EntityHelper.GetPrimaryGraphType(this, type);
                if (!String.IsNullOrEmpty(graphType))
                {
                    gType = GraphHelper.GetType(graphType);
                }
                string viewName = null;
                if (gType != null)
                {
                    foreach (
                        CacheEntityItem view in
                        EMailSourceHelper.TemplateEntity(this, null, type.FullName, gType.FullName))
                    {
                        if (view.SubKey == cacheName)

                        {
                            viewName = view.Key;
                            break;
                        }
                    }
                }
                return(CreateFieldStateForFieldName(returnState, type, gType, viewName, EPRuleCondition.FieldLength));
            }
            return(PXStringState.CreateInstance(returnState, EPRuleCondition.FieldLength, null, _FIELDNAME_STR, false, 1, null,
                                                (new List <string>()).ToArray(), (new List <string>()).ToArray(), false, null));
        }
コード例 #5
0
 protected IEnumerable entityItems(string parent)
 {
     if (DefaultSurveys.Current != null)
     {
         Type graphType;
         Type entityType = GraphHelper.GetType(DefaultSurveys.Current.EntityType);
         if (DefaultSurveys.Current.GraphType != null)
         {
             graphType = GraphHelper.GetType(DefaultSurveys.Current.GraphType);
         }
         else if (!(entityType == null) || parent == null)
         {
             graphType = EntityHelper.GetPrimaryGraphType(this, entityType);
         }
         else
         {
             yield break;
         }
         string entityTypeName = entityType.FullName;
         string graphTypeName  = graphType?.FullName;
         foreach (CacheEntityItem cacheEntityItem in EMailSourceHelper.TemplateEntity(this, parent, entityTypeName, graphTypeName))
         {
             yield return(cacheEntityItem);
         }
     }
     yield break;
 }
コード例 #6
0
        protected virtual IEnumerable entityItems([PXString] string parent)
        {
            if (MassMails.Current == null)
            {
                return(new CacheEntityItem[0]);
            }

            return(EMailSourceHelper.TemplateEntity(this, parent, typeof(Contact).FullName, null));
        }
コード例 #7
0
        private PXFieldState CreateFieldStateForFieldName(object returnState, string entityType, string graphType, string cacheName)
        {
            List <string> allowedValues = new List <string>();
            List <string> allowedLabels = new List <string>();

            Type type = GraphHelper.GetType(entityType);

            if (type != null)
            {
                Type gType = EntityHelper.GetPrimaryGraphType(this, type);
                if (!String.IsNullOrEmpty(graphType))
                {
                    gType = GraphHelper.GetType(graphType);
                }
                string viewName = null;
                if (gType != null)
                {
                    foreach (
                        CacheEntityItem view in
                        EMailSourceHelper.TemplateEntity(this, null, type.FullName, gType.FullName))
                    {
                        if (view.SubKey == cacheName)

                        {
                            viewName = view.Key;
                            break;
                        }
                    }
                }

                Dictionary <string, string> fields = new Dictionary <string, string>();
                foreach (CacheEntityItem e in
                         EMailSourceHelper.TemplateEntity(this, viewName, type.FullName, gType != null ? gType.FullName : null, true))
                {
                    fields[e.SubKey] = e.Name;
                }

                foreach (var item in fields.OrderBy(i => i.Value))
                {
                    if (!item.Key.EndsWith("_Attributes") && item.Key.Contains('_'))
                    {
                        continue;
                    }
                    allowedValues.Add(item.Key);
                    allowedLabels.Add(item.Value);
                }
            }


            return(PXStringState.CreateInstance(returnState, EPAssignmentRule.FieldLength, null, _FIELDNAME_STR, false, 1, null,
                                                allowedValues.ToArray(), allowedLabels.ToArray(), false, null));
        }
コード例 #8
0
        private IEnumerable GetEntityItems(String parent)
        {
            string screenID = IsStockItemFlag ? "IN202500" : "IN202000";

            PXSiteMapNode siteMap = PXSiteMap.Provider.FindSiteMapNodeByScreenID(screenID);

            if (siteMap != null)
            {
                foreach (var entry in EMailSourceHelper.TemplateEntity(this, parent, null, siteMap.GraphType, true))
                {
                    yield return(entry);
                }
            }
        }
コード例 #9
0
        protected virtual IEnumerable entityItems([PXString] string parent)
        {
            if (MassMails.Current == null)
            {
                return(new CacheEntityItem[0]);
            }

            var graphType = new EntityHelper(this).GetPrimaryGraphType(typeof(Contact), null, true);

            return(graphType != null
                                        ? EMailSourceHelper.TemplateEntity(this, parent,
                                                                           PXSubstManager.Substitute(typeof(Contact), graphType).FullName,
                                                                           graphType.FullName)
                                        : EMailSourceHelper.TemplateEntity(this, parent, typeof(Contact).FullName, null));
        }
コード例 #10
0
        protected PXFieldState CreateFieldStateForFieldName(object returnState, Type entityType, Type gType, string viewName, int?fieldLength)
        {
            List <string> allowedValues = new List <string>();
            List <string> allowedLabels = new List <string>();
            List <string> uniqueLabels  = new List <string>();

            if (entityType != null)
            {
                Dictionary <string, string> fields = new Dictionary <string, string>();
                foreach (CacheEntityItem c in
                         EMailSourceHelper.TemplateEntity(this, viewName,
                                                          entityType.FullName,
                                                          gType != null ? gType.FullName : null, false))
                {
                    fields[c.SubKey] = c.Name;
                }

                Action <string, string> addValueLabel = (value, label) =>
                {
                    allowedValues.Add(value);
                    allowedLabels.Add(label);
                    uniqueLabels.Add(label);
                };
                foreach (var item in fields.OrderBy(i => i.Value))
                {
                    if (!item.Key.EndsWith("_Attributes") && item.Key.Contains('_'))
                    {
                        continue;
                    }
                    if (!uniqueLabels.Contains(item.Value))
                    {
                        addValueLabel(item.Key, item.Value);
                    }
                    else
                    {
                        string label = string.Format("{0} - {1}", item.Key, item.Value);
                        addValueLabel(item.Key, label);
                    }
                }
            }

            return(PXStringState.CreateInstance(returnState, fieldLength, null, _FIELDNAME_STR, false, 1, null,
                                                allowedValues.ToArray(), allowedLabels.ToArray(), false, null));
        }
コード例 #11
0
        private PXFieldState CreateFieldStateForEntity(object returnState, string entityTypeName, string graphTypeName)
        {
            var values     = new List <string>();
            var labels     = new List <string>();
            var entityType = GraphHelper.GetType(entityTypeName);

            if (entityType != null)
            {
                var graphType = EntityHelper.GetPrimaryGraphType(Base, entityType);
                if (!string.IsNullOrEmpty(graphTypeName))
                {
                    graphType = GraphHelper.GetType(graphTypeName);
                }
                if (graphType == null)
                {
                    var customAttributes =
                        (PXCacheNameAttribute[])entityType.GetCustomAttributes(typeof(PXCacheNameAttribute), true);
                    if (entityType.IsSubclassOf(typeof(CSAnswers)))
                    {
                        values.Add(entityType.FullName);
                        var name = customAttributes.Length != 0
                            ? customAttributes[0].Name
                            : entityType.Name;
                        labels.Add(name);
                    }
                }
                else
                {
                    var cacheEntityItems = EMailSourceHelper.TemplateEntity(
                        Base, null, entityType.FullName, graphType.FullName)
                                           .Cast <CacheEntityItem>()
                                           .Where(cacheEntityItem => cacheEntityItem.SubKey != typeof(CSAnswers).FullName);
                    foreach (var cacheEntityItem in cacheEntityItems)
                    {
                        values.Add(cacheEntityItem.SubKey);
                        labels.Add(cacheEntityItem.GetSubcontractViewName());
                    }
                }
            }
            return(PXStringState.CreateInstance(returnState, 60, default(bool), "Entity", false, 1, null,
                                                values.ToArray(), labels.ToArray(), true, null));
        }
コード例 #12
0
        private PXFieldState CreateFieldStateForEntity(object returnState, string entityType, string graphType)
        {
            List <string> allowedValues = new List <string>();
            List <string> allowedLabels = new List <string>();

            Type type = GraphHelper.GetType(entityType);

            if (type != null)
            {
                Type gType = EntityHelper.GetPrimaryGraphType(this, type);
                if (!String.IsNullOrEmpty(graphType))
                {
                    gType = GraphHelper.GetType(graphType);
                }
                if (gType == null)
                {
                    PXCacheNameAttribute[] a = (PXCacheNameAttribute[])type.GetCustomAttributes(typeof(PXCacheNameAttribute), true);

                    if (type.IsSubclassOf(typeof(CS.CSAnswers)))
                    {
                        allowedValues.Add(type.FullName);
                        allowedLabels.Add(a.Length > 0 ? a[0].Name : type.Name);
                    }
                }
                else
                {
                    foreach (CacheEntityItem e in EMailSourceHelper.TemplateEntity(this, null, type.FullName, gType.FullName))
                    {
                        if (e.SubKey != typeof(CS.CSAnswers).FullName)
                        {
                            allowedValues.Add(e.SubKey);
                            allowedLabels.Add(e.Name);
                        }
                    }
                }
            }

            return(PXStringState.CreateInstance(returnState, EPAssignmentRule.FieldLength, null, "Entity", false, 1, null,
                                                allowedValues.ToArray(), allowedLabels.ToArray(), true, null));
        }
コード例 #13
0
        private PXFieldState CreateFieldStateForEntity(object returnState, string entityType, string graphType)
        {
            List <string> strs  = new List <string>();
            List <string> strs1 = new List <string>();
            Type          type  = GraphHelper.GetType(entityType);

            if (type != null)
            {
                Type primaryGraphType = EntityHelper.GetPrimaryGraphType(this, type);
                if (!string.IsNullOrEmpty(graphType))
                {
                    primaryGraphType = GraphHelper.GetType(graphType);
                }
                if (primaryGraphType != null)
                {
                    foreach (CacheEntityItem cacheEntityItem in EMailSourceHelper.TemplateEntity(this, null, type.FullName, primaryGraphType.FullName))
                    {
                        if (cacheEntityItem.SubKey == typeof(CSAnswers).FullName)
                        {
                            continue;
                        }
                        strs.Add(cacheEntityItem.SubKey);
                        strs1.Add(cacheEntityItem.Name);
                    }
                }
                else
                {
                    PXCacheNameAttribute[] customAttributes = (PXCacheNameAttribute[])type.GetCustomAttributes(typeof(PXCacheNameAttribute), true);
                    if (type.IsSubclassOf(typeof(CSAnswers)))
                    {
                        strs.Add(type.FullName);
                        strs1.Add((customAttributes.Length != 0 ? customAttributes[0].Name : type.Name));
                    }
                }
            }
            bool?nullable = null;

            return(PXStringState.CreateInstance(returnState, new int?(60), nullable, "Entity", new bool?(false), new int?(1), null, strs.ToArray(), strs1.ToArray(), new bool?(true), null, null));
        }
コード例 #14
0
        protected PXFieldState CreateFieldStateForFieldName(object returnState, Type entityType, Type gType, string viewName, string cacheName, int?fieldLength, EPRuleBaseCondition condition)
        {
            List <string> allowedValues = new List <string>();
            List <string> allowedLabels = new List <string>();
            List <string> uniqueLabels  = new List <string>();

            if (entityType != null)
            {
                Type cachetype = GraphHelper.GetType(cacheName);
                if (cachetype == null)
                {
                    return(null);
                }
                if (condition != null)
                {
                    string fieldName = condition.FieldName;
                    if (!string.IsNullOrEmpty(fieldName))
                    {
                        PXFieldState state = GetPXFieldState(cachetype, fieldName);
                        if (state == null)
                        {
                            Rules.Cache.SetStatus(condition, PXEntryStatus.Updated);
                            Rules.Cache.RaiseExceptionHandling <EPRuleCondition.fieldName>(condition, fieldName, new PXSetPropertyException(Messages.FieldCannotBeFound, PXErrorLevel.Error));
                        }
                    }
                }
                Dictionary <string, string> fields = new Dictionary <string, string>();
                foreach (CacheEntityItem c in
                         EMailSourceHelper.TemplateEntity(this, viewName,
                                                          entityType.FullName,
                                                          gType != null ? gType.FullName : null, false))
                {
                    fields[c.SubKey] = c.Name;
                }

                Action <string, string> addValueLabel = (value, label) =>
                {
                    allowedValues.Add(value);
                    allowedLabels.Add(label);
                    uniqueLabels.Add(label);
                };
                foreach (var item in fields.OrderBy(i => i.Value))
                {
                    if (!item.Key.EndsWith("_Attributes") && item.Key.Contains('_'))
                    {
                        continue;
                    }

                    var attr = this.Caches[cachetype].GetAttributes(null, item.Key);

                    var value = item.Value;

                    if (attr != null)
                    {
                        var timeListAttribute = attr.FirstOrDefault(a => a is PXTimeListAttribute) as PXTimeListAttribute;
                        var intAttribute      = attr.FirstOrDefault(a => a is PXIntAttribute) as PXIntAttribute;
                        if (timeListAttribute != null && intAttribute != null)
                        {
                            value += " (" + PXLocalizer.Localize("Minutes") + ")";
                        }
                    }

                    if (!uniqueLabels.Contains(value))
                    {
                        addValueLabel(item.Key, value);
                    }
                    else
                    {
                        string label = string.Format("{0} - {1}", item.Key, value);
                        addValueLabel(item.Key, label);
                    }
                }
            }

            return(PXStringState.CreateInstance(returnState, fieldLength, null, _FIELDNAME_STR, false, 1, null,
                                                allowedValues.ToArray(), allowedLabels.ToArray(), false, null));
        }