Beispiel #1
0
 public string GetPropertyFromConfigFile(PropertyEnum propertyEnum)
 {
     try
     {
         var eleName = PropertyEnumMap.GetPropertyEnumText(propertyEnum);
         if (null == rootElement)
         {
             throw new Exception("getPropertyFromConfigFile: root Element is NULL");
         }
         if (null == rootElementCommon)
         {
             throw new Exception("getPropertyFromCommonFile: root Element is NULL");
         }
         var pElement = rootElement.Element(eleName);
         if (null == pElement)
         {
             pElement = rootElementCommon.Element(eleName);
         }
         if (null == pElement)
         {
             return(null);
         }
         return(pElement.Value);
     }
     catch (Exception ex)
     {
         log.Error(ex.Message);
         throw ex;
     }
 }
Beispiel #2
0
 public static LALProperties GetInstance()
 {
     if (_instance == null)
     {
         _instance = new LALProperties();
         foreach (var map in PropertyEnumMap.GetPropertiesMaps())
         {
             _properties.Add(map.Key, string.Empty);
         }
     }
     return(_instance);
 }
Beispiel #3
0
        public static void LoadSettingsFromConfFile(bool isUpdateKVList)
        {
            var errNo        = ErrorNumberEnum.PLCM_SAMPLE_OK;
            var propertyMaps = PropertyEnumMap.GetPropertiesMaps();
            var properties   = lalProperties.GetProperties();

            foreach (var map in propertyMaps)
            {
                var key = map.Key;
                var val = confManager.GetPropertyFromConfigFile(key);
                if (null != val)
                {
                    if (PropertyEnum.NULL != key)
                    {
                        switch (key)
                        {
                        case PropertyEnum.SIP_PROXY_SERVER_ADDRESS:
                        case PropertyEnum.SIP_USERNAME:
                        case PropertyEnum.SIP_PASSWORD:
                        case PropertyEnum.PLCM_MFW_KVLIST_KEY_REG_ID:
                        {
                            val = string.Empty;
                        }
                        break;
                        }
                        lalProperties.SetProperty(key, val);
                        if (isUpdateKVList)
                        {
                            errNo = WrapperProxy.SetProperty(key, properties[key]);
                            if (ErrorNumberEnum.PLCM_SAMPLE_OK != errNo)
                            {
                                log.Error("AddProperty failed. Error number = " + errNo.ToString());
                                throw new Exception("AddProperty failed");
                            }
                        }
                    }
                    else
                    {
                        log.Error("no such setting in PropertyEnum for key" + key);
                        throw new Exception("no such setting in PropertyEnum for key" + key);
                    }
                }
            }
        }