Example #1
0
        private static void PublishManagerResponse(ICoreClient client, InternalRequest internalRequest)
        {
            if (internalRequest.Status == RequestStatusEnum.Undefined)
            {
                throw new ArgumentNullException("status");
            }
            ManagerResponse response = new ManagerResponse()
            {
                RequestId   = internalRequest.RequestId.ToString(),
                Status      = internalRequest.Status,
                FaultDetail = internalRequest.FaultDetail
            };
            UserIdentity requesterId = null;

            if (internalRequest.ExternalRequest != null)
            {
                requesterId = internalRequest.ExternalRequest.RequesterId;
            }
            if ((requesterId == null) && (internalRequest.Cancellation != null))
            {
                requesterId = internalRequest.Cancellation.RequesterId;
            }
            response.RequesterId = requesterId;
            if ((response.Status == RequestStatusEnum.Cancelled) && (internalRequest.Cancellation != null))
            {
                response.CancelReason = internalRequest.Cancellation.CancelReason;
            }
            client.SaveObject <ManagerResponse>(response);
        }
        public Result <IEnumerable <AddressModel> > GetAddressList(string userName)
        {
            Assert.ArgumentNotNullOrEmpty(userName, nameof(userName));

            var result = new Result <IEnumerable <AddressModel> >();

            Result <CommerceCustomer> getCustomerResult = this.GetCustomerByUserName(userName);

            if (!getCustomerResult.Success || getCustomerResult.Data == null)
            {
                result.SetErrors(getCustomerResult.Errors);
                return(result);
            }

            ManagerResponse <GetPartiesResult, IEnumerable <Party> > getPartiesResponse = this.accountManager.GetParties(getCustomerResult.Data);

            if (!getPartiesResponse.ServiceProviderResult.Success || getPartiesResponse.Result == null)
            {
                result.SetErrors(getPartiesResponse.ServiceProviderResult);
                return(result);
            }

            IEnumerable <Party>        customerParties   = getPartiesResponse.Result;
            IEnumerable <AddressModel> customerAddresses = customerParties
                                                           .Select(p => this.entityMapper.MapToAddress(p));

            result.SetResult(customerAddresses);
            return(result);
        }
Example #3
0
        public String Monitorear(String Canal)
        {
            MonitorAction   mo        = new MonitorAction(Canal, UniqueId, "gsm", true);
            ManagerResponse response2 = Conn.SendAction(mo, 15000);

            return(response2.Message);
        }
        public Result <IEnumerable <AddressModel> > AddCustomerAddress(string userName, AddressModel address)
        {
            var result = new Result <IEnumerable <AddressModel> >();

            Result <CommerceCustomer> getCustomerResult = this.GetCustomerByUserName(userName);

            if (!getCustomerResult.Success || getCustomerResult.Data == null)
            {
                result.SetErrors(getCustomerResult.Errors);
                return(result);
            }

            string partyId  = Guid.NewGuid().ToString("N");
            var    newParty = new CommerceParty {
                Name = partyId, ExternalId = partyId, PartyId = partyId
            };

            this.UpdateCommerceParty(newParty, address);

            ManagerResponse <AddPartiesResult, IEnumerable <Party> > createPartyResponse =
                this.accountManager.AddParties(getCustomerResult.Data, new List <Party> {
                newParty
            });

            if (!createPartyResponse.ServiceProviderResult.Success)
            {
                result.SetErrors(createPartyResponse.ServiceProviderResult);
                return(result);
            }

            return(this.GetAddressList(userName));
        }
Example #5
0
        public async Task <IActionResult> Create([FromBody] CreateManagerRequest createManagerRequest)
        {
            var manager = new Manager
            {
                FirstName        = createManagerRequest.FirstName,
                LastName         = createManagerRequest.LastName,
                PersonalIdentity = createManagerRequest.PersonalIdentity
            };

            var createdManager = await _repo.CreateManagerAsync(manager);

            if (!createdManager)
            {
                return(BadRequest(new { Error = "There was an error creating a new Manager" }));
            }

            var response = new ManagerResponse
            {
                Id               = manager.Id,
                FirstName        = manager.FirstName,
                LastName         = manager.LastName,
                PersonalIdentity = manager.PersonalIdentity
            };

            return(Created("", response));
        }
