コード例 #1
0
ファイル: ModuleRepository.cs プロジェクト: eternalwt/CMS
 public List<ModulesInMenus> GetModuleMenus(int moduleID)
 {
     using (CMSContext context = new CMSContext())
     {
         return context.ModulesInMenus.Where(moduleMenu => moduleMenu.ModuleID == moduleID).ToList();
     }
 }
コード例 #2
0
ファイル: ModuleRepository.cs プロジェクト: eternalwt/CMS
 public List<ModulesInRoles> GetModuleRoles(int moduleID)
 {
     using (CMSContext context = new CMSContext())
     {
         return context.ModulesInRoles.Where(moduleRole => moduleRole.ModuleID == moduleID).ToList();
     }
 }
コード例 #3
0
ファイル: PositionRepository.cs プロジェクト: eternalwt/CMS
 public Position FindPosition(int positionID)
 {
     using(CMSContext context=new CMSContext()) {
         return context
             .Positions
             .Where(m => m.PositionID==positionID).FirstOrDefault();
     }
 }
コード例 #4
0
ファイル: ModuleTypeRepository.cs プロジェクト: eternalwt/CMS
 public ModuleType FindModuleType(int moduleTypeID)
 {
     using(CMSContext context=new CMSContext()) {
         return context
             .ModuleTypes
             .Where(m => m.ModuleTypeID==moduleTypeID).FirstOrDefault();
     }
 }
コード例 #5
0
ファイル: ModuleRepository.cs プロジェクト: eternalwt/CMS
 public bool DeleteModuleRoles(int moduleID)
 {
     using (CMSContext context = new CMSContext())
     {
         List<ModulesInRoles> ModuleRoles = context.ModulesInRoles.Where(moduleposition => moduleposition.ModuleID == moduleID).ToList();
         foreach (var moduleposition in ModuleRoles)
         {
             context.ModulesInRoles.Remove(moduleposition);
         }
         return context.SaveChanges() > 0;
     }
 }
コード例 #6
0
ファイル: ModuleTypeRepository.cs プロジェクト: eternalwt/CMS
 public List<ModuleTypeDetail> GetModuleTypes()
 {
     using (CMSContext context = new CMSContext())
     {
         return (from moduleType in context.ModuleTypes
                 select new ModuleTypeDetail
                 {
                     ModuleTypeID = moduleType.ModuleTypeID,
                     ModuleTypeName = moduleType.ModuleTypeName,
                 }).ToList();
     }
 }
コード例 #7
0
ファイル: ModuleRepository.cs プロジェクト: eternalwt/CMS
 public bool DeleteModuleMenus(int moduleID)
 {
     using (CMSContext context = new CMSContext())
     {
         List<ModulesInMenus> moduleMenus = context.ModulesInMenus.Where(moduleMenu => moduleMenu.ModuleID == moduleID).ToList();
         foreach (var moduleMenu in moduleMenus)
         {
             context.ModulesInMenus.Remove(moduleMenu);
         }
         return context.SaveChanges() > 0;
     }
 }
コード例 #8
0
ファイル: ModuleRepository.cs プロジェクト: eternalwt/CMS
 public Module FindModule(int moduleID)
 {
     using (CMSContext context = new CMSContext())
     {
         return context
             .Modules
             .Include("Position")
             .Include("AccessLevel")
             .Include("ModuleType")
             .Include("ModulesInRoles")
             .Where(m => m.ModuleID == moduleID).FirstOrDefault();
     }
 }
コード例 #9
0
ファイル: ModuleRepository.cs プロジェクト: eternalwt/CMS
 public List<AccessLevelDetail> GetAccessLevels()
 {
     using (CMSContext context = new CMSContext())
     {
         return (from accessLevel in context.AccessLevels
                 orderby accessLevel.AccessLevelName
                 select new AccessLevelDetail
                 {
                     AccessLevelID = accessLevel.AccessLevelID,
                     AccessLevelName = accessLevel.AccessLevelName
                 }).ToList();
     }
 }
コード例 #10
0
ファイル: RoleRepository.cs プロジェクト: eternalwt/CMS
 public List<RoleDetail> GetRoles()
 {
     using (CMSContext context = new CMSContext())
     {
         return (from role in context.Roles
                 orderby role.RoleName
                 select new RoleDetail
                 {
                    RoleID = role.RoleID,
                      RoleName = role.RoleName
                 }).ToList();
     }
 }
コード例 #11
0
ファイル: PositionRepository.cs プロジェクト: eternalwt/CMS
 public IEnumerable<ErrorInfo> SavePosition(Position position)
 {
     using(CMSContext context=new CMSContext()) {
         IEnumerable<ErrorInfo> errors=ValidationHelper.Validate(position);
         if(errors.Any()==false) {
             if(position.PositionID<=0) {
                 context.Positions.Add(position);
             } else {
                 context.Entry(position).State=EntityState.Modified;
             }
             context.SaveChanges();
         }
         return errors;
     }
 }
コード例 #12
0
ファイル: ModuleTypeRepository.cs プロジェクト: eternalwt/CMS
 public IEnumerable<ErrorInfo> SaveModuleType(ModuleType moduleType)
 {
     using(CMSContext context=new CMSContext()) {
         IEnumerable<ErrorInfo> errors=ValidationHelper.Validate(moduleType);
         if(errors.Any()==false) {
             if(moduleType.ModuleTypeID<=0) {
                 context.ModuleTypes.Add(moduleType);
             } else {
                 context.Entry(moduleType).State=EntityState.Modified;
             }
             context.SaveChanges();
         }
         return errors;
     }
 }
コード例 #13
0
ファイル: PositionRepository.cs プロジェクト: eternalwt/CMS
        public PagedList<PositionDetail> GetPositions(string positionName,
											int pageIndex,
											int pageSize,
											string sortName,
											string sortOrder)
        {
            using(CMSContext context=new CMSContext()) {
                IQueryable<Position> query=context.Positions;
                if(string.IsNullOrEmpty(positionName)==false) {
                    query=query.Where(position => position.PositionName.StartsWith(positionName));
                }
                query=query.OrderBy(sortName,(sortOrder=="asc"));
                IQueryable<PositionDetail> positions=(from position in query
                                                    select new PositionDetail {
                                                        PositionID=position.PositionID,
                                                        PositionName=position.PositionName,
                                                    });
                return new PagedList<PositionDetail>(positions,pageIndex,pageSize);
            }
        }
コード例 #14
0
ファイル: ModuleTypeRepository.cs プロジェクト: eternalwt/CMS
        public PagedList<ModuleTypeDetail> GetModuleTypes(string moduleTypeName,
											int pageIndex,
											int pageSize,
											string sortName,
											string sortOrder)
        {
            using(CMSContext context=new CMSContext()) {
                IQueryable<ModuleType> query=context.ModuleTypes;
                if(string.IsNullOrEmpty(moduleTypeName)==false) {
                    query=query.Where(moduleType => moduleType.ModuleTypeName.StartsWith(moduleTypeName));
                }
                query=query.OrderBy(sortName,(sortOrder=="asc"));
                IQueryable<ModuleTypeDetail> moduleTypes=(from moduleType in query
                                                    select new ModuleTypeDetail {
                                                        ModuleTypeID=moduleType.ModuleTypeID,
                                                        ModuleTypeName=moduleType.ModuleTypeName,
                                                    });
                return new PagedList<ModuleTypeDetail>(moduleTypes,pageIndex,pageSize);
            }
        }
コード例 #15
0
 public SeoService(CMSContext context)
 {
     _context = context;
 }
コード例 #16
0
 public AnalyticsService(CMSContext context)
 {
     _context = context;
 }
コード例 #17
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            rssFeed.StopProcessing     = true;
            srcMessages.StopProcessing = true;
        }
        else
        {
            string feedCodeName = URLHelper.GetSafeUrlPart(FeedName, SiteName);
            // RSS feed properties
            rssFeed.FeedName            = feedCodeName;
            rssFeed.FeedLink            = URLHelper.GetAbsoluteUrl(URLHelper.AddParameterToUrl(URLHelper.CurrentURL, QueryStringKey, feedCodeName));
            rssFeed.LinkText            = LinkText;
            rssFeed.LinkIcon            = LinkIcon;
            rssFeed.FeedTitle           = FeedTitle;
            rssFeed.FeedDescription     = FeedDescription;
            rssFeed.FeedLanguage        = FeedLanguage;
            rssFeed.EnableAutodiscovery = EnableRSSAutodiscovery;
            rssFeed.QueryStringKey      = QueryStringKey;
            rssFeed.HeaderXML           = HeaderXML;
            rssFeed.FooterXML           = FooterXML;


            // Prepare alias path
            string aliasPath = Path;
            if (String.IsNullOrEmpty(aliasPath))
            {
                aliasPath = "/%";
            }
            aliasPath = CMSContext.ResolveCurrentPath(aliasPath);

            // Prepare site name
            string siteName = SiteName;
            if (String.IsNullOrEmpty(siteName))
            {
                siteName = CMSContext.CurrentSiteName;
            }

            // Prepare culture code
            string cultureCode = CultureCode;
            if (String.IsNullOrEmpty(cultureCode))
            {
                cultureCode = CMSContext.PreferredCultureCode;
            }

            // Messages datasource properties
            this.srcMessages.BoardName          = BoardName;
            this.srcMessages.SiteName           = siteName;
            this.srcMessages.WhereCondition     = WhereCondition;
            this.srcMessages.OrderBy            = OrderBy;
            this.srcMessages.TopN               = SelectTopN;
            this.srcMessages.FilterName         = ValidationHelper.GetString(this.GetValue("WebPartControlID"), this.ClientID);
            this.srcMessages.SourceFilterName   = FilterName;
            this.srcMessages.SelectOnlyApproved = SelectOnlyApproved;
            this.srcMessages.SelectedColumns    = Columns;
            this.srcMessages.ShowGroupMessages  = ShowGroupMessages;

            // Documents properties
            this.srcMessages.Path = aliasPath;
            this.srcMessages.UseDocumentFilter         = UseDocumentFilter;
            this.srcMessages.CultureCode               = cultureCode;
            this.srcMessages.DocumentsWhereCondition   = DocumentsWhereCondition;
            this.srcMessages.CombineWithDefaultCulture = CombineWithDefaultCulture;
            this.srcMessages.SelectOnlyPublished       = SelectOnlyPublished;
            this.srcMessages.MaxRelativeLevel          = MaxRelativeLevel;

            // Cache properties
            rssFeed.CacheItemName         = CacheItemName;
            rssFeed.CacheDependencies     = CacheDependencies;
            rssFeed.CacheMinutes          = CacheMinutes;
            srcMessages.CacheItemName     = CacheItemName;
            srcMessages.CacheDependencies = CacheDependencies;
            srcMessages.CacheMinutes      = CacheMinutes;

            // Transformation properties
            rssFeed.TransformationName = TransformationName;

            // Set datasource
            rssFeed.DataSourceControl = srcMessages;
        }
    }
コード例 #18
0
ファイル: CMSAdminDao.cs プロジェクト: xiaopohou/Snai.CMS
 public CMSAdminDao(CMSContext context)
 {
     Context = context;
 }
コード例 #19
0
        #pragma warning disable 1998
        public async override global::System.Threading.Tasks.Task ExecuteAsync()
        {
#line 4 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Visits\Details.cshtml"

            // Layout = null;

#line default
#line hidden
            BeginContext(136, 29, true);
            WriteLiteral("\r\n<!DOCTYPE html>\r\n\r\n<html>\r\n");
            EndContext();
            BeginContext(165, 102, false);
            __tagHelperExecutionContext = __tagHelperScopeManager.Begin("head", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "bc1c417cfea645439ac2c5c4e9987a8f", async() => {
                BeginContext(171, 89, true);
                WriteLiteral("\r\n    <meta name=\"viewport\" content=\"width=device-width\" />\r\n    <title>Details</title>\r\n");
                EndContext();
            }
                                                                        );
            __Microsoft_AspNetCore_Mvc_Razor_TagHelpers_HeadTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper>();
            __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_Razor_TagHelpers_HeadTagHelper);
            await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);

            if (!__tagHelperExecutionContext.Output.IsContentModified)
            {
                await __tagHelperExecutionContext.SetOutputContentAsync();
            }
            Write(__tagHelperExecutionContext.Output);
            __tagHelperExecutionContext = __tagHelperScopeManager.End();
            EndContext();
            BeginContext(267, 2, true);
            WriteLiteral("\r\n");
            EndContext();
            BeginContext(269, 3027, false);
            __tagHelperExecutionContext = __tagHelperScopeManager.Begin("body", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "2ed53ce7255a48fa882afdbddc56b1aa", async() => {
                BeginContext(275, 126, true);
                WriteLiteral("\r\n\r\n    <div>\r\n        <h4>Visits</h4>\r\n        <hr />\r\n        <dl class=\"dl-horizontal\">\r\n            <dt>\r\n                ");
                EndContext();
                BeginContext(402, 47, false);
#line 22 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Visits\Details.cshtml"
                Write(Html.DisplayNameFor(model => model.companyName));

#line default
#line hidden
                EndContext();
                BeginContext(449, 55, true);
                WriteLiteral("\r\n            </dt>\r\n            <dd>\r\n                ");
                EndContext();
                BeginContext(505, 43, false);
#line 25 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Visits\Details.cshtml"
                Write(Html.DisplayFor(model => model.companyName));

#line default
#line hidden
                EndContext();
                BeginContext(548, 55, true);
                WriteLiteral("\r\n            </dd>\r\n            <dt>\r\n                ");
                EndContext();
                BeginContext(604, 49, false);
#line 28 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Visits\Details.cshtml"
                Write(Html.DisplayNameFor(model => model.companyTypeId));

#line default
#line hidden
                EndContext();
                BeginContext(653, 39, true);
                WriteLiteral("\r\n            </dt>\r\n            <dd>\r\n");
                EndContext();
#line 31 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Visits\Details.cshtml"

                var _context        = new CMSContext();
                string companytype  = null;
                var CompanyTypelist = _context.CompanyType.FromSql("SELECT companyTypeId, companyType FROM CompanyType").ToList();

                foreach (CompanyType companyType in CompanyTypelist)
                {
                    if (companyType.companyTypeId == Model.companyTypeId)
                    {
                        companytype = companyType.companyType;
                        break;
                    }
                }


#line default
#line hidden
                BeginContext(1328, 16, true);
                WriteLiteral("                ");
                EndContext();
                BeginContext(1345, 41, false);
#line 45 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Visits\Details.cshtml"
                Write(Html.DisplayFor(modelItem => companytype));

#line default
#line hidden
                EndContext();
                BeginContext(1386, 55, true);
                WriteLiteral("\r\n            </dd>\r\n            <dt>\r\n                ");
                EndContext();
                BeginContext(1442, 43, false);
#line 48 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Visits\Details.cshtml"
                Write(Html.DisplayNameFor(model => model.noOfPax));

#line default
#line hidden
                EndContext();
                BeginContext(1485, 55, true);
                WriteLiteral("\r\n            </dt>\r\n            <dd>\r\n                ");
                EndContext();
                BeginContext(1541, 39, false);
#line 51 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Visits\Details.cshtml"
                Write(Html.DisplayFor(model => model.noOfPax));

#line default
#line hidden
                EndContext();
                BeginContext(1580, 55, true);
                WriteLiteral("\r\n            </dd>\r\n            <dt>\r\n                ");
                EndContext();
                BeginContext(1636, 45, false);
#line 54 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Visits\Details.cshtml"
                Write(Html.DisplayNameFor(model => model.visitDate));

#line default
#line hidden
                EndContext();
                BeginContext(1681, 39, true);
                WriteLiteral("\r\n            </dt>\r\n            <dd>\r\n");
                EndContext();
#line 57 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Visits\Details.cshtml"

                string date = Model.visitDate.ToString("dd MMM yyyy,hh:mm", DateTimeFormatInfo.InvariantInfo);


#line default
#line hidden
                BeginContext(1875, 16, true);
                WriteLiteral("                ");
                EndContext();
                BeginContext(1892, 34, false);
#line 60 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Visits\Details.cshtml"
                Write(Html.DisplayFor(modelItem => date));

#line default
#line hidden
                EndContext();
                BeginContext(1926, 55, true);
                WriteLiteral("\r\n            </dd>\r\n            <dt>\r\n                ");
                EndContext();
                BeginContext(1982, 47, false);
#line 63 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Visits\Details.cshtml"
                Write(Html.DisplayNameFor(model => model.visitTypeId));

#line default
#line hidden
                EndContext();
                BeginContext(2029, 39, true);
                WriteLiteral("\r\n            </dt>\r\n            <dd>\r\n");
                EndContext();
#line 66 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Visits\Details.cshtml"

                //var _context = new CMSContext();
                string visitType  = null;
                var visitTypelist = _context.VisitType.FromSql("SELECT visitTypeId, visitType FROM VisitType").ToList();

                foreach (VisitType visitTypes in visitTypelist)
                {
                    if (visitTypes.visitTypeId == Model.visitTypeId)
                    {
                        visitType = visitTypes.visitType;
                        break;
                    }
                }


#line default
#line hidden
                BeginContext(2679, 16, true);
                WriteLiteral("                ");
                EndContext();
                BeginContext(2696, 39, false);
#line 80 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Visits\Details.cshtml"
                Write(Html.DisplayFor(modelItem => visitType));

#line default
#line hidden
                EndContext();
                BeginContext(2735, 55, true);
                WriteLiteral("\r\n            </dd>\r\n            <dt>\r\n                ");
                EndContext();
                BeginContext(2791, 47, false);
#line 83 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Visits\Details.cshtml"
                Write(Html.DisplayNameFor(model => model.dateCreated));

#line default
#line hidden
                EndContext();
                BeginContext(2838, 39, true);
                WriteLiteral("\r\n            </dt>\r\n            <dd>\r\n");
                EndContext();
#line 86 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Visits\Details.cshtml"

                string datecreated = Model.dateCreated.ToString("dd MMM yyyy,hh:mm", DateTimeFormatInfo.InvariantInfo);


#line default
#line hidden
                BeginContext(3041, 16, true);
                WriteLiteral("                ");
                EndContext();
                BeginContext(3058, 41, false);
#line 89 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Visits\Details.cshtml"
                Write(Html.DisplayFor(modelItem => datecreated));

#line default
#line hidden
                EndContext();
                BeginContext(3099, 67, true);
                WriteLiteral("\r\n            </dd>\r\n        </dl>\r\n    </div>\r\n    <div>\r\n        ");
                EndContext();
                BeginContext(3166, 59, false);
                __tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "609207b2fdce49c380912de6c74f20d8", async() => {
                    BeginContext(3217, 4, true);
                    WriteLiteral("Edit");
                    EndContext();
                }
                                                                            );
                __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper>();
                __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper);
                __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Action = (string)__tagHelperAttribute_0.Value;
                __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0);
                if (__Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.RouteValues == null)
                {
                    throw new InvalidOperationException(InvalidTagHelperIndexerAssignment("asp-route-id", "Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper", "RouteValues"));
                }
                BeginWriteTagHelperAttribute();
