Example #1
0
        private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
        {
            string         hashed = iRadiate.Common.Authentication.Authenticator.HashPassword(PasswordBox.Password);
            IDataStoreItem d      = (this.DataContext as DataStoreItemViewModel).Item;

            (d as User).Password = hashed;
        }
Example #2
0
        public virtual object GetPropertyValue(IDataStoreItem item)
        {
            var val = getValue(item, Name);

            if (val == null)
            {
                switch (PropertyType)
                {
                case (QueryablePropertyType.DateTime):
                    return(new DateTime());

                case (QueryablePropertyType.Number):
                    return(0);

                case (QueryablePropertyType.Enumeration):
                    return(0);

                default:
                    return(null);
                }
            }
            else
            {
                return(val);
            }
        }
        public virtual void SetItem(IDataStoreItem Item)
        {
            _item = Item;
            RaisePropertyChanged("Item");

            Item.PropertyChanged += Item_PropertyChanged;
        }
Example #4
0
 public DiaryEventWrapper(ScanTask task, DiaryViewModel diaryViewModel)
 {
     _event             = task;
     _eventType         = EventType.Scan;
     _diaryViewModel    = diaryViewModel;
     _allRooms          = new List <IDataStoreItem>();
     _allRooms          = DesktopApplication.Librarian.GetItems(typeof(Room), new List <RetrievalCriteria>()).ToList();
     ViewDetailsCommand = new RelayCommand(viewDetails);
 }
Example #5
0
 public void DeleteItem(IDataStoreItem item)
 {
     lock (thisLock)
     {
         item.Deleted      = true;
         item.DeletionDate = DateTime.Now;
         SaveItem(item);
     }
 }
Example #6
0
 public AppointmentViewModel(IDataStoreItem item)
     : base(item)
 {
     foreach (BasicTask bt in ((Appointment)Item).Tasks)
     {
         Tasks.Add(bt);
     }
     TasksView.Filter = new Predicate <object>(FilterTask);
     TasksView.SortDescriptions.Add(new SortDescription("SchedulingTime", ListSortDirection.Ascending));
 }
Example #7
0
 public override void SetItem(IDataStoreItem item)
 {
     _item = item;
     Wards = DesktopApplication.CreateCollection();
     foreach (Ward w in ((Hospital)Item).Wards)
     {
         //Wards.Add(Application.GetLibrarian().GetViewModel(w));
     }
     RaisePropertyChanged("Item");
 }
Example #8
0
 public override object GetPropertyValue(IDataStoreItem item)
 {
     if (item is Patient)
     {
         var p = (Patient)item;
         return(p.Studies.Where(x => x.IsCancelled == false).Count());
     }
     else
     {
         return(0);
     }
 }
Example #9
0
        private void AddDataStoreItemAlterations(IDataStoreItem item)
        {
            foreach (PropertyInfo p in item.ConcreteType.GetProperties())
            {
                System.Diagnostics.Debug.WriteLine("p.Name = " + p.Name);
                Attribute[] attrs = Attribute.GetCustomAttributes(p);
                foreach (System.Attribute attr in attrs)
                {
                    System.Diagnostics.Debug.WriteLine("attr.ToString() = " + attr.ToString());
                    if (attr is AuditableAttribute)
                    {
                        Type t      = p.PropertyType;
                        var  oldVal = db.Entry(item).OriginalValues.GetValue <object>(p.Name);

                        PropertyInfo pi = item.GetType().GetProperty(p.Name);
                        if (oldVal == null)
                        {
                            System.Diagnostics.Debug.WriteLine("oldVal IS null");
                            DataStoreItemAlteration d = new DataStoreItemAlteration();

                            d.ItemIDNumber = item.ID;
                            d.Workstation  = Platform.CurrentWorkstation;
                            d.PropertyName = p.Name;
                            d.OldValue     = "";
                            if (pi.GetValue(item, null) == null)
                            {
                                d.NewValue = "";
                            }
                            else
                            {
                                d.NewValue          = pi.GetValue(item, null).ToString();
                                d.DataStoreItemName = item.ConcreteType.Name;
                                db.DataStoreItemAlterations.Add(d);
                            }
                        }
                        else if (pi.GetValue(item, null).ToString() != oldVal.ToString())
                        {
                            System.Diagnostics.Debug.WriteLine("oldVal is Not null");

                            DataStoreItemAlteration d = new DataStoreItemAlteration();
                            d.ItemIDNumber      = item.ID;
                            d.Workstation       = Platform.CurrentWorkstation;
                            d.PropertyName      = p.Name;
                            d.OldValue          = oldVal.ToString();
                            d.NewValue          = pi.GetValue(item, null).ToString();
                            d.DataStoreItemName = item.ConcreteType.Name;
                            db.DataStoreItemAlterations.Add(d);
                        }
                    }
                }
            }
        }
