示例#1
0
            public Setts deserialize()
            {
                XmlSerializer ser  = new XmlSerializer(typeof(Setts));
                TextReader    tr   = new StreamReader(Constants.savefile);
                object        obj  = ser.Deserialize(tr);
                Setts         sets = (Setts)obj;

                return(sets);
            }
示例#2
0
            public void serialize(Setts sets)
            {
                XmlSerializer ser = new XmlSerializer(typeof(Setts));

                using (TextWriter tw = new StreamWriter(Constants.savefile))
                {
                    ser.Serialize(tw, sets);
                }
            }
示例#3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            Setts sett = Common.GetSettings();

            DateTimeFormatInfo dfi = DateTimeFormatInfo.CurrentInfo;
            Calendar           cal = dfi.Calendar;
            int weekDiv            = sett.weekOfStart - cal.GetWeekOfYear(DateTime.Today, dfi.CalendarWeekRule, dfi.FirstDayOfWeek);

            dayInWeek = DateTime.Today.AddDays(weekDiv % 3 * 7);

            SetContentView(Resource.Layout.PlannerGrid);

            plannerGrid = FindViewById <GridView>(Resource.Id.PlannerGrid);

            plannerGrid.ItemClick += delegate(object sender, AdapterView.ItemClickEventArgs e) {
                //Toast.MakeText(this, args.Position.ToString(), ToastLength.Short).Show();
                var plannerHospList = new Intent(this, typeof(PlannerHospitalsLists));
//				int weekNum = e.Position/7;
                plannerHospList.PutExtra("WeekNum", e.Position / 5);
                if ((e.Position + 1) % 5 == 0)
                {
                    plannerHospList.PutExtra("DayOfWeek", 5);
                }
                else
                {
                    plannerHospList.PutExtra("DayOfWeek", (e.Position + 1) % 5);
                }

                StartActivity(plannerHospList);
            };

            btnPrevWeek        = FindViewById <Button>(Resource.Id.btnPrevWeek);
            btnPrevWeek.Click += (sender, e) => {
                dayInWeek = dayInWeek.AddDays(-7);
                RefreshGrid();
                //Setts sett = Common.GetSettings ();
                if (!(sett.phone == ""))
                {
                    SmsManager.Default.SendTextMessage(sett.phone, null, "Изменен календарь: Пердыдущая неделя.", null, null);
                }
            };

            btnNextWeek        = FindViewById <Button>(Resource.Id.btnNextWeek);
            btnNextWeek.Click += (sender, e) => {
                dayInWeek = dayInWeek.AddDays(7);
                RefreshGrid();
                //Setts sett = Common.GetSettings ();
                if (!(sett.phone == ""))
                {
                    SmsManager.Default.SendTextMessage(sett.phone, null, "Изменен календарь: Слелующая неделя. ", null, null);
                }
            };
        }
