Example #1
0
        private void PopulateData(String userId)
        {
            Exists = false;
            if (Utils.IsNumeric(userId))
            {
                _userInfo = UserController.GetUserById(PortalSettings.Current.PortalId, Convert.ToInt32(userId));
            }
            else
            {
                _userInfo = UserController.Instance.GetCurrentUserInfo();
            }

            if (_userInfo != null && _userInfo.UserID != -1) // only create userdata if we have a user logged in.
            {
                var modCtrl = new NBrightBuyController();
                Info = modCtrl.GetByType(_userInfo.PortalID, -1, "USERDATA", _userInfo.UserID.ToString(""));
                if (Info == null && _userInfo.UserID != -1)
                {
                    Info          = new NBrightInfo();
                    Info.ItemID   = -1;
                    Info.UserId   = _userInfo.UserID;
                    Info.PortalId = _userInfo.PortalID;
                    Info.ModuleId = -1;
                    Info.TypeCode = "USERDATA";
                    Info.XMLData  = "<genxml></genxml>";
                    Save();
                }
                else
                {
                    Exists = true;
                }
            }
        }
Example #2
0
        private void PopulateData(String userId)
        {
            DocList      = new Dictionary <string, NBrightInfo>();
            _fileKeyXref = new Dictionary <string, string>();

            Exists = false;
            if (Utils.IsNumeric(userId))
            {
                _userInfo = UserController.GetUserById(PortalSettings.Current.PortalId, Convert.ToInt32(userId));
            }
            else
            {
                _userInfo = UserController.Instance.GetCurrentUserInfo();
            }

            if (_userInfo != null && _userInfo.UserID != -1) // only create userdata if we have a user logged in.
            {
                var modCtrl = new NBrightBuyController();
                Info = modCtrl.GetByType(_userInfo.PortalID, -1, "USERDATA", _userInfo.UserID.ToString(""));
                if (Info == null && _userInfo.UserID != -1)
                {
                    Info          = new NBrightInfo();
                    Info.ItemID   = -1;
                    Info.UserId   = _userInfo.UserID;
                    Info.PortalId = _userInfo.PortalID;
                    Info.ModuleId = -1;
                    Info.TypeCode = "USERDATA";
                    Info.XMLData  = "<genxml></genxml>";
                    Save();
                }
                else
                {
                    Exists = true;
                }

                var nodlist = Info.XMLDoc.SelectNodes("genxml/docs/*");
                if (nodlist != null)
                {
                    foreach (XmlNode nod in nodlist)
                    {
                        if (nod.SelectSingleNode("filename") != null && !_fileKeyXref.ContainsKey(nod.SelectSingleNode("filename").InnerXml))
                        {
                            var nbi = new NBrightInfo();
                            nbi.XMLData = nod.OuterXml;
                            nbi.GUIDKey = nbi.GetXmlProperty("genxml/key");
                            DocList.Add(nbi.GetXmlProperty("genxml/key"), nbi);
                            _fileKeyXref.Add(nbi.GetXmlProperty("genxml/filename"), nbi.GUIDKey);
                        }
                    }
                }
            }
        }
Example #3
0
        public void Update(NBrightInfo updateInfo)
        {
            // update email
            var email = updateInfo.GetXmlProperty("genxml/textbox/email");

            if (_userInfo != null && Utils.IsEmail(email) && (_userInfo.Email != email))
            {
                _userInfo.Email = email;
                UserController.UpdateUser(PortalSettings.Current.PortalId, _userInfo);
            }

            // ClientEditorRole
            var clientEditorRole = updateInfo.GetXmlProperty("genxml/checkbox/clienteditorrole");

            if (clientEditorRole == "True")
            {
                AddClientEditorRole();
            }
            else
            {
                RemoveClientEditorRole();
            }

            // save client data fields.
            var objCtrl = new NBrightBuyController();

            DataRecord         = objCtrl.GetByType(PortalId, -1, "CLIENT", _userInfo.UserID.ToString(""));
            DataRecord.XMLData = updateInfo.XMLData;
            DataRecord.RemoveXmlNode("genxml/hidden/xmlupdatediscountcodedata");
            DataRecord.RemoveXmlNode("genxml/hidden/xmlupdatevouchercodedata");
            objCtrl.Update(DataRecord);

            // update Discount codes
            var strXml = Utils.UnCode(updateInfo.GetXmlProperty("genxml/hidden/xmlupdatediscountcodedata"));

            UpdateDiscountCodes(strXml);
            strXml = Utils.UnCode(updateInfo.GetXmlProperty("genxml/hidden/xmlupdatevouchercodedata"));
            UpdateVoucherCodes(strXml);
        }