#line 94 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Visits\Details.cshtml"
                WriteLiteral(Model.visitId);

#line default
#line hidden
                __tagHelperStringValueBuffer = EndWriteTagHelperAttribute();
                __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.RouteValues["id"] = __tagHelperStringValueBuffer;
                __tagHelperExecutionContext.AddTagHelperAttribute("asp-route-id", __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.RouteValues["id"], global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes);
                await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
                if (!__tagHelperExecutionContext.Output.IsContentModified)
                {
                    await __tagHelperExecutionContext.SetOutputContentAsync();
                }
                Write(__tagHelperExecutionContext.Output);
                __tagHelperExecutionContext = __tagHelperScopeManager.End();
                EndContext();
                BeginContext(3225, 12, true);
                WriteLiteral(" |\r\n        ");
                EndContext();
                BeginContext(3237, 38, false);
                __tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "1742e69d3d42490ba6e8598d33648312", async() => {
                    BeginContext(3259, 12, true);
                    WriteLiteral("Back to List");
                    EndContext();
                }
                                                                            );
                __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper>();
                __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper);
                __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Action = (string)__tagHelperAttribute_1.Value;
                __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_1);
                await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
                if (!__tagHelperExecutionContext.Output.IsContentModified)
                {
                    await __tagHelperExecutionContext.SetOutputContentAsync();
                }
                Write(__tagHelperExecutionContext.Output);
                __tagHelperExecutionContext = __tagHelperScopeManager.End();
                EndContext();
                BeginContext(3275, 14, true);
                WriteLiteral("\r\n    </div>\r\n");
                EndContext();
            }
                                                                        );
            __Microsoft_AspNetCore_Mvc_Razor_TagHelpers_BodyTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper>();
            __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_Razor_TagHelpers_BodyTagHelper);
            await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);

            if (!__tagHelperExecutionContext.Output.IsContentModified)
            {
                await __tagHelperExecutionContext.SetOutputContentAsync();
            }
            Write(__tagHelperExecutionContext.Output);
            __tagHelperExecutionContext = __tagHelperScopeManager.End();
            EndContext();
            BeginContext(3296, 11, true);
            WriteLiteral("\r\n</html>\r\n");
            EndContext();
        }
コード例 #20
0
        public PageList GetPage(int?page, string searchText, int?status)
        {
            int pageSize = 3;
            int pageNo   = page == null ? 1 : Convert.ToInt32(page);

            List <Page>   list          = new List <Page>();
            PageExtraData pageExtraData = new PageExtraData();
            PageList      pageList      = new PageList();

            using (var context = new CMSContext())
            {
                var param = new SqlParameter[] {
                    new SqlParameter()
                    {
                        ParameterName = "@PageNo",
                        SqlDbType     = System.Data.SqlDbType.Int,
                        Direction     = System.Data.ParameterDirection.Input,
                        Value         = page
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@Name",
                        SqlDbType     = System.Data.SqlDbType.VarChar,
                        Direction     = System.Data.ParameterDirection.Input,
                        Size          = 100,
                        Value         = searchText ?? (object)DBNull.Value
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@PageSize",
                        SqlDbType     = System.Data.SqlDbType.Int,
                        Direction     = System.Data.ParameterDirection.Input,
                        Value         = pageSize
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@Status",
                        SqlDbType     = System.Data.SqlDbType.Int,
                        Direction     = System.Data.ParameterDirection.Input,
                        Value         = status ?? (object)DBNull.Value
                    }
                };
                using (var cnn = context.Database.GetDbConnection())
                {
                    var cmm = cnn.CreateCommand();
                    cmm.CommandType = System.Data.CommandType.StoredProcedure;
                    cmm.CommandText = "[dbo].[sp_GetPageWithPaging]";
                    cmm.Parameters.AddRange(param);
                    cmm.Connection = cnn;
                    cnn.Open();
                    var reader = cmm.ExecuteReader();

                    while (reader.Read())
                    {
                        Page pages = new Page();
                        pages.Id              = Convert.ToInt32(reader["Id"]);
                        pages.Name            = Convert.ToString(reader["Name"]);
                        pages.Url             = Convert.ToString(reader["Url"]);
                        pages.MetaTitle       = Convert.ToString(reader["MetaTitle"]);
                        pages.MetaKeyword     = Convert.ToString(reader["MetaKeyword"]);
                        pages.MetaDescription = Convert.ToString(reader["MetaDescription"]);
                        pages.Description     = Convert.ToString(reader["Description"]);
                        pages.AddedOn         = Convert.ToDateTime(reader["AddedOn"]);
                        pages.Status          = Convert.ToBoolean(reader["Status"]);
                        list.Add(pages);
                    }
                    reader.NextResult();
                    while (reader.Read())
                    {
                        PagingInfo pagingInfo = new PagingInfo();
                        pagingInfo.CurrentPage  = pageNo;
                        pagingInfo.TotalItems   = Convert.ToInt32(reader["Total"]);
                        pagingInfo.ItemsPerPage = pageSize;

                        pageList.page              = list;
                        pageList.allTotalPage      = Convert.ToInt32(reader["AllTotalPage"]);
                        pageList.activeTotalPage   = Convert.ToInt32(reader["ActiveTotalPage"]);
                        pageList.inactiveTotalPage = Convert.ToInt32(reader["InActiveTotalPage"]);
                        pageList.searchText        = searchText;
                        pageList.status            = status;
                        pageList.pagingInfo        = pagingInfo;
                    }
                }
                //var result = context.sp_GetPageWithPaging(pageNo, searchText, pageSize, status);
                //list = result.Select(x => new Models.Page() { id = x.Id, name = x.Name, url = x.Url, metaTitle = x.MetaTitle, metaKeyword = x.MetaKeyword, metaDescription = x.MetaDescription, description = x.Description, addedOn = x.AddedOn, status = Convert.ToInt32(x.Status) }).ToList();

                //var pageExtraDataResult = result.GetNextResult<sp_PageExtraData>();
                //pageExtraData = pageExtraDataResult.ToList().FirstOrDefault();
            }
            return(pageList);
        }
コード例 #21
0
    protected void Page_Load(object sender, EventArgs e)
    {
        this.gridElem.WhereCondition       = "SubmissionItemSubmissionID = " + SubmissionID;
        this.gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound);

        this.btnImportFromZip.OnClientClick = "ShowUploadDialog(" + SubmissionID + ", 0);";
        this.btnExportToZip.OnClientClick   = "window.open('" + URLHelper.ResolveUrl("~/CMSModules/Translations/CMSPages/DownloadTranslation.aspx?submissionid=" + SubmissionID) + "'); return false;";


        string script = "function ShowUploadDialog(submissionId, submissionItemTd) { modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/Translations/Pages/UploadTranslation.aspx") + "?itemid=' + submissionItemTd + '&submissionid=' + submissionId, 'Upload translation', 500, 180); }";

        ScriptHelper.RegisterClientScriptBlock(this.Page, typeof(string), "ShowUploadDialog", script, true);
    }
コード例 #22
0
        #pragma warning disable 1998
        public async override global::System.Threading.Tasks.Task ExecuteAsync()
        {
            BeginContext(37, 29, true);
            WriteLiteral("\r\n<!DOCTYPE html>\r\n\r\n<html>\r\n");
            EndContext();
            BeginContext(66, 102, false);
            __tagHelperExecutionContext = __tagHelperScopeManager.Begin("head", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "d2d568310bf142ff908bb756db2156d6", async() => {
                BeginContext(72, 89, true);
                WriteLiteral("\r\n    <meta name=\"viewport\" content=\"width=device-width\" />\r\n    <title>Details</title>\r\n");
                EndContext();
            }
                                                                        );
            __Microsoft_AspNetCore_Mvc_Razor_TagHelpers_HeadTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper>();
            __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_Razor_TagHelpers_HeadTagHelper);
            await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);

            if (!__tagHelperExecutionContext.Output.IsContentModified)
            {
                await __tagHelperExecutionContext.SetOutputContentAsync();
            }
            Write(__tagHelperExecutionContext.Output);
            __tagHelperExecutionContext = __tagHelperScopeManager.End();
            EndContext();
            BeginContext(168, 2, true);
            WriteLiteral("\r\n");
            EndContext();
            BeginContext(170, 1311, false);
            __tagHelperExecutionContext = __tagHelperScopeManager.Begin("body", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "6d6c65b8c788482aa5ea49f94c6bb561", async() => {
                BeginContext(176, 143, true);
                WriteLiteral("\r\n\r\n<div>\r\n    <h4>Preset</h4>\r\n    <hr />\r\n    <dl class=\"dl-horizontal\">\r\n        <dt>\r\n            Theme Name\r\n        </dt>\r\n        <dd>\r\n");
                EndContext();
#line 20 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Presets\Details.cshtml"

                CMSContext context = new CMSContext();
                var them           = context.Theme.SingleOrDefault(n => n.themeId == Model.themeId);
                var themename      = them.themeName;


#line default
#line hidden
                BeginContext(547, 12, true);
                WriteLiteral("            ");
                EndContext();
                BeginContext(560, 39, false);
#line 25 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Presets\Details.cshtml"
                Write(Html.DisplayFor(modelItem => themename));

#line default
#line hidden
                EndContext();
                BeginContext(599, 45, true);
                WriteLiteral("\r\n        </dd>\r\n\r\n        <dt>\r\n            ");
                EndContext();
                BeginContext(645, 43, false);
#line 29 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Presets\Details.cshtml"
                Write(Html.DisplayNameFor(model => model.themeId));

#line default
#line hidden
                EndContext();
                BeginContext(688, 43, true);
                WriteLiteral("\r\n        </dt>\r\n        <dd>\r\n            ");
                EndContext();
                BeginContext(732, 39, false);
#line 32 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Presets\Details.cshtml"
                Write(Html.DisplayFor(model => model.themeId));

#line default
#line hidden
                EndContext();
                BeginContext(771, 43, true);
                WriteLiteral("\r\n        </dd>\r\n        <dt>\r\n            ");
                EndContext();
                BeginContext(815, 43, false);
#line 35 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Presets\Details.cshtml"
                Write(Html.DisplayNameFor(model => model.visitId));

#line default
#line hidden
                EndContext();
                BeginContext(858, 43, true);
                WriteLiteral("\r\n        </dt>\r\n        <dd>\r\n            ");
                EndContext();
                BeginContext(902, 39, false);
#line 38 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Presets\Details.cshtml"
                Write(Html.DisplayFor(model => model.visitId));

#line default
#line hidden
                EndContext();
                BeginContext(941, 43, true);
                WriteLiteral("\r\n        </dd>\r\n        <dt>\r\n            ");
                EndContext();
                BeginContext(985, 47, false);
#line 41 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Presets\Details.cshtml"
                Write(Html.DisplayNameFor(model => model.dateCreated));

#line default
#line hidden
                EndContext();
                BeginContext(1032, 31, true);
                WriteLiteral("\r\n        </dt>\r\n        <dd>\r\n");
                EndContext();
                BeginContext(1105, 12, true);
                WriteLiteral("            ");
                EndContext();
#line 45 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Presets\Details.cshtml"

                string datecreated = Model.dateCreated.ToString("dd MMM yyyy,hh:mm", DateTimeFormatInfo.InvariantInfo);


#line default
#line hidden
                BeginContext(1257, 12, true);
                WriteLiteral("            ");
                EndContext();
                BeginContext(1270, 41, false);
#line 48 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Presets\Details.cshtml"
                Write(Html.DisplayFor(modelItem => datecreated));

#line default
#line hidden
                EndContext();
                BeginContext(1311, 47, true);
                WriteLiteral("\r\n        </dd>\r\n    </dl>\r\n</div>\r\n<div>\r\n    ");
                EndContext();
                BeginContext(1358, 60, false);
                __tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "ba9fcb4a674c47449c3c49faf536fe64", async() => {
                    BeginContext(1410, 4, true);
                    WriteLiteral("Edit");
                    EndContext();
                }
                                                                            );
                __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper>();
                __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper);
                __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Action = (string)__tagHelperAttribute_0.Value;
                __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0);
                if (__Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.RouteValues == null)
                {
                    throw new InvalidOperationException(InvalidTagHelperIndexerAssignment("asp-route-id", "Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper", "RouteValues"));
                }
                BeginWriteTagHelperAttribute();
#line 53 "C:\Users\L33540.NYPSIT\Desktop\CMSTest2\ASP.NET-Core-CMS-master\CMS\CITI-CMS\CMS\Views\Presets\Details.cshtml"
                WriteLiteral(Model.presetId);