示例#4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.VisitsList);

            Title = Title + "(" + DateTime.Today.ToString("D") + ")";
            Setts sett = Common.GetSettings();

            DateTimeFormatInfo dfi = DateTimeFormatInfo.CurrentInfo;
            Calendar           cal = dfi.Calendar;
            int week = (cal.GetWeekOfYear(DateTime.Today, dfi.CalendarWeekRule, dfi.FirstDayOfWeek) - sett.weekOfStart) % 3;

            var choosenHospitals = (List <Hospital>)HospitalManager.GetChoosenHospitals(week, DateTime.Today.DayOfWeek);

            FindViewById <TextView> (Resource.Id.edtAnalyze).SetSingleLine(false);
            FindViewById <TextView> (Resource.Id.edtCommentForPharmacy).SetSingleLine(false);
            FindViewById <TextView> (Resource.Id.edtPOSmaterials).SetSingleLine(false);

            FindViewById <Button> (Resource.Id.btnShow).Clickable = false;
            adapter = new VisitListAdpter(this, choosenHospitals);
            var lvList = FindViewById <ListView> (Resource.Id.lvList);

            lvList.Adapter    = adapter;          //ArrayAdapter<String> (this, Android.Resource.Layout.SimpleListItemChecked, docs);
            lvList.ChoiceMode = ChoiceMode.Single;
            lvList.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => {
                doctor = adapter [e.Position];

                //presentations
                if (presents == null)
                {
                    var lblPresents = FindViewById <TextView> (Resource.Id.PresentLabel);
                    lblPresents.Visibility = ViewStates.Visible;
                    var btnShow = FindViewById <Button> (Resource.Id.btnShow);
                    btnShow.Visibility = ViewStates.Visible;
                    var spn = FindViewById <Spinner> (Resource.Id.spnPresents);
                    spn.Visibility = ViewStates.Visible;

                    string[] load = { "Загружается список презентаций..." };
                    spn.Adapter = new ArrayAdapter <String> (this, Android.Resource.Layout.SimpleListItem1, load);
                    new Thread(new ThreadStart(delegate {
                        //LOAD METHOD TO GET ACCOUNT INFO
                        RunOnUiThread(() => {
                            presents = Presentations.GetPresentations();
                            List <String> presentsTitle = new List <String> ();
                            for (int i = 0; i < presents.Count; i++)
                            {
                                for (int j = 0; j < presents [i].parts.Count; j++)
                                {
                                    presentsTitle.Add(presents [i].name + "." + presents [i].parts [j].name);
                                }
                            }

                            spn.Adapter = new ArrayAdapter <String> (this, Android.Resource.Layout.SimpleListItem1, presentsTitle.ToArray());
                        });
                    })).Start();
                }

                FindViewById <TextView> (Resource.Id.SecondNameLabel).Text       = "Фамилия: " + doctor.SecondName;
                FindViewById <TextView> (Resource.Id.FirstNameLabel).Text        = "Имя: " + doctor.FirstName;
                FindViewById <TextView> (Resource.Id.ThirdNameLabel).Text        = "Отчество: " + doctor.ThirdName;
                FindViewById <TextView> (Resource.Id.TelLabel).Text              = "Телефон: " + doctor.Tel;
                FindViewById <TextView> (Resource.Id.EmailLabel).Text            = "E-mail: " + doctor.Email;
                FindViewById <TextView> (Resource.Id.SpecialityLabel).Text       = "Специальность: " + doctor.Speciality;
                FindViewById <TextView> (Resource.Id.PositionLabel).Text         = "Должность: " + doctor.Position;
                FindViewById <TextView> (Resource.Id.HospitalLabel).Text         = "Поликлиника: " + HospitalManager.GetHospital(doctor.HospitalID).Name;
                FindViewById <TextView> (Resource.Id.CabinetLabel).Text          = "№ кабинета: " + doctor.Cabinet;
                FindViewById <TextView> (Resource.Id.edtAnalyze).Text            = doctor.LastVisitAnalyze;
                FindViewById <TextView> (Resource.Id.edtCommentForPharmacy).Text = doctor.LastCommForPharm;
                FindViewById <TextView> (Resource.Id.edtPOSmaterials).Text       = doctor.LastPOSmaterials;
            };

            FindViewById <Button> (Resource.Id.btnShow).Click += (object sender, EventArgs e) => {
                doctor.LastVisitAnalyze = FindViewById <TextView> (Resource.Id.edtAnalyze).Text;
                doctor.LastCommForPharm = FindViewById <TextView> (Resource.Id.edtCommentForPharmacy).Text;
                doctor.LastPOSmaterials = FindViewById <TextView> (Resource.Id.edtPOSmaterials).Text;
                DoctorManager.SaveDoctor(doctor);

                var slides         = new Intent(this, typeof(VisitPresentationView));
                int presentationID = 0;
                int partID         = FindViewById <Spinner> (Resource.Id.spnPresents).SelectedItemPosition;
                for (int i = 0; (i <= presents.Count - 1) && (partID > presents [i].parts.Count - 1); i++)
                {
                    presentationID = i + 1;
                    partID         = partID - presents [i].parts.Count;
                }
                slides.PutExtra("presentationID", presentationID);
                slides.PutExtra("partID", partID);
                slides.PutExtra("doctorID", adapter [lvList.CheckedItemPosition].ID);
                StartActivity(slides);
            };
        }
示例#5
0
 public DateAdapter(Activity c, DateTime dayInWeek)
 {
     context = c;
     dt      = PlannerManager.GetWeeks(3, dayInWeek);
     setts   = Common.GetSettings();
 }
示例#6
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.SyncView);

            Window.AddFlags(WindowManagerFlags.KeepScreenOn);

            settings = Common.GetSettings();

            files = new Dictionary <string, DLFile>();

            files.Add("App", new DLFile()
            {
                path = Path.Combine(Common.DatabaseFileDir(), settings.packageName), isNew = false
            });

            files.Add("Prs", new DLFile()
            {
                path = Path.Combine(Common.DatabaseFileDir(), "presents.xml.gz"), isNew = false
            });