Example #6
0
        /// <summary>
        /// Constructs an instance of ManagerResponse based on a map of attributes.
        /// </summary>
        /// <param name="attributes">the attributes and their values. The keys of this map must be all lower case.</param>
        /// <returns>the response with the given attributes.</returns>
        internal static ManagerResponse BuildResponse(Dictionary <string, string> attributes)
        {
            ManagerResponse response;

            string responseType = ((string)attributes["response"]).ToLower(Helper.CultureInfo);

            // Determine type
            if (responseType == "error")
            {
                response = new ManagerError();
            }
            else if (attributes.ContainsKey("challenge"))
            {
                response = new ChallengeResponse();
            }
            else if (attributes.ContainsKey("mailbox") && attributes.ContainsKey("waiting"))
            {
                response = new MailboxStatusResponse();
            }
            else if (attributes.ContainsKey("mailbox") && attributes.ContainsKey("newmessages") && attributes.ContainsKey("oldmessages"))
            {
                response = new MailboxCountResponse();
            }
            else if (attributes.ContainsKey("exten") && attributes.ContainsKey("context") && attributes.ContainsKey("hint") && attributes.ContainsKey("status"))
            {
                response = new ExtensionStateResponse();
            }
            else
            {
                response = new ManagerResponse();
            }

            Helper.SetAttributes(response, attributes);
            return(response);
        }
 public virtual void Initialize(ManagerResponse <GetCouponsResult, IEnumerable <Coupon> > managerResponse)
 {
     if (managerResponse?.Result != null)
     {
         Coupons = managerResponse.Result.Where(c => !c.IsApplied).ToList();
     }
 }
        public IActionResult Index()
        {
            manager.Login();
            ManagerResponse          response  = manager.SendAction(new GetConfigAction("manager.conf"));
            List <GetConfigResponse> getConfig = new List <GetConfigResponse>();

            if (response.IsSuccess())
            {
                GetConfigResponse responseConfig = (GetConfigResponse)response;
                getConfig.Add(responseConfig);
                return(View(getConfig));
            }
            else
            {
                Console.WriteLine("");
                return(View());
            }

            //{
            //    Console.WriteLine("\nUpdateConfig action");
            //    UpdateConfigAction config = new UpdateConfigAction("manager.conf", "manager.conf");
            //    config.AddCommand(UpdateConfigAction.ACTION_NEWCAT, "testadmin");
            //    config.AddCommand(UpdateConfigAction.ACTION_APPEND, "testadmin", "secret", "blabla");
            //    ManagerResponse Newresponse = manager.SendAction(config);
            //    Console.WriteLine(Newresponse);
            //}
        }
        public async Task <ManagerResponse <ContactDetail> > Delete(Guid uid)
        {
            _logger.LogInformation("Delete: Begin");

            var result = new ManagerResponse <ContactDetail>
            {
                ResultStatus = Common.Enums.ManagerResponseResult.Success,
                Result       = new List <ContactDetail>()
            };

            var dao = await _unitOfWork.Query <Data.Dao.ContactDetail>()
                      .Where(o => o.Contact.Uid == ContactUid)
                      .FirstOrDefaultAsync(o => o.Uid == uid);

            if (dao == null)
            {
                _logger.LogWarning("Delete: End (NotFound)");
                result.ResultStatus = Common.Enums.ManagerResponseResult.NotFound;
                return(result);
            }

            _unitOfWork.SoftDelete(dao);

            await _unitOfWork.SaveChangesAsync();

            // TODO

            _logger.LogInformation("Delete: End");
            result.ResultStatus = Common.Enums.ManagerResponseResult.Success;
            return(result);
        }
        public Result <CommerceUserModel> UpdateAccountInfo(CommerceUserModel user)
        {
            Assert.ArgumentNotNull(user, nameof(user));

            var result = new Result <CommerceUserModel>();

            ManagerResponse <GetUserResult, CommerceUser> getUserResponse =
                this.accountManager.GetUser(user.ContactId);

            if (!getUserResponse.ServiceProviderResult.Success || getUserResponse.Result == null)
            {
                result.SetErrors(getUserResponse.ServiceProviderResult);
                return(result);
            }

            CommerceUser userForUpdate = getUserResponse.Result;

            userForUpdate.FirstName = user.FirstName;
            userForUpdate.LastName  = user.LastName;

            ManagerResponse <UpdateUserResult, CommerceUser> userUpdateResponse =
                this.accountManager.UpdateUser(userForUpdate);

            if (!userUpdateResponse.ServiceProviderResult.Success || userUpdateResponse.Result == null)
            {
                result.SetErrors(userUpdateResponse.ServiceProviderResult);
                return(result);
            }

            result.SetResult(this.entityMapper.MapToCommerceUserModel(userUpdateResponse.Result));
            return(result);
        }
        public async Task <ManagerResponse <ContactDetail> > GetByUid(Guid uid)
        {
            _logger.LogInformation("GetByUid: Begin");

            var result = new ManagerResponse <ContactDetail>
            {
                ResultStatus = Common.Enums.ManagerResponseResult.Success,
                Result       = new List <ContactDetail>()
            };

            var dao = await _unitOfWork.Query <Data.Dao.ContactDetail>()
                      .Where(o => o.Contact.Uid == ContactUid)
                      .AsNoTracking()
                      .FirstOrDefaultAsync(o => o.Uid == uid);

            if (dao == null)
            {
                _logger.LogWarning("GetByUid: End (NotFound)");
                result.ResultStatus = Common.Enums.ManagerResponseResult.NotFound;
                return(result);
            }

            var model = _mapper.Map <ContactDetail>(dao);

            //model.ContactUid = ContactUid;
            result.Result.Add(model);

            _logger.LogInformation("GetByUid: End");
            return(result);
        }
        public WishListJsonResult GetWishList(IStorefrontContext storefrontContext, IVisitorContext visitorContext)
        {
            Assert.ArgumentNotNull((object)storefrontContext, nameof(storefrontContext));
            Assert.ArgumentNotNull((object)visitorContext, nameof(visitorContext));
            WishListJsonResult model             = this.ModelProvider.GetModel <WishListJsonResult>();
            CommerceStorefront currentStorefront = storefrontContext.CurrentStorefront;
            ManagerResponse <GetWishListResult, WishList> currentWishList = this.WishListManager.GetWishList(visitorContext, storefrontContext);

            if (!currentWishList.ServiceProviderResult.Success || currentWishList.Result == null)
            {
                string systemMessage = "Wish List not found.";
                currentWishList.ServiceProviderResult.SystemMessages.Add(new SystemMessage()
                {
                    Message = systemMessage
                });
                model.SetErrors((ServiceProviderResult)currentWishList.ServiceProviderResult);
                return(model);
            }

            if (!currentWishList.ServiceProviderResult.Success)
            {
                model.SetErrors((ServiceProviderResult)currentWishList.ServiceProviderResult);
                return(model);
            }
            model.Initialize(currentWishList.Result);
            model.Success = true;
            return(model);
        }