#line default
#line hidden
                __tagHelperStringValueBuffer = EndWriteTagHelperAttribute();
                __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.RouteValues["id"] = __tagHelperStringValueBuffer;
                __tagHelperExecutionContext.AddTagHelperAttribute("asp-route-id", __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.RouteValues["id"], global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes);
                await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
                if (!__tagHelperExecutionContext.Output.IsContentModified)
                {
                    await __tagHelperExecutionContext.SetOutputContentAsync();
                }
                Write(__tagHelperExecutionContext.Output);
                __tagHelperExecutionContext = __tagHelperScopeManager.End();
                EndContext();
                BeginContext(1418, 8, true);
                WriteLiteral(" |\r\n    ");
                EndContext();
                BeginContext(1426, 38, false);
                __tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "d274860bd2e04de4acca8c496753b526", async() => {
                    BeginContext(1448, 12, true);
                    WriteLiteral("Back to List");
                    EndContext();
                }
                                                                            );
                __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper>();
                __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper);
                __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Action = (string)__tagHelperAttribute_1.Value;
                __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_1);
                await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
                if (!__tagHelperExecutionContext.Output.IsContentModified)
                {
                    await __tagHelperExecutionContext.SetOutputContentAsync();
                }
                Write(__tagHelperExecutionContext.Output);
                __tagHelperExecutionContext = __tagHelperScopeManager.End();
                EndContext();
                BeginContext(1464, 10, true);
                WriteLiteral("\r\n</div>\r\n");
                EndContext();
            }
                                                                        );
            __Microsoft_AspNetCore_Mvc_Razor_TagHelpers_BodyTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper>();
            __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_Razor_TagHelpers_BodyTagHelper);
            await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);

            if (!__tagHelperExecutionContext.Output.IsContentModified)
            {
                await __tagHelperExecutionContext.SetOutputContentAsync();
            }
            Write(__tagHelperExecutionContext.Output);
            __tagHelperExecutionContext = __tagHelperScopeManager.End();
            EndContext();
            BeginContext(1481, 11, true);
            WriteLiteral("\r\n</html>\r\n");
            EndContext();
        }
コード例 #23
0
ファイル: MemberList.ascx.cs プロジェクト: kudutest2/Kentico
    /// <summary>
    /// Unigrid OnExternalDataBound event.
    /// </summary>
    protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        GroupMemberStatus status = GroupMemberStatus.Approved;
        DataRowView       drv    = null;
        GridViewRow       gvr    = null;
        bool current             = false;

        switch (sourceName.ToLower())
        {
        case "memberapprovedwhen":
        case "memberrejectedwhen":
            if (parameter != DBNull.Value)
            {
                // Get current dateTime
                return(CMSContext.ConvertDateTime(Convert.ToDateTime(parameter), this));
            }
            break;

        case "approve":
            gvr = parameter as GridViewRow;
            if (gvr != null)
            {
                drv = gvr.DataItem as DataRowView;
                if (drv != null)
                {
                    // Check for current user
                    if (IsLiveSite && (CMSContext.CurrentUser.UserID == ValidationHelper.GetInteger(drv["MemberUserID"], 0)))
                    {
                        current = true;
                    }

                    // Do not allow approve hidden or disabled users
                    bool hiddenOrDisabled = ValidationHelper.GetBoolean(drv["UserIsHidden"], false) || !ValidationHelper.GetBoolean(drv["UserEnabled"], true);

                    status = (GroupMemberStatus)ValidationHelper.GetInteger(drv["MemberStatus"], 0);

                    // Enable or disable Approve button
                    if (!current && (status != GroupMemberStatus.Approved) && !hiddenOrDisabled)
                    {
                        ImageButton button = ((ImageButton)sender);
                        button.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/Approve.png");
                        button.ToolTip  = GetString("general.approve");
                        button.Enabled  = true;
                    }
                    else
                    {
                        ImageButton button = ((ImageButton)sender);
                        button.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/approvedisabled.png");
                        button.ToolTip  = GetString("general.approve");
                        button.Enabled  = false;
                    }
                }
            }

            break;

        case "reject":
            gvr = parameter as GridViewRow;
            if (gvr != null)
            {
                drv = gvr.DataItem as DataRowView;
                if (drv != null)
                {
                    // Check for current user
                    if (IsLiveSite && (CMSContext.CurrentUser.UserID == ValidationHelper.GetInteger(drv.Row["MemberUserID"], 0)))
                    {
                        current = true;
                    }

                    status = (GroupMemberStatus)ValidationHelper.GetInteger(drv["MemberStatus"], 0);

                    // Enable or disable Reject button
                    if (!current && (status != GroupMemberStatus.Rejected))
                    {
                        ImageButton button = ((ImageButton)sender);
                        button.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/Reject.png");
                        button.ToolTip  = GetString("general.reject");
                        button.Enabled  = true;
                    }
                    else
                    {
                        ImageButton button = ((ImageButton)sender);
                        button.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/rejectdisabled.png");
                        button.ToolTip  = GetString("general.reject");
                        button.Enabled  = false;
                    }
                }
            }
            break;

        case "formattedusername":
            return(HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(Convert.ToString(parameter), this.IsLiveSite)));

        case "edit":
            gvr = parameter as GridViewRow;
            if (gvr != null)
            {
                drv = gvr.DataItem as DataRowView;
                if (drv != null)
                {
                    // Do not allow approve hidden or disabled users
                    bool hiddenOrDisabled = ValidationHelper.GetBoolean(drv["UserIsHidden"], false) || !ValidationHelper.GetBoolean(drv["UserEnabled"], true);

                    // Enable or disable Edit button
                    if (!hiddenOrDisabled)
                    {
                        ImageButton button = ((ImageButton)sender);
                        button.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/Edit.png");
                        button.ToolTip  = GetString("general.edit");
                        button.Enabled  = true;
                    }
                    else
                    {
                        ImageButton button = ((ImageButton)sender);
                        button.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/editdisabled.png");
                        button.ToolTip  = GetString("general.edit");
                        button.Enabled  = false;
                    }
                }
            }
            break;
        }
        return(parameter);
    }
コード例 #24
0
ファイル: ModuleRepository.cs プロジェクト: eternalwt/CMS
 public IEnumerable<ErrorInfo> SaveModuleRoles(List<ModulesInRoles> ModuleRoles)
 {
     using (CMSContext context = new CMSContext())
     {
         List<ErrorInfo> errors = new List<ErrorInfo>();
         foreach (var moduleposition in ModuleRoles)
         {
             errors.AddRange(ValidationHelper.Validate(moduleposition));
             if (errors.Any() == false)
                 context.ModulesInRoles.Add(moduleposition);
         }
         if (errors.Any() == false)
             context.SaveChanges();
         return errors;
     }
 }
コード例 #25
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            plcOther.Controls.Clear();

            if (CMSContext.CurrentUser.IsAuthenticated())
            {
                // Set the layout of tab menu
                tabMenu.TabControlLayout = BasicTabControl.GetTabMenuLayout(TabControlLayout);

                // Remove 'saved' parameter from querystring
                string absoluteUri = URLHelper.RemoveParameterFromUrl(URLRewriter.CurrentURL, "saved");

                CurrentUserInfo currentUser = CMSContext.CurrentUser;

                // Get customer info
                GeneralizedInfo customer       = ModuleCommands.ECommerceGetCustomerInfoByUserId(currentUser.UserID);
                bool            userIsCustomer = (customer != null);

                // Get friends enabled setting
                bool friendsEnabled = UIHelper.IsFriendsModuleEnabled(CMSContext.CurrentSiteName);

                // Get customer ID
                int customerId = 0;
                if (userIsCustomer)
                {
                    customerId = ValidationHelper.GetInteger(customer.ObjectID, 0);
                }

                // Selected page url
                string selectedPage = string.Empty;

                // Menu initialization
                tabMenu.UrlTarget = "_self";
                ArrayList activeTabs = new ArrayList();
                string    tabName    = string.Empty;

                int arraySize = 0;
                if (DisplayMyPersonalSettings)
                {
                    arraySize++;
                }
                if (DisplayMyMessages)
                {
                    arraySize++;
                }

                // Handle 'Notifications' tab displaying
                bool hideUnavailableUI       = SettingsKeyProvider.GetBoolValue("CMSHideUnavailableUserInterface");
                bool showNotificationsTab    = (DisplayMyNotifications && ModuleEntry.IsModuleLoaded(ModuleEntry.NOTIFICATIONS) && (!hideUnavailableUI || LicenseHelper.CheckFeature(URLHelper.GetCurrentDomain(), FeatureEnum.Notifications)));
                bool isWindowsAuthentication = RequestHelper.IsWindowsAuthentication();
                if (showNotificationsTab)
                {
                    arraySize++;
                }

                if (DisplayMyFriends && friendsEnabled)
                {
                    arraySize++;
                }
                if (DisplayMyDetails && userIsCustomer)
                {
                    arraySize++;
                }
                if (DisplayMyCredits && userIsCustomer)
                {
                    arraySize++;
                }
                if (DisplayMyAddresses && userIsCustomer)
                {
                    arraySize++;
                }
                if (DisplayMyOrders && userIsCustomer)
                {
                    arraySize++;
                }
                if (DisplayChangePassword && !currentUser.IsExternal && !isWindowsAuthentication)
                {
                    arraySize++;
                }
                if (DisplayMySubscriptions)
                {
                    arraySize++;
                }
                if (this.DisplayMyMemberships)
                {
                    arraySize++;
                }
                if (DisplayMyCategories)
                {
                    arraySize++;
                }

                tabMenu.Tabs = new string[arraySize, 5];

                if (DisplayMyPersonalSettings)
                {
                    tabName = personalTab;
                    activeTabs.Add(tabName);
                    tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyPersonalSettings");
                    tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, personalTab));

                    if (currentUser != null)
                    {
                        selectedPage = tabName;
                    }
                }

                // These items can be displayed only for customer
                if (userIsCustomer && ModuleEntry.IsModuleLoaded(ModuleEntry.ECOMMERCE))
                {
                    if (DisplayMyDetails)
                    {
                        // Try to load the control dynamically (if available)
                        ucMyDetails = Page.LoadControl("~/CMSModules/Ecommerce/Controls/MyDetails/MyDetails.ascx") as CMSAdminControl;
                        if (ucMyDetails != null)
                        {
                            ucMyDetails.ID = "ucMyDetails";
                            plcOther.Controls.Add(ucMyDetails);

                            tabName = detailsTab;
                            activeTabs.Add(tabName);
                            tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyDetails");
                            tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, detailsTab));

                            if (selectedPage == string.Empty)
                            {
                                selectedPage = tabName;
                            }
                        }
                    }

                    if (DisplayMyAddresses)
                    {
                        // Try to load the control dynamically (if available)
                        ucMyAddresses = Page.LoadControl("~/CMSModules/Ecommerce/Controls/MyDetails/MyAddresses.ascx") as CMSAdminControl;
                        if (ucMyAddresses != null)
                        {
                            ucMyAddresses.ID = "ucMyAddresses";
                            plcOther.Controls.Add(ucMyAddresses);

                            tabName = addressesTab;
                            activeTabs.Add(tabName);
                            tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyAddresses");
                            tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, addressesTab));

                            if (selectedPage == string.Empty)
                            {
                                selectedPage = tabName;
                            }
                        }
                    }

                    if (DisplayMyOrders)
                    {
                        // Try to load the control dynamically (if available)
                        ucMyOrders = Page.LoadControl("~/CMSModules/Ecommerce/Controls/MyDetails/MyOrders.ascx") as CMSAdminControl;
                        if (ucMyOrders != null)
                        {
                            ucMyOrders.ID = "ucMyOrders";
                            plcOther.Controls.Add(ucMyOrders);

                            tabName = ordersTab;
                            activeTabs.Add(tabName);
                            tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyOrders");
                            tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, ordersTab));

                            if (selectedPage == string.Empty)
                            {
                                selectedPage = tabName;
                            }
                        }
                    }

                    if (DisplayMyCredits)
                    {
                        // Try to load the control dynamically (if available)
                        ucMyCredit = Page.LoadControl("~/CMSModules/Ecommerce/Controls/MyDetails/MyCredit.ascx") as CMSAdminControl;
                        if (ucMyCredit != null)
                        {
                            ucMyCredit.ID = "ucMyCredit";
                            plcOther.Controls.Add(ucMyCredit);

                            tabName = creditTab;
                            activeTabs.Add(tabName);
                            tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyCredit");
                            tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, creditTab));

                            if (selectedPage == string.Empty)
                            {
                                selectedPage = tabName;
                            }
                        }
                    }
                }

                if (DisplayChangePassword && !currentUser.IsExternal && !isWindowsAuthentication)
                {
                    tabName = passwordTab;
                    activeTabs.Add(tabName);
                    tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.ChangePassword");
                    tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, passwordTab));

                    if (selectedPage == string.Empty)
                    {
                        selectedPage = tabName;
                    }
                }

                if ((ucMyNotifications == null) && showNotificationsTab)
                {
                    // Try to load the control dynamically (if available)
                    ucMyNotifications = Page.LoadControl("~/CMSModules/Notifications/Controls/UserNotifications.ascx") as CMSAdminControl;
                    if (ucMyNotifications != null)
                    {
                        ucMyNotifications.ID = "ucMyNotifications";
                        plcOther.Controls.Add(ucMyNotifications);

                        tabName = notificationsTab;
                        activeTabs.Add(tabName);
                        tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyNotifications");
                        tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, notificationsTab));

                        if (selectedPage == string.Empty)
                        {
                            selectedPage = tabName;
                        }
                    }
                }

                if ((ucMyMessages == null) && DisplayMyMessages && ModuleEntry.IsModuleLoaded(ModuleEntry.MESSAGING))
                {
                    // Try to load the control dynamically (if available)
                    ucMyMessages = Page.LoadControl("~/CMSModules/Messaging/Controls/MyMessages.ascx") as CMSAdminControl;
                    if (ucMyMessages != null)
                    {
                        ucMyMessages.ID = "ucMyMessages";
                        plcOther.Controls.Add(ucMyMessages);

                        tabName = messagesTab;
                        activeTabs.Add(tabName);
                        tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyMessages");
                        tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, messagesTab));

                        if (selectedPage == string.Empty)
                        {
                            selectedPage = tabName;
                        }
                    }
                }

                if ((ucMyFriends == null) && DisplayMyFriends && ModuleEntry.IsModuleLoaded(ModuleEntry.COMMUNITY) && friendsEnabled)
                {
                    // Try to load the control dynamically (if available)
                    ucMyFriends = Page.LoadControl("~/CMSModules/Friends/Controls/MyFriends.ascx") as CMSAdminControl;
                    if (ucMyFriends != null)
                    {
                        ucMyFriends.ID = "ucMyFriends";
                        plcOther.Controls.Add(ucMyFriends);

                        tabName = friendsTab;
                        activeTabs.Add(tabName);
                        tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyFriends");
                        tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, friendsTab));

                        if (selectedPage == string.Empty)
                        {
                            selectedPage = tabName;
                        }
                    }
                }

                if ((ucMyAllSubscriptions == null) && DisplayMySubscriptions)
                {
                    // Try to load the control dynamically (if available)
                    ucMyAllSubscriptions = Page.LoadControl("~/CMSModules/Membership/Controls/Subscriptions.ascx") as CMSAdminControl;
                    if (ucMyAllSubscriptions != null)
                    {
                        ucMyAllSubscriptions.Visible = false;

                        ucMyAllSubscriptions.SetValue("ShowBlogs", DisplayBlogs);
                        ucMyAllSubscriptions.SetValue("ShowMessageBoards", DisplayMessageBoards);
                        ucMyAllSubscriptions.SetValue("ShowNewsletters", DisplayNewsletters);
                        ucMyAllSubscriptions.SetValue("sendconfirmationemail", SendConfirmationEmails);

                        ucMyAllSubscriptions.ID = "ucMyAllSubscriptions";
                        plcOther.Controls.Add(ucMyAllSubscriptions);

                        tabName = subscriptionsTab;
                        activeTabs.Add(tabName);
                        tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyAllSubscriptions");
                        tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, subscriptionsTab));

                        if (selectedPage == string.Empty)
                        {
                            selectedPage = tabName;
                        }
                    }
                }

                // My memberships
                if ((this.ucMyMemberships == null) && this.DisplayMyMemberships)
                {
                    // Try to load the control dynamically
                    this.ucMyMemberships = this.Page.LoadControl("~/CMSModules/Membership/Controls/MyMemberships.ascx") as CMSAdminControl;

                    if (this.ucMyMemberships != null)
                    {
                        this.ucMyMemberships.SetValue("UserID", currentUser.UserID);

                        if (!String.IsNullOrEmpty(this.MembershipsPagePath))
                        {
                            this.ucMyMemberships.SetValue("BuyMembershipURL", CMSContext.GetUrl(this.MembershipsPagePath));
                        }

                        this.plcOther.Controls.Add(this.ucMyMemberships);

                        tabName = membershipsTab;
                        activeTabs.Add(tabName);
                        this.tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = this.GetString("myaccount.mymemberships");
                        this.tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, this.ParameterName, membershipsTab));

                        if (selectedPage == String.Empty)
                        {
                            selectedPage = tabName;
                        }
                    }
                }

                if ((ucMyCategories == null) && DisplayMyCategories)
                {
                    // Try to load the control dynamically (if available)
                    ucMyCategories = Page.LoadControl("~/CMSModules/Categories/Controls/Categories.ascx") as CMSAdminControl;
                    if (ucMyCategories != null)
                    {
                        ucMyCategories.Visible = false;

                        ucMyCategories.SetValue("DisplaySiteCategories", false);
                        ucMyCategories.SetValue("DisplaySiteSelector", false);

                        ucMyCategories.ID = "ucMyCategories";
                        plcOther.Controls.Add(ucMyCategories);

                        tabName = categoriesTab;
                        activeTabs.Add(tabName);
                        tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyCategories");
                        tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, categoriesTab));

                        if (selectedPage == string.Empty)
                        {
                            selectedPage = tabName;
                        }
                    }
                }

                // Set css class
                pnlBody.CssClass = CssClass;

                // Get page url
                page = QueryHelper.GetString(ParameterName, selectedPage);

                // Set controls visibility
                ucChangePassword.Visible        = false;
                ucChangePassword.StopProcessing = true;

                if (ucMyAddresses != null)
                {
                    ucMyAddresses.Visible        = false;
                    ucMyAddresses.StopProcessing = true;
                }

                if (ucMyOrders != null)
                {
                    ucMyOrders.Visible        = false;
                    ucMyOrders.StopProcessing = true;
                }

                if (ucMyDetails != null)
                {
                    ucMyDetails.Visible        = false;
                    ucMyDetails.StopProcessing = true;
                }

                if (ucMyCredit != null)
                {
                    ucMyCredit.Visible        = false;
                    ucMyCredit.StopProcessing = true;
                }

                if (ucMyAllSubscriptions != null)
                {
                    ucMyAllSubscriptions.Visible        = false;
                    ucMyAllSubscriptions.StopProcessing = true;
                    ucMyAllSubscriptions.SetValue("CacheMinutes", CacheMinutes);
                }

                if (ucMyNotifications != null)
                {
                    ucMyNotifications.Visible        = false;
                    ucMyNotifications.StopProcessing = true;
                }

                if (ucMyMessages != null)
                {
                    ucMyMessages.Visible        = false;
                    ucMyMessages.StopProcessing = true;
                }

                if (ucMyFriends != null)
                {
                    ucMyFriends.Visible        = false;
                    ucMyFriends.StopProcessing = true;
                }

                if (this.ucMyMemberships != null)
                {
                    this.ucMyMemberships.Visible        = false;
                    this.ucMyMemberships.StopProcessing = true;
                }

                if (this.ucMyCategories != null)
                {
                    this.ucMyCategories.Visible        = false;
                    this.ucMyCategories.StopProcessing = true;
                }

                tabMenu.SelectedTab = activeTabs.IndexOf(page);

                // Select current page
                switch (page)
                {
                case personalTab:
                    if (myProfile != null)
                    {
                        // Get alternative form info
                        AlternativeFormInfo afi = AlternativeFormInfoProvider.GetAlternativeFormInfo(AlternativeFormName);
                        if (afi != null)
                        {
                            myProfile.StopProcessing      = false;
                            myProfile.Visible             = true;
                            myProfile.AllowEditVisibility = AllowEditVisibility;
                            myProfile.AlternativeFormName = AlternativeFormName;
                        }
                        else
                        {
                            lblError.Text     = String.Format(GetString("altform.formdoesntexists"), AlternativeFormName);
                            lblError.Visible  = true;
                            myProfile.Visible = false;
                        }
                    }
                    break;

                case detailsTab:
                    if (ucMyDetails != null)
                    {
                        ucMyDetails.Visible        = true;
                        ucMyDetails.StopProcessing = false;
                        ucMyDetails.SetValue("Customer", customer);
                    }
                    break;

                case addressesTab:
                    if (ucMyAddresses != null)
                    {
                        ucMyAddresses.Visible        = true;
                        ucMyAddresses.StopProcessing = false;
                        ucMyAddresses.SetValue("CustomerId", customerId);
                    }
                    break;

                case ordersTab:
                    if (ucMyOrders != null)
                    {
                        ucMyOrders.Visible        = true;
                        ucMyOrders.StopProcessing = false;
                        ucMyOrders.SetValue("CustomerId", customerId);
                        ucMyOrders.SetValue("ShowOrderTrackingNumber", ShowOrderTrackingNumber);
                    }
                    break;

                case creditTab:
                    if (ucMyCredit != null)
                    {
                        ucMyCredit.Visible        = true;
                        ucMyCredit.StopProcessing = false;
                        ucMyCredit.SetValue("CustomerId", customerId);
                    }
                    break;

                case passwordTab:
                    ucChangePassword.Visible            = true;
                    ucChangePassword.StopProcessing     = false;
                    ucChangePassword.AllowEmptyPassword = AllowEmptyPassword;
                    break;

                case notificationsTab:
                    if (ucMyNotifications != null)
                    {
                        ucMyNotifications.Visible        = true;
                        ucMyNotifications.StopProcessing = false;
                        ucMyNotifications.SetValue("UserId", currentUser.UserID);
                        ucMyNotifications.SetValue("UnigridImageDirectory", UnigridImageDirectory);
                    }
                    break;

                case messagesTab:
                    if (ucMyMessages != null)
                    {
                        ucMyMessages.Visible        = true;
                        ucMyMessages.StopProcessing = false;
                    }
                    break;

                case friendsTab:
                    if (ucMyFriends != null)
                    {
                        ucMyFriends.Visible        = true;
                        ucMyFriends.StopProcessing = false;
                        ucMyFriends.SetValue("UserID", currentUser.UserID);
                    }
                    break;

                case subscriptionsTab:
                    if (ucMyAllSubscriptions != null)
                    {
                        ucMyAllSubscriptions.Visible        = true;
                        ucMyAllSubscriptions.StopProcessing = false;

                        ucMyAllSubscriptions.SetValue("userid", currentUser.UserID);
                        ucMyAllSubscriptions.SetValue("siteid", CMSContext.CurrentSiteID);
                    }
                    break;

                case membershipsTab:
                    if (this.ucMyMemberships != null)
                    {
                        this.ucMyMemberships.Visible        = true;
                        this.ucMyMemberships.StopProcessing = false;
                    }
                    break;

                case categoriesTab:
                    if (this.ucMyCategories != null)
                    {
                        this.ucMyCategories.Visible        = true;
                        this.ucMyCategories.StopProcessing = false;
                    }
                    break;
                }
            }
            else
            {
                // Hide control if current user is not authenticated
                Visible = false;
            }
        }
    }
