Beispiel #1
0
        /// <summary>
        /// Use this method to Import your data in Shop Application,
        /// Below are the required fields,
        /// Name, Year, Make, Model, Mobile, Email
        /// </summary>
        /// <param name="strUserName"></param>
        /// <param name="strPassword"></param>
        /// <param name="objImportData"></param>
        /// <returns></returns>
        public String ImportData(String strUserName, String strPassword, ImportData objImportData)
        {
            SummitShopApp.Utility.CommonFunctions.LoggingForImportStatus(Constants.IMPORTDATA_CALLED + strUserName);
            Int32 iShopId = 0;

            if (ValidateUser(strUserName, strPassword, out iShopId))
            {
                BodyShopBL objBodyShopBL = BodyShopBL.getShopById(iShopId);
                if (objBodyShopBL != null && objImportData != null)
                {
                    String ErrorCode = String.Empty;
                    ErrorCode = ValidateData(objImportData);
                    //Add values in particular table
                    if (!ErrorCode.Contains(Constants.ERROR))
                    {
                        SaveData(Convert.ToString(iShopId), objImportData);
                        return(Constants.SUCCESS);
                    }
                    else
                    {
                        throw new FaultException(ErrorCode);
                    }
                }
                throw new FaultException(Constants.ERROR_NOBODYSHOP_FOUND);
            }
            return(Constants.ERROR_CREDENTIALS);
        }