Example #10
0
        private void AddDataStoreItemAlterations(IDataStoreItem item)
        {
            foreach (PropertyInfo p in item.ConcreteType.GetProperties())
            {
                if (p.Name == "LastEditDate")
                {
                    continue;
                }
                if (!p.CanWrite)
                {
                    continue;
                }
                if (p.PropertyType.IsPrimitive || p.PropertyType == typeof(string) || p.PropertyType == typeof(DateTime))
                {
                    Type t      = p.PropertyType;
                    var  oldVal = db.Entry(item).OriginalValues.GetValue <object>(p.Name);

                    PropertyInfo pi = item.GetType().GetProperty(p.Name);
                    if (oldVal == null)
                    {
                        DataStoreItemAlteration d = new DataStoreItemAlteration();
                        d.ItemIDNumber = item.ID;
                        d.Workstation  = null;
                        d.PropertyName = p.Name;
                        d.OldValue     = "";
                        if (pi.GetValue(item, null) == null)
                        {
                            d.NewValue = "";
                        }
                        else
                        {
                            d.NewValue = pi.GetValue(item, null).ToString();
                        }

                        d.DataStoreItemName = item.ConcreteType.Name;
                        db.DataStoreItemAlterations.Add(d);
                    }
                    else if (pi.GetValue(item, null).ToString() != oldVal.ToString())
                    {
                        DataStoreItemAlteration d = new DataStoreItemAlteration();

                        d.Workstation       = null;
                        d.PropertyName      = p.Name;
                        d.OldValue          = oldVal.ToString();
                        d.NewValue          = pi.GetValue(item, null).ToString();
                        d.DataStoreItemName = item.ConcreteType.Name;
                        db.DataStoreItemAlterations.Add(d);
                    }
                }
            }
        }
Example #11
0
 private void UpdateLinkedItems(IDataStoreItem item)
 {
     if (item.LinkedItems.Any())
     {
         foreach (IDataStoreItem i in item.LinkedItems)
         {
             db.Entry(i).State = EntityState.Modified;
             i.LastEditDate    = DateTime.Now;
             AddDataStoreItemAlterations(i);
             UpdateLinkedItems(i);
         }
         item.LinkedItems.Clear();
     }
 }
Example #12
0
 public void UpdateItem(IDataStoreItem item)
 {
     lock (thisLock)
     {
         db.Entry(item).Reload();
         if (item is Appointment)
         {
             //System.Diagnostics.Debug.WriteLine("Item being updated is appointment, Tasks will be loaded");
             //db.Entry(item).Reference(p => (p as Appointment).Tasks).Load();
             //db.Entry(item).Reference("Tasks").Load();
             db.Entry(item).Collection(p => (p as Appointment).Tasks).Load();
         }
     }
 }
Example #13
0
 public override void SetItem(IDataStoreItem item)
 {
     _item  = item;
     _rooms = new ObservableCollection <Room>();
     _roles = new ObservableCollection <StaffMemberRoleViewModel>();
     foreach (Room r in ((NucMedPractice)Item).Rooms)
     {
         _rooms.Add(r);
     }
     foreach (StaffMemberRole m in ((NucMedPractice)Item).Roles.Where(x => x.ParentRole == null).ToList())
     {
         _roles.Add(new StaffMemberRoleViewModel(m));
     }
     _studyTypes = new ObservableCollection <StudyTypeViewModel>();
     foreach (StudyType st in ((NucMedPractice)Item).StudyTypes)
     {
         StudyTypeViewModel stvm = new StudyTypeViewModel();
         stvm.SetItem(st);
         _studyTypes.Add(stvm);
     }
 }
