From 1459ccd0aac1b2288daac6c1fc6ce43ed185e18b Mon Sep 17 00:00:00 2001
From: 王 垚 <1402714037@qq.com>
Date: 星期五, 17 六月 2022 11:10:01 +0800
Subject: [PATCH] 配置文件
---
WebAPI/Config/kdapi.config | 9 +++
WebAPI/InvokeHelper.cs | 8 ++
WebAPI/Utility/Util.cs | 124 +++++++++++++++++++++++++++++++++++++++++
WebAPI/WebAPI.csproj | 2
4 files changed, 143 insertions(+), 0 deletions(-)
diff --git a/WebAPI/Config/kdapi.config b/WebAPI/Config/kdapi.config
new file mode 100644
index 0000000..c18615b
--- /dev/null
+++ b/WebAPI/Config/kdapi.config
@@ -0,0 +1,9 @@
+锘�<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+ <appSettings>
+ <add key="DbId" value="5f9258a311401c"></add>
+ <add key="UserName" value="Administrator"></add>
+ <add key="PassWord" value="qaz!@#123"></add>
+ <add key="KDApiUrl" value="http://localhost/K3Cloud/"></add>
+ </appSettings>
+</configuration>
\ No newline at end of file
diff --git a/WebAPI/InvokeHelper.cs b/WebAPI/InvokeHelper.cs
index 2bc5e15..d046824 100644
--- a/WebAPI/InvokeHelper.cs
+++ b/WebAPI/InvokeHelper.cs
@@ -4,6 +4,7 @@
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
+using WebAPI.Utility;
namespace WebAPI
{
@@ -20,6 +21,13 @@
/// </summary>
public static string Login()
{
+ var dbId = Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "DbId");
+ var useName = Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "UserName");
+ var pwd = Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "PassWord");
+ var CloudUrl = Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "KDApiUrl");
+ //var url = GetKey(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "/kdapi.config", "KDApiUrl");
+ //var loginResult = ValidateLogin(dbId, useName, pwd, 2052);
+ //var resultType = JObject.Parse(loginResult)["LoginResultType"].Value<int>();
HttpClient httpClient = new HttpClient();
httpClient.Url = string.Concat(CloudUrl, "Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc");
diff --git a/WebAPI/Utility/Util.cs b/WebAPI/Utility/Util.cs
new file mode 100644
index 0000000..3e818fc
--- /dev/null
+++ b/WebAPI/Utility/Util.cs
@@ -0,0 +1,124 @@
+锘縰sing Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Serialization;
+
+namespace WebAPI.Utility
+{
+ public class Util
+ {
+ public static string GetObjectType(object obj)
+ {
+ var isType = false;
+ isType = obj.GetType() == typeof(string);
+ if (isType)
+ {
+ return "string";
+ }
+
+ isType = obj.GetType() == typeof(double);
+ if (isType)
+ {
+ return "double";
+ }
+
+ isType = obj.GetType() == typeof(long);
+ if (isType)
+ {
+ return "long";
+ }
+
+ isType = obj.GetType() == typeof(DateTime);
+ if (isType)
+ {
+ return "date";
+ }
+
+ isType = obj.GetType() == typeof(int);
+ if (isType)
+ {
+ return "int";
+ }
+
+ isType = obj.GetType() == typeof(decimal);
+ if (isType)
+ {
+ return "decimal";
+ }
+
+ return "string";
+ }
+
+ public static JObject JsonVerify(string json)
+ {
+ if (string.IsNullOrEmpty(json))
+ {
+ throw new Exception("鍙傛暟涓嶈兘涓虹┖");
+ }
+ try
+ {
+ return JObject.Parse(json.ToString().Replace("\r", "").Replace("\n", "").Replace("\t", ""));
+ }
+ catch (Exception)
+ {
+ throw;
+ }
+ }
+
+ //public static T DeepCopy<T>(T obj)
+ //{
+ // object retval;
+ // using (MemoryStream ms = new MemoryStream())
+ // {
+ // XmlSerializer xml = new XmlSerializer(typeof(T));
+ // xml.Serialize(ms, obj);
+ // ms.Seek(0, SeekOrigin.Begin);
+ // retval = xml.Deserialize(ms);
+ // ms.Close();
+ // }
+ // return (T)retval;
+ //}
+
+ public static String GetConfigKey(String configPath, String key)
+ {
+ Configuration ConfigurationInstance = ConfigurationManager.OpenMappedExeConfiguration(new ExeConfigurationFileMap()
+ {
+ ExeConfigFilename = configPath
+ }, ConfigurationUserLevel.None);
+
+
+ if (ConfigurationInstance.AppSettings.Settings[key] != null)
+ return ConfigurationInstance.AppSettings.Settings[key].Value;
+ else
+
+ return string.Empty;
+ }
+
+ public static bool SetConfigKey(String configPath, String key, String vls)
+ {
+ try
+ {
+ Configuration ConfigurationInstance = ConfigurationManager.OpenMappedExeConfiguration(new ExeConfigurationFileMap()
+ {
+ ExeConfigFilename = configPath
+ }, ConfigurationUserLevel.None);
+
+ if (ConfigurationInstance.AppSettings.Settings[key] != null)
+ ConfigurationInstance.AppSettings.Settings[key].Value = vls;
+ else
+ ConfigurationInstance.AppSettings.Settings.Add(key, vls);
+ ConfigurationInstance.Save(ConfigurationSaveMode.Modified);
+ ConfigurationManager.RefreshSection("appSettings");
+ return true;
+ }
+ catch
+ {
+ return false;
+ }
+ }
+ }
+}
diff --git a/WebAPI/WebAPI.csproj b/WebAPI/WebAPI.csproj
index 316c1da..45b5324 100644
--- a/WebAPI/WebAPI.csproj
+++ b/WebAPI/WebAPI.csproj
@@ -233,6 +233,7 @@
<Content Include="Index.html" />
<Content Include="Views\Scripts\bootstrap.js" />
<Content Include="Views\Scripts\bootstrap.min.js" />
+ <Content Include="Config\kdapi.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -752,6 +753,7 @@
<Compile Include="Service\ProcessDal.cs" />
<Compile Include="Service\YqnDal.cs" />
<Compile Include="Service\YqnQbService.cs" />
+ <Compile Include="Utility\Util.cs" />
<Compile Include="Web References\WebS\Reference.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
--
Gitblit v1.9.1