Пример #1
0
        public DeliveryAddressModel.CustAddress AddAddress(string custid, string fname1, string lname, string tagid1, string Countryid1, string sid, string cid, string addr1, string pinid1, string mobile1, string Email)
        {
            DeliveryAddressModel.CustAddress objadd = new DeliveryAddressModel.CustAddress();
            try
            {
                string Insertdata = "Insert into CustomerAddress ([CustomerId] ,[FirstName] ,[LastName] ,[TagId] ,[CountryId] ,[StateId] ,[CityId] ,[Address] ,[MobileNo] ,[PinCode] ,[DOC] ,[DOM] ,[IsDeleted] ,[IsActive],[Email]) Values ('" + custid + "','" + fname1 + "','" + lname + "','" + tagid1 + "','" + Countryid1 + "','" + sid + "','" + cid + "','" + addr1 + "','" + mobile1 + "','" + pinid1 + "','" + dbc.getindiantime().ToString("dd-MMM-yyyy hh:mm:ss") + "','" + dbc.getindiantime().ToString("dd-MMM-yyyy hh:mm:ss") + "','0','1','" + Email + "')select SCOPE_IDENTITY();";

                string dtdata = dbc.ExecuteSQLScaler(Insertdata).ToString();
                int    idlast = 0;
                int.TryParse(dtdata.ToString(), out idlast);

                if (idlast > 0)
                {
                    objadd.Response = CommonString.successresponse;
                    objadd.Message  = CommonString.successmessage;
                    objadd.LastId   = idlast.ToString();
                }
                else
                {
                    objadd.Response = CommonString.DataNotFoundResponse;
                    objadd.Message  = CommonString.DataNotFoundMessage;
                    objadd.LastId   = "";
                }

                return(objadd);
            }
            catch (Exception ee)
            {
                objadd.Response = CommonString.Errorresponse;
                objadd.Message  = ee.StackTrace;
                return(objadd);
            }
        }
