コード例 #1
0
        /// <summary>
        /// Kbase数据导出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnExportKbase_Click(object sender, EventArgs e)
        {
            Dictionary<string, string> ExportDics = new Dictionary<string, string>();
            if (string.IsNullOrEmpty(txbTable.Text))
            {
                XtraMessageBox.Show("请输入Kbase表名...", "提示");
                return;
            }


            var sa = gridView2.GetSelectedRows();
            foreach (var item in sa)
            {
                dynamic d = gridView2.GetRow(item) as dynamic;
                ExportDics.Add(d.KbaseB, d.KbaseE);
            }

            if (ExportDics.Count == 0)
            {
                XtraMessageBox.Show("请选择导出的字段...", "提示");
                return;
            }
            var tt = Task.Run(() =>
            {
                return KbaseHelper.ExportData(txbTable.Text, txbWhere.Text, ExportDics, btnSavePath.Text, ReportKbaseProgress);
            });

            tt.ContinueWith(t =>
            {
                this.Invoke((MethodInvoker)delegate
                {
                    XtraMessageBox.Show(t.Result.Item2, t.Result.Item1 ? "导出成功" : "导出失败");
                });
            });
        }
コード例 #2
0
        /// <summary>
        /// 上传更新文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnUpload_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(labOK.Text))
            {
                XtraMessageBox.Show("Kbase表名无效!");
                return;
            }

            var FileName = btnLoadFiles.Text;
            if (Path.GetExtension(FileName).ToLower() != ".txt")
            {
                XtraMessageBox.Show("仅支持REC文件!");
                return;
            }


            btnUpload.Enabled = false;
            var t = Task.Run(() =>
            {
                try
                {
                    var BaseDir = @"\\192.168.106.60\RecFiles\机标关键词";
                    Directory.CreateDirectory(BaseDir);
                    var BaseFileName = Path.GetFileName(FileName);
                    this.Invoke((MethodInvoker)delegate
                    {
                        txbProcessor.Text += "正在拷贝文件..." + Environment.NewLine;
                    });
                    File.Copy(FileName, Path.Combine(BaseDir, BaseFileName), true);
                    this.Invoke((MethodInvoker)delegate
                    {
                        txbProcessor.Text += "正在上传数据..." + Environment.NewLine;
                    });

                    var ur = KbaseHelper.UploadData(txbKbasename.Text, BaseFileName);
                    this.Invoke((MethodInvoker)delegate
                    {
                        txbProcessor.Text += ur.Item2 + Environment.NewLine;
                        txbProcessor.Text += $"完成!上传{(ur.Item1 ? "成功" : "失败")}!";
                    });
                }
                catch (Exception ee)
                {
                    this.Invoke((MethodInvoker)delegate
                    {
                        txbProcessor.Text += ee.Message;
                    });
                }
            });

            t.ContinueWith(st =>
            {
                this.Invoke((MethodInvoker)delegate
                {
                    btnUpload.Enabled = true;
                });
            });

        }
コード例 #3
0
        /// <summary>
        /// 同步上传时,KbaseName 发生变化时
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txbKbasename_EditValueChanged(object sender, EventArgs e)
        {
            var tableName = txbKbasename.Text;

            if (KbaseHelper.GetCols(tableName).Count == 0)
                labOK.Text = string.Empty;
            else
                labOK.Text = "√";
        }
コード例 #4
0
        /// <summary>
        /// Kbase导出数据,Kbase表名发生变化时
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txbTable_EditValueChanged(object sender, EventArgs e)
        {
            var tableName = txbTable.Text;
            var Cols = KbaseHelper.GetCols(tableName);

            if (Cols == null || Cols.Count == 0)
                return;
            List<dynamic> Datas = new List<dynamic>();

            foreach (var item in Cols)
            {
                dynamic data = new ExpandoObject();
                data.KbaseB = item;
                data.KbaseE = string.Empty;
                Datas.Add(data);
            }
            repositoryItemComboBox2.Items.AddRange(new List<string> { "文件名", "正文", "题名", "关键词", "摘要", "主题" });
            gridKbase.DataSource = Datas;

        }
コード例 #5
0
 private void MainFrame_FormClosing(object sender, FormClosingEventArgs e)
 {
     KbaseHelper.Dispose();
 }