Exemple #1
0
        }       //	prepare

        /// <summary>
        /// messages
        /// </summary>
        /// <returns>string</returns>
        protected override String DoIt()
        {
            log.Info("AD_Language=" + _AD_Language
                     + ",Mode=" + _ImportExport
                     + ",Scope=" + _ExportScope
                     + ",AD_Table_ID=" + _AD_Table_ID
                     + ",Level=" + _TranslationLevel
                     + ",Directory=" + _Directory);
            //

            TranslationMgr t   = new TranslationMgr(GetCtx());
            String         msg = t.ValidateLanguage(_AD_Language);

            if (msg.Length > 0)
            {
                throw new Exception("@LanguageSetupError@ - " + msg);
            }

            t.SetByExportID(_ByExportID);
            //	Mode
            bool imp = Mode_Import.Equals(_ImportExport);
            //	Client
            int AD_Client_ID = 0;

            if (ExportScope_Tenant.Equals(_ExportScope))
            {
                AD_Client_ID = GetCtx().GetAD_Client_ID();
            }
            t.SetExportScope(_ExportScope, AD_Client_ID);

            //	Directory
            if (Utility.Util.IsEmpty(_Directory))
            {
                _Directory = DataBase.Ini.GetFrameworkHome();//
            }
            #region [Module Parameter Check]
            // Added by Sukhwinder on 23 June,2017 for creating translations on the basis of Modules.
            MModuleInfo module = null;
            if (_AD_ModuleInfo_ID != 0)
            {
                module = new MModuleInfo(GetCtx(), _AD_ModuleInfo_ID, null);
            }
            #endregion

            int noWords = 0;
            //	All Tables
            if (_AD_Table_ID == 0)
            {
                String sql = "SELECT * FROM AD_Table WHERE IsActive='Y' AND IsView='N'"
                             + " AND TableName LIKE '%_Trl' AND TableName<>'AD_Column_Trl'";
                if (ExportScope_Tenant.Equals(_ExportScope))
                {
                    sql += " AND AccessLevel<>'4'";     //	System Only
                }
                else
                {
                    sql += " AND AccessLevel NOT IN ('1','2','3')";     // Org/Client/Both
                }
                sql += " ORDER BY TableName";
                List <MTable> tables = MTable.GetTablesByQuery(GetCtx(), sql);
                foreach (MTable table in tables)
                {
                    String tableName = table.GetTableName();
                    msg = null;

                    //msg = imp ? t.ImportTrl(_Directory, table.GetTableName()) : t.ExportTrl(_Directory, table.GetTableName(), _TranslationLevel);   // Commented and added following code in IF-ELSE on the basis of Module parameter.(Sukhwinder)

                    if (module == null)
                    {
                        msg = imp ? t.ImportTrl(_Directory, tableName) : t.ExportTrl(_Directory, tableName, _TranslationLevel);
                    }
                    else
                    {
                        msg = imp ? t.ImportTrl(_Directory, tableName) : t.ExportTrl(_Directory, tableName, _TranslationLevel, module.GetPrefix()); // by Sukhwinder on 23 June, 2017
                    }

                    //if (!msg.Contains("Updated"))
                    //{
                    //    msg = "Updated=0";
                    //}
                    AddLog(msg);
                }
                noWords = t.GetWordCount();
            }
            else        //	single table
            {
                MTable table = MTable.Get(GetCtx(), _AD_Table_ID);
                msg = null;

                //msg = imp ? t.ImportTrl(_Directory, table.GetTableName()) : t.ExportTrl(_Directory, table.GetTableName(), _TranslationLevel);   // Commented and added following code in IF-ELSE on the basis of Module parameter.(Sukhwinder)

                if (module == null)
                {
                    msg = imp ? t.ImportTrl(_Directory, table.GetTableName()) : t.ExportTrl(_Directory, table.GetTableName(), _TranslationLevel);
                }
                else
                {
                    msg = imp ? t.ImportTrl(_Directory, table.GetTableName()) : t.ExportTrl(_Directory, table.GetTableName(), _TranslationLevel, module.GetPrefix()); // by Sukhwinder on 23 June, 2017
                }

                //if (!msg.Contains("Updated"))
                //{
                //    msg = "Updated=0";
                //}
                AddLog(msg);
                noWords = t.GetWordCount();
            }
            //

            //return ("Word Count = " + noWords);

            return(Msg.GetMsg(GetCtx(), "WordCount") + " = " + noWords);
        }
        }       //	prepare

        /// <summary>
        /// messages
        /// </summary>
        /// <returns>string</returns>
        protected override String DoIt()
        {
            if (string.IsNullOrEmpty(_prefix) || string.IsNullOrEmpty(_Directory))
            {
                throw new Exception("@Error@ - prefix or folder path not found");
            }

            log.Info("AD_Language=" + _AD_Language
                     + ",Mode=" + _ImportExport
                     + ",Scope=" + _ExportScope
                     + ",AD_Table_ID=" + _AD_Table_ID
                     + ",Level=" + _TranslationLevel
                     + ",Directory=" + _Directory);

            if (!System.IO.Directory.Exists(_Directory))
            {
                try
                {
                    System.IO.Directory.CreateDirectory(_Directory);
                }
                catch (Exception e)
                {
                    throw e;
                }
            }

            TranslationMgr t = new TranslationMgr(_ctx);

            t.SetPrefix(_prefix);
            t.SetByExportID(true);


            String msg = t.ValidateLanguage(_AD_Language);

            if (msg.Length > 0)
            {
                throw new Exception("@LanguageSetupError@ - " + msg);
            }

            //	Mode
            bool imp = Mode_Import.Equals(_ImportExport);
            //	Client
            int AD_Client_ID = 0;

            if (ExportScope_Tenant.Equals(_ExportScope))
            {
                AD_Client_ID = _ctx.GetAD_Client_ID();
            }
            t.SetExportScope(_ExportScope, AD_Client_ID);

            //	Directory
            if (Util.IsEmpty(_Directory))
            {
                _Directory = VAdvantage.DataBase.Ini.GetFrameworkHome();//
            }
            int noWords = 0;

            //	All Tables
            if (_AD_Table_ID == 0)
            {
                String sql = "SELECT * FROM AD_Table WHERE IsActive='Y' AND IsView='N'"
                             + " AND TableName LIKE '%_Trl' AND TableName<>'AD_Column_Trl'";
                if (ExportScope_Tenant.Equals(_ExportScope))
                {
                    sql += " AND AccessLevel<>'4'";     //	System Only
                }
                else
                {
                    sql += " AND AccessLevel NOT IN ('1','2','3')";     // Org/Client/Both
                }
                sql += " ORDER BY TableName";
                List <MTable> tables = MTable.GetTablesByQuery(_ctx, sql);
                foreach (MTable table in tables)
                {
                    String tableName = table.GetTableName();
                    msg = null;
                    msg = imp
                        ? t.ImportTrl(_Directory, tableName)
                        : t.ExportTrl(_Directory, tableName, _TranslationLevel);
                    AddLog(msg);
                }
                noWords = t.GetWordCount();
            }
            else        //	single table
            {
                MTable table = MTable.Get(_ctx, _AD_Table_ID);
                msg = null;
                msg = imp
                    ? t.ImportTrl(_Directory, table.GetTableName())
                    : t.ExportTrl(_Directory, table.GetTableName(), _TranslationLevel);
                AddLog(msg);
                noWords = t.GetWordCount();
            }
            //
            sb.Append("Word Count = " + noWords);
            return(sb.ToString());
        }