Example #13
0
        public JsonResult RegistrationCustom(RegistrationUserInputModelCustom inputModel)
        {
            try
            {
                Assert.ArgumentNotNull(inputModel, "RegistrationUserInputModel");
                RegistrationBaseJsonResult registrationBaseJsonResult = new RegistrationBaseJsonResult(StorefrontContext, SitecoreContext);
                ValidateModel(registrationBaseJsonResult);
                if (registrationBaseJsonResult.HasErrors)
                {
                    return(Json(registrationBaseJsonResult, JsonRequestBehavior.AllowGet));
                }

                ManagerResponse <CreateUserResult, CommerceUser> managerResponse = CustomAccountManager.RegisterUserCustomer(StorefrontContext, UpdateUserName(inputModel.UserName), inputModel.Password, inputModel.UserName, inputModel.SecondaryEmail);
                if (managerResponse.ServiceProviderResult.Success && managerResponse.Result != null)
                {
                    registrationBaseJsonResult.Initialize(managerResponse.Result);
                    AccountManager.Login(StorefrontContext, VisitorContext, managerResponse.Result.UserName, inputModel.Password, false);
                }
                else
                {
                    registrationBaseJsonResult.SetErrors(managerResponse.ServiceProviderResult);
                }
                return(Json(registrationBaseJsonResult));
            }
            catch (Exception ex)
            {
                return(Json(new BaseJsonResult(nameof(Registration), ex, StorefrontContext, SitecoreContext), JsonRequestBehavior.AllowGet));
            }
        }
