Ejemplo n.º 1
0
        public async Task Add(SQueue queue, SMessage message)
        {
            var crmService = await getCrmService(queue.ServerName);

            CrmExecuteEntity entity = new CrmExecuteEntity(queue.Name, message.ID)
            {
                IsActivity = false,
                Attributes = new Dictionary <string, object>()
                {
                    { "ms_name", message.Key },
                    { "ms_type", message.Type },
                    { "ms_data", message.Data },
                    { "ms_delaymessageid", message.DelayMessageID?.ToString() },
                    { "ms_exceptionmessage", message.ExceptionMessage },
                    { "ms_expectationexecutetime", message.ExpectationExecuteTime },
                    { "ms_extensionmessage", message.ExtensionMessage },
                    { "ms_lastexecutetime", message.LastExecuteTime },
                    { "ms_retrynumber", message.RetryNumber },
                    { "ms_isdead", message.IsDead },
                }
            };

            var newID = await crmService.Create(entity);

            message.ID = newID;
        }
Ejemplo n.º 2
0
        public async Task UpdateLastExecuteTime(SQueue queue, Guid id)
        {
            //根据存储类型和服务器名称获取连接字符串
            var strConn = _messageQueueConnectionFactory.CreateAllForMessageQueue(queue.StoreType, queue.ServerName);
            await DBTransactionHelper.SqlTransactionWorkAsync(DBTypes.SqlServer, false, false, strConn, async (conn, transaction) =>
            {
                SqlTransaction sqlTran = null;
                if (transaction != null)
                {
                    sqlTran = (SqlTransaction)transaction;
                }

                await using (SqlCommand commond = new SqlCommand()
                {
                    Connection = (SqlConnection)conn,
                    CommandType = CommandType.Text,
                    Transaction = sqlTran,
                    CommandText = string.Format(@"update {0} set [lastexecutetime]=getutcdate() where [id]=@id", queue.Name)
                })
                {
                    SqlParameter parameter;

                    parameter = new SqlParameter("@id", SqlDbType.UniqueIdentifier)
                    {
                        Value = id
                    };
                    commond.Parameters.Add(parameter);

                    await commond.PrepareAsync();

                    await commond.ExecuteNonQueryAsync();
                }
            });
        }
Ejemplo n.º 3
0
Archivo: Form1.cs Proyecto: eier/sbc
        public Form1()
        {
            InitializeComponent();

            space = new XcoSpace(8000);

            // Example of builing a new XcoQueue with the SQueue wrapper.
            // To notifications are added, the first for debugging purpose, the second for keeping track of the occupancy.

            SQueue<Ei> unbemalteEier = new SQueue<Ei>(space, "UnbemalteEier");
            unbemalteEier.queue.AddNotificationForEntryEnqueued(this.unbemalteEierCB);
            unbemalteEier.count.AddNotificationForEntryEnqueued(this.unbemalteEierNotifyCB);

            SQueue<Ei> bemalteEier = new SQueue<Ei>(space, "BemalteEier");
            bemalteEier.queue.AddNotificationForEntryEnqueued(this.bemalteEierCB);
            bemalteEier.count.AddNotificationForEntryEnqueued(this.bemalteEierNotifyCB);

            SQueue<SchokoHase> schokoHasen = new SQueue<SchokoHase>(space, "SchokoHasen");
            schokoHasen.queue.AddNotificationForEntryEnqueued(this.schokoHasenCB);
            schokoHasen.count.AddNotificationForEntryEnqueued(this.schokoHasenNotifyCB);

            SQueue<Nest> nester = new SQueue<Nest>(space, "Nester");
            nester.queue.AddNotificationForEntryEnqueued(this.nesterCB);
            nester.count.AddNotificationForEntryEnqueued(this.nesterNotifyCB);

            SQueue<Nest> geliefert = new SQueue<Nest>(space, "Ausgeliefert");
            geliefert.queue.AddNotificationForEntryEnqueued(this.ausgeliefertCB);
            geliefert.count.AddNotificationForEntryEnqueued(this.ausgeliefertNotifyCB);

            space_uri = new Uri("xco://127.0.0.1:8000");
        }
