<?xml version="1.0"?>
<PackageConstruct1100 xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ID>{522bd208-7b3a-4346-bac7-99d6019f4e37}</ID>
  <ParentID />
  <Name />
  <Type>Package</Type>
  <Path />
  <Tasks>
    <anyType xsi:type="TaskConstruct">
      <ID>{d5ecba09-e11a-4b8c-8e18-56e3c65513d3}</ID>
      <ParentID>{E893A7FD-2758-4315-9181-93F8728332E5}</ParentID>
      <Name>Opsgenie - Excelを基にアラートをクローズ</Name>
      <Type>Task</Type>
      <Path />
      <StartedOn>1900-01-01T00:00:00Z</StartedOn>
      <EndedOn>1900-01-01T00:00:00Z</EndedOn>
      <ResultCode>0</ResultCode>
      <ResultText />
      <VersionDate>2022-01-28T01:53:00.48Z</VersionDate>
      <Version>38</Version>
      <ModifiedOn>2022-01-28T01:53:00.477Z</ModifiedOn>
      <CreatedOn>2022-01-28T01:10:21.95Z</CreatedOn>
      <Notes />
      <CreatedBy>{6AD627E8-373B-4104-81B7-9670A9D2F430}</CreatedBy>
      <CompletionState>InDevelopment</CompletionState>
      <ExclusionSchedules />
      <Empty>false</Empty>
      <Enabled>true</Enabled>
      <Removed>false</Removed>
      <LockedBy />
      <AML>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;AutoMateTask&gt;
  &lt;TaskInfo&gt;
    &lt;Version TaskVersion="11.6.10.49" MinVersion="0.0.0.0" AMLVersion="3.0" /&gt;
  &lt;/TaskInfo&gt;
  &lt;ManagedTask&gt;
    &lt;TaskProperties Id="{caa6557d-f36a-412e-908e-5d31f1eee542}" Name="Template V7" Path="" /&gt;
  &lt;/ManagedTask&gt;
  &lt;TaskVariables&gt;
    &lt;TaskVariable Name="TaskVar_MainPath" Default="C:\Automate\Tasks\%GetTaskName()%" /&gt;
    &lt;TaskVariable Name="TaskVar_ElapsedTime" /&gt;
    &lt;TaskVariable Name="TaskVar_Log" Description="%TaskVar_MainPath%\Logs\%GetTaskName()%_%format(Now(), &amp;quot;yyyy-MM-dd hhmmss&amp;quot;)%.log" Default="%TaskVar_MainPath%\Logs\%GetTaskName()%_%format(Now(), &amp;quot;yyyy-MM-dd&amp;quot;)%.log" /&gt;
    &lt;TaskVariable Name="TaskVar_errorTitle" Default="We found an error on the task %GetTaskName()%" /&gt;
    &lt;TaskVariable Name="TaskVar_errorDesc" /&gt;
    &lt;TaskVariable Name="TaskVar_help" Default="%GetAutoMateDirectory()%\Help\Default.htm" /&gt;
    &lt;TaskVariable Name="TaskVar_SuccessSubject" Default="Task %GetTaskName()% has finished succesfully." /&gt;
    &lt;TaskVariable Name="TaskVar_Error" /&gt;
    &lt;TaskVariable Name="var_JSONString" /&gt;
    &lt;TaskVariable Name="var_OpsGenieApiKey" /&gt;
    &lt;TaskVariable Name="var_OpsGenieRegionDomain" /&gt;
    &lt;TaskVariable Name="var_OpsGenieApiURL" /&gt;
    &lt;TaskVariable Name="var_user" /&gt;
    &lt;TaskVariable Name="var_note" /&gt;
    &lt;TaskVariable Name="var_ApiVersion" Default="v2" /&gt;
    &lt;TaskVariable Name="var_ExcelInputFile" /&gt;
    &lt;TaskVariable Name="var_Index" Default="3" /&gt;
    &lt;TaskVariable Name="var_source" /&gt;
    &lt;TaskVariable Name="var_AlertID" /&gt;
    &lt;TaskVariable Name="var_RequestID" /&gt;
  &lt;/TaskVariables&gt;
  &lt;TaskFunctions&gt;
    &lt;TaskFunction Name="OnStepStart" Access="private"&gt;
      &lt;Parameters&gt;
        &lt;Parameter Name="FunctionName" Description="The function that is starting the step" /&gt;
        &lt;Parameter Name="StepNumber" Description="The step number that is about to execute" /&gt;
      &lt;/Parameters&gt;
    &lt;/TaskFunction&gt;
    &lt;TaskFunction Name="OnStepEnd" Access="private"&gt;
      &lt;Parameters&gt;
        &lt;Parameter Name="FunctionName" Description="The function that is ending the step" /&gt;
        &lt;Parameter Name="StepNumber" Description="The step number that is about to end" /&gt;
      &lt;/Parameters&gt;
    &lt;/TaskFunction&gt;
    &lt;TaskFunction Name="OnStepError" Access="private"&gt;
      &lt;Parameters&gt;
        &lt;Parameter Name="FunctionName" Description="The function with the error" /&gt;
        &lt;Parameter Name="StepNumber" Description="The step number of the error" /&gt;
        &lt;Parameter Name="ErrorText" Description="The text of the error" /&gt;
        &lt;Parameter Name="ErrorCode" Description="The code of the error" /&gt;
      &lt;/Parameters&gt;
    &lt;/TaskFunction&gt;
    &lt;TaskFunction Name="OnTaskFailure" Access="private"&gt;
      &lt;Parameters&gt;
        &lt;Parameter Name="FunctionName" Description="The function causing the task failure" /&gt;
        &lt;Parameter Name="StepNumber" Description="The step number causing the task failure" /&gt;
        &lt;Parameter Name="ErrorText" Description="The text of the error" /&gt;
        &lt;Parameter Name="ErrorCode" Description="The code of the error" /&gt;
      &lt;/Parameters&gt;
      &lt;Steps&gt;
