コード例 #1
0
        public static User GetUserByID(int id)
        {
            User user = null;
            ThingReader <User> thingReader;
            Func <FieldInfo, IDataRecord, object> customApply = CustomApply;

            using (SqlConnection conn = new SqlConnection(AppSettings.GetConnectionString("Easynet.Edge.Core.Data.DataManager.Connection", "String")))
            {
                SqlCommand sqlCommand = DataManager.CreateCommand("User_GetByID(@userID:int)", CommandType.StoredProcedure);
                sqlCommand.Connection = conn;
                conn.Open();
                sqlCommand.Parameters["@userID"].Value = id;

                thingReader = new ThingReader <User>(sqlCommand.ExecuteReader(), CustomApply);
                if (thingReader.Read())
                {
                    user = (User)thingReader.Current;
                }
            }
            if (user != null)
            {
                user = MapperUtility.ExpandObject <User>(user, customApply);
            }

            return(user);
            //System.Data.SqlClient.SqlCommand cmd = Easynet.Edge.Core.Data.DataManager.CreateCommand("User_GetAllPermissions(@userID:int)");
        }
コード例 #2
0
        public static List <User> GetAllUsers()
        {
            List <User>        users = new List <User>();
            ThingReader <User> thingReader;
            Func <FieldInfo, IDataRecord, object> customApply = CustomApply;

            using (SqlConnection conn = new SqlConnection(AppSettings.GetConnectionString("Easynet.Edge.Core.Data.DataManager.Connection", "String")))
            {
                SqlCommand sqlCommand = DataManager.CreateCommand("SELECT UserID,IsActive,Name,Email FROM User_GUI_User ORDER BY Name");
                sqlCommand.Connection = conn;
                conn.Open();

                thingReader = new ThingReader <User>(sqlCommand.ExecuteReader(), CustomApply);
                while (thingReader.Read())
                {
                    users.Add((User)thingReader.Current);
                }
            }
            if (users != null && users.Count > 0)
            {
                for (int i = 0; i < users.Count; i++)
                {
                    users[i] = MapperUtility.ExpandObject <User>(users[i], customApply);
                }
            }
            return(users.OrderBy(N => N.Name).ToList());
        }