コード例 #26
0
 public VerkopenController(CMSContext context)
 {
     verkoopRepository = new VerkoopRepository(context);
     lampRepository    = new LampRepository(context);
     koperRepository   = new KoperRepository(context);
 }
コード例 #27
0
ファイル: ModuleRepository.cs プロジェクト: eternalwt/CMS
 public List<PositionDetail> GetPositions()
 {
     using (CMSContext context = new CMSContext())
     {
         return (from position in context.Positions
                 orderby position.PositionName
                 select new PositionDetail
                 {
                     PositionID = position.PositionID,
                     PositionName = position.PositionName
                 }).ToList();
     }
 }
コード例 #28
0
 /// <summary>
 /// Returns URL of the document specified by alias path or URL path.
 /// </summary>
 /// <param name="aliasPath">Alias path of the document</param>
 /// <param name="urlPath">Url path of the document</param>
 public static string GetUrl(object aliasPath, object urlPath)
 {
     return(CMSContext.GetUrl(Convert.ToString(aliasPath), Convert.ToString(urlPath)));
 }
コード例 #29
0
 public SiteMessageRepository(CMSContext cmsContext) : base(cmsContext)
 {
 }
コード例 #30
0
ファイル: CMSService.File.cs プロジェクト: foster-hub/box-cms
 public void RemoveUnusedFiles()
 {
     using (var ctx = new CMSContext()) {
         IQueryable<File> files = ctx.Files.Where(x => !ctx.ContentDatas.Where(c => c.JSON.Contains(x.FileUId)).Any()
         && !ctx.ContentHeads.Where(w => w.ThumbFilePath.Contains(x.FileUId)).Any());
         ctx.Files.RemoveRange(files);
         ctx.SaveChanges();
     }
 }
コード例 #31
0
        public ActionResult Add(Blog blog, int?id)
        {
            ViewBag.CategoryList = GetActiveCategory();
            ViewBag.MediaDate    = GetMediaDate();

            if (ModelState.IsValid)
            {
                var context = new CMSContext();
                if (id == null)
                {
                    var param = new SqlParameter[] {
                        new SqlParameter()
                        {
                            ParameterName = "@Url",
                            SqlDbType     = System.Data.SqlDbType.VarChar,
                            Direction     = System.Data.ParameterDirection.Input,
                            Size          = 100,
                            Value         = CommonFunction.Url(blog.Url)
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@Sep",
                            SqlDbType     = System.Data.SqlDbType.VarChar,
                            Direction     = System.Data.ParameterDirection.Input,
                            Size          = 1,
                            Value         = "-"
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@TableName",
                            SqlDbType     = System.Data.SqlDbType.VarChar,
                            Direction     = System.Data.ParameterDirection.Input,
                            Size          = 25,
                            Value         = DBNull.Value
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@Id",
                            SqlDbType     = System.Data.SqlDbType.Int,
                            Direction     = System.Data.ParameterDirection.Input,
                            Value         = DBNull.Value
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@TempUrl",
                            SqlDbType     = System.Data.SqlDbType.VarChar,
                            Direction     = System.Data.ParameterDirection.Output,
                            Size          = 100
                        }
                    };
                    context.Database.ExecuteSqlRaw("[dbo].[sp_GetURL] @Url, @Sep, @TableName, @Id, @TempUrl out", param);

                    blog.Url = Convert.ToString(param[4].Value);
                    context.Blog.Add(blog);
                    int result = context.SaveChanges();

                    TempData["result"] = result == 1 ? "Insert Successful" : "Failed";
                    if (result == 1)
                    {
                        return(RedirectToAction("Add", new { id = blog.Id }));
                    }
                }
                else
                {
                    var param = new SqlParameter[] {
                        new SqlParameter()
                        {
                            ParameterName = "@Url",
                            SqlDbType     = System.Data.SqlDbType.VarChar,
                            Direction     = System.Data.ParameterDirection.Input,
                            Size          = 100,
                            Value         = CommonFunction.Url(blog.Url)
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@Sep",
                            SqlDbType     = System.Data.SqlDbType.VarChar,
                            Direction     = System.Data.ParameterDirection.Input,
                            Size          = 1,
                            Value         = "-"
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@TableName",
                            SqlDbType     = System.Data.SqlDbType.VarChar,
                            Direction     = System.Data.ParameterDirection.Input,
                            Size          = 25,
                            Value         = "Blog"
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@Id",
                            SqlDbType     = System.Data.SqlDbType.Int,
                            Direction     = System.Data.ParameterDirection.Input,
                            Value         = id
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@TempUrl",
                            SqlDbType     = System.Data.SqlDbType.VarChar,
                            Direction     = System.Data.ParameterDirection.Output,
                            Size          = 100
                        }
                    };
                    context.Database.ExecuteSqlRaw("[dbo].[sp_GetURL] @Url, @Sep, @TableName, @Id, @TempUrl out", param);

                    var blogResult = context.Blog.Where(x => x.Id == id).FirstOrDefault();
                    blogResult.Name            = blog.Name;
                    blogResult.Url             = Convert.ToString(param[4].Value);
                    blogResult.CategoryId      = blog.CategoryId;
                    blogResult.PrimaryImageId  = blog.PrimaryImageId;
                    blogResult.Description     = blog.Description;
                    blogResult.MetaTitle       = blog.MetaTitle;
                    blogResult.MetaKeyword     = blog.MetaKeyword;
                    blogResult.MetaDescription = blog.MetaDescription;
                    blogResult.Status          = blog.Status;

                    int result = context.SaveChanges();
                    ModelState.Clear();
                    TempData["result"] = result == 1 ? "Update Successful" : "Failed";
                }
                blog.PrimaryImageUrl = blog.PrimaryImageUrl ?? "~/images/addphoto.jpg";
            }
            ViewBag.Title = id == null ? "Add New Blog" : "Update Blog";
            return(View(blog));
        }
コード例 #32
0
    protected object gridLanguages_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        TranslationStatusEnum status = TranslationStatusEnum.NotAvailable;
        DataRowView           drv    = null;

        sourceName = sourceName.ToLowerCSafe();

        if (currentUserInfo == null)
        {
            currentUserInfo = CMSContext.CurrentUser;
        }
        if (currentSiteInfo == null)
        {
            currentSiteInfo = CMSContext.CurrentSite;
        }

        switch (sourceName)
        {
        case "translate":
        case "action":
            ImageButton img = sender as CMSImageButton;
            if (img != null)
            {
                if ((sourceName == "translate") &&
                    (!CMS.TranslationServices.TranslationServiceHelper.AnyServiceAvailable(CurrentSiteName) ||
                     !CMS.TranslationServices.TranslationServiceHelper.IsTranslationAllowed(CurrentSiteName)))
                {
                    img.Visible = false;
                    return(img);
                }

                GridViewRow gvr = parameter as GridViewRow;
                if (gvr != null)
                {
                    // Get datarowview
                    drv = gvr.DataItem as DataRowView;

                    if ((drv != null) && (drv.Row["TranslationStatus"] != DBNull.Value))
                    {
                        // Get translation status
                        status = (TranslationStatusEnum)drv.Row["TranslationStatus"];
                    }
                    else
                    {
                        status = TranslationStatusEnum.NotAvailable;
                    }

                    string culture = (drv != null) ? ValidationHelper.GetString(drv.Row["DocumentCulture"], string.Empty) : string.Empty;

                    // Set appropriate icon
                    if (sourceName == "action")
                    {
                        switch (status)
                        {
                        case TranslationStatusEnum.NotAvailable:
                            img.ImageUrl = GetImageUrl("CMSModules/CMS_Content/Properties/addculture.png");
                            img.ToolTip  = GetString("transman.createnewculture");
                            break;

                        default:
                            img.ImageUrl = GetImageUrl("CMSModules/CMS_Content/Properties/editculture.png");
                            img.ToolTip  = GetString("transman.editculture");
                            break;
                        }

                        // Register redirect script
                        if (RequiresDialog)
                        {
                            if ((sourceName == "action") && (status == TranslationStatusEnum.NotAvailable))
                            {
                                // New culture version
                                img.OnClientClick = "parent.parent.parent.NewDocumentCulture(" + NodeID + ",'" + culture + "');";
                            }
                            else
                            {
                                // Existing culture version
                                ScriptHelper.RegisterWOpenerScript(Page);
                                string url = ResolveUrl(CMSContext.GetUrl(Node.NodeAliasPath, Node.DocumentUrlPath, currentSiteInfo.SiteName));
                                url = URLHelper.AppendQuery(url, "lang=" + culture);
                                img.OnClientClick = "window.refreshPageOnClose = true; window.reloadPageUrl = " + ScriptHelper.GetString(url) + "; if (wopener.RefreshWOpener) { wopener.RefreshWOpener(window); } CloseDialog();";
                            }
                        }
                        else
                        {
                            img.OnClientClick = "RedirectItem(" + NodeID + ", '" + culture + "');";
                        }

                        img.ID = "imgAction";
                    }
                    else
                    {
                        // Add parameters identifier and hash, encode query string
                        if (LicenseHelper.CheckFeature(URLHelper.GetCurrentDomain(), FeatureEnum.TranslationServices))
                        {
                            string returnUrl = CMSContext.ResolveDialogUrl("~/CMSModules/Translations/Pages/TranslateDocuments.aspx") + "?targetculture=" + culture + "&modal=1&nodeid=" + NodeID;
                            returnUrl = URLHelper.AddParameterToUrl(returnUrl, "hash", QueryHelper.GetHash(URLHelper.GetQuery(returnUrl)));

                            img.ImageUrl      = GetImageUrl("CMSModules/CMS_Content/Properties/translate.png");
                            img.ToolTip       = GetString("transman.translate");
                            img.OnClientClick = "modalDialog('" + returnUrl + "', 'TranslateDocument', 550, 440); ";
                        }
                        else
                        {
                            img.Visible = false;
                        }
                        break;
                    }
                }
            }
            return(img);

        case "translationstatus":
            if (parameter == DBNull.Value)
            {
                status = TranslationStatusEnum.NotAvailable;
            }
            else
            {
                status = (TranslationStatusEnum)parameter;
            }
            string statusName = GetString("transman." + status);
            string statusHtml = "<span class=\"" + status + "\">" + statusName + "</span>";
            // .Outdated
            return(statusHtml);

        case "documentculturedisplayname":
            drv = (DataRowView)parameter;
            // Add icon
            return(UniGridFunctions.DocumentCultureFlag(drv, Page));

        case "documentmodifiedwhen":
        case "documentmodifiedwhentooltip":
            if (string.IsNullOrEmpty(parameter.ToString()))
            {
                return("-");
            }
            else
            {
                DateTime modifiedWhen = ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME);
                bool     displayGMT   = (sourceName == "documentmodifiedwhentooltip");
                return(TimeZoneHelper.ConvertToUserTimeZone(modifiedWhen, displayGMT, currentUserInfo, currentSiteInfo));
            }

        case "versionnumber":
            if (string.IsNullOrEmpty(parameter.ToString()))
            {
                return("-");
            }
            break;

        case "documentname":
            if (string.IsNullOrEmpty(parameter.ToString()))
            {
                parameter = "-";
            }
            return(HTMLHelper.HTMLEncode(parameter.ToString()));

        case "published":
            bool published = ValidationHelper.GetBoolean(parameter, false);
            if (published)
            {
                return("<span class=\"DocumentPublishedYes\">" + GetString("General.Yes") + "</span>");
            }
            else
            {
                return("<span class=\"DocumentPublishedNo\">" + GetString("General.No") + "</span>");
            }
        }
        return(parameter);
    }
