public static ObservableCollection <SimpleProjectViewModel> GetAll(EnumSession session) { using (var conn = new SqlConnection(Properties.Settings.Default.ConnString)) { var result = conn.Query <ProjectModel>($@" SELECT [ProjectID] ProjectID ,[Project Name] ProjectName ,[Start Date] StartDate ,[End Date] EndDate ,[Alert Date] AlertDate ,[Status] Status ,[Division] Division ,[Priority] Priority ,[Comments] Comments ,[value] Value ,[description] Description ,[url] Url ,[color] Color ,[Attachment] Attachment ,[Assignees] Assignees ,[Assigners] Assigners ,[EMS_Version] EMS_Version ,[Value Current Year] CurrentValue ,[Category] Category FROM [dbo].[Projects] WHERE [EMS_Version] = '{VersionSelector.SelectedVersionEnum.EMS_Version}' ").Select(x => new SimpleProjectViewModel(x, session)).ToList(); return(new ObservableCollection <SimpleProjectViewModel>(result)); } }
//public DelegateCommand SaveProject { get; set; } #endregion public MainViewModel() { //Session = new EMSSession(); Session = new EnumSession(); //try { Projects = SimpleProjectViewModel.GetAll(Session); //MIGRATE HERE //Migration(Projects, 4); ViewColProjects = CollectionViewSource.GetDefaultView(Projects); } //catch (Exception ex) //{ // while (ex.InnerException != null) // ex = ex.InnerException; // MessageBox.Show("Error with getting projects:" + ex.Message); //} //Binding b = new Binding("Projects"); //b.Source = Projects; //b.Mode = BindingMode.OneWay; //BindingOperations.SetBinding(, CollectionViewSource.SourceProperty, b); ViewColProjects.Filter = filterAll; FontIncrease = new Prism.Commands.DelegateCommand(() => ++ FontSize); FontDecrease = new Prism.Commands.DelegateCommand(() => -- FontSize); SaveAsExcel = new Prism.Commands.DelegateCommand(saveToExcel); NewProjectCommand = new Prism.Commands.DelegateCommand(NewProject); }
public SimpleProjectViewModel(EnumSession session) { this.Model = new ProjectModel(); NotifyCommand = new DelegateCommand(ExecuteNotify, CanNotify); this.Model.EMS_Version = VersionSelector.SelectedVersionEnum.EMS_Version; Assignees = new ObservableCollection <EnumerationModel>(); Assigners = new ObservableCollection <EnumerationModel>(); }
public SimpleProjectViewModel(ProjectModel model, EnumSession session) { this.Model = model; NotifyCommand = new DelegateCommand(ExecuteNotify, CanNotify); var users = session.Users; Assignees = new ObservableCollection <EnumerationModel>(getUsers(users, model.Assignees)); Assigners = new ObservableCollection <EnumerationModel>(getUsers(users, model.Assigners)); }
public static bool SessionUsuario(MODLoginUsuario registro, EnumSession peticion) { List <MODLoginUsuario> actual = new List <MODLoginUsuario>(); actual.AddRange(Logueos); switch (peticion) { case EnumSession._inicio: int _tiempo = Convert.ToInt32(Configuraciones.ObtenerConfiguracion("Contexto", "TiempoSession")); if ((Logueos.Any(y => y.UserName == registro.UserName && (DateTime.Now - y.Fecha).TotalMinutes > _tiempo)) || (Logueos.Any(y => y.UserName == registro.UserName && y.IP == registro.IP))) { registro.Fecha = DateTime.Now; actual.Remove(Logueos.FirstOrDefault(y => y.UserName == registro.UserName)); actual.Add(registro); } else if (!Logueos.Any(y => y.UserName == registro.UserName)) { registro.Fecha = DateTime.Now; actual.Add(registro); } else { return(false); } break; case EnumSession._peticion: if (Logueos.Any(y => y.UserName == registro.UserName)) { actual.FirstOrDefault(y => y.UserName == registro.UserName).Fecha = DateTime.Now; } else { return(false); } break; case EnumSession._cierre: Logueos.Remove(Logueos.FirstOrDefault(y => y.UserName == registro.UserName)); break; default: break; } ConfiguracionNegocio.Logueos = actual; return(true); }
public NewUserView(EnumSession session) { this.Session = session; InitializeComponent(); }