Example #14
0
        public virtual Result <CartModel> GetOrderDetails(string trackingId)
        {
            Assert.ArgumentNotNullOrEmpty(trackingId, nameof(trackingId));

            var result = new Result <CartModel>();

            try
            {
                ManagerResponse <GetVisitorOrderResult, Order> orderDetails = this.orderManager.GetOrderDetails(trackingId, this.VisitorContext.ContactId, this.StorefrontContext.ShopName);

                var order = orderDetails.Result;
                if (order != null)
                {
                    CartModel orderModel = this.orderModelBuilder.Initialize(order);
                    result.SetResult(orderModel);
                    return(result);
                }

                result.SetErrors(orderDetails.ServiceProviderResult);
                return(result);
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message, ex, this);
                result.SetErrors(nameof(this.GetOrderDetails), ex);
            }

            return(result);
        }
Example #15
0
        public JsonResult ExtendedRegistration(RegistrationInputModel inputModel)
        {
            JsonResult result;

            try
            {
                Assert.ArgumentNotNull(inputModel, "RegistrationInputModel");
                RegistrationBaseJsonResult registrationBaseJsonResult = new RegistrationBaseJsonResult(StorefrontContext, SitecoreContext);
                ValidateModel(registrationBaseJsonResult);
                if (registrationBaseJsonResult.HasErrors)
                {
                    result = Json(registrationBaseJsonResult, JsonRequestBehavior.AllowGet);
                }
                else
                {
                    ManagerResponse <CreateUserResult, CommerceUser> managerResponse = AccountManager.RegisterUser(StorefrontContext, UpdateUserName(inputModel.UserName), inputModel.Password, inputModel.UserName);
                    if (managerResponse.ServiceProviderResult.Success && managerResponse.Result != null)
                    {
                        registrationBaseJsonResult.Initialize(managerResponse.Result);
                        AccountManager.Login(StorefrontContext, VisitorContext, managerResponse.Result.UserName, inputModel.Password, false);
                        AccountManager.UpdateUser(VisitorContext, inputModel.FirstName, inputModel.LastName, string.Empty, inputModel.UserName);
                    }
                    else
                    {
                        registrationBaseJsonResult.SetErrors(managerResponse.ServiceProviderResult);
                    }
                    result = Json(registrationBaseJsonResult);
                }
            }
            catch (Exception exception)
            {
                result = Json(new BaseJsonResult("Registration", exception, StorefrontContext, SitecoreContext), JsonRequestBehavior.AllowGet);
            }
            return(result);
        }
        public async Task <ManagerResponse <Model.ViewModels.ContactWithDetailsViewModel> > GetByUid(Guid uid)
        {
            _logger.LogInformation("GetByUid: Begin");

            var result = new ManagerResponse <Model.ViewModels.ContactWithDetailsViewModel>
            {
                ResultStatus = Common.Enums.ManagerResponseResult.Success,
                Result       = new List <Model.ViewModels.ContactWithDetailsViewModel>()
            };

            var dao = await BaseQuery(uid)
                      .FirstOrDefaultAsync();

            if (dao == null)
            {
                _logger.LogWarning("GetByUid: End (NotFound)");
                result.ResultStatus = Common.Enums.ManagerResponseResult.NotFound;
                return(result);
            }

            var model = _mapper.Map <Model.ViewModels.ContactWithDetailsViewModel>(dao);

            result.Result.Add(model);

            _logger.LogInformation("GetByUid: End");
            return(result);
        }
        public async Task <ManagerResponse <Model.ViewModels.ContactWithDetailsViewModel> > Get(int pageNumber, int pageSize)
        {
            _logger.LogInformation("Get: Begin");

            var totalCount = await BaseQuery().LongCountAsync();

            var skip = (pageNumber - 1) * pageSize;
            var daos = await BaseQuery()
                       .Skip(skip)
                       .Take(pageSize)
                       .ToListAsync();

            var result = new ManagerResponse <Model.ViewModels.ContactWithDetailsViewModel>
            {
                ResultStatus = Common.Enums.ManagerResponseResult.Success,
                Result       = new List <Model.ViewModels.ContactWithDetailsViewModel>(),
                PageMeta     = new PagingMetadata
                {
                    PageNumber = pageNumber,
                    PageSize   = pageSize,
                    Total      = totalCount
                }
            };

            var models = _mapper.Map <List <Model.ViewModels.ContactWithDetailsViewModel> >(daos);

            result.Result.AddRange(models);

            _logger.LogInformation("Get: End");
            return(result);
        }
