public void is_macro() { //code coverage! var item = new ActivityItem(); item.IsMacro = true; Assert.True(item.IsMacro); }
public async Task AddActivityAsync(ActivityItem item) { try { await activitiesTable.InsertAsync(item); } catch { } }
public void Equality_tests() { var workflowItem1 = new ActivityItem(Identity.New(_activityName, _activityVersion, _positionalName), new Mock <IWorkflow>().Object); var workflowItem2 = new ActivityItem(Identity.New("DifferentName", _activityVersion, _positionalName), new Mock <IWorkflow>().Object); Assert.True(WorkflowAction.ContinueWorkflow(workflowItem1).Equals(WorkflowAction.ContinueWorkflow(workflowItem1))); Assert.False(WorkflowAction.ContinueWorkflow(workflowItem1).Equals(WorkflowAction.ContinueWorkflow(workflowItem2))); }
public void By_default_schedule_activity_without_priority() { var activityItem = new ActivityItem(_activityIdentity, _workflow.Object); var decision = ScheduleDecision(activityItem); Assert.That(decision.TaskPriority.HasValue, Is.False); }
private void OnJoinActivity(ActivityItem act) { JoinActivityActionParam param = new JoinActivityActionParam(); param.ActivityId = act.GetActivityId(); Net.Instance.DoAction((int)Message.MESSAGE_ID.ID_MSG_ACTIVITY_JOIN, param); }
public void By_default_schedule_activity_with_empty_task_list() { var activityItem = new ActivityItem(_activityIdentity, _workflow.Object); var decision = ScheduleDecision(activityItem); Assert.That(decision.TaskListName, Is.Null); }
public ActivityItemViewModel(ActivityItem activity) { Id = activity.Id; Name = activity.Name; Text = activity.Text; MaxResult = activity.MaxResult; IsChecked = activity.IsChecked; }
private string ChangeStatePCRMilestone( bool published, Operation operation, ActivityItem activityItemInter, ActivityItem activityItemIntra) { var result = string.Empty; // PCRINTER if (activityItemInter != null) { if (activityItemInter.StatusId == CMConstants.ActivityItemStatus.Completed.MasterId && !published) { activityItemInter.StatusId = CMConstants.ActivityItemStatus.NotStarted.MasterId; } else if (activityItemInter.StatusId != CMConstants.ActivityItemStatus.Completed.MasterId && published) { activityItemInter.StatusId = CMConstants.ActivityItemStatus.Completed.MasterId; } if (published) { result = "1- PCR Published: Operation PCRINTER - Complete"; } else { result = "1- PCR Published: Operation PCRINTER - NotStarted"; } CMBusiness.Get(operation).UpdateActivityItem(activityItemInter); } // PCRINTRA if (activityItemIntra != null && activityItemInter != null) { if (activityItemInter.StatusId == CMConstants.ActivityItemStatus.Completed.MasterId && !published) { activityItemIntra.StatusId = CMConstants.ActivityItemStatus.NotStarted.MasterId; } else if (activityItemInter.StatusId != CMConstants.ActivityItemStatus.Completed.MasterId && published) { activityItemIntra.StatusId = CMConstants.ActivityItemStatus.Completed.MasterId; } if (published) { result = "1- PCR Published: Operation PCRINTRA - Complete"; } else { result = "1- PCR Published: Operation PCRINTRA - NotStarted"; } CMBusiness.Get(operation).UpdateActivityItem(activityItemInter); } return(result); }
public async Task StartAsync() { HashSet <ActivityItem> activityItemCache = new HashSet <ActivityItem>(); while (true) { try { var items = _leagueActivityScraper.GetNewActivityItems(); var newItems = new List <ActivityItem>(); foreach (var item in items) { if (!activityItemCache.Contains(item)) { if (activityItemCache.Count == 50) { ActivityItem oldestItem = activityItemCache.OrderBy(x => x.DateTime).First(); activityItemCache.Remove(oldestItem); } newItems.Add(item); } } if (newItems.Any()) { List <string> newItemList = newItems.Select(x => $"{x.DateTime.ToShortDateString()}: {x.Description}").ToList(); string newItemListstr = string.Join(".\n", newItemList); string body = $@"The following activity items occurred since your last update. {newItemListstr} EOM"; await _emailSender.SendEmailAsync("New League Activity", body); foreach (var item in newItems) { activityItemCache.Add(item); } } } catch (Exception ex) { try { await _emailSender.SendEmailAsync("Raspberry Pi Error!", ex.ToString()); } catch { Console.WriteLine($"An unexpected error occured.\n{ex.ToString()}"); } } await Task.Delay(new TimeSpan(0, 5, 0)); } }
public async Task AddActivityItem(int parentId, ActivityItem aItem) { List <DBActivityItems> KnownActivityItems = (await Firebase .Child("ActivityLists") .Child("ActivityItems") .OnceAsync <DBActivityItems>()).Select(item => new DBActivityItems { ActivityItemId = item.Object.ActivityItemId, ActivityId = item.Object.ActivityId, Name = item.Object.Name, AskBeforeActivity = item.Object.AskBeforeActivity, Type = item.Object.Type }).ToList(); int id = 0; if (KnownActivityItems != null) { id = KnownActivityItems.Count + 1; } await Firebase .Child("ActivityLists") .Child("ActivityItems") .PostAsync(new DBActivityItems() { ActivityItemId = id, ActivityId = parentId, Name = aItem.Name, AskBeforeActivity = aItem.AskBeforeActivity, Type = aItem.Type }); if (aItem.Type.Contains("Text")) { var itemText = aItem as TextItem; if (itemText != null) { await AddTextItem(id, itemText); } } else if (aItem.Type.Contains("Bool")) { var itemBool = aItem as BoolItem; if (itemBool != null) { await AddBoolItem(id, itemBool); } } else if (aItem.Type.Contains("List")) { var itemList = aItem as ListItem; if (itemList != null) { await AddListItems(id, itemList); } } }
public bool IsNewActivityName(string activityName) { var item = new ActivityItem() { Name = activityName }; return(!mListAdapter.Contains(item, ActivityItem.EqualityComparer)); }
public void Should_return_timer_decision_when_rescheduled_after_a_timeout() { var workflowItem = new ActivityItem(Identity.New("name", "ver", "pos"), _workflow.Object); var workflowAction = WorkflowAction.Schedule(workflowItem).After(TimeSpan.FromSeconds(2)); var decisions = workflowAction.GetDecisions(); Assert.That(decisions, Is.EquivalentTo(new [] { new ScheduleTimerDecision(Identity.New("name", "ver", "pos"), TimeSpan.FromSeconds(2), true) })); }
public void Can_be_configured_to_schedule_activity_with_priority() { var activityItem = new ActivityItem(_activityIdentity, _workflow.Object); activityItem.WithPriority(a => 10); var decision = ScheduleDecision(activityItem); Assert.That(decision.TaskPriority.Value, Is.EqualTo(10)); }
public void Returns_cancel_activity_decision_for_activity_item_when_neither_activity_not_reschedule_timer_are_active() { var activityItem = new ActivityItem(Identity.New("activityName1", "ver"), _workflow.Object); var workflowAction = WorkflowAction.Cancel(activityItem); var decisions = workflowAction.GetDecisions(); Assert.That(decisions, Is.EqualTo(new[] { new CancelActivityDecision(Identity.New("activityName1", "ver")) })); }
/// <param name = "id">is FLWMTR_CTRL_PREFIX or FLWMTR_CTRL_SUFFIX</param> /// <param name = "ctrlName"></param> /// <param name = "state">of the event task activitie</param> internal void addTaskFlowCtrl(int id, String ctrlName, int state) { ActivityItem act; if (_enabled && _isTaskFlow) { String info; switch (id) { case InternalInterface.MG_ACT_VARIABLE: info = state == FlowMonitorInterface.FLWMTR_START ? S_VARIABLE_STR : E_VARIABLE_STR; id = FlowMonitorInterface.FLWMTR_VARCHG_VALUE; break; case InternalInterface.MG_ACT_CTRL_PREFIX: info = state == FlowMonitorInterface.FLWMTR_START ? S_CTRLPRF_STR : E_CTRLPRF_STR; id = FlowMonitorInterface.FLWMTR_CTRL_PREFIX; break; case InternalInterface.MG_ACT_CTRL_SUFFIX: info = state == FlowMonitorInterface.FLWMTR_START ? S_CTRLSUF_STR : E_CTRLSUF_STR; id = FlowMonitorInterface.FLWMTR_CTRL_SUFFIX; break; case InternalInterface.MG_ACT_CTRL_VERIFICATION: info = state == FlowMonitorInterface.FLWMTR_START ? S_CTRLVER_STR : E_CTRLVER_STR; id = FlowMonitorInterface.FLWMTR_CTRL_SUFFIX; break; default: info = null; break; } act = new ActivityItem(this, ACT_TASK_FLW, id); if (info != null) { info += ctrlName; if (id == FlowMonitorInterface.FLWMTR_VARCHG_VALUE && state == FlowMonitorInterface.FLWMTR_START) { info += VARIABLE_REASON_STR; } act.setInfo(info); } _queue.put(act); } }
public void Does_not_schedule_activity_when_when_func_is_evaluated_to_false() { var activityItem = new ActivityItem(_activityIdentity, _workflow.Object); activityItem.When(a => false); var decisions = activityItem.ScheduleDecisions(); Assert.That(decisions, Is.Empty); }
public void Returns_cancel_activity_decision_for_activity_item_when_reschedule_timer_is_not_active() { SetupWorkflowToReturns(_eventGraph.ActivityStartedGraph(Identity.New("activityName1", "ver").ScheduleId(), "id")); var activityItem = new ActivityItem(Identity.New("activityName1", "ver"), _workflow.Object); var workflowAction = WorkflowAction.Cancel(activityItem); var decisions = workflowAction.Decisions(Mock.Of <IWorkflow>()); Assert.That(decisions, Is.EqualTo(new[] { new CancelActivityDecision(Identity.New("activityName1", "ver").ScheduleId()) })); }
public void Can_be_configured_to_schedule_activity_with_custom_input_object() { var activityItem = new ActivityItem(_activityIdentity, null); activityItem.WithInput(a => new{ InputFile = "SomeFile", Rate = 50 }); var decision = ScheduleDecision(activityItem); Assert.That(decision.Input, Is.EqualTo(new { InputFile = "SomeFile", Rate = 50 }.ToJson())); }
public static ActivityItem PopulateActivityItemFromIDataReader(IDataReader dr) { ActivityItem codeActivity = new ActivityItem(); codeActivity.ActivityID = DataRecordHelper.GetInt32(dr, "ActivityID"); codeActivity.ActivityKey = DataRecordHelper.GetString(dr, "ActivityKey"); codeActivity.ActivityName = DataRecordHelper.GetString(dr, "ActivityName"); codeActivity.IsEnabled = DataRecordHelper.GetBoolean(dr, "IsEnabled", true); return(codeActivity); }
public void Can_be_configured_to_schedule_activity_with_null_input() { var activityItem = new ActivityItem(_activityIdentity, null); activityItem.WithInput(a => null); var decision = ScheduleDecision(activityItem); Assert.That(decision.Input, Is.Null); }
public void Returns_cancel_timer_decision_for_activity_item_when_reschedule_timer_is_active() { SetupWorkflowToReturns(_builder.TimerStartedGraph(Identity.New("activityName1", "ver"), TimeSpan.FromSeconds(2), true)); var activityItem = new ActivityItem(Identity.New("activityName1", "ver"), _workflow.Object); var workflowAction = WorkflowAction.Cancel(activityItem); var decisions = workflowAction.GetDecisions(); Assert.That(decisions, Is.EqualTo(new[] { new CancelTimerDecision(Identity.New("activityName1", "ver")) })); }
public bool Exists(string userId, ActivityItem item, ActivityAction action, int itemId) { var result = _userActivityRepo.GetAll().FirstOrDefault( x => x.UserId == userId && x.Item == item && x.Action == action && x.ItemId == itemId); return(result != null); }
/// <summary> /// Add a field flow operation activity item. /// </summary> /// <param name = "oper">The operation being logged.</param> /// <param name = "flowMode">The task's flow mode.</param> /// <param name = "flowDirection">The task's flow direction.</param> /// <param name = "bExecuted">Will the operation be executed.</param> internal void addFlowFieldOperation(Operation oper, Flow flowMode, Direction flowDirection, bool bExecuted) { if (_enabled && _isFlowOperation) { ActivityItem act = new ActivityItem(this, ACT_FLW_OPER, FlowMonitorInterface.FLWMTR_DATA_OPER); StringBuilder buffer = new StringBuilder(FLW_PERFIX); oper.AddFlowDescription(buffer); buffer.Append(' '); switch (flowMode) { case Flow.FAST: if (flowDirection == Direction.FORE) { buffer.Append(FLW_FAST_FWD); } else if (flowDirection == Direction.BACK) { // FLOW_BACK buffer.Append(FLW_FAST_BWD); } break; // We add nothing for FLOW_NONE case Flow.STEP: if (flowDirection == Direction.FORE) { buffer.Append(FLW_STEP_FWD); } else if (flowDirection == Direction.BACK) { // FLOW_BACK buffer.Append(FLW_STEP_BWD); } break; // For operation mode NONE we write STEP_FORWARD - // see FLWMTR_CTX::output_ case FLWMTR_DATA_OPER: case Flow.NONE: buffer.Append(FLW_STEP_FWD); break; default: Logger.Instance.WriteExceptionToLog("FlowMonitorQueue.addFlowFieldOperation unknown flow mode " + flowMode); return; } if (!bExecuted) { buffer.Append(FLW_NOT_EXEC); } act.setInfo(buffer.ToString()); _queue.put(act); } }
public void By_default_schedule_activity_with_empty_timeouts() { var activityItem = new ActivityItem(_activityIdentity, _workflow.Object); var decision = ScheduleDecision(activityItem); Assert.That(decision.Timeouts.HeartbeatTimeout, Is.Null); Assert.That(decision.Timeouts.ScheduleToCloseTimeout, Is.Null); Assert.That(decision.Timeouts.ScheduleToStartTimeout, Is.Null); Assert.That(decision.Timeouts.StartToCloseTimeout, Is.Null); }
public void Last_event_can_be_null() { var workflowHistoryEvents = new WorkflowHistoryEvents(_eventGraphBuilder.WorkflowStartedGraph()); _workflow.SetupGet(w => w.WorkflowHistoryEvents).Returns(workflowHistoryEvents); var activityItem = new ActivityItem(_activityIdentity, _workflow.Object); var latestEvent = activityItem.LastEvent(); Assert.IsNull(latestEvent); }
public void Returns_timer_decision_when_jumped_after_a_timeout() { var identity = Identity.New("name", "ver", "pos"); var workflowItem = new ActivityItem(identity, _workflow.Object); var workflowAction = WorkflowAction.JumpTo(null, workflowItem).After(TimeSpan.FromSeconds(2)); var decisions = workflowAction.Decisions(Mock.Of <IWorkflow>()).ToArray(); Assert.That(decisions.Count(), Is.EqualTo(1)); decisions[0].AssertRescheduleTimer(identity.ScheduleId(), TimeSpan.FromSeconds(2)); }
public void By_default_workflow_input_is_passed_as_activity_input() { const string workflowInput = "actvity"; _workflow.SetupGet(w => w.WorkflowHistoryEvents).Returns(new WorkflowHistoryEvents(_eventGraphBuilder.WorkflowStartedGraph(workflowInput))); var activityItem = new ActivityItem(_activityIdentity, _workflow.Object); var decision = ScheduleDecision(activityItem); Assert.That(decision.Input, Is.EqualTo(workflowInput)); }
public void Can_be_configured_to_schedule_activity_with_custom_input_string() { const string activityInput = "actvity"; var activityItem = new ActivityItem(_activityIdentity, null); activityItem.WithInput(a => activityInput); var decision = ScheduleDecision(activityItem); Assert.That(decision.Input, Is.EqualTo(activityInput)); }
public void Can_be_configured_to_schedule_activity_with_primitive_string() { DateTime activityInput = DateTime.Now; var activityItem = new ActivityItem(_activityIdentity, null); activityItem.WithInput(a => activityInput); var decision = ScheduleDecision(activityItem); Assert.That(decision.Input, Is.EqualTo(activityInput.ToString())); }
public void Can_be_configured_to_schedule_activity_with_custom_task_list() { const string taskList = "taskList"; var activityItem = new ActivityItem(_activityIdentity, _workflow.Object); activityItem.OnTaskList(a => taskList); var decision = ScheduleDecision(activityItem); Assert.That(decision.TaskListName, Is.EqualTo(taskList)); }
/// <summary> /// The activity item to store activity dc. /// </summary> /// <param name="activityItem"> /// The activity item. /// </param> /// <returns> /// Converted StoreActivitiesDC instance /// </returns> public static StoreActivitiesDC ActivityItemToStoreActivitiyDC(ActivityItem activityItem) { var storeActivity = new StoreActivitiesDC(); storeActivity.ActivityCategoryName = activityItem.Category; storeActivity.Description = activityItem.Description; storeActivity.Name = activityItem.FullName; storeActivity.ShortName = activityItem.Name; storeActivity.IsCodeBeside = activityItem.HasCodeBehind; storeActivity.Version = activityItem.Version; storeActivity.Xaml = activityItem.XamlCode; storeActivity.MetaTags = activityItem.Tags; storeActivity.AuthGroupName = AuthorizationService.GetWorkflowAuthGroupName(); storeActivity.ActivityCategoryName = activityItem.Category; storeActivity.Incaller = Utility.GetCallerName(); storeActivity.IncallerVersion = Utility.GetCallerVersion(); storeActivity.DeveloperNotes = activityItem.DeveloperNote; storeActivity.InsertedDateTime = activityItem.CreateDateTime; storeActivity.InsertedByUserAlias = !String.IsNullOrEmpty(activityItem.CreatedBy) ? activityItem.CreatedBy : Environment.UserName; storeActivity.IsCodeBeside = true; storeActivity.StatusCodeName = activityItem.Status; storeActivity.Guid = Guid.NewGuid(); storeActivity.UpdatedByUserAlias = Utility.GetCurrentUserName(); storeActivity.Locked = false; storeActivity.LockedBy = Environment.UserName; storeActivity.UpdatedByUserAlias = activityItem.UpdatedBy; storeActivity.UpdatedDateTime = activityItem.UpdateDateTime; storeActivity.OldVersion = activityItem.OldVersion; if (activityItem is WorkflowItem) { storeActivity.WorkflowTypeName = ((WorkflowItem)activityItem).WorkflowType; storeActivity.IsService = ((WorkflowItem)activityItem).IfNotNull(wfi => wfi.IsService); } else { //Save default values to the store. When saving the different activities, only the root activity will be a //workflow item, the rest sub-activities will be saved with WorkflowType "metadata" until we remove WorkflowTypeID //From the Store Activities table. There is already an ActivityLibraryID to check the library that contains the activity, //so this workflowType is not being used at all and should be removed. storeActivity.WorkflowTypeName = "Metadata"; storeActivity.IsService = false; } return storeActivity; }
private void PivotMenu_Loaded(object sender, RoutedEventArgs e) { if (DesignerProperties.IsInDesignTool) { // Some design-time data var processMenu = new ProcessAreaItem(); processMenu.Title = "Process Area 1"; for (int index = 1; index < 6; index++) { var activityItem = new ActivityItem(); activityItem.Title = "Activity " + index.ToString(); processMenu.Add(activityItem); } MenuCollection menuCollection = new MenuCollection(); menuCollection.Add(processMenu); processMenu = new ProcessAreaItem(); processMenu.Title = "Process Area 2"; for (int index = 1; index < 6; index++) { var activityItem = new ActivityItem(); activityItem.Title = "Activity " + index.ToString(); processMenu.Add(activityItem); } menuCollection.Add(processMenu); this.ItemsSource = menuCollection; } else { MenuCollection menu = ApplicationEx.Instance.ApplicationMenu; if (ShouldMakeSingleLevelMenu(menu)) menu = MakeSingleLevelMenu(menu); this.ItemsSource = menu; } }
public void BindList() { StringBuilder str = new StringBuilder(); this.TotalRecords = ActivityBLL.Count_Activities(this.Term, this.UserName, this.Month, this.Year, this.Order, this.PageSize, this.AddedFilter); if (this.TotalRecords == 0) { str.Append("<div class=\"bx_msg\">"); str.Append("<h4>" + NoRecordFoundText + "</h4>"); str.Append("</div>"); lst.InnerHtml = str.ToString(); return; } List<UserActivity_Struct> _list = ActivityBLL.Load_Activities(this.Term, this.UserName, this.Month, this.Year, this.Order, this.PageSize, this.AddedFilter,this.isCache, 1); if (_list.Count > 0) { int i = 0; ActivityItem act = new ActivityItem(); act.LeftWidth = this._leftwidth; // profile layout style act.RightWidth = this._rightwidth; act.Width = 50; // profile thumb height act.Height = 50; act.isHoverEffect = true; act.ShowProfileThumb = true; // show user profile thumb on right side. if (this.Page.User.Identity.IsAuthenticated) { act.LoggedInUserName = this.Page.User.Identity.Name; } for (i = 0; i <= _list.Count - 1; i++) { string _puser = _list[i].PosterUserName; if(_puser == "") _puser = _list[i].UserName; PostUrl = UrlConfig.Prepare_User_Profile_Url(_puser, "activity", this.isAdmin) + "?id=" + _list[i].ActivityID; // generate list str.Append(act.Process(_list[i])); str.Append("<div class=\"clear\"></div>"); // clear floating items } str.Append("<div class=\"clear\"></div>"); // clear floating items // store comment flags int TotalPages = 1; if (this.TotalRecords >= this.PageSize) TotalPages = (int)Math.Ceiling((double)TotalRecords / this.PageSize); str.Append("<span style=\"display:none;\" id=\"cmt_tcmts\">" + this.TotalRecords + "</span>\n"); // store total pages info in <span> str.Append("<span style=\"display:none;\" id=\"cmt_tpages\">" + TotalPages + "</span>\n"); // store total pages info in <span> str.Append("<span style=\"display:none;\" id=\"cmt_psize\">" + PageSize + "</span>\n"); // store page size infor in <span> str.Append("<span style=\"display:none;\" id=\"cmt_pnum\">1</span>\n"); // current page number str.Append("<div id=\"cmt_load_cnt\"></div>\n"); // load more activity container str.Append("<div id=\"cmt_loading\"></div>\n"); // show loading progres if (TotalPages > 1) { str.Append("<div id=\"actldmore\" class=\"item_pad_4 bx_br_both actmore\" style=\"padding:5px 0px;\">\n"); str.Append("<a href=\"#\" class=\"bold actldmore\" title=\"load more activities\"><i class=\"icon-chevron-down icon-white\"></i> Load more...</a>\n"); str.Append("</div>\n"); } } else { str.Append("<div class=\"bx_msg\">"); str.Append("<h4>" + this.NoRecordFoundText + "</h4>"); str.Append("</div>"); } lst.InnerHtml = str.ToString(); }
/// <summary> /// The store activity dc to activity item. /// </summary> /// <param name="dc"> /// The StoreActivitiesDC data contract instance. /// </param> /// <param name="parentAssemblyItem"> /// The parent assembly item. /// </param> /// <returns> /// Converted ActivityItem instance /// </returns> public static ActivityItem StoreActivitiyDCToActivityItem( StoreActivitiesDC dc, ActivityAssemblyItem parentAssemblyItem) { var activityItem = new ActivityItem(); activityItem.CachingStatus = CachingStatus.None; activityItem.Category = dc.ActivityCategoryName; activityItem.CreateDateTime = dc.InsertedDateTime; activityItem.CreatedBy = dc.InsertedByUserAlias; activityItem.Description = dc.Description; activityItem.FullName = dc.Name; activityItem.Name = dc.ShortName ?? dc.Name; activityItem.DisplayName = dc.ShortName ?? dc.Name; activityItem.HasCodeBehind = dc.IsCodeBeside; activityItem.IsReadOnly = true; // TODO: Need to find out where this is in the Model activityItem.IsUserFavorite = false; // TODO: This needs to be added to the Database, DAL, BAL and/or DataContract reply activityItem.ParentAssemblyItem = parentAssemblyItem; activityItem.Status = dc.StatusCodeName; activityItem.UpdatedBy = dc.UpdatedByUserAlias; activityItem.UpdateDateTime = dc.UpdatedDateTime; activityItem.UserSelected = true; // TODO: Why is this set to true? activityItem.Version = activityItem.OldVersion = dc.Version; activityItem.XamlCode = dc.Xaml; return activityItem; }
public static StoreActivitiesDC ActivityItemToStoreActivitiyDC(ActivityItem activityItem, TaskAssignment task) { StoreActivitiesDC dc = ActivityItemToStoreActivitiyDC(activityItem); dc.Name = dc.ShortName = task.GetFriendlyName(activityItem.Name); dc.Version = task.Version; dc.Xaml = task.Xaml; dc.InsertedByUserAlias = dc.UpdatedByUserAlias = task.AssignTo; return dc; }
private static string GetDisplayName(ActivityItem activityItem, Type activityType) { string result = null; // If the activityItem record has a DisplayName, use that. if ((null != activityItem) && (!string.IsNullOrEmpty(activityItem.DisplayName))) result = activityItem.DisplayName; // Otherwise, if we can reflect over the type and pull out a property named "DisplayName", use that. if (string.IsNullOrEmpty(result) && !activityType.ContainsGenericParameters) // nothing else has set the result - try reflecting. { try { var properties = activityType.GetProperties(); dynamic toolboxEntry = Activator.CreateInstance(activityType); if (properties.Any(property => property.Name == "DesignerCaption")) // Some objects have this property... result = toolboxEntry.DesignerCaption; else if (properties.Any(property => property.Name == "DisplayName")) // ..but this property seems to be preferred by the .Net framework. result = toolboxEntry.DisplayName; } catch { // we could have failed because the class has generic (type) parameters, because it does not have a // public parameterless constructor, or any other number of reasons. If we do fail here, it's // OK, we'll just make a human readable display out of the type name, later on in this method. } } // If all else fails, make a human readable display out of the type name. if (string.IsNullOrEmpty(result)) // nothing else has set the result - make the type name pretty. result = GetHumanReadableName(Helper.TranslateActivityTypeName(activityType.Name)); return result; }
/// <summary> /// Does this ActivityAssemblyItem represent this assembly name? /// </summary> /// <param name="name">Name of assembly to use in the operation</param> /// <returns></returns> public bool Matches(ActivityItem otherObject) { // Return less than if the inbound assembly is null, this is unexpected but possible if (null == otherObject) return false; // Check for a Name match, not using CompareTo bool isNameMatch = !string.IsNullOrEmpty(Name) && !string.IsNullOrEmpty(otherObject.Name) && Name.Equals(otherObject.Name, StringComparison.InvariantCultureIgnoreCase); // If the Name matches then return the CompareTo for the Versions if (isNameMatch) { var otherVersion = new Version(); try { otherVersion = new System.Version(otherObject.Version); } catch (ArgumentException) { // Nothing to do for first chance exception we already have a version to start with for both } catch (FormatException) { // Nothing to do for second chance exception we already have a version to start with for both } catch (OverflowException) { // Nothing to do for tertiary exception we already have a version to start with for both } return this.Version.Equals(otherVersion); } else { return false; } }