Example #1
0
        private async void pb_shangchuan_Click(object sender, EventArgs e)
        {
            pb_shangchuangongxiang.Visible = true;
            pb_shangchuangeren.Visible     = false;

            //上传共享文件

            OpenFileDialog ofd = new OpenFileDialog();

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                string file = Path.GetFileName(ofd.FileName);

                JJFujianInfo info = new JJFujianInfo()
                {
                    _wenjianming       = file,
                    _chuangjianren     = JJLoginInfo._shiming,
                    _quanlujing        = $"{uripath}/{file}",
                    _chuangjianshijian = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"),
                    _xiazaicishu       = 0,
                    _kejian            = string.Empty,
                    _leixing           = "共享"
                };



                //添加控件,显示正在上传
                UCfujianInfo myuc = new UCfujianInfo(info)
                {
                    Dock = DockStyle.Top
                };
                panel_fujian.Controls.Add(myuc);

                Application.DoEvents();
                //开始上传
                myuc.lbl_info.Visible = true;
                myuc.lbl_info.Text    = "正在上传……";
                Application.DoEvents();
                //UpSound_Request(uripath, ofd.FileName, "xxx.zip", progressBar1);
                await JJMethod.UpLoadFile(ofd.FileName, uripath, false);

                InsertFile(info);

                //上传完之后,不显示正在上传
                myuc.lbl_info.Text    = string.Empty;
                myuc.lbl_info.Visible = false;
            }
        }
Example #2
0
 private async void UCfujianInfo_Load(object sender, EventArgs e)
 {
     if (_myinfo == null)
     {
         //判断文件是否存在,如果不存在上传,显示已上传,如果已经存在,直接显示已上传
         bool exist = ExistFile(path);
         lbl_wenjianming.Text = file;
         if (!exist)
         {
             JJFujianInfo info = new JJFujianInfo()
             {
                 _wenjianming       = file,
                 _chuangjianren     = JJLoginInfo._shiming,
                 _leixing           = "共享",
                 _quanlujing        = path,
                 _chuangjianshijian = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"),
                 _xiazaicishu       = 0,
             };
             InsertFile(info);
             lbl_info.Text = "正在上传……";
             await JJMethod.UpLoadFile(_filename, uripath, false);
         }
         lbl_info.Text = "已上传!";
     }
     else
     {
         lbl_wenjianming.Text      = _myinfo._wenjianming;
         lbl_chuangjianren.Text    = _myinfo._chuangjianren;
         lbl_chuangjianren.Visible = true;
         lbl_shijian.Text          = _myinfo._chuangjianshijian;
         lbl_shijian.Visible       = true;
         lbl_xiazai.Visible        = true;
         lbl_info.Visible          = false;
         pb_guanbi.Visible         = false;
         //共享文件可以看见垃圾桶,非共享文件可以
         if (!_myinfo._leixing.Equals("共享"))
         {
             pb_shanchu.Visible = true;
         }
         //创建人上传的共享任务可以设置可见范围,显示眼睛
         if (JJLoginInfo._shiming.Equals(_myinfo._chuangjianren) && _myinfo._leixing.Equals("共享"))
         {
             pb_kejian.Visible = true;
         }
     }
 }
Example #3
0
        /// <summary>
        /// 点击保存按钮时触发的事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void label5_Click(object sender, EventArgs e)
        {
            //先判断数据库中是否有登陆人创建的同名工作清单
            string str_sql = $"select count(*) from jjdbrenwutaizhang.通知公告表 " +
                             $"where 标题='{tb_biaoti.Text}'";
            int num = Convert.ToInt32(_mysql.ExecuteScalar(str_sql));

            //判断窗体的模式,如果是保存就提示名称已经存在并且return
            //如果是编辑模式,那么提示是否保存编辑,选择是之后,就update

            if (num > 0)
            {
                if (mode.Equals("创建"))
                {
                    MessageBox.Show("标题名称重复!请重新输入!");

                    return;
                }
                else if (mode.Equals("编辑"))
                {
                    //删除这条标题通知公告,为一会重新保存做准备
                    str_sql = $"delete from jjdbrenwutaizhang.通知公告表 " +
                              $"where 标题='{tb_biaoti.Text}'";
                    _mysql.ExecuteNonQuery(str_sql);
                }
            }
            //将内容保存到本地
            //这里为了防止通知过多,需要单独创建一个temp文件夹存放,通知的数量始终保持一个
            string localdir = $"{Environment.CurrentDirectory}\\temp";

            if (Directory.Exists(localdir))
            {
                //清空temp中的文件
                string[] files = Directory.GetFiles(localdir);
                File.Delete(files[0]);
            }
            else
            {
                Directory.CreateDirectory(localdir);
            }
            string filename = $"{localdir}\\{tb_biaoti.Text}.rtf";

            devUCrichtextbox1.richEditControl1.Document.SaveDocument(filename, DevExpress.XtraRichEdit.DocumentFormat.Rtf);
            //将本地文件上传到服务器,存放位置
            string uristring = $"http://49.233.40.109/通知公告";
            await JJMethod.UpLoadFile(filename, uristring, false);

            //将服务器地址赋值给tongzhiinfo的内容



            //分解阅读范围
            string[] person = Regex.Split(tb_yuedufanwei.Text, ",");
            foreach (string s in person)
            {
                //构造一个jjtongzhiinfo
                JJTongzhiInfo myinfo = new JJTongzhiInfo()
                {
                    _chuangjianren = JJLoginInfo._shiming,
                    _biaoti        = tb_biaoti.Text,
                    _qianfaren     = tb_wenhao.Text,
                    _neirongpath   = $"{ uristring}/{tb_biaoti.Text}.rtf",

                    _qingzhonghuanji = rb_putong.Checked ? "普通" : "紧急",
                    _zhuangtai       = "未读",

                    _fabushijian = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"),
                    _shixian     = dtp_shixian.Value.ToString("yyyy-MM-dd hh:mm:ss"),
                    _yuedufanwei = s
                };
                //保存jjtonzhiinfo
                _mycontroller.SaveTongzhi(myinfo);
            }



            MessageBox.Show("保存成功!");

            this.DialogResult = DialogResult.OK;
        }