&lt;AMVARIABLE ACTIVITY="set" VARIABLENAME="TaskVar_error"&gt;&lt;![CDATA[&lt;strong&gt;%AMError.FunctionName%&lt;/strong&gt; in the Step &lt;strong&gt;%AMError.StepNumber%&lt;/strong&gt;. Error Description: &lt;span style="color: #ff0000;"&gt;&lt;strong&gt;"%AMError.ErrorDesc%"&lt;/strong&gt;&lt;/span&gt;]]&gt;&lt;/AMVARIABLE&gt;
&lt;AMTIMER ACTIVITY="stop" RESULTVARIABLE="TaskVar_ElapsedTime" SESSION="TimerSession1" /&gt;
&lt;AMFILESYSTEM ACTIVITY="write_file" FILE="%TaskVar_Log%"&gt;%NOW()% - ERROR - Error found on the Function %Replace(Replace(Replace(Replace(Replace(Replace(TaskVar_Error, "&amp;lt;span style=""color: #ff0000;""&amp;gt;", "", 1, -1), "&amp;lt;p&amp;gt;&amp;amp;lt;", "", 1, -1), "&amp;lt;/strong&amp;gt;", "", 1, -1), "&amp;lt;strong&amp;gt;", "", 1, -1), "&amp;lt;p&amp;gt;&amp;amp;lt;&amp;lt;strong&amp;gt;", "", 1, -1), "&amp;lt;/span&amp;gt;", "", 1, -1)%. 
%NOW()% - INFO - Aborting task. Total elapsed time: %Round(TaskVar_ElapsedTime, 2)% seconds.&lt;/AMFILESYSTEM&gt;
&lt;AMTASK ACTIVITY="stop" STATUSTYPE="ERROR" ERRORNUMBER="12345" ERRORTEXT="Error during execution." /&gt;
	&lt;/Steps&gt;
    &lt;/TaskFunction&gt;
    &lt;TaskFunction Name="OnTaskStart" Access="private"&gt;
      &lt;Parameters&gt;
        &lt;Parameter Name="Reason" Description="The reason the task is starting" /&gt;
      &lt;/Parameters&gt;
      &lt;Steps&gt;
