DataLoader/App.config | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
DataLoader/CS/Importor.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
DataLoader/CS/NtstWeb.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
DataLoader/DataLoader.csproj | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
DataLoader/MainWindow.xaml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
DataLoader/MainWindow.xaml.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
DataLoader/Model/Common.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
DataLoader/Model/CommonProp.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
DataLoader/App.config
@@ -1,6 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> <configuration> <appSettings> <add key="StartPath" value="1"/> <add key="SourcePath" value="D:\LF\import"/> <add key="TargetPath" value="D:\LF\upload"/> <!--<add key="pgConn" value="Server=127.0.0.1;Port=5433;Database=langfang;User Id=postgres;Password=postgres;"/>--> <add key="pgConn" value="Server=192.168.20.83;Port=5433;Database=moon;User Id=postgres;Password=Postgres!_14_moon;"/> </appSettings> DataLoader/CS/Importor.cs
@@ -87,12 +87,12 @@ vd.Meta = new SysMeta(); vd.Meta.name = fi.Name; vd.Meta.dirid = Common.DirId; //vd.Meta.dirid = Common.DirId; vd.Meta.depid = 1; vd.Meta.verid = 0; vd.Meta.type = fi.Extension.ToLower().Replace(".", ""); vd.Meta.sizes = Tools.SizeToMb(fi.Length); vd.Meta.create_user = Common.UserId; vd.Meta.create_user = CommonProp.UserId; } public static void ImportFiles(ObservableCollection<ViewData> viewDatas, string target, int start) DataLoader/CS/NtstWeb.cs
@@ -21,13 +21,13 @@ { if (uid > 0 && !string.IsNullOrEmpty(token)) { Common.UserId = uid; Common.Uname = uname; Common.Token = token; CommonProp.UserId = uid; CommonProp.Uname = uname; CommonProp.Token = token; owner.Dispatcher.Invoke(new Action(delegate { Common.Owner.SetLoginInfo(); CommonProp.Owner.SetLoginInfo(); })); } } DataLoader/DataLoader.csproj
@@ -138,7 +138,7 @@ <Compile Include="CS\MetaHelper.cs" /> <Compile Include="CS\StaticData.cs" /> <Compile Include="CS\Tools.cs" /> <Compile Include="Model\Common.cs" /> <Compile Include="Model\CommonProp.cs" /> <Compile Include="CS\ModelHandler.cs" /> <Compile Include="CS\NtstWeb.cs" /> <Compile Include="CS\PostgreHelper.cs" /> DataLoader/MainWindow.xaml
@@ -1,9 +1,9 @@ <Window x:Class="DataLoader.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="500" Width="750" Height="700" Width="900" Loaded="Window_Loaded" Title="æ°æ®å ¥åº v1.4" WindowStartupLocation="CenterScreen"> Title="影忰æ®å ¥åº v1.5" WindowStartupLocation="CenterScreen"> <Window.Resources> <Style x:Key="btn" TargetType="Button"> <Setter Property="Background" Value="#005699"/> @@ -38,31 +38,30 @@ </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="5*" /> <ColumnDefinition Width="18*" /> <ColumnDefinition Width="4*" /> <ColumnDefinition Width="18*" /> <ColumnDefinition Width="7*" /> <ColumnDefinition Width="20*" /> <ColumnDefinition Width="4*" /> <ColumnDefinition Width="20*" /> <ColumnDefinition Width="5*" /> </Grid.ColumnDefinitions> <Label Grid.Row="0" Grid.Column="0" Content="ç¨æ·IDï¼" VerticalAlignment="Center" HorizontalAlignment="Right" /> <TextBox x:Name="tbUid" Grid.Row="0" Grid.Column="1" Style="{StaticResource tb}" Text="1"/> <Label Grid.Row="0" Grid.Column="2" Content="ç®å½IDï¼" VerticalAlignment="Center" HorizontalAlignment="Right" /> <TextBox x:Name="tbDir" Grid.Row="0" Grid.Column="3" Style="{StaticResource tb}" Text="1"/> <!--<Label Grid.Row="0" Grid.Column="2" Content="令çï¼" VerticalAlignment="Center" HorizontalAlignment="Right" /> <TextBox x:Name="tbToken" Grid.Row="0" Grid.Column="3" Style="{StaticResource tb}"/> <Button Grid.Row="0" Grid.Column="4" Content="ç» å½" Style="{StaticResource btn}" Click="Login_MouseLeftButtonDown"/>--> <Button Grid.Row="0" Grid.Column="4" Content="设 ç½®" Style="{StaticResource btn}" Click="Login_MouseLeftButtonDown"/> <Label Grid.Row="0" Grid.Column="0" Content="ç¨æ·åï¼" VerticalAlignment="Center" HorizontalAlignment="Right" /> <TextBox Grid.Row="0" Grid.Column="1" Style="{StaticResource tb}" IsReadOnly="True" x:Name="tbUname"/> <Label Grid.Row="0" Grid.Column="2" Content="令çï¼" VerticalAlignment="Center" HorizontalAlignment="Right" /> <TextBox Grid.Row="0" Grid.Column="3" Style="{StaticResource tb}" IsReadOnly="True" x:Name="tbToken"/> <Button Grid.Row="0" Grid.Column="4" Content="ç» å½" Style="{StaticResource btn}" Click="Login_MouseLeftButtonDown"/> <Label Grid.Row="1" Grid.Column="0" Content="æ°æ®ç®å½ï¼" VerticalAlignment="Center" HorizontalAlignment="Right" /> <TextBox x:Name="tbSource" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" Style="{StaticResource tb}" Text="{Binding Path=SourcePath, Mode=TwoWay}"/> <Button x:Name="btnSource" Grid.Row="1" Grid.Column="4" Content="é æ©" Style="{StaticResource btn}" Click="Source_MouseLeftButtonDown"/> <Label Grid.Row="1" Grid.Column="0" Content="èµæºç®å½ï¼" VerticalAlignment="Center" HorizontalAlignment="Right" /> <TextBox Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" Style="{StaticResource tb}" x:Name="tbDir"/> <Button Grid.Row="1" Grid.Column="4" Content="é æ©" Style="{StaticResource btn}" Click="Dir_MouseLeftButtonDown" x:Name="btnDir"/> <Label Grid.Row="2" Grid.Column="0" Content="å ¥åºç®å½ï¼" VerticalAlignment="Center" HorizontalAlignment="Right" /> <TextBox x:Name="tbTarget" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" Style="{StaticResource tb}" Text="{Binding Path=TargetPath, Mode=TwoWay}"/> <Label Grid.Row="2" Grid.Column="0" Content="æ°æ®ç®å½ï¼" VerticalAlignment="Center" HorizontalAlignment="Right" /> <TextBox Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" Style="{StaticResource tb}" x:Name="tbSource"/> <Button Grid.Row="2" Grid.Column="4" Content="é æ©" Style="{StaticResource btn}" Click="Source_MouseLeftButtonDown" x:Name="btnSource"/> <Label Grid.Row="3" Grid.Column="0" Content="èµ·å§ç¼å·ï¼" VerticalAlignment="Center" HorizontalAlignment="Right" /> <TextBox x:Name="tbStart" Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="3" Style="{StaticResource tb}" Text="1"/> <Label Grid.Row="3" Grid.Column="0" Content="å ¥åºç®å½ï¼" VerticalAlignment="Center" HorizontalAlignment="Right" /> <TextBox Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="3" Style="{StaticResource tb}" x:Name="tbTarget"/> <Button Grid.Row="3" Grid.Column="4" Content="é æ©" Style="{StaticResource btn}" Click="Target_MouseLeftButtonDown" x:Name="btnTarget"/> <ScrollViewer Grid.Row="4" Grid.RowSpan="3" Grid.Column="0" Grid.ColumnSpan="4" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Margin="2"> <ListView x:Name="lvView"> @@ -85,8 +84,7 @@ </ListView> </ScrollViewer> <Button x:Name="btnTarget" Grid.Row="2" Grid.Column="4" Content="é æ©" Style="{StaticResource btn}" Click="Target_MouseLeftButtonDown"/> <Button x:Name="btnLoad" Grid.Row="3" Grid.Column="4" Content="å è½½" Style="{StaticResource btn}" Click="Load_MouseLeftButtonDown"/> <Button x:Name="btnImport" Grid.Row="4" Grid.Column="4" Content="导 å ¥" Style="{StaticResource btn}" Click="Import_MouseLeftButtonDown"/> <Button x:Name="btnLoad" Grid.Row="4" Grid.Column="4" Content="å è½½" Style="{StaticResource btn}" Click="Load_MouseLeftButtonDown"/> <Button x:Name="btnImport" Grid.Row="5" Grid.Column="4" Content="导 å ¥" Style="{StaticResource btn}" VerticalAlignment="Top" Click="Import_MouseLeftButtonDown"/> </Grid> </Window> DataLoader/MainWindow.xaml.cs
@@ -7,52 +7,17 @@ using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Forms.VisualStyles; using System.Windows.Threading; namespace DataLoader { public partial class MainWindow : Window, INotifyPropertyChanged public partial class MainWindow : Window { private ObservableCollection<ViewData> viewDatas = new ObservableCollection<ViewData>(); public event PropertyChangedEventHandler PropertyChanged; private string _sourcePath = @"D:\LF\data\mdb"; private string _targetPath = @"\\LAPTOP-DRTGLTU2\share"; private LoginWin win; public string SourcePath { get { return _sourcePath; } set { if (!String.IsNullOrEmpty(value) && Directory.Exists(value)) { _sourcePath = value; PropertyChanged(this, new PropertyChangedEventArgs("SourcePath")); } } } public string TargetPath { get { return _targetPath; } set { if (!String.IsNullOrEmpty(value) && Directory.Exists(value)) { _targetPath = value; PropertyChanged(this, new PropertyChangedEventArgs("TargetPath")); } } } public MainWindow() { @@ -60,15 +25,10 @@ this.DataContext = this; } protected virtual void OnPropertyChanged(string propertyName = null) { //PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } private void Window_Loaded(object sender, RoutedEventArgs e) { Common.Owner = this; CommonProp.Owner = this; CommonProp.Init(); this.btnLoad.IsEnabled = false; this.btnImport.IsEnabled = false; @@ -76,8 +36,7 @@ lvView.DataContext = viewDatas; lvView.SetBinding(ListView.ItemsSourceProperty, new Binding()); //String file = "E:\\data\\mpt\\A4mpt20131125.mpt"; //string md5 = MD5Helper.GetMD5Hash(file); // string md5 = MD5Helper.GetMD5Hash("E:\\data\\mpt\\A4mpt20131125.mpt"); LogOut.Info("************ åºç¨ç¨åºå¯å¨æåï¼ ************"); } @@ -87,9 +46,6 @@ win = new LoginWin(); this.Hide(); win.Show(); //SetLoginInfo(); //GdalHelper.Instance.ReadTiff(); } public void SetLoginInfo() @@ -100,69 +56,69 @@ //this.tbUid.Text = Tool.UserId.ToString(); //this.tbToken.Text = Tool.Token; string uidStr = this.tbUid.Text.Trim(); string didStr = this.tbDir.Text.Trim(); //string uidStr = this.tbUid.Text.Trim(); //string didStr = this.tbDir.Text.Trim(); int.TryParse(uidStr, out Common.UserId); int.TryParse(didStr, out Common.DirId); //int.TryParse(uidStr, out Common.UserId); //int.TryParse(didStr, out Common.DirId); this.btnLoad.IsEnabled = true; this.btnImport.IsEnabled = true; } // æºç®å½ // èµæºç®å½ private void Dir_MouseLeftButtonDown(object sender, RoutedEventArgs e) { } // æ°æ®ç®å½ private void Source_MouseLeftButtonDown(object sender, RoutedEventArgs e) { System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog(); if (!String.IsNullOrEmpty(SourcePath) && Directory.Exists(SourcePath)) dialog.SelectedPath = SourcePath; if (!String.IsNullOrEmpty(CommonProp.SourcePath) && Directory.Exists(CommonProp.SourcePath)) dialog.SelectedPath = CommonProp.SourcePath; System.Windows.Forms.DialogResult result = dialog.ShowDialog(); if (result == System.Windows.Forms.DialogResult.Cancel) { return; } if (result == System.Windows.Forms.DialogResult.Cancel) return; this.SourcePath = dialog.SelectedPath.Trim(); this.tbSource.Text = CommonProp.SourcePath = dialog.SelectedPath.Trim(); } // ç®æ ç®å½ private void Target_MouseLeftButtonDown(object sender, RoutedEventArgs e) { System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog(); if (!String.IsNullOrEmpty(TargetPath) && Directory.Exists(TargetPath)) dialog.SelectedPath = TargetPath; if (!String.IsNullOrEmpty(CommonProp.TargetPath) && Directory.Exists(CommonProp.TargetPath)) dialog.SelectedPath = CommonProp.TargetPath; System.Windows.Forms.DialogResult result = dialog.ShowDialog(); if (result == System.Windows.Forms.DialogResult.Cancel) { return; } if (result == System.Windows.Forms.DialogResult.Cancel) return; this.TargetPath = dialog.SelectedPath.Trim(); this.tbTarget.Text = CommonProp.TargetPath = dialog.SelectedPath.Trim(); } // å è½½ private void Load_MouseLeftButtonDown(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(SourcePath) || !Directory.Exists(SourcePath)) { MessageBox.Show("è¯·éæ©æ°æ®ç®å½ï¼", "æç¤º"); return; } if (string.IsNullOrEmpty(TargetPath) || !Directory.Exists(TargetPath)) { MessageBox.Show("è¯·éæ©å ¥åºç®å½ï¼", "æç¤º"); return; } //if (string.IsNullOrEmpty(SourcePath) || !Directory.Exists(SourcePath)) //{ // MessageBox.Show("è¯·éæ©æ°æ®ç®å½ï¼", "æç¤º"); // return; //} //if (string.IsNullOrEmpty(TargetPath) || !Directory.Exists(TargetPath)) //{ // MessageBox.Show("è¯·éæ©å ¥åºç®å½ï¼", "æç¤º"); // return; //} string[] files = Directory.GetFiles(SourcePath); if (null == files || files.Length == 0) { MessageBox.Show("æ°æ®ç®å½ä¸æ²¡ææä»¶ï¼", "æç¤º"); return; } //string[] files = Directory.GetFiles(SourcePath); //if (null == files || files.Length == 0) //{ // MessageBox.Show("æ°æ®ç®å½ä¸æ²¡ææä»¶ï¼", "æç¤º"); // return; //} this.viewDatas.Clear(); Importor.GetFiles(viewDatas, SourcePath); //this.viewDatas.Clear(); //Importor.GetFiles(viewDatas, SourcePath); } // å¯¼å ¥ @@ -170,15 +126,16 @@ { if (viewDatas.Count == 0) return; string str = this.tbStart.Text.Trim(); int start = 1; int.TryParse(str, out start); //string str = this.tbStart.Text.Trim(); //int start = 1; //int.TryParse(str, out start); Thread thread = new Thread(new ThreadStart(() => { Importor.ImportFiles(viewDatas, TargetPath, start); //Importor.ImportFiles(viewDatas, TargetPath, start); lvView.Dispatcher.BeginInvoke((ThreadStart)delegate { lvView.Dispatcher.BeginInvoke((ThreadStart)delegate { ICollectionView view = CollectionViewSource.GetDefaultView(viewDatas); view.Refresh(); }); DataLoader/Model/Common.cs
ÎļþÒÑɾ³ý DataLoader/Model/CommonProp.cs
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,142 @@ using DataLoader.CS; using System; using System.ComponentModel; using System.IO; namespace DataLoader.Model { /// <summary> /// éç¨å±æ§ç±» /// </summary> public class CommonProp // : INotifyPropertyChanged { /// <summary> /// åå§å /// </summary> public static void Init() { string startPath = Tools.GetSetting("StartPath"); int.TryParse(startPath, out StartPath); SourcePath = Tools.GetSetting("SourcePath"); TargetPath = Tools.GetSetting("TargetPath"); Owner.tbSource.Text = SourcePath; Owner.tbTarget.Text = TargetPath; } /// <summary> /// ææè /// </summary> public static MainWindow Owner; /// <summary> /// å¼å§ç®å½ /// </summary> public static int StartPath; /// <summary> /// ç¨æ·ID /// </summary> public static int UserId = 1; /// <summary> /// ç¨æ·å /// </summary> public static string Uname = "admin"; /// <summary> /// 令ç /// </summary> public static string Token; /// <summary> /// åä½ç¼ç /// </summary> public static string Depcode; /// <summary> /// åä½åç§° /// </summary> public static string Depname; /// <summary> /// ç®å½ç¼ç /// </summary> public static string Dircode; /// <summary> /// ç®å½åç§° /// </summary> public static string Dirname; /// <summary> /// ä¼ æå¨ç±»å /// </summary> public static string sensortype; /// <summary> /// ééæ¶é´ /// </summary> public static DateTime acq_time = DateTime.Now; /// <summary> /// å æ°æ®ç±»å /// </summary> public static string MetaType; /// <summary> /// æ°æ®ç®å½ /// </summary> public static string SourcePath; /// <summary> /// å ¥åºç®å½ /// </summary> public static string TargetPath; /*private string _sourcePath; /// <summary> /// æ°æ®æºç®å½ /// </summary> public string SourcePath { get { return _sourcePath; } set { if (!String.IsNullOrEmpty(value) && Directory.Exists(value)) { _sourcePath = value; PropertyChanged(this, new PropertyChangedEventArgs("SourcePath")); } } } private string _targetPath; /// <summary> /// ç®æ ç®å½ /// </summary> public string TargetPath { get { return _targetPath; } set { if (!String.IsNullOrEmpty(value) && Directory.Exists(value)) { _targetPath = value; PropertyChanged(this, new PropertyChangedEventArgs("TargetPath")); } } } public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged(string propertyName) { //PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); }*/ } }