public static int?AddTerm(this IDivision division, IModelContext modelContext) { // TODO: Get vocabulary name from config var vocabularyName = "University_Structure"; var vocabulary = new VocabularyController().GetVocabularies().FirstOrDefault(v => v.Name == vocabularyName); if (vocabulary != null) { var termName = GetSafeTermName(division.ShortTitle, division.Title); try { var term = new Term(termName, string.Empty, vocabulary.VocabularyId); var parentDivision = division.GetParentDivision(modelContext); if (parentDivision != null) { term.ParentTermId = parentDivision.DivisionTermID; } return(new TermController().AddTerm(term)); } catch (Exception ex) { Exceptions.LogException(new Exception($"Error adding {termName} term to {vocabularyName} vocabulary.", ex)); } } else { Exceptions.LogException(new Exception($"Could not find vocabulary with name {vocabularyName}.")); } return(null); }
public void Initialize(IModelContext model) { _clientUnit = model.Clients.HandleRemoveChanges(removed: client => { if (_clients.ContainsKey(client)) { _clients[client].StopListen(); _clients.Remove(client); } }); _interlocutorUnit = model.Interlocutors.HandleRemoveChanges(removed: interlocutor => { if (_interlocutors.ContainsKey(interlocutor)) { _interlocutors[interlocutor].StopListen(); _interlocutors.Remove(interlocutor); } }); _roomUnit = model.Rooms.HandleRemoveChanges(removed: room => { if (_rooms.ContainsKey(room)) { _rooms[room].StopListen(); _rooms.Remove(room); } }); }
public static void UpdateTerm(this IDivision division, IModelContext modelContext) { var termName = GetSafeTermName(division.ShortTitle, division.Title); try { var parentDivision = division.GetParentDivision(modelContext); if (division.DivisionTermID != null) { var termCtrl = new TermController(); var term = termCtrl.GetTerm(division.DivisionTermID.Value); if (term != null) { term.Name = termName; if (parentDivision != null) { term.ParentTermId = parentDivision.DivisionTermID; } termCtrl.UpdateTerm(term); } } } catch (Exception ex) { Exceptions.LogException(new Exception($"Error updating {termName} term.", ex)); } }
/// <summary> /// Find a single Right /// </summary> public IRightDataModel Get(Func <IRightDataModel, bool> filter, IModelContext context) { var ctx = new AppContext(); var rtn = ctx.Right.FirstOrDefault(filter); return(rtn); }
/// <summary> /// Tries to create a new item /// </summary> /// <param name="item">The item.</param> /// <param name="errors">The errors.</param> /// <param name="context">The context.</param> /// <returns></returns> /// <exception cref="InvalidOperationException">Unable to update IAccountDataModel"</exception> private bool TryCreate(IAccountDataModel item, List <IModelError> errors, IModelContext context = null) { if (TryValidateModel(item, Operation.Create, errors, context) == false) { return(false); } if (item != null && item.Password != null) { item.Password = cryptoProvider.CreateHash(item.Password); } try { changeHandler.BeforeCreate(item, context); dal.Create(item, context); changeHandler.AfterCreate(item, context); } catch (Exception ex) { log.Exception(LogName, ex); throw new InvalidOperationException("Unable to create IAccountDataModel", ex); } return(true); }
/// <summary> /// Find a single Right /// </summary> public IRightDataModel Get(int id, IModelContext context) { var ctx = new AppContext(); var rtn = ctx.Right.FirstOrDefault(x => x.Id == id); return(rtn); }
public void Update(AssociatedData other, IModelContext modelContext) { this.Name = other.Name; this.Description = other.Description; this.SqlDataSourceId = other.SqlDataSourceId; this.SqlFieldId = other.SqlFieldId; }
public IOperationContext Create(IModelContext modelContext, Operation operation, ODataPath path, QueryOptions queryOptions) { var navigationTarget = this.pathService.GetNavigationTarget(modelContext, path); var navigationRoot = this.pathService.GetNavigationRoot(modelContext, path); return(new OperationContext(path, operation, queryOptions, navigationTarget, navigationRoot, modelContext)); }
public void Update(PaymentVariable other, IModelContext context) { this.Name = other.Name; this.Variable = other.Variable; this.ValueReference = other.ValueReference; this.Aditional = other.Aditional; this.AdjustmentFactor = other.AdjustmentFactor; this.FixedValue = other.FixedValue; this.Operator = other.Operator; this.Indicator = other.Indicator; context.SetModified(this); if (!this.PaymentTableEquals(other.PaymentTables)) { if (this.PaymentTables == null) { this.PaymentTables = new List <CompensationPaymentVariablePaymentTable>(); } if (other.PaymentTables != null) { other.PaymentTables.ForEach(t => t.PaymentVariable = this); context.AddRemoveCollectionItems(this.PaymentTables, other.PaymentTables, table => table.Id); } } }
public HistoryWindow(Interlocutor interlocutor, IModelContext context) { InitializeComponent(); _context = context; this.DataContext = this; Interlocutor = interlocutor; var history = new MessageRepository().LoadHistory(interlocutor) ?? new History { InterlocutorId = interlocutor.Id, Messages = new List<Message>() }; HistoryView = new ObservableCollection<HistoryView>(); HistoryMessages = new RichTextBox(new FlowDocument()); HistoryMessages.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; HistoryMessages.IsReadOnly = true; var monthGroups = history.Messages .OrderByDescending(note => note.Date) .GroupBy(key => key.Date.ToString("MMMM yyyy")); foreach (var monthGroup in monthGroups) { HistoryView.Add(new HistoryView { Month = monthGroup.Key, ActiveDates = new ObservableCollection<DayMessageView>( monthGroup.GroupBy(key => key.Date.ToShortDateString()) .Select(dayGroup => new DayMessageView { Day = dayGroup.Key, Messages = new ObservableCollection<Message>(dayGroup) })) }); } }
public ActionResult UpdateContext(ContextViewModel postedModel) { MetadataModel metadata = TempData["Metadata"] as MetadataModel; IModelContext eavContext = metadata.CurrentContext; if (UpdateRequested) { eavContext.Name = postedModel.Name; eavContext.DataName = postedModel.DataName; eavContext.DisplayText = postedModel.DisplayText; foreach (ContainerViewModel containerModel in postedModel.Containers) { eavContext.Containers.Single(it => it.ContainerID == containerModel.ID).Sequence = containerModel.Sequence; } } else if (eavContext.ObjectState == ObjectState.New && (String.IsNullOrWhiteSpace(eavContext.Name) || (String.IsNullOrWhiteSpace(eavContext.DataName))) && !eavContext.Containers.Any()) { metadata.Contexts.Remove(eavContext); } TempData["Metadata"] = metadata; return(BuildResult(null, null, null, metadata.Contexts.Select(it => new { Value = it.ContextID, Text = it.Name }))); }
public ProjectRunner( string projectName, IModelContext context, ITimeService timeService, IReporter reporter, string dataDbConnectionString, IDataDbCreatorFactory dataDbCreatorFactory, IUsersRunnerFactory usersRunnerFactory, IServiceRunnerFactory serviceRunnerFactory, ICyclicRunnerFactory cyclicRunnerFactory, IIoDeviceRunTargetFactory ioDeviceRunTargetFactory, IAlarmsRunTargetFactory alarmsRunTargetFactory, ITrendsRunTargetFactory trendsRunTargetFactory, ILogRunTargetFactory logMaintainerFactory) { _projectName = projectName; _context = context; _timeService = timeService; _reporter = reporter; _dataDbConnectionString = dataDbConnectionString; _dataDbCreator = dataDbCreatorFactory.Create(_dataDbConnectionString, _reporter); _usersRunnerFactory = usersRunnerFactory; _serviceRunnerFactory = serviceRunnerFactory; _cyclicRunnerFactory = cyclicRunnerFactory; _ioDeviceRunTargetFactory = ioDeviceRunTargetFactory; _alarmsRunTargetFactory = alarmsRunTargetFactory; _trendsRunTargetFactory = trendsRunTargetFactory; _logMaintainerFactory = logMaintainerFactory; }
public void Update(GoalPayment other, IModelContext context) { this.PaymentTypeId = other.PaymentTypeId; this.MaxLimitTypeId = other.MaxLimitTypeId; this.Percentage = other.Percentage; this.GoalKindId = other.GoalKindId; this.KindValue = other.KindValue; }
public void Start() { using (NpgsqlConnection connection = _connectionFactory.Create()) { _repository.EnsureTable(connection); InsertContextUsers(connection); _context = null; } }
/// <summary> /// Gets the single Right by Role id for RoleRight relationship. /// </summary> public IRightDataModel GetSingleRightByRoleForRoleRight(int roleId, IModelContext context = null) { changeHandler.BeforeGetSingleRightByRoleForRoleRight(roleId, context); var rtn = dal.GetSingleRightByRoleForRoleRight(roleId, context); changeHandler.AfterGetSingleRightByRoleForRoleRight(rtn, roleId, context); return(rtn); }
public ModelStateValidationContext(IModelContext context, ModelStateDictionary modelState) { _context = context; _modelState = modelState; _context.CreateChildContext(ContextHierarchy.ValidationContext, x => x.RegisterInstance(this).As<IValidationContext>()); }
/// <summary> /// Get all Role for 'AccountRole' relationship. /// </summary> public IQueryable <IRoleDataModel> GetAllForAccountRole(int accountId, IModelContext context = null) { changeHandler.BeforeGetAllForAccountRole(accountId, context); var rtn = dal.GetAllForAccountRole(accountId, context); changeHandler.AfterGetAllForAccountRole(rtn, accountId, context); return(rtn); }
public void Update(FileDataSourceField other, IModelContext modelContext) { this.Name = other.Name; this.IsDate = other.IsDate; this.HierarchyStructureId = other.HierarchyStructureId; this.HierarchyStructureNodeId = other.HierarchyStructureNodeId; this.Position = other.Position; }
public static int?AddOrUpdateTerm(this IDivision division, IModelContext modelContext) { var vocabularyName = UniversityConfig.Instance.Vocabularies.OrgStructure; var vocabulary = new VocabularyController().GetVocabularies().FirstOrDefault(v => v.Name == vocabularyName); if (vocabulary == null) { Exceptions.LogException(new Exception($"Could not find the {vocabularyName} vocabulary.")); return(null); } var termName = GetSafeTermName(division.ShortTitle, division.Title); var termCtrl = new TermController(); var term = default(Term); if (division.DivisionTermID == null) { term = termCtrl.GetTermsByVocabulary(vocabulary.VocabularyId).FirstOrDefault(t => t.Name == termName); if (term != null) { Exceptions.LogException(new Exception($"Could not create term {termName} in the {vocabularyName} vocabulary as it already exists.")); return(null); } term = new Term(termName, string.Empty, vocabulary.VocabularyId); } else { term = termCtrl.GetTerm(division.DivisionTermID.Value); term.Name = termName; } var parentDivision = division.GetParentDivision(modelContext); if (parentDivision != null) { term.ParentTermId = parentDivision.DivisionTermID; } else { term.ParentTermId = null; } try { if (division.DivisionTermID == null) { return(termCtrl.AddTerm(term)); } termCtrl.UpdateTerm(term); return(term.TermId); } catch (Exception ex) { Exceptions.LogException(new Exception($"Error creating/updating {termName} term in the vocabulary {vocabularyName}.", ex)); } return(null); }
public void Update(ThresholdDetail other, IModelContext modelContext) { this.Percentage = other.Percentage; this.UnitNumber = other.UnitNumber; this.ThresholdLow = other.ThresholdLow; this.ThresholdUp = other.ThresholdUp; this.FixedValue = other.FixedValue; this.PercentageUnit = other.PercentageUnit; }
public BindableModelContext( IModelContext underlyingModelContext, IDictionary <INavigatable, IEnumerable <DependencyDeclaration> > dependencies, IDictionary <INavigatable, IBinding> bindings) { this.underlyingModelContext = underlyingModelContext; this.dependencies = dependencies; this.bindings = bindings; }
public BackgroundVerificationContext( [NotNull] IModelContext innerModelContext, [NotNull] SpatialReferenceDescriptor spatialReferenceDescriptor, [NotNull] ICollection <Dataset> verifiedDatasets) { InnerModelContext = innerModelContext; SpatialReferenceDescriptor = spatialReferenceDescriptor; _verifiedDatasets = verifiedDatasets; }
public UsersRunner( IModelContext context, INpgsqlConnectionFactory connectionFactory, IUsersRepository repository) { _context = context; _connectionFactory = connectionFactory; _repository = repository; }
/// <summary> /// Create a new Right /// </summary> public void Create(IRightDataModel item, IModelContext context) { var ctx = new AppContext(); var dataEntity = new RightEntityDataModel(item); ctx.Right.Add(dataEntity); ctx.SaveChanges(); item.Id = dataEntity.Id; }
public static IDivision GetParentDivision(this IDivision division, IModelContext modelContext) { if (division.ParentDivisionID != null) { return(modelContext.Get <DivisionInfo> (division.ParentDivisionID.Value)); } return(null); }
/// <summary> /// The update. /// </summary> /// <param name="other"> /// The other. /// </param> /// <param name="context"> /// The context. /// </param> public void Update(PaymentTableIndicator other, IModelContext context) { if ((this.GoalPayment is null && !(other.GoalPayment is null)) || !this.GoalPayment.Equals(other.GoalPayment)) { if (this.GoalPayment is null || other.GoalPayment is null) { this.GoalPayment = other.GoalPayment; context.SetModified(this); }
/// <summary> /// Get all Account for 'AccountRole' relationship. /// </summary> public IQueryable <IAccountDataModel> GetAllForAccountRole(int roleId, IModelContext context) { var ctx = new AppContext(); var result = (from main in ctx.Account join link in ctx.AccountRole on main.Id equals link.AccountId where (link.RoleId == roleId) select main); return(result); }
public static IDivision GetParentDivision(this IDivision division, IModelContext modelContext) { Contract.Ensures(Contract.Result <IDivision> () != null); if (division.ParentDivisionID != null) { return(modelContext.Get <DivisionInfo, int> (division.ParentDivisionID.Value)); } return(null); }
public ContextViewModel(IModelContext context) { ID = context.ContextID.GetValueOrDefault(); Name = context.Name; DataName = context.DataName; DisplayText = context.DisplayText; containers = new List <ContainerViewModel>(); InitializeContainers(context.Containers); }
public static IEntityType GetEntityTypeOrThrow(this IModelContext context, string name) { IEntityType entityType; if (context.TryGetEntityType(name, out entityType)) { return(entityType); } throw new KeyNotFoundException("Entity type not found: " + name); }
public static IEntitySet GetEntitySetOrThrow(this IModelContext context, string name) { IEntitySet entitySet; if (context.TryGetEntitySet(name, out entitySet)) { return(entitySet); } throw new KeyNotFoundException("Entity set not found: " + name); }
protected bool Invoke (IModelContext context, IEntityAction entityAction) { bool res = false; if (ContainsOperation (entityAction)) { Operations [entityAction.Operation.Operation].Invoke (context, entityAction, entityAction.Operation.Extension); res = true; } return (res); }
public IEntitySet GetNavigationRoot(IModelContext modelContext, IEnumerable <ODataPathSegment> oDataPath) { if (!oDataPath.Any()) { throw new ArgumentException("The path must not be empty.", nameof(oDataPath)); } var translator = new NavigatablePathSegmentTranslator(modelContext); var root = oDataPath.First().TranslateWith(translator); return(root.As <IEntitySet>()); }
public VSTalkCore(IWindowsManager windowsManager, IEnvironmentManager environmentManager, IModelContext modelContext) { WindowsManager = windowsManager; EnvironmentManager = environmentManager; ModelContext = modelContext; NotificationQueue = new NotificationQueue(); Connector = new ClientConnector(this); ControlsRepository = new ControlRepository(this); LoadConnections(); }
private static string GetName(Message message, IModelContext context) { var client = context.GetClientById(message.From); if (client != null) { return client.Login; } var interlocutor = context.GetContactById(message.From); if (interlocutor != null) { return interlocutor.Name; } return message.From.Jid; }
public InterlocutorChatViewModel(Interlocutor interlocutor, IModelContext context) { Interlocutor = interlocutor; _context = context; Message = string.Empty; ChatTextBox = new RichTextBox(new FlowDocument()); ChatTextBox.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; ChatTextBox.IsReadOnly = true; MessageTextBox = new RichTextBox(new FlowDocument()); MessageTextBox.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; ParseCurrentHistory(); Interlocutor.History.CollectionChanged += HistoryChanged; }
/// <summary> /// Инициализирует экземпляр класса <see cref="ApplicationBus"/>, используя /// в качестве родительского контекста <paramref name="parentModelContext"/>. /// </summary> /// <param name="parentModelContext"></param> public ApplicationBus( IModelContext parentModelContext, IEnumerable<IApplicationBusMessageHandler> handlers) { if (parentModelContext == null) { throw new ArgumentNullException("parentModelContext"); } _context = parentModelContext.CreateChildContext( ContextHierarchy.ApplicationBus, x => x.RegisterInstance(this).As<IApplicationBus>().AsSelf()); _validationContext = _context.Get<IValidationContext>(); foreach (var handler in handlers) { RegisterHandler(handler); } }
public static IEnumerable<Paragraph> CreateParagraph(this Message message, IModelContext context) { var paragraphs = new List<Paragraph>(); var name = GetName(message, context); var title = new Bold(new Run(string.Format("{0} {1:hh:mm}: ", name, message.Date))); var paragraph = new Paragraph(); paragraph.Inlines.Add(title); paragraphs.Add(paragraph); if (message.Type == MessageType.Xaml) { var body = ParseXamlString(message.Body); paragraphs.AddRange(body.Blocks.Select(block => block as Paragraph)); } else { var body = new Run(message.Body); paragraph.Inlines.Add(body); } return paragraphs; }
/// <summary> /// Constructs a new instance of <see cref="ModelService"/> /// </summary> /// <param name="context">An instance of an <see cref="IModelContext"/></param> /// <param name="log">An instance of an <see cref="ILog"/></param> public ModelService(IModelContext context, ILog log) : base(log) { this.context = context; }
public TeachersQuery (IModelContext modelContext): base (modelContext) { }
public UpdateEduProgramProfileFormsCommand (IModelContext modelContext) { ModelContext = modelContext; }
public void Start() { using (var connection = _connectionFactory.Create()) { _repository.EnsureTable(connection); InsertContextUsers(connection); _context = null; } }
public EduProgramCommonQuery (IModelContext modelContext): base (modelContext) { }
public void Save(IModelContext context) { _context = context; SaveHistory(); SaveAccount(); }
public DivisionHierarchyQuery (IModelContext modelContext): base (modelContext) { }
public IUsersRunner Create(IModelContext context, string connectionString) { return new UsersRunner(context, new NpgsqlConnectionFactory(connectionString), new UsersRepository()); }
protected EduProgramProfileQueryBase (IModelContext modelContext): base (modelContext) { }
public EduLevelQuery (IModelContext modelContext): base (modelContext) { }
public EmployeeQuery (IModelContext modelContext): base (modelContext) { }
public ISessionModel Create(IModelContext persistentModel) { var model = new SessionModel(); model.Initialize(persistentModel); return model; }
internal void Bind(IModelContext model) { Context = model; }
protected QueryBase (IModelContext modelContext) { ModelContext = modelContext; }
public UpdateEmployeeAchievementsCommand (IModelContext modelContext) { ModelContext = modelContext; }
public UpdateOccupiedPositionsCommand (IModelContext modelContext) { ModelContext = modelContext; }
public EduProgramProfileQuery (IModelContext modelContext): base (modelContext) { }
public ModelService(IModelContext context, ILog log) : base(context, log) { }
/// <summary> /// Инициализирует экземпляр класса <see cref="ValidationContext"/>, /// используя указанный <paramref name="parentContext"/>. /// </summary> /// <param name="parentContext"></param> public ValidationContext(IModelContext parentContext) { _modelContext = parentContext.CreateChildContext( ContextHierarchy.ValidationContext, x => x.RegisterInstance(this).As<IValidationContext>()); }
public void Start() { try { _reporter.Report(string.Format(Res.ProjectStartingMessage, _projectName)); _dataDbCreator.Start(); StartUsersRunner(); StartIoDevices(); StartAlarms(); StartTrends(); StartLogs(); StartService(); _reporter.Report(string.Format(Res.ProjectStartedMessage, _projectName)); _context.Dispose(); _context = null; } catch (Exception exception) { _reporter.Report(Res.StartError, exception); } }