初始化代码
This commit is contained in:
106
AliAPI/AliAPI.csproj
Normal file
106
AliAPI/AliAPI.csproj
Normal file
@@ -0,0 +1,106 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{B3EB328E-D841-4A8B-B73D-C1F4614C996A}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>AliAPI</RootNamespace>
|
||||
<AssemblyName>AliAPI</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="AlibabaCloud.EndpointUtil, Version=0.1.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\AlibabaCloud.EndpointUtil.0.1.1\lib\net45\AlibabaCloud.EndpointUtil.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AlibabaCloud.GatewaySpi, Version=0.0.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\AlibabaCloud.GatewaySpi.0.0.2\lib\net45\AlibabaCloud.GatewaySpi.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AlibabaCloud.OpenApiClient, Version=0.1.6.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\AlibabaCloud.OpenApiClient.0.1.7\lib\net45\AlibabaCloud.OpenApiClient.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AlibabaCloud.OpenApiUtil, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\AlibabaCloud.OpenApiUtil.1.1.1\lib\net45\AlibabaCloud.OpenApiUtil.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AlibabaCloud.SDK.AliGenieip_1_0, Version=2.3.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\AlibabaCloud.SDK.AliGenieip_1_0.2.4.0\lib\net45\AlibabaCloud.SDK.AliGenieip_1_0.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AlibabaCloud.TeaUtil, Version=0.1.14.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\AlibabaCloud.TeaUtil.0.1.17\lib\net45\AlibabaCloud.TeaUtil.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AlibabaCloud.TeaXML, Version=0.0.5.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\AlibabaCloud.TeaXML.0.0.5\lib\net45\AlibabaCloud.TeaXML.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Aliyun.Credentials, Version=1.3.3.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Aliyun.Credentials.1.3.3\lib\net45\Aliyun.Credentials.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" />
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Net.Http.Extensions, Version=2.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http.Primitives, Version=4.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http.WebRequest" />
|
||||
<Reference Include="System.Security" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Tea, Version=1.1.3.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Tea.1.1.3\lib\net45\Tea.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AliOpenApiHelper.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets'))" />
|
||||
</Target>
|
||||
</Project>
|
||||
215
AliAPI/AliOpenApiHelper.cs
Normal file
215
AliAPI/AliOpenApiHelper.cs
Normal file
@@ -0,0 +1,215 @@
|
||||
using System;
|
||||
using AlibabaCloud.OpenApiClient.Models;
|
||||
using AlibabaCloud.SDK.AliGenieip_1_0;
|
||||
using AlibabaCloud.SDK.AliGenieip_1_0.Models;
|
||||
|
||||
namespace AliAPI
|
||||
{
|
||||
/// <summary>
|
||||
/// 阿里api处理类
|
||||
/// </summary>
|
||||
public static class AliOpenApiHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 创建访问客户端
|
||||
/// </summary>
|
||||
/// <param name="accessKeyId"></param>
|
||||
/// <param name="accessKeySecret"></param>
|
||||
/// <returns></returns>
|
||||
private static Client CreateClient(string accessKeyId, string accessKeySecret)
|
||||
{
|
||||
Config config = new Config
|
||||
{
|
||||
AccessKeyId = accessKeyId,
|
||||
AccessKeySecret = accessKeySecret,
|
||||
};
|
||||
config.Endpoint = "openapi.aligenie.com";//访问的域名
|
||||
return new Client(config);
|
||||
}
|
||||
/// <summary>
|
||||
/// 自定义场景上报
|
||||
/// </summary>
|
||||
/// <param name="accessKeyId"></param>
|
||||
/// <param name="accessKeySecret"></param>
|
||||
/// <param name="jsonData"></param>
|
||||
/// <returns></returns>
|
||||
public static APIResultEntity PostCustomScene(string accessKeyId, string accessKeySecret, string jsonData)
|
||||
{
|
||||
if (string.IsNullOrEmpty(accessKeyId))
|
||||
{
|
||||
return ReturnResult(false, "accessKeyId不能为空");
|
||||
}
|
||||
if (string.IsNullOrEmpty(accessKeySecret))
|
||||
{
|
||||
return ReturnResult(false, "accessKeySecret不能为空");
|
||||
}
|
||||
if (string.IsNullOrEmpty(jsonData))
|
||||
{
|
||||
return ReturnResult(false, "jsonData不能为空");
|
||||
}
|
||||
try
|
||||
{
|
||||
Client client = CreateClient(accessKeyId, accessKeySecret);
|
||||
ImportHotelConfigRequest req = Newtonsoft.Json.JsonConvert.DeserializeObject<ImportHotelConfigRequest>(jsonData);
|
||||
ImportHotelConfigResponse resp = client.ImportHotelConfig(req);
|
||||
return ReturnResult((bool)resp.Body.Result, resp.Body.Message, Newtonsoft.Json.JsonConvert.SerializeObject(resp.Body));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ReturnResult(false, ex.Message, ex.ToString());
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 退房重置
|
||||
/// </summary>
|
||||
/// <param name="accessKeyId"></param>
|
||||
/// <param name="accessKeySecret"></param>
|
||||
/// <param name="jsonData"></param>
|
||||
/// <returns></returns>
|
||||
public static APIResultEntity CheckoutWithAK(string accessKeyId, string accessKeySecret, string jsonData)
|
||||
{
|
||||
if (string.IsNullOrEmpty(accessKeyId))
|
||||
{
|
||||
return ReturnResult(false, "accessKeyId不能为空");
|
||||
}
|
||||
if (string.IsNullOrEmpty(accessKeySecret))
|
||||
{
|
||||
return ReturnResult(false, "accessKeySecret不能为空");
|
||||
}
|
||||
if (string.IsNullOrEmpty(jsonData))
|
||||
{
|
||||
return ReturnResult(false, "jsonData不能为空");
|
||||
}
|
||||
try
|
||||
{
|
||||
Client client = CreateClient(accessKeyId, accessKeySecret);
|
||||
CheckoutWithAKRequest req = Newtonsoft.Json.JsonConvert.DeserializeObject<CheckoutWithAKRequest>(jsonData);
|
||||
CheckoutWithAKResponse resp = client.CheckoutWithAK(req);
|
||||
return ReturnResult((bool)resp.Body.Result, resp.Body.Message, Newtonsoft.Json.JsonConvert.SerializeObject(resp.Body));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ReturnResult(false, ex.Message, ex.ToString());
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 推送并直接播报欢迎词
|
||||
/// </summary>
|
||||
/// <param name="accessKeyId"></param>
|
||||
/// <param name="accessKeySecret"></param>
|
||||
/// <param name="jsonData"></param>
|
||||
/// <returns></returns>
|
||||
public static APIResultEntity PushWelcome(string accessKeyId, string accessKeySecret, string jsonData)
|
||||
{
|
||||
if (string.IsNullOrEmpty(accessKeyId))
|
||||
{
|
||||
return new APIResultEntity() { result = false, msg = "accessKeyId不能为空", data = "" };
|
||||
}
|
||||
if (string.IsNullOrEmpty(accessKeySecret))
|
||||
{
|
||||
return new APIResultEntity() { result = false, msg = "accessKeySecret不能为空", data = "" };
|
||||
}
|
||||
if (string.IsNullOrEmpty(jsonData))
|
||||
{
|
||||
return new APIResultEntity() { result = false, msg = "jsonData不能为空", data = "" };
|
||||
}
|
||||
try
|
||||
{
|
||||
Client client = CreateClient(accessKeyId, accessKeySecret);
|
||||
PushWelcomeRequest req = Newtonsoft.Json.JsonConvert.DeserializeObject<PushWelcomeRequest>(jsonData);
|
||||
PushWelcomeResponse resp = client.PushWelcome(req);
|
||||
return ReturnResult((bool)resp.Body.Result, resp.Body.Message, Newtonsoft.Json.JsonConvert.SerializeObject(resp.Body));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ReturnResult(false, ex.Message, ex.ToString());
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置欢迎词
|
||||
/// </summary>
|
||||
/// <param name="accessKeyId"></param>
|
||||
/// <param name="accessKeySecret"></param>
|
||||
/// <param name="jsonData"></param>
|
||||
/// <returns></returns>
|
||||
public static APIResultEntity AddOrUpdateWelcomeText(string accessKeyId, string accessKeySecret, string jsonData)
|
||||
{
|
||||
if (string.IsNullOrEmpty(accessKeyId))
|
||||
{
|
||||
return new APIResultEntity() { result = false, msg = "accessKeyId不能为空", data = "" };
|
||||
}
|
||||
if (string.IsNullOrEmpty(accessKeySecret))
|
||||
{
|
||||
return new APIResultEntity() { result = false, msg = "accessKeySecret不能为空", data = "" };
|
||||
}
|
||||
if (string.IsNullOrEmpty(jsonData))
|
||||
{
|
||||
return new APIResultEntity() { result = false, msg = "jsonData不能为空", data = "" };
|
||||
}
|
||||
try
|
||||
{
|
||||
Client client = CreateClient(accessKeyId, accessKeySecret);
|
||||
AddOrUpdateWelcomeTextRequest req = Newtonsoft.Json.JsonConvert.DeserializeObject<AddOrUpdateWelcomeTextRequest>(jsonData);
|
||||
AddOrUpdateWelcomeTextResponse resp = client.AddOrUpdateWelcomeText(req);
|
||||
return ReturnResult((bool)resp.Body.Result, resp.Body.Message, Newtonsoft.Json.JsonConvert.SerializeObject(resp.Body));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ReturnResult(false, ex.Message, ex.ToString());
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 播报欢迎词
|
||||
/// </summary>
|
||||
/// <param name="accessKeyId"></param>
|
||||
/// <param name="accessKeySecret"></param>
|
||||
/// <param name="jsonData"></param>
|
||||
/// <returns></returns>
|
||||
public static APIResultEntity PushWelcomeTextAndMusic(string accessKeyId, string accessKeySecret, string jsonData)
|
||||
{
|
||||
if (string.IsNullOrEmpty(accessKeyId))
|
||||
{
|
||||
return new APIResultEntity() { result = false, msg = "accessKeyId不能为空", data = "" };
|
||||
}
|
||||
if (string.IsNullOrEmpty(accessKeySecret))
|
||||
{
|
||||
return new APIResultEntity() { result = false, msg = "accessKeySecret不能为空", data = "" };
|
||||
}
|
||||
if (string.IsNullOrEmpty(jsonData))
|
||||
{
|
||||
return new APIResultEntity() { result = false, msg = "jsonData不能为空", data = "" };
|
||||
}
|
||||
try
|
||||
{
|
||||
Client client = CreateClient(accessKeyId, accessKeySecret);
|
||||
PushWelcomeTextAndMusicRequest req = Newtonsoft.Json.JsonConvert.DeserializeObject<PushWelcomeTextAndMusicRequest>(jsonData);
|
||||
PushWelcomeTextAndMusicResponse resp = client.PushWelcomeTextAndMusic(req);
|
||||
return ReturnResult((bool)resp.Body.Result, resp.Body.Message, Newtonsoft.Json.JsonConvert.SerializeObject(resp.Body));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ReturnResult(false, ex.Message, ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private static APIResultEntity ReturnResult(bool result, string msg, string data = "")
|
||||
{
|
||||
return new APIResultEntity() { result = result, msg = msg, data = data };
|
||||
}
|
||||
}
|
||||
public class APIResultEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 结果:true成功,false失败
|
||||
/// </summary>
|
||||
public bool result { get; set; }
|
||||
/// <summary>
|
||||
/// 提示信息
|
||||
/// </summary>
|
||||
public string msg { get; set; }
|
||||
/// <summary>
|
||||
/// 返回数据
|
||||
/// </summary>
|
||||
public string data { get; set; }
|
||||
}
|
||||
}
|
||||
36
AliAPI/Properties/AssemblyInfo.cs
Normal file
36
AliAPI/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("AliAPI")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("AliAPI")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2023")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("b3eb328e-d841-4a8b-b73d-c1f4614c996a")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
11
AliAPI/app.config
Normal file
11
AliAPI/app.config
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
16
AliAPI/packages.config
Normal file
16
AliAPI/packages.config
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="AlibabaCloud.EndpointUtil" version="0.1.1" targetFramework="net45" />
|
||||
<package id="AlibabaCloud.GatewaySpi" version="0.0.2" targetFramework="net45" />
|
||||
<package id="AlibabaCloud.OpenApiClient" version="0.1.7" targetFramework="net45" />
|
||||
<package id="AlibabaCloud.OpenApiUtil" version="1.1.1" targetFramework="net45" />
|
||||
<package id="AlibabaCloud.SDK.AliGenieip_1_0" version="2.4.0" targetFramework="net48" />
|
||||
<package id="AlibabaCloud.TeaUtil" version="0.1.17" targetFramework="net48" />
|
||||
<package id="AlibabaCloud.TeaXML" version="0.0.5" targetFramework="net48" />
|
||||
<package id="Aliyun.Credentials" version="1.3.3" targetFramework="net48" />
|
||||
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net45" />
|
||||
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net48" />
|
||||
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net45" />
|
||||
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
|
||||
<package id="Tea" version="1.1.3" targetFramework="net48" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user