瀏覽代碼

zhao:修改上传

tags/录制修改前
耀 4 年之前
父節點
當前提交
0474a500cf

+ 10
- 8
Common/system/FileToolsCommon.cs 查看文件

@@ -300,13 +300,13 @@ namespace Common.system
300 300
         /// 获取一个文件的长度,单位为Byte  
301 301
         /// </summary>  
302 302
         /// <param name="filePath">文件的绝对路径</param>          
303
-        public static int GetFileSize(string filePath)
303
+        public static long GetFileSize(string filePath)
304 304
         {
305 305
             //创建一个文件对象  
306 306
             FileInfo fi = new FileInfo(filePath);
307 307
 
308 308
             //获取文件的大小  
309
-            return (int)fi.Length;
309
+            return fi.Length;
310 310
         }
311 311
 
312 312
         /// <summary>  
@@ -317,9 +317,10 @@ namespace Common.system
317 317
         {
318 318
             //创建一个文件对象  
319 319
             FileInfo fi = new FileInfo(filePath);
320
-            long size = fi.Length / 1024;
320
+            //double size = fi.Length / 1024;
321
+            double size = Math.Round(((double)fi.Length / 1024.0), 2, MidpointRounding.AwayFromZero);
321 322
             //获取文件的大小  
322
-            return double.Parse(size.ToString());
323
+            return size;
323 324
         }
324 325
 
325 326
         /// <summary>  
@@ -330,9 +331,10 @@ namespace Common.system
330 331
         {
331 332
             //创建一个文件对象  
332 333
             FileInfo fi = new FileInfo(filePath);
333
-            long size = fi.Length / 1024 / 1024;
334
+            //double size = fi.Length / 1024 / 1024;
335
+            double size = Math.Round(((double)fi.Length / 1024.0 / 1024.0), 2, MidpointRounding.AwayFromZero);
334 336
             //获取文件的大小  
335
-            return double.Parse(size.ToString());
337
+            return size;
336 338
         }
337 339
         #endregion
338 340
 
@@ -536,7 +538,7 @@ namespace Common.system
536 538
         public static byte[] FileToBytes(string filePath)
