Exemple #1
0
        public static DBtblUserCollection GetAllItem()
        {
            string key  = SETTINGS_ALL_KEY;
            object obj2 = dtpCache.Get(key);

            if ((obj2 != null))
            {
                return((DBtblUserCollection)obj2);
            }
            DBtblUserCollection ItemCollection = new DBtblUserCollection();
            Database            db             = SqlHelper.CreateConnection(SqlHelper.MyConnection);
            DbCommand           dbCommand      = db.GetStoredProcCommand("dtp_tblUser_GetAll");

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    DBtblUser item = GetItemFromReader(dataReader);
                    ItemCollection.Add(item);
                }
            }

            dtpCache.Max(key, ItemCollection);

            return(ItemCollection);
        }
Exemple #2
0
        private static DBtblUser GetItemFromReader(IDataReader dataReader)
        {
            DBtblUser objItem = new DBtblUser();

            objItem.UserID = SqlHelper.GetInt(dataReader, "UserID");

            objItem.Name = SqlHelper.GetString(dataReader, "Name");

            objItem.Username = SqlHelper.GetString(dataReader, "Username");

            objItem.Address = SqlHelper.GetString(dataReader, "Address");

            objItem.Birthday = SqlHelper.GetDateTime(dataReader, "Birthday");

            objItem.Email = SqlHelper.GetString(dataReader, "Email");

            objItem.password = SqlHelper.GetString(dataReader, "password");

            objItem.Website = SqlHelper.GetString(dataReader, "Website");

            objItem.CreatedDate = SqlHelper.GetDateTime(dataReader, "CreatedDate");

            objItem.Sex = SqlHelper.GetBoolean(dataReader, "Sex");

            objItem.Active = SqlHelper.GetBoolean(dataReader, "Active");

            objItem.ImgUrl = SqlHelper.GetString(dataReader, "ImgUrl");

            objItem.SaltKey = SqlHelper.GetString(dataReader, "SaltKey");
            return(objItem);
        }
Exemple #3
0
        public static DBtblUser GetItemByID(Int64 UserID)
        {
            string key  = String.Format(SETTINGS_ID_KEY, UserID);
            object obj2 = dtpCache.Get(key);

            if (obj2 != null)
            {
                return((DBtblUser)obj2);
            }


            DBtblUser item      = null;
            Database  db        = SqlHelper.CreateConnection(SqlHelper.MyConnection);
            DbCommand dbCommand = db.GetStoredProcCommand("tblUser_GetByID");

            db.AddInParameter(dbCommand, "UserID", DbType.Int64, UserID);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    item = GetItemFromReader(dataReader);
                }
            }
            dtpCache.Max(key, item);
            return(item);
        }
Exemple #4
0
        public static int DeleteItem(int ItemId)
        {
            Database  db        = SqlHelper.CreateConnection(SqlHelper.MyConnection);
            DbCommand dbCommand = db.GetStoredProcCommand("tblUser_Delete");

            db.AddInParameter(dbCommand, "UserID", DbType.Int32, ItemId);
            DBtblUser item = GetItemByID(ItemId);

            if (item != null)
            {
                RemoveCache(item);
            }
            return(db.ExecuteNonQuery(dbCommand));
        }
Exemple #5
0
        public static DBtblUser GetItemByEmailOrUser(string UsOrEmail)
        {
            DBtblUser item      = null;
            Database  db        = SqlHelper.CreateConnection(SqlHelper.MyConnection);
            DbCommand dbCommand = db.GetStoredProcCommand("dtp_tblUser_ByEmailOrUserName");

            db.AddInParameter(dbCommand, "UsOrEmail", DbType.String, UsOrEmail);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    item = GetItemFromReader(dataReader);
                }
            }
            return(item);
        }