//			filePath = Path.Combine(Common.DatabaseFileDir(), settings.packageName);

            vrsnAppCurr = PackageManager.GetPackageInfo(PackageName, PackageInfoFlags.Activities).VersionName;
//			vrsnPrsCurr = settings.vrsnOfPresents;

            client = new WebClient();

            client.DownloadStringCompleted += (object sender, DownloadStringCompletedEventArgs e) => {
                if (File.Exists(files["Prs"].path))
                {
                    string fileText = File.ReadAllText(files["Prs"].path);
                    vrsnPrsCurr = UploadFiles.GetMd5Hash(fileText);
                }
                else
                {
                    vrsnPrsCurr = "";
                };
                try {
                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(e.Result);
                    files["App"].vrsnNew = doc.GetElementById("versionApp").InnerText;
                    files["Prs"].vrsnNew = doc.GetElementById("versionPrs").InnerText;
                    files["App"].isNew   = !bool.Equals(vrsnAppCurr, files["App"].vrsnNew);
                    files["Prs"].isNew   = !bool.Equals(vrsnPrsCurr, files["Prs"].vrsnNew);

                    if ((files["App"].isNew) || (files["Prs"].isNew))
                    {
                        RunOnUiThread(() => CheckLoadPackage());
                    }
                } catch (Exception exc) {
                    RunOnUiThread(() => Toast.MakeText(this, exc.Message, ToastLength.Long).Show());
                }
            };

            client.DownloadDataCompleted += (object sender, DownloadDataCompletedEventArgs e) => {
                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                }
                ;
                try {
                    File.WriteAllBytes(filePath, e.Result);
                    RunOnUiThread(() => txtProgress.Text = "Загрузка окончена");
                    RunOnUiThread(() => Toast.MakeText(this, "ALL", ToastLength.Short).Show());
                    RunOnUiThread(() => pB.Visibility = ViewStates.Gone);
                    RunOnUiThread(() => CheckLoadPackage());
                } catch (Exception exc) {
                    RunOnUiThread(() => Toast.MakeText(this, exc.Message, ToastLength.Long).Show());
                }
            };

            client.DownloadProgressChanged += (object sender, DownloadProgressChangedEventArgs e) => {
                if (pB.Visibility == ViewStates.Visible)
                {
                    RunOnUiThread(() => pB.Activated = true);
                    RunOnUiThread(() => pB.Max       = (int)e.TotalBytesToReceive);
                    RunOnUiThread(() => pB.Progress  = (int)e.BytesReceived);
                }
            };

            pB            = FindViewById <ProgressBar> (Resource.Id.StatusProgress);
            pB.Visibility = ViewStates.Gone;

            txtVersion      = FindViewById <TextView> (Resource.Id.txtVersion);
            txtVersion.Text = "Текущая версия программы: " + PackageManager.GetPackageInfo(PackageName, PackageInfoFlags.Activities).VersionName;

            btnUpdateApp            = FindViewById <Button> (Resource.Id.btnUpdateApp);
            btnUpdateApp.Visibility = ViewStates.Gone;

            btnDownLoadPresents            = FindViewById <Button> (Resource.Id.btnDownLoadPresents);
            btnDownLoadPresents.Visibility = ViewStates.Gone;
            btnDownLoadPresents.Click     += (object sender, EventArgs e) => {
                pB.Visibility = ViewStates.Visible;
                if (DownLoad.HasConnection(this) && !client.IsBusy)
                {
                    filePath = files ["Prs"].path;
                    client.DownloadDataAsync(new Uri(settings.dlSite + "presents.xml.gz"));
                    files ["Prs"].isNew            = false;
                    btnDownLoadPresents.Visibility = ViewStates.Gone;
                }
                else
                {
                    btnDownLoadPresents.Text = "Подождите окончания другой загрузки...";
                }
            };


            txtProgress               = FindViewById <TextView> (Resource.Id.txtProgress);
            txtProgress.Text          = "Идет сверка информации с сервером...";
            btnUploadFiles            = FindViewById <Button> (Resource.Id.btnUploadFiles);
            btnUploadFiles.Visibility = ViewStates.Gone;

            btnUploadFiles.Click += (object sender, EventArgs e) => {
                var t = new Thread(() => {
                    string loadResult = "";
                    RunOnUiThread(() => pB.Visibility    = ViewStates.Visible);
                    RunOnUiThread(() => pB.Activated     = true);
                    RunOnUiThread(() => pB.Max           = 5);
                    RunOnUiThread(() => pB.Progress      = 0);
                    RunOnUiThread(() => txtProgress.Text = "Идет синхронизация с сервером...");
                    loadResult = UploadFiles.LoadFile("Settings");
                    Console.WriteLine(loadResult);
                    RunOnUiThread(() => pB.Progress = 1);
                    //RunOnUiThread(() => txtProgress.Text = loadResult);
                    Thread.Sleep(1000);
                    loadResult = UploadFiles.LoadFile("DoctorDB");
                    Console.WriteLine(loadResult);
                    RunOnUiThread(() => pB.Progress = 2);
                    //RunOnUiThread(() => txtProgress.Text = loadResult);
                    Thread.Sleep(1000);
                    //RunOnUiThread(() => txtProgress.Text = "load HospitalDB");
                    loadResult = UploadFiles.LoadFile("HospitalDB");
                    Console.WriteLine(loadResult);
                    RunOnUiThread(() => pB.Progress = 3);
                    //RunOnUiThread(() => txtProgress.Text = loadResult);
                    Thread.Sleep(1000);
                    //RunOnUiThread(() => txtProgress.Text = "load Demonstration");
                    loadResult = UploadFiles.LoadFile("Demonstration");
                    Console.WriteLine(loadResult);
                    RunOnUiThread(() => pB.Progress = 4);
                    //RunOnUiThread(() => txtProgress.Text = loadResult);
                    Thread.Sleep(1000);
                    if (loadResult.Contains("FILE SAVED"))
                    {
                        string reportString = UploadFiles.DownLoadReport();

                        DemonstrationManager.CurrentDemonstrationToArchive();

                        var serializer = new XmlSerializer(typeof(List <Report>));
                        using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(reportString))) {
                            List <Report> dlReport  = (List <Report>)serializer.Deserialize(stream);
                            List <Report> curReport = (List <Report>)ReportManager.GetReports();
                            if (curReport.Count == 0)
                            {
                                curReport = dlReport;
                            }
                            else
                            {
                                for (int dl = 0; dl < dlReport.Count; dl++)
                                {
                                    var report = curReport.Find(r => r.doctorID == dlReport[dl].doctorID);
                                    if (report == null)
                                    {
                                        curReport.Add(dlReport[dl]);
                                    }
                                    else
                                    {
                                        for (int i = 0; i < dlReport[dl].rItems.Count; i++)
                                        {
                                            var rItem = report.rItems.Find(ri => ri.weekNum == dlReport[dl].rItems[i].weekNum);
                                            if (rItem == null)
                                            {
                                                report.rItems.Add(dlReport[dl].rItems[i]);
                                            }
                                            else
                                            {
                                                rItem.visitCount = rItem.visitCount + dlReport[dl].rItems[i].visitCount;
                                            }
                                        }
                                    }
                                }
                            }
                            if (ReportManager.SaveReports(curReport))
                            {
                                Console.WriteLine("Report saved...");
                                //RunOnUiThread(() => txtProgress.Text = "Report saved...");
                            }
                            else
                            {
                                Console.WriteLine("Report not saved...");
                                //RunOnUiThread(() => txtProgress.Text = "Report not saved...");
                            }
                        }
                    }
                    RunOnUiThread(() => pB.Progress = 5);
                    Thread.Sleep(2500);
                    Console.WriteLine("Uploading finished...");
                    RunOnUiThread(() => pB.Visibility             = ViewStates.Gone);
                    RunOnUiThread(() => txtProgress.Visibility    = ViewStates.Visible);
                    RunOnUiThread(() => txtProgress.Text          = "Синхронизация успешно завершена.");
                    RunOnUiThread(() => btnUploadFiles.Visibility = ViewStates.Invisible);
                }
                                   );
                t.Start();
                //RunOnUiThread(() => pB.Activated = true);
                //RunOnUiThread(() => pB.Max = (int)e.TotalBytesToReceive);
                //RunOnUiThread(() => pB.Progress = (int)e.BytesReceived);
                //txtProgress.Text = "load DoctorDB";
                //txtProgress.Text = UploadFiles.LoadFile("DoctorDB");//Toast.MakeText(this, "Toast within progress dialog.", ToastLength.Long).Show());
                //txtProgress.Text = "load HospitalDB";
                //txtProgress.Text = UploadFiles.LoadFile("HospitalDB");
                //Console.WriteLine ("Uploading finished...");
            };
        }