537 539
         {
538 540
             //获取文件的大小   
539
-            int fileSize = GetFileSize(filePath);
541
+            long fileSize = GetFileSize(filePath);
540 542
 
541 543
             //创建一个临时缓冲区  
542 544
             byte[] buffer = new byte[fileSize];
@@ -548,7 +550,7 @@ namespace Common.system
548 550
             try
549 551
             {
550 552
                 //将文件流读入缓冲区  
551
-                fs.Read(buffer, 0, fileSize);
553
+                fs.Read(buffer, 0, (int)fileSize);
552 554
 
553 555
                 return buffer;
554 556
             }

+ 53
- 8
XHWK.WKTool/App.cs 查看文件

@@ -4,6 +4,8 @@ using Common.system;
4 4
 using System;
5 5
 using System.Collections.Generic;
6 6
 using System.Diagnostics;
7
+using System.Reflection;
8
+using System.Security.Principal;
7 9
 using System.Security.RightsManagement;
8 10
 using System.Threading;
9 11
 using System.Windows;
@@ -123,15 +125,58 @@ namespace XHWK.WKTool
123 125
         [STAThread]
124 126
         private static void Main()
125 127
         {
126
-            // 定义Application对象作为整个应用程序入口
127
-            Application app = new Application();
128
-            UserInfo = new Model_UserInfo();
129
-             WKDataList = new List<Model_WKData>();
130
-            WKData = new Model_WKData();
131
-            VideoList = new List<Model_Video>();
128
+            try
129
+            {
130
+                UserInfo = new Model_UserInfo();
131
+                WKDataList = new List<Model_WKData>();
132
+                WKData = new Model_WKData();
133
+                VideoList = new List<Model_Video>();
134
+                #region 强制以管理员方式运行 修改人:赵耀 修改时间:2020年9月7日
135
+                WindowsIdentity identity = WindowsIdentity.GetCurrent();
136
+                WindowsPrincipal principal = new WindowsPrincipal(identity);
137
+                //判断当前登录用户是否为管理员
138
+                if (principal.IsInRole(WindowsBuiltInRole.Administrator))
139
+                {
140
+                    //如果是管理员,则直接运行
141
+                    W_CreateAMicroLessonWindow = new CreateAMicroLessonWindow();
142
+                    // 定义Application对象作为整个应用程序入口
143
+                    Application app = new Application();
144
+                    app.Run(W_CreateAMicroLessonWindow);
145
+                }
146
+                else
147
+                {
148
+                    //创建启动对象
149
+                    System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
150
+                    startInfo.UseShellExecute = true;
151
+                    startInfo.WorkingDirectory = Environment.CurrentDirectory;
152
+                    startInfo.FileName = Assembly.GetExecutingAssembly().Location;
153
+                    //设置启动动作,确保以管理员身份运行
154
+                    startInfo.Verb = "runas";
155
+                    try
156
+                    {
157
+                        System.Diagnostics.Process.Start(startInfo);
158
+                    }
159
+                    catch
160
+                    {
161
+                        return;
162
+                    }
163
+                    //退出
164
+                    Application.Current.Shutdown();
165
+
166
+                }
167
+                #endregion
168
+            }
169
+            catch (Exception ex)
170
+            {
171
+
172
+                string ErrMessage = "【进程】(Main):进程意外关闭。 " + ex.Message;
173
+                LogHelper.WriteErrLog(ErrMessage, ex);
174
+            }
175
+
132 176
             //app.DispatcherUnhandledException += MyApp_DispatcherUnhandledException;
133
-            W_CreateAMicroLessonWindow = new CreateAMicroLessonWindow();
134
-            app.Run(W_CreateAMicroLessonWindow);
177
+            //Application app = new Application();
178
+            //W_CreateAMicroLessonWindow = new CreateAMicroLessonWindow();
179
+            //app.Run(W_CreateAMicroLessonWindow);
135 180
             //LogHelper.WriteInfoLog("启动项目");
136 181
             StopSameProcess();
137 182
             Killffmpeg();

+ 1
- 1
XHWK.WKTool/CreateAMicroLessonWindow.xaml 查看文件

@@ -7,7 +7,7 @@
7 7
         mc:Ignorable="d"
8 8
         Title="MainWindow" Height="341" Width="454"   AllowsTransparency="True"
9 9
     ShowInTaskbar="False"
10
-    WindowStartupLocation="CenterOwner"
10
+    WindowStartupLocation="CenterScreen"
11 11
     WindowStyle="None">
12 12
     <Viewbox>
13 13
         <Grid Height="341" Width="454" >

+ 20
- 25
XHWK.WKTool/CreateAMicroLessonWindow.xaml.cs 查看文件

@@ -84,29 +84,7 @@ namespace XHWK.WKTool
84 84
                 System.Windows.MessageBox.Show("路径不可为空!");
85 85
                 return;
86 86
             }
87
-            APP.WKData.WkPath = FileToolsCommon.GetLegalPath(txbStoragePath.Text) + txbExplainName.Text.Trim() + "/";
88
-            if (APP.UserInfo != null)
89
-            {
90
-                if (!string.IsNullOrWhiteSpace(APP.UserInfo.Username))
91
-                {
92
-                    //判断课程是否存在
93
-                    if (APP.WKDataList.Exists(x => x.WkName == APP.WKData.WkName))
94
-                    {
95
-                        MessageBoxResult dr = System.Windows.MessageBox.Show("此微课已存在是否覆盖?", "提示", MessageBoxButton.OKCancel);
96
-                        if (dr == MessageBoxResult.OK)
97
-                        {
98
-                            FileToolsCommon.DeleteDirectory(APP.WKData.WkPath);
99
-                            FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
100
-                            APP.WKDataList.RemoveAll(x => x.WkName == APP.WKData.WkName);
101
-                        }
102
-                        else
103
-                        {
104
-                            return;
105
-                        }
106
-                    }
107
-                    APP.WKData.WkPath += APP.UserInfo.Username + "/";
108
-                }
109
-            }
87
+            APP.WKData.WkPath = FileToolsCommon.GetLegalPath(txbStoragePath.Text) + txbExplainName.Text.Trim() + "/"+APP.UserInfo.Username + "/";
110 88
             #endregion
111 89
             //创建文件夹
112 90
             FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
@@ -114,14 +92,31 @@ namespace XHWK.WKTool
114 92
             FileToolsCommon.SetConfigValue("VideoSavePath", txbStoragePath.Text);
115 93
             APP.WKData.WkName = txbExplainName.Text;
116 94
             APP.WKData.WkCreateDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
95
+            //判断微课是否存在,存在则询问
96
+            if (APP.WKDataList != null&& APP.WKDataList.Count>0)
97
+            {
98
+                if (APP.WKDataList.Exists(x => x.WkName == APP.WKData.WkName))
99
+                {
100
+                    MessageBoxResult dr = System.Windows.MessageBox.Show("此微课已存在是否覆盖?", "提示", MessageBoxButton.OKCancel);
101
+                    if (dr == MessageBoxResult.OK)
102
+                    {
103
+                        FileToolsCommon.DeleteDirectory(APP.WKData.WkPath);
104
+                        FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
105
+                        APP.WKDataList.RemoveAll(x => x.WkName == APP.WKData.WkName);
106
+                    }
107
+                    else
108
+                    {
109
+                        return;
110
+                    }
111
+                }
112
+            }
117 113
             if (APP.W_XHMicroLessonSystemWindow == null)
118 114
             {
119 115
                 APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow();
120 116
                 //APP.W_XHMicroLessonSystemWindow .Topmost = true;
121 117
             }
122
-            this.Hide();
123 118
             APP.W_XHMicroLessonSystemWindow.Show();
124
-          
119
+            this.Hide();
125 120
         }
