コード例 #1
0
 protected IEnumerable <Type> GetMatchingValues()
 {
     if (_matchingValues == null)
     {
         IList <Type> allTypes = new List <Type>();
         foreach (var ass in AppDomain.CurrentDomain.GetAssemblies())
         {
             if (PXSubstManager.IsSuitableTypeExportAssembly(ass, true))
             {
                 Type[] types = null;
                 try {
                     if (!ass.IsDynamic)
                     {
                         types = ass.GetExportedTypes();
                     }
                 } catch (ReflectionTypeLoadException te) {
                     types = te.Types;
                 } catch {
                     continue;
                 }
                 if (types != null)
                 {
                     allTypes.AddRange(types.Where(ty => predicate(ty)));
                 }
             }
         }
         _matchingValues = allTypes.Distinct();
     }
     return(_matchingValues);
 }
コード例 #2
0
 protected virtual IEnumerable licences()
 {
     foreach (Assembly ass in AppDomain.CurrentDomain.GetAssemblies())
     {
         if (PXSubstManager.IsSuitableTypeExportAssembly(ass, false))
         {
             Type[] types = null;
             try
             {
                 if (!ass.IsDynamic)
                 {
                     types = ass.GetExportedTypes();
                 }
             }
             catch (ReflectionTypeLoadException te)
             {
                 types = te.Types;
             }
             catch
             {
                 continue;
             }
             if (types != null)
             {
                 foreach (Type t in types)
                 {
                     if (t != null && typeof(IProjectLicense).IsAssignableFrom(t) && t != typeof(IProjectLicense))
                     {
                         var projectLicense  = (IProjectLicense)Activator.CreateInstance(t);
                         var existingLicence = (ClientLicencingSetup)ExistingLicences.SelectWindowed(0, 1, projectLicense.ProjectID);
                         if (existingLicence != null)
                         {
                             yield return(existingLicence);
                         }
                         else
                         {
                             var licence = new ClientLicencingSetup()
                             {
                                 CustomizationID = projectLicense.ProjectID,
                                 Description     = projectLicense.ProjectDescription,
                                 Url             = projectLicense.LicenseServerUrl,
                                 Username        = projectLicense.LicenseServerUsername,
                                 Password        = projectLicense.LicenseServerPassword,
                                 WindowDays      = projectLicense.LicenseWindowDays,
                             };
                             Licences.Insert(licence);
                             yield return(licence);
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #3
0
 protected virtual IEnumerable GetRecords()
 {
     foreach (Assembly ass in AppDomain.CurrentDomain.GetAssemblies())
     {
         if (PXSubstManager.IsSuitableTypeExportAssembly(ass, false))
         {
             Type[] types = null;
             try
             {
                 if (!ass.IsDynamic)
                 {
                     types = ass.GetExportedTypes();
                 }
             }
             catch (ReflectionTypeLoadException te)
             {
                 types = te.Types;
             }
             catch
             {
                 continue;
             }
             if (types != null)
             {
                 foreach (Type t in types)
                 {
                     if (t != null && _MainProviderType.IsAssignableFrom(t) && t != _MainProviderType)
                     {
                         var dependents = _DependentProviderType.Where(dt => dt.IsAssignableFrom(t)).ToList();
                         if (dependents.Any())
                         {
                             var nonBaseDependents = dependents.Where(dt => dt != t).ToList();
                             if (nonBaseDependents.Any())
                             {
                                 yield return(new ProviderRec {
                                     TypeName = t.FullName, ProviderName = nonBaseDependents.Select(nbd => nbd.Name).LastOrDefault()
                                 });
                             }
                         }
                         else
                         {
                             yield return(new ProviderRec {
                                 TypeName = t.FullName, ProviderName = _MainProviderType.Name
                             });
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #4
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));
        }
コード例 #5
0
        public virtual IEnumerable relate(PXAdapter adapter)
        {
            bool lint = entityFilter.AskExt() == WebDialogResult.OK && entityFilter.VerifyRequired();

            if (lint)
            {
                PXCache       cache            = this.Caches <CRSMEmail>();
                RelatedEntity relatedEntity    = entityFilter.Current;
                EntityHelper  helper           = new EntityHelper(this);
                Type          entityType       = PXBuildManager.GetType(relatedEntity.Type, false);
                object        row              = helper.GetEntityRow(entityType, relatedEntity.RefNoteID);
                Type          graphType        = helper.GetPrimaryGraphType(row, false);
                Type          actualEntityType = PXSubstManager.Substitute(entityType, graphType);
                object        actualRow        = helper.GetEntityRow(actualEntityType, relatedEntity.RefNoteID);
                PXGraph       graph            = PXGraph.CreateInstance(graphType);
                graph.Caches[actualEntityType].Current = actualRow;
                foreach (PXResult <CRSMEmail, EMailAccount, EPView> email in SelectedList())
                {
                    ((CRSMEmail)email).Selected = false;
                    CRSMEmail copy = PXCache <CRSMEmail> .CreateCopy(email);

                    CRActivity newActivity = (CRActivity)graph.Caches[typeof(CRActivity)].Insert();

                    copy.BAccountID = newActivity.BAccountID;
                    copy.ContactID  = newActivity.ContactID;
                    copy.RefNoteID  = newActivity.RefNoteID;
                    copy.MPStatus   = MailStatusListAttribute.Processed;
                    copy.Exception  = null;
                    PXRefNoteSelectorAttribute.EnsureNotePersistence(this, entityFilter.Current.Type, entityFilter.Current.RefNoteID);
                    copy = (CRSMEmail)cache.Update(copy);
                }
                Save.Press();
            }
            else
            {
                entityFilter.Ask(Messages.Warning, Messages.SelectRecord, MessageButtons.OK);
            }

            Emails.Cache.IsDirty = false;
            Emails.Cache.Clear();
            Emails.Cache.ClearQueryCacheObsolete();
            Emails.View.RequestRefresh();
            return(adapter.Get());
        }
コード例 #6
0
 public static IEnumerable <ProviderRec> GetProviderRecs(params Type[] providerInterfaceTypes)
 {
     if (providerInterfaceTypes == null)
     {
         yield break;
     }
     foreach (Assembly ass in AppDomain.CurrentDomain.GetAssemblies())
     {
         if (PXSubstManager.IsSuitableTypeExportAssembly(ass, false))
         {
             Type[] types = null;
             try
             {
                 if (!ass.IsDynamic)
                 {
                     types = ass.GetExportedTypes();
                 }
             }
             catch (ReflectionTypeLoadException te)
             {
                 types = te.Types;
             }
             catch
             {
                 continue;
             }
             if (types != null)
             {
                 foreach (var type in types
                          .Where(assemblyType => providerInterfaceTypes
                                 .Any(interfaceType => interfaceType.IsAssignableFrom(assemblyType) && assemblyType != interfaceType)))
                 {
                     Attribute attribute   = type.GetCustomAttributes().FirstOrDefault(a => a is PXDisplayTypeNameAttribute);
                     string    displayName = (attribute as PXDisplayTypeNameAttribute)?.Name ?? type.FullName;
                     yield return(new ProviderRec {
                         TypeName = type.FullName, DisplayTypeName = displayName
                     });
                 }
             }
         }
     }
 }