Ejemplo n.º 1
0
 public static void UpdateExperienceDetails(ExperienceNodeViewModel experience)
 {
     try
     {
         using (_certonaService = new CertonaServiceClient())
         {
             try
             {
                 UserDTO user    = FormsAuthenticationWrapper.User;
                 var     request = new UpdateExperienceDetailsRequest
                 {
                     User         = user,
                     ExperienceID = experience.ExperienceID,
                     Name         = experience.Name,
                     Description  = experience.Description,
                 };
                 _certonaService.UpdateExperienceDetails(request);
             }
             catch (TimeoutException exception)
             {
                 _certonaService.Abort();
                 throw;
             }
             catch (CommunicationException exception)
             {
                 _certonaService.Abort();
                 throw;
             }
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Ejemplo n.º 2
0
        private static void DeactivateExperiences(SchemeExperience experience)
        {
            // get all experiences for container
            var m = SchemeModel.GetSchemeExperiences(experience.SchemeID);

            try
            {
                using (_certonaService = new CertonaServiceClient())
                {
                    try
                    {
                        UserDTO user = FormsAuthenticationWrapper.User;
                        foreach (var exp in m.Experiences)
                        {
                            if (exp.ExperienceID != experience.ExperienceID && exp.Status == "Active")
                            {
                                // set others to Inactive
                                var request = new UpdateExperienceDetailsRequest
                                {
                                    User         = user,
                                    ExperienceID = exp.ExperienceID,
                                    Status       = "Inactive",
                                };
                                _certonaService.UpdateExperienceDetails(request);

                                // clear Traffic
                                var req = new UpdateExperienceTrafficRequest()
                                {
                                    User = user, ExperienceID = exp.ExperienceID
                                };
                                _certonaService.UpdateExperienceTraffic(req);
                            }
                        }
                    }
                    catch (TimeoutException exception)
                    {
                        _certonaService.Abort();
                        throw;
                    }
                    catch (CommunicationException exception)
                    {
                        _certonaService.Abort();
                        throw;
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Ejemplo n.º 3
0
        public static void UpdateExperienceDetails(SchemeExperience experience)
        {
            try
            {
                ExperienceNodeViewModel exp = GetExperienceDetails(experience.ExperienceID);
                // Get existing
                bool activating   = (exp.Status != "Active" && experience.Status == "Active");
                bool deactivating = (exp.Status == "Active" && experience.Status != "Active");

                using (_certonaService = new CertonaServiceClient())
                {
                    try
                    {
                        UserDTO user    = FormsAuthenticationWrapper.User;
                        var     request = new UpdateExperienceDetailsRequest
                        {
                            User         = user,
                            ExperienceID = experience.ExperienceID,
                            Name         = experience.Name,
                            Description  = experience.Description,
                            Status       = experience.Status,
                        };
                        _certonaService.UpdateExperienceDetails(request);

                        if (activating)
                        {
                            // for Active (current) one, set Traffic = 100
                            var req = new UpdateExperienceTrafficRequest()
                            {
                                User = user, ExperienceID = experience.ExperienceID
                            };
                            if (experience.Traffic.HasValue)
                            {
                                req.SamplingRangeBegin = 0;
                                req.SamplingRangeEnd   = experience.Traffic.Value;
                            }
                            _certonaService.UpdateExperienceTraffic(req);
                        }
                        if (deactivating)
                        {
                            var req = new UpdateExperienceTrafficRequest()
                            {
                                User = user, ExperienceID = experience.ExperienceID
                            };
                            _certonaService.UpdateExperienceTraffic(req);
                        }
                    }
                    catch (TimeoutException exception)
                    {
                        _certonaService.Abort();
                        throw;
                    }
                    catch (CommunicationException exception)
                    {
                        _certonaService.Abort();
                        throw;
                    }
                }

                if (activating)
                {
                    // set others to Inactive and clear Traffic
                    DeactivateExperiences(experience);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }