Ejemplo n.º 1
0
    public void AddFriendByLongCodeF(UserRegistrationBLL ur, string userMobileWhoSendFriendReq, int grid)
    {//Mahesh: Use second parameter mobile for only send sms only, because at run time mobile number of sender change.
        try
        {
            string sender  = "";
            string joiner  = "";
            bool   JoinAll = false;
            string flagMob = ur.usrAltMobileNo;
            status = urRegistBll.BLLIsExistUserRegistrationInitial(ur);
            if (status == 0)
            {
                status = urRegistBll.BLLIsExistUserRegistrationInitialByLc(ur);
                if (status == 0)
                {
                    string sqlFlagStr = "select JoinFlag from userMaster where usrMobileNo='" + flagMob.ToString() + "'";
                    int    jof        = Convert.ToInt32(cc.ExecuteScalar(sqlFlagStr));
                    if (jof > 1)
                    {
                        JoinAll         = true;
                        ur.JoinFlagProp = Convert.ToString(jof);
                    }
                    //DataTable dt1 = new DataTable();
                    string  sql = "select usrUserId, usrFirstName,usrCityId from UserMaster where usrMobileNo='" + ur.usrMobileNo + "'";
                    DataSet ds  = new DataSet();
                    ds = cc.ExecuteDataset(sql);
                    //dt1 = ds.Tables[0];
                    string userId;
                    string usrName = "";
                    int    cityId;
                    foreach (DataRow dr1 in ds.Tables[0].Rows)
                    {
                        userId            = Convert.ToString(dr1["usrUserId"]);
                        usrName           = Convert.ToString(dr1["usrFirstName"]);
                        cityId            = Convert.ToInt32(dr1["usrCityId"]);
                        ur.frnrelFriendId = userId;
                        ur.usrCityId      = cityId;
                        joiner            = Convert.ToString(usrName);
                        //ur.frnrelFrnRelName = usrName;
                        //ur.frnrelRelation = "friend";
                        //ur.frnrelGroup = "1";
                    }
                    string  sql1 = "select usrUserId, usrFirstName from UserMaster where usrMobileNo='" + ur.usrAltMobileNo + "'";
                    DataSet ds1  = new DataSet();
                    ds1 = cc.ExecuteDataset(sql1);
                    //dt1 = ds.Tables[0];
                    string FriId;
                    string FriName;
                    foreach (DataRow dr2 in ds1.Tables[0].Rows)
                    {
                        FriId               = Convert.ToString(dr2["usrUserId"]);
                        FriName             = Convert.ToString(dr2["usrFirstName"]);
                        ur.frnrelUserId     = FriId;
                        ur.frnrelFrnRelName = FriName;
                        ur.frnrelRelation   = "friend";
                        sender              = Convert.ToString(FriName);
                        //ur.frnrelGroup = "1";
                        //status = ur.BLLInsertUserFriendRelative(ur);
                        ur.frnrelGroup = Convert.ToString(grid);
                    }

                    status = ur.BLLInsertUserFriendRelative(ur);
                    if (status > 0)
                    {
                        string SendTo   = ur.usrAltMobileNo;
                        string sendFrom = ur.usrMobileNo;
                        string message  = "I " + usrName + "(" + sendFrom.ToString() + ") added u in www.myct.in to send SMS." + cc.AddSMS(SendTo);

                        cc.SendMessage1(sendFrom, SendTo, message);
                        if (JoinAll == true)
                        {
                            string resJoinAll = "Thanks " + joiner.ToString() + ", I " + sender.ToString() + "( " + SendTo.ToString() + " ) also added u on www.myct.in " + cc.AddSMS(sendFrom);
                            cc.SendMessage1(SendTo, sendFrom, resJoinAll);
                        }
                        string changeFlagSql = "update come2mycity.test set FlagStatus = 0 where PK=" + Convert.ToInt32(ur.usrPKval);
                        int    pkchange      = 0;
                        pkchange = cc.ExecuteNonQuery(changeFlagSql);
                        if (pkchange == 0)
                        {
                            pkchange = cc.ExecuteNonQuery(changeFlagSql);
                        }
                    }
                    else
                    {
                        string SendTo   = ur.usrAltMobileNo;
                        string sendFrom = ur.usrMobileNo;
                        string message  = "Dear " + joiner.ToString() + " u already added " + sender.ToString() + " in www.myct.in to send SMS." + cc.AddSMS(sendFrom);

                        cc.SendMessage1(SendTo, sendFrom, message);

                        string changeFlagSql = "update come2mycity.test set FlagStatus = 0 where PK=" + Convert.ToInt32(ur.usrPKval);
                        int    pkchange      = 0;
                        pkchange = cc.ExecuteNonQuery(changeFlagSql);
                        if (pkchange == 0)
                        {
                            pkchange = cc.ExecuteNonQuery(changeFlagSql);
                        }
                    }
                }
                else
                {
                    string  sql3 = "select usrUserId, usrFirstName,usrCityId from UserMaster where usrMobileNo='" + ur.usrMobileNo + "'";
                    DataSet ds   = new DataSet();
                    ds = cc.ExecuteDataset(sql3);
                    //dt1 = ds.Tables[0];
                    string userId;
                    flagMob = ur.usrAltMobileNo;
                    string usrName  = "";
                    int    cityId   = 0;
                    string cityName = "";
                    foreach (DataRow dr1 in ds.Tables[0].Rows)
                    {
                        userId          = Convert.ToString(dr1["usrUserId"]);
                        usrName         = Convert.ToString(dr1["usrFirstName"]);
                        cityId          = Convert.ToInt32(dr1["usrCityId"]);
                        ur.frnrelUserId = userId;
                        ur.usrCityId    = cityId;
                        joiner          = Convert.ToString(usrName);
                        //ur.frnrelFrnRelName = usrName;
                        //ur.frnrelRelation = "friend";
                        //ur.frnrelGroup = "1";
                    }
                    string sqlFlagStr = "select JoinFlag from userMaster where usrMobileNo='" + flagMob.ToString() + "'";
                    int    jof        = Convert.ToInt32(cc.ExecuteScalar(sqlFlagStr));
                    if (jof >= 1)
                    {
                        JoinAll         = true;
                        ur.JoinFlagProp = Convert.ToString(jof);
                    }
                    string sqlquery = "select cityName from CityMaster where cityId='" + Convert.ToString(cityId) + "'";
                    cityName = cc.ExecuteScalar(sqlquery);

                    urRegistBll.usrUserId = System.Guid.NewGuid().ToString();

                    ur.usrMobileNo = ur.usrAltMobileNo;

                    ur.usrFirstName = ur.frnrelFrnRelName;

                    Random rnd = new Random();
                    urRegistBll.usrPassword = cc.DESEncrypt(Convert.ToString(rnd.Next(10001, 99999)));

                    status = urRegistBll.BLLInsertUserRegistrationInitial(urRegistBll);
                    if (status > 0)
                    {
                        string  sql1 = "select usrUserId, usrFirstName from UserMaster where usrMobileNo='" + ur.usrAltMobileNo + "'";
                        DataSet ds1  = new DataSet();
                        ds1 = cc.ExecuteDataset(sql1);
                        //dt1 = ds.Tables[0];
                        string FriId;
                        string FriName;
                        foreach (DataRow dr2 in ds1.Tables[0].Rows)
                        {
                            FriId               = Convert.ToString(dr2["usrUserId"]);
                            FriName             = Convert.ToString(dr2["usrFirstName"]);
                            ur.frnrelFriendId   = FriId;
                            ur.frnrelFrnRelName = FriName;
                            ur.frnrelRelation   = "friend";
                            ur.frnrelGroup      = Convert.ToString(grid);
                            sender              = Convert.ToString(FriName);
                        }

                        status = ur.BLLInsertUserFriendRelative(ur);
                        if (status > 0)
                        {
                        }
                        string senderId   = userMobileWhoSendFriendReq.ToString();
                        string myMobileNo = urRegistBll.usrMobileNo;
                        string myPassword = cc.DESDecrypt(urRegistBll.usrPassword);
                        string myName     = ur.frnrelFrnRelName;
                        string thisDir    = Server.MapPath("~");

                        if (!System.IO.Directory.Exists(thisDir + "\\User_Resource\\" + ur.usrUserId + "\\Profile_Photo\\"))
                        {
                            System.IO.Directory.CreateDirectory(thisDir + "\\User_Resource\\" + ur.usrUserId + "\\Profile_Photo\\");

                            File.Copy(thisDir + "\\User_Resource\\Profile_Photo\\default_user.jpg", thisDir + "\\User_Resource\\" + ur.usrUserId + "\\Profile_Photo\\default_user.jpg");
                        }

                        //string passwordMessage = "Dear " + myName + ", Password for ur First Login is " + myPassword + " " + cc.AdvMessage();
                        string passwordMessage = "I " + usrName + "(" + senderId.ToString() + ") added u in come2mycity.com. U use it to send SMS.Dear " + myName + ",Password for ur First Login is " + myPassword + " for come2myCity.com";
                        cc.SendMessage1(senderId, myMobileNo, passwordMessage);
                        cc.SendMessageImp1(senderId, myMobileNo, passwordMessage);
                        if (JoinAll == true)
                        {
                            string resJoinAll = "Thanks " + joiner.ToString() + ", I " + sender.ToString() + "( " + myMobileNo.ToString() + " ) also added u on www.myct.in " + cc.AddSMS(senderId);
                            cc.SendMessage1(myMobileNo, senderId, resJoinAll);
                        }
                        string changeFlagSql = "update come2mycity.test set FlagStatus = 0 where PK=" + Convert.ToInt32(ur.usrPKval);
                        int    pkchange      = 0;
                        pkchange = cc.ExecuteNonQuery(changeFlagSql);
                        if (pkchange == 0)
                        {
                            pkchange = cc.ExecuteNonQuery(changeFlagSql);
                        }
                    }
                }
            }
            else
            {
                //NotRegisterMessageForLongCode(urRegistBll);
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }