예제 #1
0
 private bool Handle_HandshakeResponse(eNetCmd cmd, UsCmd c)
 {
     NetUtil.Log("eNetCmd.SV_HandshakeResponse received, connection validated.", (object[])Array.Empty <object>());
     SysPost.InvokeMulticast((object)this, (MulticastDelegate)this.LogicallyConnected);
     this._guardTimer.Deactivate();
     return(true);
 }
예제 #2
0
 public bool EffectStressTestTriggered(string[] args)
 {
     try
     {
         if (args.Length == 3)
         {
             string effectName  = args[1];
             int    effectCount = int.Parse(args[2]);
             SysPost.InvokeMulticast(this, RunEffectStressTest, new UsEffectStressTestEventArgs(effectName, effectCount));
         }
         else
         {
             int           effectCount    = int.Parse(args[args.Length - 1]);
             List <string> effectNameList = new List <string>(args);
             effectNameList.RemoveAt(0);
             effectNameList.RemoveAt(effectNameList.Count - 1);
             string effectName = string.Join(" ", effectNameList.ToArray());
             SysPost.InvokeMulticast(this, RunEffectStressTest, new UsEffectStressTestEventArgs(effectName, effectCount));
         }
     }
     catch (Exception ex)
     {
         Log.Exception(ex);
         throw;
     }
     return(true);
 }
예제 #3
0
    private void OnDisconnected(object sender, EventArgs e)
    {
        _tickTimer.Stop();
        _guardTimer.Deactivate();

        SysPost.InvokeMulticast(this, LogicallyDisconnected);
    }
예제 #4
0
 public static void InvokeMulticast(object sender, MulticastDelegate md)
 {
     if ((object)md == null)
     {
         return;
     }
     SysPost.InvokeMulticast(sender, md, (EventArgs)null);
 }
예제 #5
0
    private bool Handle_HandshakeResponse(eNetCmd cmd, UsCmd c)
    {
        NetUtil.Log("eNetCmd.SV_HandshakeResponse received, connection validated.");

        SysPost.InvokeMulticast(this, LogicallyConnected);

        _guardTimer.Deactivate();
        return(true);
    }
예제 #6
0
 public void Disconnect()
 {
     if (this._tcpClient == null)
     {
         return;
     }
     this._tcpClient.Close();
     this._tcpClient = (TcpClient)null;
     this._host      = string.Empty;
     this._port      = 0;
     NetUtil.Log("connection closed.", (object[])Array.Empty <object>());
     SysPost.InvokeMulticast((object)this, (MulticastDelegate)this.Disconnected);
 }
예제 #7
0
 public JsonResult SavePost(string data)
 {
     try
     {
         SysPost model = Newtonsoft.Json.JsonConvert.DeserializeObject <SysPost>(data);
         if (model.PostId == 0)
         {
             model.CreateTime = DateTime.Now;
             model.CreateUser = 0;
             model.TenantId   = CurrentTenant.TenantId;
             model.PostCode   = model.PostName;
             //新增
             _postManager.AddPost(model);
         }
         else
         {
             //修改
             SysPost post = _postManager.GetPostById(model.PostId);
             if (post == null)
             {
                 return(Json(new { result = 0, content = RetechWing.LanguageResources.TenantUI.TenantPost.NotFound }, JsonRequestBehavior.AllowGet));
             }
             if (post.TenantId != CurrentTenant.TenantId)
             {
                 return(Json(new { result = 0, content = RetechWing.LanguageResources.TenantUI.TenantPost.NotFound }, JsonRequestBehavior.AllowGet));
             }
             var childIds = new List <int>();
             GetChildPostIds(model.PostId, _postManager.GetAllPost(CurrentTenant.TenantId), childIds);
             childIds.Add(model.PostId);
             if (childIds.Contains(model.ParentId))
             {
                 return(Json(new { result = 0, content = RetechWing.LanguageResources.TenantUI.TenantPost.CanNotBeSub }, JsonRequestBehavior.AllowGet));
             }
             post.ParentId    = model.ParentId;
             post.PostName    = model.PostName;
             post.PostCode    = model.PostName;
             post.Description = model.Description;
             _postManager.UpdatePost(post);
             if (post.DeptId != model.DeptId)
             {
                 _postManager.UpdatePostDeptId(model.DeptId, childIds.ToArray());
             }
         }
         return(Json(new { result = 1, content = RetechWing.LanguageResources.Common.SaveSuccess }, JsonRequestBehavior.AllowGet));
     }
     catch
     {
         return(Json(new { result = 0, content = RetechWing.LanguageResources.Common.SaveFailed }, JsonRequestBehavior.AllowGet));
     }
 }
예제 #8
0
        public void Disconnect()
        {
            if (_tcpClient != null)
            {
                _tcpClient.Close();
                _tcpClient = null;

                _host = "";
                _port = 0;

                UsLogging.Printf("connection closed.");
                SysPost.InvokeMulticast(this, Disconnected);
            }
        }
예제 #9
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <ApiResult <string> > Add(SysPost model)
        {
            var result = new ApiResult <string>();

            try
            {
                await _thisRepository.AddAsync(model);
            }
            catch (Exception ex)
            {
                result.StatusCode = (int)HttpStatusCode.InternalServerError;
                result.Message    = ex.Message;
            }
            return(result);
        }
예제 #10
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <ApiResult <string> > Modify(SysPost model)
        {
            var result = new ApiResult <string>();

            try
            {
                await _thisRepository.UpdateAsync(model, m => new { m.CreateUser, m.CreateTime, m.IsDel });
            }
            catch (Exception ex)
            {
                result.StatusCode = (int)HttpStatusCode.InternalServerError;
                result.Message    = ex.Message;
            }
            return(result);
        }
예제 #11
0
        /// <summary>
        /// 递归获取子节点
        /// </summary>
        /// <param name="dept"></param>
        /// <param name="all"></param>
        /// <returns></returns>
        private EasyuiTreeNode GetChildPosts(SysPost post, IEnumerable <SysPost> all, int showCheckBox, int[] postIds)
        {
            var node = new EasyuiTreeNode
            {
                id       = post.PostId + "_1",
                text     = post.PostName,
                @checked = showCheckBox == 1 && postIds.Contains(post.PostId)
            };
            var tmp = all.Where(p => p.ParentId == post.PostId);

            foreach (var item in tmp)
            {
                node.children.Add(GetChildPosts(item, all, showCheckBox, postIds));
            }
            return(node);
        }
예제 #12
0
        private void Delete()
        {
            UltraGridRow row = ultraGrid1.ActiveRow;

            if (row == null)
            {
                MetroMessageBox.Show(this, "请选择需要修改的岗位!");
                return;
            }
            SysPost post  = row.ListObject as SysPost;
            string  orgId = post.PostOrgId;

            if (MetroMessageBox.Show(this, "是否确定删除岗位" + post.PostName + "?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                this.Update(Globals.POST_SERVICE_NAME, "delete", new object[] { post.PostId });
                QueryPost(orgId);
            }
        }
예제 #13
0
        private new void Update()
        {
            UltraGridRow row = ultraGrid1.ActiveRow;

            if (row == null)
            {
                MetroMessageBox.Show(this, "请选择需要修改的岗位!");
                return;
            }
            SysPost     post  = row.ListObject as SysPost;
            string      orgId = post.PostOrgId;
            DlgPostEdit dlg   = new DlgPostEdit(post, EditType.Update, this.Action);

            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                QueryPost(orgId);
            }
        }
예제 #14
0
        public JsonResult GetPostAbilites(int postId, string abname, string level, int catId, int pageIndex,
                                          int pageSize)
        {
            SysPost            post = _postManager.GetPostById(postId);
            int                total;
            List <PostAbility> list = _postAbilityManager.GetPostAbility(out total, postId, abname, catId, level,
                                                                         pageIndex, pageSize);

            return(Json(new
            {
                dataList = list,
                recordCount = total,
                desc = post.Description,
                postName = post.PostName,
                promotionName = post.DefaultPromotionName,
                promotionId = post.DefaultPromotionId
            }, JsonRequestBehavior.AllowGet));
        }
예제 #15
0
        /// <summary>
        ///     递归获取子节点
        /// </summary>
        /// <param name="dept"></param>
        /// <param name="all"></param>
        /// <returns></returns>
        private EasyuiTreeNode GetChildPosts(SysPost post, IEnumerable <SysPost> all, int showCheckBox, int[] postIds)
        {
            var node = new EasyuiTreeNode
            {
                id   = post.PostId + "_1",
                text =
                    "<input type='checkbox' value='" + post.PostId + "' id='post_id_" + post.PostId +
                    "'/><label for='post_id_" + post.PostId + "'>" + post.PostName + "</label>",
                @checked = showCheckBox == 1 && postIds.Contains(post.PostId)
            };
            IEnumerable <SysPost> tmp = all.Where(p => p.ParentId == post.PostId);

            foreach (SysPost item in tmp)
            {
                node.children.Add(GetChildPosts(item, all, showCheckBox, postIds));
            }
            return(node);
        }
예제 #16
0
 public bool QueryEffectListTriggered(string[] args)
 {
     try
     {
         if (args.Length != 1)
         {
             Log.Error((object)"Command 'get_effect_list' parameter count mismatched. ({0} expected, {1} got)", (object)1, (object)args.Length);
             return(false);
         }
         SysPost.InvokeMulticast((object)this, (MulticastDelegate)this.QueryEffectList);
     }
     catch (Exception ex)
     {
         Log.Exception(ex);
         throw;
     }
     return(true);
 }
예제 #17
0
    private void OnConnect(IAsyncResult asyncResult)
    {
        TcpClient asyncState = (TcpClient)asyncResult.AsyncState;

        try
        {
            if (!asyncState.Connected)
            {
                throw new Exception();
            }
            NetUtil.Log("connected successfully.", (object[])Array.Empty <object>());
            SysPost.InvokeMulticast((object)this, (MulticastDelegate)this.Connected);
        }
        catch (Exception ex)
        {
            this.DisconnectOnError("connection failed while handling OnConnect().", ex);
        }
    }
예제 #18
0
 public bool StartAnalysePixelsTriggered(string[] args)
 {
     try
     {
         bool b = false;
         if (args.Length == 2 && args[1] == "refresh")
         {
             b = true;
         }
         SysPost.InvokeMulticast((object)this, (MulticastDelegate)this.StartAnalyzePixel, (EventArgs) new UsvConsoleCmds.AnalysePixelsArgs(b));
     }
     catch (Exception ex)
     {
         Log.Exception(ex);
         throw;
     }
     return(true);
 }
예제 #19
0
        private void Add()
        {
            UltraTreeNode node = ultraTree1.ActiveNode;

            if (node == null)
            {
                MetroMessageBox.Show(this, "请选择需要新增岗位的组织机构!");
                return;
            }
            SysPost post = new SysPost();

            post.PostOrgId = (node.Tag as SysOrganization).OrganizationId;
            DlgPostEdit dlg = new DlgPostEdit(post, EditType.Add, this.Action);

            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                QueryPost(post.PostOrgId);
            }
        }
예제 #20
0
        private void Tile_Clicked(object sender, EventArgs e)
        {
            MetroTileItem ti = sender as MetroTileItem;

            if (ti == null)
            {
                return;
            }

            ti.Checked = true;
            if (m_selectedTile != null)
            {
                m_selectedTile.Checked = false;
            }

            m_selectedTile  = ti;
            m_selectedAsset = SysUtil.GetRelativePath((string)ti.Tag, m_assetRoot);
            SysPost.InvokeMulticast(this, AssetSelected);
        }
예제 #21
0
        public ActionResult EditPost(int postId = 0)
        {
            SysPost post = postId == 0 ? new SysPost {
                DeptId = -1
            } : _postManager.GetPostById(postId);

            if (post.PostId > 0 && post.DeptId == 0)
            {
                post.DeptName = CurrentTenant.TenantName;
            }
            if (post.ParentId > 0)
            {
                var parent = _postManager.GetPostById(post.ParentId);
                if (parent != null)
                {
                    post.ParentName = parent.PostName;
                }
            }
            return(View(post));
        }
예제 #22
0
 public JsonResult ChangeUserPost(string userIds, int id)
 {
     try
     {
         SysPost post = _postManager.GetPostById(id);
         var     f    = _userManager.BatchChangeUserPost(userIds.GetArray(), id, post.DeptId);
         return(Json(new
         {
             result = f ? 1 : 0,
             content = f ? RetechWing.LanguageResources.Common.OperationSuccessful : RetechWing.LanguageResources.Common.OperationFailed
         }, JsonRequestBehavior.AllowGet));
     }
     catch
     {
         return(Json(new
         {
             result = 0,
             content = RetechWing.LanguageResources.Common.OperationFailed
         }, JsonRequestBehavior.AllowGet));
     }
 }
예제 #23
0
        // Called when a connection to a server is established
        private void OnConnect(IAsyncResult asyncResult)
        {
            // Retrieving TcpClient from IAsyncResult
            TcpClient tcpClient = (TcpClient)asyncResult.AsyncState;

            try
            {
                if (tcpClient.Connected) // may throw NullReference
                {
                    UsLogging.Printf("connected successfully.");
                    SysPost.InvokeMulticast(this, Connected);
                }
                else
                {
                    throw new Exception();
                }
            }
            catch (Exception ex)
            {
                DisconnectOnError("connection failed while handling OnConnect().", ex);
            }
        }
예제 #24
0
파일: DlgPostEdit.cs 프로젝트: Jackjet/BIP
        private void Save()
        {
            if (!ValidateInput())
            {
                return;
            }
            SysPost post = null;

            switch (type)
            {
            case EditType.Add:
                post           = new SysPost();
                post.PostId    = BipGuid.Guid;
                post.PostName  = txtPostName.Text.Trim();
                post.PostCode  = txtPostCode.Text.Trim();
                post.PostLevel = cmbPostLevel.Text;
                post.PostType  = cmbPostType.Text;
                post.Remark    = txtRemark.Text;
                post.PostOrgId = cbtOrg.Value;
                post.RoleId    = cbtRole.Value;
                this.Update(Globals.POST_SERVICE_NAME, "add", new object[] { post });
                break;

            case EditType.Update:
                post           = _post;
                post.PostName  = txtPostName.Text.Trim();
                post.PostCode  = txtPostCode.Text.Trim();
                post.PostLevel = cmbPostLevel.Text;
                post.PostType  = cmbPostType.Text;
                post.Remark    = txtRemark.Text;
                post.PostOrgId = cbtOrg.Value;
                post.RoleId    = cbtRole.Value;
                this.Update(Globals.POST_SERVICE_NAME, "update", new object[] { post });
                break;
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
예제 #25
0
    public bool StartAnalysePixelsTriggered(string[] args)
    {
        try
        {
            bool bRefresh = false;
            if (args.Length == 2)
            {
                string args2 = args[1];
                if (args2 == "refresh")
                {
                    bRefresh = true;
                }
            }

            SysPost.InvokeMulticast(this, StartAnalyzePixel, new AnalysePixelsArgs(bRefresh));
        }
        catch (Exception ex)
        {
            Log.Exception(ex);
            throw;
        }

        return(true);
    }
예제 #26
0
 public bool EffectStressTestTriggered(string[] args)
 {
     try
     {
         if (args.Length == 3)
         {
             SysPost.InvokeMulticast((object)this, (MulticastDelegate)this.RunEffectStressTest, (EventArgs) new UsvConsoleCmds.UsEffectStressTestEventArgs(args[1], int.Parse(args[2])));
         }
         else
         {
             int           effectCount = int.Parse(args[args.Length - 1]);
             List <string> stringList  = new List <string>((IEnumerable <string>)args);
             stringList.RemoveAt(0);
             stringList.RemoveAt(stringList.Count - 1);
             SysPost.InvokeMulticast((object)this, (MulticastDelegate)this.RunEffectStressTest, (EventArgs) new UsvConsoleCmds.UsEffectStressTestEventArgs(string.Join(" ", stringList.ToArray()), effectCount));
         }
     }
     catch (Exception ex)
     {
         Log.Exception(ex);
         throw;
     }
     return(true);
 }
예제 #27
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="post"></param>
 public void UpdatePost(SysPost post)
 {
     _dataAccess.UpdateEntity(post);
 }
예제 #28
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="post"></param>
 public void AddPost(SysPost post)
 {
     _dataAccess.AddEntity(post);
 }
예제 #29
0
 private void OnDisconnected(object sender, EventArgs e)
 {
     this._tickTimer.Stop();
     this._guardTimer.Deactivate();
     SysPost.InvokeMulticast((object)this, (MulticastDelegate)this.LogicallyDisconnected);
 }
예제 #30
0
 public async Task <ApiResult <string> > Modify([FromBody] SysPost model) => await _sysPostService.Modify(model);