Пример #1
0
    /// <summary>
    /// 低減開始時間ボタン押下イベントハンドラ
    /// </summary>
    public void OnSuppressionStartTimeButtonTap()
    {
        //ピッカーを表示して低減開始時間を設定させる
        string title        = "振動開始時間設定";
        string unit         = "分";
        float  maxValue     = (float)SuppressionStartTime.Max;
        float  minValue     = (float)SuppressionStartTime.Min;
        float  stepValue    = 1;
        float  currentValue = (float)TempDeviceSetting.SuppressionStartTime;
        var    vs           = new SelectValueDialogParamSet(
            SelectValueDialogParamSet.DISPLAY_TYPE.Numeric,
            title,
            unit,
            maxValue,
            minValue,
            stepValue,
            currentValue);

        SelectValueDialog.Show(vs, (SelectValueDialog.ButtonItem status, float value, GameObject dialog) => {
            if (status == SelectValueDialog.ButtonItem.OK)
            {
                SuppressionStartTime lastStartTime = TempDeviceSetting.SuppressionStartTime;

                //結果をテキストに反映
                suppressionStartTimeText.text = value.ToString("0") + unit;

                //アプリ内保存
                TempDeviceSetting.SuppressionStartTime = (SuppressionStartTime)value;
                if (lastStartTime != TempDeviceSetting.SuppressionStartTime) //Change data, need to send command to device
                {
                    SaveDeviceSetting();
                    StartCoroutine(ChangeDeviceSettingCoroutine());
                }
            }
            else
            {
                //なにもしない
            }
        });
    }