Example #14
0
        public void GetAlterations(IDataStoreItem item)
        {
            item.Alterations.Clear();
            System.Diagnostics.Debug.Print("GetAlterations(DatastoreItem item)....");
            RetrievalCriteria        rc1    = new RetrievalCriteria("DataStoreItemName", CriteraType.ExactTextMatch, item.ConcreteType.Name);
            RetrievalCriteria        rc2    = new RetrievalCriteria("ItemIDNumber", CriteraType.Equals, item.ID);
            List <RetrievalCriteria> rcList = new List <RetrievalCriteria>();

            rcList.Add(rc1);
            rcList.Add(rc2);
            System.Diagnostics.Debug.Print("    abou to get tmpList");
            AsyncObservableCollection <IDataStoreItem> tmpList = GetItems(typeof(DataStoreItemAlteration), rcList);

            System.Diagnostics.Debug.Print("    tmpList retrieved");
            foreach (IDataStoreItem i in tmpList)
            {
                System.Diagnostics.Debug.Print("         " + i.ConcreteType.Name);
                item.Alterations.Add(i as DataStoreItemAlteration);
            }
            System.Diagnostics.Debug.Print("GetAlterations(DatastoreItem item....Complete!");
        }
Example #15
0
 public void ReloadItem(IDataStoreItem item)
 {
 }
Example #16
0
 public NewDataStoreItemEventArgs(IDataStoreItem newItem)
 {
     NewItem = newItem;
 }
Example #17
0
 public DataStoreItemViewModel(IDataStoreItem item) : base()
 {
     SetItem(item);
     item.PropertyChanged += Item_PropertyChanged;
     NonUIThreadInitialize();
 }
Example #18
0
        private object getValue(IDataStoreItem item, string property)
        {
            //System.Diagnostics.Debug.WriteLine("finding property " + property + " on " + item.ConcreteType.Name);
            Type t = item.GetType();

            if (!property.Contains(">"))
            {
                var p = t.GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.Name == property).First();
                if (p.GetValue(item) == null)
                {
                    //System.Diagnostics.Debug.WriteLine("Returning string.empty");
                    return(null);
                }

                //System.Diagnostics.Debug.WriteLine("Returning " + p.GetValue(item).ToString());
                return(p.GetValue(item));
            }
            else
            {
                var    s        = property.Split('>');
                string typeName = s[0];
                string prName   = property.Remove(0, typeName.Length + 1);
                //System.Diagnostics.Debug.WriteLine("typeName = " + typeName + ", prName = " + prName);
                var p = t.GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.Name == typeName).First();

                if (p.GetValue(item) == null)
                {
                    //System.Diagnostics.Debug.WriteLine("Returning string.empty");
                    return(null);
                }

                var obj = p.GetValue(item);
                //System.Diagnostics.Debug.WriteLine("obj is " + (obj as IDataStoreItem).ConcreteType.Name);
                //obj will be the IDataStoreItem that matches typeName

                if (s.Length > 2)
                {
                    //System.Diagnostics.Debug.WriteLine("s.Length > 2");
                    string newString = "";
                    for (int i = 1; i < s.Length; i++)
                    {
                        newString = s[i] + ">";
                    }
                    newString = newString.Remove(newString.Length - 1);
                    //System.Diagnostics.Debug.WriteLine("newString = " + newString);
                    return(getValue(obj as IDataStoreItem, prName));
                }
                else
                {
                    //System.Diagnostics.Debug.WriteLine("s.Length !> 2");
                    var y = obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.Name == prName).First();
                    if (y.GetValue(obj) == null)
                    {
                        System.Diagnostics.Debug.WriteLine("Returning string.empty");
                        return(null);
                    }

                    //System.Diagnostics.Debug.WriteLine("Returning " + y.GetValue(obj).ToString());
                    return(y.GetValue(obj));
                }
            }
        }
