Ejemplo n.º 1
0
        public List<Entity> FindEntities(EntityType entityType, string searchString, string stateFilter)
        {
            var templateId = entityType != null ? entityType.Id : 0;
            var searchValue = searchString.ToLower();

            using (var w = WorkspaceFactory.CreateReadOnly())
            {
                var result =
                    w.Query<Entity>(
                        x =>
                        x.EntityTypeId == templateId &&
                        (x.CustomData.Contains(searchString) || x.Name.ToLower().Contains(searchValue))).Take(250).ToList();

                if (entityType != null)
                    result = result.Where(x => entityType.GetMatchingFields(x, searchString).Any(y => !y.Hidden) || x.Name.ToLower().Contains(searchValue)).ToList();

                if (!string.IsNullOrEmpty(stateFilter))
                {
                    var sv = string.Format("\"S\":\"{0}\"", stateFilter);
                    var set = result.Select(x => x.Id).ToList();
                    var ids = w.Queryable<EntityStateValue>().Where(x => set.Contains(x.EntityId) && x.EntityStates.Contains(sv)).GroupBy(x => x.EntityId).Select(x => x.Max(y => y.Id));
                    var entityIds = w.Queryable<EntityStateValue>().Where(x => ids.Contains(x.Id)).Select(x => x.EntityId).ToList();
                    result = result.Where(x => entityIds.Contains(x.Id)).ToList();
                }
                return result;
            }
        }
Ejemplo n.º 2
0
 private static Entity CreateEntity(IWorkspace workspace, string name, EntityType currentEntityType)
 {
     var entityName = name.ToLower().Trim();
     return workspace.Single<Entity>(x => x.Name.ToLower() == entityName) != null
         ? null
         : new Entity { Name = name, EntityTypeId = currentEntityType.Id };
 }
Ejemplo n.º 3
0
 public EntityScreenItem(EntityType entityType, Entity entity, string entityState = null)
     : this()
 {
     EntityId = entity.Id;
     Name = entityType.GetFormattedDisplayName(entity.Name, entity);
     EntityState = entityState;
 }
Ejemplo n.º 4
0
 public List<Entity> SearchEntities(EntityType selectedEntityType, string searchString, string stateFilter)
 {
     if (searchString.Contains(":") && !searchString.EndsWith(":"))
     {
         var parts = searchString.Split(new[] { ':' }, 2);
         return _entityDao.FindEntities(selectedEntityType, parts[0], parts[1], stateFilter);
     }
     return _entityDao.FindEntities(selectedEntityType, searchString, stateFilter);
 }
Ejemplo n.º 5
0
 private static EntityType CreateEntityType(string item, IEnumerable<EntityType> entityTypes)
 {
     var entityTypeName = item.Trim('#', ' ');
     var entityType = entityTypes.SingleOrDefault(x => x.Name.ToLower() == entityTypeName.ToLower());
     if (entityType == null)
     {
         using (var w = WorkspaceFactory.Create())
         {
             entityType = new EntityType { Name = entityTypeName };
             w.Add(entityType);
             w.CommitChanges();
         }
     }
     return entityType;
 }
Ejemplo n.º 6
0
 public void Initialize()
 {
     if (IsInitialized) return;
     CustomerType = _cacheService.GetEntityTypes().SingleOrDefault(x => x.Name == Resources.Customers);
     try
     {
         var frmMain = new FrmMain();
         frmMain.axCIDv51.OnCallerID += axCIDv51_OnCallerID;
         frmMain.axCIDv51.Start();
         IsInitialized = true;
     }
     catch (Exception)
     {
     #if DEBUG
         var i = 0;
     #else
         InteractionService.UserIntraction.DisplayPopup(Resources.Information, Resources.CallerIdDriverError);
     #endif
     }
 }
Ejemplo n.º 7
0
 public EntityCustomDataViewModel(Entity model, EntityType template)
 {
     EntityType = template;
     Model = model;
 }
Ejemplo n.º 8
0
 private void OnSelectEntity(EntityType obj)
 {
     var ticketEntity = SelectedTicket.TicketEntities.SingleOrDefault(x => x.EntityTypeId == obj.Id);
     var selectedEntity = ticketEntity != null ? _cacheService.GetEntityById(ticketEntity.EntityId) : Entity.GetNullEntity(obj.Id);
     EntityOperationRequest<Entity>.Publish(selectedEntity, EventTopicNames.SelectEntity, EventTopicNames.EntitySelected);
 }
Ejemplo n.º 9
0
 private bool CanSelectEntity(EntityType arg)
 {
     Debug.Assert(SelectedTicket != null);
     return arg != null && !SelectedTicket.IsLocked && SelectedTicket.CanSubmit && _applicationState.GetTicketEntityScreens().Any(x => x.EntityTypeId == arg.Id);
 }
Ejemplo n.º 10
0
 public void UpdateEntityData(EntityType entityType, string entityName, string fieldName, string value)
 {
     _entityDao.UpdateEntityData(entityType, entityName, fieldName, value);
 }
Ejemplo n.º 11
0
 public List<Entity> SearchEntities(string searchString, EntityType selectedEntityType, string stateFilter)
 {
     return _entityDao.FindEntities(selectedEntityType, searchString, stateFilter);
 }
Ejemplo n.º 12
0
 public EntitySearchResultViewModel(Entity model, EntityType template)
 {
     EntityType = template;
     Model = model;
 }
Ejemplo n.º 13
0
 private bool CanSelectEntity(EntityType arg)
 {
     return !SelectedTicket.IsLocked && SelectedTicket.CanSubmit && _applicationState.GetTicketEntityScreens().Any(x => x.EntityTypeId == arg.Id);
 }
Ejemplo n.º 14
0
 public EntityButton(EntityType model, Ticket selectedTicket)
 {
     _selectedTicket = selectedTicket;
     Model = model;
 }
Ejemplo n.º 15
0
        private IWorkspace PrepareWorkspace(string fileName)
        {
            Assembly ass = Assembly.GetExecutingAssembly();
            var lp = new Uri(ass.CodeBase);
            string pth = Path.GetDirectoryName(lp.LocalPath);
            pth = Path.Combine(pth, "..\\..\\..\\Samba.Presentation");
            LocalSettings.AppPath = pth;
            LocalSettings.CurrentLanguage = "tr";
            var dataFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\tests";
            if (!Directory.Exists(dataFolder)) Directory.CreateDirectory(dataFolder);
            var filePath = string.Format("{0}\\{1}", dataFolder, fileName);
            if (File.Exists(filePath)) File.Delete(filePath);
            WorkspaceFactory.UpdateConnection(filePath);
            var workspace = WorkspaceFactory.Create();

            CustomerEntityType = new EntityType { Name = "Customers", EntityName = "Customer" };
            CustomerEntityType.EntityCustomFields.Add(new EntityCustomField { EditingFormat = "(###) ### ####", FieldType = 0, Name = "Phone" });
            workspace.Add(CustomerEntityType);
            workspace.CommitChanges();

            return workspace;
        }