Live Support, Chat, Upload Control and Rich Text Editor
Welcome to Support forums Sign in | Join | Help |Client Center
in Search

NukeChat7 supports DNN& c# code?

Last post 12-11-2015, 11:16 AM by Kenneth. 1 replies.
Sort Posts: Previous Next
  •  12-11-2015, 1:45 AM 81979

    NukeChat7 supports DNN& c# code?

    Hi ,

    We triedtrail version of NukeChat 7 on DNN7 ,but while deploying we need deploy  DNNChatProvider.vb file in app_code folder.

    As our code base is C# it throws error.

    Please let us know is there any way to fix this or any other module

     

    Thanks,

    Shrutika 

  •  12-11-2015, 11:16 AM 81984 in reply to 81979

    Re: NukeChat7 supports DNN& c# code?

    Hi,

     

    you can create a new c# file name "DNNChatProvider.cs" in the App_Code folder and use the code below.

     

    1. using System;  
    2. using System.IO;  
    3. using System.Security;  
    4. using System.Security.Principal;  
    5. using System.Threading;  
    6. using System.Web;  
    7. using System.Web.Security;  
    8. using System.Collections;  
    9.   
    10. using DotNetNuke.Common.Utilities;  
    11. using DotNetNuke.Entities.Portals;  
    12. using DotNetNuke.Security.Roles;  
    13. using DotNetNuke.Services.Exceptions;  
    14. using DotNetNuke.Services.Log.EventLog;  
    15. using DotNetNuke.Services.Scheduling;  
    16. using DotNetNuke.Services.Upgrade;  
    17.   
    18.   
    19. /// <summary>  
    20. /// Summary description for DNNChatProvider  
    21. /// </summary>  
    22. public class DNNChatProvider : CuteChat.ChatProvider  
    23. {  
    24.     protected DotNetNuke.Entities.Portals.PortalSettings CurrentPortal()  
    25.     {  
    26.   
    27.         DotNetNuke.Entities.Portals.PortalSettings ps = default(DotNetNuke.Entities.Portals.PortalSettings);  
    28.   
    29.         ps = PortalController.GetCurrentPortalSettings();  
    30.   
    31.   
    32.         if (ps == null)  
    33.         {  
    34.             throw (new System.Exception("PortalSettings Not Ready"));  
    35.   
    36.         }  
    37.   
    38.         return ps;  
    39.   
    40.     }  
    41.     public DotNetNuke.Entities.Users.UserInfo GetLogonUser()  
    42.     {  
    43.   
    44.   
    45.         if (!HttpContext.Current.Request.IsAuthenticated)  
    46.         {  
    47.             return null;  
    48.   
    49.         }  
    50.   
    51.         string username = HttpContext.Current.User.Identity.Name;  
    52.   
    53.         return DotNetNuke.Entities.Users.UserController.GetUserByName(CurrentPortal().PortalId, username);  
    54.   
    55.     }  
    56.     public override string GetConnectionString()  
    57.     {  
    58.   
    59.         return System.Configuration.ConfigurationManager.ConnectionStrings["SiteSqlServer"].ConnectionString;  
    60.   
    61.     }  
    62.     public override CuteChat.AppChatIdentity GetLogonIdentity()  
    63.     {  
    64.   
    65.         DotNetNuke.Entities.Users.UserInfo user = GetLogonUser();  
    66.   
    67.   
    68.         if (user == null)  
    69.         {  
    70.             return null;  
    71.   
    72.         }  
    73.   
    74.         return new CuteChat.AppChatIdentity(user.Username, false, ToUserId(user.Username), HttpContext.Current.Request.UserHostAddress);  
    75.   
    76.     }  
    77.     public override bool GetUserInfo(string loginName, ref string nickName, ref bool isAdmin)  
    78.     {  
    79.   
    80.   
    81.         try  
    82.         {  
    83.             DotNetNuke.Entities.Users.UserInfo user = DotNetNuke.Entities.Users.UserController.GetUserByName(CurrentPortal().PortalId, loginName);  
    84.   
    85.   
    86.             if (user == null)  
    87.             {  
    88.                 return false;  
    89.   
    90.             }  
    91.   
    92.             nickName = user.Username;  
    93.   
    94.             isAdmin = user.IsInRole("Administrators") | (user.Username == "admin");  
    95.   
    96.             return true;  
    97.   
    98.   
    99.         }  
    100.         catch (System.Exception ex)  
    101.         {  
    102.             return false;  
    103.   
    104.         }  
    105.   
    106.     }  
    107.     public override string FindUserLoginName(string nickName)  
    108.     {  
    109.   
    110.   
    111.         try  
    112.         {  
    113.             int totalRecords = 0;  
    114.   
    115.   
    116.             foreach (DotNetNuke.Entities.Users.UserInfo user in DotNetNuke.Entities.Users.UserController.GetUsersByUserName(CurrentPortal().PortalId, false, nickName, 0, 100, ref totalRecords))  
    117.             {  
    118.   
    119.                 if (string.Equals(user.Username, nickName, StringComparison.OrdinalIgnoreCase))  
    120.                 {  
    121.                     return user.Username;  
    122.   
    123.                 }  
    124.   
    125.             }  
    126.   
    127.             return null;  
    128.   
    129.   
    130.         }  
    131.         catch (System.Exception ex)  
    132.         {  
    133.             return null;  
    134.   
    135.         }  
    136.   
    137.     }  
    138.     public override bool ValidateUser(string loginName, string password)  
    139.     {  
    140.   
    141.   
    142.         if (System.Web.Security.Membership.ValidateUser(loginName, password))  
    143.         {  
    144.             System.Web.Security.FormsAuthentication.SetAuthCookie(loginName, false);  
    145.   
    146.             return true;  
    147.   
    148.         }  
    149.         return false;  
    150.   
    151.     }  
    152.   
    153. }  
     

    Regards,

     

    ken 

View as RSS news feed in XML
Powered by ASP.Net
Copyright 2003 - 2017 CuteSoft Components Inc.. All rights reserved.