コード例 #1
0
 public DistributorModule(CollectorModel model, AsyncTaskModule asyncTaskModule,
                          AsyncTasksConfiguration asyncPing)
 {
     _model           = model;
     _asyncTaskModule = asyncTaskModule;
     _asyncPing       = asyncPing;
 }
コード例 #2
0
        public Operation <long> CreateCollector(CollectorModel model)
        {
            return(Operation.Create(() =>
            {
                var collector = _repo.Query <Collector>()
                                .Where(c => c.UserId == model.UserId && c.YearId == model.YearId && c.GroupId == model.GroupId)
                                .FirstOrDefault();
                if (collector != null)
                {
                    throw new Exception("Collector already added for this group and year");
                }

                var entity = new Collector()
                {
                    GroupId = model.GroupId,
                    MonthId = model.MonthId,
                    YearId = model.YearId,
                    UserId = model.UserId
                };

                _repo.Add <Collector>(entity);
                _repo.SaveChanges().Unwrap();
                return (long)entity.CollectorId;
            }));
        }
コード例 #3
0
ファイル: Employee.cs プロジェクト: DarrenWen/Program1
        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBox1.Text))
            {
                MessageBox.Show("编号不能为空!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrEmpty(textBox2.Text))
            {
                MessageBox.Show("姓名不能为空!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (CheckNoIsExists(textBox1.Text))
            {
                MessageBox.Show("用户编号已经存在!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            CollectorModel m = new CollectorModel()
            {
                UserName = textBox2.Text, Code = textBox1.Text
            };

            AddNewRow(m);
            textBox1.Text = textBox2.Text = "";
        }
コード例 #4
0
ファイル: Employee.cs プロジェクト: DarrenWen/Program1
        private void AddNewRow(CollectorModel item)
        {
            gvInfo.Rows.Add(1);
            var rowcount = gvInfo.Rows.Count - 2;

            gvInfo.Rows[rowcount].Cells[0].Value = rowcount + 1;
            gvInfo.Rows[rowcount].Cells[1].Value = rowcount + 1;
            gvInfo.Rows[rowcount].Cells[2].Value = item.Code;
            gvInfo.Rows[rowcount].Cells[3].Value = item.UserName;
        }
コード例 #5
0
        public void CollectorModel_GetSystemState_CheckWritersState()
        {
            const int countReplics = 2;
            var       writer       = new HashWriter(new HashMapConfiguration("TestCollectorModel", HashMapCreationMode.CreateNew, 4, 3, HashFileType.Distributor));

            writer.CreateMap();
            writer.SetServer(0, "localhost", 1, 157);
            writer.SetServer(1, "localhost", 2, 157);
            writer.SetServer(2, "localhost", 3, 157);
            writer.SetServer(3, "localhost", 4, 157);
            writer.Save();

            var model = new CollectorModel(new DistributorHashConfiguration(countReplics),
                                           new HashMapConfiguration("TestCollectorModel", HashMapCreationMode.ReadFromFile, 1, countReplics, HashFileType.Writer));

            model.Start();


            var state = model.GetSystemState();

            Assert.AreEqual(SystemSearchStateInner.AllServersAvailable, state);

            model.ServerNotAvailable(new ServerId("localhost", 1));
            state = model.GetSystemState();
            Assert.AreEqual(SystemSearchStateInner.AllDataAvailable, state);

            model.ServerNotAvailable(new ServerId("localhost", 3));
            state = model.GetSystemState();
            Assert.AreEqual(SystemSearchStateInner.AllDataAvailable, state);

            model.ServerNotAvailable(new ServerId("localhost", 2));
            state = model.GetSystemState();
            Assert.AreEqual(SystemSearchStateInner.SomeDataUnavailable, state);

            model.ServerAvailable(new ServerId("localhost", 1));
            state = model.GetSystemState();
            Assert.AreEqual(SystemSearchStateInner.SomeDataUnavailable, state);

            model.ServerNotAvailable(new ServerId("localhost", 4));
            state = model.GetSystemState();
            Assert.AreEqual(SystemSearchStateInner.SomeDataUnavailable, state);

            model.ServerAvailable(new ServerId("localhost", 3));
            state = model.GetSystemState();
            Assert.AreEqual(SystemSearchStateInner.AllDataAvailable, state);
        }
コード例 #6
0
 public CollectorModel CreateCollector(CollectorModel model)
 {
     throw new NotImplementedException();
 }
コード例 #7
0
        public IHttpActionResult AddCollectorToGroup([FromBody] CollectorModel model)
        {
            var op = _collectorManager.AddCollectorToGroup(model.UserId, model.MonthId, model.GroupId);

            return(this.OperationResult(op));
        }