public static SystemParameter GetSystemParameter()
 {
     SystemParameter sp = new SystemParameter();
     sp.Key = "SystemParameter" + RandomIntModifier() + RandomIntModifier();
     sp.Value = RandomIntModifier().ToString();
     return sp;
 }
 public void SetValue(string key, object value)
 {
     SystemParameter sp = spr.GetByKey(key);
     if (sp == null)
     {
         sp = new SystemParameter();
         sp.Key = key;
         sp.Value = value.ToString();
         spr.Save(sp);
     }
     else
     {
         sp.Value = value.ToString();
         spr.Update(sp.Id, sp);
     }
 }
        public static void Initialize()
        {
            if (SystemPropertyService.GetInstance().GetValue(Common.Dictionary.SystemProperties.SP_SCADA_NAME) == null)
            {
                SystemParameter scadaName = new SystemParameter();
                scadaName.Key = Common.Dictionary.SystemProperties.SP_SCADA_NAME;
                scadaName.Value = "RapidScada";
                spr.Save(scadaName);
            }

            if (SystemPropertyService.GetInstance().GetValue(Common.Dictionary.SystemProperties.SP_CLOUD_HOST) == null)
            {
                SystemParameter cloudIp = new SystemParameter();
                cloudIp.Key = Common.Dictionary.SystemProperties.SP_CLOUD_HOST;
                cloudIp.Value = "http://scadadiploma.azurewebsites.net";
                spr.Save(cloudIp);
            }

            if (SystemPropertyService.GetInstance().GetValue(Common.Dictionary.SystemProperties.SP_SCADA_ID) == null)
            {
                SystemParameter scadaId = new SystemParameter();
                scadaId.Key = Common.Dictionary.SystemProperties.SP_SCADA_ID;
                scadaId.Value = "";
                spr.Save(scadaId);
            }

            if (SystemPropertyService.GetInstance().GetValue(Common.Dictionary.SystemProperties.SP_REGISTERED) == null)
            {
                SystemParameter registered = new SystemParameter();
                registered.Key = Common.Dictionary.SystemProperties.SP_REGISTERED;
                registered.Value = false.ToString();
                spr.Save(registered);
            }


        }