Ejemplo n.º 4
0
    /// <summary>
    /// 复制(潜拷贝)
    /// </summary>
    protected override void toShadowCopy(BaseData data)
    {
        if (!(data is SystemPartData))
        {
            return;
        }

        SystemPartData mData = (SystemPartData)data;

        this.version                       = mData.version;
        this.serverTime                    = mData.serverTime;
        this.isBlock                       = mData.isBlock;
        this.flowStep                      = mData.flowStep;
        this.keepSave                      = mData.keepSave;
        this.clientRandomSeeds             = mData.clientRandomSeeds;
        this.clientRandomSeedIndex         = mData.clientRandomSeedIndex;
        this.clientOfflineWorkReceiveIndex = mData.clientOfflineWorkReceiveIndex;
        this.gmCommandSet                  = mData.gmCommandSet;
        this.gmType              = mData.gmType;
        this.serverBornCode      = mData.serverBornCode;
        this.serverStartTime     = mData.serverStartTime;
        this.logQueue            = mData.logQueue;
        this.nextDailyTime       = mData.nextDailyTime;
        this.createDate          = mData.createDate;
        this.clientRandomSeedKey = mData.clientRandomSeedKey;
    }
Ejemplo n.º 5
0
Archivo: Form1.cs Proyecto: eier/sbc
        public Form1()
        {
            InitializeComponent();

            space = new XcoSpace(8000);

            // Example of builing a new XcoQueue with the SQueue wrapper.
            // To notifications are added, the first for debugging purpose, the second for keeping track of the occupancy.

            SQueue<Ei> unbemalteEier = new SQueue<Ei>(space, "UnbemalteEier");
            unbemalteEier.queue.AddNotificationForEntryEnqueued(this.unbemalteEierCB);
            unbemalteEier.count.AddNotificationForEntryEnqueued(this.unbemalteEierNotifyCB);

            SQueue<Ei> bemalteEier = new SQueue<Ei>(space, "BemalteEier");
            bemalteEier.queue.AddNotificationForEntryEnqueued(this.bemalteEierCB);
            bemalteEier.count.AddNotificationForEntryEnqueued(this.bemalteEierNotifyCB);

            SQueue<SchokoHase> schokoHasen = new SQueue<SchokoHase>(space, "SchokoHasen");
            schokoHasen.queue.AddNotificationForEntryEnqueued(this.schokoHasenCB);
            schokoHasen.count.AddNotificationForEntryEnqueued(this.schokoHasenNotifyCB);

            SQueue<Nest> nester = new SQueue<Nest>(space, "Nester");
            nester.queue.AddNotificationForEntryEnqueued(this.nesterCB);
            nester.count.AddNotificationForEntryEnqueued(this.nesterNotifyCB);

            SQueue<Nest> geliefert = new SQueue<Nest>(space, "Ausgeliefert");
            geliefert.queue.AddNotificationForEntryEnqueued(this.ausgeliefertCB);
            geliefert.count.AddNotificationForEntryEnqueued(this.ausgeliefertNotifyCB);

            space_uri = new Uri("xco://127.0.0.1:8000");
        }
Ejemplo n.º 6
0
    /// <summary>
    /// 读取字节流(简版)
    /// </summary>
    protected override void toReadBytesSimple(BytesReadStream stream)
    {
        this.id = stream.readInt();

        this.price = stream.readInt();

        int daysLen = stream.readLen();

        if (this.days != null)
        {
            this.days.clear();
            this.days.ensureCapacity(daysLen);
        }
        else
        {
            this.days = new SQueue <CountData>();
        }

        SQueue <CountData> daysT = this.days;

        for (int daysI = daysLen - 1; daysI >= 0; --daysI)
        {
            CountData daysV;
            daysV = (CountData)stream.readDataSimpleNotNull();

            daysT.offer(daysV);
        }
    }
