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)");
        }
        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());
        }
        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);
        }
        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);
        }
        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);
        }
        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);
        }
        public void DeleteRefund()
        {
            string        command       = "SP_Delete_Refund_per_Account(@AccountID:Int,@ChannelID:Int,@Month:datetime)";
            SqlConnection sqlConnection = new SqlConnection(AppSettings.Get(string.Empty, "DWH.ConnectionString").ToString());

            sqlConnection.Open();
            MapperUtility.SaveOrRemoveSimpleObject <Refund>(command, System.Data.CommandType.StoredProcedure, SqlOperation.Insert, this, sqlConnection, null);
        }
Beispiel #8
0
        public void AddRefund()
        {
            string        command       = "SP_Add_Refund_per_Account(@AccountID:Int,@ChannelID:Int,@Month:datetime, @RefundAmount:decimal)";
            SqlConnection sqlConnection = new SqlConnection(AppSettings.GetAbsolute("DWH.ConnectionString").ToString());

            sqlConnection.Open();
            MapperUtility.SaveOrRemoveSimpleObject <Refund>(command, System.Data.CommandType.StoredProcedure, SqlOperation.Insert, this, sqlConnection, null);
        }
        public int UserOperations(SqlOperation sqlOperation)
        {
            SqlTransaction sqlTransaction = null;
            int            returnValue    = -1;

            try
            {
                //Insert/Update/Remove user (also this clean all permissions and assigned groups)
                string        command       = @"User_Operations(@Action:Int,@UserID:Int,@Name:NvarChar,@IsActive:bit,@AccountAdmin:bit,@Email:NvarChar,@Password:NvarChar)";
                SqlConnection sqlConnection = new SqlConnection(DataManager.ConnectionString);
                sqlConnection.Open();
                sqlTransaction = sqlConnection.BeginTransaction("SaveUser");
                returnValue    = this.UserID = Convert.ToInt32(MapperUtility.SaveOrRemoveSimpleObject <User>(command, CommandType.StoredProcedure, sqlOperation, this, sqlConnection, sqlTransaction));

                //insert the new permission
                foreach (KeyValuePair <int, List <AssignedPermission> > assignedPermissionPerAccount in this.AssignedPermissions)
                {
                    foreach (AssignedPermission assignedPermission in assignedPermissionPerAccount.Value)
                    {
                        SqlCommand sqlCommand = DataManager.CreateCommand("Permissions_Operations(@AccountID:Int,@TargetID:Int,@TargetIsGroup:Bit,@PermissionType:NvarChar,@Value:Bit)", CommandType.StoredProcedure);
                        sqlCommand.Connection  = sqlConnection;
                        sqlCommand.Transaction = sqlTransaction;
                        sqlCommand.Parameters["@AccountID"].Value      = assignedPermissionPerAccount.Key;
                        sqlCommand.Parameters["@TargetID"].Value       = this.UserID;
                        sqlCommand.Parameters["@TargetIsGroup"].Value  = 0;
                        sqlCommand.Parameters["@PermissionType"].Value = assignedPermission.PermissionType;
                        sqlCommand.Parameters["@Value"].Value          = assignedPermission.Value;
                        sqlCommand.ExecuteNonQuery();
                    }
                }

                foreach (Group group in this.AssignedToGroups)
                {
                    SqlCommand sqlCommand = DataManager.CreateCommand(@"INSERT INTO User_GUI_UserGroupUser
																	(GroupID,UserID)
																	VALUES
																	(@GroupID:Int,@UserID:Int)"                                                                    );
                    sqlCommand.Parameters["@GroupID"].Value = group.GroupID;
                    sqlCommand.Parameters["@UserID"].Value  = this.UserID;
                    sqlCommand.Connection  = sqlConnection;
                    sqlCommand.Transaction = sqlTransaction;
                    sqlCommand.ExecuteNonQuery();
                }

                sqlTransaction.Commit();
            }
            catch (Exception ex)
            {
                if (sqlTransaction != null)
                {
                    sqlTransaction.Rollback();
                }
                throw ex;
            }
            return(returnValue);
        }
Beispiel #10
0
        public static void Update(List <CampaignStatusSchedule> campaignStatusSchedules)
        {
            string         command;
            SqlTransaction sqlTransaction = null;
            SqlConnection  sqlConnection  = new SqlConnection(DataManager.ConnectionString);

            sqlConnection.Open();
            sqlTransaction = sqlConnection.BeginTransaction("Schedule");
            command        = "DELETE FROM Campaigns_Scheduling WHERE Campaign_GK=@Campaign_GK:int";
            MapperUtility.SaveOrRemoveSimpleObject <CampaignStatusSchedule>(command, System.Data.CommandType.Text, SqlOperation.Delete, campaignStatusSchedules[0], sqlConnection, sqlTransaction);
            command = @"CampaignStatusSchedule_Insert(@Action:Int,@Account_ID:int,
           @Campaign_GK:int,
           @Channel_ID:int,
           @Day:int,
           @Hour00:int,
           @Hour01:int,
           @Hour02:int,
           @Hour03:int,
           @Hour04:int,
           @Hour05:int,
           @Hour06:int,
           @Hour07:int,
           @Hour08:int,
           @Hour09:int,
           @Hour10:int,
           @Hour11:int,
           @Hour12:int,
           @Hour13:int,
           @Hour14:int,
           @Hour15:int,
           @Hour16:int,
           @Hour17:int,
           @Hour18:int,
           @Hour19:int,
           @Hour20:int,
           @Hour21:int,
           @Hour22:int,
           @Hour23:int)";
            foreach (CampaignStatusSchedule campaignStatusSchedule in campaignStatusSchedules)
            {
                MapperUtility.SaveOrRemoveSimpleObject <CampaignStatusSchedule>(command, System.Data.CommandType.StoredProcedure, SqlOperation.Update, campaignStatusSchedule, sqlConnection, sqlTransaction);
            }
            command = @"UPDATE UserProcess_GUI_PaidCampaign
						SET ScheduleEnabled=@ScheduleEnabled:bit
						WHERE Campaign_GK= @Campaign_GK:int"                        ;
            ;
            MapperUtility.SaveOrRemoveSimpleObject <CampaignStatusSchedule>(command, System.Data.CommandType.Text, SqlOperation.Update, campaignStatusSchedules[0], sqlConnection, sqlTransaction);
            sqlTransaction.Commit();
        }
        public bool Read()
        {
            bool hasData = _reader.Read();

            if (hasData)
            {
                _current = new ThingT();



                _current = MapperUtility.CreateMainObject <ThingT>(_reader, _onApplyValue);
            }

            return(hasData);
        }