예제 #1
0
        public KeyValuePair <bool, Guid> InsertGuest(EnterpriseNode.DataStructure.EnterpriseNode enterpriseNode,
                                                     List <Guid> boothIdlist, HttpPostedFileBase file, List <DiscountType> discountAttaches,
                                                     string callBackurl, FormGenerator.DataStructure.FormStructure postFormData, Guid congressId)
        {
            var keyValuePairs = new ModelView.InFormEntitiyList <UserBooth>();
            var guid          = Guid.Empty;
            var userBoothBo   = new UserBoothBO();

            try
            {
                this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
                this.PaymentConnection.StartTransaction(IsolationLevel.ReadUncommitted);
                this.FormGeneratorConnection.StartTransaction(IsolationLevel.ReadUncommitted);
                this.EnterpriseNodeConnection.StartTransaction(IsolationLevel.ReadUncommitted);
                var additionalData = new CongressDiscountTypeBO().FillTempAdditionalData(this.ConnectionHandler, congressId);
                if (
                    !EnterpriseNodeComponent.Instance.EnterpriseNodeTransactionalFacade(this.EnterpriseNodeConnection)
                    .Insert(enterpriseNode, file))
                {
                    return(new KeyValuePair <bool, Guid>(false, Guid.Empty));
                }
                postFormData.RefId = enterpriseNode.Id.ToString();
                if (
                    !FormGeneratorComponent.Instance.FormDataTransactionalFacade(this.FormGeneratorConnection)
                    .ModifyFormData(postFormData))
                {
                    throw new Exception(Resources.Congress.ErrorInSaveBoothReserv);
                }
                var boothBo = new BoothBO();
                var amount  = boothBo.Sum(ConnectionHandler, x => x.ValidCost, x => x.Id.In(boothIdlist));

                if (amount.ToDecimal() > 0)
                {
                    var firstOrDefault = boothIdlist.FirstOrDefault();
                    var booth          = boothBo.Get(this.ConnectionHandler, firstOrDefault);
                    var temp           = new Temp
                    {
                        PayerId     = enterpriseNode.Id,
                        CallBackUrl = callBackurl + enterpriseNode.Id,
                        PayerTitle  = enterpriseNode.DescriptionField,
                        Description = Resources.Congress.PaymentBoothReserv,
                        Amount      =
                            new CongressDiscountTypeBO().CalulateAmountNew(this.PaymentConnection, amount.ToDecimal(),
                                                                           discountAttaches),
                        CurrencyType   = (byte)booth.CurrencyType.ToEnum <Radyn.Common.Definition.Enums.CurrencyType>(),
                        AdditionalData = additionalData
                    };

                    if (
                        !PaymentComponenets.Instance.TempTransactionalFacade(this.PaymentConnection)
                        .Insert(temp, discountAttaches))
                    {
                        return(new KeyValuePair <bool, Guid>(false, Guid.Empty));
                    }
                    guid = temp.Id;
                }
                foreach (var guid1 in boothIdlist)
                {
                    var userBooth = new UserBooth()
                    {
                        UserId  = enterpriseNode.Id,
                        BoothId = guid1,
                        TempId  = guid != Guid.Empty ? guid : (Guid?)null,
                    };
                    if (!userBoothBo.Insert(this.ConnectionHandler, userBooth))
                    {
                        throw new Exception(Resources.Congress.ErrorInSaveBoothReserv);
                    }
                    keyValuePairs.Add(userBooth,
                                      Resources.Congress.BoothInsertEmail, Resources.Congress.BoothInsertSMS);
                }

                this.ConnectionHandler.CommitTransaction();
                this.PaymentConnection.CommitTransaction();
                this.FormGeneratorConnection.CommitTransaction();
                this.EnterpriseNodeConnection.CommitTransaction();
            }
            catch (KnownException ex)
            {
                this.ConnectionHandler.RollBack();
                this.PaymentConnection.RollBack();
                this.FormGeneratorConnection.RollBack();
                this.EnterpriseNodeConnection.RollBack();
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
            catch (Exception ex)
            {
                this.ConnectionHandler.RollBack();
                this.PaymentConnection.RollBack();
                this.FormGeneratorConnection.RollBack();
                this.EnterpriseNodeConnection.RollBack();
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
            try
            {
                userBoothBo.InformUserboothReserv(this.ConnectionHandler, congressId, keyValuePairs);
            }
            catch (Exception)
            {
            }
            return(new KeyValuePair <bool, Guid>(true, guid));
        }