Example #1
0
        public void createClientPermissions(string userName, string ConnectionString)
        {
            UserPermissions UserPermissions = UserPermission.SelectByField("UserName", userName, ConnectionString);
            if (UserPermissions.Count == 0)
            {
                UserPermission objUserPer = new UserPermission(ConnectionString);
                objUserPer.IsMList = true;
                objUserPer.IsList = true;
                objUserPer.IsContact = true;
                objUserPer.IsImport = true;
                objUserPer.IsSegments = true;
                objUserPer.IsDownloadContacts = true;

                objUserPer.IsMCampaigns = true;
                objUserPer.IsMailing = true;
                objUserPer.IsCampaigns = true;
                objUserPer.IsTemplates = true;
                objUserPer.IsAgedCampaigns = true;
                objUserPer.IsMAdvanced = true;
                objUserPer.IsMangeFields = true;
                objUserPer.IsMergeLists = true;
                objUserPer.IsSuppressAddress = true;
                objUserPer.IsBounceSettings = true;
                objUserPer.IsMActivity = true;
                objUserPer.IsAccountActivity = true;
                objUserPer.IsCompareCampaign = true;
                objUserPer.IsBounceReport = true;
                objUserPer.IsMCampReports = true;
                objUserPer.IsDashboard = true;
                objUserPer.IsContactActivity = true;
                objUserPer.IsClickPerformance = true;
                objUserPer.IsAdvancedReports = true;
                objUserPer.IsMicrositeManager = false;
                objUserPer.IsCustomizedAMMForms = false;
                objUserPer.IsAMMAdvanceReprot = false;
                objUserPer.MasterLogo = null;
                objUserPer.ChildLogo = null;
                objMembershipUser = Membership.GetUser(userName);
                objUserPer.UserName = userName;
                objUserPer.UserId = (Guid)objMembershipUser.ProviderUserKey;
                bool status = objUserPer.Insert();
            }
        }
        /// <summary>
        /// This method will return an object representing the record matching the primary key information specified.
        /// </summary>
        ///
        /// <param name="pk" type="UserPermissionPrimaryKey">Primary Key information based on which data is to be fetched.</param>
        ///
        /// <returns>object of class UserPermission</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			7/5/2012 11:05:31 AM		Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        public static UserPermission SelectOne(UserPermissionPrimaryKey pk, string ConnectionString)
        {
            DatabaseHelper oDatabaseHelper = new DatabaseHelper(ConnectionString);
            bool ExecutionState = false;

            // Pass the values of all key parameters to the stored procedure.
            System.Collections.Specialized.NameValueCollection nvc = pk.GetKeysAndValues();
            foreach (string key in nvc.Keys)
            {
                oDatabaseHelper.AddParameter("@" + key,nvc[key] );
            }
            // The parameter '@ErrorCode' will contain the status after execution of the stored procedure.
            oDatabaseHelper.AddParameter("@ErrorCode", -1, System.Data.ParameterDirection.Output);

            IDataReader dr=oDatabaseHelper.ExecuteReader("sp_UserPermissions_SelectbyPrimaryKey", ref ExecutionState);
            if (dr.Read())
            {
                UserPermission obj = new UserPermission(ConnectionString);
                PopulateObjectFromReader(obj,dr);
                dr.Close();
                oDatabaseHelper.Dispose();
                return obj;
            }
            else
            {
                dr.Close();
                oDatabaseHelper.Dispose();
                return null;
            }
        }
        /// <summary>
        /// Populates the fields for multiple objects from the columns found in an open reader.
        /// </summary>
        ///
        /// <param name="rdr" type="IDataReader">An object that implements the IDataReader interface</param>
        ///
        /// <returns>Object of UserPermissions</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			7/5/2012 11:05:31 AM		Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        internal static UserPermissions PopulateObjectsFromReaderWithCheckingReader(IDataReader rdr, DatabaseHelper oDatabaseHelper, string ConnectionString)
        {
            UserPermissions list = new UserPermissions();

            if (rdr.Read())
            {
                UserPermission obj = new UserPermission(ConnectionString);
                PopulateObjectFromReader(obj, rdr);
                list.Add(obj);
                while (rdr.Read())
                {
                    obj = new UserPermission(ConnectionString);
                    PopulateObjectFromReader(obj, rdr);
                    list.Add(obj);
                }
                oDatabaseHelper.Dispose();
                return list;
            }
            else
            {
                oDatabaseHelper.Dispose();
                return null;
            }
        }
        /// <summary>
        /// Populates the fields for multiple objects from the columns found in an open reader.
        /// </summary>
        ///
        /// <param name="rdr" type="IDataReader">An object that implements the IDataReader interface</param>
        ///
        /// <returns>Object of UserPermissions</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			7/5/2012 11:05:31 AM		Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        internal static UserPermissions PopulateObjectsFromReader(IDataReader rdr, string ConnectionString)
        {
            UserPermissions list = new UserPermissions();

            while (rdr.Read())
            {
                UserPermission obj = new UserPermission(ConnectionString);
                PopulateObjectFromReader(obj,rdr);
                list.Add(obj);
            }
            return list;
        }
