Exemple #1
0
        private void CreateAppointments()
        {
            Orders = new ScheduleAppointmentCollection();
            CreateColorCollection();
            Calendar calendar = Calendar.Instance;
            Calendar DateFrom = Calendar.Instance;

            DateFrom.Add(CalendarField.Date, -10);
            Calendar DateTo = Calendar.Instance;

            DateTo.Add(CalendarField.Date, 10);
            Calendar dateRangeStart = Calendar.Instance;

            dateRangeStart.Add(CalendarField.Date, -3);
            Calendar dateRangeEnd = Calendar.Instance;

            dateRangeEnd.Add(CalendarField.Date, 3);

            for (int index = 0; index < schedulerList.Count; index++)
            {
                ScheduleAppointment order             = new ScheduleAppointment();
                Java.Util.Calendar  startTimeCalendar = Java.Util.Calendar.Instance;

                CultureInfo provider = CultureInfo.InvariantCulture;

                DateTime startDateTime = DateTime.ParseExact(schedulerList[index].Start_date, "yyyy-MM-dd HH:mm:ss", provider);
                DateTime endDateTime   = DateTime.ParseExact(schedulerList[index].End_date, "yyyy-MM-dd HH:mm:ss", provider);

                if (startDateTime >= DateTime.Now && startDateTime != endDateTime)
                {
                    if (Orders.Count == 0)
                    {
                        minDateTime = startDateTime;
                    }
                    else
                    {
                        minDateTime = (minDateTime < startDateTime) ? minDateTime : startDateTime;
                    }
                    startTimeCalendar.Set(startDateTime.Year, startDateTime.Month - 1, startDateTime.Day, startDateTime.Hour, startDateTime.Minute);

                    order.StartTime = startTimeCalendar;

                    Calendar endTimeCalendar = Calendar.Instance;
                    endTimeCalendar.Set(endDateTime.Year, endDateTime.Month - 1, endDateTime.Day, endDateTime.Hour, endDateTime.Minute);
                    order.EndTime      = endTimeCalendar;
                    order.Color        = Color.ParseColor(colorCollection[index % colorCollection.Count]);
                    order.Subject      = schedulerList[index].Text;
                    order.RecurrenceId = int.Parse(schedulerList[index].Id);
                    Orders.Add(order);
                }
            }
        }
        public List <String[]> getEvents(int calendarid = 1)
        {
            var eventsUri = CalendarContract.Events.ContentUri;

            Console.WriteLine("whatever");
            string[] eventsProjection =
            {
                CalendarContract.Events.InterfaceConsts.Id,
                CalendarContract.Events.InterfaceConsts.Title,
                CalendarContract.Events.InterfaceConsts.Dtstart,
                CalendarContract.Events.InterfaceConsts.Dtend,
                CalendarContract.Events.InterfaceConsts.Description,
                CalendarContract.Events.InterfaceConsts.EventLocation,
                CalendarContract.Events.InterfaceConsts.EventTimezone
            };
            //Date d = new Date ();
            Java.Util.Calendar c = Java.Util.Calendar.GetInstance(Java.Util.TimeZone.GetTimeZone("Australia/Brisbane"));

            c.Add(CalendarField.Month, -1);

            Console.WriteLine("Date: " + c.Get(CalendarField.DayOfMonth) + "/" + c.Get(CalendarField.Month) + "/" + c.Get(CalendarField.Year) + " ::: " + c.TimeInMillis);

            String ww = "calendar_id=" + calendarid + " AND dtstart > " + c.TimeInMillis;

            ICursor cursor = Forms.Context.ApplicationContext.ContentResolver.Query(eventsUri, eventsProjection, ww, null, "dtstart ASC");
            //do date not datetime, write to system calendar

            List <String[]> things = new List <String[]> ();

            if (cursor.MoveToFirst())
            {
                do
                {
                    String calid  = cursor.GetString(cursor.GetColumnIndex(CalendarContract.Events.InterfaceConsts.Id));
                    String title  = cursor.GetString(cursor.GetColumnIndex(CalendarContract.Events.InterfaceConsts.Title));
                    String Dstart = cursor.GetString(cursor.GetColumnIndex(CalendarContract.Events.InterfaceConsts.Dtstart));
                    String Dend   = cursor.GetString(cursor.GetColumnIndex(CalendarContract.Events.InterfaceConsts.Dtend));
                    String desc   = cursor.GetString(cursor.GetColumnIndex(CalendarContract.Events.InterfaceConsts.Description));
                    String loc    = cursor.GetString(cursor.GetColumnIndex(CalendarContract.Events.InterfaceConsts.EventLocation));
                    Console.WriteLine(cursor.GetString(cursor.GetColumnIndex(CalendarContract.Events.InterfaceConsts.EventTimezone)));
                    things.Add(new String[] { calid, title, Dstart, Dend, desc, loc });

                    //Console.WriteLine("ID: " + calid);
                }while(cursor.MoveToNext());
            }

            cursor.Close();
            cursor.Dispose();

            return(things);
        }
