コード例 #1
0
ファイル: ExportToRQM.cs プロジェクト: ramizil/Ginger
        private ActivityPlan GetTestPlanFromBusinessFlow(BusinessFlow businessFlow)
        {
            ActivityPlan testPlan = new ActivityPlan();

            //Check if updating or creating new instance in RQM
            if (!string.IsNullOrEmpty(businessFlow.ExternalID))
            {
                try
                {
                    long rqmID = Convert.ToInt64(GetExportedIDString(businessFlow.ExternalID, "RQMID"));
                    //getExportID(businessFlow.ExternalID);
                    if (rqmID != 0)
                    {
                        testPlan.ExportedID    = rqmID;
                        testPlan.ShouldUpdated = true;
                    }
                }
                catch (Exception e)
                {
                    testPlan.ShouldUpdated = false;
                    Reporter.ToLog(eLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name}, Error - {e.Message}");
                }
            }

            testPlan.EntityName = businessFlow.Name;
            testPlan.EntityDesc = businessFlow.Description == null ? "" : businessFlow.Description;

            //Add custom properties
            Dictionary <string, string> ActivityLevelproperties = GetCustomProperties("TestPlan");

            testPlan.CustomProperties = ActivityLevelproperties;

            return(testPlan);
        }
コード例 #2
0
        public IActionResult DeleteActivty(int ActivityPlanID)
        {
            ActivityPlan deleteMe = _context.ActivityPlans.SingleOrDefault(a => a.ActivityPlanID == ActivityPlanID);

            _context.Remove(deleteMe);
            _context.SaveChanges();
            return(RedirectToAction("ShowDashboard"));
        }
コード例 #3
0
        public ActivityPlanViewModel(ActivityPlan plan) : this()
        {
            _isEdit     = true;
            _editedPlan = plan;
            Name        = plan.Name;

            foreach (var selectedActivity in plan.ActivityPlanActivities)
            {
                SelectedActivities.Add(selectedActivity);
            }
        }
コード例 #4
0
ファイル: TextComment.cs プロジェクト: ut-hk/ut-api-legacy
 public static TextComment Create(string content, ActivityPlan activityPlan, User owner)
 {
     return(new TextComment
     {
         Text = content,
         ActivityPlan = activityPlan,
         ActivityPlanId = activityPlan.Id,
         Owner = owner,
         OwnerId = owner.Id
     });
 }
コード例 #5
0
 public static Rating Create(RatingStatus ratingStatus, ActivityPlan activityPlan, User owner)
 {
     return(new Rating
     {
         RatingStatus = ratingStatus,
         ActivityPlan = activityPlan,
         ActivityPlanId = activityPlan.Id,
         Owner = owner,
         OwnerId = owner.Id
     });
 }
コード例 #6
0
 public static InternalImageComment Create(Image image, ActivityPlan activityPlan, User owner)
 {
     return(new InternalImageComment
     {
         Image = image,
         ImageId = image.Id,
         ActivityPlan = activityPlan,
         ActivityPlanId = activityPlan.Id,
         Owner = owner,
         OwnerId = owner.Id
     });
 }
コード例 #7
0
        public void Post_Creates_New_ActivityPlan()
        {
            var newActivityPlan  = new ActivityPlan(1, "title", "agerange", "description", 50, 50, 1);
            var ActivityPlanList = new List <ActivityPlan>();

            activityPlanRepo.When(t => t.Create(newActivityPlan))
            .Do(t => ActivityPlanList.Add(newActivityPlan));

            activityPlanRepo.GetAll().Returns(ActivityPlanList);

            var result = underTest.Post(newActivityPlan);

            Assert.Contains(newActivityPlan, result);
        }
コード例 #8
0
        public async Task <EntityDto <Guid> > CreateActivityPlan(CreateActivityPlanInput input)
        {
            var currentUser = await GetCurrentUserAsync();

            var tags = await _tagManager.GetTags(input.TagTexts);

            var activityPlan = await _activityPlanManager.CreateAsync(ActivityPlan.Create(
                                                                          input.Name,
                                                                          tags,
                                                                          currentUser
                                                                          ));

            return(new EntityDto <Guid>(activityPlan.Id));
        }
コード例 #9
0
        public static TextDescription Create(string text, ActivityPlan activityPlan, long createUserId)
        {
            if (createUserId != activityPlan.OwnerId)
            {
                throw new UserFriendlyException($"You are not allowed to create a text description in this activity plan with id = {activityPlan.Id}.");
            }

            return(new TextDescription
            {
                Text = text,
                ActivityPlan = activityPlan,
                ActivityPlanId = activityPlan.Id
            });
        }
