Ejemplo n.º 1
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddGoods_Click(object sender, EventArgs e)
        {
            MessageAlert alert    = new MessageAlert();
            bool         isUpdate = false;

            if (CurrentGoods != null)
            {
                //保存商品到本地数据库
                int gid = LogicGoods.Instance.SaveGoods(CurrentGoods, MyUserInfo.currentUserId, out isUpdate);
                if (gid > 0)
                {
                    alert.Message = "保存成功!";
                    taskForm.LoadGoodsGridView();
                }
                else
                {
                    alert.Message = "商品采集失败!";
                }
            }
            else
            {
                alert.Message = "商品采集失败";
            }
            alert.Show();
        }
Ejemplo n.º 2
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            Button btn = sender as Button;

            if (btn.Tag.ToString().Equals("pic"))
            {
                if (this.openFileImage.ShowDialog() == DialogResult.OK)
                {
                    txtPicPath.Text = openFileImage.FileName;
                }
                this.openFileImage.Dispose();
            }
            else
            {
                if (this.openFileVideo.ShowDialog() == DialogResult.OK)
                {
                    var ret = this.openFileVideo.SafeFileName.Split('.');
                    ext = ret[ret.Length - 1];
                    using (Stream stream = this.openFileVideo.OpenFile())
                    {
                        long v = stream.Length / 1024 / 1024;
                        if (v < 20)
                        {
                            this.txtVideoPath.Text = this.openFileVideo.FileName;
                        }
                        else
                        {
                            MessageAlert alert = new MessageAlert("视频文件最大不能超过20M");
                            alert.Show();
                        }
                    }
                }
                this.openFileVideo.Dispose();
            }
        }
 /// <summary>
 /// 提示
 /// </summary>
 /// <param name="text"></param>
 public void AlertTip(string text)
 {
     if (this.InvokeRequired)
     {
         this.Invoke(new Action <string>(AlertTip), new object[] { text });
     }
     else
     {
         MessageAlert alert = new MessageAlert(text, "提示");
         alert.StartPosition = FormStartPosition.CenterScreen;
         alert.Show();
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 开始上传
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnStartUpdate_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(sourceFileName))
     {
         string fileName = Environment.CurrentDirectory + "\\temp\\video\\" + MyUserInfo.currentUserId.ToString();
         if (!Directory.Exists(fileName))
         {
             Directory.CreateDirectory(fileName);
         }
         fileName += "\\" + EncryptHelper.MD5(itemId) + "." + ext;
         File.Copy(sourceFileName, fileName, true);
         //TODO:将视频文件路径保存到数据库中
         sourceFileName = string.Empty;
         MessageAlert alert = new MessageAlert("上传成功");
         alert.StartPosition = FormStartPosition.CenterScreen;
         alert.Show(this);
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 开始发送
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnStartSend_Click(object sender, EventArgs e)
        {
            if (Running)
            {
                MessageAlert alert = new MessageAlert("正在发送,请稍后...");
                alert.StartPosition = FormStartPosition.CenterScreen;
                alert.Show();
                return;
            }
            List <WindowInfo> wins = WinApi.GetAllDesktopWindows();

            if (wins == null || wins.Count() == 0)
            {
                MessageAlert alert = new MessageAlert("未找到聊天窗口");
                alert.StartPosition = FormStartPosition.CenterScreen;
                alert.Show();
                return;
            }
            selecctItems.Clear();
            foreach (var item in lbWeChat.SelectedItems)
            {
                selecctItems.Add(item.ToString());
            }
            if (selecctItems.Count() == 0)
            {
                MessageAlert alert = new MessageAlert("请选择发送目标");
                alert.StartPosition = FormStartPosition.CenterScreen;
                alert.Show();
                return;
            }
            string PicFilePath   = txtPicPath.Text;
            string VideoFilePath = txtVideoPath.Text;
            string sendText      = txtTempText.Text;

            if (thread != null)
            {
                thread.Abort();
                thread = null;
            }
            ShowAlert("正在发送,请稍后...");
            Running = true;
            thread  = new System.Threading.Thread(() =>
            {
                try
                {
                    //发送图片
                    SendFile(wins, PicFilePath);

                    //发送文本
                    SendText(wins, sendText);

                    //发送视频文件
                    SendFile(wins, VideoFilePath, true);

                    ShowAlert("发送完成");
                    Running = false;
                }
                catch (System.Threading.ThreadAbortException)
                {
                }
                catch (Exception ex)
                {
                }
            });
            thread.IsBackground = true;
            thread.TrySetApartmentState(System.Threading.ApartmentState.STA);
            thread.Start();
        }