Ejemplo n.º 7
0
        public async Task AddToDead(SQueue queue, SMessage message)
        {
            if (!queue.IsDead)
            {
                throw new Exception(string.Format("SQueue {0}.{1} is not dead, can't be used in SMessageStoreForSQLDB.AddToDead", queue.GroupName, queue.Name));
            }

            var crmService = await getCrmService(queue.ServerName);

            CrmExecuteEntity entity = new CrmExecuteEntity(queue.Name, message.ID)
            {
                IsActivity = false,
                Attributes = new Dictionary <string, object>()
                {
                    { "ms_name", message.Key },
                    { "ms_type", message.Type },
                    { "ms_data", message.Data },
                    { "ms_delaymessageid", message.DelayMessageID?.ToString() },
                    { "ms_exceptionmessage", message.ExceptionMessage },
                    { "ms_expectationexecutetime", message.ExpectationExecuteTime },
                    { "ms_extensionmessage", message.ExtensionMessage },
                    { "ms_lastexecutetime", null },
                    { "ms_retrynumber", 0 },
                    { "ms_isdead", true },
                }
            };

            var newID = await crmService.Create(entity);

            message.ID = newID;
        }
Ejemplo n.º 8
0
        public async Task AddRetry(SQueue queue, Guid id, string exceptionMessage)
        {
            var crmService = await getCrmService(queue.ServerName);

            CrmRetrieveSignleAttributeRequestMessage request = new CrmRetrieveSignleAttributeRequestMessage()
            {
                EntityName    = queue.Name,
                EntityId      = id,
                AttributeName = "ms_retrynumber"
            };
            var response = (CrmRetrieveSignleAttributeResponseMessage)await crmService.Execute(request);

            var objRetry = response.Value.ToObject <int?>();
            int retry    = 0;

            if (objRetry.HasValue)
            {
                retry = objRetry.Value;
            }

            CrmExecuteEntity entity = new CrmExecuteEntity(queue.Name, id)
            {
                IsActivity = false,
                Attributes = new Dictionary <string, object>()
                {
                    { "ms_retrynumber", retry++ },
                }
            };
            await crmService.Update(entity);
        }
Ejemplo n.º 9
0
        public void TestEnqueue()
        {
            SQueue queue    = new SQueue(new Node(0));
            Node   testNode = new Node(100);

            queue.Enqueue(testNode);
            Assert.Equal(testNode, queue.Peek().Next);
        }
Ejemplo n.º 10
0
        public async Task <SQueue> QueryByCode(string groupName, bool isDead, int code)
        {
            SQueue queue = null;

            await DBTransactionHelper.SqlTransactionWorkAsync(DBTypes.SqlServer, true, false, _messageQueueConnectionFactory.CreateReadForMessageQueueMain(), async (conn, transaction) =>
            {
                SqlTransaction sqlTran = null;
                if (transaction != null)
                {
                    sqlTran = (SqlTransaction)transaction;
                }

                await using (SqlCommand commond = new SqlCommand()
                {
                    Connection = (SqlConnection)conn,
                    CommandType = CommandType.Text,
                    Transaction = sqlTran,
                    CommandText = string.Format(@"select {0} from SQueue where [groupname]=@groupname and [code]=@code and [isdead]=@isdead", StoreHelper.GetSQueueSelectFields(string.Empty))
                })
                {
                    var parameter = new SqlParameter("@groupname", SqlDbType.VarChar, 150)
                    {
                        Value = groupName
                    };
                    commond.Parameters.Add(parameter);

                    parameter = new SqlParameter("@code", SqlDbType.Int)
                    {
                        Value = code
                    };
                    commond.Parameters.Add(parameter);

                    parameter = new SqlParameter("@isdead", SqlDbType.Bit)
                    {
                        Value = isDead
                    };
                    commond.Parameters.Add(parameter);


                    await commond.PrepareAsync();

                    SqlDataReader reader = null;

                    await using (reader = await commond.ExecuteReaderAsync())
                    {
                        if (await reader.ReadAsync())
                        {
                            queue = new SQueue();
                            StoreHelper.SetSQueueSelectFields(queue, reader, string.Empty);
                        }

                        await reader.CloseAsync();
                    }
                }
            });

            return(queue);
        }