コード例 #33
0
    /// <summary>
    /// Page load.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        string aType = SetMode(avValue);

        picUser.UserAvatarType = aType;

        switch (aType)
        {
        case AvatarInfoProvider.AVATAR:

            // Get resource strings
            lblUploader.Text = GetString("filelist.btnupload") + ResHelper.Colon;

            // Setup delete image properties
            btnDeleteImage.ImageUrl      = GetImageUrl("Design/Controls/UniGrid/Actions/delete.png");
            btnDeleteImage.OnClientClick = "return deleteAvatar('" + hiddenDeleteAvatar.ClientID + "', '" + hiddenAvatarGuid.ClientID + "', '" + pnlAvatarImage.ClientID + "' );";
            btnDeleteImage.ToolTip       = GetString("general.delete");
            btnDeleteImage.AlternateText = btnDeleteImage.ToolTip;


            // Setup show gallery button
            btnShowGallery.Text    = GetString("avat.selector.select");
            btnShowGallery.Visible = SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSEnableDefaultAvatars");

            // Register dialog script
            string resolvedAvatarsPage = string.Empty;
            if (IsLiveSite)
            {
                if (CMSContext.CurrentUser.IsAuthenticated())
                {
                    resolvedAvatarsPage = CMSContext.ResolveDialogUrl("~/CMSModules/Avatars/CMSPages/AvatarsGallery.aspx");
                }
                else
                {
                    resolvedAvatarsPage = CMSContext.ResolveDialogUrl("~/CMSModules/Avatars/CMSPages/PublicAvatarsGallery.aspx");
                }
            }
            else
            {
                resolvedAvatarsPage = ResolveUrl("~/CMSModules/Avatars/Dialogs/AvatarsGallery.aspx");
            }

            ScriptHelper.RegisterDialogScript(Page);
            ControlsHelper.RegisterClientScriptBlock(this, Page, typeof(string), "SelectAvatar",
                                                     ScriptHelper.GetScript("function SelectAvatar(avatarType, clientId) { " +
                                                                            "modalDialog('" + resolvedAvatarsPage + "?avatartype=' + avatarType + '&clientid=' + clientId, 'permissionDialog', 600, 270); return false;}"));
            ltlScript.Text = ScriptHelper.GetScript("function UpdateForm(){ ; } \n ");

            // Setup btnShowGallery action
            btnShowGallery.Attributes.Add("onclick", "SelectAvatar('" + AvatarInfoProvider.GetAvatarTypeString(avatarType) + "', '" + ClientID + "'); return false;");

            // Get image size param(s) for preview
            string sizeParams = string.Empty;
            // Keep aspect ratio is set - property was set directly or indirectly by max side size property.
            if (KeepAspectRatio)
            {
                sizeParams += "&maxsidesize=" + (MaxPictureWidth > MaxPictureHeight ? MaxPictureWidth : MaxPictureHeight);
            }
            else
            {
                sizeParams += "&width=" + MaxPictureWidth + "&height=" + MaxPictureHeight;
            }

            // JavaScript which creates selected image preview and saves image guid  to hidden field
            string getAvatarPath = ResolveUrl("~/CMSModules/Avatars/CMSPages/GetAvatar.aspx");

            string updateHiddenScript = ScriptHelper.GetScript("function " + ClientID + "updateHidden(guidPrefix, clientId)" +
                                                               "{" +
                                                               "if ( clientId == '" + ClientID + "')" +
                                                               "{" +
                                                               "avatarGuid = guidPrefix.substring(4);" +
                                                               "if ( avatarGuid != '')" +
                                                               "{" +
                                                               "hidden = document.getElementById('" + hiddenAvatarGuid.ClientID + "');" +
                                                               "hidden.value = avatarGuid ;" +
                                                               "div = document.getElementById('" + pnlPreview.ClientID + "');" +
                                                               "div.style.display='';" +
                                                               "div.innerHTML = '<img src=\"" + getAvatarPath + "?avatarguid=" + "'+ avatarGuid + '" + sizeParams + "\" />" +
                                                               "&#13;&#10;&nbsp;<img src=\"" + btnDeleteImage.ImageUrl + "\" border=\"0\" onclick=\"deleteImagePreview(\\'" + hiddenAvatarGuid.ClientID + "\\',\\'" + pnlPreview.ClientID + "\\')\" style=\"cursor:pointer\"/>';" +
                                                               "placeholder = document.getElementById('" + pnlAvatarImage.ClientID + "');" +
                                                               "if ( placeholder != null)" +
                                                               "{" +
                                                               "placeholder.style.display='none';" +
                                                               "}" +
                                                               "}" +
                                                               "}" +
                                                               "}");

            ControlsHelper.RegisterClientScriptBlock(this, Page, typeof(string), ClientID + "updateHidden", updateHiddenScript);

            // JavaScript which deletes image preview
            string deleteImagePreviewScript = ScriptHelper.GetScript("function deleteImagePreview(hiddenId, divId)" +
                                                                     "{" +
                                                                     "if( confirm(" + ScriptHelper.GetString(GetString("myprofile.pictdeleteconfirm")) + "))" +
                                                                     "{" +
                                                                     "hidden = document.getElementById(hiddenId);" +
                                                                     "hidden.value = '' ;" +
                                                                     "div = document.getElementById(divId);" +
                                                                     "div.style.display='none';" +
                                                                     "div.innerHTML = ''; " +
                                                                     "}" +
                                                                     "}");

            ControlsHelper.RegisterClientScriptBlock(this, Page, typeof(string), "deleteImagePreviewScript", deleteImagePreviewScript);

            // JavaScript which pseudo deletes avatar
            string deleteAvatarScript = ScriptHelper.GetScript("function deleteAvatar(hiddenDeleteId, hiddenGuidId, placeholderId)" +
                                                               "{" +
                                                               "if( confirm(" + ScriptHelper.GetString(GetString("myprofile.pictdeleteconfirm")) + "))" +
                                                               "{" +
                                                               "hidden = document.getElementById(hiddenDeleteId);" +
                                                               "hidden.value = 'true' ;" +
                                                               "placeholder = document.getElementById(placeholderId);" +
                                                               "placeholder.style.display='none';" +
                                                               "hidden = document.getElementById(hiddenGuidId);" +
                                                               "hidden.value = '' ;" +
                                                               "}" +
                                                               "return false; " +
                                                               "}");
            ControlsHelper.RegisterClientScriptBlock(this, Page, typeof(string), "deleteAvatar", deleteAvatarScript);

            // Try to load avatar either on first load or when it is first attempt to load an avatar
            if ((UserInfo == null) && (!RequestHelper.IsPostBack() || !AvatarAlreadyLoaded) && (avatarID != 0))
            {
                AvatarAlreadyLoaded = true;

                pnlAvatarImage.Visible = true;
                picUser.AvatarID       = avatarID;
            }
            btnDeleteImage.Visible = ((avatarID > 0) || ((UserInfo != null) && (UserInfo.UserAvatarID > 0)));
            plcUploader.Visible    = true;
            imgHelp.Visible        = false;

            break;

        case AvatarInfoProvider.GRAVATAR:
            // Hide avatar controls
            btnDeleteImage.Visible = false;
            btnShowGallery.Visible = false;
            plcUploader.Visible    = false;

            // Help icon for Gravatar
            ScriptHelper.RegisterTooltip(Page);
            imgHelp.ImageUrl = GetImageUrl("CMSModules/CMS_Settings/help.png");
            imgHelp.Attributes.Add("alt", "");
            ScriptHelper.AppendTooltip(imgHelp, GetString("avatar.gravatarinfo"), null);

            // Show only UserPicture control
            pnlAvatarImage.Visible = true;
            picUser.Visible        = true;
            imgHelp.Visible        = true;
            break;
        }
    }
コード例 #34
0
ファイル: PageService.cs プロジェクト: jarmatys/CMS
 public PageService(CMSContext context)
 {
     _context = context;
 }
コード例 #35
0
        public IActionResult Add(Page page, int?id)
        {
            if (ModelState.IsValid)
            {
                using (var context = new CMSContext())
                {
                    if (id == null)
                    {
                        var param = new SqlParameter[] {
                            new SqlParameter()
                            {
                                ParameterName = "@Name",
                                SqlDbType     = System.Data.SqlDbType.VarChar,
                                Direction     = System.Data.ParameterDirection.Input,
                                Size          = 100,
                                Value         = page.Name
                            },
                            new SqlParameter()
                            {
                                ParameterName = "@Url",
                                SqlDbType     = System.Data.SqlDbType.VarChar,
                                Direction     = System.Data.ParameterDirection.Input,
                                Size          = 100,
                                Value         = CommonFunction.Url(page.Url)
                            },
                            new SqlParameter()
                            {
                                ParameterName = "@MetaTitle",
                                SqlDbType     = System.Data.SqlDbType.VarChar,
                                Direction     = System.Data.ParameterDirection.Input,
                                Size          = 250,
                                Value         = page.MetaTitle ?? (object)DBNull.Value
                            },
                            new SqlParameter()
                            {
                                ParameterName = "@MetaKeyword",
                                SqlDbType     = System.Data.SqlDbType.VarChar,
                                Direction     = System.Data.ParameterDirection.Input,
                                Size          = 250,
                                Value         = page.MetaKeyword ?? (object)DBNull.Value
                            },
                            new SqlParameter()
                            {
                                ParameterName = "@MetaDescription",
                                SqlDbType     = System.Data.SqlDbType.VarChar,
                                Direction     = System.Data.ParameterDirection.Input,
                                Size          = 250,
                                Value         = page.MetaDescription ?? (object)DBNull.Value
                            },
                            new SqlParameter()
                            {
                                ParameterName = "@Description",
                                SqlDbType     = System.Data.SqlDbType.VarChar,
                                Direction     = System.Data.ParameterDirection.Input,
                                Size          = -1,
                                Value         = page.Description
                            },
                            new SqlParameter()
                            {
                                ParameterName = "@Status",
                                SqlDbType     = System.Data.SqlDbType.Bit,
                                Direction     = System.Data.ParameterDirection.Input,
                                Value         = page.Status
                            },
                            new SqlParameter()
                            {
                                ParameterName = "@Result",
                                SqlDbType     = System.Data.SqlDbType.VarChar,
                                Direction     = System.Data.ParameterDirection.Output,
                                Size          = 50
                            },
                            new SqlParameter()
                            {
                                ParameterName = "@CreatedId",
                                SqlDbType     = System.Data.SqlDbType.Int,
                                Direction     = System.Data.ParameterDirection.Output,
                            }
                        };

                        context.Database.ExecuteSqlRaw("[dbo].[sp_InsertPage] @Name, @Url, @MetaTitle, @MetaKeyword, @MetaDescription, @Description, @Status, @Result out, @CreatedId out", param);

                        TempData["result"] = Convert.ToString(param[7].Value);
                        if (Convert.ToString(param[7].Value) == "Insert Successful")
                        {
                            return(RedirectToAction("Add", new { id = Convert.ToInt32(param[8].Value) }));
                        }
                    }
                    else
                    {
                        var param = new SqlParameter[] {
                            new SqlParameter()
                            {
                                ParameterName = "@Id",
                                SqlDbType     = System.Data.SqlDbType.Int,
                                Direction     = System.Data.ParameterDirection.Input,
                                Value         = page.Id
                            },
                            new SqlParameter()
                            {
                                ParameterName = "@Name",
                                SqlDbType     = System.Data.SqlDbType.VarChar,
                                Direction     = System.Data.ParameterDirection.Input,
                                Size          = 100,
                                Value         = page.Name
                            },
                            new SqlParameter()
                            {
                                ParameterName = "@Url",
                                SqlDbType     = System.Data.SqlDbType.VarChar,
                                Direction     = System.Data.ParameterDirection.Input,
                                Size          = 100,
                                Value         = CommonFunction.Url(page.Url)
                            },
                            new SqlParameter()
                            {
                                ParameterName = "@MetaTitle",
                                SqlDbType     = System.Data.SqlDbType.VarChar,
                                Direction     = System.Data.ParameterDirection.Input,
                                Size          = 250,
                                Value         = page.MetaTitle ?? (object)DBNull.Value
                            },
                            new SqlParameter()
                            {
                                ParameterName = "@MetaKeyword",
                                SqlDbType     = System.Data.SqlDbType.VarChar,
                                Direction     = System.Data.ParameterDirection.Input,
                                Size          = 250,
                                Value         = page.MetaKeyword ?? (object)DBNull.Value
                            },
                            new SqlParameter()
                            {
                                ParameterName = "@MetaDescription",
                                SqlDbType     = System.Data.SqlDbType.VarChar,
                                Direction     = System.Data.ParameterDirection.Input,
                                Size          = 250,
                                Value         = page.MetaDescription ?? (object)DBNull.Value
                            },
                            new SqlParameter()
                            {
                                ParameterName = "@Description",
                                SqlDbType     = System.Data.SqlDbType.VarChar,
                                Direction     = System.Data.ParameterDirection.Input,
                                Size          = -1,
                                Value         = page.Description
                            },
                            new SqlParameter()
                            {
                                ParameterName = "@Status",
                                SqlDbType     = System.Data.SqlDbType.Bit,
                                Direction     = System.Data.ParameterDirection.Input,
                                Value         = page.Status
                            },
                            new SqlParameter()
                            {
                                ParameterName = "@Result",
                                SqlDbType     = System.Data.SqlDbType.VarChar,
                                Direction     = System.Data.ParameterDirection.Output,
                                Size          = 50
                            },
                            new SqlParameter()
                            {
                                ParameterName = "@CreatedUrl",
                                SqlDbType     = System.Data.SqlDbType.VarChar,
                                Direction     = System.Data.ParameterDirection.Output,
                                Size          = 100
                            }
                        };
                        context.Database.ExecuteSqlRaw("[dbo].[sp_UpdatePage] @Id, @Name, @Url, @MetaTitle, @MetaKeyword, @MetaDescription, @Description, @Status, @Result out, @CreatedUrl out", param);
                        ModelState.Clear();
                        page.Url           = Convert.ToString(param[9].Value);
                        TempData["result"] = Convert.ToString(param[8].Value);
                    }
                }
            }
            ViewBag.Title = id == null ? "Add New Page" : "Update Page";
            return(View(page));
        }
