예제 #1
0
        private void getCategoryButton_Click(object sender, RoutedEventArgs e)
        {
            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;
            }
        }
예제 #2
0
        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       = this.versionTextBox.Text;
            module.Detail        = this.descriptionTextBox.Text;
            module.DownNum       = 0;

            FileStream fs = File.OpenRead(this.appFileTextBox.Text);

            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.appFileTextBox.Text); // 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^_"));
                foreach (TypeItem item in this.categoryListBox.Items)
                {
                    module.ClassID    = item.ParentType;
                    module.SubClassID = item.Type;
                    service.AddApp(module, userId, Helper.GetMD5Hash(password), Helper.GetMD5Hash("$df9!d^_"));
                }
                this.uploadStatusTextBox.Text = "应用上传成功.";
                MessageBox.Show("应用上传成功", "应用上传", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (Exception ex)
            {
                this.uploadStatusTextBox.Text = string.Format("应用上传失败:{0}", ex.Message);
                MessageBox.Show(this.uploadStatusTextBox.Text, "应用上传", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            this.enableCtrls(true);
        }
예제 #3
0
        private void startButton_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(this.appFileTextBox.Text))
            {
                MessageBox.Show("请选择速学应用安装包文件。", "上传应用", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            this.enableCtrls(false);

            if (!ExtractPackFile())
            {
                MessageBox.Show("安装包格式不正确", "上传应用", MessageBoxButton.OK, MessageBoxImage.Error);
                this.enableCtrls(true);
                return;
            }

            string userId   = this.userIdTextBox.Text;
            string password = this.passwordTextBox.Password;

            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.appFileTextBox.Text);
            client.UploadFileAsync(new Uri(appUrl), "POST", this.appFileTextBox.Text);
        }