コード例 #10
0
        public void EditDescriptions(ActivityPlan activityPlan, long[] descriptionIds, long editUserId)
        {
            var activityPlanDescriptions = activityPlan.Descriptions;

            foreach (var activityPlanDescription in activityPlanDescriptions)
            {
                for (var i = 0; i < descriptionIds.Length; i++)
                {
                    if (descriptionIds[i] == activityPlanDescription.Id)
                    {
                        activityPlanDescription.EditPriority(i, editUserId);
                    }
                }
            }
        }
コード例 #11
0
ファイル: RatingManager.cs プロジェクト: ut-hk/ut-api-legacy
        public async Task <Rating> CreateAsync(RatingStatus ratingStatus, ActivityPlan activityPlan, User owner)
        {
            var rating = activityPlan.Ratings.FirstOrDefault(r => r.OwnerId == owner.Id && r.ActivityPlanId == activityPlan.Id);

            if (rating != null)
            {
                rating.EditRating(ratingStatus, owner.Id);
            }
            else
            {
                rating = await CreateAsync(Rating.Create(ratingStatus, activityPlan, owner));
            }

            return(rating);
        }
コード例 #12
0
        public static InternalImageDescription Create(Image image, ActivityPlan activityPlan, long createUserId)
        {
            if (createUserId != activityPlan.OwnerId)
            {
                throw new UserFriendlyException($"You are not allowed to create a internal description in this activity plan with id = {activityPlan.Id}.");
            }

            return(new InternalImageDescription
            {
                Image = image,
                ImageId = image.Id,
                ActivityPlan = activityPlan,
                ActivityPlanId = activityPlan.Id
            });
        }
コード例 #13
0
        public static ExternalImageDescription Create(string path, ActivityPlan activityPlan, long createUserId)
        {
            if (createUserId != activityPlan.OwnerId)
            {
                throw new UserFriendlyException($"You are not allowed to create a external image description in this activity plan with id = {activityPlan.Id}.");
            }

            var uri = new Uri(path);

            return(new ExternalImageDescription
            {
                Path = uri.Host + uri.PathAndQuery,
                ActivityPlan = activityPlan,
                ActivityPlanId = activityPlan.Id
            });
        }
コード例 #14
0
        public void Put_Updates_ActivityPlan()
        {
            var originalActivityPlan = new ActivityPlan(1, "title", "agerange", "description", 50, 50, 1);
            var expectedActivityPlan = new List <ActivityPlan>()
            {
                originalActivityPlan
            };
            var updatedActivityPlan = new ActivityPlan(1, "2title", "2agerange", "2description", 250, 250, 1);

            activityPlanRepo.When(t => activityPlanRepo.Update(updatedActivityPlan))
            .Do(Callback.First(t => expectedActivityPlan.Remove(originalActivityPlan))
                .Then(t => expectedActivityPlan.Add(updatedActivityPlan)));
            activityPlanRepo.GetAll().Returns(expectedActivityPlan);

            var result = underTest.Put(updatedActivityPlan);

            Assert.Equal(expectedActivityPlan, result.ToList());
        }
コード例 #15
0
 public IActionResult CreateActivityPlan(ActivityPlanViewModel AnActivityPlan)
 {
     if (ModelState.IsValid)
     {
         ActivityPlan AddActivityPlan = new ActivityPlan
         {
             Title        = AnActivityPlan.Title,
             StartDate    = AnActivityPlan.StartDate,
             Duration     = AnActivityPlan.Duration,
             DurationType = AnActivityPlan.DurationType,
             Description  = AnActivityPlan.Description,
             UserID       = (int)HttpContext.Session.GetInt32("logged_id")
         };
         _context.ActivityPlans.Add(AddActivityPlan);
         _context.SaveChanges();
         return(RedirectToAction("ShowDashboard"));
     }
     return(View("ActivityForm"));
 }
コード例 #16
0
        public void Delete_Removes_ActivityPlan()
        {
            var ActivityPlanID      = 1;
            var deletedActivityPlan = new ActivityPlan(1, "title", "agerange", "description", 50, 50, 1);
            var activityPlanList    = new List <ActivityPlan>()
            {
                deletedActivityPlan,
                new ActivityPlan(2, "2title", "2agerange", "2description", 250, 250, 2)
            };

            activityPlanRepo.GetById(ActivityPlanID).Returns(deletedActivityPlan);
            activityPlanRepo.When(d => d.Delete(deletedActivityPlan))
            .Do(d => activityPlanList.Remove(deletedActivityPlan));

            activityPlanRepo.GetAll().Returns(activityPlanList);
            var result = underTest.Delete(ActivityPlanID);

            Assert.DoesNotContain(deletedActivityPlan, result);
            //Assert.All(result, item => Assert.Contains("second item", item.Title));
        }
