管道基础大数据平台系统开发-【CS】-ExportMap
13693261870
2023-01-01 dc2da375cd8b8cc7fb5cb3a3f854cf53e685da9e
1.1.5
已添加1个文件
已修改5个文件
已删除1个文件
121 ■■■■ 文件已修改
DataLoader/CS/Importor.cs 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DataLoader/DataLoader.csproj 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
DataLoader/LoginWin.xaml.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
DataLoader/MainWindow.xaml.cs 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DataLoader/Model/Main.cs 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DataLoader/Model/NtstWeb.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DataLoader/Model/Tool.cs 78 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DataLoader/CS/Importor.cs
@@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
@@ -10,7 +11,7 @@
{
    public class Importor
    {
        private static readonly string insertMeta = "insert into lf.sys_meta(name, dirid, depid, verid, type, sizes, cs, scale, resolution, gather, batch, descr, create_user) values  @name, @dirid, @depid, @verid, @type, @sizes, @cs, @scale, @resolution, @gather, @batch, @descr, @create_user)";
        private static readonly string insertMeta = "insert into lf.sys_meta(name, dirid, depid, verid, type, sizes, cs, scale, resolution, gather, batch, descr, create_user) values  @name, @dirid, @depid, @verid, @type, @sizes, @cs, @scale, @resolution, @gather, @batch, @descr, @create_user) returning id";
        private static readonly string insertMetaFile = "insert into lf.sys_meta_file(name, metaid, fileid, guid, path, sizes, create_user) values (@name, @metaid, @fileid, @guid, @path, @sizes, @create_user)";
DataLoader/DataLoader.csproj
@@ -88,7 +88,7 @@
      <SubType>Code</SubType>
    </Compile>
    <Compile Include="CS\Importor.cs" />
    <Compile Include="Model\Main.cs" />
    <Compile Include="Model\Tool.cs" />
    <Compile Include="CS\ModelHandler.cs" />
    <Compile Include="Model\NtstWeb.cs" />
    <Compile Include="CS\PostgreHelper.cs" />
DataLoader/LoginWin.xaml.cs
@@ -32,7 +32,7 @@
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            web.Address = Main.BaseDir + "htmls\\login.html";
            web.Address = Tool.BaseDir + "htmls\\login.html";
        }
    }
}
DataLoader/MainWindow.xaml.cs
@@ -64,7 +64,7 @@
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Main.Owner = this;
            Tool.Owner = this;
            this.btnImport.IsEnabled = false;
            lvView.DataContext = viewDatas;
@@ -85,8 +85,8 @@
            if (win != null) win.Close();
            this.Show();
            this.tbUid.Text = Main.UserId.ToString() + "," + Main.Uname;
            this.tbToken.Text = Main.Token;
            this.tbUid.Text = Tool.UserId.ToString() + "," + Tool.Uname;
            this.tbToken.Text = Tool.Token;
            this.btnImport.IsEnabled = true;
        }
DataLoader/Model/Main.cs
ÎļþÒÑɾ³ý
DataLoader/Model/NtstWeb.cs
@@ -21,13 +21,13 @@
        {
            if (uid > 0 && !string.IsNullOrEmpty(token))
            {
                Main.UserId = uid;
                Main.Uname = uname;
                Main.Token = token;
                Tool.UserId = uid;
                Tool.Uname = uname;
                Tool.Token = token;
                owner.Dispatcher.Invoke(new Action(delegate
                {
                    Main.Owner.SetLoginInfo();
                    Tool.Owner.SetLoginInfo();
                }));
            }
        }
DataLoader/Model/Tool.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,78 @@
using Npgsql;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.Common;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace DataLoader.Model
{
    public class Tool
    {
        public static MainWindow Owner = null;
        public static readonly string BaseDir = AppDomain.CurrentDomain.BaseDirectory;
        public static int UserId = 0;
        public static string Uname = "";
        public static string Token = "";
        public static string FormatBytes(long bytes)
        {
            string[] Suffix = { "Byte", "KB", "MB", "GB", "TB" };
            int i = 0;
            double dblSByte = bytes;
            if (bytes > 1024)
                for (i = 0; (bytes / 1024) > 0; i++, bytes /= 1024)
                    dblSByte = bytes / 1024.0;
            return String.Format("{0:0.##}{1}", dblSByte, Suffix[i]);
        }
        public static string GetSetting(string key)
        {
            if (!ConfigurationManager.AppSettings.AllKeys.Contains(key))
            {
                return null;
            }
            return ConfigurationManager.AppSettings[key];
        }
        public static List<DbParameter> GetParams<T>(string sql, T t)
        {
            List<DbParameter> list = new List<DbParameter>();
            Type tType = typeof(T);
            BindingFlags flags = BindingFlags.Public | BindingFlags.IgnoreCase | BindingFlags.Instance;
            int start = sql.IndexOf("@");
            while (start != -1)
            {
                int end = sql.IndexOf(",", start);
                if (end == -1) end = sql.IndexOf(")", start);
                if (end == -1) end = sql.IndexOf(" ", start);
                if (end == -1) end = sql.Length;
                string name = sql.Substring(start + 1, end - start - 1);
                PropertyInfo pi = tType.GetProperty(name, flags);
                if (pi != null)
                {
                    object value = pi.GetValue(t, null);
                    DbParameter dp = new NpgsqlParameter("@" + name, value);
                    list.Add(dp);
                }
                start = sql.IndexOf("@", end);
            }
            return list;
        }
    }
}