Пример #1
0
        public UploadFiles(SyncView syncView)
        {
            sc = syncView;
            wc = new WebClient();

            TelephonyManager manager = (TelephonyManager)sc.GetSystemService(Context.TelephonyService);

            imei            = manager.DeviceId;
            pos             = 0;
            isNeedUploading = false;

            fileTypes = new List <string> ();
            fileTypes.Add("HospitalDB");
            fileTypes.Add("DoctorDB");
            fileTypes.Add("Demonstration");

            wc.DownloadStringCompleted += (object sender, DownloadStringCompletedEventArgs e) => {
                //XmlDocument doc = new XmlDocument();
                //doc.LoadXml(e.Result);
                //() =>Toast.MakeText(sc, fileTypes[pos] + ": " + e.Result, ToastLength.Short).Show()); //doc.GetElementById ("message").InnerText
                try {
                    Console.WriteLine(fileTypes [pos] + ": " + e.Result);
                    Console.WriteLine("FILE NEED UPLOAD: " + e.Result.Contains("FILE NEED UPLOAD").ToString());
                    isNeedUploading = isNeedUploading || e.Result.Contains("FILE NEED UPLOAD");
                    pos             = pos + 1;
                    if (fileTypes.Count == pos)
                    {
                        if (isNeedUploading)
                        {
                            sc.RunOnUiThread(() => sc.txtProgress.Visibility    = Android.Views.ViewStates.Gone);
                            sc.RunOnUiThread(() => sc.btnUploadFiles.Visibility = Android.Views.ViewStates.Visible);
                            sc.RunOnUiThread(() => sc.btnUploadFiles.Text       = "Необходима синхронизация визитов с сервером");
                        }
                        else
                        {
                            sc.RunOnUiThread(() => sc.txtProgress.Text = "Cинхронизация визитов с сервером не требуется");
                        }
                        sc.CheckAppNewVersion();
                        return;
                    }
                    else
                    {
                        CheckFiles();
                        return;
                    }
                } catch (Exception exc) {
                    sc.RunOnUiThread(() => Toast.MakeText(sc, exc.Message, ToastLength.Long).Show());
                }
            };
        }
Пример #2
0
        public UploadFiles(SyncView syncView)
        {
            sc = syncView;
            wc = new WebClient ();

            TelephonyManager manager= (TelephonyManager)sc.GetSystemService(Context.TelephonyService);
            imei = manager.DeviceId;
            pos = 0;
            isNeedUploading = false;

            fileTypes = new List<string> ();
            fileTypes.Add ("HospitalDB");
            fileTypes.Add ("DoctorDB");
            fileTypes.Add ("Demonstration");

            wc.DownloadStringCompleted += (object sender, DownloadStringCompletedEventArgs e) => {
                //XmlDocument doc = new XmlDocument();
                //doc.LoadXml(e.Result);
                //() =>Toast.MakeText(sc, fileTypes[pos] + ": " + e.Result, ToastLength.Short).Show()); //doc.GetElementById ("message").InnerText
                try {
                    Console.WriteLine (fileTypes [pos] + ": " + e.Result);
                    Console.WriteLine ("FILE NEED UPLOAD: " + e.Result.Contains ("FILE NEED UPLOAD").ToString ());
                    isNeedUploading = isNeedUploading || e.Result.Contains ("FILE NEED UPLOAD");
                    pos = pos + 1;
                    if (fileTypes.Count == pos) {
                        if (isNeedUploading) {
                            sc.RunOnUiThread (() => sc.txtProgress.Visibility = Android.Views.ViewStates.Gone);
                            sc.RunOnUiThread (() => sc.btnUploadFiles.Visibility = Android.Views.ViewStates.Visible);
                            sc.RunOnUiThread (() => sc.btnUploadFiles.Text = "Необходима синхронизация визитов с сервером");
                        } else {
                            sc.RunOnUiThread (() => sc.txtProgress.Text = "Cинхронизация визитов с сервером не требуется");
                        }
                        sc.CheckAppNewVersion ();
                        return;
                    } else {
                        CheckFiles ();
                        return;
                    }
                } catch (Exception exc) {
                    sc.RunOnUiThread (() => Toast.MakeText(sc, exc.Message, ToastLength.Long).Show());
                }
            };
        }