コード例 #3
0
        public static Group GetGroupByID(int groupID)
        {
            Group group = null;
            ThingReader <Group> thingReader;
            Func <FieldInfo, IDataRecord, object> customApply = CustomApply;

            using (SqlConnection conn = new SqlConnection(AppSettings.GetConnectionString("Easynet.Edge.Core.Data.DataManager.Connection", "String")))
            {
                SqlCommand sqlCommand = DataManager.CreateCommand(@"SELECT GroupID,
																			Name,
																			IsActive,
																			AccountAdmin     
																			FROM User_GUI_UserGroup
																			WHERE GroupID=@GroupID:Int"                                                                            );
                sqlCommand.Parameters["@GroupID"].Value = groupID;
                sqlCommand.Connection = conn;
                conn.Open();

                thingReader = new ThingReader <Group>(sqlCommand.ExecuteReader(), CustomApply);
                if (thingReader.Read())
                {
                    group = (Group)thingReader.Current;
                }
            }
            if (group != null)
            {
                group = MapperUtility.ExpandObject <Group>(group, customApply);
            }

            return(group);
        }
コード例 #4
0
        public static List <Permission> GetAllPermissionTypeTree()
        {
            List <Permission>        returnObject = new List <Permission>();
            ThingReader <Permission> thingReader;
            Stack <Permission>       stackPermission = new Stack <Permission>();



            using (SqlConnection conn = new SqlConnection(AppSettings.GetConnectionString("Easynet.Edge.Core.Data.DataManager.Connection", "String")))
            {
                using (SqlCommand sqlCommand = DataManager.CreateCommand(@"Permmissions_GetAllPermissions", CommandType.StoredProcedure))
                {
                    sqlCommand.Connection = conn;
                    conn.Open();
                    thingReader = new ThingReader <Permission>(sqlCommand.ExecuteReader(), null);
                    while (thingReader.Read())
                    {
                        Permission permission = (Permission)thingReader.Current;
                        if (stackPermission.Count == 0)
                        {
                            stackPermission.Push(permission);
                        }
                        else if (permission.Path.StartsWith(stackPermission.Peek().Path))
                        {
                            stackPermission.Peek().ChildPermissions.Add(permission);
                            stackPermission.Push(permission);
                        }
                        else
                        {
                            while (stackPermission.Count != 1 && !permission.Path.StartsWith(stackPermission.Peek().Path))
                            {
                                stackPermission.Pop();
                            }
                            if (!permission.Path.StartsWith(stackPermission.Peek().Path))
                            {
                                returnObject.Add(stackPermission.Pop());
                                stackPermission.Push(permission);
                            }
                            else
                            {
                                stackPermission.Peek().ChildPermissions.Add(permission);
                                stackPermission.Push(permission);
                            }
                        }
                    }
                }
            }
            while (stackPermission.Count > 1)
            {
                stackPermission.Pop();
            }
            if (stackPermission.Count > 0)
            {
                returnObject.Add(stackPermission.Pop());
            }

            returnObject = Order(returnObject);

            return(returnObject);
        }
コード例 #5
0
        public static List <Group> GetAllGroups()
        {
            List <Group>        groups = new List <Group>();
            ThingReader <Group> thingReader;
            Func <FieldInfo, IDataRecord, object> customApply = CustomApply;

            using (DataManager.Current.OpenConnection())
            {
                SqlCommand sqlCommand = DataManager.CreateCommand("SELECT GroupID,Name,AccountAdmin FROM User_GUI_UserGroup ORDER BY GroupID");


                thingReader = new ThingReader <Group>(sqlCommand.ExecuteReader(), CustomApply);
                while (thingReader.Read())
                {
                    groups.Add((Group)thingReader.Current);
                }
            }
            if (groups != null && groups.Count > 0)
            {
                for (int i = 0; i < groups.Count; i++)
                {
                    groups[i] = MapperUtility.ExpandObject <Group>(groups[i], customApply);
                }
            }
            return(groups);
        }
コード例 #6
0
        public static List <Group> GetAllGroups()
        {
            List <Group>        groups = new List <Group>();
            ThingReader <Group> thingReader;
            Func <FieldInfo, IDataRecord, object> customApply = CustomApply;

            using (SqlConnection conn = new SqlConnection(AppSettings.GetConnectionString("Easynet.Edge.Core.Data.DataManager.Connection", "String")))
            {
                conn.Open();
                SqlCommand sqlCommand = DataManager.CreateCommand("SELECT GroupID,IsActive,Name,AccountAdmin FROM User_GUI_UserGroup ORDER BY Name");
                sqlCommand.Connection = conn;
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }

                thingReader = new ThingReader <Group>(sqlCommand.ExecuteReader(), CustomApply);
                while (thingReader.Read())
                {
                    groups.Add((Group)thingReader.Current);
                }
            }
            if (groups != null && groups.Count > 0)
            {
                for (int i = 0; i < groups.Count; i++)
                {
                    groups[i] = MapperUtility.ExpandObject <Group>(groups[i], customApply);
                }
            }
            return(groups);
        }
コード例 #7
0
        public static List <User> GetAllUsers()
        {
            List <User>        users = new List <User>();
            ThingReader <User> thingReader;
            Func <FieldInfo, IDataRecord, object> customApply = CustomApply;

            using (DataManager.Current.OpenConnection())
            {
                SqlCommand sqlCommand = DataManager.CreateCommand("SELECT UserID,Name,AccountAdmin,Email FROM User_GUI_User ORDER BY UserID");


                thingReader = new ThingReader <User>(sqlCommand.ExecuteReader(), CustomApply);
                while (thingReader.Read())
                {
                    users.Add((User)thingReader.Current);
                }
            }
            if (users != null && users.Count > 0)
            {
                for (int i = 0; i < users.Count; i++)
                {
                    users[i] = MapperUtility.ExpandObject <User>(users[i], customApply);
                }
            }
            return(users);
        }