Пример #2
0
        protected override void ProcessRecordInternal()
        {
            ActionRule result = new ActionRule();

            if (ShouldProcess(
                    target: string.Format(Resources.TargetWithRG, this.Name, this.ResourceGroupName),
                    action: Resources.CreateOrUpdateActionRule_Action))
            {
                switch (ParameterSetName)
                {
                case BySimplifiedFormatActionGroupActionRuleParameterSet:
                    if (ActionRuleType != "ActionGroup")
                    {
                        throw new PSInvalidOperationException(string.Format(Resources.IncorrectActionRuleType_Exception, "ActionGroup"));
                    }

                    // Create Action Rule
                    ActionRule actionGroupAR = new ActionRule(
                        location: "Global",
                        tags: new Dictionary <string, string>(),
                        properties: new ActionGroup(
                            scope: ParseScope(),
                            conditions: ParseConditions(),
                            actionGroupId: ActionGroupId,
                            description: Description,
                            status: Status
                            )
                        );

                    result = this.AlertsManagementClient.ActionRules.CreateUpdateWithHttpMessagesAsync(
                        resourceGroupName: ResourceGroupName, actionRuleName: Name, actionRule: actionGroupAR).Result.Body;
                    break;

                case BySimplifiedFormatSuppressionActionRuleParameterSet:

                    if (ActionRuleType != "Suppression")
                    {
                        throw new PSInvalidOperationException(string.Format(Resources.IncorrectActionRuleType_Exception, "Suppression"));
                    }

                    SuppressionConfig config = new SuppressionConfig(recurrenceType: ReccurenceType);
                    if (ReccurenceType != "Always")
                    {
                        config.Schedule = new SuppressionSchedule(
                            startDate: SuppressionStartTime.Split(' ')[0],
                            endDate: SuppressionEndTime.Split(' ')[0],
                            startTime: SuppressionStartTime.Split(' ')[1],
                            endTime: SuppressionEndTime.Split(' ')[1]
                            );

                        if (ReccurentValue.Length > 0)
                        {
                            config.Schedule.RecurrenceValues = ReccurentValue.OfType <int?>().ToList();
                        }
                    }

                    // Create Action Rule
                    ActionRule suppressionAR = new ActionRule(
                        location: "Global",
                        tags: new Dictionary <string, string>(),
                        properties: new Suppression(
                            scope: ParseScope(),
                            conditions: ParseConditions(),
                            description: Description,
                            status: Status,
                            suppressionConfig: config
                            )
                        );

                    result = this.AlertsManagementClient.ActionRules.CreateUpdateWithHttpMessagesAsync(
                        resourceGroupName: ResourceGroupName, actionRuleName: Name, actionRule: suppressionAR).Result.Body;
                    break;

                case BySimplifiedFormatDiagnosticsActionRuleParameterSet:
                    if (ActionRuleType != "Diagnostics")
                    {
                        throw new PSInvalidOperationException(string.Format(Resources.IncorrectActionRuleType_Exception, "Diagnostics"));
                    }

                    // Create Action Rule
                    ActionRule diagnosticsAR = new ActionRule(
                        location: "Global",
                        tags: new Dictionary <string, string>(),
                        properties: new Diagnostics(
                            scope: ParseScope(),
                            conditions: ParseConditions(),
                            description: Description,
                            status: Status
                            )
                        );

                    result = this.AlertsManagementClient.ActionRules.CreateUpdateWithHttpMessagesAsync(
                        resourceGroupName: ResourceGroupName, actionRuleName: Name, actionRule: diagnosticsAR).Result.Body;

                    break;

                case ByInputObjectParameterSet:
                    ExtractedInfo info = CommonUtils.ExtractFromActionRuleResourceId(InputObject.Id);
                    switch (InputObject.ActionRuleType)
                    {
                    case "ActionGroup":
                        // Create Action Rule
                        PSActionGroupActionRule actionGroupInputObject = (PSActionGroupActionRule)InputObject;
                        ActionRule actionGroupARFromInputObject        = new ActionRule(
                            location: "Global",
                            tags: new Dictionary <string, string>(),
                            properties: new ActionGroup(
                                scope: JsonConvert.DeserializeObject <Scope>(actionGroupInputObject.Scope),
                                conditions: JsonConvert.DeserializeObject <Conditions>(actionGroupInputObject.Conditions),
                                actionGroupId: actionGroupInputObject.ActionGroupId,
                                description: actionGroupInputObject.Description,
                                status: actionGroupInputObject.Status
                                )
                            );

                        result = this.AlertsManagementClient.ActionRules.CreateUpdateWithHttpMessagesAsync(
                            resourceGroupName: info.ResourceGroupName, actionRuleName: info.Resource, actionRule: actionGroupARFromInputObject).Result.Body;
                        break;

                    case "Suppression":
                        PSSuppressionActionRule suppressionInputObject = (PSSuppressionActionRule)InputObject;
                        SuppressionConfig       configFromInputObject  = new SuppressionConfig(recurrenceType: suppressionInputObject.RecurrenceType);
                        if (suppressionInputObject.RecurrenceType != "Always")
                        {
                            configFromInputObject.Schedule = new SuppressionSchedule(
                                startDate: suppressionInputObject.StartDate,
                                endDate: suppressionInputObject.EndDate,
                                startTime: suppressionInputObject.StartTime,
                                endTime: suppressionInputObject.EndTime
                                );

                            if (ReccurentValue.Length > 0)
                            {
                                configFromInputObject.Schedule.RecurrenceValues = suppressionInputObject.RecurrenceValues;
                            }
                        }

                        // Create Action Rule
                        ActionRule suppressionARFromInputObject = new ActionRule(
                            location: "Global",
                            tags: new Dictionary <string, string>(),
                            properties: new Suppression(
                                scope: JsonConvert.DeserializeObject <Scope>(suppressionInputObject.Scope),
                                conditions: JsonConvert.DeserializeObject <Conditions>(suppressionInputObject.Conditions),
                                description: suppressionInputObject.Description,
                                status: suppressionInputObject.Status,
                                suppressionConfig: configFromInputObject
                                )
                            );

                        result = this.AlertsManagementClient.ActionRules.CreateUpdateWithHttpMessagesAsync(
                            resourceGroupName: info.ResourceGroupName, actionRuleName: info.Resource, actionRule: suppressionARFromInputObject).Result.Body;
                        break;

                    case "Diagnostics":
                        // Create Action Rule
                        PSDiagnosticsActionRule diagnosticsInputObject = (PSDiagnosticsActionRule)InputObject;
                        ActionRule diagnosticsARFromInputObject        = new ActionRule(
                            location: "Global",
                            tags: new Dictionary <string, string>(),
                            properties: new Diagnostics(
                                scope: JsonConvert.DeserializeObject <Scope>(diagnosticsInputObject.Scope),
                                conditions: JsonConvert.DeserializeObject <Conditions>(diagnosticsInputObject.Conditions),
                                description: diagnosticsInputObject.Description,
                                status: diagnosticsInputObject.Status
                                )
                            );

                        result = this.AlertsManagementClient.ActionRules.CreateUpdateWithHttpMessagesAsync(
                            resourceGroupName: info.ResourceGroupName, actionRuleName: info.Resource, actionRule: diagnosticsARFromInputObject).Result.Body;
                        break;
                    }
                    break;
                }

                WriteObject(sendToPipeline: TransformOutput(result));
            }
        }
 /// <summary>
 /// 低減開始時間設定を保存する
 /// </summary>
 /// <param name="suppressionStartTime">低減開始時間</param>
 public static void Save(SuppressionStartTime suppressionStartTime)
 {
     PlayerPrefs.SetInt(Key, (int)suppressionStartTime);
 }