Example #19
0
        public void UpdateAppointments()
        {
            DateTime start = DateTime.Now;

            lock (thisLock)
            {
                try
                {
                    foreach (AppointmentList al in AppointmentLists)
                    {
                        try
                        {
                            List <RetrievalCriteria> rc    = new List <RetrievalCriteria>();
                            RetrievalCriteria        first = new RetrievalCriteria("ScheduledArrivalTime", CriteraType.GreaterThan, al.SelectedDate.Date);
                            rc.Add(first);
                            RetrievalCriteria second = new RetrievalCriteria("ScheduledArrivalTime", CriteraType.LessThan, al.SelectedDate.Date.AddDays(1));
                            rc.Add(second);

                            //Create a new retriever item
                            EFDataRetriever spareRetriever = new EFDataRetriever();

                            List <IDataStoreItem> items = spareRetriever.RetrieveItems(typeof(Appointment), rc, true);

                            foreach (IDataStoreItem dt in items)
                            {
                                //rmember dt = item fress from database
                                //check if this already exists in the list of appointments
                                if (al.Appointments.Where(x => x.ID == dt.ID).Any())
                                {
                                    //this means this items is in the appointment list, we must check for updates
                                    IDataStoreItem oldItem = al.Appointments.Where(x => x.ID == dt.ID).First();


                                    if (oldItem.LastEditDate != dt.LastEditDate)
                                    {
                                        logger.Trace("Found appointment in current list -- Needs to be updated");

                                        retriever.UpdateItem(oldItem);
                                    }
                                    else
                                    {
                                    }

                                    //Now we check all the tasks for this appointment
                                    foreach (BasicTask bt in ((Appointment)dt).Tasks)
                                    {
                                        try
                                        {
                                            if (((Appointment)oldItem).Tasks.Where(x => x.ID == bt.ID).Any())
                                            {
                                                //this task is already in the appointment - check for updates needed
                                                BasicTask ot = ((Appointment)oldItem).Tasks.Where(x => x.ID == bt.ID).First();
                                                if (ot.LastEditDate != bt.LastEditDate)
                                                {
                                                    retriever.UpdateItem(ot);
                                                }
                                                //foreach (BaseConstraint c in bt.Constraints)
                                                //{
                                                //    if (ot.Constraints.Where(x => x.ID == c.ID).Any())
                                                //    {
                                                //        //this constraint exists in our version
                                                //        if (ot.Constraints.Where(x => x.ID == c.ID).First().LastEditDate != c.LastEditDate)
                                                //        {
                                                //            retriever.UpdateItem(ot.Constraints.Where(x => x.ID == c.ID).First());

                                                //        }
                                                //    }
                                                //    else
                                                //    {



                                                //    }
                                                //}
                                            }
                                            else
                                            {
                                                //need to add this task
                                                //(oldItem as Appointment).Tasks.Add(bt);

                                                retriever.UpdateItem(oldItem);
                                                System.Diagnostics.Debug.WriteLine("New task found ... appointment reloaded");
                                                if (bt is ArrivalTask)
                                                {
                                                    System.Diagnostics.Debug.WriteLine("task being added is arrivalTask");
                                                    (oldItem as Appointment).FireArrivalEvent();
                                                }
                                                else
                                                {
                                                    System.Diagnostics.Debug.WriteLine("task being added is NOT arrivalTask");
                                                }
                                                retriever.SaveItem(oldItem);
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            System.Diagnostics.Debug.WriteLine("Exception: " + ex.Message);
                                        }
                                    }
                                }
                                else
                                {
                                    //This one is not in the list of appointments must add it.
                                    logger.Trace("Could not find this appointment in the current list");

                                    al.Appointments.Add(dt);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Caught exception during appointment refresh: " + ex.Message);
                        }
                    }
                }
                catch
                {
                }

                logger.Trace("UpdateAppointments()...done");
            }
        }
Example #20
0
 public BaseTaskViewModel(IDataStoreItem item) : base(item)
 {
 }
Example #21
0
 public void DeleteItem(IDataStoreItem item)
 {
     retriever.DeleteItem(item);
 }
Example #22
0
 public PatientViewModel(IDataStoreItem item)
     : base(item)
 {
 }
Example #23
0
 public void UndeleteItem(IDataStoreItem item)
 {
     retriever.UnDeleteItem(item);
 }
Example #24
0
 public void UpdateOriginalRowVersion(IDataStoreItem item)
 {
     //db.db.Entry(item).OriginalValues.SetValues()
 }
Example #25
0
 public void SaveItem(IDataStoreItem item)
 {
     item.FireSavingEvent();
     retriever.SaveItem(item);
     item.FireSavedEvent();
 }
Example #26
0
        public bool FilterItem(IDataStoreItem item)
        {
            string val = GetPropertyValue((IDataStoreItem)item).ToString();

            if (PropertyType == QueryablePropertyType.Text)
            {
                if (FilterOperator == "Contains")
                {
                    if (val.ToLower().Contains(FilterValue.ToLower()))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (FilterOperator == "Equals")
                {
                    if (val.ToLower() == FilterValue.ToLower())
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(true);
                }
            }
            else if (PropertyType == QueryablePropertyType.Number)
            {
                double valNum       = Convert.ToDouble(val);
                double filterValNum = 0;
                if (FilterValue == String.Empty)
                {
                }
                else
                {
                    filterValNum = Convert.ToDouble(FilterValue.Trim());
                }


                if (FilterOperator == "<")
                {
                    if (valNum < filterValNum)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (FilterOperator == ">")
                {
                    if (valNum > filterValNum)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (FilterOperator == "=")
                {
                    if (valNum == filterValNum)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (FilterOperator == "<=")
                {
                    if (valNum <= filterValNum)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (FilterOperator == ">=")
                {
                    if (valNum >= filterValNum)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            else if (PropertyType == QueryablePropertyType.DateTime)
            {
                DateTime valDate = Convert.ToDateTime(val).Date;
                if (FilterOperator == "Between")
                {
                    var      s         = FilterValue.Split(' ');
                    DateTime startDate = Convert.ToDateTime(s[0]);
                    DateTime endDate   = Convert.ToDateTime(s[2]);
                    if (valDate >= startDate && valDate < endDate)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                DateTime filterDate = new DateTime();

                if (DateTime.TryParse(FilterValue, out filterDate))
                {
                }


                if (FilterOperator == "On")
                {
                    if (filterDate == valDate)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (FilterOperator == "After")
                {
                    if (valDate > filterDate)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (FilterOperator == "Before")
                {
                    if (valDate < filterDate)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (FilterOperator == "Today")
                {
                    if (valDate >= DateTime.Today && valDate < DateTime.Today.AddDays(1))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (FilterOperator == "Yesterday")
                {
                    if (valDate >= DateTime.Today.AddDays(-1) && valDate < DateTime.Today)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (FilterOperator == "This Week")
                {
                    int diff = (Convert.ToInt16(DateTime.Today.DayOfWeek) - 1) * -1;
                    if (valDate >= DateTime.Today.AddDays(diff) && valDate < DateTime.Today.AddDays(7 + diff))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (FilterOperator == "Last Week")
                {
                    int diff = (Convert.ToInt16(DateTime.Today.DayOfWeek) - 1) * -1;
                    if (valDate >= DateTime.Today.AddDays(diff - 7) && valDate < DateTime.Today.AddDays(7 + diff - 7))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (FilterOperator == "This Month")
                {
                    int month = DateTime.Today.Month;
                    int year  = DateTime.Today.Year;
                    if (valDate >= new DateTime(year, month, 1) && valDate < new DateTime(year, month + 1, 1))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (FilterOperator == "Last Month")
                {
                    int month = DateTime.Today.Month;
                    int year  = DateTime.Today.Year;
                    if (valDate >= new DateTime(year, month - 1, 1) && valDate < new DateTime(year, month, 1))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (FilterOperator == "This Year")
                {
                    int month = DateTime.Today.Month;
                    int year  = DateTime.Today.Year;
                    if (valDate >= new DateTime(year, 1, 1) && valDate < new DateTime(year + 1, 1, 1))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (FilterOperator == "Last Year")
                {
                    int month = DateTime.Today.Month;
                    int year  = DateTime.Today.Year;
                    if (valDate >= new DateTime(year - 1, 1, 1) && valDate < new DateTime(year, 1, 1))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            else if (PropertyType == QueryablePropertyType.Enumeration)
            {
                var s = FilterValue.ToString();
                if (val == s)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (PropertyType == QueryablePropertyType.Boolean)
            {
                var s = Convert.ToBoolean(FilterValue);
                var b = Convert.ToBoolean(val);
                if (s == b)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            return(false);
        }
Example #27
0
 public void UpdateItem(IDataStoreItem item)
 {
     db.Entry(item).Reload();
 }
Example #28
0
        public void UnDeleteItem(IDataStoreItem item)
        {
            item.Deleted = false;

            SaveItem(item);
        }
Example #29
0
 public void AddInventoryItem(IDataStoreItem item)
 {
     InventoryItems.Add(item);
 }
 public override void SetItem(IDataStoreItem Item)
 {
     base.SetItem(Item);
 }