コード例 #17
0
        public ActionResult SaveActivity()
        {
            var request = Request.Form;

            var id = request.GetValues("id");

            ActivityPlan itemToSave = null;

            if (id != null)
            {
                var intId = int.Parse(id[0]);
                itemToSave = calendarContext.ActivityPlans.FirstOrDefault(o => o.Id == intId);
            }

            if (itemToSave == null)
            {
                itemToSave = new ActivityPlan();
            }

            itemToSave.Description  = request.Get("Description");
            itemToSave.Date         = DateTime.Parse(request.Get("Date"));
            itemToSave.Type         = (ActivityType)Enum.Parse(typeof(ActivityType), request.Get("Type"));
            itemToSave.ActivityName = request.Get("ActivityName");
            itemToSave.UserId       = request.Get("UserId");

            if (itemToSave.Id == 0)
            {
                calendarContext.ActivityPlans.Add(itemToSave);
            }
            else
            {
                calendarContext.ActivityPlans.AddOrUpdate(itemToSave);
            }
            calendarContext.SaveChanges();

            return(RedirectToActionPermanent("Index"));
        }
コード例 #18
0
ファイル: ExportToRQM.cs プロジェクト: ramizil/Ginger
        public bool ExportBusinessFlowToRQM(BusinessFlow businessFlow, ObservableList <ExternalItemFieldBase> ExternalItemsFields, ref string result)
        {
            mExternalItemsFields = ExternalItemsFields;
            LoginDTO loginData = new LoginDTO()
            {
                User = ALMCore.AlmConfig.ALMUserName, Password = ALMCore.AlmConfig.ALMPassword, Server = ALMCore.AlmConfig.ALMServerURL
            };

            //ActivityPlan is TestPlan in RQM and BusinessFlow in Ginger
            List <IActivityPlan> testPlanList = new List <IActivityPlan>(); //1
            ActivityPlan         testPlan     = GetTestPlanFromBusinessFlow(businessFlow);

            testPlanList.Add(testPlan);//2

            if (businessFlow.ActivitiesGroups.Count == 0)
            {
                throw new Exception(GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + " must have at least one " + GingerDicser.GetTermResValue(eTermResKey.ActivitiesGroup));
            }

            ResultInfo resultInfo;

            try
            {
                //Create (RQM)TestCase for each Ginger ActivityGroup and add it to RQM TestCase List
                testPlan.Activities = new List <IActivityModel>();//3
                foreach (ActivitiesGroup ag in businessFlow.ActivitiesGroups)
                {
                    testPlan.Activities.Add(GetTestCaseFromActivityGroup(ag));
                }

                RQMConnect.Instance.RQMRep.GetConection();

                resultInfo = RQMConnect.Instance.RQMRep.ExportTestPlan(loginData, testPlanList, ALMCore.AlmConfig.ALMServerURL, RQMCore.ALMProjectGuid, ALMCore.AlmConfig.ALMProjectName, RQMCore.ALMProjectGroupName, null);
            }
            catch (Exception ex)
            {
                result = "Failed to export the Business Flow to RQM/ALM " + ex.Message;
                Reporter.ToLog(eLogLevel.ERROR, "Failed to export the Business Flow to RQM/ALM", ex);
                return(false);
            }

            // Deal with response from RQM after export
            // 0 = sucsess , 1 = failed
            if (resultInfo.ErrorCode == 0)
            {
                foreach (ActivityPlan plan in testPlanList)
                {
                    businessFlow.ExternalID = "RQMID=" + plan.ExportedID.ToString();
                    int ActivityGroupCounter = 0;
                    int activityStepCounter  = 0;
                    int activityStepOrderID  = 1;
                    foreach (ACL_Data_Contract.Activity act in plan.Activities)
                    {
                        string ActivityGroupID = "RQMID=" + act.ExportedID.ToString() + "|RQMScriptID=" + act.ExportedTestScriptId.ToString() + "|RQMRecordID=" + act.ExportedTcExecutionRecId.ToString() + "|AtsID=" + act.EntityId.ToString();
                        businessFlow.ActivitiesGroups[ActivityGroupCounter].ExternalID = ActivityGroupID;

                        foreach (ACL_Data_Contract.ActivityStep activityStep in act.ActivityData.ActivityStepsColl)
                        {
                            //string activityStepID = "RQMID=" + activityStepOrderID.ToString() + "|AtsID=" + act.EntityId.ToString();
                            string activityStepID = "RQMID=" + act.ExportedTestScriptId.ToString() + "_" + activityStepOrderID + "|AtsID=" + act.EntityId.ToString();
                            businessFlow.Activities[activityStepCounter].ExternalID = activityStepID;
                            activityStepCounter++;
                            activityStepOrderID++;
                        }
                        activityStepOrderID = 0;
                        ActivityGroupCounter++;
                    }
                }
                return(true);
            }
            else
            {
                result = "Failed to export the " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + " to RQM/ALM, " + resultInfo.ErrorDesc;
                Reporter.ToLog(eLogLevel.ERROR, "Failed to export the Business Flow to RQM/ALM, " + resultInfo.ErrorDesc);
                return(false);
            }
        }
