Esempio n. 1
0
        public static string DisplayValue(SiteSettings ss, DataRow dataRow)
        {
            switch (ss.ReferenceType)
            {
            case "Issues": return(IssueUtilities.TitleDisplayValue(ss, dataRow));

            case "Results": return(ResultUtilities.TitleDisplayValue(ss, dataRow));

            case "Wikis": return(WikiUtilities.TitleDisplayValue(ss, dataRow));

            default: return(string.Empty);
            }
        }
Esempio n. 2
0
 public static void Initialize()
 {
     if (ItemsIsEmpty())
     {
         new SiteCollection().ForEach(siteModel =>
         {
             if (siteModel.SiteSettings != null)
             {
                 Rds.ExecuteNonQuery(
                     connectionString: Parameters.Rds.OwnerConnectionString,
                     statements: new SqlStatement[]
                 {
                     Rds.IdentityInsertItems(on: true),
                     Rds.InsertItems(
                         param: Rds.ItemsParam()
                         .ReferenceId(siteModel.SiteId)
                         .ReferenceType("Sites")
                         .SiteId(siteModel.SiteId)
                         .Title(siteModel.Title.Value)),
                     Rds.IdentityInsertItems(on: false)
                 });
             }
         });
         new SiteCollection(tableType: Sqls.TableTypes.Deleted).ForEach(siteModel =>
         {
             if (siteModel.SiteSettings != null)
             {
                 Rds.ExecuteNonQuery(
                     statements: new SqlStatement[]
                 {
                     Rds.InsertItems(
                         tableType: Sqls.TableTypes.Deleted,
                         param: Rds.ItemsParam()
                         .ReferenceId(siteModel.SiteId)
                         .Ver(siteModel.Ver)
                         .ReferenceType("Sites")
                         .SiteId(siteModel.SiteId)
                         .Title(siteModel.Title.Value))
                 });
             }
         });
         new SiteCollection(tableType: Sqls.TableTypes.History).ForEach(siteModel =>
         {
             if (siteModel.SiteSettings != null)
             {
                 Rds.ExecuteNonQuery(
                     statements: new SqlStatement[]
                 {
                     Rds.InsertItems(
                         tableType: Sqls.TableTypes.History,
                         param: Rds.ItemsParam()
                         .ReferenceId(siteModel.SiteId)
                         .Ver(siteModel.Ver)
                         .ReferenceType("Sites")
                         .SiteId(siteModel.SiteId)
                         .Title(siteModel.Title.Value))
                 });
             }
         });
         Rds.ExecuteTable(statements: Rds.SelectIssues(
                              tableType: Sqls.TableTypes.Normal,
                              column: Rds.IssuesColumn()
                              .SiteId()
                              .IssueId()
                              .Ver())).AsEnumerable().ForEach(dataRow =>
         {
             var siteId = dataRow["SiteId"].ToLong();
             var ss     = new SiteModel().Get(where :
                                              Rds.SitesWhere().SiteId(siteId))?
                          .IssuesSiteSettings(dataRow["IssueId"].ToLong());
             var issueModel = new IssueModel(ss).Get(
                 ss: ss,
                 tableType: Sqls.TableTypes.Normal,
                 where : Rds.IssuesWhere()
                 .SiteId(dataRow["SiteId"].ToLong())
                 .IssueId(dataRow["IssueId"].ToLong())
                 .Ver(dataRow["Ver"].ToInt()));
             if (ss != null &&
                 issueModel.AccessStatus == Databases.AccessStatuses.Selected)
             {
                 Rds.ExecuteNonQuery(
                     connectionString: Parameters.Rds.OwnerConnectionString,
                     statements: new SqlStatement[]
                 {
                     Rds.IdentityInsertItems(on: true),
                     Rds.InsertItems(
                         param: Rds.ItemsParam()
                         .ReferenceId(issueModel.IssueId)
                         .ReferenceType("Issues")
                         .SiteId(issueModel.SiteId)
                         .Title(IssueUtilities.TitleDisplayValue(
                                    ss, issueModel))),
                     Rds.IdentityInsertItems(on: false)
                 });
             }
         });
         Rds.ExecuteTable(statements: Rds.SelectIssues(
                              tableType: Sqls.TableTypes.Deleted,
                              column: Rds.IssuesColumn()
                              .SiteId()
                              .IssueId()
                              .Ver())).AsEnumerable().ForEach(dataRow =>
         {
             var siteId = dataRow["SiteId"].ToLong();
             var ss     = new SiteModel().Get(where :
                                              Rds.SitesWhere().SiteId(siteId))?
                          .IssuesSiteSettings(dataRow["IssueId"].ToLong());
             var issueModel = new IssueModel(ss).Get(
                 ss: ss,
                 tableType: Sqls.TableTypes.Deleted,
                 where : Rds.IssuesWhere()
                 .SiteId(dataRow["SiteId"].ToLong())
                 .IssueId(dataRow["IssueId"].ToLong())
                 .Ver(dataRow["Ver"].ToInt()));
             if (ss != null &&
                 issueModel.AccessStatus == Databases.AccessStatuses.Selected)
             {
                 Rds.ExecuteNonQuery(
                     statements: new SqlStatement[]
                 {
                     Rds.InsertItems(
                         tableType: Sqls.TableTypes.Deleted,
                         param: Rds.ItemsParam()
                         .ReferenceId(issueModel.IssueId)
                         .Ver(issueModel.Ver)
                         .ReferenceType("Issues")
                         .SiteId(issueModel.SiteId)
                         .Title(IssueUtilities.TitleDisplayValue(
                                    ss, issueModel)))
                 });
             }
         });
         Rds.ExecuteTable(statements: Rds.SelectResults(
                              tableType: Sqls.TableTypes.Normal,
                              column: Rds.ResultsColumn()
                              .SiteId()
                              .ResultId()
                              .Ver())).AsEnumerable().ForEach(dataRow =>
         {
             var siteId = dataRow["SiteId"].ToLong();
             var ss     = new SiteModel().Get(where :
                                              Rds.SitesWhere().SiteId(siteId))?
                          .ResultsSiteSettings(dataRow["ResultId"].ToLong());
             var resultModel = new ResultModel(ss).Get(
                 ss: ss,
                 tableType: Sqls.TableTypes.Normal,
                 where : Rds.ResultsWhere()
                 .SiteId(dataRow["SiteId"].ToLong())
                 .ResultId(dataRow["ResultId"].ToLong())
                 .Ver(dataRow["Ver"].ToInt()));
             if (ss != null &&
                 resultModel.AccessStatus == Databases.AccessStatuses.Selected)
             {
                 Rds.ExecuteNonQuery(
                     connectionString: Parameters.Rds.OwnerConnectionString,
                     statements: new SqlStatement[]
                 {
                     Rds.IdentityInsertItems(on: true),
                     Rds.InsertItems(
                         param: Rds.ItemsParam()
                         .ReferenceId(resultModel.ResultId)
                         .ReferenceType("Results")
                         .SiteId(resultModel.SiteId)
                         .Title(ResultUtilities.TitleDisplayValue(
                                    ss, resultModel))),
                     Rds.IdentityInsertItems(on: false)
                 });
             }
         });
         Rds.ExecuteTable(statements: Rds.SelectResults(
                              tableType: Sqls.TableTypes.Deleted,
                              column: Rds.ResultsColumn()
                              .SiteId()
                              .ResultId()
                              .Ver())).AsEnumerable().ForEach(dataRow =>
         {
             var siteId = dataRow["SiteId"].ToLong();
             var ss     = new SiteModel().Get(where :
                                              Rds.SitesWhere().SiteId(siteId))?
                          .ResultsSiteSettings(dataRow["ResultId"].ToLong());
             var resultModel = new ResultModel(ss).Get(
                 ss: ss,
                 tableType: Sqls.TableTypes.Deleted,
                 where : Rds.ResultsWhere()
                 .SiteId(dataRow["SiteId"].ToLong())
                 .ResultId(dataRow["ResultId"].ToLong())
                 .Ver(dataRow["Ver"].ToInt()));
             if (ss != null &&
                 resultModel.AccessStatus == Databases.AccessStatuses.Selected)
             {
                 Rds.ExecuteNonQuery(
                     statements: new SqlStatement[]
                 {
                     Rds.InsertItems(
                         tableType: Sqls.TableTypes.Deleted,
                         param: Rds.ItemsParam()
                         .ReferenceId(resultModel.ResultId)
                         .Ver(resultModel.Ver)
                         .ReferenceType("Results")
                         .SiteId(resultModel.SiteId)
                         .Title(ResultUtilities.TitleDisplayValue(
                                    ss, resultModel)))
                 });
             }
         });
         Rds.ExecuteTable(statements: Rds.SelectWikis(
                              tableType: Sqls.TableTypes.Normal,
                              column: Rds.WikisColumn()
                              .SiteId()
                              .WikiId()
                              .Ver())).AsEnumerable().ForEach(dataRow =>
         {
             var siteId = dataRow["SiteId"].ToLong();
             var ss     = new SiteModel().Get(where :
                                              Rds.SitesWhere().SiteId(siteId))?
                          .WikisSiteSettings(dataRow["WikiId"].ToLong());
             var wikiModel = new WikiModel(ss).Get(
                 ss: ss,
                 tableType: Sqls.TableTypes.Normal,
                 where : Rds.WikisWhere()
                 .SiteId(dataRow["SiteId"].ToLong())
                 .WikiId(dataRow["WikiId"].ToLong())
                 .Ver(dataRow["Ver"].ToInt()));
             if (ss != null &&
                 wikiModel.AccessStatus == Databases.AccessStatuses.Selected)
             {
                 Rds.ExecuteNonQuery(
                     connectionString: Parameters.Rds.OwnerConnectionString,
                     statements: new SqlStatement[]
                 {
                     Rds.IdentityInsertItems(on: true),
                     Rds.InsertItems(
                         param: Rds.ItemsParam()
                         .ReferenceId(wikiModel.WikiId)
                         .ReferenceType("Wikis")
                         .SiteId(wikiModel.SiteId)
                         .Title(WikiUtilities.TitleDisplayValue(
                                    ss, wikiModel))),
                     Rds.IdentityInsertItems(on: false)
                 });
             }
         });
         Rds.ExecuteTable(statements: Rds.SelectWikis(
                              tableType: Sqls.TableTypes.Deleted,
                              column: Rds.WikisColumn()
                              .SiteId()
                              .WikiId()
                              .Ver())).AsEnumerable().ForEach(dataRow =>
         {
             var siteId = dataRow["SiteId"].ToLong();
             var ss     = new SiteModel().Get(where :
                                              Rds.SitesWhere().SiteId(siteId))?
                          .WikisSiteSettings(dataRow["WikiId"].ToLong());
             var wikiModel = new WikiModel(ss).Get(
                 ss: ss,
                 tableType: Sqls.TableTypes.Deleted,
                 where : Rds.WikisWhere()
                 .SiteId(dataRow["SiteId"].ToLong())
                 .WikiId(dataRow["WikiId"].ToLong())
                 .Ver(dataRow["Ver"].ToInt()));
             if (ss != null &&
                 wikiModel.AccessStatus == Databases.AccessStatuses.Selected)
             {
                 Rds.ExecuteNonQuery(
                     statements: new SqlStatement[]
                 {
                     Rds.InsertItems(
                         tableType: Sqls.TableTypes.Deleted,
                         param: Rds.ItemsParam()
                         .ReferenceId(wikiModel.WikiId)
                         .Ver(wikiModel.Ver)
                         .ReferenceType("Wikis")
                         .SiteId(wikiModel.SiteId)
                         .Title(WikiUtilities.TitleDisplayValue(
                                    ss, wikiModel)))
                 });
             }
         });
     }
 }