如何在基于Web的软件中管理多个登录用户的数据 [英] How to manage multiple login user's data in web based software

查看:44
本文介绍了如何在基于Web的软件中管理多个登录用户的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是.net技术的新手。

我使用asp.net,c#和sql server 2008 R2开发了一个基于Web的应用程序。



以下是我对软件的要求。

我将给客户一个超级管理员用户(使用微软CreateUserWizard控件创建)。

超级管理员可以创建不同角色,添加/编辑/删除不同页面的权限。



例如:

角色名称:XYZ_Admin

表格名称添加删除编辑

查询是否是

帐户是是否

订单否否否



超级管理员可以为具有角色的特许经营(由超级管理员创建)创建不同的特许经营(分支)和用户帐户。



现在特许经营将使用其凭证登录并为自己的特许经营创建角色。与上面的示例相同。



现在特许经营为自己的特许经营创建不同的角色(由特许经营权创建)的用户帐户。

- -------------------------------------------------- -------------------------------------------

现在用户(由特许经营商创建)以其信誉登录,他/她可以根据分配角色权限执行操作。



一个用户看不到记录(例如:查询记录)其他用户记录(例如:查询记录)。

------------------------- -------------------------------------------------- ---------------------

每个特许经营店都可以看到自己特许经营的所有用户记录的所有记录。但每个特许经营权都看不到其他特许经营权的记录。

------------------------------ -------------------------------------------------- ----------------

超级管理员可以查看每个特许经营记录的所有记录。

------- -------------------------------------------------- ---------------------------------------

我正在使用microsoft CreateUserWizard控件创建登录帐户和登录控件。



以下方式我实现了这个要求:

当用户登录时。所有我获得登录用户的角色权限(例如上面给出),它的角色类型(超级管理员/特许经营/特许经营的用户)和用户的fracnchise的ID通过调用一个函数(我在C#类文件中实现)。在此函数中,我使用登录用户的ID作为参数调用存储过程,此存储过程返回所有角色权限,角色类型和特许经营ID。

将所有这些用户的角色权限,角色类型和特许经营权的id存储在c#class的私有变量中的不同变量中。

例如:

I am new in .net technology.
I have developed a web based application using asp.net, c# and sql server 2008 R2.

Following is my requirement in software.
I will give client to one Super admin user(which is created using microsoft CreateUserWizard control).
Super admin can create different roles with add/edit/delete permission of different pages.

e.g :
Role Name : XYZ_Admin
Form Name Add Delete Edit
Inquiry Yes No Yes
Account Yes Yes No
Order No No No

Super admin can create different Franchises(branch) and user accounts for those franchises with role(which are created by Super Admin).

Now Franchises will login with its credential and create roles for own franchise. Same as above example.

Now Franchises create different user accounts with role (which are created by franchise) for own franchise.
-----------------------------------------------------------------------------------------------
Now User(which are created by franchise) login with its credntial and he/she can perform operation according to assign role permission.

One user can't see records(e.g: Inquiry records) of other users record(e.g: Inquiry records).
------------------------------------------------------------------------------------------------
Each franchise can see all records of its own franchise's all users records. but each franchises can't see records of other franchises.
------------------------------------------------------------------------------------------------
Super Admin can see all records of each franchises records.
------------------------------------------------------------------------------------------------
I am using microsoft CreateUserWizard control to create account and login control for login.

Following way I have implement this requirement:
When User Login.First of all I am getting login user's role permission(given in above e.g), it's role type(super admin/Franchise/Franchise's User) and user's fracnchise's ID by calling a function (which I have implemented in C# class file). In this function I am calling a store procedure with login user's ID as parameter and this store procedure returns all role permission, role type and franchises ID.
Store all these user's role permission, role type and franchise's id in different variables in c# class's private variables.
e.g:

private static int nRoleType1;
    private static Guid nBranchId1;

    private static bool bInqAdd1 = false;
    private static bool bInqMod1 = false;
    private static bool bInqDel1 = false;

 public void GetRolePermission()
    {
        SqlTransaction trans = CreateTransaction();
        try
        {
            MembershipUser newUser = Membership.GetUser();
            command = new SqlCommand("GetRolePermissionByLoginUserIDForAdmin", con, trans);
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("UserId", SqlDbType.UniqueIdentifier).Value = (Guid)newUser.ProviderUserKey;
            command.Connection = con;

            DataTable dt = new DataTable();
            da = new SqlDataAdapter(command);
            da.Fill(dt);

            nRoleType   = Convert.ToInt32(dt.Rows[0]["snRoleType"].ToString());
            bInqAdd    = Convert.ToBoolean(dt.Rows[0]["bInqAdd"].ToString());
            bInqMod     = Convert.ToBoolean(dt.Rows[0]["bInqModify"].ToString());
            bInqDel    = Convert.ToBoolean(dt.Rows[0]["bInqDelete"].ToString());
            if (nRoleType == 2) // Franchise
            {nBranchId = (Guid)newUser.ProviderUserKey;}
            else if (nRoleType == 3)   // For Franchise's user
            {nBranchId = (Guid)dt.Rows[0]["nGeneratedBy"];}
            trans.Commit();
        }
        catch (SqlException err)
        {
            trans.Rollback();
            throw err;
        }
        catch (Exception ex)
        {
            trans.Rollback();
            throw ex;
        }
        finally
        {
            EndTransaction();
        }







通过它的属性访问这些私有变量。

例如:






Accessing these private variables by it's properties.
e.g:

public int nRoleType    {
        get{return nRoleType1;}
        set{nRoleType1 = value;}
    }

    public Guid nBranchId{
        get{return nBranchId1;}
        set{nBranchId1 = value;}}
    }
public bool bInqAdd   {
       get{return bInqAdd1;}
       set{bInqAdd1 = value;}   }

   public bool bInqMod   {
       get{return bInqMod1;}
       set{bInqMod1 = value;}   }

   public bool bInqDel{
       get{return bInqDel1;}
       set{bInqDel1 = value;}}





------ -------------------------------------------------- ----------------------------------------问题:



当我使用特许经营权的用户信誉登录特许经营和其他用户登录时(此用户由franchis创建)即用户用户可以在几秒/毫秒后在其他系统中获得任何特许经营权。

现在特许经营许可权已被最后用户和最后用户视为特许经营权,最后一位用户查看所有特许经营权记录特许经营不能在网格中看到自己的用户记录(我在页面中使用过),也改变了最后一个用户的特许经营许可。



---------------------------------- -------------------------------------------------- ---------

我希望你理解我的要求和问题。

请尽快帮我解决这个问题。



------------------------------------------------------------------------------------------------Problem:

When I am login with Franchise and other user login with franchise's user credntial(This user is created by franchise. User user can be of any franchises) in other system after few second/milli second.
Now Franchise permissions are over right by last users and last users treated as franchise and last user see all record of franchises and franchise can't see its own users records in grid(which i used in page) and also change franchise permission by last user.

---------------------------------------------------------------------------------------------
I hope you understand my requirement and problems.
Please help me how to solve this issues ASAP.

推荐答案

你的答案就在这里:



http://msdn.microsoft.com/en-us/library/5k850zwb.ASPX [ ^ ]
Your Answer is Here:

http://msdn.microsoft.com/en-us/library/5k850zwb.ASPX[^]


这篇关于如何在基于Web的软件中管理多个登录用户的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