Beispiel #1
0
        public async Task <JsonResult> ExecuteBatchStepByObserveId(string ObserveId)
        {
            ObserverDbContext _db = new ObserverDbContext();

            ObservesModel model = _db.Observes
                                  .Where(e => e.Id == ObserveId)
                                  .FirstOrDefault();

            if (model.Users.Id == User.Identity.GetUserId())
            {
                List <StepsModel> listModel = _db.Observes.Where(e => e.Id == ObserveId).FirstOrDefault().List_Steps.Where(e => e.Deleted == false).OrderBy(e => e.Order).ToList();
                List <StepExecutionInputModel> inputList = new List <StepExecutionInputModel>();
                PCMethodsModel pcMethodsModel            = null;

                foreach (StepsModel item in listModel)
                {
                    string PC1      = null;
                    string PC2      = null;
                    int    PCMethod = 0;
                    if (item.PC_Method != null)
                    {
                        pcMethodsModel = PCMethodServiceManager.GetPCMethodById(item.PC_Method.Id);
                        PC1            = pcMethodsModel.PC1;
                        PC2            = pcMethodsModel.PC2;
                        PCMethod       = int.Parse(item.PC_Method.Id);
                    }

                    StepExecutionInputModel input = new StepExecutionInputModel()
                    {
                        Order        = item.Order.GetValueOrDefault(),
                        Uri          = item.Url,
                        Method       = item.Method.GetValueOrDefault(),
                        PC_Method    = PCMethod,
                        PC1          = item.PC1,
                        PC2          = item.PC2,
                        PC2Secret    = item.PC2Secret,
                        CustomHeader = item.PredefinedHeader,
                        UseHeader    = item.SetHeader.GetValueOrDefault(),
                        LabelPC1     = PC1,
                        LabelPC2     = PC2
                    };

                    inputList.Add(input);
                }

                return(Json(await StepServiceManager.ExecuteBatchStepReturningResult(inputList)));
            }
            else
            {
                StepExecutionOutputModel input = new StepExecutionOutputModel()
                {
                    Status = "Unauthorized"
                };

                return(Json(input));
            }
        }
Beispiel #2
0
        public async Task <JsonResult> ExecuteStep(string StepId)
        {
            ObserverDbContext _db = new ObserverDbContext();

            StepsModel stepsModel = _db.Steps
                                    .Where(e => e.Id == StepId)
                                    .FirstOrDefault();

            ObservesModel observesModel = stepsModel.Observes;

            if (observesModel.Users.Id == User.Identity.GetUserId())
            {
                string pcMethodsModelId    = null;
                string LabelPC1            = null;
                string LabelPC2            = null;
                int    pcMethodsModelIdInt = 0;
                if (stepsModel.PC_Method != null)
                {
                    pcMethodsModelId    = stepsModel.PC_Method.Id;
                    LabelPC1            = stepsModel.PC_Method.PC1;
                    LabelPC2            = stepsModel.PC_Method.PC2;
                    pcMethodsModelIdInt = int.Parse(pcMethodsModelId);
                }

                StepExecutionInputModel input = new StepExecutionInputModel()
                {
                    Order            = stepsModel.Order.GetValueOrDefault(),
                    Uri              = stepsModel.Url,
                    Method           = stepsModel.Method.GetValueOrDefault(),
                    PC_Method        = pcMethodsModelIdInt,
                    PC1              = stepsModel.PC1,
                    PC2              = stepsModel.PC2,
                    CustomHeader     = stepsModel.PredefinedHeader,
                    PredefinedHeader = stepsModel.SetHeader.GetValueOrDefault(),
                    LabelPC1         = LabelPC1,
                    LabelPC2         = LabelPC2,
                    PC2Secret        = stepsModel.PC2Secret
                };

                return(Json(await StepServiceManager.ExecuteStepReturningResult(input)));
            }
            else
            {
                StepExecutionOutputModel input = new StepExecutionOutputModel()
                {
                    Status = "Unauthorized"
                };

                return(Json(input));
            }
        }