Skip to content

Commit

Permalink
fix 2nd init fail
Browse files Browse the repository at this point in the history
  • Loading branch information
Smilefounder committed Mar 25, 2018
1 parent 539def6 commit d281fb6
Showing 1 changed file with 18 additions and 27 deletions.
45 changes: 18 additions & 27 deletions src/Swastika.Cms.Lib/Services/GlobalConfigurationService.cs
Expand Up @@ -23,32 +23,26 @@ public class GlobalConfigurationService
public string Name { get; set; }
public bool IsInit { get; set; }

public string ConnectionString
{
get
{
public string ConnectionString {
get {
return _connectionString;
}
set
{
set {
_connectionString = value;
}
}

private static List<ConfigurationViewModel> _listConfiguration;

public static List<ConfigurationViewModel> ListConfiguration
{
get
{
public static List<ConfigurationViewModel> ListConfiguration {
get {
if (_listConfiguration == null)
{
InitConfigurations();
}
return _listConfiguration;
}
set
{
set {
_listConfiguration = value;
}
}
Expand All @@ -71,14 +65,11 @@ public static List<ConfigurationViewModel> ListConfiguration
//}
private static GlobalConfigurationService _instance;

public static GlobalConfigurationService Instance
{
get
{
public static GlobalConfigurationService Instance {
get {
return _instance ?? (_instance = new GlobalConfigurationService());
}
set
{
set {
_instance = value;
}
}
Expand Down Expand Up @@ -250,7 +241,7 @@ public void InitSWCms()
};

isSucceed = isSucceed && theme.SaveModel(true, context, transaction).IsSucceed;

if (isSucceed)
{
ConfigurationViewModel config = (ConfigurationViewModel.Repository.GetSingleModel(
Expand Down Expand Up @@ -377,19 +368,17 @@ public void InitSWCms()

if (isSucceed)
{

BECategoryViewModel cate = new BECategoryViewModel( new SiocCategory()
BECategoryViewModel cate = new BECategoryViewModel(new SiocCategory()
{
Title = "Home",
Specificulture = "vi-vn",
Template = "_Home",
Type = (int)SWCmsConstants.CateType.Home,
CreatedBy = "Admin"

});

isSucceed = isSucceed && cate.SaveModel(false, context, transaction).IsSucceed;
BECategoryViewModel uscate = new BECategoryViewModel( new SiocCategory()
BECategoryViewModel uscate = new BECategoryViewModel(new SiocCategory()
{
Title = "Home",
Specificulture = "en-us",
Expand All @@ -400,15 +389,17 @@ public void InitSWCms()
isSucceed = isSucceed && uscate.SaveModel(false, context, transaction).IsSucceed;
}


if (isSucceed)
{

GlobalLanguageService.Instance.RefreshCultures(context, transaction);

transaction.Commit();
IsInit = true;
}
else
{
transaction.Rollback();
IsInit = false;
}
}
}
catch (Exception ex) // TODO: Add more specific exeption types instead of Exception only
Expand Down Expand Up @@ -524,4 +515,4 @@ public int GetLocalInt(string key, string culture, int defaultValue)
return result;
}
}
}
}

0 comments on commit d281fb6

Please sign in to comment.