Beispiel #1
0
 public override int Visit(PassState passState)
 {
     _currentContext.AssertIsValidInputPath(passState.InputPath);
     _currentContext.AssertIsValidOutputPath(passState.OutputPath);
     _currentContext.AssertIsValidResultPath(passState.ResultPath);
     ValidateTransition(passState.Transition);
     return(0);
 }
        public void Execute(ProcessInfo process, PassState passInfo)
        {
            Dictionary <int, int> pages = new Dictionary <int, int>();

            pages.Add(1, 0);        // pages =0   hour =0
            pages.Add(6, 8);        // pages <5   hour =8
            pages.Add(21, 16);      // pages <=20 hour =16
            pages.Add(200, 24);     // pages >20  hour =24
            try
            {
                ProcessVariable doc       = process.GetVariableByName("Документ");
                ProcessVariable count     = process.GetVariableByName("Общее кол-во листов");
                ProcessVariable hours     = process.GetVariableByName("Срок исполнения задания");
                DVCard          _doc      = (DVCard)doc.Value;
                CardData        cardData  = process.Session.CardManager.GetCardData(new Guid(_doc.ID));
                RowData         row       = cardData.Sections[cardData.Type.Sections["СвойстваСтруктура"].Id].FirstRow;
                int             countPage = row.GetInt32("КоличествоЛистов").HasValue ? row.GetInt32("КоличествоЛистов").Value : 0;
                int             countApp  = row.GetInt32("ВПриложении").HasValue ? row.GetInt32("ВПриложении").Value : 0;
                count.Value = countPage + countApp;
                hours.Value = pages.Where(s => s.Key > (int)count.Value).Select(s => s.Value).Min();
                //var message=string.Format("Общее кол {0}, срок согласования {1} ч.", count.Value, hours.Value);

                //ListHours
                ProcessVariable listHours = process.GetVariableByName("ListHours");
                process.LogMessage("Кол" + listHours.Values.Count.ToString());
                process.LogMessage(listHours.GetType().Name);

                process.LogMessage("Кол listHours.VarEnumValues.Count" + listHours.VarEnumValues.Count.ToString());
                process.LogMessage("listHours.Values");
                for (int i = 0; i < listHours.Values.Count; i++)
                {
                    var value = listHours.Values[i];
                    process.LogMessage(value.GetType().Name);
                    process.LogMessage(value.Key.ToString());
                    process.LogMessage(value.Value.ToString());
                    //pages.Add((int)value.Key,(int)value.Value);
                }
                process.LogMessage("listHours.VarEnumValues");
                process.LogMessage(listHours.VarEnumValues.Keys.Count.ToString());
                //for (int i = 0; i < listHours.VarEnumValues.Count; i++)
                //{
                //	process.LogMessage(listHours.VarEnumValues[i].GetType().Name );
                //	process.LogMessage(listHours.VarEnumValues[i].NumValue.ToString());
                //	process.LogMessage(listHours.VarEnumValues[i].Value.ToString());
                //}
            }
            catch (Exception ex)
            {
                process.LogMessage("Ошибка выполнения скрипта:" + ex.Message);
            }
            return;
        }
Beispiel #3
0
    private void Start()
    {
        renderComponent = GetComponent <SpriteRenderer>();
        trailComponent  = GetComponent <TrailRenderer>();
        anim            = GetComponent <Animator>();

        menuIdle   = new MenuIdle(this);
        intoScene  = new IntoScene(this);
        gameIdle   = new GameIdle(this);
        sliceState = new SliceState(this, 10, 0.5f);
        passState  = new PassState(this, 1f);
        failState  = new FailState(this, 0.5f);
        actState   = new ActState(this);
        TranslateState(null, menuIdle);
    }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue,
                                        JsonSerializer serializer)
        {
            var obj  = JObject.Load(reader);
            var type = obj["Type"].Value <string>();

            State.IBuilder <State> result = null;

            switch (Enum.Parse(typeof(StateType), type))
            {
            case StateType.Choice:
                result = ChoiceState.GetBuilder();
                break;

            case StateType.Fail:
                result = FailState.GetBuilder();
                break;

            case StateType.Parallel:
                result = ParallelState.GetBuilder();
                break;

            case StateType.Pass:
                result = PassState.GetBuilder();
                break;

            case StateType.Succeed:
                result = SucceedState.GetBuilder();
                break;

            case StateType.Task:
                result = TaskState.GetBuilder();
                break;

            case StateType.Wait:
                result = WaitState.GetBuilder();
                break;

            case StateType.Map:
                result = MapState.GetBuilder();
                break;
            }

            serializer.Populate(obj.CreateReader(), result);

            return(result);
        }
Beispiel #5
0
        public void Execute(ProcessInfo process, PassState passInfo, DocsVision.Platform.ObjectModel.ObjectContext objectContext)
        {
            try
            {
                #region Переменный БП
                ProcessVariable doc    = process.GetVariableByName("Документ");
                DVCard          _doc   = (DVCard)doc.Value;
                Guid            idCard = new Guid(_doc.ID);

                ProcessVariable listEmploeesApproval = process.GetVariableByName("Согласующие лица");
                var             c = listEmploeesApproval.Values.Values;
                #endregion
                Document          document        = objectContext.GetObject <Document>(idCard);
                var               cardKind        = document.SystemInfo.CardKind;
                var               result          = (((BaseCardSectionRow)document.GetSection(new Guid("{B13955FD-3202-44D1-92BD-6B0F6878385F}"))[0])["ВидДокумента"]);
                var               subKindDocument = (((BaseCardSectionRow)document.GetSection(new Guid("{B13955FD-3202-44D1-92BD-6B0F6878385F}"))[0]).GetGuid("ВидДокумента"));
                BaseUniversalItem itemCard        = objectContext.GetObject <BaseUniversalItem>(subKindDocument);
            }
            catch (Exception ex)
            {
                process.LogMessage("Ошибка выполнения скрипта:" + ex.Message);
            }
            return;
        }
Beispiel #6
0
        public object GetStartState()
        {
            var createCollection =
                new AmazonStateTask <IndexAllFacesRequest, AmazonRekognitionClient, CreateCollectionRequest,
                                     CreateCollectionResponse>()
                .SetParameters(i => new CreateCollectionRequest
            {
                CollectionId = i.Collection,
                Tags         = new Dictionary <string, string>
                {
                    { "App", "Test" }
                }
            }
                               );

            var waitState = new WaitState();



            var getCollection =
                new AmazonStateTask <IndexAllFacesRequest, AmazonRekognitionClient, DescribeCollectionRequest,
                                     DescribeCollectionResponse>()
                .SetParameters(i => new DescribeCollectionRequest
            {
                CollectionId = i.Collection
            })
                .AddErrorHandler(typeof(ResourceNotFoundException), new ErrorHandler
            {
                FallbackState = createCollection
            });

            var getObject = new AmazonStateTask <GetObjectRequest, AmazonS3Client, GetObjectRequest, GetObjectResponse>()
                            .SetParameters(i => i)
                            .Catch(typeof(Amazon.DynamoDBv2.Model.ResourceNotFoundException), createCollection)
                            .SetNextState(new SuccessState {
                Name = "Done"
            });

            var getAllObjects = new MapState <ListObjectsV2Response, S3Object, GetObjectRequest>(getObject)
                                .SetIterator(i => i.S3Objects)
                                .SetMapping(i => new GetObjectRequest
            {
                BucketName = i.BucketName,
                Key        = i.Key
            });

            var listObjects =
                new AmazonStateTask <IndexAllFacesRequest, AmazonS3Client, ListObjectsV2Request, ListObjectsV2Response>()
                .SetParameters(i => new ListObjectsV2Request
            {
                BucketName = i.Bucket
            })
                .AddErrorHandler(typeof(AmazonS3Exception), new ErrorHandler())
                .SetNextState(getAllObjects);


            var getItem =
                new AmazonStateTask <IndexAllFacesRequest, AmazonDynamoDBClient, GetItemRequest, GetItemResponse>()
                .SetParameters(i => new GetItemRequest
            {
                TableName = i.TableName,
                Key       = new Dictionary <string, AttributeValue>
                {
                    { "Partition", new AttributeValue(i.Bucket) }
                }
            }).AddErrorHandler(typeof(Amazon.DynamoDBv2.Model.ResourceNotFoundException), new ErrorHandler {
                FallbackState = new FailState()
            });


            var passState = new PassState(getItem)
            {
            };

            var choiceState = new ChoiceSate <IndexAllFacesRequest>(passState)
                              .AddRule(i => i.Bucket.StartsWith("node") ||
                                       i.TableName != "Something", waitState)
                              .AddRule(i => i.Collection == null, getItem);

            var parallelTask = new ParallelState()
                               .AddState(getCollection)
                               .AddState(listObjects)
                               .AddState(getItem)
                               .SetNextState(new SuccessState());

            return(choiceState);

            return(parallelTask);
        }
