private void Window_Loaded(object sender, RoutedEventArgs e) { this.Dispatcher.BeginInvoke(new Action(() => { Cursor cursor = this.Cursor; try { this.Cursor = Cursors.Wait; AppServerSoapClient service = new AppServerSoapClient(); service.Endpoint.Address = new System.ServiceModel.EndpointAddress(@"http://www.soonlearning.com/WebServers/AppServer.asmx"); string[] result = service.GetAppClass(Helper.GetMD5Hash("$af3#d_&")); this.GetMainTypes(result); } catch (Exception ex) { MessageBox.Show(ex.Message, "上传应用", MessageBoxButton.OK, MessageBoxImage.Error); } finally { this.Cursor = cursor; } } ), DispatcherPriority.Background, null); }
private void okButton_Click(object sender, RoutedEventArgs e) { userId = this.idTextBox.Text; password = this.passwordTextBox.Password; if (string.IsNullOrEmpty(userId)) { MessageBox.Show("请输入用户Id或者邮箱。", "登陆", MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (string.IsNullOrEmpty(password)) { MessageBox.Show("请输入密码。", "登陆", MessageBoxButton.OK, MessageBoxImage.Warning); return; } Cursor cursor = this.Cursor; try { this.Cursor = Cursors.Wait; AppServerSoapClient service = new AppServerSoapClient(); service.Endpoint.Address = new System.ServiceModel.EndpointAddress(@"http://www.soonlearning.com/WebServers/AppServer.asmx"); string result = service.GetLoginName(userId, Helper.GetMD5Hash(password), Helper.GetMD5Hash("4%!@s*&d")); if (!string.IsNullOrEmpty(result)) { string[] parts = result.Split(new string[] { "||" }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length >= 3) { if (Convert.ToInt32(parts[2]) != 3) { MessageBox.Show("该账户不是教师账户,请先申请注册为教师账户,再上传应用。", "登陆", MessageBoxButton.OK, MessageBoxImage.Warning); return; } else { this.DialogResult = true; this.Close(); } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "上传应用", MessageBoxButton.OK, MessageBoxImage.Error); } finally { this.Cursor = cursor; } }
private void startButton_Click(object sender, RoutedEventArgs e) { TypeItem typeItem = this.subCategoryComboBox.SelectedItem as TypeItem; if (typeItem == null) { MessageBox.Show("请选择应用分类。", "上传应用", MessageBoxButton.OK, MessageBoxImage.Warning); return; } ProjectMgr.Instance.App.Type = typeItem.ParentType; ProjectMgr.Instance.App.SubType = typeItem.Type; this.packageFile = ProjectMgr.Instance.CreateAppPackage(); MessageBox.Show("应用在发布到速学应用平台服务器之前已经成功安装到您本地的速学应用平台中,您可以打开速学应用平台查看您的应用。", "上传应用", MessageBoxButton.OK, MessageBoxImage.Information); if (string.IsNullOrEmpty(this.packageFile)) { MessageBox.Show("请选择速学应用安装包文件。", "上传应用", MessageBoxButton.OK, MessageBoxImage.Warning); return; } this.enableCtrls(false); if (!ExtractPackFile()) { MessageBox.Show("安装包格式不正确。", "上传应用", MessageBoxButton.OK, MessageBoxImage.Error); this.enableCtrls(true); return; } if (string.IsNullOrEmpty(userId)) { MessageBox.Show("请输入用户ID", "上传应用", MessageBoxButton.OK, MessageBoxImage.Error); this.enableCtrls(true); return; } if (string.IsNullOrEmpty(password)) { MessageBox.Show("请输入用户密码", "上传应用", MessageBoxButton.OK, MessageBoxImage.Error); this.enableCtrls(true); return; } try { AppServerSoapClient service = new AppServerSoapClient(); service.Endpoint.Address = new System.ServiceModel.EndpointAddress(@"http://www.soonlearning.com/WebServers/AppServer.asmx"); int ret = service.CheckApp(userId, Helper.GetMD5Hash(password), appItem.Id, Helper.GetMD5Hash("$df9!d^_")); if (ret == 1) { string message = "该应用已经上传到服务器上,你确定要更新该应用吗?"; if (MessageBox.Show(message, "上传应用", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No) { this.enableCtrls(false); return; } } else if (ret == 2) { string message = "该应用已经由其他用户上传到速学应用平台,你不能修改并上传该应用!"; MessageBox.Show(message, "上传应用", MessageBoxButton.OK, MessageBoxImage.Information); { this.enableCtrls(false); return; } } else if (ret == 0) { } else { string message = "检查应用时发生了未知错误!"; MessageBox.Show(message, "上传应用", MessageBoxButton.OK, MessageBoxImage.Information); this.enableCtrls(false); return; } } catch (Exception ex) { MessageBox.Show(ex.Message, "上传应用", MessageBoxButton.OK, MessageBoxImage.Error); this.enableCtrls(true); return; } this.uploadStatusTextBox.Text = "正在上传应用安装包..."; if (client != null) { client.Dispose(); client = null; } client = new WebClient(); client.Headers.Add("AddApp", "{A298CC02-CE4B-4B69-A1B5-94FF344C6B95}"); client.UploadProgressChanged += ((s, e1) => { this.uploadProgressBar.Value = e1.BytesSent * 100 / e1.TotalBytesToSend; }); client.UploadFileCompleted += ((s, e1) => { if (e1.Error != null) { this.uploadProgressBar.Value = 0; this.uploadStatusTextBox.Text = "上传应用失败:" + e1.Error.Message; this.enableCtrls(true); } else if (e1.Cancelled) { this.uploadProgressBar.Value = 0; this.uploadStatusTextBox.Text = "上传应用过程被取消"; this.enableCtrls(true); } else { this.uploadProgressBar.Value = 100; // if (this.thumbnailListBox.Items.Count > 0) { this.snapshotUploadingIndex = 0; this.Dispatcher.BeginInvoke(new ThreadStart(() => { // if (this.thumbnailListBox.Items.Count == 0) { this.uploadIcon(); } // else { // this.uploadSnapshot(this.thumbnailListBox.Items[this.snapshotUploadingIndex] as ThumbnailInfo); } }), DispatcherPriority.Background, null); } } }); this.appUrl = this.CreateAppUri("Apps/Packages", this.packageFile); client.UploadFileAsync(new Uri(appUrl), "POST", this.packageFile); }
private void addApp() { if (client != null) { client.Dispose(); client = null; } double price = 0.0f; if (!double.TryParse(this.priceTextBox.Text, out price)) { } // string userId = this.userIdTextBox.Text; // string password = this.passwordTextBox.Password; if (string.IsNullOrEmpty(userId)) { MessageBox.Show("请输入用户ID", "上传应用", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (string.IsNullOrEmpty(password)) { MessageBox.Show("请输入用户密码", "上传应用", MessageBoxButton.OK, MessageBoxImage.Error); return; } APKSoftModel module = new APKSoftModel(); module.AddDate = DateTime.Now.ToUniversalTime(); module.Attach = new APKAttachModel(); module.Attach.Image1 = this.getSnapshot(0); module.Attach.Image2 = this.getSnapshot(1); module.Attach.Image3 = this.getSnapshot(2); module.Attach.Image4 = this.getSnapshot(3); module.Attach.Image5 = this.getSnapshot(4); module.ClassID = this.appItem.AppType; module.SubClassID = this.appItem.AppSubType; module.TopicNum = 0; module.UniqueId = this.appItem.Id; module.UserID = 0; // TODO module.Version = ProjectMgr.Instance.App.Version; module.Detail = this.descriptionTextBox.Text; module.DownNum = 0; FileStream fs = File.OpenRead(this.packageFile); module.Filesize = new decimal(fs.Length); fs.Close(); module.FileUrl = this.appUrl; module.ICON = this.iconUrl; module.IsIndex = 0; // TODO; module.IsNew = 1; module.IsUse = 0; module.Md5Check = GetMD5HashFromFile(this.packageFile); // TODO module.Name = this.appItem.Title; module.Price = new decimal(price); module.Sketch = this.appItem.Description; module.SubClassID = this.appItem.AppSubType; try { AppServerSoapClient service = new AppServerSoapClient(); service.Endpoint.Address = new System.ServiceModel.EndpointAddress(@"http://www.soonlearning.com/WebServers/AppServer.asmx"); service.AddApp(module, userId, Helper.GetMD5Hash(password), Helper.GetMD5Hash("$df9!d^_")); TypeItem item = this.subCategoryComboBox.SelectedItem as TypeItem; { module.ClassID = item.ParentType; module.SubClassID = item.Type; service.AddApp(module, userId, Helper.GetMD5Hash(password), Helper.GetMD5Hash("$df9!d^_")); } this.uploadStatusTextBox.Text = "应用上传成功."; } catch (Exception ex) { this.uploadStatusTextBox.Text = string.Format("应用上传失败:{0}", ex.Message); } this.enableCtrls(true); }