Example #18
0
 /// <summary>
 /// Continue the workflow of an order.
 /// </summary>
 /// <param name="managerResponse">The managers response to an order.</param>
 /// <returns></returns>
 public static Order RunApproveOrder(ManagerResponse managerResponse)
 {
     using (var client = new OrderProductServiceReference.ServiceClient())
     {
         return(client.ApproveOrder(managerResponse));
     }
 }
Example #19
0
        //-------------------------------------------------------------------------------------------------------------

        void TransferCall(string DialedNumber)
        {
            if (RINGENABLED != false)
            {
                // Now send Redirect action
                RedirectAction ra = new RedirectAction();
                ra.Channel = AsteriskPhoneAgentForm.CHANNEL_REMOTE;
                //ra.ExtraChannel = AsteriskPhoneAgentForm.;
                ra.Context  = ORIGINATE_CONTEXT;
                ra.Exten    = DialedNumber;
                ra.Priority = 1;
                try
                {
                    ManagerResponse mr = manager.SendAction(ra, 10000);
                    Log("Transfer Call"
                        + "\n\tResponse:" + mr.Response
                        + "\n\tMessage:" + mr.Message
                        );
                }
                catch (Exception ex)
                {
                    Log(ex.Message);
                }
            }
        }
Example #20
0
        public bool AgentLogoff(string agent)
        {
            AgentLogoffAction ala = new AgentLogoffAction(agent);
            ManagerResponse   mr  = (ManagerResponse)_manager.SendAction(ala, 10000);

            return(mr.IsSuccess());
        }
Example #21
0
        public virtual WishListJsonResult RemoveWishListLines(IStorefrontContext storefrontContext, IVisitorContext visitorContext, List <string> wishListLineIds)
        {
            Assert.ArgumentNotNull(storefrontContext, nameof(storefrontContext));
            Assert.ArgumentNotNull(visitorContext, nameof(visitorContext));
            Assert.ArgumentNotNull(wishListLineIds, nameof(wishListLineIds));
            WishListJsonResult model             = _modelProvider.GetModel <WishListJsonResult>();
            CommerceStorefront currentStorefront = storefrontContext.CurrentStorefront;
            ManagerResponse <GetWishListResult, WishList> currentWishList = _wishListManager.GetWishList(visitorContext, storefrontContext);

            if (!currentWishList.ServiceProviderResult.Success || currentWishList.Result == null)
            {
                string systemMessage = "Wish List not found.";
                currentWishList.ServiceProviderResult.SystemMessages.Add(new SystemMessage
                {
                    Message = systemMessage
                });

                model.SetErrors(currentWishList.ServiceProviderResult);
                return(model);
            }
            ManagerResponse <RemoveWishListLinesResult, WishList> managerResponse = _wishListManager.RemoveWishListLines(currentStorefront, visitorContext, currentWishList.Result, wishListLineIds);

            if (!managerResponse.ServiceProviderResult.Success)
            {
                model.SetErrors(managerResponse.ServiceProviderResult);
                return(model);
            }
            model.Initialize(managerResponse.Result);
            model.Success = true;
            return(model);
        }
