Esempio n. 1
0
        protected override Java.Lang.Object DoInBackground(params Java.Lang.Object[] @params)
        {
            if (!CommonService.CheckInternetConnection(activity.Context))
            {
                return(null);
            }
            key = @params[0].ToString();
            URL    url   = new URL(sqlquery_url);
            string query = "";

            if (key == "GetMenuByRestoID")
            {
                query = MenuResto.GetByRestoID(@params[1].ToString());
            }
            if (key == "GetMenuMakananByRestoID")
            {
                query = MenuResto.GetMenuMakananByRestoID(@params[1].ToString());
            }
            if (key == "GetMenuMinumanByRestoID")
            {
                query = MenuResto.GetMenuMinumanByRestoID(@params[1].ToString());
            }
            if (key == "GetMenuSpesialByRestoID")
            {
                query = MenuResto.GetMenuSpesialByRestoID(@params[1].ToString());
            }
            if (key == "GetMenuByIDInSelect")
            {
                query = MenuResto.GetMenuByIDInSelect(@params[1].ToString());
            }
            string            data    = URLEncoder.Encode("query", "UTF-8") + "=" + URLEncoder.Encode(query, "UTF-8");
            HttpURLConnection urlConn = (HttpURLConnection)url.OpenConnection();

            urlConn.RequestMethod = "POST";
            urlConn.DoInput       = true;
            urlConn.DoOutput      = true;
            try
            {
                Stream         oStream = urlConn.OutputStream;
                BufferedWriter bw      = new BufferedWriter(new OutputStreamWriter(oStream, "UTF-8"));
                bw.Write(data);
                bw.Flush();
                bw.Close();
                oStream.Close();
                Stream                    iStream       = urlConn.InputStream;
                BufferedReader            br            = new BufferedReader(new InputStreamReader(iStream));
                System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
                string                    line          = "";
                while ((line = br.ReadLine()) != null)
                {
                    stringBuilder.Append(line + "\n");
                }
                urlConn.Disconnect();
                string result = stringBuilder.ToString().Trim();
                m_result = MenuResto.GetListByServerResponse(result);
                return(result);
            }
            catch (Java.IO.IOException ex)
            {
                //   Toast.MakeText(activity.GetContext(), ex.Message, ToastLength.Short);
            }
            return(null);
        }
Esempio n. 2
0
        /// <summary>
        /// login,getbyid
        /// </summary>
        /// <param name="params"></param>
        /// <returns></returns>
        protected override Java.Lang.Object DoInBackground(params Java.Lang.Object[] @params)
        {
            if (!CommonService.CheckInternetConnection(activity.GetContext()))
            {
                return(null);
            }
            key = @params[0].ToString();
            URL    url   = new URL(sqlquery_url);
            string query = "";

            if (key == "login")
            {
                query = MrGo.Entity.Member.GetMemberByEmailPasswordSQL(@params[1].ToString(), @params[2].ToString());
            }
            if (key == "getbyid")
            {
                query = MrGo.Entity.Member.GetMemberByIdSQL(Convert.ToInt32(@params[1].ToString()));
            }
            if (key == "updateReSentCodeByEmail")
            {
                query = MrGo.Entity.Member.UpdateReSentCodeByEmail(@params[1].ToString());
            }
            if (key == "register")
            {
                url   = new URL(sqlnonquery_url);
                query = MrGo.Entity.Member.GetInsertSQL(
                    @params[1].ToString()
                    , @params[2].ToString()
                    , @params[3].ToString()
                    , @params[4].ToString()
                    , "1234"
                    );
            }
            if (key == "getbyemail")
            {
                query = MrGo.Entity.Member.GetMemberByEmail(@params[1].ToString());
            }
            if (key == "activateuser")
            {
                url   = new URL(sqlnonquery_url);
                query = MrGo.Entity.Member.GetActivateUserSQL(@params[1].ToString(), @params[2].ToString());
            }
            string            data    = URLEncoder.Encode("query", "UTF-8") + "=" + URLEncoder.Encode(query, "UTF-8");
            HttpURLConnection urlConn = (HttpURLConnection)url.OpenConnection();

            urlConn.RequestMethod = "POST";
            urlConn.DoInput       = true;
            urlConn.DoOutput      = true;
            try
            {
                Stream oStream = urlConn.OutputStream;

                BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(oStream, "UTF-8"));
                //string query = MrGo.Entity.Member.GetMemberByEmailPasswordSQL(@params[1].ToString(), @params[2].ToString());

                bw.Write(data);
                bw.Flush();
                bw.Close();
                oStream.Close();
                Stream                    iStream       = urlConn.InputStream;
                BufferedReader            br            = new BufferedReader(new InputStreamReader(iStream));
                System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
                string                    line          = "";
                while ((line = br.ReadLine()) != null)
                {
                    stringBuilder.Append(line + "\n");
                }
                urlConn.Disconnect();
                string result = stringBuilder.ToString().Trim();
                Member = Member.GetByServerResponse(result);
                return(result);
            }
            catch (Java.IO.IOException ex)
            {
                //   Toast.MakeText(activity.GetContext(), ex.Message, ToastLength.Short);
            }
            return(null);
        }
