Ejemplo n.º 1
0
        public static string SerializeObj(AlertsDataTransfer allalerts)
        {
            var serializer = new System.Xml.Serialization.XmlSerializer(allalerts.GetType());
            var ms = new MemoryStream();
            serializer.Serialize(ms, allalerts);

            byte[] bytes = ms.ToArray();
            ms.Close();
            return System.Text.Encoding.UTF8.GetString(bytes, 0, bytes.Length);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Helper method to return a stub object for the purpose of debugging
        /// </summary>
        /// <returns></returns>
        public static AlertsDataTransfer CreateStub(int countAssignedTasks, int countManagedTasks)
        {
            var trfr = new AlertsDataTransfer
                           {
                               AssignedTasks = new ObservableCollection<TaskItem>(),
                               ManagedTasks = new ObservableCollection<TaskItem>()
                           };

            int sec = DateTime.Now.Second; //to inroduce a variability in the data 
            int count = countAssignedTasks;
            while (count > 0)
            {
                var  a = new TaskItem  
                                { 
                                    TaskName = "Some task" + count, 
                                    DueTime = (sec % 12 + 9) +":00",
                                    AssignedTo = "username:"******"abcdefghijklmnopqrstuvwxyz01234567890123456789";

                count--;
            }

            count = countManagedTasks;
            while (count > 0)
            {
                var a = new TaskItem  
                                    { 
                                    TaskName = "ManagedName:" + count,
                                    DueTime = (sec % 12 + 9) + ":00",
                                    AssignedTo = "user-"+sec,
                                    CreatedUtc =DateTime.Now.Date  
                                    };
                trfr.ManagedTasks.Add(a);
                count--;
            }

            trfr.TotalAlerts = DateTime.Now.Second;
            return trfr;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This will query the alerts data that is currently held by the model and
        /// prepara a smaller subset of data that needs to be displayed in the Popup UI
        /// </summary>
        /// <param name="vm"></param>
        /// <param name="alertCategory"> </param>
        /// <returns></returns>
        public static AlertsDataTransfer CreateFromModel(ViewModel vm ,AlertsCategory alertCategory)
        {
            var trfr = new AlertsDataTransfer {CurrentTimeZone = ViewModel.Current.RegionalSettings.ActiveTimeZone};


            IEnumerable<TaskItem>   queryTasksAlerts=null;
            ObservableCollection<TaskItem> alertsCollection = null;

            if (alertCategory == AlertsCategory.AlertAssignedTasks)
            {
                queryTasksAlerts= vm.TaskAlerts.AssignedTasksAlerts;
                alertsCollection = trfr.AssignedTasks;
                Debug.WriteLine("Creating alerts for Assigned tasks");
            }

            if (alertCategory == AlertsCategory.AlertsManagedTasks)
            {
                queryTasksAlerts = vm.TaskAlerts.ManagedTasksAlerts;
                alertsCollection = trfr.ManagedTasks;
                Debug.WriteLine("Creating alerts for Managed tasks");
            }

            int count = MaxRowsToTransfer;
            
            foreach (TaskItem t in queryTasksAlerts )
            {
                TaskItem d = t.Clone();
                alertsCollection.Add(d);
                
                count--;
                if (count <= 0) break;
            }

            trfr.TotalAlerts = queryTasksAlerts.Count();
            Debug.WriteLine( string.Format ( "Created a total of {0}",trfr.TotalAlerts ));

            return trfr;
        }