126 121
         /// <summary>
127 122
         /// 窗体移动

+ 21
- 1
XHWK.WKTool/DAL/DAL_Upload.cs 查看文件

@@ -120,7 +120,27 @@ namespace XHWK.WKTool.DAL
120 120
             ErrMessage = "";
121 121
             try
122 122
             {
123
-                Model_Video VideoInfo = APP.VideoList.Find(x => x.FileGuid == VideoGuid);
123
+                Model_Video VideoInfo = null;
124
+                foreach (Model_WKData Vdata in APP.WKDataList)
125
+                {
126
+                    if (Vdata.VideoList == null)
127
+                        continue;
128
+                    foreach (Model_Video videoinfo in Vdata.VideoList)
129
+                    {
130
+                        if(videoinfo.FileGuid== VideoGuid)
131
+                        {
132
+                            VideoInfo = videoinfo;
133
+                            break;
134
+                        }
135
+                    }
136
+                    if (VideoInfo != null)
137
+                        break;
138
+                }
139
+                if (VideoInfo==null)
140
+                {
141
+                    ErrMessage = "未找到课程!";
142
+                    return false;
143
+                }
124 144
                 string UploadUrl = FileRequestAddress + "/chunkdb/upchunk";
125 145
                 if (VideoInfo.IsUpload)
126 146
                 {

+ 10
- 3
XHWK.WKTool/FileDirectoryWindow.xaml.cs 查看文件

@@ -40,6 +40,7 @@ namespace XHWK.WKTool
40 40
             LoadingVideoList();
41 41
             int i = 1;
42 42
             bool isColour = true;
43
+            pageData.menuList.Clear();
43 44
             //显示视频
44 45
             foreach (Model_Video videoinfo in model_VideoList)
45 46
             {
@@ -74,7 +75,6 @@ namespace XHWK.WKTool
74 75
                     vis= "Collapsed";
75 76
                     cos= "Visible";
76 77
                 }
77
-
78 78
                 pageData.menuList.Add(new FileDirectoryModel()
79 79
                 {
80 80
                     SerialNumber = i,
@@ -141,8 +141,15 @@ namespace XHWK.WKTool
141 141
                 if (buttons[i] == sender)
142 142
                 {
143 143
                     DAL_Upload dAL_Upload = new DAL_Upload();
144
-                    string msg = string.Empty;
145
-                    dAL_Upload.UploadVideo(pageData.menuList[i].FileGuid,out msg);
144
+                    if (dAL_Upload.UploadVideo(pageData.menuList[i].FileGuid, out string ErrMessage))
145
+                    {
146
+                        MessageBox.Show("视频上传成功!");
147
+                    }
148
+                    else
149
+                    {
150
+                        MessageBox.Show(ErrMessage);
151
+                    }
152
+                    
146 153
                 }
147 154
             }
148 155
         }

+ 3
- 1
XHWK.WKTool/LoginWindow.xaml.cs 查看文件

@@ -95,7 +95,9 @@ namespace XHWK.WKTool
95 95
                         }
96 96
                         else
97 97
                         {
98
-                            APP.W_CreateAMicroLessonWindow.Show();
98
+                            APP.W_CreateAMicroLessonWindow.Owner = this;
99
+                            //APP.W_CreateAMicroLessonWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
100
+                            APP.W_CreateAMicroLessonWindow.ShowDialog();
99 101
                         }
100 102
                     }