コード例 #36
0
 public CMSCarManageRecordDAO(CMSContext context) : base(context)
 {
 }
コード例 #37
0
 public ExecutiveRepository(IDefaultContextFactory contextFactory)
 {
     this.context = contextFactory.Create();
 }
コード例 #38
0
    /// <summary>
    /// Gets user effective permissions HTML content.
    /// </summary>
    /// <param name="siteId">Site ID</param>
    /// <param name="resourceId">ID of particular resource</param>
    /// <param name="selectedType">Permission type</param>
    /// <param name="userId">User ID</param>
    private string GetBeforeRowsContent(int siteId, int resourceId, string selectedType, int userId)
    {
        // Check if selected users exists
        UserInfo user = SelectedUser;

        if (user == null)
        {
            gridMatrix.ShowContentBeforeRows = false;
            return(null);
        }

        string columns = "PermissionID";

        // Ensure tooltip column
        if (!String.IsNullOrEmpty(gridMatrix.ItemTooltipColumn))
        {
            columns += ",Matrix." + gridMatrix.ItemTooltipColumn;
        }

        // Get permission data
        DataSet dsPermissions = null;

        switch (selectedType)
        {
        case "r":
            dsPermissions = UserInfoProvider.GetUserResourcePermissions(user, siteId, resourceId, true, columns);
            break;

        default:
            dsPermissions = UserInfoProvider.GetUserDataClassPermissions(user, siteId, resourceId, true, columns);
            break;
        }

        // Initialize string builder
        StringBuilder sb = new StringBuilder("");

        if (!DataHelper.DataSourceIsEmpty(dsPermissions))
        {
            // Initialize variables used during rendering
            string            firstColumnsWidth = (gridMatrix.FirstColumnsWidth > 0) ? "width:" + gridMatrix.FirstColumnsWidth + (gridMatrix.UsePercentage ? "%;" : "px;") : "";
            string            imagesUrl         = GetImageUrl("Design/Controls/UniMatrix/", IsLiveSite, true);
            DataRowCollection rows     = dsPermissions.Tables[0].Rows;
            string            userName = Functions.GetFormattedUserName(user.UserName, user.FullName);

            // Get user name column
            sb.Append("<td class=\"MatrixHeader\" style=\"");
            sb.Append(firstColumnsWidth);
            sb.Append("white-space:nowrap;\" title=\"");
            sb.Append(HTMLHelper.HTMLEncode(userName));
            sb.Append("\">");
            sb.Append(HTMLHelper.HTMLEncode(TextHelper.LimitLength(userName, 50)));
            sb.Append("</td>\n");


            // Process permissions according to matrix order
            foreach (int index in gridMatrix.ColumnOrderIndex)
            {
                DataRow dr = (DataRow)rows[index];

                // Render cell
                sb.Append("<td style=\"white-space:nowrap; text-align: center;\"><img src=\"");
                sb.Append(imagesUrl);

                // Render checkboxes
                if (SelectedUser.IsGlobalAdministrator || Convert.ToInt32(dr["Allowed"]) == 1)
                {
                    sb.Append("allowed.png");
                }
                else
                {
                    sb.Append("denied.png");
                }

                // Append tootlip and alternative text
                sb.Append("\" title=\"");
                string tooltip = HTMLHelper.HTMLEncode(CMSContext.ResolveMacros(ValidationHelper.GetString(DataHelper.GetDataRowValue(dr, gridMatrix.ItemTooltipColumn), "")));
                sb.Append(tooltip);
                sb.Append("\" alt=\"");
                sb.Append(tooltip);
                sb.Append("\" onclick=\"NA()\" /></td>\n");
            }

            bool manyColumns = gridMatrix.ColumnOrderIndex.Length >= 10;

            // Add finish row
            if (!manyColumns)
            {
                sb.Append("<td colspan=\"" + (gridMatrix.ColumnsCount - rows.Count + 1) + "\"></td>");
            }
        }
        return(sb.ToString());
    }
コード例 #39
0
    /// <summary>
    /// Retrieves the specified resources and wraps them in an data container.
    /// </summary>
    /// <param name="settings">CSS settings</param>
    /// <param name="name">Resource name</param>
    /// <param name="cached">If true, the result will be cached</param>
    /// <returns>The data container with the resulting stylesheet data</returns>
    private static CMSOutputResource GetResource(CMSCssSettings settings, string name, bool cached)
    {
        List <CMSOutputResource> resources = new List <CMSOutputResource>();

        // Add files
        if (settings.Files != null)
        {
            foreach (string item in settings.Files)
            {
                // Get the resource
                CMSOutputResource resource = GetFile(item, CSS_FILE_EXTENSION);
                resources.Add(resource);
            }
        }

        // Add stylesheets
        if (settings.Stylesheets != null)
        {
            foreach (string item in settings.Stylesheets)
            {
                // Get the resource
                CMSOutputResource resource = GetStylesheet(item);
                resources.Add(resource);
            }
        }

        // Add web part containers
        if (settings.Containers != null)
        {
            foreach (string item in settings.Containers)
            {
                // Get the resource
                CMSOutputResource resource = GetContainer(item);
                resources.Add(resource);
            }
        }

        // Add web parts
        if (settings.WebParts != null)
        {
            foreach (string item in settings.WebParts)
            {
                // Get the resource
                CMSOutputResource resource = GetWebPart(item);
                resources.Add(resource);
            }
        }

        // Add templates
        if (settings.Templates != null)
        {
            foreach (string item in settings.Templates)
            {
                // Get the resource
                CMSOutputResource resource = GetTemplate(item);
                resources.Add(resource);
            }
        }

        // Add layouts
        if (settings.Layouts != null)
        {
            foreach (string item in settings.Layouts)
            {
                // Get the resource
                CMSOutputResource resource = GetLayout(item);
                resources.Add(resource);
            }
        }

        // Add transformation containers
        if (settings.Transformations != null)
        {
            foreach (string item in settings.Transformations)
            {
                // Get the resource
                CMSOutputResource resource = GetTransformation(item);
                resources.Add(resource);
            }
        }

        // Add web part layouts
        if (settings.WebPartLayouts != null)
        {
            foreach (string item in settings.WebPartLayouts)
            {
                // Get the resource
                CMSOutputResource resource = GetWebPartLayout(item);
                resources.Add(resource);
            }
        }

        // Combine to a single output
        CMSOutputResource result = CombineResources(resources);

        // Resolve the macros
        if (CSSHelper.ResolveMacrosInCSS)
        {
            MacroContext context = new MacroContext()
            {
                TrackCacheDependencies = cached
            };

            if (cached)
            {
                // Add the default dependencies
                context.AddCacheDependencies(settings.GetCacheDependencies());
                context.AddFileCacheDependencies(settings.GetFileCacheDependencies());
            }

            result.Data = CMSContext.ResolveMacros(result.Data, context);

            if (cached)
            {
                // Add cache dependency
                result.CacheDependency = CacheHelper.GetCacheDependency(context.FileCacheDependencies, context.CacheDependencies);
            }
        }
        else if (cached)
        {
            // Only the cache dependency from settings
            result.CacheDependency = settings.GetCacheDependency();
        }

        // Minify
        MinifyResource(result, mCssMinifier, CSSHelper.StylesheetMinificationEnabled && settings.EnableMinification, settings.EnableMinification);

        return(result);
    }
コード例 #40
0
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        // Do not process control by default
        StopProcessing = true;

        // Keep frequent objects
        cui = CMSContext.CurrentUser;
        PageInfo pi = CMSContext.CurrentPageInfo;

        if (pi == null)
        {
            IsPageNotFound = true;
            pi             = OnSiteEditHelper.PageInfoForPageNotFound;
        }

        ucUIToolbar.StopProcessing = true;
        largeCMSDeskButton         = !cui.UserSiteManagerAdmin;

        // Check whether user is authorized to edit page
        if ((pi != null) && cui.IsAuthenticated() && cui.IsEditor && ((IsPageNotFound && pi.NodeID == 0) || cui.IsAuthorizedPerTreeNode(pi.NodeID, NodePermissionsEnum.Read) == AuthorizationResultEnum.Allowed))
        {
            // Enable processing
            StopProcessing = false;

            // Check whether the preferred culture is RTL
            isRTL = CultureHelper.IsUICultureRTL();

            // Add link to CSS file
            CSSHelper.RegisterCSSLink(Page, "Design", "OnSiteEdit.css");

            // Filter UI element buttons
            ucUIToolbar.OnButtonFiltered += ucUIToolbar_OnButtonFiltered;
            ucUIToolbar.OnButtonCreated  += ucUIToolbar_OnButtonCreated;
            ucUIToolbar.OnButtonCreating += ucUIToolbar_OnButtonCreating;
            ucUIToolbar.OnGroupsCreated  += ucUIToolbar_OnGroupsCreated;
            ucUIToolbar.IsRTL             = isRTL;

            // Register edit script file
            RegisterEditScripts(pi);

            if (ViewMode == ViewModeEnum.EditLive)
            {
                popupHandler.Visible           = true;
                IsLiveSite                     = false;
                MessagesPlaceHolder.IsLiveSite = false;
                MessagesPlaceHolder.Opacity    = 100;

                // Display warning in the Safe mode
                if (PortalHelper.SafeMode)
                {
                    string safeModeText        = GetString("onsiteedit.safemode") + "<br/><a href=\"" + URLHelper.RawUrl.Replace("safemode=1", "safemode=0") + "\">" + GetString("general.close") + "</a> " + GetString("contentedit.safemode2");
                    string safeModeDescription = GetString("onsiteedit.safemode") + "<br/>" + GetString("general.seeeventlog");

                    // Display the warning message
                    ShowWarning(safeModeText, safeModeDescription, "");
                }

                ucUIToolbar.StopProcessing = false;

                // Ensure document redirection
                if (!String.IsNullOrEmpty(pi.DocumentMenuRedirectUrl))
                {
                    string redirectUrl = CMSContext.ResolveMacros(pi.DocumentMenuRedirectUrl);
                    redirectUrl = URLHelper.ResolveUrl(redirectUrl);
                    ShowInformation(GetString("onsiteedit.redirectinfo") + " <a href=\"" + redirectUrl + "\">" + redirectUrl + "</a>");
                }
            }
            // Mode menu on live site
            else if (ViewMode == ViewModeEnum.LiveSite)
            {
                // Hide the edit panel, show only slider button
                pnlToolbarSpace.Visible = false;
                pnlToolbar.Visible      = false;
                pnlSlider.Visible       = true;

                imgSliderButton.ImageUrl      = GetImageUrl("CMSModules/CMS_PortalEngine/OnSiteEdit/edit.png");
                imgSliderButton.ToolTip       = GetString("onsiteedit.editmode");
                imgSliderButton.AlternateText = GetString("onsitedit.editmode");

                pnlButton.Attributes.Add("onclick", "OnSiteEdit_ChangeEditMode();");

                imgMaximize.Style.Add("display", "none");
                imgMaximize.AlternateText = GetString("general.maximize");
                imgMaximize.ImageUrl      = GetImageUrl("CMSModules/CMS_PortalEngine/OnSiteEdit/ArrowDown.png");
                imgMinimize.ImageUrl      = GetImageUrl("CMSModules/CMS_PortalEngine/OnSiteEdit/ArrowUp.png");
                imgMinimize.AlternateText = GetString("general.minimize");
                pnlMinimize.Attributes.Add("onclick", "OESlideSideToolbar();");

                // Hide the OnSite edit button when displayed in CMSDesk
                pnlSlider.Style.Add("display", "none");
            }
        }
        // Hide control actions for unauthorized users
        else
        {
            plcEdit.Visible = false;
        }
    }