Exemple #3
0
            private void CreateKey_Credentials()
            {
                var generator = KeyPairGenerator.GetInstance("RSA", AndroidKeyStore);

                if (Build.VERSION.SdkInt < BuildVersionCodes.M)
                {
                    Java.Util.Calendar calendar = Java.Util.Calendar.Instance;
                    calendar.Add(Java.Util.CalendarField.Year, 20);

                    Date startDate = Java.Util.Calendar.Instance.Time;
                    Date endDate   = calendar.Time;

#pragma warning disable 0618

                    var builder = new KeyPairGeneratorSpec.Builder(_context);

#pragma warning restore 0618

                    builder.SetAlias(KEYALIAS_CREDENTIALS);
                    builder.SetSerialNumber(Java.Math.BigInteger.One);
                    builder.SetSubject(new Javax.Security.Auth.X500.X500Principal("CN=${alias} CA Certificate"));
                    builder.SetStartDate(startDate);
                    builder.SetEndDate(endDate);

                    generator.Initialize(builder.Build());
                }
                else
                {
                    var builder = new KeyGenParameterSpec.Builder(KEYALIAS_CREDENTIALS, KeyStorePurpose.Encrypt | KeyStorePurpose.Decrypt);
                    builder.SetBlockModes(KeyProperties.BlockModeEcb);
                    builder.SetEncryptionPaddings(KeyProperties.EncryptionPaddingRsaPkcs1);
                    generator.Initialize(builder.Build());
                }

                generator.GenerateKeyPair();
            }
        public IList <WeekViewEvent> OnMonthChange(int newYear, int newMonth)
        {
            // Populate the week view with some events.
            List <WeekViewEvent> events = new List <WeekViewEvent>();

            Java.Util.Calendar startTime = Java.Util.Calendar.Instance;
            startTime.Set(CalendarField.HourOfDay, 3);
            startTime.Set(CalendarField.Minute, 0);
            startTime.Set(CalendarField.Month, newMonth - 1);
            startTime.Set(CalendarField.Year, newYear);
            Java.Util.Calendar endTime = (Java.Util.Calendar)startTime.Clone();
            endTime.Add(CalendarField.Hour, 1);
            endTime.Set(CalendarField.Month, newMonth - 1);
            WeekViewEvent _event = new WeekViewEvent(1, getEventTitle(startTime), startTime, endTime);

            _event.Color = Resources.GetColor(Resource.Color.event_color_01);
            events.Add(_event);

            startTime = Java.Util.Calendar.Instance;
            startTime.Set(CalendarField.HourOfDay, 3);
            startTime.Set(CalendarField.Minute, 30);
            startTime.Set(CalendarField.Month, newMonth - 1);
            startTime.Set(CalendarField.Year, newYear);
            endTime = (Java.Util.Calendar)startTime.Clone();
            endTime.Set(CalendarField.HourOfDay, 4);
            endTime.Set(CalendarField.Minute, 30);
            endTime.Set(CalendarField.Month, newMonth - 1);
            _event       = new WeekViewEvent(10, getEventTitle(startTime), startTime, endTime);
            _event.Color = Resources.GetColor(Resource.Color.event_color_02);
            events.Add(_event);

            startTime = Java.Util.Calendar.Instance;
            startTime.Set(CalendarField.HourOfDay, 4);
            startTime.Set(CalendarField.Minute, 20);
            startTime.Set(CalendarField.Month, newMonth - 1);
            startTime.Set(CalendarField.Year, newYear);
            endTime = (Java.Util.Calendar)startTime.Clone();
            endTime.Set(CalendarField.HourOfDay, 5);
            endTime.Set(CalendarField.Minute, 0);
            _event       = new WeekViewEvent(10, getEventTitle(startTime), startTime, endTime);
            _event.Color = Resources.GetColor(Resource.Color.event_color_03);
            events.Add(_event);

            startTime = Calendar.Instance;
            startTime.Set(CalendarField.HourOfDay, 5);
            startTime.Set(CalendarField.Minute, 30);
            startTime.Set(CalendarField.Month, newMonth - 1);
            startTime.Set(CalendarField.Year, newYear);
            endTime = (Java.Util.Calendar)startTime.Clone();
            endTime.Add(CalendarField.HourOfDay, 2);
            endTime.Set(CalendarField.Month, newMonth - 1);
            _event          = new WeekViewEvent(2, getEventTitle(startTime), startTime, endTime);
            _event.Location = "Hinjewadi Pune";
            _event.Color    = Resources.GetColor(Resource.Color.event_color_04);
            events.Add(_event);

            startTime = Java.Util.Calendar.Instance;
            startTime.Set(CalendarField.HourOfDay, 5);
            startTime.Set(CalendarField.Minute, 0);
            startTime.Set(CalendarField.Month, newMonth - 1);
            startTime.Set(CalendarField.Year, newYear);
            startTime.Add(CalendarField.Date, 1);
            endTime = (Java.Util.Calendar)startTime.Clone();
            endTime.Add(CalendarField.HourOfDay, 3);
            endTime.Set(CalendarField.Month, newMonth - 1);

            _event          = new WeekViewEvent(3, getEventTitle(startTime), startTime, endTime);
            _event.Location = "Hinjewadi Pune";
            _event.Color    = Resources.GetColor(Resource.Color.event_color_01);
            events.Add(_event);

            startTime = Java.Util.Calendar.Instance;
            startTime.Set(CalendarField.DayOfMonth, 15);
            startTime.Set(CalendarField.HourOfDay, 3);
            startTime.Set(CalendarField.Minute, 0);
            startTime.Set(CalendarField.Month, newMonth - 1);
            startTime.Set(CalendarField.Year, newYear);
            endTime = (Java.Util.Calendar)startTime.Clone();
            endTime.Add(CalendarField.HourOfDay, 3);

            _event          = new WeekViewEvent(4, getEventTitle(startTime), startTime, endTime);
            _event.Location = "Hinjewadi Pune";
            _event.Color    = Resources.GetColor(Resource.Color.event_color_02);
            events.Add(_event);

            startTime = Java.Util.Calendar.Instance;
            startTime.Set(CalendarField.DayOfMonth, 1);
            startTime.Set(CalendarField.HourOfDay, 3);
            startTime.Set(CalendarField.Minute, 0);
            startTime.Set(CalendarField.Month, newMonth - 1);
            startTime.Set(CalendarField.Year, newYear);
            endTime = (Java.Util.Calendar)startTime.Clone();
            endTime.Add(CalendarField.HourOfDay, 3);
            _event          = new WeekViewEvent(5, getEventTitle(startTime), startTime, endTime);
            _event.Location = "Hinjewadi Pune";
            _event.Color    = Resources.GetColor(Resource.Color.event_color_03);
            events.Add(_event);

            startTime = Java.Util.Calendar.Instance;
            startTime.Set(CalendarField.DayOfMonth, startTime.GetActualMaximum(Java.Util.Calendar.DayOfMonth));
            startTime.Set(CalendarField.HourOfDay, 15);
            startTime.Set(CalendarField.Minute, 0);
            startTime.Set(CalendarField.Month, newMonth - 1);
            startTime.Set(CalendarField.Year, newYear);
            endTime = (Java.Util.Calendar)startTime.Clone();
            endTime.Add(CalendarField.HourOfDay, 3);
            _event       = new WeekViewEvent(5, getEventTitle(startTime), startTime, endTime);
            _event.Color = Android.Graphics.Color.ParseColor("#59dbe0");
            events.Add(_event);

            return(events);
        }