protected override void OnViewSet() { View.OnCreateData += OnCreateData; View.OnDeleteData += OnDeleteData; _users = DynamicDataServiceContext.GetObjects("User"); InitData(); InitFilter(); View.Bind(_projectTaskList); }
protected override object GetEntity() { var entity = DynamicDataServiceContext.GetOrNew(EntityName, EntityId, "InvoiceContracts,CreatedBy,ModifiedBy"); if (WorkingMode == EntityDetailWorkingMode.Add) { entity.AsDyanmic().StatusCode = 1; entity.AsDyanmic().TransactionCurrencyId = Guid.Parse("992a4ff1-856d-421f-a928-654357e4b70b"); } ConvertEntity(entity); return(entity); }
private void SetHistory(TaskTimeHistory task) { var taskTimeHistory = DynamicDataServiceContext.GetOrNew("TaskTimeHistory", task.TaskTimeHistoryId).AsDyanmic(); task.TaskTimeHistoryId = taskTimeHistory.TaskTimeHistoryId; taskTimeHistory.TaskId = task.TaskId; taskTimeHistory.ActualInput = task.ActualInput; taskTimeHistory.Effort = task.Effort; taskTimeHistory.Overtime = task.Overtime; taskTimeHistory.Description = task.Description; taskTimeHistory.RecordOn = task.RecordOn; }
protected override void OnSaved() { base.OnSaved(); if (DynamicEntity.OriginatingLeadId == null) { return; } var leadEntity = DynamicDataServiceContext.GetOrNew("Lead", DynamicEntity.OriginatingLeadId); leadEntity.StatusCode = 4; DynamicDataServiceContext.SaveChanges(); }
public void Init(Guid entityId, GridView gridView) { _gridView = gridView; var entityMeta = MetadataProvider.Instance.EntiyMetadata.Single(e => e.EntityId == entityId); var entityType = DynamicDataServiceContext.GetTypeDefinition(entityMeta.PhysicalName); List <string> allFields = PopuldateFieldList(entityType).ToList(); List <string> selectedFields = gridView.Columns.Cast <GridColumn>().Select(c => c.FieldName).ToList(); List <string> availableFields = allFields.Except(selectedFields).ToList(); fieldsListBox.DataSource = availableFields; columnsListBox.DataSource = selectedFields; }
protected override void OnViewSet() { base.OnViewSet(); View.NewQuoteLineItem += View_NewQuoteLineItem; View.RemoveQuoteLineItem += ViewRemoveQuoteLineItem; View.CalculateTotalAmount += ViewCalculateTotalAmount; View.QuoteLineItemSelectProductChanged += ViewQuoteLineItemSelectProductChanged; productList = DynamicDataServiceContext.GetObjects("Product"); View.PoppulateProducts(productList); }
void View_DeteleNotification(object sender, EventArgs <object> e) { if (e.Data == null) { return; } DynamicDataServiceContext context = new DynamicDataServiceContext(); context.DeleteObject(_entityName, e.Data); context.SaveChanges(); View.Bind(_entityName); }
private RoleViewModel GetRoleViewModel() { var roleViewModel = new RoleViewModel { RoleId = DynamicEntity.RoleId, RoleName = DynamicEntity.RoleName, Description = DynamicEntity.Description }; IList rolePrivilegeList = DynamicEntity.RolePrivileges; var privilegeEntities = DynamicDataServiceContext.GetObjects("PrivilegeEntity"); var privileges = DynamicDataServiceContext.GetObjects("Privilege"); var viewModelList = new Dictionary <string, EntityViewModel>(); foreach (var privilegeEntity in privilegeEntities) { dynamic dynamicEntity = new SysBits.DynamicProxies.DynamicProxy(privilegeEntity); var selectedEntityId = dynamicEntity.PrivilegeEntityId; Guid privilegeId = dynamicEntity.PrivilegeId; string entityName = dynamicEntity.EntityName; EntityViewModel entityViewModel; if (viewModelList.ContainsKey(entityName)) { entityViewModel = viewModelList[entityName]; } else { entityViewModel = new EntityViewModel() { EntityId = selectedEntityId, Name = entityName }; roleViewModel.SelectedEntities.Add(entityViewModel); viewModelList.Add(entityName, entityViewModel); } var privilege = privileges.AsQueryable().Where("PrivilegeId = @0", privilegeId)._First(); dynamic dynamicPrivilege = new SysBits.DynamicProxies.DynamicProxy(privilege); var privilegeViewModel = new PrivilegeViewModel { PrivilegeId = dynamicPrivilege.PrivilegeId, PrivilegeName = dynamicPrivilege.Name, Selected = SelectedPrivilege(rolePrivilegeList, privilegeId) }; entityViewModel.Privileges.Add(privilegeViewModel); } return(roleViewModel); }
public static DataServiceQuery CreateQuery(string entityName, CriteriaOperator commonFilter, Dictionary <string, string> properties) { var fetchColumns = GetColumnFieldMapping(entityName).ToDictionary(kvp => kvp.FieldNameMapping, kvp => kvp.Expression); if (properties != null) { fetchColumns = properties.Concat(fetchColumns).ToDictionary(e => e.Key, e => e.Value); } var query = new DynamicDataServiceContext().CreateObjectQuery(entityName, commonFilter, fetchColumns); return(query); }
protected override void OnSaved() { //base.OnSaved(); if (DynamicEntity.OriginatingLeadId == null) { return; } var leadEntity = DynamicDataServiceContext.GetOrNew("Lead", DynamicEntity.OriginatingLeadId); leadEntity.StatusCode = 4; DynamicDataServiceContext.SaveChanges(); MetadataProvider.Instance.CreateCommonNotification(DynamicEntity.OpportunityId, EntityName, "Lead"); }
protected override void OnViewSet() { View.OnCreateData += OnCreateData; View.OnDeleteData += OnDeleteData; _users = DynamicDataServiceContext.GetObjects("User"); _editTaskTimeHistory = new TaskTimeHistory(); _editTaskTimeHistory.RecordOn = DateTime.Today; InitData(); View.Bind(new List <TaskTimeHistory>() { _editTaskTimeHistory }); }
public void DeleteTimeTracking(object sender, EventArgs <Guid> e) { var timeTracking = DynamicDataServiceContext.GetOrNew("TimeTracking", e.Data); DynamicDataServiceContext.DeleteObject("TimeTracking", timeTracking); DynamicDataServiceContext.SaveChanges(); ShowTimeTrackingListView(); if (OnReloadTiming != null) { OnReloadTiming(this, new EventArgs()); } }
private void OnContractEditValueChanged(object sender, Katrin.Win.Infrastructure.EventArgs <Guid> e) { var entity = DynamicDataServiceContext.GetOrNew("Contract", e.Data, "Opportunity"); bool isAdd = WorkingMode == EntityDetailWorkingMode.Add; var opportunity = entity.AsDyanmic().Opportunity; if (entity != null && opportunity != null) { DynamicEntity.ContractId = e.Data; DynamicEntity.CustomerId = isAdd ? opportunity.CustomerId : DynamicEntity.CustomerId ?? opportunity.CustomerId; DynamicEntity.ProjectTypeCode = isAdd ? opportunity.ProjectTypeCode : DynamicEntity.ProjectTypeCode ?? opportunity.ProjectTypeCode; DynamicEntity.TechnologyCode = isAdd ? opportunity.TechnologyCode : DynamicEntity.TechnologyCode ?? opportunity.TechnologyCode; } }
public void DeleteProjectIteration(object sender, EventArgs <Guid> e) { var timeTracking = DynamicDataServiceContext.GetOrNew("ProjectIteration", e.Data); DynamicDataServiceContext.DeleteObject("ProjectIteration", timeTracking); DynamicDataServiceContext.SaveChanges(); EventHandler handler = OnRefreshListProjectIteration; if (handler != null) { handler(sender, e); } OnShowProjectIteration(sender, e); }
private IEnumerable GetTasks(DateTime date) { var extraColumns = new Dictionary <string, string> { { "TaskTimeHistories", "TaskTimeHistories" } }; CriteriaOperator filter = new BinaryOperator("OwnerId", AuthorizationManager.CurrentUserId); filter &= new BinaryOperator("StartDate", date, BinaryOperatorType.LessOrEqual); filter &= new GroupOperator(GroupOperatorType.Or, new UnaryOperator(UnaryOperatorType.IsNull, "EndDate"), new BinaryOperator("EndDate", date, BinaryOperatorType.GreaterOrEqual)); return(DynamicDataServiceContext.GetObjects("ProjectTask", filter, extraColumns)); }
private string InitEmailMessage(out string emailTo, DateTime thisDay, DateTime nextDay, Guid projectId, IEnumerable taskList) { string dayReportTemplate = Properties.Resources.DayReportTemplate; //project var project = DynamicDataServiceContext.GetOrNew("Project", projectId, "Customer"); var customer = project.AsDyanmic().Customer; emailTo = customer == null ? string.Empty : customer.EMailAddress1; dayReportTemplate = dayReportTemplate.Replace("$CustomerName$", project.AsDyanmic().Contact); dayReportTemplate = dayReportTemplate.Replace("$ThisWeekTask$", GetWeekTask(thisDay, projectId)); dayReportTemplate = dayReportTemplate.Replace("$TodayTask$", GetDayTask(taskList, projectId, false, thisDay)); dayReportTemplate = dayReportTemplate.Replace("$NextDayTask$", GetDayTask(GetTasks(nextDay), projectId, true, nextDay)); dayReportTemplate = dayReportTemplate.Replace("$ReportPeople$", AuthorizationManager.FullName); return(dayReportTemplate); }
public void DeleteNote(object sender, EventArgs <Guid> e) { var noteEntity = DynamicDataServiceContext.GetOrNew("Note", e.Data); DynamicDataServiceContext.DeleteObject("Note", noteEntity); DynamicDataServiceContext.SaveChanges(); string key = "NoteDetailListView"; var noteListView = WorkItem.Items.Get <NoteListView>(key); noteListView.DeleteFocusedRow(); if (OnReloadNote != null) { OnReloadNote(this, new EventArgs()); } }
private bool CheckSinglePersonData() { CriteriaOperator filter = new BinaryOperator("OwnerId", AuthorizationManager.CurrentUserId); filter &= new BinaryOperator("StartDate", DateTime.Today, BinaryOperatorType.LessOrEqual); filter &= new BinaryOperator(new OperandProperty("ActualWorkHours"), new OperandProperty("Effort"), BinaryOperatorType.Greater); var ownerProjectTasks = DynamicDataServiceContext.GetObjects("ProjectTask", filter, null); if (ownerProjectTasks.AsQueryable().Count() <= 0) { XtraMessageBox.Show(Properties.Resources.NoNewTaskMessage, Properties.Resources.Katrin, MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } return(true); }
protected override void OnSaving() { bool result = true; View.ValidateResult = result; if (!View.ValidateData()) { return; } DateTime startDate = DynamicEntity.StartDate; DateTime endDate = DynamicEntity.Deadline; if (startDate > endDate) { result = false; XtraMessageBox.Show(Properties.Resources.IterationDateCompareMessage, Properties.Resources.Katrin, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } if (result) { CriteriaOperator filter = new BinaryOperator("projectid", DynamicEntity.ProjectId) & new BinaryOperator("ProjectIterationId", DynamicEntity.ProjectIterationId, BinaryOperatorType.NotEqual); var iterationList = DynamicDataServiceContext.GetObjects(EntityName, filter, null); foreach (var iteration in iterationList) { dynamic dynamic = iteration.AsDyanmic(); DateTime iterationStartDate = dynamic.StartDate; DateTime iterationEndDate = dynamic.Deadline; if (startDate < iterationEndDate && endDate > iterationStartDate) { result = false; XtraMessageBox.Show(Properties.Resources.IterationDateErrorMessage, Properties.Resources.Katrin, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); break; } } } View.ValidateResult = result; }
private bool SaveEntity() { View.PostEditors(); OnSaving(); if (!View.ValidateData()) { return(false); } DynamicDataServiceContext.SaveChanges(); NewEntityId = Guid.Empty; OnSaved(); if (WorkingMode == EntityDetailWorkingMode.Add) { WorkingMode = EntityDetailWorkingMode.Edit; } OnEntitySaved(new EventArgs <bool>(false)); WorkItem.Commands["Refresh"].Execute(); return(true); }
private IEnumerable GetTaskHistory(DateTime recordDate, List <Guid> taskListId) { DateTime startDate = Utils.Date.WeekBegin(recordDate); DateTime endDate = Utils.Date.WeekEnd(recordDate); if (taskListId.Count <= 0) { return(null); } CriteriaOperator filter = new BinaryOperator("RecordOn", startDate, BinaryOperatorType.GreaterOrEqual); filter &= new BinaryOperator("RecordOn", endDate, BinaryOperatorType.LessOrEqual); if (taskListId.Count > 0) { filter &= new InOperator("TaskId", taskListId); } return(DynamicDataServiceContext.GetObjects("TaskTimeHistory", filter, null)); }
private bool CheckTaskEffort() { foreach (var taskId in _taskList.Keys) { var taskEntity = DynamicDataServiceContext.GetOrNew("ProjectTask", taskId); var taskDyanmic = taskEntity.AsDyanmic(); double remainderTime = taskDyanmic.ActualWorkHours ?? 0d - taskDyanmic.Effort ?? 0d; if (_taskList[taskId] > remainderTime) { View.ValidateResult = false; XtraMessageBox.Show(Properties.Resources.OverEffortMessage, Properties.Resources.Katrin, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); return(false); } } return(true); }
private void InitPickUp(string filterEntityName) { if (string.IsNullOrEmpty(filterEntityName)) { panelControl1.Visible = false; return; } var entityType = DynamicDataServiceContext.GetTypeDefinition(filterEntityName); _filterKeyName = entityType.Key().First().Name; this.lookUpEdit1.DataBindings.Add(new System.Windows.Forms.Binding("EditValue", this.LookUpBindingSource, _filterKeyName, true)); BindLookUpData(_filterKeyName, _layoutEntityName); DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn(_filterKeyName)); DataRow row = dt.NewRow(); row[_filterKeyName] = Guid.Empty; dt.Rows.Add(row); LookUpBindingSource.DataSource = dt; }
public void OnSetOpportunityFail(object sender, EventArgs e) { OpportunityLossReason resonForm = new OpportunityLossReason(); DialogResult result = resonForm.ShowDialog(); if (result == DialogResult.OK) { string lossReason = resonForm.LossReasion(); DynamicEntity.ClosedTime = DateTime.Now; DynamicEntity.StatusCode = (int)OpportunityStatus.Lost; DynamicEntity.SalesStageCode = DynamicEntity.StatusCode + SaleStageCodeOffSet; if (!string.IsNullOrEmpty(lossReason)) { DynamicEntity.Description += "\r\n" + lossReason; } DynamicDataServiceContext.SaveChanges(); OnEntitySaved(new EventArgs <bool>(false)); WorkItem.Commands["Refresh"].Execute(); } }
private void UpdateTask() { foreach (var taskId in _taskList.Keys) { var taskEntity = DynamicDataServiceContext.GetOrNew("ProjectTask", taskId, "TaskTimeHistories"); var taskDyanmic = taskEntity.AsDyanmic(); IList historyList = taskDyanmic.TaskTimeHistories as IList; historyList = historyList.AsQueryable().Where("IsDeleted=@0", false).ToArrayList(); taskDyanmic.ActualInput = historyList.AsQueryable().Select("ActualInput").Cast <double?>().Sum(); taskDyanmic.Effort = historyList.AsQueryable().Select("Effort").Cast <double?>().Sum(); taskDyanmic.Overtime = historyList.AsQueryable().Select("Overtime").Cast <double?>().Sum(); if (taskDyanmic.ActualWorkHours - taskDyanmic.Effort <= 0) { taskDyanmic.StatusCode = 3; } else if (taskDyanmic.StatusCode == 1 || taskDyanmic.ActualWorkHours - taskDyanmic.Effort > 0) { taskDyanmic.StatusCode = 2; } } }
protected override object GetEntity() { Dictionary <string, string> extraColumns = new Dictionary <string, string>(); var entity = DynamicDataServiceContext.GetOrNew(EntityName, EntityId, "CreatedBy,ModifiedBy,ProjectTasks,ProjectMembers"); _projectSummaryEntity = new ProjectSummary(); IList projectTasks = entity.AsDyanmic().ProjectTasks; _projectSummaryEntity.SumQuoteWorkHours = projectTasks.AsQueryable().Select("QuoteWorkHours").Cast <double?>().Sum(); _projectSummaryEntity.SumActualWorkHours = projectTasks.AsQueryable().Select("ActualWorkHours").Cast <double?>().Sum(); _projectSummaryEntity.SumActualInput = projectTasks.AsQueryable().Select("ActualInput").Cast <double?>().Sum(); _projectSummaryEntity.SumEffort = projectTasks.AsQueryable().Select("Effort").Cast <double?>().Sum(); _projectSummaryEntity.SumOvertime = projectTasks.AsQueryable().Select("Overtime").Cast <double?>().Sum(); _projectSummaryEntity.SumRemainderTime = _projectSummaryEntity.SumActualWorkHours - _projectSummaryEntity.SumEffort; View.BindStatisticNumber(new List <ProjectSummary>() { _projectSummaryEntity }); ConvertEntity(entity); return(entity); }
private void OnProjectChange(object sender, EventArgs <Guid> e) { if (WorkingMode != EntityDetailWorkingMode.Add) { return; } Guid projectId = e.Data; CriteriaOperator filter = new BinaryOperator("ProjectId", projectId); filter &= new BinaryOperator("ProjectIterationId", DynamicEntity.ProjectIterationId, BinaryOperatorType.NotEqual); var iterationList = DynamicDataServiceContext.GetObjects(EntityName, filter, null); DateTime startDate = DateTime.Today; IList projectIterationList = iterationList as IList; if (projectIterationList.Count > 0) { startDate = projectIterationList.AsQueryable().Select("Deadline").Cast <DateTime>().Max(); startDate = startDate.AddDays(1); } DynamicEntity.StartDate = startDate; }
private void SinglePersonData() { var extraColumns = new Dictionary <string, string> { { "Project", "Project" } }; CriteriaOperator filter = new BinaryOperator("OwnerId", AuthorizationManager.CurrentUserId, BinaryOperatorType.Equal); filter &= new BinaryOperator("StartDate", DateTime.Today, BinaryOperatorType.LessOrEqual); filter &= new BinaryOperator(new OperandProperty("ActualWorkHours"), new OperandProperty("Effort"), BinaryOperatorType.Greater); if (EntityId != Guid.Empty) { filter &= new BinaryOperator("TaskId", EntityId, BinaryOperatorType.Equal); } var ownerProjectTasks = DynamicDataServiceContext.GetObjects("ProjectTask", filter, extraColumns); if (ownerProjectTasks != null && ownerProjectTasks.ToArrayList().Count > 0) { foreach (var task in ownerProjectTasks) { TaskTimeHistory item = new TaskTimeHistory(); var dyanmic = task.AsDyanmic(); item.TaskId = dyanmic.TaskId; item.Name = dyanmic.Name; item.ActualWorkHours = dyanmic.ActualWorkHours; item.RecordOn = DateTime.Today; item.RemainderTime = dyanmic.ActualWorkHours - dyanmic.Effort; item.TaskTimeHistoryId = Guid.Empty; item.RecordPerson = GetUserName(AuthorizationManager.CurrentUserId); if (dyanmic.Project != null) { item.ProjectName = dyanmic.Project.Name; } _projectTaskList.Insert(0, item); } } }
protected override void OnSaving() { if (WorkItem.State == null) { return; } base.OnSaving(); DynamicEntity.ObjectId = EntityId; DynamicEntity.ObjectType = ObjectType; var parentEntity = DynamicDataServiceContext.GetOrNew(ObjectType, EntityId); var dynamicEntity = new SysBits.Reflection.ReflectionProxy(parentEntity); dynamicEntity.TrySetProperty("ModifiedById", AuthorizationManager.CurrentUserId); dynamicEntity.TrySetProperty("ModifiedOn", DateTime.Now); if (View.AppandDescription) { object description; if (dynamicEntity.TryGetProperty("Description", out description)) { string appandedDescription = description != null ? description.ToString() + DynamicEntity.NoteText : DynamicEntity.NoteText; dynamicEntity.SetProperty("Description", appandedDescription); DynamicDataServiceContext.UpdateObject(parentEntity); } } if (View.UpdateLatestFeadback) { object latestFeedbackOn; if (dynamicEntity.TryGetProperty("LatestFeedbackOn", out latestFeedbackOn)) { dynamicEntity.SetProperty("LatestFeedbackOn", DateTime.Now); DynamicDataServiceContext.UpdateObject(parentEntity); } } }
protected override void OnSaving() { if (_editTaskTimeHistory == null) { return; } if (_editTaskTimeHistory.Overtime > _editTaskTimeHistory.Effort) { View.ValidateResult = false; XtraMessageBox.Show(Properties.Resources.OverTimeTip, Properties.Resources.Katrin, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); return; } if (_editTaskTimeHistory.ActualInput == 0) { View.ValidateResult = false; XtraMessageBox.Show(Properties.Resources.ActualInputIsZero, Properties.Resources.Katrin, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); return; } dynamic taskEntity = DynamicDataServiceContext.GetOrNew("ProjectTask", _editTaskTimeHistory.TaskId); if (!UpdateTask(taskEntity, _editTaskTimeHistory)) { return; } SetHistory(_editTaskTimeHistory); View.ValidateResult = true; }