コード例 #8
0
        public static List <Account> GetAccount(int?id, bool firstTime, int userId)
        {
            ThingReader <Account> accountReader;
            ThingReader <CalculatedPermission> calculatedPermissionReader;
            List <CalculatedPermission>        calculatedPermissionList = new List <CalculatedPermission>();
            List <Account>                        returnObject          = new List <Account>();
            Dictionary <int?, Account>            parents     = new Dictionary <int?, Account>();
            Func <FieldInfo, IDataRecord, object> customApply = CustomApply;

            using (DataManager.Current.OpenConnection())
            {
                SqlCommand sqlCommand = null;
                sqlCommand = DataManager.CreateCommand("User_CalculatePermissions(@UserID:Int)", CommandType.StoredProcedure);
                sqlCommand.Parameters["@UserID"].Value = userId;
                calculatedPermissionReader             = new ThingReader <CalculatedPermission>(sqlCommand.ExecuteReader(), customApply);
                while (calculatedPermissionReader.Read())
                {
                    calculatedPermissionList.Add(calculatedPermissionReader.Current);
                }
                calculatedPermissionReader.Dispose();
                if (id == null)
                {
                    sqlCommand = DataManager.CreateCommand("SELECT DISTINCT ID,Name,Parent_ID,AccountSettings,Level,SiteURL FROM [V_User_GUI_Accounts]   ORDER BY Parent_ID", CommandType.Text);
                }
                else
                {
                    sqlCommand = DataManager.CreateCommand("SELECT DISTINCT ID,Name,Parent_ID,AccountSettings,Level,SiteURL FROM [V_User_GUI_Accounts] WHERE ID=@ID:Int ORDER BY Parent_ID", CommandType.Text);
                    sqlCommand.Parameters["@ID"].Value = id;
                }
                accountReader = new ThingReader <Account>(sqlCommand.ExecuteReader(), CustomApply);
                while (accountReader.Read())
                {
                    Account account = accountReader.Current;
                    account.Permissions = calculatedPermissionList.FindAll(calculatedPermission => calculatedPermission.AccountID == account.ID).Select(calc => calc.Path).ToList();


                    if (account.Permissions != null && account.Permissions.Count > 0)
                    {
                        if (account.ParentID == null || !parents.ContainsKey(account.ParentID))                         //If has no parent or parentid==null(is main father)
                        {
                            returnObject.Add(account);
                        }
                        else
                        {
                            parents[account.ParentID].ChildAccounts.Add(account);     //has father then add it has a child
                        }
                        if (!parents.ContainsKey(account.ID))                         //always add it to the parents
                        {
                            parents.Add(account.ID, account);
                        }
                    }
                }
            }
            returnObject = Order(returnObject);
            return(returnObject);
        }
コード例 #9
0
        public static List <CampaignStatusSchedule> GetCampaignStatusSchedules(long campaignID)
        {
            List <CampaignStatusSchedule>        campaignStatusSchedules = new List <CampaignStatusSchedule>();
            ThingReader <CampaignStatusSchedule> thingReader;

            //Func<FieldInfo, IDataRecord, object> customApply = CustomApply;
            using (DataManager.Current.OpenConnection())
            {
                SqlCommand sqlCommand = DataManager.CreateCommand("CampaignStatusSchedules_GetByCampaignGK(@Campaign_GK:Int", System.Data.CommandType.StoredProcedure);
                sqlCommand.Parameters["@Campaign_GK"].Value = campaignID;


                thingReader = new ThingReader <CampaignStatusSchedule>(sqlCommand.ExecuteReader(), null);
                while (thingReader.Read())
                {
                    campaignStatusSchedules.Add((CampaignStatusSchedule)thingReader.Current);
                }
            }

            return(campaignStatusSchedules);
        }
コード例 #10
0
        public static List <Campaign> GetCampaignsByAccountIdAndChannel(int accountID, int channelID)
        {
            List <Campaign>        campaigns = new List <Campaign>();
            ThingReader <Campaign> thingReader;

            //Func<FieldInfo, IDataRecord, object> customApply = CustomApply;
            using (DataManager.Current.OpenConnection())
            {
                SqlCommand sqlCommand = DataManager.CreateCommand("CampaignByAccountAndChannel(@Account_ID:Int,@Channel_ID:Int", System.Data.CommandType.StoredProcedure);

                sqlCommand.Parameters["@Account_ID"].Value = accountID;
                sqlCommand.Parameters["@Channel_ID"].Value = channelID;

                thingReader = new ThingReader <Campaign>(sqlCommand.ExecuteReader(), null);
                while (thingReader.Read())
                {
                    campaigns.Add((Campaign)thingReader.Current);
                }
            }

            return(campaigns);
        }