Example #5
0
        /// <summary>
        /// Create User in UserPermissions Table
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public bool insertUserInPermissionsTb(string userName,object userId)
        {
            bool status = false;
            try
            {
                //First Get all Permissions of Client for User
                UserPermissions objClientPer = UserPermission.SelectByField("UserName",User.Identity.Name.ToString(), ConnectionString);

                //Add the Clent Permission to User For first Time
                UserPermission objUserPer = new UserPermission(ConnectionString);
                objUserPer.IsMList = (bool)objClientPer[0].IsMList;
                objUserPer.IsList = objClientPer[0].IsList;
                objUserPer.IsContact = objClientPer[0].IsContact;
                objUserPer.IsImport = objClientPer[0].IsImport;
                objUserPer.IsSegments = objClientPer[0].IsSegments;
                objUserPer.IsDownloadContacts = objClientPer[0].IsDownloadContacts;

                objUserPer.IsMCampaigns = objClientPer[0].IsMCampaigns;

                objUserPer.IsMailing =objClientPer[0].IsMailing;
                objUserPer.IsCampaigns = objClientPer[0].IsCampaigns;
                objUserPer.IsTemplates = objClientPer[0].IsTemplates;
                objUserPer.IsAgedCampaigns = objClientPer[0].IsAgedCampaigns;

                objUserPer.IsMAdvanced = objClientPer[0].IsMAdvanced;

                objUserPer.IsMangeFields = objClientPer[0].IsMangeFields;
                objUserPer.IsMergeLists =objClientPer[0].IsMergeLists;
                objUserPer.IsSuppressAddress = objClientPer[0].IsSuppressAddress;
                objUserPer.IsBounceSettings = false;

                objUserPer.IsMActivity =objClientPer[0].IsMActivity;

                objUserPer.IsAccountActivity =objClientPer[0].IsAccountActivity;
                objUserPer.IsCompareCampaign =objClientPer[0].IsCompareCampaign;
                objUserPer.IsBounceReport = objClientPer[0].IsBounceReport;

                objUserPer.IsMCampReports =objClientPer[0].IsMCampReports;

                objUserPer.IsDashboard =objClientPer[0].IsDashboard;
                objUserPer.IsContactActivity =objClientPer[0].IsContactActivity;
                objUserPer.IsClickPerformance =objClientPer[0].IsClickPerformance;
                objUserPer.IsAdvancedReports = objClientPer[0].IsAdvancedReports;

                objUserPer.IsMicrositeManager = objClientPer[0].IsMicrositeManager;
                objUserPer.IsCustomizedAMMForms = objClientPer[0].IsCustomizedAMMForms;
                objUserPer.IsAMMAdvanceReprot =objClientPer[0].IsAMMAdvanceReprot;

                objUserPer.ChildLogo = null;
                objUserPer.MasterLogo = null;

                objUserPer.UserId = (Guid)userId;
                objUserPer.UserName = userName;

                status = objUserPer.Insert();
            }
            catch (Exception ex)
            {

            }
            return status;
        }
        public bool generateAccCls(string userName, string mode)
        {
            bool status = false;
            try
            {
                objUserPer = new UserPermission(ConnectionString);
                objUserPer.IsMList = RTAccountSettings.Nodes[0].Checked;
                objUserPer.IsList = RTAccountSettings.Nodes[0].Nodes[0].Checked;
                objUserPer.IsContact = RTAccountSettings.Nodes[0].Nodes[1].Checked;
                objUserPer.IsImport = RTAccountSettings.Nodes[0].Nodes[2].Checked;
                objUserPer.IsSegments = RTAccountSettings.Nodes[0].Nodes[3].Checked;
                objUserPer.IsDownloadContacts = RTAccountSettings.Nodes[0].Nodes[4].Checked;
                objUserPer.IsMCampaigns = RTAccountSettings.Nodes[1].Checked;
                objUserPer.IsMailing = RTAccountSettings.Nodes[1].Nodes[0].Checked;
                objUserPer.IsCampaigns = RTAccountSettings.Nodes[1].Nodes[1].Checked;
                objUserPer.IsTemplates = RTAccountSettings.Nodes[1].Nodes[2].Checked;
                objUserPer.IsAgedCampaigns = RTAccountSettings.Nodes[1].Nodes[3].Checked;
                objUserPer.IsMAdvanced = RTAccountSettings.Nodes[2].Checked;
                objUserPer.IsMangeFields = RTAccountSettings.Nodes[2].Nodes[0].Checked;
                objUserPer.IsMergeLists = RTAccountSettings.Nodes[2].Nodes[1].Checked;
                objUserPer.IsSuppressAddress = RTAccountSettings.Nodes[2].Nodes[2].Checked;
                objUserPer.IsBounceSettings = RTAccountSettings.Nodes[2].Nodes[3].Checked;
                objUserPer.IsMActivity = RTAccountSettings.Nodes[3].Checked;
                objUserPer.IsAccountActivity = RTAccountSettings.Nodes[3].Nodes[0].Checked;
                objUserPer.IsCompareCampaign = RTAccountSettings.Nodes[3].Nodes[1].Checked;
                objUserPer.IsBounceReport = RTAccountSettings.Nodes[3].Nodes[2].Checked;
                objUserPer.IsMCampReports = RTAccountSettings.Nodes[4].Checked;
                objUserPer.IsDashboard = RTAccountSettings.Nodes[4].Nodes[0].Checked;
                objUserPer.IsContactActivity = RTAccountSettings.Nodes[4].Nodes[1].Checked;
                objUserPer.IsClickPerformance = RTAccountSettings.Nodes[4].Nodes[2].Checked;
                objUserPer.IsAdvancedReports = RTAccountSettings.Nodes[4].Nodes[3].Checked;
                objUserPer.IsMicrositeManager = RTAccountSettings.Nodes[5].Checked;
                objUserPer.IsCustomizedAMMForms = RTAccountSettings.Nodes[6].Checked;
                objUserPer.IsAMMAdvanceReprot = RTAccountSettings.Nodes[7].Checked;
                objUserPer.MasterLogo = null;
                if (LogoFileUpload.HasFile)
                {
                    //Written By Swaroop Feb 15,2012 LogoFileUpload
                    System.IO.Stream streamContent = LogoFileUpload.PostedFile.InputStream;
                    picbyte = new byte[streamContent.Length];
                    MemoryStream ms = new MemoryStream(picbyte);
                    LogoFileUpload.PostedFile.InputStream.Read(picbyte, 0, picbyte.Length);
                    objUserPer.ChildLogo = picbyte;
                }
                else
                {
                    if (ViewState["Logo"] != null)
                        objUserPer.ChildLogo = (byte[])ViewState["Logo"];
                }
                objMembershipUser = Membership.GetUser(userName);
                objUserPer.UserName = userName;
                objUserPer.UserId = (Guid)objMembershipUser.ProviderUserKey;

                if (mode == "Insert")
                    status = objUserPer.Insert();
                else
                    status = objUserPer.Update();

                poplateTreeView(ddlUsers.SelectedItem.Text);

            }
            catch (Exception ex)
            {
                lblMsg.ForeColor = Color.Red;
                lblMsg.Text = ex.Message;
            }
            return status;
        }
        public bool updateAllUserPermissions(string userName)
        {
            bool status = false;
            try
            {
                UserPermissions objClientPer = UserPermission.SelectByField("UserName", ddlClients.SelectedItem.Text.ToString(), ConnectionString);
                //First Get the UserPermissions.
                UserPermissions UserPermissions = UserPermission.SelectByField("UserName", userName, ConnectionString);
                if (UserPermissions.Count != 0)
                {
                    objUserPer = new UserPermission(ConnectionString);
                    objUserPer.IsMList = (!(bool)objClientPer[0].IsMList) ? false : UserPermissions[0].IsMList;
                    objUserPer.IsList = (!(bool)objClientPer[0].IsList) ? false : UserPermissions[0].IsList;
                    objUserPer.IsContact = (!(bool)objClientPer[0].IsContact) ? false : UserPermissions[0].IsContact;
                    objUserPer.IsImport = (!(bool)objClientPer[0].IsImport) ? false : UserPermissions[0].IsImport;
                    objUserPer.IsSegments = (!(bool)objClientPer[0].IsSegments) ? false : UserPermissions[0].IsSegments;
                    objUserPer.IsDownloadContacts = (!(bool)objClientPer[0].IsDownloadContacts) ? false : UserPermissions[0].IsDownloadContacts;
                    objUserPer.IsMCampaigns = (!(bool)objClientPer[0].IsMCampaigns) ? false : UserPermissions[0].IsMCampaigns;
                    objUserPer.IsMailing = (!(bool)objClientPer[0].IsMailing) ? false : UserPermissions[0].IsMailing;
                    objUserPer.IsCampaigns = (!(bool)objClientPer[0].IsCampaigns) ? false : UserPermissions[0].IsCampaigns;
                    objUserPer.IsTemplates = (!(bool)objClientPer[0].IsTemplates) ? false : UserPermissions[0].IsTemplates;
                    objUserPer.IsAgedCampaigns = (!(bool)objClientPer[0].IsAgedCampaigns) ? false : UserPermissions[0].IsAgedCampaigns;

                    objUserPer.IsMAdvanced = (!(bool)objClientPer[0].IsMAdvanced) ? false : UserPermissions[0].IsMAdvanced;

                    objUserPer.IsMangeFields = (!(bool)objClientPer[0].IsMangeFields) ? false : UserPermissions[0].IsMangeFields;
                    objUserPer.IsMergeLists = (!(bool)objClientPer[0].IsMergeLists) ? false : UserPermissions[0].IsMergeLists;
                    objUserPer.IsSuppressAddress = (!(bool)objClientPer[0].IsSuppressAddress) ? false : UserPermissions[0].IsSuppressAddress;
                    objUserPer.IsBounceSettings = (!(bool)objClientPer[0].IsBounceSettings) ? false : UserPermissions[0].IsBounceSettings;

                    objUserPer.IsMActivity = (!(bool)objClientPer[0].IsMActivity) ? false : UserPermissions[0].IsMActivity;

                    objUserPer.IsAccountActivity = (!(bool)objClientPer[0].IsAccountActivity) ? false : UserPermissions[0].IsAccountActivity;
                    objUserPer.IsCompareCampaign = (!(bool)objClientPer[0].IsCompareCampaign) ? false : UserPermissions[0].IsCompareCampaign;
                    objUserPer.IsBounceReport = (!(bool)objClientPer[0].IsBounceReport) ? false : UserPermissions[0].IsBounceReport;

                    objUserPer.IsMCampReports = (!(bool)objClientPer[0].IsMCampReports) ? false : UserPermissions[0].IsMCampReports;

                    objUserPer.IsDashboard = (!(bool)objClientPer[0].IsDashboard) ? false : UserPermissions[0].IsDashboard;
                    objUserPer.IsContactActivity = (!(bool)objClientPer[0].IsContactActivity) ? false : UserPermissions[0].IsContactActivity;
                    objUserPer.IsClickPerformance = (!(bool)objClientPer[0].IsClickPerformance) ? false : UserPermissions[0].IsClickPerformance;
                    objUserPer.IsAdvancedReports = (!(bool)objClientPer[0].IsAdvancedReports) ? false : UserPermissions[0].IsAdvancedReports;

                    objUserPer.IsMicrositeManager = (!(bool)objClientPer[0].IsMicrositeManager) ? false : UserPermissions[0].IsMicrositeManager;
                    objUserPer.IsCustomizedAMMForms = (!(bool)objClientPer[0].IsCustomizedAMMForms) ? false : UserPermissions[0].IsCustomizedAMMForms;
                    objUserPer.IsAMMAdvanceReprot = (!(bool)objClientPer[0].IsAMMAdvanceReprot) ? false : UserPermissions[0].IsAMMAdvanceReprot;

                    objUserPer.ChildLogo = UserPermissions[0].ChildLogo;
                    objUserPer.MasterLogo = UserPermissions[0].MasterLogo;

                    objUserPer.UserId = (Guid)UserPermissions[0].UserId;
                    objUserPer.UserName = UserPermissions[0].UserName;

                    status = objUserPer.Update();
                }
            }
            catch (Exception ex)
            {
                lblMsg.ForeColor = Color.Red;
                lblMsg.Text = ex.Message;
            }
            return status;
        }