コード例 #41
0
    /// <summary>
    /// UniGrid external data bound.
    /// </summary>
    protected object GridDocsOnExternalDataBound(object sender, string sourceName, object parameter)
    {
        string      attName       = null;
        string      attachmentExt = null;
        DataRowView drv           = null;

        switch (sourceName.ToLower())
        {
        case "update":
            drv = parameter as DataRowView;
            PlaceHolder plcUpd = new PlaceHolder();
            plcUpd.ID = "plcUdateAction";
            Panel pnlBlock = new Panel();
            pnlBlock.ID = "pnlBlock";

            plcUpd.Controls.Add(pnlBlock);

            // Add disabled image
            ImageButton imgUpdate = new ImageButton();
            imgUpdate.ID         = "imgUpdate";
            imgUpdate.PreRender += imgUpdate_PreRender;
            pnlBlock.Controls.Add(imgUpdate);

            // Add update control
            // Dynamically load uploader control
            DirectFileUploader dfuElem = Page.LoadControl("~/CMSModules/Content/Controls/Attachments/DirectFileUploader/DirectFileUploader.ascx") as DirectFileUploader;

            // Set uploader's properties
            if (dfuElem != null)
            {
                dfuElem.ID            = "dfuElem" + DocumentID;
                dfuElem.SourceType    = MediaSourceEnum.Attachment;
                dfuElem.DisplayInline = true;
                if (!createTempAttachment)
                {
                    dfuElem.AttachmentGUID = ValidationHelper.GetGuid(drv["AttachmentGUID"], Guid.Empty);
                }

                dfuElem.ForceLoad = true;
                dfuElem.FormGUID  = FormGUID;
                dfuElem.AttachmentGUIDColumnName = GUIDColumnName;
                dfuElem.DocumentID          = DocumentID;
                dfuElem.NodeParentNodeID    = NodeParentNodeID;
                dfuElem.NodeClassName       = NodeClassName;
                dfuElem.ResizeToWidth       = ResizeToWidth;
                dfuElem.ResizeToHeight      = ResizeToHeight;
                dfuElem.ResizeToMaxSideSize = ResizeToMaxSideSize;
                dfuElem.AllowedExtensions   = AllowedExtensions;
                dfuElem.ImageUrl            = ResolveUrl(GetImageUrl("Design/Controls/DirectUploader/upload.png"));
                dfuElem.ImageHeight         = 16;
                dfuElem.ImageWidth          = 16;
                dfuElem.InsertMode          = false;
                dfuElem.ParentElemID        = ClientID;
                dfuElem.IncludeNewItemInfo  = true;
                dfuElem.CheckPermissions    = CheckPermissions;
                dfuElem.NodeSiteName        = SiteName;
                dfuElem.IsLiveSite          = this.IsLiveSite;
                // Setting of the direct single mode
                dfuElem.UploadMode        = MultifileUploaderModeEnum.DirectSingle;
                dfuElem.Width             = 16;
                dfuElem.Height            = 16;
                dfuElem.MaxNumberToUpload = 1;

                dfuElem.PreRender += dfuElem_PreRender;
                pnlBlock.Controls.Add(dfuElem);
            }

            attName       = ValidationHelper.GetString(drv["AttachmentName"], string.Empty);
            attachmentExt = ValidationHelper.GetString(drv["AttachmentExtension"], string.Empty);

            int  nodeGroupId       = (Node != null) ? Node.GetIntegerValue("NodeGroupID") : 0;
            bool displayGroupAdmin = true;

            // Check group admin for live site
            if (IsLiveSite && (nodeGroupId > 0))
            {
                displayGroupAdmin = CMSContext.CurrentUser.IsGroupAdministrator(nodeGroupId);
            }

            // Check if WebDAV allowed by the form
            bool allowWebDAV = (Form == null) ? true : Form.AllowWebDAV;

            // Add WebDAV edit control
            if (allowWebDAV && CMSContext.IsWebDAVEnabled(SiteName) && RequestHelper.IsWindowsAuthentication() && (FormGUID == Guid.Empty) && WebDAVSettings.IsExtensionAllowedForEditMode(attachmentExt, SiteName) && displayGroupAdmin)
            {
                // Dynamically load control
                WebDAVEditControl webdavElem = Page.LoadControl("~/CMSModules/WebDAV/Controls/AttachmentWebDAVEditControl.ascx") as WebDAVEditControl;

                // Set editor's properties
                if (webdavElem != null)
                {
                    webdavElem.ID = "webdavElem" + DocumentID;

                    // Ensure form identification
                    if ((Form != null) && (Form.Parent != null))
                    {
                        webdavElem.FormID = Form.Parent.ClientID;
                    }
                    webdavElem.PreRender      += webdavElem_PreRender;
                    webdavElem.SiteName        = SiteName;
                    webdavElem.FileName        = attName;
                    webdavElem.NodeAliasPath   = Node.NodeAliasPath;
                    webdavElem.NodeCultureCode = Node.DocumentCulture;
                    if (FieldInfo != null)
                    {
                        webdavElem.AttachmentFieldName = FieldInfo.Name;
                    }

                    // Set Group ID for live site
                    webdavElem.GroupID    = IsLiveSite ? nodeGroupId : 0;
                    webdavElem.IsLiveSite = IsLiveSite;

                    // Align left if WebDAV is enabled and windows authentication is enabled
                    bool isRTL = (IsLiveSite && CultureHelper.IsPreferredCultureRTL()) || (!IsLiveSite && CultureHelper.IsUICultureRTL());
                    pnlBlock.Style.Add("text-align", isRTL ? "right" : "left");

                    pnlBlock.Controls.Add(webdavElem);
                }
            }

            return(plcUpd);

        case "edit":
            // Get file extension
            string extension = ValidationHelper.GetString(((DataRowView)((GridViewRow)parameter).DataItem).Row["AttachmentExtension"], string.Empty).ToLower();
            // Get attachment GUID
            attachmentGuid = ValidationHelper.GetGuid(((DataRowView)((GridViewRow)parameter).DataItem).Row["AttachmentGUID"], Guid.Empty);
            if (sender is ImageButton)
            {
                ImageButton img = (ImageButton)sender;
                if (createTempAttachment)
                {
                    img.Visible = false;
                }
                else
                {
                    img.AlternateText = extension;
                    img.ToolTip       = attachmentGuid.ToString();
                    img.PreRender    += img_PreRender;
                }
            }
            break;

        case "delete":
            if (sender is ImageButton)
            {
                ImageButton imgDelete = (ImageButton)sender;
                // Turn off validation
                imgDelete.CausesValidation = false;
                imgDelete.PreRender       += imgDelete_PreRender;
                // Explicitly initialize confirmation
                imgDelete.OnClientClick = "if(DeleteConfirmation() == false){return false;}";
            }
            break;

        case "attachmentname":
        {
            drv = parameter as DataRowView;
            // Get attachment GUID
            attachmentGuid = ValidationHelper.GetGuid(drv["AttachmentGUID"], Guid.Empty);

            // Get attachment extension
            attachmentExt = ValidationHelper.GetString(drv["AttachmentExtension"], string.Empty);
            bool   isImage = ImageHelper.IsImage(attachmentExt);
            string iconUrl = GetFileIconUrl(attachmentExt, "List");

            // Get link for attachment
            string attachmentUrl = null;
            attName = ValidationHelper.GetString(drv["AttachmentName"], string.Empty);
            int documentId = DocumentID;

            if (Node != null)
            {
                if (IsLiveSite && (documentId > 0))
                {
                    attachmentUrl = CMSContext.ResolveUIUrl(TreePathUtils.GetAttachmentUrl(attachmentGuid, URLHelper.GetSafeFileName(attName, CMSContext.CurrentSiteName), 0, null));
                }
                else
                {
                    attachmentUrl = CMSContext.ResolveUIUrl(TreePathUtils.GetAttachmentUrl(attachmentGuid, URLHelper.GetSafeFileName(attName, CMSContext.CurrentSiteName), VersionHistoryID, null));
                }
            }
            else
            {
                attachmentUrl = ResolveUrl(DocumentHelper.GetAttachmentUrl(attachmentGuid, VersionHistoryID));
            }
            attachmentUrl = URLHelper.UpdateParameterInUrl(attachmentUrl, "chset", Guid.NewGuid().ToString());

            // Ensure correct URL
            if (SiteName != CMSContext.CurrentSiteName)
            {
                attachmentUrl = URLHelper.AddParameterToUrl(attachmentUrl, "sitename", SiteName);
            }

            // Add latest version requirement for live site
            if (IsLiveSite && (documentId > 0))
            {
                // Add requirement for latest version of files for current document
                string newparams = "latestfordocid=" + documentId;
                newparams += "&hash=" + ValidationHelper.GetHashString("d" + documentId);

                attachmentUrl += "&" + newparams;
            }

            // Optionally trim attachment name
            string attachmentName = TextHelper.LimitLength(attName, ATTACHMENT_NAME_LIMIT, "...");

            // Tooltip
            string tooltip = null;
            if (ShowTooltip)
            {
                string title       = ValidationHelper.GetString(drv["AttachmentTitle"], string.Empty);;
                string description = ValidationHelper.GetString(drv["AttachmentDescription"], string.Empty);
                int    imageWidth  = ValidationHelper.GetInteger(drv["AttachmentImageWidth"], 0);
                int    imageHeight = ValidationHelper.GetInteger(drv["AttachmentImageHeight"], 0);
                tooltip = UIHelper.GetTooltipAttributes(attachmentUrl, imageWidth, imageHeight, title, attachmentName, attachmentExt, description, null, 300);
            }

            // Icon
            string imageTag = "<img class=\"Icon\" src=\"" + iconUrl + "\" alt=\"" + attachmentName + "\" />";
            if (isImage)
            {
                return("<a href=\"#\" onclick=\"javascript: window.open('" + attachmentUrl + "'); return false;\"><span " + tooltip + ">" + imageTag + attachmentName + "</span></a>");
            }
            else
            {
                return("<a href=\"" + attachmentUrl + "\"><span id=\"" + attachmentGuid + "\" " + tooltip + ">" + imageTag + attachmentName + "</span></a>");
            }
        }

        case "attachmentsize":
            long size = ValidationHelper.GetLong(parameter, 0);
            return(DataHelper.GetSizeString(size));
        }

        return(parameter);
    }
コード例 #42
0
    /// <summary>
    /// Updates the current Group or creates new if no GroupID is present.
    /// </summary>
    public void SaveData()
    {
        // Check banned ip
        if (!BannedIPInfoProvider.IsAllowed(CMSContext.CurrentSiteName, BanControlEnum.AllNonComplete))
        {
            lblError.Visible = true;
            lblError.Text    = GetString("General.BannedIP");
            return;
        }

        // Validate form entries
        string errorMessage = ValidateForm();

        if (errorMessage == "")
        {
            try
            {
                codeName = GetSafeCodeName();
                codeName = GetUniqueCodeName(codeName);

                GroupInfo group = new GroupInfo();
                group.GroupDisplayName    = this.txtDisplayName.Text;
                group.GroupName           = codeName;
                group.GroupDescription    = this.txtDescription.Text;
                group.GroupAccess         = GetGroupAccess();
                group.GroupSiteID         = this.mSiteId;
                group.GroupApproveMembers = GetGroupApproveMembers();

                // Set columns GroupCreatedByUserID and GroupApprovedByUserID to current user
                CurrentUserInfo user = CMSContext.CurrentUser;

                if (user != null)
                {
                    group.GroupCreatedByUserID = user.UserID;

                    if ((!this.RequireApproval) || (CurrentUserIsAdmin()))
                    {
                        group.GroupApprovedByUserID = user.UserID;
                        group.GroupApproved         = true;
                    }
                }

                // Save Group in the database
                GroupInfoProvider.SetGroupInfo(group);

                // Create group admin role
                RoleInfo roleInfo = new RoleInfo();
                roleInfo.DisplayName = "Group admin";
                roleInfo.RoleName    = group.GroupName + "_groupadmin";
                roleInfo.RoleGroupID = group.GroupID;
                roleInfo.RoleIsGroupAdministrator = true;
                roleInfo.SiteID = this.mSiteId;
                // Save group admin role
                RoleInfoProvider.SetRoleInfo(roleInfo);

                if (user != null)
                {
                    // Set user as member of group
                    GroupMemberInfo gmi = new GroupMemberInfo();
                    gmi.MemberUserID           = user.UserID;
                    gmi.MemberGroupID          = group.GroupID;
                    gmi.MemberJoined           = DateTime.Now;
                    gmi.MemberStatus           = GroupMemberStatus.Approved;
                    gmi.MemberApprovedWhen     = DateTime.Now;
                    gmi.MemberApprovedByUserID = user.UserID;

                    // Save user as member of group
                    GroupMemberInfoProvider.SetGroupMemberInfo(gmi);

                    // Set user as member of admin group role
                    UserRoleInfo userRole = new UserRoleInfo();
                    userRole.UserID = user.UserID;
                    userRole.RoleID = roleInfo.RoleID;

                    // Save user as member of admin group role
                    UserRoleInfoProvider.SetUserRoleInfo(userRole);
                }

                // Clear user session a request
                CMSContext.CurrentUser.Invalidate();
                CMSContext.CurrentUser = null;

                string culture = CultureHelper.EnglishCulture.ToString();
                if (CMSContext.CurrentDocument != null)
                {
                    culture = CMSContext.CurrentDocument.DocumentCulture;
                }

                // Copy document
                errorMessage = GroupInfoProvider.CopyGroupDocument(group, CMSContext.ResolveCurrentPath(GroupTemplateSourceAliasPath), CMSContext.ResolveCurrentPath(GroupTemplateTargetAliasPath), GroupProfileURLPath, culture, this.CombineWithDefaultCulture, CMSContext.CurrentUser, roleInfo);

                if (errorMessage != "")
                {
                    // Display error message
                    this.lblError.Text    = errorMessage;
                    this.lblError.Visible = true;
                    return;
                }

                // Create group forum
                if (CreateForum)
                {
                    CreateGroupForum(group);

                    // Create group forum search index
                    if (CreateSearchIndexes)
                    {
                        CreateGroupForumSearchIndex(group);
                    }
                }

                // Create group media library
                if (CreateMediaLibrary)
                {
                    CreateGroupMediaLibrary(group);
                }

                // Create search index for group documents
                if (CreateSearchIndexes)
                {
                    CreateGroupContentSearchIndex(group);
                }

                // Display information on success
                this.lblInfo.Text    = GetString("group.group.createdinfo");
                this.lblInfo.Visible = true;

                // If URL is set, redirect user to specified page
                if (!String.IsNullOrEmpty(this.RedirectToURL))
                {
                    URLHelper.Redirect(ResolveUrl(CMSContext.GetUrl(this.RedirectToURL)));
                }

                // After registration message
                if ((this.RequireApproval) && (!CurrentUserIsAdmin()))
                {
                    this.lblInfo.Text = this.SuccessfullRegistrationWaitingForApprovalText;

                    // Send approval email to admin
                    if (!String.IsNullOrEmpty(SendWaitingForApprovalEmailTo))
                    {
                        // Create the message
                        EmailTemplateInfo eti = EmailTemplateProvider.GetEmailTemplate("Groups.WaitingForApproval", CMSContext.CurrentSiteName);
                        if (eti != null)
                        {
                            EmailMessage message = new EmailMessage();
                            if (String.IsNullOrEmpty(eti.TemplateFrom))
                            {
                                message.From = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSSendEmailNotificationsFrom");
                            }
                            else
                            {
                                message.From = eti.TemplateFrom;
                            }

                            MacroResolver resolver = CMSContext.CurrentResolver;
                            resolver.SourceData = new object[] { group };
                            resolver.SetNamedSourceData("Group", group);

                            message.Recipients = SendWaitingForApprovalEmailTo;
                            message.Subject    = resolver.ResolveMacros(eti.TemplateSubject);
                            message.Body       = resolver.ResolveMacros(eti.TemplateText);

                            resolver.EncodeResolvedValues = false;
                            message.PlainTextBody         = resolver.ResolveMacros(eti.TemplatePlainText);

                            // Send the message using email engine
                            EmailSender.SendEmail(message);
                        }
                    }
                }
                else
                {
                    string groupPath = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSGroupProfilePath");
                    string url       = String.Empty;

                    if (!String.IsNullOrEmpty(groupPath))
                    {
                        url = TreePathUtils.GetUrl(groupPath.Replace("{GroupName}", group.GroupName));
                    }
                    this.lblInfo.Text = String.Format(this.SuccessfullRegistrationText, url);
                }

                // Hide form
                if (this.HideFormAfterRegistration)
                {
                    this.plcForm.Visible = false;
                }
                else
                {
                    ClearForm();
                }
            }
            catch (Exception ex)
            {
                // Display error message
                this.lblError.Text    = GetString("general.erroroccurred") + ex.Message;
                this.lblError.Visible = true;
            }
        }
        else
        {
            // Display error message
            this.lblError.Text    = errorMessage;
            this.lblError.Visible = true;
        }
    }
コード例 #43
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            calItems.StopProcessing = true;
        }
        else
        {
            calItems.ControlContext = repEvent.ControlContext = ControlContext;

            // Calendar properties
            calItems.CacheItemName = CacheItemName;

            calItems.CacheDependencies         = CacheDependencies;
            calItems.CacheMinutes              = CacheMinutes;
            calItems.CheckPermissions          = CheckPermissions;
            calItems.ClassNames                = ClassNames;
            calItems.CombineWithDefaultCulture = CombineWithDefaultCulture;

            calItems.CultureCode         = CultureCode;
            calItems.MaxRelativeLevel    = MaxRelativeLevel;
            calItems.OrderBy             = OrderBy;
            calItems.WhereCondition      = WhereCondition;
            calItems.Columns             = Columns;
            calItems.Path                = Path;
            calItems.SelectOnlyPublished = SelectOnlyPublished;
            calItems.SiteName            = SiteName;
            calItems.FilterName          = FilterName;

            calItems.RelationshipName           = RelationshipName;
            calItems.RelationshipWithNodeGuid   = RelationshipWithNodeGuid;
            calItems.RelatedNodeIsOnTheLeftSide = RelatedNodeIsOnTheLeftSide;

            calItems.TransformationName        = TransformationName;
            calItems.NoEventTransformationName = NoEventTransformationName;

            calItems.DayField             = DayField;
            calItems.EventEndField        = EventEndField;
            calItems.HideDefaultDayNumber = HideDefaultDayNumber;

            calItems.TodaysDate = CMSContext.ConvertDateTime(DateTime.Now, this);

            bool detail = false;

            // If calendar event path is defined event is loaded in accordance to the selected path
            string eventPath = QueryHelper.GetString("CalendarEventPath", null);
            if (!String.IsNullOrEmpty(eventPath))
            {
                detail        = true;
                repEvent.Path = eventPath;

                // Set selected date to specific document
                TreeNode node = TreeHelper.GetDocument(SiteName, eventPath, CultureCode, CombineWithDefaultCulture, ClassNames, SelectOnlyPublished, CheckPermissions, CMSContext.CurrentUser);
                if (node != null)
                {
                    object value = node.GetValue(DayField);
                    if (ValidationHelper.GetDateTime(value, DataHelper.DATETIME_NOT_SELECTED) != DataHelper.DATETIME_NOT_SELECTED)
                    {
                        calItems.TodaysDate = CMSContext.ConvertDateTime((DateTime)value, this);
                    }
                }
            }

            // By default select current event from current document value
            PageInfo currentPage = CMSContext.CurrentPageInfo;
            if ((currentPage != null) && (ClassNames.ToLower().Contains(currentPage.ClassName.ToLower())))
            {
                detail        = true;
                repEvent.Path = currentPage.NodeAliasPath;

                // Set selected date to current document
                object value = CMSContext.CurrentDocument.GetValue(DayField);
                if (ValidationHelper.GetDateTime(value, DataHelper.DATETIME_NOT_SELECTED) != DataHelper.DATETIME_NOT_SELECTED)
                {
                    calItems.TodaysDate = CMSContext.ConvertDateTime((DateTime)value, this);
                    // Get name of coupled class ID column
                    string idColumn = CMSContext.CurrentDocument.CoupledClassIDColumn;
                    if (!string.IsNullOrEmpty(idColumn))
                    {
                        // Set selected item ID and the ID column name so it is possible to highlight specific event in the calendar
                        calItems.SelectedItemIDColumn = idColumn;
                        calItems.SelectedItemID       = ValidationHelper.GetInteger(CMSContext.CurrentDocument.GetValue(idColumn), 0);
                    }
                }
            }

            if (detail)
            {
                // Setup the detail repeater
                repEvent.Visible        = true;
                repEvent.StopProcessing = false;

                repEvent.SelectedItemTransformationName = EventDetailTransformation;
                repEvent.ClassNames = ClassNames;
                repEvent.Columns    = Columns;

                if (!String.IsNullOrEmpty(CacheItemName))
                {
                    repEvent.CacheItemName = CacheItemName + "|detail";
                }

                repEvent.CacheDependencies         = CacheDependencies;
                repEvent.CacheMinutes              = CacheMinutes;
                repEvent.CheckPermissions          = CheckPermissions;
                repEvent.CombineWithDefaultCulture = CombineWithDefaultCulture;

                repEvent.CultureCode = CultureCode;

                repEvent.SelectOnlyPublished = SelectOnlyPublished;
                repEvent.SiteName            = SiteName;

                repEvent.WhereCondition = WhereCondition;
            }
        }
    }
