Exemplo n.º 1
0
    /// <summary>
    /// Invokes a Web Method, with its parameters encoded or not.
    /// </summary>
    /// <param name="methodName">Name of the web method you want to call (case sensitive)</param>
    /// <param name="encode">Do you want to encode your parameters? (default: true)</param>
    private void Invoke(string methodName, bool encode)
    {
        AssertCanInvoke(methodName);
        string soapStr =
            @"<?xml version=""1.0"" encoding=""utf-8""?>
                <soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
                   xmlns:xsd=""http://www.w3.org/2001/XMLSchema""
                   xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">
                  <soap:Body>
                    <{0} xmlns=""http://tempuri.org/"">
                      {1}
                    </{0}>
                  </soap:Body>
                </soap:Envelope>";

        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(Url);

        req.Headers.Add("SOAPAction", "\"http://tempuri.org/" + methodName + "\"");
        req.ContentType = "text/xml;charset=\"utf-8\"";
        req.Accept      = "text/xml";
        req.Method      = "POST";

        using (Stream stm = req.GetRequestStream())
        {
            string postValues = "";
            foreach (var param in Params)
            {
                if (encode)
                {
                    postValues += string.Format("<{0}>{1}</{0}>", HttpUtility.HtmlEncode(param.Key), HttpUtility.HtmlEncode(param.Value));
                }
                else
                {
                    postValues += string.Format("<{0}>{1}</{0}>", param.Key, param.Value);
                }
            }

            soapStr = string.Format(soapStr, methodName, postValues);
            using (StreamWriter stmw = new StreamWriter(stm))
            {
                stmw.Write(soapStr);
            }
        }

        using (StreamReader responseReader = new StreamReader(req.GetResponse().GetResponseStream()))
        {
            string result = responseReader.ReadToEnd();
            ResponseSOAP = XDocument.Parse(ENUtils.UnescapeString(result));
            ExtractResult(methodName);
        }
    }
        private void ReplyMessage()
        {
            try
            {
                if (grdLister.CurrentRow != null && grdLister.CurrentRow is GridViewDataRowInfo)
                {
                    int    DriverId = grdLister.CurrentRow.Cells["SenderId"].Value.ToInt();
                    string mobileNo = "";


                    string sendFrom = grdLister.CurrentRow.Cells["SendFrom"].Value.ToStr();

                    string messageType = "Inbox";

                    if (sendFrom.ToLower() == "pda")
                    {
                        messageType = "pda";
                    }
                    else
                    {
                        mobileNo = grdLister.CurrentRow.Cells["Name"].Value.ToStr();
                        int index = mobileNo.LastIndexOf('(');

                        if (index != -1)
                        {
                            mobileNo = mobileNo.Substring(mobileNo.LastIndexOf('(') + 1);
                            mobileNo = mobileNo.Replace(")", "");
                        }
                        else
                        {
                            mobileNo = "";
                        }
                    }

                    frmMessageReply frmReply = new frmMessageReply();
                    frmReply.MessageType      = messageType;
                    frmReply.FromMessage      = grdLister.CurrentRow.Cells["Message"].Value.ToStr();
                    frmReply.CustomerMobileNo = mobileNo;
                    frmReply.DriverId         = DriverId;
                    frmReply.ReceiverName     = grdLister.CurrentRow.Cells["Name"].Value.ToStr();

                    frmReply.ShowDialog();
                    frmReply.Dispose();
                }
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
        private void LoadOnBreakDriver()
        {
            try
            {
                var data1 = General.GetQueryable <Fleet_DriverQueueList>(c => c.Status == true && c.DriverWorkStatusId == Enums.Driver_WORKINGSTATUS.ONBREAK).AsEnumerable();
                var query = (from a in data1
                             select new
                {
                    ID = a.Id,
                    Driver = a.Fleet_Driver.DriverNo + "-" + a.Fleet_Driver.DriverName,
                    BreakTime = a.OnBreakDateTime,
                }).OrderByDescending(c => c.BreakTime);

                grdLister.DataSource = query.ToList();
            }
            catch (Exception ex)
            {
                ENUtils.ShowErrorMessage(ex.Message);
            }
        }
        void btnLastBookings_Click(object sender, EventArgs e)
        {
            try
            {
                if (grdLister.CurrentRow != null && grdLister.CurrentRow is GridViewDataRowInfo)
                {
                    string MobileNo = grdLister.CurrentRow.Cells["Name"].Value.ToStr();

                    int a = MobileNo.IndexOf("(");

                    if (a == -1)
                    {
                        a = 0;
                    }

                    MobileNo = MobileNo.Substring(a, MobileNo.Length - a);


                    MobileNo = MobileNo.Replace("(", "");
                    MobileNo = MobileNo.Replace(")", "");
                    frmSearchBooking frm = new frmSearchBooking(MobileNo);
                    frm.ShowDialog();


                    //using (Taxi_Model.TaxiDataContext db = new Taxi_Model.TaxiDataContext())
                    //{
                    //    db.Messages.DeleteOnSubmit(db.Messages.FirstOrDefault(c => c.Id == Id));
                    //    db.SubmitChanges();


                    //}

                    //PopulateData();
                }
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
        void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (grdLister.CurrentRow != null && grdLister.CurrentRow is GridViewDataRowInfo)
                {
                    long Id = grdLister.CurrentRow.Cells["Id"].Value.ToLong();

                    using (Taxi_Model.TaxiDataContext db = new Taxi_Model.TaxiDataContext())
                    {
                        db.Messages.DeleteOnSubmit(db.Messages.FirstOrDefault(c => c.Id == Id));
                        db.SubmitChanges();
                    }

                    PopulateData();
                }
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }