| | |
| | | using System.Collections.Generic; |
| | | using System.Collections.ObjectModel; |
| | | using System.Linq; |
| | | using System.Reflection; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | |
| | | { |
| | | 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)"; |
| | | |
| | |
| | | <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" /> |
| | |
| | | |
| | | private void Window_Loaded(object sender, RoutedEventArgs e) |
| | | { |
| | | web.Address = Main.BaseDir + "htmls\\login.html"; |
| | | web.Address = Tool.BaseDir + "htmls\\login.html"; |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | private void Window_Loaded(object sender, RoutedEventArgs e) |
| | | { |
| | | Main.Owner = this; |
| | | Tool.Owner = this; |
| | | |
| | | this.btnImport.IsEnabled = false; |
| | | lvView.DataContext = viewDatas; |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | { |
| | | 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(); |
| | | })); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | } |
| | | } |
| | | } |