Beispiel #7
0
    protected override void BaseUpdate()
    {
        base.BaseUpdate();

        Cursor.lockState = CursorLockMode.Locked;

        switch (passState)
        {
        case PassState.None:
            if (Input.GetButtonDown("Pass"))
            {
                //Set the correct hand pose for the situation ('set' only for now)
                anim.SetTrigger("Set");

                //Inverse kinematics
                if (ball)
                {
                    ik.solvers.leftHand.target  = ball.transform;
                    ik.solvers.rightHand.target = ball.transform;
                }

                handIKweight = WEIGHT_HAND_SET;
                bodyIKweight = WEIGHT_BODY_SET;
                headIKweight = 1f;

                passState = PassState.Charging;
            }
            break;

        case PassState.Charging:
            //If you've released button when charging, and press it down again, reset.
            if (Input.GetButtonDown("Pass"))
            {
                handIKweight    = WEIGHT_HAND_SET;
                bodyIKweight    = WEIGHT_BODY_SET;
                headIKweight    = 1f;
                passCancelTimer = 0f;
                anim.SetBool("Cancelled", false);
                anim.SetTrigger("Set");                         //Only set for now
            }

            //Increase power while holding the button
            if (Input.GetButton("Pass"))
            {
                power += Time.deltaTime * maxPower;                         //1 second

                if (power > maxPower)
                {
                    power = maxPower;
                }
            }

            //Actually shoot the ball somewhere:
            if (!Input.GetButton("Pass") &&
                (setterBox.HasBall ||
                 diggerBox.HasBall))
            {
                if (setterBox.HasBall)
                {
                    //Set:
                    //Set IK and trigger release animation
                    handIKweight = 0f;
                    bodyIKweight = 0f;
                    headIKweight = WEIGHT_HEAD_IDLE;
                    anim.SetTrigger("Release");
                }
                else if (diggerBox.HasBall)
                {
                    //Dig:
                    //Set IK and trigger release animation
                }

                passState = PassState.Release;
            }
            else if (!Input.GetButton("Pass"))
            {
                //Cancel the animation if enough time passes with no results, when not holding button
                passCancelTimer += Time.deltaTime;

                if (passCancelTimer > passCancelTime)
                {
                    power           = 0f;
                    handIKweight    = 0f;
                    bodyIKweight    = 0f;
                    headIKweight    = WEIGHT_HEAD_IDLE;
                    passCancelTimer = passCancelTime;

                    anim.SetBool("Cancelled", true);
                }
            }

            break;

        case PassState.Release:

            break;
        }
    }
 public virtual T Visit(PassState passState)
 {
     return(default(T));
 }