Пример #2
0
    public int SendNotification(string type, string uid, string image, string msg, bool Isoffer, string category, string mobile, string productid, int sendtype)
    {
        SqlConnection connection = new SqlConnection();

        try
        {
            dbConnection dbc = new dbConnection();

            SqlTransaction transaction;
            connection.ConnectionString = dbc.consString;
            connection.Open();
            SqlCommand command = connection.CreateCommand();
            command.CommandTimeout = 1200;
            transaction            = connection.BeginTransaction();
            command.Connection     = connection;
            command.Transaction    = transaction;

            mobile = mobile.Replace("\r\n", ",");
            mobile = mobile.Replace(",,,", ",");
            mobile = mobile.Replace(",,", ",");
            int      sendcount = 0;
            string[] mobarray  = mobile.Split(',');


            string qry = "insert into Taaza_NotificationBatchMaster ([Mesage],[imgurl],[userid],[type],[doc]) values (@msg,@url,@userid,@typ,DATEADD(MINUTE, 330, GETUTCDATE()))";

            command.CommandText = qry;
            command.Parameters.Clear();
            command.Parameters.AddWithValue("@msg", msg);
            command.Parameters.AddWithValue("@url", image);
            command.Parameters.AddWithValue("@userid", uid);
            command.Parameters.AddWithValue("@typ", type);

            int j = command.ExecuteNonQuery();

            if (j > 0)
            {
                string qs2 = "SELECT IDENT_CURRENT('Taaza_NotificationBatchMaster')";

                object objbid = dbc.ExecuteSQLScaler(qs2);
                int    bid    = objbid == null ? 0 : int.Parse(objbid.ToString());

                if (Isoffer == true)
                {
                    int ii = InsertIsOffer(bid, image, msg);
                    if (ii <= 0)
                    {
                        return(0);
                    }
                }

                callImageNotificationService(mobile, bid, type, msg, image, category, productid, sendtype);
                transaction.Commit();
                return(1);
            }
            else
            {
                return(0);
            }
        }
        catch (Exception ex)
        {
            return(0);
        }
        finally
        {
            connection.Close();
        }
    }
    public int StoreNotificationScheduler(string NotificationTo, string SendTo, string Category, string Product, string Message, string MobileNumber, string NotificationType, string ScheduleTime, string exptime, string ImageUrl)
    {
        try
        {
            //string NotificationType = "15";

            int userId = 0;
            int.TryParse(Request.Cookies["TUser"]["Id"], out userId);

            string   ScheduleQuery = "INSERT INTO [dbo].[Sosho_Notification_Schedule] ([NotificationTo],[SendTo],[CategoryId],[ProductId],[ImageUrl],[Message],[NotificationType],[IsSend],[DOC],[DOM],[ExpiredTime],[SendBy],[ScheduleTime],DisplayExpiredTime) VALUES(@1,@2,@3,@4,@5,@6,@7,@8,CONVERT(DATETIME, '" + dbc.getDOCMtime() + "', 102),CONVERT(DATETIME, '" + dbc.getDOCMtime() + "', 102),CONVERT(DATETIME, '" + dbc.getindiantime().AddHours(24).ToString("yyyy-MM-dd HH:mm:ss") + "', 102),@9,'" + ScheduleTime + "','" + exptime + "')";
            string[] parm          = { NotificationTo, SendTo, "0", Product, ImageUrl, Message, Category, "0", userId.ToString() };
            int      rest          = dbc.ExecuteQueryWithParams(ScheduleQuery, parm);
            if (rest > 0)
            {
                string qs2 = "SELECT IDENT_CURRENT('Sosho_Notification_Schedule')";

                object objbid = dbc.ExecuteSQLScaler(qs2);

                int scheduleId = 0;
                int.TryParse(objbid.ToString(), out scheduleId);


                if (scheduleId > 0)
                {
                    if (SendTo.Equals("1"))
                    {
                        string    MobileQuery = "select *,iif(IsIOS = 1,1,0) as DeviceType from (select isnull(deviceid,'') as deviceid, isnull(fcmregistrationid,'') as fcmregistrationid, mobilenumber, [doc], dom, Id, IsIOS, (select top 1 isnull(Id,0) from Customer where Mobile = mobilenumber) as CustomerId from [dbo].[DevicedetailsCustomer] where mobilenumber in (" + MobileNumber + ")) as finalData where CustomerId <> 0 AND deviceid <> '' AND fcmregistrationid <> '' Order by mobilenumber";
                        DataTable dtMob       = dbc.GetDataTable(MobileQuery);

                        if (dtMob.Rows.Count > 0)
                        {
                            for (int i = 0; i < dtMob.Rows.Count; i++)
                            {
                                string InertScheduleDetail = "INSERT INTO [dbo].[Sosho_Notification_Schedule_Detail] ([ScheduleID],[DeviceId],[FCMRegistrationId],[Message],[ResponseId],[Type],[DOC],[Mobile],[isSend],[isSuccess],[delivered],[opentime],[DeviceType],[CustomerId],[ExpiredTime]) VALUES (@1,@2,@3,@4,'',@5,CONVERT(DATETIME, '" + dbc.getDOCMtime() + "', 102),@6,0,0,'','',@7,@8,@9)";

                                string[] parmdata = { scheduleId.ToString(), dtMob.Rows[i]["deviceid"].ToString(), dtMob.Rows[i]["fcmregistrationid"].ToString(), Message, NotificationType, dtMob.Rows[i]["mobilenumber"].ToString(), dtMob.Rows[i]["DeviceType"].ToString(), dtMob.Rows[i]["CustomerId"].ToString(), exptime };

                                int restdet = dbc.ExecuteQueryWithParams(InertScheduleDetail, parmdata);
                            }
                            return(1);
                        }
                        else
                        {
                            return(0);
                        }
                    }
                    else
                    {
                        return(1); // Send To All Mobile Details Store Via Scheduler
                    }
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                return(0);
            }
        }
        catch (Exception ex)
        {
            return(-1);
        }
    }