Beispiel #1
0
        private static DBgl_FriendRequest GetItemFromReader(IDataReader dataReader)
        {
            DBgl_FriendRequest objItem = new DBgl_FriendRequest();

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

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

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

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

            objItem.requesttoken = SqlHelper.GetGuid(dataReader, "requesttoken");

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

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

            objItem.WorkflowId = SqlHelper.GetGuid(dataReader, "WorkflowId");

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

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

            objItem.isCancel  = SqlHelper.GetBoolean(dataReader, "isCancel");
            objItem.BudgetAmt = SqlHelper.GetDecimal(dataReader, "BudgetAmt");

            objItem.ReceivedAmt = SqlHelper.GetDecimal(dataReader, "ReceivedAmt");
            objItem.comment     = SqlHelper.GetString(dataReader, "comment");

            objItem.RType = SqlHelper.GetInt(dataReader, "RType");
            return(objItem);
        }
Beispiel #2
0
        public static DBgl_FriendRequestCollection GetAllItemFromUser(string fromUser)
        {
            string key  = string.Format(SETTINGS_ALL_FrmUser_KEY, fromUser);
            object obj2 = dtpCache.Get(key);

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

            db.AddInParameter(dbCommand, "FromUser", DbType.String, fromUser);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    DBgl_FriendRequest item = GetItemFromReader(dataReader);
                    ItemCollection.Add(item);
                }
            }

            dtpCache.Max(key, ItemCollection);

            return(ItemCollection);
        }
Beispiel #3
0
        public static DBgl_FriendRequestCollection GetAllItem()
        {
            string key  = SETTINGS_ALL_KEY;
            object obj2 = dtpCache.Get(key);

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

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

            dtpCache.Max(key, ItemCollection);

            return(ItemCollection);
        }
Beispiel #4
0
        public static DBgl_FriendRequest GetItemByWorkflowId_UserOrEmail(string Email, string UserName, Guid WorkflowId)
        {
            string key  = String.Format(SETTINGS_Email_User_KEY, Email, UserName, WorkflowId);
            object obj2 = dtpCache.Get(key);

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


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

            db.AddInParameter(dbCommand, "toUser", DbType.String, UserName);
            db.AddInParameter(dbCommand, "Email", DbType.String, Email);
            db.AddInParameter(dbCommand, "WorkflowId", DbType.Guid, WorkflowId);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    item = GetItemFromReader(dataReader);
                }
            }
            dtpCache.Max(key, item);
            return(item);
        }
Beispiel #5
0
        public static DBgl_FriendRequestCollection GetAllItemByWfId(Guid WorkflowId)
        {
            string key  = String.Format(SETTINGS_WorkflowId_KEY, WorkflowId);
            object obj2 = dtpCache.Get(key);

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

            db.AddInParameter(dbCommand, "WorkflowID", DbType.Guid, WorkflowId);

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

            dtpCache.Max(key, ItemCollection);

            return(ItemCollection);
        }
Beispiel #6
0
        public static DBgl_FriendRequest GetItemByID(Int64 RequestId)
        {
            string key  = String.Format(SETTINGS_ID_KEY, RequestId);
            object obj2 = dtpCache.Get(key);

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


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

            db.AddInParameter(dbCommand, "RequestId", DbType.Int64, RequestId);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    item = GetItemFromReader(dataReader);
                }
            }
            dtpCache.Max(key, item);
            return(item);
        }
Beispiel #7
0
 private static void RemoveCache(DBgl_FriendRequest objItem)
 {
     dtpCache.RemoveByPattern(SETTINGS_ALL_KEY);
     dtpCache.RemoveByPattern(string.Format(SETTINGS_ID_KEY, objItem.RequestId));
     dtpCache.RemoveByPattern(string.Format(SETTINGS_ALL_toUser_KEY, objItem.toUser));
     dtpCache.RemoveByPattern(string.Format(SETTINGS_ALL_FrmUser_KEY, objItem.FromUser));
     dtpCache.RemoveByPattern(string.Format(SETTINGS_WorkflowId_KEY, objItem.WorkflowId));
     dtpCache.RemoveByPattern(string.Format(SETTINGS_Approve_WorkflowId_KEY, objItem.WorkflowId));
     dtpCache.RemoveByPattern(string.Format(SETTINGS_Email_User_KEY, objItem.Email, objItem.toUser, objItem.WorkflowId));
 }
