Example #1
0
        /// <summary>
        /// Creates a builder of the desired type
        /// </summary>
        /// <param name="db">Database id</param>
        /// <param name="path">Path to PX-file or datatable</param>
        /// <returns>The created Paxiom model builder</returns>
        protected static internal PCAxis.Paxiom.IPXModelBuilder CreatePaxiomBuilder(string db, string path)
        {
            PCAxis.Paxiom.IPXModelBuilder builder = null;
            DatabaseInfo dbi = PXWeb.Settings.Current.General.Databases.GetDatabase(db);

            if (dbi.Type == PCAxis.Web.Core.Enums.DatabaseType.PX)
            {
                string fullPath = System.IO.Path.Combine(
                    System.Web.HttpContext.Current.Server.MapPath(Settings.Current.General.Paths.PxDatabasesPath),
                    path);
                builder = new PCAxis.Paxiom.PXFileBuilder();
                builder.SetPath(fullPath);
            }
            else
            {
                //it seems the incomming path here already is db:tableid . (In the paralell method in SSDHandler.cs it is not)
                builder = new PCAxis.PlugIn.Sql.PXSQLBuilder();
                if (path.Contains(":"))
                {
                    builder.SetPath(path);
                }
                else
                {
                    builder.SetPath(db + ":" + path);
                }
            }

            return(builder);
        }
Example #2
0
        /// <summary>
        /// Get PxModel object from CNMM database
        /// </summary>
        /// <param name="dbId">Database id</param>
        /// <param name="language">Language</param>
        /// <param name="tableId">String specifiying the table</param>
        /// <returns>PxModel object for the specified table</returns>
        private PXModel GetCnmmModel(string dbId, string language, string tableId)
        {
            try
            {
                PCAxis.PlugIn.Sql.PXSQLBuilder builder = new PCAxis.PlugIn.Sql.PXSQLBuilder();
                builder.SetPreferredLanguage(language);
                builder.SetPath(string.Format("{0}:{1}", dbId, tableId));
                builder.BuildForSelection();

                return(builder.Model);
            }
            catch (Exception ex)
            {
                _logger.Error("PCAxis.Search PxModelManager::GetCnmmModel : " + ex.Message);
            }

            return(null);
        }
Example #3
0
        /// <summary>
        /// Creates and returns an IPXModelBuilder depending on the type of database provided
        /// </summary>
        /// <param name="language">database language</param>
        /// <param name="db">id for the database</param>
        /// <param name="tablePath">path to the table</param>
        /// <returns>The builder for the table</returns>
        private static PCAxis.Paxiom.IPXModelBuilder GetPXBuilder(string language, string db, string[] tablePath)
        {
            PCAxis.Paxiom.IPXModelBuilder builder;
            switch (ExposedDatabases.DatabaseConfigurations[language][db].Type)
            {
            case "PX":
                builder = new PCAxis.Paxiom.PXFileBuilder();
                builder.SetPath(ExposedDatabases.DatabaseConfigurations[language][db].RootPath + "\\" + string.Join("\\", tablePath.ToArray()));
                break;

            case "CNMM":
                builder = new PCAxis.PlugIn.Sql.PXSQLBuilder();
                builder.SetPath(string.Format("{0}:{1}", db, tablePath.Last()));
                break;

            default:
                throw new NotImplementedException("Database type not implemented");
            }
            return(builder);
        }