&lt;!--Initiating our log--&gt;
&lt;AMTIMER SESSION="TimerSession1" /&gt;
&lt;!--Writing the task start--&gt;
&lt;AMFILESYSTEM ACTIVITY="write_file" FILE="%TaskVar_Log%"&gt;---------------------------------------------------------------------------------------
%Now()% - INFO - Starting the task "%GetTaskName()%"&lt;/AMFILESYSTEM&gt;
&lt;!--Lets create our main path in case does not exist--&gt;
&lt;AMIF ACTIVITY="folder_exist" ACCESSIBILITYENGINE="active" FOLDER="%TaskVar_MainPath%" MODE="not_exist" /&gt;
&lt;AMFILESYSTEM ACTIVITY="create_folder" FOLDER="%TaskVar_MainPath%" /&gt;
&lt;AMIF ACTIVITY="end" ACCESSIBILITYENGINE="active" /&gt;
&lt;!--Setting variable from Constants--&gt;
&lt;AMVARIABLE ACTIVITY="set" VARIABLENAME="var_OpsGenieApiKey"&gt;&lt;![CDATA[%const_OpsgenieApiKey%]]&gt;&lt;/AMVARIABLE&gt;
&lt;AMVARIABLE ACTIVITY="set" VARIABLENAME="var_OpsGenieRegionDomain"&gt;&lt;![CDATA[%const_OpsgenieRegionDomain%]]&gt;&lt;/AMVARIABLE&gt;
	&lt;/Steps&gt;
    &lt;/TaskFunction&gt;
    &lt;TaskFunction Name="OnTaskEnd" Access="private"&gt;
      &lt;Parameters&gt;
        &lt;Parameter Name="Reason" Description="The reason the task is ending" /&gt;
      &lt;/Parameters&gt;
      &lt;Steps&gt;
&lt;!--Ending the log--&gt;
&lt;AMTIMER ACTIVITY="stop" RESULTVARIABLE="TaskVar_ElapsedTime" SESSION="TimerSession1" /&gt;
&lt;AMFILESYSTEM ACTIVITY="write_file" FILE="%TaskVar_Log%"&gt;%now()% - INFO - Ending our task
%now()% - INFO - The Task %GetTaskName()% has finished without errors
%now()% - INFO - Elapsed time: %Round(TaskVar_ElapsedTime, 2)% seconds&lt;/AMFILESYSTEM&gt;
	&lt;/Steps&gt;
    &lt;/TaskFunction&gt;
    &lt;TaskFunction Name="Main" Access="private"&gt;
      &lt;Steps&gt;
&lt;!--Opsgenie &amp;#45; Excelを基にアラートをクローズ
ExcelのINPUTファイルからOpsgenieのアラートを閉じるAutoMateタスク。
By HelpSystems--&gt;
&lt;AMREGION NAME="設定" /&gt;
&lt;!--アラートクロージング用のINPUT OpsGenie Excelファイルのロケーションパスと名前を設定します。--&gt;
&lt;AMVARIABLE ACTIVITY="set" VARIABLENAME="var_ExcelInputFile" VALUE="D:\test\Opsgenie Close Alerts INPUT.xlsx" /&gt;
&lt;AMENDREGION /&gt;
&lt;AMREGION NAME="Opsgenieアラートを作成する" /&gt;
&lt;AMTASK ACTIVITY="call_function" FUNCTIONNAME="CloseOpsgenieAlerts()" /&gt;
&lt;AMENDREGION /&gt;
	&lt;/Steps&gt;
    &lt;/TaskFunction&gt;
    &lt;TaskFunction Name="CloseOpsgenieAlerts"&gt;
      &lt;Steps&gt;