Exemple #6
0
        public static DBtblUser GetItemByEmail(string email, string password)
        {
            DBtblUser item      = null;
            Database  db        = SqlHelper.CreateConnection(SqlHelper.MyConnection);
            DbCommand dbCommand = db.GetStoredProcCommand("tblUser_GetByemail");

            db.AddInParameter(dbCommand, "Email", DbType.String, email);
            db.AddInParameter(dbCommand, "password", DbType.String, password);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    item = GetItemFromReader(dataReader);
                }
            }
            return(item);
        }
Exemple #7
0
        public static DBtblUser AddItem(string Name, string Username, string Address, DateTime Birthday, string Email, string password, string Website, DateTime CreatedDate, bool Sex, bool Active, string ImgUrl, string SaltKey)
        {
            DBtblUser item      = null;
            Database  db        = SqlHelper.CreateConnection(SqlHelper.MyConnection);
            DbCommand dbCommand = db.GetStoredProcCommand("tblUser_Add");

            db.AddOutParameter(dbCommand, "UserID", DbType.Int64, 0);

            db.AddInParameter(dbCommand, "Name", DbType.String, Name);

            db.AddInParameter(dbCommand, "Username", DbType.String, Username);

            db.AddInParameter(dbCommand, "Address", DbType.String, Address);

            db.AddInParameter(dbCommand, "Birthday", DbType.DateTime, Birthday);

            db.AddInParameter(dbCommand, "Email", DbType.String, Email);

            db.AddInParameter(dbCommand, "password", DbType.String, password);

            db.AddInParameter(dbCommand, "Website", DbType.String, Website);

            db.AddInParameter(dbCommand, "CreatedDate", DbType.DateTime, CreatedDate);

            db.AddInParameter(dbCommand, "Sex", DbType.Boolean, Sex);

            db.AddInParameter(dbCommand, "Active", DbType.Boolean, Active);

            db.AddInParameter(dbCommand, "ImgUrl", DbType.String, ImgUrl);

            db.AddInParameter(dbCommand, "SaltKey", DbType.String, SaltKey);
            if (db.ExecuteNonQuery(dbCommand) > 0)
            {
                int itemID = Convert.ToInt32(db.GetParameterValue(dbCommand, "@UserID"));
                item = GetItemByID(itemID);

                if (item != null)
                {
                    RemoveCache(item);
                }
            }
            return(item);
        }
