예제 #1
0
 /// <summary>
 /// Creates Icon tables for all available language
 /// </summary>
 /// <param name="dbConnection"></param>
 /// <param name="dbQueries"></param>
 /// <param name="forOnlineDB"></param>
 public static void CreateIconsTblsForAllLngs(DIConnection dbConnection, DIQueries dbQueries, bool forOnlineDB)
 {
     if (DIIcons.IsIconsTblExists(dbQueries.TablesName.Icons, dbConnection) == false)
     {
         try
         {
             //-- create Icon table
             dbConnection.ExecuteNonQuery(DIIcons.CreateIconsTbl(dbQueries.TablesName.Icons, forOnlineDB));
         }
         catch (Exception ex)
         {
             throw new ApplicationException(ex.Message);
         }
     }
 }
예제 #2
0
        /// <summary>
        /// Dictionary containing old IconNId as key and new IconNId as value.
        /// This information shall be utilised to update metadata xml being inserted / updated
        /// </summary>
        /// <param name="NidInSourceDB"></param>
        /// <param name="NidInTargetDB"></param>
        /// <param name="elementType"></param>
        /// <param name="sourceQurey"></param>
        /// <param name="SourceDBConnection"></param>
        /// <param name="targetQurey"></param>
        /// <param name="TargetDBConnection"></param>
        /// <returns>
        /// </returns>
        /// <remarks></remarks>
        public static Dictionary <string, string> ImportElement(int NidInSourceDB, int NidInTargetDB, IconElementType elementType, DIQueries sourceQurey, DIConnection sourceDBConnection, DIQueries targetQurey, DIConnection targetDBConnection)
        {
            Dictionary <string, string> RetVal = new Dictionary <string, string>();

            string    ElementValue = DIIcons.Elements[elementType];
            string    SqlQuery     = string.Empty;
            DataTable IconsDatatable;
            string    OldIconNId = string.Empty;
            string    NewIconNId = string.Empty;

            try {
                if ((sourceDBConnection != null))
                {
                    if (DIIcons.IsIconsTblExists(sourceQurey.TablesName.Icons, sourceDBConnection))
                    {
                        //-- In Target Database: delete records from UT_Icon table if Icon is already associated with given Element Type
                        SqlQuery = DevInfo.Lib.DI_LibDAL.Queries.Icon.Delete.DeleteIcon(targetQurey.DataPrefix, ElementValue, NidInTargetDB.ToString());
                        targetDBConnection.ExecuteNonQuery(SqlQuery);


                        //-- In Source Database: check Icon is associated with the given Element type in UT_ICon table
                        SqlQuery       = sourceQurey.Icon.GetIcon(NidInSourceDB.ToString(), ElementValue);
                        IconsDatatable = sourceDBConnection.ExecuteDataTable(SqlQuery);

                        //-- If associated, then copy it it from Source database into target database
                        foreach (DataRow Row in IconsDatatable.Rows)
                        {
                            //-- Insert Icon and get new IconNId
                            NewIconNId = DIIcons.InsertIcon(targetDBConnection, targetQurey, (byte[])(Row["Element_Icon"]), Row["Icon_Type"].ToString(), Convert.ToInt32(Row["Icon_Dim_W"]), Convert.ToInt32(Row["Icon_Dim_H"]), ElementValue, Convert.ToString(NidInTargetDB)).ToString();

                            //-- Add Item to Dictionary with New IconNId as Key and Old IconNId as Value
                            RetVal.Add(IMG_PREFIX + Row["Icon_NId"].ToString() + ".", IMG_PREFIX + NewIconNId + ".");
                        }
                    }
                }
            }
            catch (Exception ex) {
                throw new ApplicationException(ex.Message);
            }
            return(RetVal);
        }