Example #22
0
        public ShoppingCartJsonResult GetCurrentShoppingCart(IStorefrontContext storefrontContext, IVisitorContext visitorContext)
        {
            ShoppingCartJsonResult model = this.ModelProvider.GetModel <ShoppingCartJsonResult>();

            try
            {
                ManagerResponse <CartResult, Sitecore.Commerce.Entities.Carts.Cart> currentCart = this.CartManager.GetCurrentCart(visitorContext, storefrontContext, true);
                if (!currentCart.ServiceProviderResult.Success || currentCart.Result == null)
                {
                    model.Success = false;
                    string systemMessage = storefrontContext.GetSystemMessage("Cart Not Found Error", true);
                    currentCart.ServiceProviderResult.SystemMessages.Add(new SystemMessage()
                    {
                        Message = systemMessage
                    });
                    model.SetErrors((ServiceProviderResult)currentCart.ServiceProviderResult);
                }

                ShoppingCartLinesManager cartManager = new ShoppingCartLinesManager(this.StorefrontContext, this.SearchManager);
                string shopName = storefrontContext.CurrentStorefront.ShopName;
                string cartId   = $"Default{visitorContext.UserId}" + shopName;

                dynamic cartLineList = cartManager.GetCurrentCartLines(cartId);

                model.Initialize(currentCart.Result, cartLineList);
            }
            catch (Exception ex)
            {
                model.SetErrors(nameof(GetCurrentCart), ex);
            }
            return(model);
        }
