winform+dev的前后台分离标准项目
lg
2024-09-02 59abbe4785268a10ec9390b8373cce3939c1d24b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using Microsoft.AspNetCore.Http;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Net.WebRequestMethods;
 
namespace Gs.Toolbox
{
    public static class UtilityHelper
    {
        /// <summary>
        /// string 转guid
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static Guid? GetGuid(string? str)
        {
            if (string.IsNullOrEmpty(str))
                return null;
            return Guid.Parse(str);
        }
        /// <summary>
        /// 读取userGuid,orgGuid
        /// </summary>
        /// <param name="_http"></param>
        /// <returns></returns>
        public static (string?, string?) GetUserGuidAndOrgGuid(IHttpContextAccessor _http)
        {
            try
            {
                string _token = _http.HttpContext.Request.Headers["token"];
                string[] _ary = _token.Split("~");
                return (_ary[0], _ary[1]);
            }
            catch (Exception ex)
            {
                Gs.Toolbox.LogHelper.Debug("GetUserGuidAndOrgGuid:", ex.Message);
                return (null, null);
            }
 
        }
    }
}