protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         this.Flow = this.GetFromContext <RequestFlow>("Flow");
     }
 }
 protected void RegisterSampleRequestFlow()
 {
     if (this.flow == null)
     {
         this.flow = new RequestFlow();
     }
     HttpContext.Current.Items["Flow"] = this.flow;
 }
 protected void Button1_Click(object sender, EventArgs e)
 {
     try
     {
         RequestFlow f = new RequestFlow();
         //f.CreateWorkflowInstance(Guid.NewGuid(), "7", this.CurrentUserCode, null,null,null, "شماره درخواست: 7, مشتري: عليمي", "",0);
     }
     catch (Exception ex)
     {
         ShowException(ex);
     }
 }
Exemple #4
0
        public HttpResponseMessage Get(string cardData)
        {
            CardInput     cartInput     = JsonConvert.DeserializeObject <CardInput>(cardData);
            PayPalRequest payPalRequest = new PayPalRequest(cartInput);

            try
            {
                RequestFlow flow = payPalRequest.GetFlow();
                return(Request.CreateResponse(HttpStatusCode.OK, flow));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, "Fail"));
            }
        }
        public void Index()
        {
            flow = new RequestFlow();
            try
            {
                var apiContext = Utility.Configuration.GetAPIContext();

                string token = Request.Params["token"];
                if (string.IsNullOrEmpty(token))
                {
                    var returnUrl = this.CreateBillingAgreement(apiContext);
                    Response.Redirect(returnUrl);
                }
                else
                {
                    //this.ExecuteBillingAgreement(apiContext, token);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public async Task <ResponseFlow> PostAsync([FromBody] RequestFlow data)
 {
     return(await _flowExec.ExecuteFlowAsync(data));
 }
Exemple #7
0
        public async Task<ResponseFlow> ExecuteFlowAsync(RequestFlow data)
        {
            FlowsExec flowExec;
            ResponseFlow responseFlow = new ResponseFlow();
            Flow paramFlow = _flowsParams.GetFlow(data.Flow);

            if (data.Id > 0)
            {
                flowExec = await _context.FlowsExecs
                    .Where(a => a.Id == data.Id)
                    .Include(a => a.FieldsByFlowExecs)
                    .ThenInclude(a => a.IdFieldNavigation)
                    .FirstOrDefaultAsync();

                if (flowExec.Sequence == paramFlow.Sequences)
                {
                    throw new Exception("Ya no tiene más pasos para ejecutar");
                }

                flowExec.FieldsByFlowExecs.ToList().ForEach(a =>
                {
                    if (!data.Fields.ContainsKey(a.IdFieldNavigation.Code))
                    {
                        data.Fields.Add(a.IdFieldNavigation.Code, a.Value);
                    }
                });
            }
            else
            {
                flowExec = _context.FlowsExecs.Add(new FlowsExec
                {
                    IdFlow = paramFlow.Id,
                    Sequence = 0
                }).Entity;
                await _context.SaveChangesAsync();
            }

            flowExec.Sequence += 1;


            List<StepsByFlow> steps = paramFlow.StepsByFlows.Where(a => a.Sequence == flowExec.Sequence).ToList();
            List<Task<Dictionary<int, (string, string)>>> tasks = new List<Task<Dictionary<int, (string, string)>>>();
            Dictionary<int, (string, string)> keyValues = new Dictionary<int, (string, string)>();
            steps.ForEach(a => tasks.Add(ExecuteStepAsync(a.IdStepNavigation, data.Fields)));
            try
            {
                await Task.WhenAll(tasks);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            tasks.ForEach(a => keyValues = keyValues.Concat(a.Result).GroupBy(a => a.Key).ToDictionary(a => a.Key, a=> a.First().Value));
            responseFlow.Fields = new Dictionary<string, string>();

            foreach (var item in keyValues)
            {
                FieldsByFlowExec fieldByFlow = _context.FieldsByFlowExecs.Where(a => a.IdFlowExec == flowExec.Id && a.IdField == item.Key).FirstOrDefault();

                if (fieldByFlow == null)
                {
                    fieldByFlow = new FieldsByFlowExec
                    {
                        IdField = item.Key,
                        IdFlowExec = flowExec.Id,
                        Value = item.Value.Item2
                    };
                    _context.FieldsByFlowExecs.Add(fieldByFlow);
                }
                else
                {
                    fieldByFlow.Value = item.Value.Item2;
                }
                responseFlow.Fields.Add(item.Value.Item1, item.Value.Item2);
            }
            await _context.SaveChangesAsync();

            responseFlow.Id = flowExec.Id;

            return responseFlow;
        }