コード例 #1
0
ファイル: tb_mqpath_partition_dal.cs プロジェクト: xwx2015/MQ
        public virtual bool Add2(DbConn PubConn, tb_mqpath_partition_model model)
        {
            List<ProcedureParameter> Par = new List<ProcedureParameter>()
                {

                    //ij·���µ�mq��id
                    new ProcedureParameter("@mqpathid",    model.mqpathid),
                    //����id���
                    new ProcedureParameter("@partitionid",    model.partitionid),
                    //����˳���(ij��·����mq��˳���)
                    new ProcedureParameter("@partitionindex",    model.partitionindex),
                    //ij·����mq��״̬,1 �����У�0 ������Ǩ�ƻ�ֹͣ��-1 ��ɾ��
                    new ProcedureParameter("@state",    model.state),
                };
            int rev = PubConn.ExecuteSql(@"insert into tb_mqpath_partition(mqpathid,partitionid,partitionindex,state,createtime)
                                           values(@mqpathid,@partitionid,@partitionindex,@state,getdate())", Par);
            return rev == 1;
        }
コード例 #2
0
ファイル: tb_mqpath_partition_dal.cs プロジェクト: xwx2015/MQ
        public virtual tb_mqpath_partition_model CreateModel(DataRow dr)
        {
            var o = new tb_mqpath_partition_model();

            //
            if(dr.Table.Columns.Contains("id"))
            {
                o.id = dr["id"].Toint();
            }
            //ij·���µ�mq��id
            if(dr.Table.Columns.Contains("mqpathid"))
            {
                o.mqpathid = dr["mqpathid"].Toint();
            }
            //����id���
            if(dr.Table.Columns.Contains("partitionid"))
            {
                o.partitionid = dr["partitionid"].Toint();
            }
            //����˳���(ij��·����mq��˳���)
            if(dr.Table.Columns.Contains("partitionindex"))
            {
                o.partitionindex = dr["partitionindex"].Toint();
            }
            //ij·����mq��״̬,1 �����У�0 ������Ǩ�ƻ�ֹͣ��-1 ��ɾ��
            if(dr.Table.Columns.Contains("state"))
            {
                o.state = dr["state"].ToByte();
            }
            //����ʱ��(�Ե�ǰ��ʱ��Ϊ׼)
            if(dr.Table.Columns.Contains("createtime"))
            {
                o.createtime = dr["createtime"].ToDateTime();
            }
            return o;
        }
コード例 #3
0
ファイル: tb_mqpath_partition_dal.cs プロジェクト: xwx2015/MQ
        public virtual bool Edit(DbConn PubConn, tb_mqpath_partition_model model)
        {
            List<ProcedureParameter> Par = new List<ProcedureParameter>()
            {

                    //ij·���µ�mq��id
                    new ProcedureParameter("@mqpathid",    model.mqpathid),
                    //����id���
                    new ProcedureParameter("@partitionid",    model.partitionid),
                    //����˳���(ij��·����mq��˳���)
                    new ProcedureParameter("@partitionindex",    model.partitionindex),
                    //ij·����mq��״̬,1 �����У�0 ������Ǩ�ƻ�ֹͣ��-1 ��ɾ��
                    new ProcedureParameter("@state",    model.state),
                    //����ʱ��(�Ե�ǰ��ʱ��Ϊ׼)
                    new ProcedureParameter("@createtime",    model.createtime)
            };
            Par.Add(new ProcedureParameter("@id",  model.id));

            int rev = PubConn.ExecuteSql("update tb_mqpath_partition set mqpathid=@mqpathid,partitionid=@partitionid,partitionindex=@partitionindex,state=@state,createtime=@createtime where id=@id", Par);
            return rev == 1;
        }
コード例 #4
0
        public ActionResult Add(tb_mqpath_partition_model model)
        {
            try
            {
                using (DbConn conn = DbConfig.CreateConn(DataConfig.MqManage))
                {
                    try
                    {
                        conn.Open();
                        conn.BeginTransaction();
                        model.state = (byte)XXF.BaseService.MessageQuque.BusinessMQ.SystemRuntime.EnumMqPathPartitionState.Running;
                        model.partitionindex = new tb_mqpath_partition_dal().GetMaxPartitionIndexOfMqPath(conn, model.mqpathid) + 1;
                        if (new tb_mqpath_dal().Get(conn, model.mqpathid) == null)
                        {
                            throw new Exception("无法找到队列");
                        }
                        if (new tb_mqpath_partition_dal().GetByPartitionId(conn, model.partitionid) != null)
                        {
                            throw new Exception("分区已被使用");
                        }
                        if (new tb_mqpath_partition_dal().CheckMaxPartitionIndexOfMqPathIsRunning(conn, model.mqpathid) == false)
                        {
                            throw new Exception("最后的分区未处于正常使用状态,若分区正在待删状态,请删除完毕后新增分区。");
                        }
                        if (new tb_mqpath_partition_dal().Add2(conn, model))
                        {
                            new tb_partition_dal().UpdateIsUsed(conn, 1, model.partitionid);
                            var partitioninfo = XXF.BaseService.MessageQuque.BusinessMQ.SystemRuntime.PartitionRuleHelper.GetPartitionIDInfo(model.partitionid);
                            //创建3天的表
                            var serverdate = conn.GetServerDate().Date;
                            for (int i = 0; i < 3; i++)
                            {
                                var currentdate = serverdate.AddDays(i);
                                var tablename = XXF.BaseService.MessageQuque.BusinessMQ.SystemRuntime.PartitionRuleHelper.GetTableName(partitioninfo.TablePartition, currentdate);//
                                SqlHelper.ExcuteSql(DataConfig.DataNodeParConn(partitioninfo.DataNodePartition + ""), (c) =>
                                {
                                    bool exsit = c.TableIsExist(tablename);
                                    if (exsit != true)
                                    {
                                        string cmd = DataConfig.MQCreateTableSql.Replace("{tablepartiton}", XXF.BaseService.MessageQuque.BusinessMQ.SystemRuntime.PartitionRuleHelper.PartitionNameRule(partitioninfo.TablePartition))
                                            .Replace("{daypartition}", currentdate.ToString("yyMMdd")).Replace("{datanodepartiton}", XXF.BaseService.MessageQuque.BusinessMQ.SystemRuntime.PartitionRuleHelper.PartitionNameRule(partitioninfo.DataNodePartition));
                                        c.ExecuteSql(cmd, new List<XXF.Db.ProcedureParameter>());
                                    }
                                });
                            }
                            conn.Commit();

                        }
                        else
                            throw new Exception("更新错误");

                    }
                    catch (Exception exp)
                    {
                        conn.Rollback();
                        throw exp;
                    }
                }
                ReStartQuque(model.mqpathid);
                return RedirectToAction("index");
            }
            catch (Exception e)
            {
                ModelState.AddModelError("Error", e.Message);
                return View(model);
            }
        }