From b6753f4c30f043b38655acb5e98391fcfb476e14 Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期三, 06 七月 2022 14:17:43 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/SRM-WEBAPI
---
.gitignore | 8 ++
WebAPI/Config/kdapi.config | 10 +++
WebAPI/InvokeHelper.cs | 22 ++----
WebAPI/Utility/Util.cs | 124 +++++++++++++++++++++++++++++++++++++++++
WebAPI/WebAPI.csproj | 2
5 files changed, 151 insertions(+), 15 deletions(-)
diff --git a/.gitignore b/.gitignore
index 4ce6fdd..e563943 100644
--- a/.gitignore
+++ b/.gitignore
@@ -337,4 +337,10 @@
.localhistory/
# BeatPulse healthcheck temp database
-healthchecksdb
\ No newline at end of file
+healthchecksdb
+/WebAPI/Vlog/webapi20220706.txt
+/WebAPI/Vlog/webapi20220622.txt
+/WebAPI/Vlog/webapi20220610.txt
+/WebAPI/Vlog/webapi20220518.txt
+/WebAPI/Vlog/webapi20220512.txt
+/WebAPI/Vlog/webapi20220510.txt
diff --git a/WebAPI/Config/kdapi.config b/WebAPI/Config/kdapi.config
new file mode 100644
index 0000000..4610af2
--- /dev/null
+++ b/WebAPI/Config/kdapi.config
@@ -0,0 +1,10 @@
+锘�<?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>
+ <add key="DataBaseName" value="http://localhost/K3Cloud/"></add>
+ </appSettings>
+</configuration>
\ No newline at end of file
diff --git a/WebAPI/InvokeHelper.cs b/WebAPI/InvokeHelper.cs
index ecfacd8..11d42d2 100644
--- a/WebAPI/InvokeHelper.cs
+++ b/WebAPI/InvokeHelper.cs
@@ -4,33 +4,27 @@
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
+using WebAPI.Utility;
namespace WebAPI
{
public static class InvokeHelper
{
- //private static string CloudUrl = "http://localhost/k3cloud/";//K/3 Cloud 涓氬姟绔欑偣鍦板潃
- //private static string CloudUrl = "http://60.190.4.42:9002/k3cloud/";//K/3 Cloud 涓氬姟绔欑偣鍦板潃
- //private static string CloudUrl = "http://47.96.97.237/k3cloud/";//K/3 Cloud 涓氬姟绔欑偣鍦板潃
- //private static string CloudUrl = "http://60.190.4.42:9002/K3CLOUD/";//澶忓疂
- private static string CloudUrl = "http://192.168.1.238:9002/K3CLOUD/";//澶忓疂
-
-
-
+ private static string CloudUrl = Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "KDApiUrl");//K/3 Cloud 涓氬姟绔欑偣鍦板潃
/// <summary>
/// 鐧婚檰
/// </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");
HttpClient httpClient = new HttpClient();
httpClient.Url = string.Concat(CloudUrl, "Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc");
-
- //var loginResult = client.ValidateLogin("61b14ea86f5c8a", "Administrator", "sharbo@2012", 2052); 澶忓疂澶囦唤娴嬭瘯璐﹀
- //var loginResult = client.ValidateLogin("61a5bea53ffc61", "Administrator", "1234.com", 2052);澶忓疂姝e紡璐﹀
List<object> Parameters = new List<object>();
- Parameters.Add("61a5bea53ffc61");//璐﹀鏍囩ず
- Parameters.Add("Administrator");//鐢ㄦ埛鍚�
- Parameters.Add("1234.com");//瀵嗙爜
+ Parameters.Add(dbId);//璐﹀鏍囩ず
+ Parameters.Add(useName);//鐢ㄦ埛鍚�
+ Parameters.Add(pwd);//瀵嗙爜
Parameters.Add(2052);//2052浠h〃涓枃
httpClient.Content = JsonConvert.SerializeObject(Parameters);
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 d5c843b..72d4f53 100644
--- a/WebAPI/WebAPI.csproj
+++ b/WebAPI/WebAPI.csproj
@@ -193,6 +193,7 @@
<Content Include="HtmlPage.html" />
<Content Include="HtmlPage1.html" />
<Content Include="Index.html" />
+ <Content Include="Config\kdapi.config" />
<None Include="Scripts\jquery-1.6.4-vsdoc.js" />
<Content Include="Scripts\jquery-1.6.4.js" />
<Content Include="Scripts\jquery-1.6.4.min.js" />
@@ -238,6 +239,7 @@
<Compile Include="MyHub.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Startup.cs" />
+ <Compile Include="Utility\Util.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="packages.config" />
--
Gitblit v1.9.1