Example #4
0
        private void PopulateData(String userId)
        {
            Exists = false;
            if (Utils.IsNumeric(userId))
                _userInfo = UserController.GetUserById(PortalSettings.Current.PortalId, Convert.ToInt32(userId));
            else
                _userInfo = UserController.Instance.GetCurrentUserInfo();

            if (_userInfo != null && _userInfo.UserID != -1) // only create userdata if we have a user logged in.
            {
                var modCtrl = new NBrightBuyController();
                Info = modCtrl.GetByType(_userInfo.PortalID, -1, "USERDATA", _userInfo.UserID.ToString(""));
                if (Info == null && _userInfo.UserID != -1)
                {
                    Info = new NBrightInfo();
                    Info.ItemID = -1;
                    Info.UserId = _userInfo.UserID;
                    Info.PortalId = _userInfo.PortalID;
                    Info.ModuleId = -1;
                    Info.TypeCode = "USERDATA";
                    Info.XMLData = "<genxml></genxml>";
                    Save();
                }
                else
                    Exists = true;
            }
        }
Example #5
0
        private void PopulateClientData(int userId)
        {
            _clientInfo          = new NBrightInfo(true);
            _clientInfo.ItemID   = userId;
            _clientInfo.UserId   = userId;
            _clientInfo.PortalId = PortalId;

            _userInfo = UserController.GetUserById(PortalId, userId);
            if (_userInfo != null)
            {
                Exists = true;

                _clientInfo.ModifiedDate = _userInfo.Membership.CreatedDate;

                foreach (var propertyInfo in _userInfo.GetType().GetProperties())
                {
                    if (propertyInfo.CanRead)
                    {
                        var pv = propertyInfo.GetValue(_userInfo, null);
                        if (pv == null)
                        {
                            pv = "";
                        }
                        _clientInfo.SetXmlProperty("genxml/textbox/" + propertyInfo.Name.ToLower(), pv.ToString());
                    }
                }

                foreach (DotNetNuke.Entities.Profile.ProfilePropertyDefinition p in _userInfo.Profile.ProfileProperties)
                {
                    _clientInfo.SetXmlProperty("genxml/textbox/" + p.PropertyName.ToLower(), p.PropertyValue);
                }

                _clientInfo.AddSingleNode("membership", "", "genxml");
                foreach (var propertyInfo in _userInfo.Membership.GetType().GetProperties())
                {
                    if (propertyInfo.CanRead)
                    {
                        var pv = propertyInfo.GetValue(_userInfo.Membership, null);
                        if (pv != null)
                        {
                            _clientInfo.SetXmlProperty("genxml/membership/" + propertyInfo.Name.ToLower(), pv.ToString());
                        }
                    }
                }

                if (_userInfo.IsInRole(StoreSettings.ClientEditorRole))
                {
                    _clientInfo.SetXmlProperty("genxml/checkbox/clienteditorrole", "True");
                }
                else
                {
                    _clientInfo.SetXmlProperty("genxml/checkbox/clienteditorrole", "False");
                }

                var objCtrl = new NBrightBuyController();
                DataRecord = objCtrl.GetByType(PortalId, -1, "CLIENT", _userInfo.UserID.ToString(""));
                if (DataRecord == null)
                {
                    DataRecord          = new NBrightInfo(true);
                    DataRecord.ItemID   = -1;
                    DataRecord.UserId   = _userInfo.UserID;
                    DataRecord.PortalId = PortalId;
                    DataRecord.ModuleId = -1;
                    DataRecord.TypeCode = "CLIENT";
                }
                DiscountCodes = GetEntityList("discountcodes");
                VoucherCodes  = GetEntityList("vouchercodes");
            }
        }