Ejemplo n.º 11
0
        public void TestDequeue()
        {
            Node   testNode1 = new Node(100);
            Node   testNode2 = new Node(999);
            SQueue queue     = new SQueue(testNode1);

            queue.Enqueue(testNode2);
            Assert.True(queue.Dequeue() == testNode1 && queue.Peek() == testNode2);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// 初始化初值
 /// </summary>
 public override void initDefault()
 {
     this.version = new SaveVersionData();
     this.version.initDefault();
     this.keepSave = new KeepSaveData();
     this.keepSave.initDefault();
     this.logQueue   = new SQueue <InfoLogData>();
     this.createDate = new DateData();
     this.createDate.initDefault();
 }
Ejemplo n.º 13
0
        public async Task <SMessage> QueryByKeyAndBeforeExpectTime(SQueue queue, string key, DateTime expectTime)
        {
            SMessage message = null;
            //根据存储类型和服务器名称获取连接字符串
            var strConn = _messageQueueConnectionFactory.CreateReadForMessageQueue(queue.StoreType, queue.ServerName);

            await DBTransactionHelper.SqlTransactionWorkAsync(DBTypes.SqlServer, true, false, strConn, async (conn, transaction) =>
            {
                SqlTransaction sqlTran = null;
                if (transaction != null)
                {
                    sqlTran = (SqlTransaction)transaction;
                }

                await using (SqlCommand commond = new SqlCommand()
                {
                    Connection = (SqlConnection)conn,
                    CommandType = CommandType.Text,
                    Transaction = sqlTran,
                    CommandText = string.Format(@"select top 1 {0} from {1} where [key]=@key and [expectationexecutetime]<@expectationexecutetime ", StoreHelper.GetSMessageSelectFields(string.Empty), queue.Name)
                })
                {
                    var parameter = new SqlParameter("@key", SqlDbType.VarChar, 150)
                    {
                        Value = key
                    };
                    commond.Parameters.Add(parameter);

                    parameter = new SqlParameter("@expectationexecutetime", SqlDbType.DateTime)
                    {
                        Value = expectTime
                    };
                    commond.Parameters.Add(parameter);

                    await commond.PrepareAsync();


                    SqlDataReader reader = null;

                    await using (reader = await commond.ExecuteReaderAsync())
                    {
                        if (await reader.ReadAsync())
                        {
                            message = new SMessage();
                            StoreHelper.SetSMessageSelectFields(message, reader, string.Empty);
                            message.Extensions[_queueName] = queue;
                        }

                        await reader.CloseAsync();
                    }
                }
            });

            return(message);
        }
Ejemplo n.º 14
0
    /// <summary>
    /// 复制(深拷贝)
    /// </summary>
    protected override void toCopy(BaseData data)
    {
        if (!(data is AuctionItemRecordData))
        {
            return;
        }

        AuctionItemRecordData mData = (AuctionItemRecordData)data;

        this.id = mData.id;

        this.price = mData.price;

        if (mData.days != null)
        {
            if (this.days != null)
            {
                this.days.clear();
                this.days.ensureCapacity(mData.days.size());
            }
            else
            {
                this.days = new SQueue <CountData>();
            }

            SQueue <CountData> daysT = this.days;
            if (!mData.days.isEmpty())
            {
                CountData[] daysVValues = mData.days.getValues();
                int         daysVMark   = mData.days.getMark();
                int         daysVStart  = mData.days.getStart();
                for (int daysVI = 0, daysVLen = mData.days.length(); daysVI < daysVLen; ++daysVI)
                {
                    CountData daysV = daysVValues[(daysVI + daysVStart) & daysVMark];
                    CountData daysU;
                    if (daysV != null)
                    {
                        daysU = (CountData)daysV.clone();
                    }
                    else
                    {
                        daysU = null;
                        nullObjError("daysU");
                    }

                    daysT.offer(daysU);
                }
            }
        }
        else
        {
            this.days = null;
            nullObjError("days");
        }
    }
Ejemplo n.º 15
0
        public async Task <SMessage> QueryByOriginalID(SQueue queue, Guid originalMessageID, Guid listenerID)
        {
            SMessage message = null;
            //根据存储类型和服务器名称获取连接字符串
            var strConn = _messageQueueConnectionFactory.CreateReadForMessageQueue(queue.StoreType, queue.ServerName);

            await DBTransactionHelper.SqlTransactionWorkAsync(DBTypes.SqlServer, true, false, strConn, async (conn, transaction) =>
            {
                SqlTransaction sqlTran = null;
                if (transaction != null)
                {
                    sqlTran = (SqlTransaction)transaction;
                }

                await using (SqlCommand commond = new SqlCommand()
                {
                    Connection = (SqlConnection)conn,
                    CommandType = CommandType.Text,
                    Transaction = sqlTran,
                    CommandText = string.Format(@"select top 1 {0} from {1} where [originalmessageid]=@originalmessageid and [listenerid]=@listenerid ", StoreHelper.GetSMessageSelectFields(string.Empty), queue.Name)
                })
                {
                    var parameter = new SqlParameter("@originalmessageid", SqlDbType.UniqueIdentifier)
                    {
                        Value = originalMessageID
                    };
                    commond.Parameters.Add(parameter);

                    parameter = new SqlParameter("@listenerid", SqlDbType.UniqueIdentifier)
                    {
                        Value = listenerID
                    };
                    commond.Parameters.Add(parameter);

                    await commond.PrepareAsync();


                    SqlDataReader reader = null;

                    await using (reader = await commond.ExecuteReaderAsync())
                    {
                        if (await reader.ReadAsync())
                        {
                            message = new SMessage();
                            StoreHelper.SetSMessageSelectFields(message, reader, string.Empty);
                            message.Extensions[_queueName] = queue;
                        }

                        await reader.CloseAsync();
                    }
                }
            });

            return(message);
        }
Ejemplo n.º 16
0
        static void Main(string[] args)
        {
            SQueue queue = MakeQueue(5, 50, 5);

            Console.WriteLine("Initial queue");
            ViewQueue(queue);
            queue.Enqueue(queue.Dequeue());
            Console.WriteLine("\nQueue after moving the front to the rear");
            ViewQueue(queue);
            Console.ReadKey();
        }
Ejemplo n.º 17
0
    /// <summary>
    /// 复制(潜拷贝)
    /// </summary>
    protected override void toShadowCopy(BaseData data)
    {
        if (!(data is ChatChannelData))
        {
            return;
        }

        ChatChannelData mData = (ChatChannelData)data;

        this.queue = mData.queue;
    }
Ejemplo n.º 18
0
        /// <summary>
        /// Displays the SQueue in the console.
        /// </summary>
        /// <param name="queue">The SQueue being displayed.</param>
        static void ViewQueue(SQueue queue)
        {
            Node node = queue.Peek();

            Console.Write("FRONT --> ");
            while (node != null)
            {
                Console.Write($"{node.Value} --> ");
                node = node.Next;
            }
            Console.Write("NULL\n");
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Creates and populates a SQueue.
        /// </summary>
        /// <param name="start">The value of the first node in the SQueue.</param>
        /// <param name="end">The maximum value for the nodes generated.</param>
        /// <param name="step">The difference in the values of adjacent nodes.</param>
        /// <returns>The resulting SQueue.</returns>
        static SQueue MakeQueue(int start, int end, int step)
        {
            Node   node  = new Node(start);
            SQueue queue = new SQueue(node);

            for (int i = start + step; i <= end; i += step)
            {
                node = new Node(i);
                queue.Enqueue(node);
            }
            return(queue);
        }
Ejemplo n.º 20
0
    /// <summary>
    /// 转文本输出
    /// </summary>
    protected override void toWriteDataString(DataWriter writer)
    {
        writer.writeTabs();
        writer.sb.Append("id");
        writer.sb.Append(':');
        writer.sb.Append(this.id);

        writer.writeEnter();
        writer.writeTabs();
        writer.sb.Append("price");
        writer.sb.Append(':');
        writer.sb.Append(this.price);

        writer.writeEnter();
        writer.writeTabs();
        writer.sb.Append("days");
        writer.sb.Append(':');
        writer.sb.Append("Queue<CountData>");
        if (this.days != null)
        {
            SQueue <CountData> daysT = this.days;
            int daysLen = daysT.size();
            writer.sb.Append('(');
            writer.sb.Append(daysLen);
            writer.sb.Append(')');
            writer.writeEnter();
            writer.writeLeftBrace();
            for (int daysI = 0; daysI < daysLen; ++daysI)
            {
                CountData daysV = daysT.get(daysI);
                writer.writeTabs();
                writer.sb.Append(daysI);
                writer.sb.Append(':');
                if (daysV != null)
                {
                    daysV.writeDataString(writer);
                }
                else
                {
                    writer.sb.Append("CountData=null");
                }

                writer.writeEnter();
            }
            writer.writeRightBrace();
        }
        else
        {
            writer.sb.Append("=null");
        }

        writer.writeEnter();
    }
Ejemplo n.º 21
0
    /// <summary>
    /// 读取字节流(完整版)
    /// </summary>
    protected override void toReadBytesFull(BytesReadStream stream)
    {
        stream.startReadObj();

        this.id = stream.readInt();

        this.price = stream.readInt();

        int daysLen = stream.readLen();

        if (this.days != null)
        {
            this.days.clear();
            this.days.ensureCapacity(daysLen);
        }
        else
        {
            this.days = new SQueue <CountData>();
        }

        SQueue <CountData> daysT = this.days;

        for (int daysI = daysLen - 1; daysI >= 0; --daysI)
        {
            CountData daysV;
            BaseData  daysVT = stream.readDataFullNotNull();
            if (daysVT != null)
            {
                if (daysVT is CountData)
                {
                    daysV = (CountData)daysVT;
                }
                else
                {
                    daysV = new CountData();
                    if (!(daysVT.GetType().IsAssignableFrom(typeof(CountData))))
                    {
                        stream.throwTypeReadError(typeof(CountData), daysVT.GetType());
                    }
                    daysV.shadowCopy(daysVT);
                }
            }
            else
            {
                daysV = null;
            }

            daysT.offer(daysV);
        }

        stream.endReadObj();
    }
Ejemplo n.º 22
0
    /// <summary>
    /// 复制(潜拷贝)
    /// </summary>
    protected override void toShadowCopy(BaseData data)
    {
        if (!(data is AuctionItemRecordData))
        {
            return;
        }

        AuctionItemRecordData mData = (AuctionItemRecordData)data;

        this.id    = mData.id;
        this.price = mData.price;
        this.days  = mData.days;
    }
Ejemplo n.º 23
0
    /// <summary>
    /// 复制(深拷贝)
    /// </summary>
    protected override void toCopy(BaseData data)
    {
        if (!(data is ChatChannelData))
        {
            return;
        }

        ChatChannelData mData = (ChatChannelData)data;

        if (mData.queue != null)
        {
            if (this.queue != null)
            {
                this.queue.clear();
                this.queue.ensureCapacity(mData.queue.size());
            }
            else
            {
                this.queue = new SQueue <RoleChatData>();
            }

            SQueue <RoleChatData> queueT = this.queue;
            if (!mData.queue.isEmpty())
            {
                RoleChatData[] queueVValues = mData.queue.getValues();
                int            queueVMark   = mData.queue.getMark();
                int            queueVStart  = mData.queue.getStart();
                for (int queueVI = 0, queueVLen = mData.queue.length(); queueVI < queueVLen; ++queueVI)
                {
                    RoleChatData queueV = queueVValues[(queueVI + queueVStart) & queueVMark];
                    RoleChatData queueU;
                    if (queueV != null)
                    {
                        queueU = (RoleChatData)queueV.clone();
                    }
                    else
                    {
                        queueU = null;
                        nullObjError("queueU");
                    }

                    queueT.offer(queueU);
                }
            }
        }
        else
        {
            this.queue = null;
            nullObjError("queue");
        }
    }
Ejemplo n.º 24
0
    /// <summary>
    /// 是否数据一致
    /// </summary>
    protected override bool toDataEquals(BaseData data)
    {
        ChatChannelData mData = (ChatChannelData)data;

        if (mData.queue != null)
        {
            if (this.queue == null)
            {
                return(false);
            }
            if (this.queue.size() != mData.queue.size())
            {
                return(false);
            }
            SQueue <RoleChatData> queueT = this.queue;
            SQueue <RoleChatData> queueR = mData.queue;
            int queueLen = queueT.size();
            for (int queueI = 0; queueI < queueLen; ++queueI)
            {
                RoleChatData queueU = queueT.get(queueI);
                RoleChatData queueV = queueR.get(queueI);
                if (queueV != null)
                {
                    if (queueU == null)
                    {
                        return(false);
                    }
                    if (!queueU.dataEquals(queueV))
                    {
                        return(false);
                    }
                }
                else
                {
                    if (queueU != null)
                    {
                        return(false);
                    }
                }
            }
        }
        else
        {
            if (this.queue != null)
            {
                return(false);
            }
        }

        return(true);
    }
Ejemplo n.º 25
0
        public async Task UpdateLastExecuteTime(SQueue queue, Guid id)
        {
            var crmService = await getCrmService(queue.ServerName);

            CrmExecuteEntity entity = new CrmExecuteEntity(queue.Name, id)
            {
                IsActivity = false,
                Attributes = new Dictionary <string, object>()
                {
                    { "ms_lastexecutetime", DateTime.UtcNow },
                }
            };
            await crmService.Update(entity);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// 为队列从DbDataReader中赋值
        /// </summary>
        /// <param name="queue"></param>
        /// <param name="reader"></param>
        /// <param name="prefix"></param>
        public static void SetSQueueSelectFields(SQueue queue, DbDataReader reader, string prefix)
        {
            queue.ID = (Guid)reader[string.Format("{0}id", prefix)];

            if (reader[string.Format("{0}groupname", prefix)] != DBNull.Value)
            {
                queue.GroupName = reader[string.Format("{0}groupname", prefix)].ToString();
            }

            if (reader[string.Format("{0}interval", prefix)] != DBNull.Value)
            {
                queue.Interval = (int)reader[string.Format("{0}interval", prefix)];
            }

            if (reader[string.Format("{0}storetype", prefix)] != DBNull.Value)
            {
                queue.StoreType = (int)reader[string.Format("{0}storetype", prefix)];
            }

            if (reader[string.Format("{0}servername", prefix)] != DBNull.Value)
            {
                queue.ServerName = reader[string.Format("{0}servername", prefix)].ToString();
            }

            if (reader[string.Format("{0}name", prefix)] != DBNull.Value)
            {
                queue.Name = reader[string.Format("{0}name", prefix)].ToString();
            }

            if (reader[string.Format("{0}code", prefix)] != DBNull.Value)
            {
                queue.Code = (int)reader[string.Format("{0}code", prefix)];
            }

            if (reader[string.Format("{0}isdead", prefix)] != DBNull.Value)
            {
                queue.IsDead = (bool)reader[string.Format("{0}isdead", prefix)];
            }

            if (reader[string.Format("{0}createtime", prefix)] != DBNull.Value)
            {
                queue.CreateTime = (DateTime)reader[string.Format("{0}createtime", prefix)];
            }

            if (reader[string.Format("{0}modifytime", prefix)] != DBNull.Value)
            {
                queue.ModifyTime = (DateTime)reader[string.Format("{0}modifytime", prefix)];
            }
        }
Ejemplo n.º 27
0
    /// <summary>
    /// 读取字节流(完整版)
    /// </summary>
    protected override void toReadBytesFull(BytesReadStream stream)
    {
        stream.startReadObj();

        int queueLen = stream.readLen();

        if (this.queue != null)
        {
            this.queue.clear();
            this.queue.ensureCapacity(queueLen);
        }
        else
        {
            this.queue = new SQueue <RoleChatData>();
        }

        SQueue <RoleChatData> queueT = this.queue;

        for (int queueI = queueLen - 1; queueI >= 0; --queueI)
        {
            RoleChatData queueV;
            BaseData     queueVT = stream.readDataFullNotNull();
            if (queueVT != null)
            {
                if (queueVT is RoleChatData)
                {
                    queueV = (RoleChatData)queueVT;
                }
                else
                {
                    queueV = new RoleChatData();
                    if (!(queueVT.GetType().IsAssignableFrom(typeof(RoleChatData))))
                    {
                        stream.throwTypeReadError(typeof(RoleChatData), queueVT.GetType());
                    }
                    queueV.shadowCopy(queueVT);
                }
            }
            else
            {
                queueV = null;
            }

            queueT.offer(queueV);
        }

        stream.endReadObj();
    }
Ejemplo n.º 28
0
        public async Task <SQueue> QueryById(Guid id)
        {
            SQueue queue = null;

            await DBTransactionHelper.SqlTransactionWorkAsync(DBTypes.SqlServer, true, false, _messageQueueConnectionFactory.CreateReadForMessageQueueMain(), async (conn, transaction) =>
            {
                SqlTransaction sqlTran = null;
                if (transaction != null)
                {
                    sqlTran = (SqlTransaction)transaction;
                }

                await using (SqlCommand commond = new SqlCommand()
                {
                    Connection = (SqlConnection)conn,
                    CommandType = CommandType.Text,
                    Transaction = sqlTran,
                    CommandText = string.Format(@"select {0} from SQueue where [id]=@id", StoreHelper.GetSQueueSelectFields(string.Empty))
                })
                {
                    var parameter = new SqlParameter("@id", SqlDbType.UniqueIdentifier)
                    {
                        Value = id
                    };
                    commond.Parameters.Add(parameter);

                    await commond.PrepareAsync();

                    SqlDataReader reader = null;

                    await using (reader = await commond.ExecuteReaderAsync())
                    {
                        if (await reader.ReadAsync())
                        {
                            queue = new SQueue();
                            StoreHelper.SetSQueueSelectFields(queue, reader, string.Empty);
                        }

                        await reader.CloseAsync();
                    }
                }
            });

            return(queue);
        }
Ejemplo n.º 29
0
 //* -----------------------------------------------------------------------*
 /// <summary>コルーチン操作キューをリストへ反映します。</summary>
 private void commitQueue()
 {
     while (operationQueue.Count > 0)
     {
         SQueue data = operationQueue.Dequeue();
         if (data.add)
         {
             coRoutines.AddLast(data.coRoutine);
         }
         else if (data.coRoutine == null)
         {
             coRoutines.Clear();
         }
         else
         {
             coRoutines.Remove(data.coRoutine);
         }
     }
 }
Ejemplo n.º 30
0
 /// <summary>
 /// 回池
 /// </summary>
 protected override void toRelease(DataPool pool)
 {
     this.version                       = null;
     this.serverTime                    = 0L;
     this.isBlock                       = false;
     this.flowStep                      = 0;
     this.keepSave                      = null;
     this.clientRandomSeeds             = null;
     this.clientRandomSeedIndex         = 0;
     this.clientOfflineWorkReceiveIndex = 0;
     this.gmCommandSet                  = null;
     this.gmType              = 0;
     this.serverBornCode      = 0;
     this.serverStartTime     = 0L;
     this.logQueue            = null;
     this.nextDailyTime       = 0L;
     this.createDate          = null;
     this.clientRandomSeedKey = 0;
 }
Ejemplo n.º 31
0
    /// <summary>
    /// 转文本输出
    /// </summary>
    protected override void toWriteDataString(DataWriter writer)
    {
        writer.writeTabs();
        writer.sb.Append("queue");
        writer.sb.Append(':');
        writer.sb.Append("Queue<RoleChatData>");
        if (this.queue != null)
        {
            SQueue <RoleChatData> queueT = this.queue;
            int queueLen = queueT.size();
            writer.sb.Append('(');
            writer.sb.Append(queueLen);
            writer.sb.Append(')');
            writer.writeEnter();
            writer.writeLeftBrace();
            for (int queueI = 0; queueI < queueLen; ++queueI)
            {
                RoleChatData queueV = queueT.get(queueI);
                writer.writeTabs();
                writer.sb.Append(queueI);
                writer.sb.Append(':');
                if (queueV != null)
                {
                    queueV.writeDataString(writer);
                }
                else
                {
                    writer.sb.Append("RoleChatData=null");
                }

                writer.writeEnter();
            }
            writer.writeRightBrace();
        }
        else
        {
            writer.sb.Append("=null");
        }

        writer.writeEnter();
    }