Beispiel #2
0
        /// <summary>
        /// Validate User and get ShopId for that user
        /// </summary>
        /// <param name="strUserName"></param>
        /// <param name="strPassword"></param>
        /// <param name="iShopId"></param>
        /// <returns></returns>
        public Boolean ValidateUser(String strUserName, String strPassword, out Int32 iShopId)
        {
            iShopId = 0;
            LoginBL    thisUser    = LoginBL.getByUserName(strUserName);
            BodyShopBL objBodyShop = null;

            strPassword = Security.encode(strPassword);
            if (thisUser != null)
            {
                if (Security.decode(thisUser.strPassword) == Security.decode(strPassword))
                {
                    if (thisUser.iRoleID == Constants.OWNER)
                    {
                        objBodyShop = BodyShopBL.getShopById(Convert.ToInt32(thisUser.iShopID));
                        if (objBodyShop != null)
                        {
                            iShopId = objBodyShop.ID;
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Beispiel #3
0
        //This method is use to send sms from admin user
        public Boolean SendSMS(String strMobileNumber, String strMessageBody, Int32 iToUserId, FromAppSection eFromSection, Int32 iShopId)
        {
            Boolean bSent = false;

            //Check available message of shop
            BodyShopBL objBodyShop = BodyShopBL.getShopById(iShopId);

            if ((objBodyShop == null && objBodyShop.iAvailableMessages == null) || (objBodyShop.iAvailableMessages - (objBodyShop.iMessageCount == null ? 0 : objBodyShop.iMessageCount) <= 0))
            {
                return(false);
            }

            //System.Threading.Thread.Sleep(10000);

            if (SendSMS(strMobileNumber, strMessageBody, objBodyShop.strShopName, iToUserId))
            {
                bSent = true;

                //Update body Shop message count
                if (objBodyShop.iMessageCount == null)
                {
                    objBodyShop.iMessageCount = 1;
                }
                else
                {
                    objBodyShop.iMessageCount += 1;
                }

                CommunicationHistoryBL objComHistory = new CommunicationHistoryBL();
                objComHistory.iUserId = iToUserId;
                objComHistory.iShopId = iShopId;
                objComHistory.iCommunicationTypeId = 1;
                objComHistory.dtCreatedDate        = DateTime.Now;
                objComHistory.strMessageText       = strMessageBody;
                objComHistory.strPhone             = strMobileNumber;
                objComHistory.iFromAppSection      = (Int32)eFromSection;
                objComHistory.strMessageId         = m_strMessageID;
                objComHistory.strDeliveryStatus    = "PENDING";
                objComHistory.Save();
            }
            //This code will make entry into "C:\\MessagingList.csv" file for all sms whether sent or not.
            try
            {
                StreamWriter sw = new StreamWriter("C:\\MessagingList.csv", true);
                sw.Write(DateTime.Now.ToString() + ",");
                sw.Write(strMobileNumber + ",");
                sw.Write(strMessageBody + ",");
                sw.Write(SessionInfo.UserShop.id.ToString() + ",");
                sw.Write(m_strMessageID + ",");
                sw.WriteLine();
                sw.Dispose();
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, Constants.ExceptionPolicy);
                return(false);
            }


            // To send Opt out Notification for first time only
            if (bSent)
            {
                String subStringMobile = String.Empty;
                if (strMobileNumber.Length >= 10)
                {
                    subStringMobile = strMobileNumber.Substring(strMobileNumber.Length - 10, 10);
                }

                int count = UserBL.getDataByUserPhoneAndNotificationSent(subStringMobile);
                if (count == 0)
                {
                    if (SendSMS(strMobileNumber, Constants.OPT_OUT_PROCEDURE_MESSAGE, objBodyShop.strShopName, iToUserId))
                    {
                        UserBL.UpdateUsersOnOptOutNotificationSent(subStringMobile);

                        bSent = true;


                        //Update body Shop message count
                        if (objBodyShop.iMessageCount == null)
                        {
                            objBodyShop.iMessageCount = 1;
                        }
                        else
                        {
                            objBodyShop.iMessageCount += 1;
                        }


                        CommunicationHistoryBL objComHistory = new CommunicationHistoryBL();
                        objComHistory.iUserId = iToUserId;
                        objComHistory.iShopId = iShopId;
                        objComHistory.iCommunicationTypeId = 1;
                        objComHistory.dtCreatedDate        = DateTime.Now;
                        objComHistory.strMessageText       = Constants.OPT_OUT_PROCEDURE_MESSAGE;
                        objComHistory.strPhone             = strMobileNumber;
                        objComHistory.iFromAppSection      = (Int32)eFromSection;
                        objComHistory.strMessageId         = m_strMessageID;
                        objComHistory.strDeliveryStatus    = "PENDING";
                        objComHistory.Save();
                    }
                }
            }

            if (objBodyShop != null)
            {
                objBodyShop.Save();
            }

            return(bSent);
        }
        private bool setUserPrefferedShop(Int32 iUserId, out Int32 iShopId, out Boolean hasGroupOfPrivateShops, out Boolean bPerfromOperation)
        {
            iShopId = 0;
            hasGroupOfPrivateShops = false;
            bPerfromOperation      = true;
            UserPreferredShopBL objPrefferedShop = UserPreferredShopBL.getShopByUserId(iUserId);
            Int32 iPrivateShopId = 0;

            if (Request.QueryString[Constants.QUERYSTRING_PRIVATELABELSHOPID] != null)
            {
                iPrivateShopId = Convert.ToInt32(Request.QueryString[Constants.QUERYSTRING_PRIVATELABELSHOPID]);
            }
            else if (Request.Form[Constants.QUERYSTRING_PRIVATELABELSHOPID] != null)
            {
                iPrivateShopId = Convert.ToInt32(Request.Form[Constants.QUERYSTRING_PRIVATELABELSHOPID]);
            }
            if (iPrivateShopId > 0)
            {
                BodyShopBL objShop = null;
                List <BodyShopPrivateLabelBL> lstBodyShopPrivateLabelBL = new List <BodyShopPrivateLabelBL>();
                lstBodyShopPrivateLabelBL = BodyShopPrivateLabelBL.GetShopListByPrivateLabelId(iPrivateShopId);

                //Check that more than one shop within this private labeling group? if yes then don't assign preferred shop
                if (lstBodyShopPrivateLabelBL.Count > 1)
                {
                    //This privateLabelId exist for a group of shops; user need to select preferred shop from "Select Preferred Shop" page
                    hasGroupOfPrivateShops = true;
                    return(false);
                }
                else
                {
                    objShop = BodyShopBL.getShopById(Convert.ToInt32(lstBodyShopPrivateLabelBL[0].iShopID));
                }
                if (objShop != null)
                {
                    if (objPrefferedShop == null)
                    {
                        objPrefferedShop = new UserPreferredShopBL();
                    }
                    else
                    {
                        //If user has alredy set same preferred shop then return.
                        if (objShop.ID == objPrefferedShop.iShopId)
                        {
                            bPerfromOperation = false;
                            return(false);
                        }
                        MessageBL objMesssage = MessageBL.getDataByUserShopIdAndType(iUserId, objShop.ID, Constants.REGISTRATIONMESSAGTYPE);
                        if (objMesssage != null)
                        {
                            objMesssage.Delete();
                        }
                    }
                    objPrefferedShop.iShopId = objShop.ID;
                    objPrefferedShop.iUserId = iUserId;
                    if (objPrefferedShop.Save())
                    {
                        iShopId = objShop.ID;
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            return(false);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                String strPhoneId = String.Empty;
                String strImage   = String.Empty;
                String strNewApp  = String.Empty;

                if (!String.IsNullOrEmpty(Request.QueryString["ShopID"]))
                {
                    if (!Int32.TryParse(Security.DecodeNumbers(Request.QueryString["ShopID"]), out iShopID))
                    {
                        return;
                    }

                    if (Request.QueryString["User_Id"] != null)
                    {
                        strPhoneId = Request.QueryString["User_Id"];
                        strNewApp  = Request.QueryString["N"];
                    }
                    else if (Request.Form["User_Id"] != null)
                    {
                        strPhoneId = Request.Form["User_Id"];
                        strNewApp  = Request.Form["N"];
                    }
                }
                else
                {
                    if (Request.QueryString["User_Id"] != null)
                    {
                        strPhoneId = Request.QueryString["User_Id"];
                        strNewApp  = Request.QueryString["N"];
                    }
                    else if (Request.Form["User_Id"] != null)
                    {
                        strPhoneId = Request.Form["User_Id"];
                        strNewApp  = Request.Form["N"];
                    }
                    Int32.TryParse(strNewApp, out iShopID);
                }
                if (!String.IsNullOrEmpty(strPhoneId))
                {
                    UserBL objUser = null;
                    if (iShopID != 0)
                    {
                        MyCustomerBL objMyCustomer = MyCustomerBL.getDataByShopIdNPhone(iShopID, strPhoneId);
                        if (objMyCustomer != null)
                        {
                            objUser = UserBL.getByActivityId(objMyCustomer.iUserId.Value);
                        }
                    }
                    else
                    {
                        objUser = UserBL.getDataByPhoneId(strPhoneId);
                    }
                    String     strShopName = String.Empty;
                    String     strPhone    = String.Empty;
                    String     strEMail    = String.Empty;
                    String     strCell     = String.Empty;
                    String     strWebSite  = String.Empty;
                    String     strLogo     = String.Empty;
                    string     strShopID   = String.Empty;
                    BodyShopBL objBodyShop = null;

                    {
                        if (iShopID == 0)
                        {
                            if (objUser != null)
                            {
                                objBodyShop = BodyShopBL.getShopByUserId(objUser.ID);
                            }
                        }
                        else
                        {
                            objBodyShop = BodyShopBL.getShopById(iShopID);
                        }
                        if (objBodyShop != null)
                        {
                            if (iShopID == 0)
                            {
                                strShopID = objBodyShop.ID.ToString();
                            }
                            strShopName = objBodyShop.strShopName;
                            strPhone    = objBodyShop.strPhone;
                            strEMail    = objBodyShop.strEmail;
                            strWebSite  = GetWebSiteURL(objBodyShop.ID, objBodyShop.bIsPremierShop);
                            strCell     = objBodyShop.strPhone;
                            strLogo     = objBodyShop.strImagePath;
                            //strLogo = "E:\\SummitApp\\Bentley\\px_bentley_main.jpg";
                            if (!string.IsNullOrEmpty(strLogo) && File.Exists(Constants.SHOP_APP_PHY_PATH + strLogo))
                            {
                                strLogo       = Constants.SHOP_APP_PHY_PATH + strLogo;
                                byteImageData = ReadImage(strLogo.ToLower(), new string[] { ".gif", ".jpg", ".bmp", ".png" });
                            }
                            else
                            {
                                byteImageData = null;
                            }
                        }
                    }

                    XmlDocument  xmlDoc = new XmlDocument();
                    MemoryStream stream = new MemoryStream();
                    //XmlTextWriter xmlWriter = new XmlTextWriter(stream, System.Text.Encoding.ASCII);
                    XmlTextWriter xmlWriter = new XmlTextWriter(stream, System.Text.Encoding.UTF8);
                    xmlWriter.WriteStartDocument();
                    xmlWriter.WriteStartElement("MyPreferredShop");
                    xmlWriter.WriteElementString("Name", String.IsNullOrEmpty(strShopName) ? "" : strShopName);
                    xmlWriter.WriteElementString("Phone", String.IsNullOrEmpty(strPhone) ? "" : strPhone);
                    xmlWriter.WriteElementString("EMail", String.IsNullOrEmpty(strEMail) ? "" : strEMail);
                    xmlWriter.WriteElementString("Cell", String.IsNullOrEmpty(strCell) ? "" : strCell);
                    xmlWriter.WriteElementString("WebSite", String.IsNullOrEmpty(strWebSite) ? "" : strWebSite);
                    if (iShopID == 0)
                    {
                        xmlWriter.WriteElementString("ShopID", String.IsNullOrEmpty(Security.EncodeNumbers(strShopID)) ? "" : strWebSite);
                    }

                    // New attribute 'N' for New Prototype App with value 'T' for True has to be recieved to PreferredShop.aspx,
                    // so as to identify new App and get the dynamic logo in response.
                    // This attribute is only for New Prototype app.
                    if (!String.IsNullOrEmpty(strNewApp))
                    {
                        if (strNewApp.Equals("T"))
                        {
                            xmlWriter.WriteElementString("Logo", String.IsNullOrEmpty(byteImageData != null ? Convert.ToBase64String(byteImageData) : strImage) ? strImage : Convert.ToBase64String(byteImageData));
                        }
                    }
                    xmlWriter.WriteEndElement();
                    xmlWriter.WriteEndDocument();
                    xmlWriter.Flush();
                    byte[] byteArray = stream.ToArray();
                    HttpContext.Current.Response.Clear();
                    HttpContext.Current.Response.AppendHeader("Content-Disposition", "filename=MyExportedFile.xml");
                    HttpContext.Current.Response.AppendHeader("Content-Length", byteArray.Length.ToString());
                    HttpContext.Current.Response.ContentType = "text/xml";
                    HttpContext.Current.Response.BinaryWrite(byteArray);
                }
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, Constants.ExceptionPolicy);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Boolean bResult = false;

            try
            {
                String strPhoneId  = String.Empty;
                String strPhoneId1 = String.Empty;

                if (!String.IsNullOrEmpty(Request.QueryString["ShopID"]))
                {
                    if (Request.QueryString["User_ID"] != null)
                    {
                        strPhoneId1 = Request.QueryString["User_ID"];
                    }
                    else if (Request.Form["User_ID"] != null)
                    {
                        strPhoneId1 = Request.Form["User_ID"];
                    }
                    if (!Int32.TryParse(Security.DecodeNumbers(Request.QueryString["ShopID"]), out iShopID))
                    {
                        return;
                    }
                }
                else
                {
                    if (Request.QueryString["User_ID"] != null)
                    {
                        strPhoneId = Request.QueryString["User_ID"];
                    }
                    else if (Request.Form["User_ID"] != null)
                    {
                        strPhoneId = Request.Form["User_ID"];
                    }
                }
                UserBL objUser = null;
                if (!String.IsNullOrEmpty(strPhoneId))
                {
                    //if phone user id is found
                    objUser = UserBL.getDataByPhoneId(strPhoneId);
                }
                else
                {
                    MyCustomerBL objMyCustomer = MyCustomerBL.getDataByShopIdNPhone(iShopID, strPhoneId1);
                    if (objMyCustomer != null)
                    {
                        objUser = UserBL.getByActivityId(objMyCustomer.iUserId.Value);
                    }
                }

                if (objUser != null)
                {
                    String strUserName = String.Empty;

                    if (string.IsNullOrEmpty(objUser.strUserName))
                    {
                        if (Request.QueryString["Phone_Owner_Name"] != null)
                        {
                            objUser.strUserName = Request.QueryString["Phone_Owner_Name"];
                        }
                        else if (Request.Form["Phone_Owner_Name"] != null && !string.IsNullOrEmpty(Request.Form["Phone_Owner_Name"].ToString()))
                        {
                            objUser.strUserName = Request.Form["Phone_Owner_Name"];
                        }
                    }
                    objUser.Save();

                    UserPreferredShopBL objUserPreferredShop = UserPreferredShopBL.getShopByUserId(objUser.ID);



                    MessageBL objMessage = null;
                    if (objUserPreferredShop != null || iShopID > 0)
                    {
                        objMessage = new MessageBL();
                        objMessage.iPhoneUserID = objUser.ID;
                        if (objUserPreferredShop != null)
                        {
                            objMessage.iShopID = objUserPreferredShop.iShopId;
                        }
                        else
                        {
                            objMessage.iShopID = iShopID;
                        }
                        objMessage.dtMessageTime = DateTime.Now;

                        if (Request.QueryString["Message"] != null)
                        {
                            objMessage.strMessage = Request.QueryString["Message"].ToString();
                        }
                        else if (Request.Form["Message"] != null)
                        {
                            objMessage.strMessage = Request.Form["Message"].ToString();
                        }

                        String strType = String.Empty;
                        if (Request.QueryString["MessageType"] != null)
                        {
                            strType = Request.QueryString["MessageType"].ToString();
                        }
                        else if (Request.Form["MessageType"] != null)
                        {
                            strType = Request.Form["MessageType"].ToString();
                        }

                        String[] strPhoneNumbers = null;
                        if (Request.QueryString["smsTo"] != null)
                        {
                            strPhoneNumbers = Request.QueryString["smsTo"].ToString().Split(',');
                        }

                        if (strType.ToLower() == "predefinedsms" && Request.QueryString["Message"] != null)
                        {
                            String strMSG = Request.QueryString["Message"].ToString();
                            if (strPhoneNumbers != null)
                            {
                                SMS objSMS = new SMS();
                                foreach (String item in strPhoneNumbers)
                                {
                                    objSMS.SendSMS(item, objMessage.strMessage, objUser.strPhone, objUser.ID);
                                }
                            }
                        }

                        try
                        {
                            if (Request.QueryString["Latitude"] != null)
                            {
                                objMessage.fLatitude = Convert.ToDouble(Request.QueryString["Latitude"]);
                            }
                            else if (Request.Form["Latitude"] != null)
                            {
                                objMessage.fLatitude = Convert.ToDouble(Request.Form["Latitude"]);
                            }
                        }
                        catch (Exception ex)
                        {
                            objMessage.fLatitude = 0.0;
                        }
                        try
                        {
                            if (Request.QueryString["Longitude"] != null)
                            {
                                objMessage.fLongitude = Convert.ToDouble(Request.QueryString["Longitude"]);
                            }
                            else if (Request.Form["Longitude"] != null)
                            {
                                objMessage.fLongitude = Convert.ToDouble(Request.Form["Longitude"]);
                            }
                        }
                        catch (Exception ex)
                        {
                            objMessage.fLongitude = 0.0;
                        }
                        objMessage.iType = Constants.PredefinedSMS;

                        objMessage.Save();

                        BodyShopBL objBodyShop = null;
                        if (objUserPreferredShop != null)
                        {
                            objBodyShop = BodyShopBL.getShopById(Convert.ToInt32(objUserPreferredShop.iShopId));
                        }
                        else
                        {
                            objBodyShop = BodyShopBL.getShopById(iShopID);
                        }

                        if (objBodyShop != null)
                        {
                            objBodyShop.iNoHelpSelection = (objBodyShop.iNoHelpSelection == null) ? 1 : (objBodyShop.iNoHelpSelection + 1);

                            if (objBodyShop.Save())
                            {
                                if (Cache["CommunicationList"] != null)
                                {
                                    Cache.Remove("CommunicationList");
                                }
                                if (Cache["OpportunityList"] != null)
                                {
                                    Cache.Remove("OpportunityList");
                                }
                                if (Cache["RepairProspect"] != null)
                                {
                                    Cache.Remove("RepairProspect");
                                }
                                if (Cache["EmailMarketing"] != null)
                                {
                                    Cache.Remove("EmailMarketing");
                                }
                                if (Cache["TextMarketing"] != null)
                                {
                                    Cache.Remove("TextMarketing");
                                }
                                bResult = true;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                bResult = false;
            }

            XmlDocument  xmlDoc = new XmlDocument();
            MemoryStream stream = new MemoryStream();
            //XmlTextWriter xmlWriter = new XmlTextWriter(stream, System.Text.Encoding.ASCII);
            XmlTextWriter xmlWriter = new XmlTextWriter(stream, System.Text.Encoding.UTF8);

            xmlWriter.WriteStartDocument();
            xmlWriter.WriteStartElement("EditCountReport");
            xmlWriter.WriteElementString("Status", bResult ? "Success" : "Fail");
            xmlWriter.WriteEndElement();
            xmlWriter.WriteEndDocument();
            xmlWriter.Flush();
            byte[] byteArray = stream.ToArray();
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.AppendHeader("Content-Disposition", "filename=MyExportedFile.xml");
            HttpContext.Current.Response.AppendHeader("Content-Length", byteArray.Length.ToString());
            HttpContext.Current.Response.ContentType = "text/xml";
            HttpContext.Current.Response.BinaryWrite(byteArray);
        }
Beispiel #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Boolean bResult = false;

            try
            {
                String strPhoneId  = String.Empty;
                String strPhoneId1 = String.Empty;

                if (!String.IsNullOrEmpty(Request.QueryString["ShopID"]))
                {
                    if (Request.QueryString["User_ID"] != null)
                    {
                        strPhoneId1 = Request.QueryString["User_ID"];
                    }
                    else if (Request.Form["User_ID"] != null)
                    {
                        strPhoneId1 = Request.Form["User_ID"];
                    }
                    if (!Int32.TryParse(Security.DecodeNumbers(Request.QueryString["ShopID"]), out iShopID))
                    {
                        return;
                    }
                }
                else
                {
                    if (Request.QueryString["User_ID"] != null)
                    {
                        strPhoneId = Request.QueryString["User_ID"];
                    }
                    else if (Request.Form["User_ID"] != null)
                    {
                        strPhoneId = Request.Form["User_ID"];
                    }
                }
                UserBL objUser = null;
                if (!String.IsNullOrEmpty(strPhoneId))
                {
                    //if phone user id is found
                    objUser = UserBL.getDataByPhoneId(strPhoneId);
                }
                else
                {
                    MyCustomerBL objMyCustomer = MyCustomerBL.getDataByShopIdNPhone(iShopID, strPhoneId1);
                    if (objMyCustomer != null)
                    {
                        objUser = UserBL.getByActivityId(objMyCustomer.iUserId.Value);
                    }
                }
                if (objUser != null)
                {
                    //if user of that phone user id is found fill message info
                    String strUserName = String.Empty;

                    if (string.IsNullOrEmpty(objUser.strUserName))
                    {
                        if (Request.QueryString["Phone_Owner_Name"] != null)
                        {
                            objUser.strUserName = Request.QueryString["Phone_Owner_Name"];
                        }
                        else if (Request.Form["Phone_Owner_Name"] != null && !string.IsNullOrEmpty(Request.Form["Phone_Owner_Name"].ToString()))
                        {
                            objUser.strUserName = Request.Form["Phone_Owner_Name"];
                        }
                    }

                    //if (!String.IsNullOrEmpty(strUserName) && objUser.strFirstName != strUserName)
                    //{
                    //if user's first name is changed replace it
                    //objUser.strFirstName = strUserName;
                    objUser.Save();
                    //}

                    UserPreferredShopBL objUserPreferredShop = UserPreferredShopBL.getShopByUserId(objUser.ID);



                    if (objUserPreferredShop != null || iShopID > 0)
                    {
                        String strMSG = String.Empty;
                        //save the message against his preferred body shop
                        MessageBL objMessage = new MessageBL();
                        objMessage.iPhoneUserID = objUser.ID;
                        if (objUserPreferredShop != null)
                        {
                            objMessage.iShopID = objUserPreferredShop.iShopId;
                        }
                        else
                        {
                            objMessage.iShopID = iShopID;
                        }
                        objMessage.dtMessageTime = DateTime.Now;

                        if (Request.QueryString["Message"] != null)
                        {
                            objMessage.strMessage = Request.QueryString["Message"].ToString();
                        }
                        else if (Request.Form["Message"] != null)
                        {
                            objMessage.strMessage = Request.Form["Message"].ToString();
                        }

                        String strType = String.Empty;
                        if (Request.QueryString["MessageType"] != null)
                        {
                            strType = Request.QueryString["MessageType"].ToString();
                        }
                        else if (Request.Form["MessageType"] != null)
                        {
                            strType = Request.Form["MessageType"].ToString();
                        }

                        //Check isSendSMS flag to send SMS via Web Application
                        Boolean bIsSendSMS       = false;
                        String  strBodyShopPhone = String.Empty;
                        if (Request.QueryString["sendSMS"] != null && Request.QueryString["sendSMS"].ToString() == "1")
                        {
                            bIsSendSMS = true;
                        }

                        BodyShopBL objBodyShop = null;
                        if (objUserPreferredShop != null && objUserPreferredShop.iShopId.HasValue)
                        {
                            objBodyShop = BodyShopBL.getShopById(objUserPreferredShop.iShopId.Value);
                        }
                        else if (iShopID > 0)
                        {
                            objBodyShop = BodyShopBL.getShopById(iShopID);
                        }
                        if (objBodyShop != null && objBodyShop.strPhone != null)
                        {
                            strBodyShopPhone = objBodyShop.strPhone;
                        }

                        if (!String.IsNullOrEmpty(strType))
                        {
                            switch (strType.ToLower())
                            {
                            //select the message type eg. SMS, Email, Predefined SMS
                            case "sms":
                                objMessage.iType = Constants.SMS;
                                if (bIsSendSMS)
                                {
                                    if (!String.IsNullOrEmpty(strBodyShopPhone))
                                    {
                                        SMS objSMS = new SMS();
                                        objSMS.SendSMS(strBodyShopPhone, objMessage.strMessage, objUser.strPhone, objUser.ID);
                                    }
                                }
                                break;

                            case "email":
                                objMessage.iType = Constants.Email;
                                break;

                            case "predefinedsms":
                                objMessage.iType = Constants.PredefinedSMS;
                                break;
                            }
                        }

                        //save the message n if saved return true to phone n remove cache
                        if (objMessage.Save())
                        {
                            bResult = true;
                            if (objMessage.iType == Constants.PredefinedSMS)
                            {
                                if (Cache["OpportunityList"] != null)
                                {
                                    Cache.Remove("OpportunityList");
                                }
                            }
                            else if (objMessage.iType == Constants.SMS || objMessage.iType == Constants.Email)
                            {
                                if (Cache["CommunicationList"] != null)
                                {
                                    Cache.Remove("CommunicationList");
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                bResult = false;
            }

            XmlDocument  xmlDoc = new XmlDocument();
            MemoryStream stream = new MemoryStream();
            //XmlTextWriter xmlWriter = new XmlTextWriter(stream, System.Text.Encoding.ASCII);
            XmlTextWriter xmlWriter = new XmlTextWriter(stream, System.Text.Encoding.UTF8);

            xmlWriter.WriteStartDocument();
            xmlWriter.WriteStartElement("MessageReport");
            xmlWriter.WriteElementString("Status", bResult ? "Success" : "Fail");
            xmlWriter.WriteEndElement();
            xmlWriter.WriteEndDocument();
            xmlWriter.Flush();
            byte[] byteArray = stream.ToArray();
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.AppendHeader("Content-Disposition", "filename=MyExportedFile.xml");
            HttpContext.Current.Response.AppendHeader("Content-Length", byteArray.Length.ToString());
            HttpContext.Current.Response.ContentType = "text/xml";
            HttpContext.Current.Response.BinaryWrite(byteArray);
        }