Example #6
0
 public static NBrightInfo GetSettings(int portalId, int moduleId, String ctrlTypeCode = "", bool useCache = true)
 {
     var obj = (NBrightInfo) GetModCache("NBright_NBsettings" + portalId.ToString("") + "_" + moduleId.ToString(""));
     if (obj == null | !useCache)
     {
         // single record for EntityTypeCode settings, so get record directly.
         var objCtrl = new NBrightBuyController();
         obj = objCtrl.GetByType(portalId, moduleId, "SETTINGS");
         if (obj == null)
         {
             obj = new NBrightInfo {ItemID = -1};
             obj.TypeCode = "SETTINGS";
             obj.ModuleId = moduleId;
             obj.PortalId = portalId;
             obj.XMLData = "<genxml><hidden></hidden><textbox></textbox></genxml>";
             obj.UserId = -1;
             obj.GUIDKey = ctrlTypeCode;
         }
         SetModCache(moduleId, "NBright_NBsettings" + portalId.ToString("") + "_" + moduleId.ToString(""), obj);
     }
     return obj;
 }
Example #7
0
        private void PopulateClientData(int userId)
        {
            _clientInfo = new NBrightInfo(true);
            _clientInfo.ItemID = userId;
            _clientInfo.UserId = userId;
            _clientInfo.PortalId = PortalId;

            _userInfo = UserController.GetUserById(PortalId, userId);
            if (_userInfo != null)
            {
                Exists = true;

                _clientInfo.ModifiedDate = _userInfo.Membership.CreatedDate;

                foreach (var propertyInfo in _userInfo.GetType().GetProperties())
                {
                    if (propertyInfo.CanRead)
                    {
                        var pv = propertyInfo.GetValue(_userInfo, null);
                        if (pv == null) pv = "";
                        _clientInfo.SetXmlProperty("genxml/textbox/" + propertyInfo.Name.ToLower(), pv.ToString());
                    }
                }

                foreach (DotNetNuke.Entities.Profile.ProfilePropertyDefinition p in _userInfo.Profile.ProfileProperties)
                {
                    _clientInfo.SetXmlProperty("genxml/textbox/" + p.PropertyName.ToLower(), p.PropertyValue);
                }

                _clientInfo.AddSingleNode("membership", "", "genxml");
                foreach (var propertyInfo in _userInfo.Membership.GetType().GetProperties())
                {
                    if (propertyInfo.CanRead)
                    {
                        var pv = propertyInfo.GetValue(_userInfo.Membership, null);
                        if (pv != null) _clientInfo.SetXmlProperty("genxml/membership/" + propertyInfo.Name.ToLower(), pv.ToString());
                    }
                }

                if (_userInfo.IsInRole(StoreSettings.ClientEditorRole))
                {
                    _clientInfo.SetXmlProperty("genxml/checkbox/clienteditorrole", "True");
                }
                else
                {
                    _clientInfo.SetXmlProperty("genxml/checkbox/clienteditorrole", "False");
                }

                var objCtrl = new NBrightBuyController();
                DataRecord = objCtrl.GetByType(PortalId, -1, "CLIENT", _userInfo.UserID.ToString(""));
                if (DataRecord == null)
                {
                    DataRecord = new NBrightInfo(true);
                    DataRecord.ItemID = -1;
                    DataRecord.UserId = _userInfo.UserID;
                    DataRecord.PortalId = PortalId;
                    DataRecord.ModuleId = -1;
                    DataRecord.TypeCode = "CLIENT";
                }
                DiscountCodes = GetEntityList("discountcodes");
                VoucherCodes = GetEntityList("vouchercodes");

            }
        }
 private NBrightInfo CreateSettingsInfo(String moduleid, NBrightInfo nbi)
 {
     var objCtrl = new NBrightBuyController();
     nbi = objCtrl.GetByType(PortalSettings.Current.PortalId, Convert.ToInt32(moduleid), "SETTINGS");
     if (nbi == null)
     {
         nbi = new NBrightInfo(true); // populate empty XML so we can update nodes.
         nbi.GUIDKey = "";
         nbi.PortalId = PortalSettings.Current.PortalId;
         nbi.ModuleId = Convert.ToInt32(moduleid);
         nbi.TypeCode = "SETTINGS";
         nbi.Lang = "";
     }
     //rebuild xml
     nbi.ModuleId = Convert.ToInt32(moduleid);
     nbi.GUIDKey = Utils.GetUniqueKey(10);
     nbi.SetXmlProperty("genxml/hidden/modref", nbi.GUIDKey);
     return nbi;
 }