コード例 #19
0
 public async Task RemoveAsync(ActivityPlan activityPlan, long deleteUserId)
 {
     await activityPlan.RemoveAsync(_activityPlanRepository, deleteUserId);
 }
コード例 #20
0
 public void EditActivityPlan(ActivityPlan activityPlan, string name, ICollection <Tag> tags, long editUserId)
 {
     activityPlan.Edit(name, tags, editUserId);
 }
コード例 #21
0
 public IEnumerable <ActivityPlan> Put([FromBody] ActivityPlan activityPlan)
 {
     activityPlanRepo.Update(activityPlan);
     return(activityPlanRepo.GetAll());
 }
コード例 #22
0
 public ActivityPlanWindow(ActivityPlan activityPlan)
 {
     InitializeComponent();
     _viewModel = new ActivityPlanViewModel(activityPlan);
 }
コード例 #23
0
        public async Task <ActivityPlan> CreateAsync(ActivityPlan activityPlan)
        {
            activityPlan.Id = await _activityPlanRepository.InsertAndGetIdAsync(activityPlan);

            return(activityPlan);
        }
コード例 #24
0
        public bool ExportBfActivitiesGroupsToALM(BusinessFlow businessFlow, ObservableList <ActivitiesGroup> grdActivitiesGroups, ref string result)
        {
            LoginDTO loginData = new LoginDTO()
            {
                User = ALMCore.DefaultAlmConfig.ALMUserName, Password = ALMCore.DefaultAlmConfig.ALMPassword, Server = ALMCore.DefaultAlmConfig.ALMServerURL
            };
            //ActivityPlan is TestPlan in RQM and BusinessFlow in Ginger
            List <IActivityPlan> testPlanList = new List <IActivityPlan>(); //1
            ActivityPlan         testPlan     = new ActivityPlan();

            testPlan.IsPlanDisabled = true;
            testPlanList.Add(testPlan);

            try
            {
                //Create (RQM)TestCase for each Ginger ActivityGroup and add it to RQM TestCase List
                testPlan.Activities = new List <IActivityModel>();//3
                foreach (ActivitiesGroup ag in grdActivitiesGroups)
                {
                    testPlan.Activities.Add(GetTestCaseFromActivityGroup(ag));
                }

                RQMConnect.Instance.RQMRep.GetConection();

                ResultInfo resultInfo;
                resultInfo = RQMConnect.Instance.RQMRep.ExportTestPlan(loginData, testPlanList, ALMCore.DefaultAlmConfig.ALMServerURL, RQMCore.ALMProjectGuid, ALMCore.DefaultAlmConfig.ALMProjectName, RQMCore.ALMProjectGroupName, null);


                // Deal with response from RQM after export
                // 0 = sucsess , 1 = failed
                if (resultInfo.ErrorCode == 0)
                {
                    foreach (ActivityPlan plan in testPlanList)
                    {
                        int ActivityGroupCounter = 0;
                        int activityStepCounter  = 0;
                        int activityStepOrderID  = 0;
                        foreach (ACL_Data_Contract.Activity act in plan.Activities)
                        {
                            string ActivityGroupID = "RQMID=" + act.ExportedID.ToString() + "|RQMScriptID=" + act.ExportedTestScriptId.ToString() + "|RQMRecordID=" + act.ExportedTcExecutionRecId.ToString() + "|AtsID=" + act.EntityId.ToString();
                            businessFlow.ActivitiesGroups[ActivityGroupCounter].ExternalID = ActivityGroupID;

                            foreach (ACL_Data_Contract.ActivityStep activityStep in act.ActivityData.ActivityStepsColl)
                            {
                                string activityStepID = "RQMID=" + activityStepOrderID.ToString() + "|AtsID=" + act.EntityId.ToString();
                                businessFlow.Activities[activityStepCounter].ExternalID = activityStepID;
                                activityStepCounter++;
                                activityStepOrderID++;
                            }
                            activityStepOrderID = 0;
                            ActivityGroupCounter++;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                result = "Failed to export the " + GingerDicser.GetTermResValue(eTermResKey.ActivitiesGroups) + " to RQM/ALM " + ex.Message;
                Reporter.ToLog(eLogLevel.ERROR, "Failed to export " + GingerDicser.GetTermResValue(eTermResKey.ActivitiesGroups) + " to RQM/ALM", ex);
                return(false);
            }

            return(true);
        }