Beispiel #8
0
        public int DeleteItem(Int64 itemID)
        {
            Database  db        = SqlHelper.CreateConnection(SqlHelper.MyConnection);
            DbCommand dbCommand = db.GetStoredProcCommand("HBankRate_Delete");

            db.AddInParameter(dbCommand, "HouseRateID", DbType.Int64, itemID);
            DBgl_FriendRequest objItem = DBgl_FriendRequestManager.GetItemByID(itemID);

            //if (objItem != null) { RemoveCache(objItem); };
            return(db.ExecuteNonQuery(dbCommand));
            // return DataHelper.ExecuteNonQuery("", itemID);
        }
Beispiel #9
0
        public static int DeleteItem(int ItemId)
        {
            Database  db        = SqlHelper.CreateConnection(SqlHelper.MyConnection);
            DbCommand dbCommand = db.GetStoredProcCommand("gl_FriendRequest_Delete");

            db.AddInParameter(dbCommand, "RequestId", DbType.Int32, ItemId);
            DBgl_FriendRequest objItem = DBgl_FriendRequestManager.GetItemByID(ItemId);

            if (objItem != null)
            {
                RemoveCache(objItem);
            }
            ;
            return(db.ExecuteNonQuery(dbCommand));
        }
Beispiel #10
0
        public static DBgl_FriendRequest GetUserInRequestList(Guid WorkflowId, Guid RequestTokenId)
        {
            DBgl_FriendRequest           objItem = null;
            DBgl_FriendRequestCollection objcol  = DBgl_FriendRequestManager.GetAllItemByWfId(WorkflowId);

            for (int i = 0; i < objcol.Count; i++)
            {
                if (objcol[i].requesttoken == RequestTokenId)
                {
                    objItem = objcol[i];
                    break;
                }
            }
            return(objItem);
        }
Beispiel #11
0
        public static DBgl_FriendRequest AddItem(string FromUser, string toUser, string Email,
                                                 Guid requesttoken, DateTime createdDate, string createdUser, Guid WorkflowId, bool isClick,
                                                 bool IsApprove, bool isCancel, decimal BudgetAmt, decimal ReceivedAmt, string comment, int RType)
        {
            DBgl_FriendRequest item      = null;
            Database           db        = SqlHelper.CreateConnection(SqlHelper.MyConnection);
            DbCommand          dbCommand = db.GetStoredProcCommand("gl_FriendRequest_Add");

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

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

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

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

            db.AddInParameter(dbCommand, "requesttoken", DbType.Guid, requesttoken);

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

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

            db.AddInParameter(dbCommand, "WorkflowId", DbType.Guid, WorkflowId);

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

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

            db.AddInParameter(dbCommand, "isCancel", DbType.Boolean, isCancel);
            db.AddInParameter(dbCommand, "BudgetAmt", DbType.Decimal, BudgetAmt);

            db.AddInParameter(dbCommand, "ReceivedAmt", DbType.Decimal, ReceivedAmt);
            db.AddInParameter(dbCommand, "comment", DbType.String, comment);

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

                if (item != null)
                {
                    RemoveCache(item);
                }
            }
            return(item);
        }
Beispiel #12
0
        public static DBgl_FriendRequestCollection GetItemPagging(int page, int rec, string strSearch, out int TotalRecords)
        {
            TotalRecords = 0;
            DBgl_FriendRequestCollection ItemCollection = new DBgl_FriendRequestCollection();
            Database  db        = SqlHelper.CreateConnection(SqlHelper.MyConnection);
            DbCommand dbCommand = db.GetStoredProcCommand("gl_FriendRequest_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())
                {
                    DBgl_FriendRequest item = GetItemFromReader(dataReader);
                    ItemCollection.Add(item);
                }
            }
            TotalRecords = Convert.ToInt32(db.GetParameterValue(dbCommand, "@TotalRecords"));
            return(ItemCollection);
        }
Beispiel #13
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);
        }