コード例 #44
0
    /// <summary>
    /// Creates group forum.
    /// </summary>
    /// <param name="group">Particular group info object</param>
    private void CreateGroupForum(GroupInfo group)
    {
        #region "Create forum group"

        // Get forum group code name
        string forumGroupCodeName = "Forums_group_" + group.GroupGUID;

        // Check if forum group with given name already exists
        if (ForumGroupInfoProvider.GetForumGroupInfo(forumGroupCodeName, CMSContext.CurrentSiteID) != null)
        {
            return;
        }

        // Create forum base URL
        string   baseUrl       = null;
        TreeNode groupDocument = TreeProvider.SelectSingleNode(group.GroupNodeGUID, CMSContext.CurrentDocumentCulture.CultureCode, CMSContext.CurrentSiteName);
        if (groupDocument != null)
        {
            baseUrl = CMSContext.GetUrl(groupDocument.NodeAliasPath + "/" + FORUM_DOCUMENT_ALIAS);
        }

        ForumGroupInfo forumGroupObj = new ForumGroupInfo();
        string         suffix        = " forums";
        forumGroupObj.GroupDisplayName = TextHelper.LimitLength(group.GroupDisplayName, 200 - suffix.Length, "") + suffix;
        forumGroupObj.GroupName        = forumGroupCodeName;
        forumGroupObj.GroupOrder       = 0;
        forumGroupObj.GroupEnableQuote = true;
        forumGroupObj.GroupGroupID     = group.GroupID;
        forumGroupObj.GroupSiteID      = CMSContext.CurrentSiteID;
        forumGroupObj.GroupBaseUrl     = baseUrl;

        // Additional settings
        forumGroupObj.GroupEnableCodeSnippet   = true;
        forumGroupObj.GroupEnableFontBold      = true;
        forumGroupObj.GroupEnableFontColor     = true;
        forumGroupObj.GroupEnableFontItalics   = true;
        forumGroupObj.GroupEnableFontStrike    = true;
        forumGroupObj.GroupEnableFontUnderline = true;
        forumGroupObj.GroupEnableQuote         = true;
        forumGroupObj.GroupEnableURL           = true;
        forumGroupObj.GroupEnableImage         = true;

        // Set forum group info
        ForumGroupInfoProvider.SetForumGroupInfo(forumGroupObj);

        #endregion

        #region "Create forum"

        string codeName = "General_discussion_group_" + group.GroupGUID;

        // Check if forum with given name already exists
        if (ForumInfoProvider.GetForumInfo(codeName, CMSContext.CurrentSiteID, group.GroupID) != null)
        {
            return;
        }

        // Create new forum object
        ForumInfo forumObj = new ForumInfo();
        forumObj.ForumSiteID          = CMSContext.CurrentSiteID;
        forumObj.ForumIsLocked        = false;
        forumObj.ForumOpen            = true;
        forumObj.ForumDisplayEmails   = false;
        forumObj.ForumRequireEmail    = false;
        forumObj.ForumDisplayName     = "General discussion";
        forumObj.ForumName            = codeName;
        forumObj.ForumGroupID         = forumGroupObj.GroupID;
        forumObj.ForumModerated       = false;
        forumObj.ForumAccess          = 40000;
        forumObj.ForumPosts           = 0;
        forumObj.ForumThreads         = 0;
        forumObj.ForumPostsAbsolute   = 0;
        forumObj.ForumThreadsAbsolute = 0;
        forumObj.ForumOrder           = 0;
        forumObj.ForumUseCAPTCHA      = false;
        forumObj.SetValue("ForumHTMLEditor", null);

        // Set security
        forumObj.AllowAccess       = SecurityAccessEnum.GroupMembers;
        forumObj.AllowAttachFiles  = SecurityAccessEnum.GroupMembers;
        forumObj.AllowMarkAsAnswer = SecurityAccessEnum.GroupMembers;
        forumObj.AllowPost         = SecurityAccessEnum.GroupMembers;
        forumObj.AllowReply        = SecurityAccessEnum.GroupMembers;
        forumObj.AllowSubscribe    = SecurityAccessEnum.GroupMembers;

        if (ForumInfoProvider.LicenseVersionCheck(URLHelper.GetCurrentDomain(), FeatureEnum.Forums, VersionActionEnum.Insert))
        {
            ForumInfoProvider.SetForumInfo(forumObj);
        }

        #endregion
    }
コード例 #45
0
 public UserRepository(CMSContext context)
 {
     this.context = context;
 }
コード例 #46
0
    /// <summary>
    /// Logged in handler.
    /// </summary>
    void loginElem_LoggedIn(object sender, EventArgs e)
    {
        // Set view mode to live site after login to prevent bar with "Close preview mode"
        CMSContext.ViewMode = CMS.PortalEngine.ViewModeEnum.LiveSite;

        // Ensure response cookie
        CookieHelper.EnsureResponseCookie(FormsAuthentication.FormsCookieName);

        // Set cookie expiration
        if (loginElem.RememberMeSet)
        {
            CookieHelper.ChangeCookieExpiration(FormsAuthentication.FormsCookieName, DateTime.Now.AddYears(1), false);
        }
        else
        {
            // Extend the expiration of the authentication cookie if required
            if (!UserInfoProvider.UseSessionCookies && (HttpContext.Current != null) && (HttpContext.Current.Session != null))
            {
                CookieHelper.ChangeCookieExpiration(FormsAuthentication.FormsCookieName, DateTime.Now.AddMinutes(Session.Timeout), false);
            }
        }

        // Current username
        string userName = loginElem.UserName;

        // Get user name (test site prefix too)
        UserInfo ui = UserInfoProvider.GetUserInfoForSitePrefix(userName, CMSContext.CurrentSite);

        // Check whether safe user name is required and if so get safe username
        if (RequestHelper.IsMixedAuthentication() && UserInfoProvider.UseSafeUserName)
        {
            // User stored with safe name
            userName = ValidationHelper.GetSafeUserName(this.loginElem.UserName, CMSContext.CurrentSiteName);

            // Find user by safe name
            ui = UserInfoProvider.GetUserInfoForSitePrefix(userName, CMSContext.CurrentSite);
            if (ui != null)
            {
                // Authenticate user by site or global safe username
                CMSContext.AuthenticateUser(ui.UserName, this.loginElem.RememberMeSet);
            }
        }

        // Log activity (warning: CMSContext contains info of previous user)
        if (ui != null)
        {
            // If user name is site prefixed, authenticate user manually
            if (UserInfoProvider.IsSitePrefixedUser(ui.UserName))
            {
                CMSContext.AuthenticateUser(ui.UserName, this.loginElem.RememberMeSet);
            }

            // Log activity
            string siteName = CMSContext.CurrentSiteName;
            if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) && ActivitySettingsHelper.UserLoginEnabled(siteName))
            {
                int contactId = ModuleCommands.OnlineMarketingGetUserLoginContactID(ui);
                ActivityLogHelper.UpdateContactLastLogon(contactId);
                if (ActivitySettingsHelper.ActivitiesEnabledForThisUser(ui))
                {
                    TreeNode currentDoc = CMSContext.CurrentDocument;
                    ActivityLogProvider.LogLoginActivity(contactId, ui, URLHelper.CurrentRelativePath,
                                                         (currentDoc != null ? currentDoc.NodeID : 0), CMSContext.CurrentSiteName, CMSContext.Campaign, (currentDoc != null ? currentDoc.DocumentCulture : null));
                }
            }
        }

        // Redirect user to the return url, or if is not defined redirect to the default target url
        string url = QueryHelper.GetString("ReturnURL", string.Empty);

        if (!string.IsNullOrEmpty(url))
        {
            if (url.StartsWith("~") || url.StartsWith("/") || QueryHelper.ValidateHash("hash"))
            {
                URLHelper.Redirect(ResolveUrl(ValidationHelper.GetString(Request.QueryString["ReturnURL"], "")));
            }
            else
            {
                URLHelper.Redirect(ResolveUrl("~/CMSMessages/Error.aspx?title=" + ResHelper.GetString("general.badhashtitle") + "&text=" + ResHelper.GetString("general.badhashtext")));
            }
        }
        else
        {
            if (DefaultTargetUrl != "")
            {
                URLHelper.Redirect(ResolveUrl(DefaultTargetUrl));
            }
            else
            {
                URLHelper.Redirect(URLRewriter.CurrentURL);
            }
        }
    }
        public async Task <CandidateTestsContainerDto> GetCandidateTestsForCandidate(UserInfo userInfo)
        {
            if (userInfo.IsCandidateLogin)
            {
                throw new Exception("You do not have access to perform this action!");
            }

            using (var db = new CMSContext())
            {
                var candidate = await(from cnd in db.Candidates
                                      join usr in db.Users on cnd.UserId equals usr.Id
                                      join cmp in db.Companies on cnd.CompanyId equals cmp.Id
                                      join jo in db.JobOpenings on cnd.JobOpeningId equals jo.Id
                                      join lc in db.Users on cnd.CreatedBy equals lc.Id
                                      where
                                      cnd.Id == CandidateId &&
                                      cnd.CompanyId == userInfo.CompanyId
                                      select new GetCandidateDto
                {
                    CandidateId = cnd.Id,
                    User        = new UserSimpleDto
                    {
                        UserId    = usr.Id,
                        FullName  = usr.FullName,
                        ShortName = usr.ShortName,
                        Email     = usr.Email
                    },
                    Company = new CompanySimpleDto
                    {
                        Id   = cmp.Id,
                        Name = cmp.Name
                    },
                    JobOpening = new JobOpeningSimpleDto
                    {
                        Id          = jo.Id,
                        Title       = jo.Title,
                        Description = jo.Description,
                    },
                    CreatedDetails = new CreatedOnDto
                    {
                        UserId    = lc.Id,
                        FullName  = lc.FullName,
                        ShortName = lc.ShortName,
                        CreatedOn = cnd.CreatedOn
                    }
                }).SingleOrDefaultAsync();

                if (candidate == null)
                {
                    throw new Exception("Candidate not found!");
                }

                var candidateTests = (await(from cdt in db.CandidateTests
                                            join cd in db.Candidates on cdt.CandidateId equals cd.Id
                                            join tst in db.Tests on cdt.TestId equals tst.Id
                                            join cdts in db.CandidateTestScores on cdt.Id equals cdts.CandidateTestId
                                            join tsts in db.TestScores on cdts.TestScoreId equals tsts.Id
                                            where
                                            cdt.CandidateId == CandidateId &&
                                            cd.CompanyId == userInfo.CompanyId
                                            select new
                {
                    CandidateId = cdt.CandidateId,
                    TestTitle = tst.Title,

                    TestScoreId = tsts.Id,
                    TestScoreTitle = tsts.Title,
                    TestScoreIsMandatory = tsts.IsMandatory,
                    TestScoreMaximumScore = tsts.MaximumScore,
                    TestScoreCutoffScore = tsts.CutoffScore,

                    CandidateTestScoreId = cdts.Id,
                    CandidateTestScoreValue = cdts.Value,
                    CandidateTestScoreComment = cdts.Comment
                }).ToListAsync())
                                     .GroupBy(t => new { t.CandidateId, t.TestTitle })
                                     .Select(t => new CandidateTestDto
                {
                    Title = t.Key.TestTitle,

                    CandidateTestScores = t.Select(ts => new CandidateTestScoreDto
                    {
                        CandidateTestScoreId = ts.CandidateTestScoreId,
                        TestScoreId          = ts.TestScoreId,
                        Title       = ts.TestScoreTitle,
                        IsMandatory = ts.TestScoreIsMandatory,

                        Value        = ts.CandidateTestScoreValue,
                        MaximumScore = ts.TestScoreMaximumScore,
                        CutoffScore  = ts.TestScoreCutoffScore,
                        Comment      = ts.CandidateTestScoreComment
                    }).OrderBy(ts => ts.Title).ToList()
                }).ToList();

                var sortedTotalScores = candidateTests.Select(cdsts => (double?)cdsts.CandidateTestScores.Select(cdts => cdts.Value)?.Sum() ?? 0d).ToList();
                sortedTotalScores.Sort();

                foreach (var candidateTest in candidateTests)
                {
                    candidateTest.TotalScore = candidateTest.CandidateTestScores.Select(ts => ts.Value)?.Sum() ?? 0;
                    candidateTest.Percentile = (decimal)sortedTotalScores.GetPercentile((double)candidateTest.TotalScore);
                }

                return(new CandidateTestsContainerDto
                {
                    Candidate = candidate,
                    CandidateTests = candidateTests
                });
            }
        }
コード例 #48
0
ファイル: CMSCommonDAO.cs プロジェクト: tmac2236/MMS
 public CMSCommonDAO(CMSContext context)
 {
     _context = context;
 }
コード例 #49
0
ファイル: ModuleRepository.cs プロジェクト: eternalwt/CMS
 public PagedList<ModuleDetail> GetModules(string moduleName,
                                     int? moduleTypeID,
                                     int? positionID,
                                     int? accessLevelID,
                                     bool? isPublish,
                                     int pageIndex,
                                     int pageSize,
                                     string sortName,
                                     string sortOrder)
 {
     using (CMSContext context = new CMSContext())
     {
         IQueryable<Module> query = context.Modules;
         if (string.IsNullOrEmpty(moduleName) == false)
         {
             query = query.Where(m => m.ModuleName.StartsWith(moduleName));
         }
         if ((moduleTypeID ?? 0) > 0)
         {
             query = query.Where(m => m.ModuleTypeID == moduleTypeID);
         }
         if ((positionID ?? 0) > 0)
         {
             query = query.Where(m => m.PositionID == positionID);
         }
         if ((accessLevelID ?? 0) > 0)
         {
             query = query.Where(m => m.AccessLevelID == accessLevelID);
         }
         if (isPublish == true)
         {
             query = query.Where(m => m.IsPublish == isPublish);
         }
         query = query.OrderBy(sortName, (sortOrder == "asc"));
         IQueryable<ModuleDetail> modules = (from module in query
                                             select new ModuleDetail
                                             {
                                                 ModuleID = module.ModuleID,
                                                 ModuleName = module.ModuleName,
                                                 IsPublish = module.IsPublish,
                                                 SortOrder = module.SortOrder,
                                                 AccessLevelName = module.AccessLevel.AccessLevelName,
                                                 ModuleTypeName = module.ModuleType.ModuleTypeName,
                                                 PositionName = module.Position.PositionName
                                             });
         return new PagedList<ModuleDetail>(modules, pageIndex, pageSize);
     }
 }
コード例 #50
0
 public RouteRepository(CMSContext context)
 {
     this.context = context;
 }