Exemple #3
0
        }       //	prepare

        /// <summary>
        /// messages
        /// </summary>
        /// <returns>string</returns>
        protected override String DoIt()
        {
            log.Info("AD_Language=" + _AD_Language
                     + ",Mode=" + _ImportExport
                     + ",Scope=" + _ExportScope
                     + ",AD_Table_ID=" + _AD_Table_ID
                     + ",Level=" + _TranslationLevel
                     + ",Directory=" + _Directory);
            //

            TranslationMgr t   = new TranslationMgr(GetCtx());
            String         msg = t.ValidateLanguage(_AD_Language);

            if (msg.Length > 0)
            {
                throw new Exception("@LanguageSetupError@ - " + msg);
            }

            t.SetByExportID(_ByExportID);
            //	Mode
            bool imp = Mode_Import.Equals(_ImportExport);
            //	Client
            int AD_Client_ID = 0;

            if (ExportScope_Tenant.Equals(_ExportScope))
            {
                AD_Client_ID = GetCtx().GetAD_Client_ID();
            }
            t.SetExportScope(_ExportScope, AD_Client_ID);

            //	Directory
            if (Utility.Util.IsEmpty(_Directory))
            {
                _Directory = DataBase.Ini.GetFrameworkHome();//
            }
            int noWords = 0;

            //	All Tables
            if (_AD_Table_ID == 0)
            {
                String sql = "SELECT * FROM AD_Table WHERE IsActive='Y' AND IsView='N'"
                             + " AND TableName LIKE '%_Trl' AND TableName<>'AD_Column_Trl'";
                if (ExportScope_Tenant.Equals(_ExportScope))
                {
                    sql += " AND AccessLevel<>'4'";     //	System Only
                }
                else
                {
                    sql += " AND AccessLevel NOT IN ('1','2','3')";     // Org/Client/Both
                }
                sql += " ORDER BY TableName";
                List <MTable> tables = MTable.GetTablesByQuery(GetCtx(), sql);
                foreach (MTable table in tables)
                {
                    String tableName = table.GetTableName();
                    msg = null;
                    msg = imp
                        ? t.ImportTrl(_Directory, tableName)
                        : t.ExportTrl(_Directory, tableName, _TranslationLevel);
                    //if (!msg.Contains("Updated"))
                    //{
                    //    msg = "Updated=0";
                    //}
                    AddLog(msg);
                }
                noWords = t.GetWordCount();
            }
            else        //	single table
            {
                MTable table = MTable.Get(GetCtx(), _AD_Table_ID);
                msg = null;
                msg = imp
                    ? t.ImportTrl(_Directory, table.GetTableName())
                    : t.ExportTrl(_Directory, table.GetTableName(), _TranslationLevel);
                //if (!msg.Contains("Updated"))
                //{
                //    msg = "Updated=0";
                //}
                AddLog(msg);
                noWords = t.GetWordCount();
            }
            //
            return("Word Count = " + noWords);
        }