private void TaskForm_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { if (!FormUtilities.Instance.IsFormInTemplateMode(this)) { if (this.DataContext is IDataItem) { dataInstance = (IDataItem)this.DataContext; if ((bool)dataInstance["$IsNew$"]) { //assign key properties dataInstance["Id"] = Guid.NewGuid().ToString(); } if (dataInstance.HasProperty("ParentWorkItem")) { var parentWorkItems = dataInstance["ParentWorkItem"] as ICollection <IDataItem>; if (parentWorkItems != null) { parentWorkItem = parentWorkItems.First(); hlParentWorkItem.DataContext = parentWorkItem; } } if (!dataInstance.HasProperty("RelatedProject")) { //(Cireson) Project Task Activity Relates To Project (Cireson.ProjectAutomation.ProjectTaskActivityRelatesToProject.ProjectionType) (3d3c8eb9-1cb7-d2dd-bcaa-0bcc5c21a157) var relatedProjectProjection = ConsoleContextHelper.Instance.GetProjectionInstance((Guid)dataInstance["$Id$"], new Guid("3d3c8eb9-1cb7-d2dd-bcaa-0bcc5c21a157")); if (relatedProjectProjection.HasProperty("RelatedProject")) { relatedProject = relatedProjectProjection["RelatedProject"] as IDataItem; hlRelatedProject.DataContext = relatedProject; } } else { relatedProject = dataInstance["RelatedProject"] as IDataItem; hlRelatedProject.DataContext = relatedProject; } if (!dataInstance.HasProperty("RelatedResource")) { //(Cireson) Project Task Activity Has Resource (Cireson.ProjectAutomation.ProjectTaskActivityHasResource.ProjectionType) (43b76917-318f-9d41-db49-50a42e9fb7e2) var TaskHasResourceProjection = ConsoleContextHelper.Instance.GetProjectionInstance((Guid)dataInstance["$Id$"], new Guid("43b76917-318f-9d41-db49-50a42e9fb7e2")); if (TaskHasResourceProjection.HasProperty("RelatedResource")) { resources = TaskHasResourceProjection["RelatedResource"] as ICollection <IDataItem>; lvResources.DataContext = resources; lvResources.ItemsSource = resources; } } } } }
private void BindMap() { if (DataContext == null) { return; } IDataItem data = this.DataContext as IDataItem; if (data == null) { return; } if (!data.HasProperty("Longtitude") || !data.HasProperty("Latitude")) { return; } if (data["Longtitude"] == null || data["Latitude"] == null) { return; } String strLong = data["Longtitude"].ToString(); String strLat = data["Latitude"].ToString(); double iLo = 0; double iLa = 0; //TODO Put default coordinates here double.TryParse(strLong, out iLo); double.TryParse(strLat, out iLa); myMap.Center = new Microsoft.Maps.MapControl.WPF.Location(iLa, iLo); myPin.Location = new Microsoft.Maps.MapControl.WPF.Location(iLa, iLo); }
public void WorkItemCallback(IDataItem RMAForm, IDataItem IncidentForm) { try { // Note to self: RelatedWorkItems should be in MP XML as alias under TypeProjections if (RMAForm != null && RMAForm.HasProperty("RelatedWorkItems")) { // Perform Linking RMAForm["RelatedWorkItems"] = IncidentForm; // Copy Incident Title to RMA Title RMAForm["Title"] = IncidentForm["Title"]; // Copy Incident Description to RMA Description RMAForm["Description"] = IncidentForm["Description"]; } } catch (Exception exc2) { MessageBox.Show(exc2.Message, "Exception", MessageBoxButton.OK, MessageBoxImage.Error); } }
public override void ExecuteCommand(IList <NavigationModelNodeBase> navigationNodes, NavigationModelNodeTask task, ICollection <String> parameters) { foreach (NavigationModelNode navigationNode in navigationNodes) { IDataItem dataitemIncident = null; IDataItem dataitemIncidentStatus = null; IDataItem dataitemMessageType = null; bool boolIsFormAction = false; Uri uriFormsDefinition = new Uri(NavigationModel.NavigationRoot, "Windows/Forms/"); if (navigationNode != null && uriFormsDefinition.IsBaseOf(navigationNode.Location)) { boolIsFormAction = true; FrameworkElement userControl = GetIncidentControl(navigationNode); if (userControl != null) { if (userControl.CheckAccess()) { dataitemIncident = userControl.DataContext as IDataItem; } else { using (AutoResetEvent autoreset = new AutoResetEvent(false)) { EventHandler delegateHandleUserControl = delegate(object sender, EventArgs e) { dataitemIncident = userControl.DataContext as IDataItem; autoreset.Set(); }; userControl.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, delegateHandleUserControl, null, null); autoreset.WaitOne(); } } } } else { //Console Node IDataItem dataItem = navigationNode as IDataItem; if (dataItem != null) { dataitemIncident = DataQueryHelper.GetEmoProjectionItem((Guid)dataItem[Constants.MP_PROPERTY_ID_DOLLAR], new Guid(Constants.MP_PROJECTION_TYPE_INCIDENT)); } } String strMessage = String.Empty; Boolean boolAddToActionLog = false; dataitemIncidentStatus = (IDataItem)dataitemIncident[Constants.MP_PROPERTY_INCIDENT_STATUS]; bool?result = SendEmailForm.LaunchDialog(task.DisplayName, ref dataitemMessageType, ref dataitemIncidentStatus, out strMessage, out boolAddToActionLog); if (result == null || !result.Value || String.IsNullOrEmpty(strMessage)) { // The user either did not enter any comment or he clicked the cancel button break; } dataitemIncident[Constants.MP_PROPERTY_INCIDENT_MESSAGE] = strMessage; dataitemIncident[Constants.MP_PROPERTY_INCIDENT_MESSAGE_TYPE] = dataitemMessageType; dataitemIncident[Constants.MP_PROPERTY_INCIDENT_STATUS] = dataitemIncidentStatus; if (boolAddToActionLog) { //Add the Action Log Object IDataItem dataitemSentEmailActionType = DataQueryHelper.GetEnumerations(new Guid(Constants.MP_ENUM_TYPE_SENT_EMAIL), false)[0]; IDataItem dataitemActionLogItem = DataQueryHelper.CreateNewInstanceBindableItem(new Guid(Constants.MP_CLASS_TYPE_ACTION_LOG)); dataitemActionLogItem[Constants.MP_PROPERTY_ACTION_LOG_ENTERED_DATE] = DateTime.Now; dataitemActionLogItem[Constants.MP_PROPERTY_ACTION_LOG_DESCRIPTION] = strMessage; dataitemActionLogItem[Constants.MP_PROPERTY_ACTION_LOG_ID] = Guid.NewGuid().ToString(); dataitemActionLogItem[Constants.MP_PROPERTY_ACTION_LOG_ACTION_TYPE] = dataitemSentEmailActionType; dataitemActionLogItem[Constants.MP_PROPERTY_ACTION_LOG_TITLE] = dataitemSentEmailActionType[DataItemConstants.DisplayName]; dataitemActionLogItem[Constants.MP_PROPERTY_ACTION_LOG_ENTERED_BY] = (String)DataQueryHelper.GetCurrentLoggedInUser()[DataItemConstants.DisplayName]; if (dataitemIncident.HasProperty(Constants.MP_PROPERTY_ACTION_LOG_ACTION_LOGS)) { dataitemIncident[Constants.MP_PROPERTY_ACTION_LOG_ACTION_LOGS] = dataitemActionLogItem; } } if (!boolIsFormAction) { //If this was initiated from the console we need to update the incident straight away EnterpriseManagementObjectProjectionDataType.UpdateDataItem(dataitemIncident); } } }
private void UserControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { if (this.DataContext is IDataItem) { _instance = (this.DataContext as IDataItem); ParameterMappings mappings = null; if (_instance.HasProperty("ParameterMappings")) { try { mappings = ParameterMappings.CreateFromString((string)_instance["ParameterMappings"]); } catch (Exception) {} } if (mappings == null) mappings = new ParameterMappings(); Init(mappings, (Guid)(_instance["$Class$"] as IDataItem)["Id"]); if (!(bool)_instance["$IsNew$"]) { RunbookGrid.IsEnabled = false; JobTabItem.Visibility = Visibility.Visible; HistoryTabItem.Visibility = Visibility.Visible; /* var className = (_instance["$Class$"] as IDataItem)["Name"].ToString(); var activityClass = _emg.EntityTypes.GetClasses(new ManagementPackClassCriteria("Name = '" + className + "'")).FirstOrDefault(); if (activityClass != null) { foreach (var p in activityClass.GetProperties(BaseClassTraversalDepth.None)) { AddPropertyEditor(p); } } */ } else { RunbookGrid.IsEnabled = true; JobTabItem.Visibility = Visibility.Collapsed; HistoryTabItem.Visibility = Visibility.Collapsed; } var t = RefreshRunbookParameters(); } }