Example #23
0
        public void CallStart(string originate_channel, string originate_callerid, string originate_exten)
        {
            if (!manager.IsConnected())
            {
                throw new AsteriskNotConnectedException("Asterisk not connected. Contact with administrator");
            }

            try
            {
                OriginateResponseEvent a = new OriginateResponseEvent(manager);
                Console.WriteLine(a.Exten);

                OriginateAction oc = new OriginateAction();
                oc.Context  = options.OriginateContext;
                oc.Priority = "1";
                oc.Channel  = originate_channel;
                oc.CallerId = originate_callerid;
                oc.Exten    = originate_exten;
                oc.Timeout  = options.OriginateTimeout;
                oc.Async    = true;
                oc.ActionCompleteEventClass();
                // oc.Variable = "VAR1=abc|VAR2=def";
                //oc.SetVariable("VAR3", "ghi");
                ManagerResponse originateResponse = manager.SendAction(oc, oc.Timeout);
                Console.WriteLine(originateResponse);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Example #24
0
        public virtual Result <SubmitOrderModel> SubmitOrder()
        {
            var result = new Result <SubmitOrderModel>();
            var model  = new SubmitOrderModel();

            try
            {
                ManagerResponse <CartResult, Sitecore.Commerce.Entities.Carts.Cart> currentCart = this.CartManager.GetCurrentCart(this.StorefrontContext.ShopName, this.VisitorContext.ContactId);
                if (!currentCart.ServiceProviderResult.Success)
                {
                    result.SetErrors(currentCart.ServiceProviderResult);
                    return(result);
                }

                ManagerResponse <SubmitVisitorOrderResult, Order> managerResponse = this.OrderManager.SubmitVisitorOrder(currentCart.Result);
                if (managerResponse.ServiceProviderResult.Success || !managerResponse.ServiceProviderResult.SystemMessages.Any())
                {
                    model.Temp           = managerResponse.Result;
                    model.ConfirmationId = managerResponse.Result.TrackingNumber;
                    result.SetResult(model);

                    return(result);
                }

                result.SetErrors(managerResponse.ServiceProviderResult);
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message, ex, this);
                result.SetErrors(nameof(this.SubmitOrder), ex);
            }

            return(result);
        }
        public async Task <ManagerResponse <ContactDetail> > Create(ContactDetail model)
        {
            _logger.LogInformation("Create: Begin");

            var result = new ManagerResponse <ContactDetail>
            {
                ResultStatus = Common.Enums.ManagerResponseResult.Success,
                Result       = new List <ContactDetail>()
            };

            var dao = _mapper.Map <ContactDetail, Data.Dao.ContactDetail>(model);

            var parentId = await TryGetParentId(ContactUid);

            if (parentId == null)
            {
                _logger.LogWarning("Create: End (Invalid ContactUid)");
                result.ResultStatus = Common.Enums.ManagerResponseResult.ForeignKeyViolation;
                return(result);
            }
            dao.ContactId = parentId.Value;

            _unitOfWork.Add(dao);
            try
            {
                await _unitOfWork.SaveChangesAsync();
            }
            catch (DbUpdateException ex)
            {
                _logger.LogError("Create: DbUpdateException", ex);

                var dbErrorType = _dbExceptionHelper.HandleUpdateException(ex);
                switch (dbErrorType)
                {
                case Common.Enums.DbUpdateExceptionType.ForeignKeyConstraintViolation:
                    result.ResultStatus = Common.Enums.ManagerResponseResult.ForeignKeyViolation;
                    result.ErrorMessage = "Foreign key constraint violation";
                    return(result);

                case Common.Enums.DbUpdateExceptionType.UniqueKeyConstraintViolation:
                    result.ResultStatus = Common.Enums.ManagerResponseResult.UniqueKeyViolation;
                    result.ErrorMessage = "Unique key constraint violation";
                    return(result);

                default:
                    result.ResultStatus = Common.Enums.ManagerResponseResult.UnknownError;
                    result.ErrorMessage = "Unknown database error";
                    return(result);
                }
            }

            var createdModel = _mapper.Map <Data.Dao.ContactDetail, ContactDetail>(dao);

            //createdModel.ContactUid = contactUid;
            result.Result.Add(createdModel);

            _logger.LogInformation("Create: End");
            return(result);
        }
Example #26
0
 /// <summary>
 ///     This method is called when a response is received.
 /// </summary>
 /// <param name="response">the response received</param>
 public virtual void HandleResponse(ManagerResponse response)
 {
     this.response = response;
     if (autoEvent != null)
     {
         this.autoEvent.Set();
     }
 }
Example #27
0
        public CommerceUserModel GetCommerceUser(string contactIdOrName)
        {
            Assert.ArgumentNotNullOrEmpty(contactIdOrName, nameof(contactIdOrName));

            ManagerResponse <GetUserResult, CommerceUser> commerceUser =
                this.accountManager.GetUser(contactIdOrName);

            return(this.MapToCommerceUserModel(commerceUser.Result, contactIdOrName));
        }
Example #28
0
        public IActionResult DeleteUser(string idUser)
        {
            UpdateConfigAction config = new UpdateConfigAction("sip.conf", "sip.conf", true);

            config.AddCommand(UpdateConfigAction.ACTION_DELCAT, idUser);
            ManagerResponse response = manager.SendAction(config);

            return(RedirectToAction("Index"));
        }
Example #29
0
        static void Main(string[] args)
        {
            manager = new ManagerConnection(ASTERISK_HOST, ASTERISK_PORT, ASTERISK_LOGINNAME, ASTERISK_LOGINPWD);

            manager.PingInterval = 0;
            // +++
            try
            {
                manager.Login();                        // Login only (fast)

                Console.WriteLine("Asterisk version : " + manager.Version);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                Console.ReadLine();
                manager.Logoff();
                return;
            }

            if (args.Count() == 4)
            {
                string originateChannel  = args[0];
                string originateCallerId = args[1];
                string originateExten    = args[2];
                string originateContext  = args[3];
                //string originateChannel = "SIP/billy";
                //string originateCallerId = "<1001>";
                //string originateExten = "1002";
                //string originateContext = "phones";

                OriginateAction oc = new OriginateAction();

                //oc.Channel = originateChannel;
                //oc.CallerId = originateCallerId;
                //oc.Context = originateContext;
                //oc.Exten = originateExten;
                //oc.Priority = 2;
                //oc.Timeout = 15000;

                oc.Channel     = originateChannel;
                oc.CallerId    = originateCallerId;
                oc.Application = "Dial";
                oc.Data        = "Local/" + originateExten + "@" + originateContext;
                oc.Timeout     = 15000;

                try
                {
                    ManagerResponse originateResponse = manager.SendAction(oc, oc.Timeout);
                }
                catch (Exception e)
                {
                    Console.WriteLine("error: {0}", e.Message);
                }
            }
            manager.Logoff();
        }
Example #30
0
        public bool AgentLogin(string agent, string dn)
        {
            AgentCallbackLoginAction acla = new AgentCallbackLoginAction(agent, dn);

            acla.AckCall = false;
            ManagerResponse mr = (ManagerResponse)_manager.SendAction(acla, 10000);

            return(mr.IsSuccess());
        }
Example #31
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BusinessResponse"/> class.
 /// </summary>
 /// <param name="managerResponse">The manager response.</param>
 public BusinessResponse(ManagerResponse managerResponse)
 {
     _managerResponse = managerResponse;
 }
Example #32
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BusinessResponse"/> class.
 /// </summary>
 /// <param name="managerResponse">The manager response.</param>
 /// <param name="errorMessage">The error message.</param>
 public BusinessResponse(ManagerResponse managerResponse, string errorMessage)
 {
     _managerResponse = managerResponse;
     _errorMessage = errorMessage;
 }
        /// <summary>
        /// Sets the payment methods.
        /// </summary>
        /// <param name="storefront">The storefront.</param>
        /// <param name="visitorContext">The visitor context.</param>
        /// <param name="inputModel">The input model.</param>
        /// <returns>The manager response with a cart in the result.</returns>
        public virtual ManagerResponse<CartResult, CommerceCart> SetPaymentMethods([NotNull] CommerceStorefront storefront, [NotNull] VisitorContext visitorContext, [NotNull] PaymentInputModel inputModel)
        {
            Assert.ArgumentNotNull(storefront, "storefront");
            Assert.ArgumentNotNull(visitorContext, "visitorContext");
            Assert.ArgumentNotNull(inputModel, "inputModel");

            var addPaymentResponse = new ManagerResponse<CartResult, CommerceCart>(new AddPaymentInfoResult { Success = true }, null);
            var errorResponse = new AddPaymentInfoResult { Success = false };
            var response = this.GetCurrentCart(storefront, visitorContext, true);
            if (!response.ServiceProviderResult.Success || response.Result == null)
            {
                return new ManagerResponse<CartResult, CommerceCart>(errorResponse, response.Result);
            }

            var cart = (CommerceCart)response.ServiceProviderResult.Cart;
            if (inputModel.CreditCardPayment != null && !string.IsNullOrEmpty(inputModel.CreditCardPayment.PaymentMethodID) && inputModel.BillingAddress != null)
            {
                var removeBillingResponse = this.RemoveAllBillingParties(storefront, visitorContext, cart);
                if (!removeBillingResponse.ServiceProviderResult.Success)
                {
                    errorResponse.SystemMessages.Add(removeBillingResponse.ServiceProviderResult.SystemMessages[0]);
                    return new ManagerResponse<CartResult, CommerceCart>(errorResponse, errorResponse.Cart as CommerceCart);
                }

                cart = removeBillingResponse.Result;

                CommerceParty billingParty = inputModel.BillingAddress.ToNewBillingParty();

                var addPartyResponse = this.AddPartyToCart(storefront, visitorContext, cart, billingParty);
                if (!addPartyResponse.ServiceProviderResult.Success)
                {
                    errorResponse.SystemMessages.Add(addPartyResponse.ServiceProviderResult.SystemMessages[0]);
                    return new ManagerResponse<CartResult, CommerceCart>(errorResponse, errorResponse.Cart as CommerceCart);
                }

                cart = addPartyResponse.Result;

                var removePaymentResponse = this.RemoveAllPaymentMethods(storefront, visitorContext, cart);
                if (!removePaymentResponse.ServiceProviderResult.Success)
                {
                    errorResponse.SystemMessages.Add(removePaymentResponse.ServiceProviderResult.SystemMessages[0]);
                    return new ManagerResponse<CartResult, CommerceCart>(errorResponse, errorResponse.Cart as CommerceCart);
                }

                cart = removePaymentResponse.Result;

                CommerceCreditCardPaymentInfo creditCardPayment = inputModel.CreditCardPayment.ToCreditCardPaymentInfo();

                addPaymentResponse = this.AddPaymentInfoToCart(storefront, visitorContext, cart, creditCardPayment, billingParty, true);
                if (!addPaymentResponse.ServiceProviderResult.Success)
                {
                    errorResponse.SystemMessages.Add(addPaymentResponse.ServiceProviderResult.SystemMessages[0]);
                    return new ManagerResponse<CartResult, CommerceCart>(errorResponse, errorResponse.Cart as CommerceCart);
                }

                cart = addPaymentResponse.Result;
            }

            return addPaymentResponse;
        }
Example #34
0
 protected void AssertErrorMessage(BusinessResponse response, ManagerResponse expectedResponse)
 {
     Assert.IsNotNull(response);
     Assert.AreEqual(expectedResponse, response.ManagerResponse);
     Assert.IsNotNull(response.ErrorMessage);
     Assert.Greater(response.ErrorMessage.Length, 0);
 }