public static ICarrierService CreateCarrierService(PXGraph graph, CarrierPlugin plugin) { ICarrierService service = null; if (!string.IsNullOrEmpty(plugin.PluginTypeName)) { try { Type carrierType = PXBuildManager.GetType(plugin.PluginTypeName, true); service = (ICarrierService)Activator.CreateInstance(carrierType); PXSelectBase <CarrierPluginDetail> select = new PXSelect <CarrierPluginDetail, Where <CarrierPluginDetail.carrierPluginID, Equal <Required <CarrierPluginDetail.carrierPluginID> > > >(graph); PXResultset <CarrierPluginDetail> resultset = select.Select(plugin.CarrierPluginID); IList <ICarrierDetail> list = new List <ICarrierDetail>(resultset.Count); foreach (CarrierPluginDetail item in resultset) { list.Add(item); } service.LoadSettings(list); } catch (Exception ex) { throw new PXException(Messages.FailedToCreateCarrierPlugin, ex.Message); } } return(service); }
private static DacInfo ReadProperties(string dacName) { if (string.IsNullOrEmpty(dacName)) { return(null); } lock (_dacMap.SyncRoot) { var res = _dacMap[dacName] as DacInfo; if (res == null) { PXFieldState[] fieldStates = null; var dac = PXBuildManager.GetType(dacName, false); if (dac != null) { var graph = new PXGraph(); fieldStates = PXFieldState.GetFields(graph, new Type[] { dac }, false); } res = DacInfo.Create(dacName, fieldStates); _dacMap.Add(dacName, res); } return(res); } }
public static IList <string> GetCarrierPluginAttributes(PXGraph graph, string carrierPluginID) { CarrierPlugin plugin = PXSelect <CarrierPlugin, Where <CarrierPlugin.carrierPluginID, Equal <Required <CarrierPlugin.carrierPluginID> > > > .Select(graph, carrierPluginID); if (plugin == null) { throw new PXException(Messages.FailedToFindCarrierPlugin, carrierPluginID); } ICarrierService service = null; if (!string.IsNullOrEmpty(plugin.PluginTypeName)) { try { Type carrierType = PXBuildManager.GetType(plugin.PluginTypeName, true); service = (ICarrierService)Activator.CreateInstance(carrierType); } catch (Exception ex) { throw new PXException(Messages.FailedToCreateCarrierPlugin, ex.Message); } } return(service == null ? new List <String>() : service.Attributes); }
public static IReadOnlyList <string> GetTaxPluginAttributes(PXGraph graph, string taxPluginID) { TaxPlugin plugin = PXSelect <TaxPlugin, Where <TaxPlugin.taxPluginID, Equal <Required <TaxPlugin.taxPluginID> > > > .Select(graph, taxPluginID); if (plugin == null) { throw new PXException(Messages.FailedToFindTaxPlugin, taxPluginID); } ITaxProvider provider = null; if (!string.IsNullOrEmpty(plugin.PluginTypeName)) { try { Type taxType = PXBuildManager.GetType(plugin.PluginTypeName, true); provider = (ITaxProvider)Activator.CreateInstance(taxType); } catch (Exception ex) { throw new PXException(Messages.FailedToCreateTaxPlugin, ex.Message); } } return(provider == null ? new List <string>().AsReadOnly() : provider.Attributes); }
public static IReadOnlyList <string> GetAddressValidatorPluginAttributes(PXGraph graph, string addressValidatorPluginID) { AddressValidatorPlugin plugin = PXSelect <AddressValidatorPlugin, Where <AddressValidatorPlugin.addressValidatorPluginID, Equal <Required <AddressValidatorPlugin.addressValidatorPluginID> > > > .Select(graph, addressValidatorPluginID); if (plugin == null) { throw new PXException(Messages.FailedToFindAddressValidatorPlugin, addressValidatorPluginID); } IAddressValidator validator = null; if (!string.IsNullOrEmpty(plugin.PluginTypeName)) { try { Type addressValidatorType = PXBuildManager.GetType(plugin.PluginTypeName, true); validator = (IAddressValidator)Activator.CreateInstance(addressValidatorType); } catch (Exception ex) { throw new PXException(Messages.FailedToCreateAddressValidatorPlugin, ex.Message); } } return(validator == null ? new List <string>().AsReadOnly() : validator.Attributes); }
public static ITaxProvider CreateTaxProvider(PXGraph graph, TaxPlugin plugin) { ITaxProvider service = null; if (!string.IsNullOrEmpty(plugin.PluginTypeName)) { try { Type taxType = PXBuildManager.GetType(plugin.PluginTypeName, true); service = (ITaxProvider)Activator.CreateInstance(taxType); PXSelectBase <TaxPluginDetail> select = new PXSelect <TaxPluginDetail, Where <TaxPluginDetail.taxPluginID, Equal <Required <TaxPluginDetail.taxPluginID> > > >(graph); PXResultset <TaxPluginDetail> resultset = select.Select(plugin.TaxPluginID); var list = new List <ITaxProviderSetting>(resultset.Count); foreach (TaxPluginDetail item in resultset) { list.Add(item); } service.Initialize(list); } catch (Exception ex) { throw new PXException(Messages.FailedToCreateTaxPlugin, ex.Message); } } return(service); }
void RenderSiteMap() { DivGraphs.Visible = true; IEnumerable <SiteMap> siteMap = Select <SiteMap>(PXSelectOrderBy <SiteMap, OrderBy <Asc <SiteMap.screenID> > > .Select(new PXGraph())); IList <string> lookup = ToLookup(siteMap); IEnumerable <SiteMap> hidden = GetHiddenScreens(lookup); HtmlTableBuilder b = new HtmlTableBuilder(); b.Table = TableGraphs; foreach (SiteMap rowSiteMap in Concat(siteMap, hidden)) { b.AddRow(); b.AddCellHref(rowSiteMap.ScreenID, rowSiteMap.Url); b.AddCell(rowSiteMap.Graphtype); bool isTypeFound = false; if (!String.IsNullOrEmpty(rowSiteMap.Graphtype)) { Type t = PXBuildManager.GetType(rowSiteMap.Graphtype, false); if (t != null) { try { string apiGraphName = ServiceManager.GetGraphNameFromType(t); isTypeFound = true; try { //WsdlSchemaBuilder.CreateGraph(t); //Activator.CreateInstance(t); string graphUrl = GetUrl("graph", apiGraphName); b.AddCellHref("Graph" + apiGraphName, graphUrl); } catch { b.AddCell("Graph" + apiGraphName + " - login?"); } } catch (ArgumentException) {} catch (KeyNotFoundException) { } } } if (!isTypeFound) { b.AddCell(null); b.Row.Style.Add("display", "none"); } b.AddCell(rowSiteMap.Title); } }
static Page_SM201020() { Type syncHandlerType = PXBuildManager.GetType(_CALENDAR_SYNC_HANDLER_TYPE, false); if (syncHandlerType != null) { _getSyncUrlMethod = syncHandlerType.GetMethod("GetSyncUrl", new Type[] { typeof(System.Web.HttpContext), typeof(string) }); } }
protected virtual void TMasterFieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { TMaster row = (TMaster)e.Row; if (row == null || row.ClassID == null) { return; } RelatedEntity pars = this.Caches <RelatedEntity>().Current as RelatedEntity; if (pars == null || pars.Type == null || pars.RefNoteID == null) { return; } EntityHelper helper = new EntityHelper(this); Type entityType = PXBuildManager.GetType(pars.Type, false); var related = new EntityHelper(this).GetEntityRow(entityType, pars.RefNoteID); if (related == null) { return; } Type graphType = helper.GetPrimaryGraphType(entityType, related, true); if (graphType == null) { return; } TMaster copy = PXCache <TMaster> .CreateCopy(row); PXGraph graph = CreateInstance(graphType); Type noteType = EntityHelper.GetNoteType(entityType); PXView view = new PXView(this, false, BqlCommand.CreateInstance(BqlCommand.Compose(typeof(Select <,>), entityType, typeof(Where <,>), noteType, typeof(Equal <>), typeof(Required <>), noteType))); graph.Caches[entityType].Current = view.SelectSingle(pars.RefNoteID); PXCache <TMaster> cache = graph.Caches <TMaster>(); cache.SetDefaultExt(copy, typeof(CRActivity.bAccountID).Name); cache.SetDefaultExt(copy, typeof(CRActivity.contactID).Name); if (copy.BAccountID != null) { row.BAccountID = copy.BAccountID; } if (copy.ContactID != null) { row.ContactID = copy.ContactID; } }
public override object Evaluate(PXCache cache, object item, Dictionary <Type, object> pars) { string sourceItemType = (string)pars[typeof(SourceItemType)]; if (!string.IsNullOrEmpty(sourceItemType)) { return(sourceItemType); } else { string entityType = (string)pars[typeof(EntityTypeName)]; return(EntityHelper.GetFriendlyEntityName(PXBuildManager.GetType(entityType, false, true))); } }
private object InitializePlugin(CCProcessingCenter aProcCenter) { object plugin = null; try { Type processorType = PXBuildManager.GetType(aProcCenter.ProcessingTypeName, true); plugin = Activator.CreateInstance(processorType); } catch (Exception) { throw new PXException(Messages.ERR_ProcessingCenterTypeInstanceCreationFailed, aProcCenter.ProcessingTypeName, aProcCenter.ProcessingCenterID); } return(plugin); }
private IReadOnlyDictionary <string, Type> ConvertTables(Report report) { var graph = new PXGraph(); var tableTypes = new Dictionary <string, Type>(StringComparer.OrdinalIgnoreCase); foreach (var table in Base.Tables.Select().RowCast <GITable>() .Where(t => !String.IsNullOrEmpty(t.Name) && !String.IsNullOrEmpty(t.Alias))) { Type type = PXBuildManager.GetType(table.Name, false); if (type == null) { continue; } tableTypes[table.Alias] = type; } foreach (var type in tableTypes.Values.Distinct()) { var reportTable = new ReportTable(type.Name) { FullName = type.FullName, }; PXCache cache = graph.Caches[type]; foreach (string field in cache.Fields) { var fieldInfo = ApiFieldInfo.Create(cache, field); if (fieldInfo == null) { continue; } var reportField = new ReportField(field); TypeCode typeCode = Type.GetTypeCode(fieldInfo.DataType); if (typeCode != TypeCode.Empty) { reportField.DataType = typeCode; } reportTable.Fields.Add(reportField); } report.Tables.Add(reportTable); } return(tableTypes); }
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()); }
private Guid?FindMatchingNoteIDForFolder(string screenID, string keyValues) { string graphType = PXPageIndexingService.GetGraphTypeByScreenID(screenID); if (string.IsNullOrEmpty(graphType)) { throw new PXException(Messages.PrimaryGraphForScreenIDNotFound, screenID); } string primaryViewName = PXPageIndexingService.GetPrimaryView(graphType); if (string.IsNullOrEmpty(primaryViewName)) { throw new PXException(Messages.PrimaryGraphForScreenIDNotFound, graphType); } var viewDescription = new Data.Description.PXViewDescription(primaryViewName); KeyValuePair <string, string>[] keyValuePairs; var graph = PXGraph.CreateInstance(PXBuildManager.GetType(graphType, true)); try { keyValuePairs = GetKeyValuePairsFromKeyValues(graph, primaryViewName, keyValues); } catch (FolderNameKeyValuesMismatchException) { return(null); } var view = graph.Views[primaryViewName]; ScreenUtils.SelectCurrent(view, viewDescription, keyValuePairs); if (view.Cache.Current == null) { return(null); } else { return(PXNoteAttribute.GetNoteID(view.Cache, view.Cache.Current, EntityHelper.GetNoteField(view.Cache.Current.GetType()))); } }
static ShowRouter() { _instance = new ShowRouter(); _kbArticleType = -1; Type attType; FieldInfo typeConst; if ((attType = PXBuildManager.GetType(_WIKIARTICLETYPE_ATTRIBUTE_TYPE, false)) != null && (typeConst = attType.GetField(_TYPE_CONST_NAME)) != null) { _kbArticleType = (int)typeConst.GetValue(null); } Type twaType; if ((twaType = PXBuildManager.GetType(_TEMPLATEWIKIARTICLE_TYPE, false)) != null) { _isTemplateArticle = twaType.GetMethod(_IS_TEMPLATE_METHOD); } }
protected virtual void BoxScreenConfiguration_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { var screenConfig = e.Row as BoxScreenConfiguration; if (!string.IsNullOrEmpty(screenConfig.ScreenID)) { string graphTypeName = PXPageIndexingService.GetGraphTypeByScreenID(screenConfig.ScreenID); if (string.IsNullOrEmpty(graphTypeName)) { throw new PXException(Messages.PrimaryGraphForScreenIDNotFound, screenConfig.ScreenID); } Type graphType = PXBuildManager.GetType(graphTypeName, true); var graph = PXGraph.CreateInstance(graphType); string primaryViewName = PXPageIndexingService.GetPrimaryView(graphTypeName); PXView view = graph.Views[primaryViewName]; //Construct ddl values and displayed values, specifying field name for duplicates var fieldsArray = PXFieldState.GetFields(graph, view.BqlSelect.GetTables(), true); var displayNames = fieldsArray.GroupBy(fa => fa.DisplayName).ToDictionary(k => k.Key, v => v.ToList()); var labels = new List <string>(); var values = new List <string>(); foreach (var displayName in displayNames) { if (displayName.Value.Count > 1) { foreach (var displayNameField in displayName.Value) { labels.Add($"{displayName.Key} ({displayNameField.Name})"); values.Add(displayNameField.Name); } } else { labels.Add(displayName.Key); values.Add(displayName.Value.FirstOrDefault()?.Name); } } PXStringListAttribute.SetList <BoxScreenGroupingFields.fieldName>(Fields.Cache, null, values.ToArray(), labels.ToArray()); } }
private static PXGraph InitializeGraph(string graphType) { Type type = null; if (graphType != null) { type = PXBuildManager.GetType(graphType, false); if (type == null) { throw new PXException(PXMessages.LocalizeFormatNoPrefixNLA(Messages.TypeCannotBeFound, graphType)); } if (!typeof(PXGraph).IsAssignableFrom(type)) { throw new PXException(PXMessages.LocalizeFormatNoPrefixNLA(Messages.IsNotGraphSubclass, graphType)); } } PXGraph graph = type != null?PXGraph.CreateInstance(type) : null; return(graph ?? new PXGraph()); }
private static PXGraph InitializeGraph(string graphType) { Type type = null; if (graphType != null) { type = PXBuildManager.GetType(graphType, false); if (type == null) { throw new PXException(graphType + " type cannot be found."); } if (!typeof(PXGraph).IsAssignableFrom(type)) { throw new PXException(graphType + " is not a graph subclass."); } } PXGraph graph = type != null?PXGraph.CreateInstance(type) : null; return(graph ?? new PXGraph()); }
protected ICardTransactionProcessingWrapper GetProcessingWrapper(CCProcessingContext context) { if (context.processingCenter == null) { throw new PXException(Messages.ERR_CCProcessingCenterNotFound); } object processor; try { Type processorType = PXBuildManager.GetType(context.processingCenter.ProcessingTypeName, true); processor = Activator.CreateInstance(processorType); } catch (Exception) { throw new PXException(Messages.ERR_ProcessingCenterTypeInstanceCreationFailed, context.processingCenter.ProcessingTypeName, context.processingCenter.ProcessingCenterID); } return(_processingWrapper(processor, context)); }
private int?GetCategory() { if (searchType == SearchService.SearchLookupType.ActiveModule) { foreach (SearchService.SearchLookupItem item in comboBoxLookupList) { if (item.Type == SearchService.SearchLookupType.ActiveModule && !string.IsNullOrEmpty(item.Module)) { //Had to use reflection so that Acumatica Studio can compile. Type searchCategoryType = PXBuildManager.GetType("PX.Objects.SM.SearchCategory", false); if (searchCategoryType != null) { MethodInfo method = searchCategoryType.GetMethod("Parse"); return(Convert.ToInt32(method.Invoke(null, new object[] { item.Module }))); } } } } return(null); }
private static IAddressValidationService Create(Country country) { IAddressValidationService processor = null; string processorTypeAsString = country.AddressVerificationTypeName; if (string.IsNullOrEmpty(processorTypeAsString) == false) { try { Type processorType = PXBuildManager.GetType(processorTypeAsString, true); processor = (IAddressValidationService)Activator.CreateInstance(processorType); } catch (HttpException e) { throw new PXException(e, Messages.AddressVerificationServiceCreationErrorHTTP, processorTypeAsString); } catch (Exception e) { throw new PXException(e, Messages.AddressVerificationServiceCreationError, processorTypeAsString); } } return(processor); }
public static void TransferDocProcessingCenter(PXGraph graph, CABatch doc, CABatchExt docExt) { var pcGraph = PXGraph.CreateInstance <CCProcessingCenterMaint>(); pcGraph.ProcessingCenter.Current = pcGraph. ProcessingCenter. Search <CCProcessingCenter.processingCenterID> (docExt.ProcessingCenterID); var processingCenter = pcGraph.ProcessingCenter.Current; if (processingCenter != null) { var providerIsDirectDeposit = PXMultipleProviderTypeSelectorAttribute.IsProvider <CCProcessingCenter.processingTypeName, IDDPaymentProcessing>(pcGraph.ProcessingCenter.Cache, processingCenter); if (providerIsDirectDeposit) { IDDPaymentProcessing provider = null; try { Type providerType = PXBuildManager.GetType(processingCenter.ProcessingTypeName, true); provider = (IDDPaymentProcessing)Activator.CreateInstance(providerType); provider.Initialize(pcGraph); } catch (Exception ex) { throw new PXException(Messages.FailedToCreateDirectDepositProvider, ex.Message); } var fileNotes = PXNoteAttribute.GetFileNotes(graph.Views[graph.PrimaryView].Cache, doc); if (fileNotes.Length == 1) { var fileNote = fileNotes[0]; UploadFileMaintenance upload = PXGraph.CreateInstance <UploadFileMaintenance>(); var file = upload.GetFile(fileNote); string message; if (!provider.DoTransaction(file.FullName, file.BinData, out message)) { throw new PXException(message); } else { docExt.FileTransferTime = DateTime.Now; graph.Views[graph.PrimaryView].Cache.Update(doc); graph.Actions.PressSave(); } } else { if (fileNotes.Length > 1) { throw new Exception(Messages.ACHTransferFailMoreThanOneAttachment); } else { throw new PXException(Messages.ACHTransferFailNoAttachment); } } } else { throw new PXException(Messages.ACHTransferFailProviderIsNotForDirectDeposit); } } else { throw new PXException(Messages.ACHTransferFailNoProcessingCenterSelected); } }
public ExtensionSorting() { PXBuildManager.SortExtensions += (list) => PXBuildManager.PartialSort(list, _order); }
public static Type GetPluginType(string typeName) { Type pluginType = PXBuildManager.GetType(typeName, true); return(pluginType); }
private static void StableSort(List <Type> list) { PXBuildManager.PartialSort(list, _order); }
public static bool IsFeatureSupported(CCProcessingCenter ccProcessingCenter, CCProcessingFeature feature) { return(ccProcessingCenter != null && !string.IsNullOrEmpty(ccProcessingCenter.ProcessingTypeName) && IsFeatureSupported(PXBuildManager.GetType(ccProcessingCenter.ProcessingTypeName, true), feature)); }