Esempio n. 3
0
        protected override Java.Lang.Object DoInBackground(params Java.Lang.Object[] @params)
        {
            if (!CommonService.CheckInternetConnection(activity.Context))
            {
                return(null);
            }
            key = @params[0].ToString();
            URL    url   = new URL(sqlquery_url);
            string query = "";

            if (key == "InsertTransaction")
            {
                url = new URL(sqlnonquery_url);
                Transaction tr = (Transaction)@params[1];
                query = MrGo.Entity.Transaction.GetInsertSQL(tr);
            }
            if (key == "getmaxidbymember")
            {
                query = MrGo.Entity.Transaction.SelectMaxTransactionId(Convert.ToInt32(@params[1].ToString()));
            }
            if (key == "getmaxid")
            {
                query = MrGo.Entity.Transaction.SelectMaxTransactionId();
            }
            if (key == "InsertDetailsTransaction")
            {
                url = new URL(sqlnonquery_url);
                TransactionDetail tr = (TransactionDetail)@params[1];
                query = MrGo.Entity.TransactionDetail.GetInsertSQL(tr);
            }
            if (key == "getByMemberByStatus")
            {
                TransactionStatus trSts = (TransactionStatus)Enum.Parse(typeof(TransactionStatus), @params[1].ToString());
                int trid = Convert.ToInt32(@params[2].ToString());
                query = MrGo.Entity.Transaction.GetByMemberByStatusSQLSQL(trid, trSts);
            }
            if (key == "getByID")
            {
                int trId = Convert.ToInt32(@params[1].ToString());
                query = MrGo.Entity.Transaction.GetByIDSQL(trId);
            }
            if (key == "getTrDetailByTrId")
            {
                int trId = Convert.ToInt32(@params[1].ToString());
                query = MrGo.Entity.TransactionDetail.GetTrDetailByTrIdSQL(trId);
            }
            if (key == "updateStatus")
            {
                url = new URL(sqlnonquery_url);
                TransactionStatus trSts = (TransactionStatus)Enum.Parse(typeof(TransactionStatus), @params[1].ToString());
                int trId = Convert.ToInt32(@params[2].ToString());
                query = MrGo.Entity.Transaction.UpDateStatusSQL(trId, trSts);
            }
            string            data    = URLEncoder.Encode("query", "UTF-8") + "=" + URLEncoder.Encode(query, "UTF-8");
            HttpURLConnection urlConn = (HttpURLConnection)url.OpenConnection();

            urlConn.RequestMethod = "POST";
            urlConn.DoInput       = true;
            urlConn.DoOutput      = true;
            try
            {
                Stream         oStream = urlConn.OutputStream;
                BufferedWriter bw      = new BufferedWriter(new OutputStreamWriter(oStream, "UTF-8"));
                bw.Write(data);
                bw.Flush();
                bw.Close();
                oStream.Close();
                Stream                    iStream       = urlConn.InputStream;
                BufferedReader            br            = new BufferedReader(new InputStreamReader(iStream));
                System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
                string                    line          = "";
                while ((line = br.ReadLine()) != null)
                {
                    stringBuilder.Append(line + "\n");
                }
                urlConn.Disconnect();
                string result = stringBuilder.ToString().Trim();
                if (key == "getTrDetailByTrId")
                {
                    m_result = TransactionDetail.GetListByServerResponse(result);
                }
                else
                {
                    m_result = Transaction.GetListByServerResponse(result);
                }
                return(result);
            }
            catch (Java.IO.IOException ex)
            {
                //   Toast.MakeText(activity.GetContext(), ex.Message, ToastLength.Short);
            }
            return(null);
        }