&lt;AMREGION NAME="Opsgenieアラートを作成する" /&gt;
&lt;!--We read the file from the 3rd row and we store in Excel Dataset--&gt;
&lt;AMODS ACTIVITY="get_cell" WORKBOOK="%var_ExcelInputFile%" SAVETYPE="do_not_save" ACTION="rangebyreference" RESULTDATASET="ExcelDataset" STARTCELLREF="A3" LASTCELL="YES" /&gt;
&lt;AMLOOP ACTIVITY="dataset" DATASET="ExcelDataset" /&gt;
&lt;AMIF EXPRESSION="%ExcelDataset.E = ''  AND ExcelDataset.A &amp;lt;&amp;gt;  ''%" USECOMPLEXUI="YES" /&gt;
&lt;AMFILESYSTEM ACTIVITY="write_file" FILE="%TaskVar_Log%"&gt;%Now()% - INFO - Closing new Case in Excel INPUT in Row %var_Index +2%.&lt;/AMFILESYSTEM&gt;
&lt;AMVARIABLE ACTIVITY="set" VARIABLENAME="var_AlertID"&gt;&lt;![CDATA[%ExcelDataset.A%]]&gt;&lt;/AMVARIABLE&gt;
&lt;AMVARIABLE ACTIVITY="set" VARIABLENAME="var_note"&gt;&lt;![CDATA[%ExcelDataset.B%]]&gt;&lt;/AMVARIABLE&gt;
&lt;AMVARIABLE ACTIVITY="set" VARIABLENAME="var_user"&gt;&lt;![CDATA[%ExcelDataset.C%]]&gt;&lt;/AMVARIABLE&gt;
&lt;AMVARIABLE ACTIVITY="set" VARIABLENAME="var_source"&gt;&lt;![CDATA[%ExcelDataset.D%]]&gt;&lt;/AMVARIABLE&gt;
&lt;AMVARIABLE ACTIVITY="set" VARIABLENAME="var_JSONString"&gt;&lt;![CDATA[{
    "user":"%var_user%",
    "source":"%var_source%",
    "note":"%var_note%"
}]]&gt;&lt;/AMVARIABLE&gt;
&lt;AMVARIABLE ACTIVITY="set" VARIABLENAME="var_OpsGenieApiURL"&gt;&lt;![CDATA[%var_OpsGenieRegionDomain%/%var_ApiVersion%/alerts/%var_AlertID%/close]]&gt;&lt;/AMVARIABLE&gt;
&lt;AMHTTP ACTIVITY="post" URL="%var_OpsGenieApiURL%" DATA="%var_JSONString%" RESULTDATASET="GetResult"&gt;&lt;HEADER NAME="Content-Type" VALUE="application/json" /&gt;&lt;HEADER NAME="Authorization" VALUE="GenieKey %var_OpsGenieApiKey%" /&gt;&lt;HEADER NAME="Accept" VALUE="application/json" /&gt;&lt;/AMHTTP&gt;
&lt;AMIF ACTIVITY="contains_text" TEXT="%GetResult(1).ResponseHeader%" SUBSTRING="HTTP/1.1 202 Accepted" /&gt;
&lt;AMJSON JSONSTRING="%GetResult(1).Data%" RESULTSTRUCTURE="obj_Result" /&gt;
&lt;AMVARIABLE ACTIVITY="set" VARIABLENAME="var_RequestID"&gt;&lt;![CDATA[%obj_Result.requestId%]]&gt;&lt;/AMVARIABLE&gt;
&lt;AMODS ACTIVITY="set_cell" WORKBOOK="%var_ExcelInputFile%" SETTERTYPE="list" CELLREF="E%var_Index%" LIST="YES;%Now()%;%var_RequestID%" DELIMITER="semi_colon" /&gt;
&lt;AMFILESYSTEM ACTIVITY="write_file" FILE="%TaskVar_Log%"&gt;%Now()% - INFO - The Alert %var_AlertID% was closed, request id %var_RequestID%.&lt;/AMFILESYSTEM&gt;
&lt;AMELSE /&gt;
&lt;AMODS ACTIVITY="set_cell" WORKBOOK="%var_ExcelInputFile%" SETTERTYPE="list" CELLREF="E%var_Index%" LIST="NO;%Now()%;Could not close Alert. See the log for further information." DELIMITER="semi_colon" /&gt;
&lt;AMFILESYSTEM ACTIVITY="write_file" FILE="%TaskVar_Log%"&gt;%Now()% - ERROR - The Alert in Row %var_Index% and id %var_AlertID% could not be closed in Opsgenie. &lt;/AMFILESYSTEM&gt;
&lt;AMFILESYSTEM ACTIVITY="write_file" FILE="%TaskVar_Log%"&gt;%Now()% - ERROR - Error Details: %GetResult(1).Data%&lt;/AMFILESYSTEM&gt;
&lt;AMIF ACTIVITY="end" /&gt;
&lt;AMIF ACTIVITY="end" /&gt;
&lt;AMVARIABLE ACTIVITY="increment" RESULTVARIABLE="var_Index" /&gt;
&lt;AMLOOP ACTIVITY="end" /&gt;
&lt;AMENDREGION /&gt;
	&lt;/Steps&gt;
    &lt;/TaskFunction&gt;
  &lt;/TaskFunctions&gt;
&lt;/AutoMateTask&gt;</AML>
    </anyType>
  </Tasks>
  <TaskProperties />
  <Triggers />
  <TriggerProperties />
  <WorkFlows />
  <WorkFlowProperties />
  <Folders />
  <ItemPermissions />
  <Processes />
  <WorkflowItemProperties />
  <Exclusions />
</PackageConstruct1100>