Exemple #8
0
        public static DBtblUser Login(string email, string Password, bool isCookie)
        {
            DBtblUser customer = GetItemByEmailOrUser(email);

            if (customer != null)
            {
                string passwordHash = CreatePasswordHash(Password, customer.SaltKey);
                bool   result       = customer.password.Equals(passwordHash);
                if (result)
                {
                    return(customer);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Exemple #9
0
        public static DBtblUserCollection GetItemPagging(int page, int rec, string strSearch, out int TotalRecords)
        {
            TotalRecords = 0;
            DBtblUserCollection ItemCollection = new DBtblUserCollection();
            Database            db             = SqlHelper.CreateConnection(SqlHelper.MyConnection);
            DbCommand           dbCommand      = db.GetStoredProcCommand("tblUser_Paging");

            db.AddInParameter(dbCommand, "Page", DbType.Int32, page);
            db.AddInParameter(dbCommand, "RecsPerPage", DbType.Int32, rec);
            db.AddInParameter(dbCommand, "SearchValue", DbType.String, strSearch);
            db.AddOutParameter(dbCommand, "TotalRecords", DbType.Int32, 0);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    DBtblUser item = GetItemFromReader(dataReader);
                    ItemCollection.Add(item);
                }
            }
            TotalRecords = Convert.ToInt32(db.GetParameterValue(dbCommand, "@TotalRecords"));
            return(ItemCollection);
        }
Exemple #10
0
 private static void RemoveCache(DBtblUser objItem)
 {
     dtpCache.RemoveByPattern(SETTINGS_ALL_KEY);
     dtpCache.RemoveByPattern(string.Format(SETTINGS_ID_KEY, objItem.UserID));
 }
Exemple #11
0
        public static DBgl_Workflow AddItem(int WStatus,
                                            DateTime CreatedDate,
                                            string CreatedUser,
                                            bool Published,
                                            string WorkflowName,
                                            string SmallDesc,
                                            DateTime FromDate,
                                            DateTime ToDate, decimal BudgetAmt, decimal ReceiveAmt, decimal PaymentAmnt, decimal CashOnHandAmt, int Members,
                                            bool isClose, int Ratting, string ImgUrl, int SharingType)
        {
            DBgl_Workflow item      = null;
            Database      db        = SqlHelper.CreateConnection(SqlHelper.MyConnection);
            DbCommand     dbCommand = db.GetStoredProcCommand("gl_Workflow_Add");

            db.AddOutParameter(dbCommand, "WorkflowID", DbType.Guid, 0);

            db.AddInParameter(dbCommand, "WStatus", DbType.Int32, WStatus);

            db.AddInParameter(dbCommand, "CreatedDate", DbType.DateTime, CreatedDate);

            db.AddInParameter(dbCommand, "CreatedUser", DbType.String, CreatedUser);

            db.AddInParameter(dbCommand, "Published", DbType.Boolean, Published);

            db.AddInParameter(dbCommand, "WorkflowName", DbType.String, HtmlTag.Strip(WorkflowName));

            db.AddInParameter(dbCommand, "SmallDesc", DbType.String, SmallDesc);

            db.AddInParameter(dbCommand, "FromDate", DbType.DateTime, FromDate);

            db.AddInParameter(dbCommand, "ToDate", DbType.DateTime, ToDate);
            db.AddInParameter(dbCommand, "BudgetAmt", DbType.Decimal, BudgetAmt);

            db.AddInParameter(dbCommand, "ReceiveAmt", DbType.Decimal, ReceiveAmt);

            db.AddInParameter(dbCommand, "PaymentAmnt", DbType.Decimal, PaymentAmnt);

            db.AddInParameter(dbCommand, "CashOnHandAmt", DbType.Decimal, CashOnHandAmt);
            db.AddInParameter(dbCommand, "Members", DbType.Int32, Members);

            db.AddInParameter(dbCommand, "isClose", DbType.Boolean, isClose);

            db.AddInParameter(dbCommand, "Ratting", DbType.Int32, Ratting);

            db.AddInParameter(dbCommand, "ImgUrl", DbType.String, ImgUrl);
            db.AddInParameter(dbCommand, "SharingType", DbType.Int32, SharingType);
            if (db.ExecuteNonQuery(dbCommand) > 0)
            {
                Guid itemID = (Guid)(db.GetParameterValue(dbCommand, "@WorkflowID"));
                item = GetItemByID(itemID);
                if (item != null)
                {
                    //add this user to Friend Request
                    DBtblUser          objUser    = DBtblUserManager.GetItemByUser(CreatedUser);
                    DBgl_FriendRequest objRequest = DBgl_FriendRequestManager.AddItem(objUser.Username, objUser.Username,
                                                                                      objUser.Email, Guid.NewGuid(), DateTime.Now,
                                                                                      objUser.Username, item.WorkflowID, true, true, false, 0, 0, "", (int)FriendRequestEnum.gl_Invited);
                    //UPdate USerInfo Legs
                    DBgl_UserInfo objInfo = DBgl_UserInfoManager.GetItemByUserName(CreatedUser);
                    if (objInfo != null)
                    {
                        int joinlegs    = objInfo.MyLegs + 1;
                        int myenjoyLegs = objInfo.EnjoyLegs + 1;
                        objInfo = DBgl_UserInfoManager.UpdateItem(objInfo.UserInfId, objInfo.UserId,
                                                                  objInfo.UserName, objInfo.CreatedDate, objInfo.Mobile, objInfo.CountryId, objInfo.LocationId, objInfo.Address,
                                                                  objInfo.Rating, joinlegs, myenjoyLegs, objInfo.Sex, objInfo.createdUser);
                    }
                    RemoveCache(item);
                }
            }
            return(item);
        }