Beispiel #1
0
        /// <summary>
        /// 重发
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void butsend_Click(object sender, EventArgs e)
        {
            DataView dv   = (DataView)dgveventlog.DataSource;
            int      nrow = dgveventlog.CurrentCell.RowIndex;

            DataRow[] rows = dv.Table.Select("选择=true", "id asc ");

            if (MessageBox.Show(this, "您确定要重发 [" + rows.Length.ToString() + "] 条消息吗?", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }

            RelationalDatabase db = new TrasenClasses.DatabaseAccess.MsSqlServer();

            db.Initialize(strConnectionString);

            try
            {
                db.BeginTransaction();

                for (int i = 0; i <= rows.Length - 1; i++)
                {
                    string id       = rows[i]["id"].ToString();
                    string bizid    = rows[i]["bizid"].ToString();
                    string sevent   = rows[i]["event"].ToString();
                    string CATEGORY = rows[i]["CATEGORY"].ToString();

                    string ssql = @"insert into event_mz_hjb(EVENT,CATEGORY,BIZID,MESSAGE,TS,ENABLE,RETURNDESC,finish)values('" + sevent + "','" + CATEGORY + "','" + bizid + "','',GETDATE(),1,'',0 )";

                    int n = db.DoCommand(ssql);
                    if (n > 0)
                    {
                        ssql = "update event_mz_hjb set finish=1,message='取消并已重新发送' where finish=0 and bizid='" + bizid + "' and event='" + sevent + "' and id=" + id + " ";
                        n    = db.DoCommand(ssql);
                        //if (n == 0) throw new Exception("没有影响到行,消息可行已被正常执行,无需重新发送");
                    }
                }

                db.CommitTransaction();
                MessageBox.Show("发送成功", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                butview_Click(null, null);
            }
            catch (System.Exception err)
            {
                InstanceForm.BDatabase.RollbackTransaction();
                MessageBox.Show(err.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                db.Close();
                db.Dispose();
            }
        }
Beispiel #2
0
        /// <summary>
        /// 设置消息状态
        /// </summary>
        /// <param name="IsDeal"></param>
        /// <param name="EmployeeId"></param>
        /// <param name="IpAddress"></param>
        public void SetStatus(bool IsDeal, int EmployeeId, string IpAddress)
        {
            //0,未处理,1、仅标记为已读,2、已做处理
            string sql = "update pub_message_record set DealStatus = {0},FirstReader={1},ReadTime=getdate(),ReadByIP = '{2}'  where MsgId = '{3}'";

            sql += " and FirstReader=0 and ReadTime is null and ReadByIP=''";
            if (IsDeal)
            {
                sql = string.Format(sql, 2, EmployeeId, IpAddress, this.messageId.ToString());
            }
            else
            {
                sql = string.Format(sql, 1, EmployeeId, IpAddress, this.messageId.ToString());
            }
            try
            {
                RelationalDatabase database = new TrasenClasses.DatabaseAccess.MsSqlServer();
                database.Initialize(TrasenFrame.Classes.WorkStaticFun.GetConnnectionString_Default(TrasenFrame.Classes.ConnectionType.SQLSERVER));
                database.Open();
                database.DoCommand(sql);
                database.Close();
            }
            catch (Exception error)
            {
                TrasenFrame.Forms.FrmMdiMain.WriteFrameLocalLog(new string[] { "更改消息状态失败!", error.Message, error.StackTrace }, true);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 取消执行消息
        /// </summary>
        /// <param name="ids"></param>
        public void CancelEventMzHjb(string[] ids)
        {
            RelationalDatabase db = new TrasenClasses.DatabaseAccess.MsSqlServer();

            db.Initialize(strConnectionString);
            try
            {
                string[] sqls = new string[ids.Length];
                for (int i = 0; i <= ids.Length - 1; i++)
                {
                    sqls[i] = "update event_mz_hjb set finish=2,returndesc='取消执行 By " + InstanceForm.BCurrentUser.Name + " at " + DateTime.Now.ToString() + "' where id=" + ids[i];
                }

                db.DoCommand(null, null, null, sqls);
            }
            catch
            {
            }
            finally
            {
                db.Close();
                db.Dispose();
            }
        }