Example #1
0
            /// <summary>
            /// XML Comment
            /// </summary>
            /// <param name="dt"></param>
            /// <returns></returns>
            /// <remarks></remarks>
            private Dictionary <string, ConfigurationItem> GetConfigurationItems(DataTable dt)
            {
                var results = new Dictionary <string, ConfigurationItem>();

                foreach (DataRow row in dt.Rows)
                {
                    try
                    {
                        var id                   = Utilities.CheckForDBNull_String(row["ID"]);
                        var configID             = Utilities.CheckForDBNull_String(row["CONFIG_ID"]);
                        ConfigurationItem config = new ConfigurationItem();
                        config.DisplayName         = Utilities.CheckForDBNull_String(row["DISPLAY_NAME"]);
                        config.DefaultName         = Utilities.CheckForDBNull_String(row["DEFAULT_NAME"]);
                        config.TableName           = Utilities.CheckForDBNull_String(row["TABLE_NAME"]);
                        config.DefaultKey1         = Utilities.CheckForDBNull_String(row["DEFAULT_KEY1"]);
                        config.DefaultKey2         = Utilities.CheckForDBNull_String(row["DEFAULT_KEY2"]);
                        config.DefaultKey3         = Utilities.CheckForDBNull_String(row["DEFAULT_KEY3"]);
                        config.DefaultKey4         = Utilities.CheckForDBNull_String(row["DEFAULT_KEY4"]);
                        config.VariableKey1        = Utilities.CheckForDBNull_String(row["VARIABLE_KEY1"]);
                        config.VariableKey2        = Utilities.CheckForDBNull_String(row["VARIABLE_KEY2"]);
                        config.VariableKey3        = Utilities.CheckForDBNull_String(row["VARIABLE_KEY3"]);
                        config.VariableKey4        = Utilities.CheckForDBNull_String(row["VARIABLE_KEY4"]);
                        config.AllowedValues       = GetAllowedValues(row);
                        config.AllowedPlaceHolders = Utilities.CheckForDBNull_String(row["ALLOWED_PLACE_HOLDER"]);
                        config.Description         = Utilities.CheckForDBNull_String(row["DESCRIPTION"]);
                        config.DefaultValue        = Utilities.CheckForDBNull_String(row["DEFAULT_VALUE"]);
                        config.CurrentValue        = config.DefaultValue;
                        config.UpdatedValue        = config.DefaultValue;
                        if (config.VariableKey1 == "*ALL")
                        {
                            UpdateConfigItem(configID, config);
                        }
                        config.GuidValue = guidGenerator.GenerateGUIDString(System.Convert.ToInt32(id), ConfigurationEntity.GetEntity(row));
                        var prevConfigId = configID.Substring(0, configID.LastIndexOf("-"));
                        var newConfigId  = config.GuidValue.Substring(0, config.GuidValue.LastIndexOf("-"));
                        if (prevConfigId == newConfigId)
                        {
                            results.Add(configID, config);
                        }
                    }
                    catch (InvalidConfigurationException)
                    {
                        //NOTE: Do nothing so it will skip this configuration and proceed with next.
                    }
                }
                return(results);
            }
Example #2
0
            public bool UpdateEntity(ConfigurationEntity entity, string moduleName)
            {
                bool          result        = false;
                GUIDGenerator guidGenerator = new GUIDGenerator();

                entity.NewConfigurationId = guidGenerator.GenerateGUIDString(guidGenerator.ExtractUniqueId(entity.ConfigurationId), entity);
                string           commandText           = "UPDATE [tbl_config_detail] SET CONFIG_ID= @NEW_CONFIG_ID, DISPLAY_NAME = @DISPLAY_NAME, DEFAULT_VALUE = @DEFAULT_VALUE, ALLOWED_VALUE = @ALLOWED_VALUE, ALLOWED_PLACE_HOLDER = @ALLOWED_PLACE_HOLDER, Description = @Description, MODULE_NAME=@MODULE_NAME, LASTMODIFIED_TIMESTAMP=GETDATE() WHERE CONFIG_ID=@CONFIG_ID";
                int              affectedRows          = 0;
                TalentDataAccess talentSqlAccessDetail = new TalentDataAccess();
                ErrorObj         err = new ErrorObj();

                //Construct The Call
                talentSqlAccessDetail.Settings = settings;
                talentSqlAccessDetail.CommandElements.CommandExecutionType = CommandExecution.ExecuteNonQuery;
                talentSqlAccessDetail.CommandElements.CommandText          = commandText;
                talentSqlAccessDetail.CommandElements.CommandParameter.Add(Utilities.ConstructParameter("@NEW_CONFIG_ID", entity.NewConfigurationId));
                talentSqlAccessDetail.CommandElements.CommandParameter.Add(Utilities.ConstructParameter("@DISPLAY_NAME", entity.DisplayName));
                talentSqlAccessDetail.CommandElements.CommandParameter.Add(Utilities.ConstructParameter("@DEFAULT_VALUE", entity.DefaultValue));
                talentSqlAccessDetail.CommandElements.CommandParameter.Add(Utilities.ConstructParameter("@ALLOWED_VALUE", entity.AllowedValues));
                talentSqlAccessDetail.CommandElements.CommandParameter.Add(Utilities.ConstructParameter("@ALLOWED_PLACE_HOLDER", entity.AllowedPlaceHolders));
                talentSqlAccessDetail.CommandElements.CommandParameter.Add(Utilities.ConstructParameter("@Description", entity.Description));
                talentSqlAccessDetail.CommandElements.CommandParameter.Add(Utilities.ConstructParameter("@CONFIG_ID", entity.ConfigurationId));
                talentSqlAccessDetail.CommandElements.CommandParameter.Add(Utilities.ConstructParameter("@MODULE_NAME", moduleName));
                //Execute
                err = talentSqlAccessDetail.SQLAccess(DestinationDatabase.TALENT_CONFIG);
                if ((!(err.HasError)) && (!(talentSqlAccessDetail.ResultDataSet == null)))
                {
                    affectedRows = System.Convert.ToInt32(talentSqlAccessDetail.ResultDataSet.Tables[0].Rows[0][0]);
                }
                talentSqlAccessDetail = null;
                if (affectedRows > 0)
                {
                    if (entity.ConfigurationId == entity.NewConfigurationId)
                    {
                        entity.NewConfigurationId = string.Empty;
                    }
                    return(true);
                }
                return(false);
            }