コード例 #11
0
        public static List <User> GetUserAssociateUsers(int ID)
        {
            List <User> associateUsers = new List <User>();

            using (DataManager.Current.OpenConnection())
            {
                SqlCommand sqlCommand = DataManager.CreateCommand(@"SELECT DISTINCT  T0.UserID ,T1.Name
																	FROM User_GUI_UserGroupUser T0
																	INNER JOIN User_GUI_User T1 ON T0.UserID=T1.UserID 
																	WHERE GroupID=@GroupID:Int"                                                                    );
                sqlCommand.Parameters["@GroupID"].Value = ID;

                using (ThingReader <User> thingReader = new ThingReader <User>(sqlCommand.ExecuteReader(), null))
                {
                    while (thingReader.Read())
                    {
                        associateUsers.Add((User)thingReader.Current);
                    }
                }
            }
            return(associateUsers);
        }
コード例 #12
0
        public static List <Menu> GetMenu(int userId)
        {
            Stack <Menu> stackMenu = new Stack <Menu>();

            string                                newPath = string.Format("{0}%", string.Empty); //for future get specific menu and sub menu
            ThingReader <Menu>                    thingReader;
            List <Menu>                           returnObject  = new List <Menu>();
            Dictionary <int, List <Menu> >        menuesByLevel = new Dictionary <int, List <Menu> >();
            Func <FieldInfo, IDataRecord, object> customApply   = CustomApply;

            using (SqlConnection conn = new SqlConnection(AppSettings.GetConnectionString("Easynet.Edge.Core.Data.DataManager.Connection", "String")))
            {
                SqlCommand sqlCommand = DataManager.CreateCommand("Menu_GetMenuByUserPermission(@userID:Int,@menuPath:NvarChar)", CommandType.StoredProcedure);
                sqlCommand.Connection = conn;
                conn.Open();
                sqlCommand.Parameters["@menuPath"].Value = newPath;
                sqlCommand.Parameters["@userID"].Value   = userId;

                thingReader = new ThingReader <Menu>(sqlCommand.ExecuteReader(), CustomApply);

                while (thingReader.Read())
                {
                    Menu menu = (Menu)thingReader.Current;

                    if (stackMenu.Count == 0)
                    {
                        stackMenu.Push(menu);
                    }
                    else if (menu.Path.StartsWith(stackMenu.Peek().Path))
                    {
                        stackMenu.Peek().ChildItems.Add(menu);
                        stackMenu.Push(menu);
                    }
                    else
                    {
                        while (stackMenu.Count != 1 && !Regex.IsMatch(menu.Path, string.Format(@"^{0}(?=\/)", stackMenu.Peek().Path), RegexOptions.IgnoreCase))
                        {
                            stackMenu.Pop();
                        }

                        if (!Regex.IsMatch(menu.Path, string.Format(@"^{0}(?=\/)", stackMenu.Peek().Path), RegexOptions.IgnoreCase))
                        {
                            returnObject.Add(stackMenu.Pop());
                            stackMenu.Push(menu);
                        }
                        else
                        {
                            stackMenu.Peek().ChildItems.Add(menu);
                            stackMenu.Push(menu);
                        }
                    }
                }
            }

            while (stackMenu.Count > 1)
            {
                stackMenu.Pop();
            }
            if (stackMenu.Count > 0)
            {
                returnObject.Add(stackMenu.Pop());
            }

            returnObject = Order(returnObject);

            return(returnObject);
        }
コード例 #13
0
        public static List <Menu> GetMenu(int userId)
        {
            Stack <Menu> stackMenu = new Stack <Menu>();

            string                                newPath = string.Format("{0}%", string.Empty); //for future get specific menu and sub menu
            ThingReader <Menu>                    thingReader;
            List <Menu>                           returnObject  = new List <Menu>();
            Dictionary <int, List <Menu> >        menuesByLevel = new Dictionary <int, List <Menu> >();
            Func <FieldInfo, IDataRecord, object> customApply   = CustomApply;

            using (DataManager.Current.OpenConnection())
            {
                SqlCommand sqlCommand = DataManager.CreateCommand("Menu_GetMenuByUserPermission(@userID:Int,@menuPath:NvarChar)", CommandType.StoredProcedure);
                sqlCommand.Parameters["@menuPath"].Value = newPath;
                sqlCommand.Parameters["@userID"].Value   = userId;

                thingReader = new ThingReader <Menu>(sqlCommand.ExecuteReader(), CustomApply);

                while (thingReader.Read())
                {
                    Menu menu = (Menu)thingReader.Current;

                    if (stackMenu.Count == 0)
                    {
                        stackMenu.Push(menu);
                    }
                    else if (menu.Path.StartsWith(stackMenu.Peek().Path))
                    {
                        stackMenu.Peek().ChildItems.Add(menu);
                        stackMenu.Push(menu);
                    }
                    else
                    {
                        while (stackMenu.Count != 1 && !menu.Path.StartsWith(stackMenu.Peek().Path))
                        {
                            stackMenu.Pop();
                        }
                        if (!menu.Path.StartsWith(stackMenu.Peek().Path))
                        {
                            returnObject.Add(stackMenu.Pop());
                            stackMenu.Push(menu);
                        }
                        else
                        {
                            stackMenu.Peek().ChildItems.Add(menu);
                            stackMenu.Push(menu);                             //bug 157 it was with comment
                        }
                    }
                }
            }
            //stackMenu.Pop();
            while (stackMenu.Count > 1)
            {
                stackMenu.Pop();
            }
            if (stackMenu.Count > 0)
            {
                returnObject.Add(stackMenu.Pop());
            }

            returnObject = Order(returnObject);

            return(returnObject);
        }