101 103
                 }

+ 38
- 34
XHWK.WKTool/XHMicroLessonSystemWindow.xaml.cs 查看文件

@@ -302,14 +302,14 @@ namespace XHWK.WKTool
302 302
             if(APP.fileDirectoryWindow==null)
303 303
             {
304 304
                 APP.fileDirectoryWindow = new FileDirectoryWindow();
305
-                APP.fileDirectoryWindow.Topmost = true;
305
+                //APP.fileDirectoryWindow.Topmost = true;
306 306
                 APP.fileDirectoryWindow.Owner = this;
307 307
             }
308 308
             else
309 309
             {
310
-                Initialize();
310
+                APP.fileDirectoryWindow.Initialize();
311 311
             }
312
-            APP.fileDirectoryWindow.Show();
312
+            APP.fileDirectoryWindow.ShowDialog();
313 313
         }
314 314
         /// <summary>
315 315
         /// 关闭事件
@@ -1042,36 +1042,6 @@ namespace XHWK.WKTool
1042 1042
         {
1043 1043
             if (IsSuspendR)
1044 1044
             {
1045
-                ImgPrint.Visibility = Visibility.Collapsed;//录制中不可打印
1046
-                ImgPrintTwo.Visibility = Visibility.Visible;
1047
-                btnPrint.IsEnabled = false;
1048
-
1049
-                ImgScreenshot.Visibility = Visibility.Collapsed;//录制中不可截图
1050
-                ImgScreenshotTwo.Visibility = Visibility.Visible;
1051
-                btnScreenshot.IsEnabled = false;
1052
-
1053
-                ImgImport.Visibility = Visibility.Collapsed;//录制中不可导入文档
1054
-                ImgImportTwo.Visibility = Visibility.Visible;
1055
-                btnImport.IsEnabled = false;
1056
-
1057
-                ImgScreenRecording.Visibility = Visibility.Collapsed;//录制中不可录屏
1058
-                ImgScreenRecordingTwo.Visibility = Visibility.Visible;
1059
-                btnScreenRecording.IsEnabled = false;
1060
-
1061
-                ImgUpload.Visibility = Visibility.Collapsed;//录制中不可上传
1062
-                ImgUploadTwo.Visibility = Visibility.Visible;
1063
-                btnUpload.IsEnabled = false;
1064
-
1065
-                ImgMyMine.Visibility = Visibility.Collapsed;//录制中不可点击我的
1066
-                ImgMyMineTwo.Visibility = Visibility.Visible;
1067
-                btnMyMine.IsEnabled = false;
1068
-
1069
-                ImgSetUp.Visibility = Visibility.Collapsed;//录制中不可设置
1070
-                ImgSetUpTwo.Visibility = Visibility.Visible;
1071
-                btnSetUp.IsEnabled = false;
1072
-
1073
-                btnLoginType.IsEnabled = false;
1074
-
1075 1045
                 if (IsFirstR)//是否第一次录制  初始化录制
1076 1046
                 {
1077 1047
                     VideoInfo = new Model_Video();
@@ -1107,6 +1077,39 @@ namespace XHWK.WKTool
1107 1077
                             return;
1108 1078
                         }
1109 1079
                     }
1080
+
1081
+                    #region 禁用按钮
1082
+                    ImgPrint.Visibility = Visibility.Collapsed;//录制中不可打印
1083
+                    ImgPrintTwo.Visibility = Visibility.Visible;
1084
+                    btnPrint.IsEnabled = false;
1085
+
1086
+                    ImgScreenshot.Visibility = Visibility.Collapsed;//录制中不可截图
1087
+                    ImgScreenshotTwo.Visibility = Visibility.Visible;
1088
+                    btnScreenshot.IsEnabled = false;
1089
+
1090
+                    ImgImport.Visibility = Visibility.Collapsed;//录制中不可导入文档
1091
+                    ImgImportTwo.Visibility = Visibility.Visible;
1092
+                    btnImport.IsEnabled = false;
1093
+
1094
+                    ImgScreenRecording.Visibility = Visibility.Collapsed;//录制中不可录屏
1095
+                    ImgScreenRecordingTwo.Visibility = Visibility.Visible;
1096
+                    btnScreenRecording.IsEnabled = false;
1097
+
1098
+                    ImgUpload.Visibility = Visibility.Collapsed;//录制中不可上传
1099
+                    ImgUploadTwo.Visibility = Visibility.Visible;
1100
+                    btnUpload.IsEnabled = false;
1101
+
1102
+                    ImgMyMine.Visibility = Visibility.Collapsed;//录制中不可点击我的
1103
+                    ImgMyMineTwo.Visibility = Visibility.Visible;
1104
+                    btnMyMine.IsEnabled = false;
1105
+
1106
+                    ImgSetUp.Visibility = Visibility.Collapsed;//录制中不可设置
1107
+                    ImgSetUpTwo.Visibility = Visibility.Visible;
1108
+                    btnSetUp.IsEnabled = false;
1109
+
1110
+                    btnLoginType.IsEnabled = false;
1111
+                    #endregion
1112
+
1110 1113
                     IsFirstR = false;
1111 1114
                     RsImgName = new List<string>();
1112 1115
                     timer = new System.Timers.Timer(200);//设置执行一次(false)还是一直执行(true)
@@ -1273,10 +1276,11 @@ namespace XHWK.WKTool
1273 1276
                             Thread.Sleep(100);
1274 1277
                         }
1275 1278
                         FileToolsCommon.DeleteFile(ThumbnailPathName);
1276
-                        VideoInfo.VideoSize = FileToolsCommon.GetFileSizeByMB(VideoSavePathName).ToString() + " MB";
1277 1279
                         VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
1278 1280
                         VideoInfo.VideoPath = VideoSavePathName;
1279 1281
                         VideoInfo.ThumbnailPath = ThumbnailPathName;
1282
+                        Thread.Sleep(500);
1283
+                        VideoInfo.VideoSize = FileToolsCommon.GetFileSizeByMB(VideoSavePathName).ToString() + " MB";
1280 1284
                         APP.FFmpeg.GenerateThumbnails(VideoSavePathName, ThumbnailPathName);
1281 1285
                         VideoInfo.FileGuid = Guid.NewGuid().ToString();
1282 1286
                         VideoInfo.IsUpload = false;

Loading…
取消
儲存