Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9047939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T12:01:33+00:00 2026-06-16T12:01:33+00:00

I’m going to rewrite the application from Monotouh to Monodroid application for android. Correct

  • 0

I’m going to rewrite the application from Monotouh to Monodroid application for android. Correct me if I’m wrong. The logic remains the same as in MonoTouch or change anything? If something changes, please tell me, what?

As far as I understand, only GIU changes. Thanks in advance!

So, this is my code where i call data from my server:

namespace Mobile{
public static class SiteHelper
{
    public static string DbPath = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), "Sql_1.4.sqlite");
    public const string TempDbPath = "./Sql.sqlite";


    public static UIView View { get; set; }

    public static BaseController Controller { get; set; }

    private static event NIHandler _noInternetHandler;

    private static bool _noInternetShoved = false;
    public static string SiteDomain = "http://mysite.com"; //files which connecting to the DB on server (.asx files)

    private delegate void NIHandler ();



    public static XDocument DoRequest (string Request)
    {

        if (_noInternetHandler != null) {
            foreach (var del in _noInternetHandler.GetInvocationList()) {
                _noInternetHandler -= del as NIHandler;
            }
        }

        if (Controller != null)
            _noInternetHandler += new NIHandler (Controller.PushThenNoInternet);

        string CryptoString = "";
        string Language = "ru";

        using (MD5 md5Hash = MD5.Create()) {
            string hashKey = Guid.NewGuid ().ToString ().Substring (0, 4);
            CryptoString = Request + (Request.Contains ("?") ? "&" : "?") + "hash=" + GetMd5Hash (
                md5Hash,
                "myprogMobhash_" + hashKey
            ) + "&hashKey=" + hashKey + "&language=" + Language;




            UIActivityIndicatorView _preloader = null;

            if (Controller != null) {
                Controller.InvokeOnMainThread (delegate() {
                    _preloader = new UIActivityIndicatorView (UIActivityIndicatorViewStyle.Gray);


                    if (View != null && Request.IndexOf ("login.ashx") == -1 
                        && Request.IndexOf ("yandex") == -1 
                        && Request.IndexOf ("GetDialogMessages") == -1) {

                        lock (_preloader) {
                            if (_preloader != null && !_preloader.IsAnimating)
                                _preloader.HidesWhenStopped = true;
                            _preloader.Frame = new RectangleF (150, 170, 30, 30);
                            _preloader.Transform = MonoTouch.CoreGraphics.CGAffineTransform.MakeScale ((float)1.3, (float)1.3);
                            _preloader.StartAnimating ();
                            View.Add (_preloader);
                        }
                    }
                });
            }


            /*ctx.GetText(Resource.String.SiteAddress)*/
            Stream Stream = null;
            try {
                HttpWebRequest request = new HttpWebRequest (new Uri (SiteDomain + "/FolderWithFiles/" + CryptoString));
                request.Timeout = 8000;
                Stream = request.GetResponse ().GetResponseStream ();
                _noInternetShoved = false;
                if (_noInternetHandler != null)
                    _noInternetHandler -= new NIHandler (Controller.PushThenNoInternet);
            } catch (WebException) {
                if (_noInternetHandler != null)
                    _noInternetHandler.Invoke ();
                var resp = new XDocument (new XElement ("Response", 
                            new XElement ("status", "error"), 
                            new XElement ("error", "Отсутствует интернет"))
                );
                return resp;

            }


            StreamReader Sr = new StreamReader (Stream);
            string Resp = Sr.ReadToEnd ();
            XDocument Response = XDocument.Parse (Resp.Substring (0, Resp.IndexOf ("<html>") == -1 ? Resp.Length : Resp.IndexOf ("<!DOCTYPE html>")));
            string Hash = Response.Descendants ().Where (x => x.Name == "hash")
                .FirstOrDefault ().Value;
            string HashKey = Response.Descendants ().Where (x => x.Name == "hashKey")
                .FirstOrDefault ().Value;

            Sr.Close ();
            Stream.Close ();


            if (Controller != null && _preloader != null) {
                Controller.InvokeOnMainThread (delegate() {
                    lock (_preloader) {
                        _preloader.StopAnimating ();
                        _preloader.RemoveFromSuperview ();
                    }
                });
            }


            if (VerifyMd5Hash (
                md5Hash,
                "mobileSitehash_" + HashKey,
                Hash
            ))
                return Response;
            else
                throw new Exception ();


        }
    }



    public static XDocument DoWriteFileRequest (string Request, byte[] file)
    {
        string CryptoString = "";
        string Language = "ru";

        using (MD5 md5Hash = MD5.Create()) {
            string hashKey = Guid.NewGuid ().ToString ().Substring (0, 4);
            CryptoString = Request + (Request.Contains ("?") ? "&" : "?") + "hash=" + GetMd5Hash (
                md5Hash,
                "mobileMobhash_" + hashKey
            ) + "&hashKey=" + hashKey + "&language=" + Language;

            HttpWebRequest Req = (HttpWebRequest)WebRequest.Create (SiteDomain + "/misc/mobile/" + CryptoString);
            Req.Method = "POST"; 
            Stream requestStream = Req.GetRequestStream ();
            requestStream.Write (file, 0, file.Length);
            requestStream.Close ();

            Stream Stream = Req.GetResponse ().GetResponseStream ();
            StreamReader Sr = new StreamReader (Stream);
            string Resp = Sr.ReadToEnd ();
            XDocument Response = XDocument.Parse (Resp);
            string Hash = Response.Descendants ().Where (x => x.Name == "hash")
                .FirstOrDefault ().Value;
            string HashKey = Response.Descendants ().Where (x => x.Name == "hashKey")
                .FirstOrDefault ().Value;

            Sr.Close ();
            Stream.Close ();

            if (VerifyMd5Hash (
                md5Hash,
                "mobileSitehash_" + HashKey,
                Hash
            ))
                return Response;
            else
                throw new Exception ();


        }
    }

    public static string GetMd5Hash (MD5 md5Hash, string input)
    {

        // Convert the input string to a byte array and compute the hash.
        byte[] data = md5Hash.ComputeHash (Encoding.UTF8.GetBytes (input));

        // Create a new Stringbuilder to collect the bytes
        // and create a string.
        StringBuilder sBuilder = new StringBuilder ();

        // Loop through each byte of the hashed data 
        // and format each one as a hexadecimal string.
        for (int i = 0; i < data.Length; i++) {
            sBuilder.Append (data [i].ToString ("x2"));
        }

        // Return the hexadecimal string.2
        return sBuilder.ToString ();
    }

    //Geting the info for my app
    public static List<PackageListModel> GetUserPackages (int UserID)
    {
        List<PackageListModel> Events = new List<PackageListModel> ();
        string Req = "SomeFile.ashx?UserID=" + UserID;
        XDocument XmlAnswer = DoRequest (Req);

        if (XmlAnswer.Descendants ("status").First ().Value == "ok") {
            foreach (var el in XmlAnswer.Descendants ("Response").First ().Descendants().Where(x=>x.Name == "Event")) {
                PackageListModel Event = null;
                Event = new PackageListModel ()
                {
                    ID = int.Parse(el.Attribute("ID").Value),
                    Title = el.Element("Title").Value,
                    Date = el.Element("Date").Value,
                    Price = el.Element("Price").Value,
                    ImageUrl = el.Element("ImageUrl").Value,
                    Location = el.Element("Location").Value
                };
                Events.Add (Event);
            }
        }
        return Events;
    }

    //Получить пользовательские поездки
    public static List<TransporterListModel> GetUserTransporters (int UserID)
    {
        List<TransporterListModel> Events = new List<TransporterListModel> ();
        string Req = "SomeFile.ashx?UserID=" + UserID;
        XDocument XmlAnswer = DoRequest (Req);

        if (XmlAnswer.Descendants ("status").First ().Value == "ok") {
            foreach (var el in XmlAnswer.Descendants ("Response").First ().Descendants().Where(x=>x.Name == "Event")) {
                TransporterListModel Event = null;
                Event = new TransporterListModel ()
                {
                    ID = int.Parse(el.Attribute("ID").Value),
                    Date = el.Element("Date").Value,
                    Price = el.Element("Price").Value,
                    TransportsStr = el.Element("Transports").Value,
                    Location = el.Element("Location").Value
                };
                Events.Add (Event);
            }
        }
        return Events;

    }

            }
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T12:01:35+00:00Added an answer on June 16, 2026 at 12:01 pm

    I think you should read this.
    In brief – you can reuse application logic that not depends on platform-specific parts, so working with database/server can be shared between MonoTouch and Mono for Android.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a bunch of posts stored in text files formatted in yaml/textile (from
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.