Пример #1
0
 public LoginForm()
 {
     InitializeComponent();
     userOperation      = new UserOperation(new UserRepository());
     algorithmOperation = new AlgorithmOperation(new AlgorithmRepository());
     groupOperation     = new GroupOperation(new AccessGroupRepository());
 }
        public void RegistraionTest()
        {
            UserOperation target = new UserOperation(); // TODO: Initialize to an appropriate value
            Customer      obj    = new Customer()
            {
                _cname     = "abc",
                _cUserID   = "SU1292",
                _cityID    = 101,
                _countryID = 1,
                _stateID   = 5001,
                _street    = "church",
                _house     = "#12",
                _ph        = "1234567890",

                _eMail = "*****@*****.**"
            };
            Credentials creObj = new Credentials()
            {
                _userPswd = "abds",
                //_userType = "A"
            };


            // Customer _reg = null; // TODO: Initialize to an appropriate value


            // Credentials _cre = null; // TODO: Initialize to an appropriate value
            int expected = 1; // TODO: Initialize to an appropriate value
            int actual;

            actual = target.Registraion(obj, creObj);
            Assert.AreEqual(expected, actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }
Пример #3
0
        public IList <UserOperation> GetUserOperationsByPage(int userid, int pageindex, int pagesize, out int pagecount)
        {
            string sql = "usp_getuseroperation";

            SqlParameter[] spms =
                SqlHelper.GetSqpParameters(new string[] { "@userid", "@pageindex", "@pagesize", "@pagecount" },
                                           new object[] { userid, pageindex, pagesize, DBNull.Value },
                                           new SqlDbType[] { SqlDbType.Int, SqlDbType.Int, SqlDbType.Int, SqlDbType.Int });
            spms[3].Direction = ParameterDirection.Output;
            DataSet set = new DataSet();

            SqlHelper.GetDataTable(sql, CommandType.StoredProcedure, set, spms);
            pagecount = Convert.ToInt32(spms[3].Value);
            List <UserOperation> list = new List <UserOperation>();

            foreach (DataRow dataRow in set.Tables[0].Rows)
            {
                UserOperation model = new UserOperation();
                model.Id       = Convert.ToInt32(dataRow[0]);
                model.UserId   = Convert.ToInt32(dataRow[1]);
                model.UserNmae = dataRow[2].ToString();
                model.Action   = (UserAction)Convert.ToInt32(dataRow[3]);
                model.EventId  = Convert.ToInt32(dataRow[4]);
                model.DelFlag  = (DelFlag)Convert.ToInt32(dataRow[5]);
                model.DateLine = Convert.ToDateTime(dataRow[6]);
                list.Add(model);
            }
            return(list);
        }
Пример #4
0
 /// <summary>
 /// Page_Load
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         //判断是否存在该id的用户
         UserEntity ue = UserOperation.GetUser(int.Parse(Request.QueryString["id"].ToString()));
         if (ue == null)
         {
             SmallScript.MessageBox(Page, "不存在该用户!点击返回!");
             SmallScript.GoBack(Page);
             return;
         }
         else
         {
             //在表单中显示数据
             tb_UserName.Text = ue.UserName;
             tb_QQ.Text       = ue.Qq;
             tb_PassWord.Text = ue.Password;
             tb_Email.Text    = ue.Email;
             if (ue.Sex)
             {
                 rb_Sex.SelectedIndex = 0;
             }
             else
             {
                 rb_Sex.SelectedIndex = 1;
             }
             cb_IsAdmin.Checked = ue.Isadmin;
             lb_RegTime.Text    = ue.RegTime.ToString();
             lb_ID.Text         = ue.Id.ToString();
         }
     }
 }
Пример #5
0
        /// <summary>
        /// 新增用户操作记录
        /// </summary>
        /// <param name="userOperation"></param>
        /// <returns></returns>
        public static async Task InsertUserOperation(UserOperation userOperation)
        {
            if (userOperation.Operation == UserOperationEnum.Read.ToString())
            {
                await articleDal.InsertReadRecord(userOperation.ArticleId);
            }
            else if (userOperation.Operation == UserOperationEnum.Favorite.ToString())
            {
                ArticleFavoriteDal articleFavoriteDal = new ArticleFavoriteDal();
                var hasFavorite = await articleFavoriteDal.HasFavorite(userOperation);

                if (!hasFavorite)
                {
                    userOperation.Operation = UserOperationEnum.CancelFavorite.ToString();
                }
                await articleDal.InsertFavoriteRecord(userOperation.ArticleId, hasFavorite);
            }
            else if (userOperation.Operation == UserOperationEnum.Share.ToString())
            {
                await articleDal.InsertShareRecord(userOperation.ArticleId);
            }
            if (userOperation.Operation != UserOperationEnum.Read.ToString())
            {
                await articleDal.InsertUserOperation(userOperation);
            }
        }
Пример #6
0
        private (bool success, UserOperationAccessList accessList, string?error) SimulateValidation(
            Transaction transaction, UserOperation userOperation, BlockHeader parent,
            ITransactionProcessor transactionProcessor)
        {
            UserOperationBlockTracer blockTracer = CreateBlockTracer(parent, userOperation);
            ITxTracer txTracer = blockTracer.StartNewTxTrace(transaction);

            transactionProcessor.CallAndRestore(transaction, parent, txTracer);
            blockTracer.EndTxTrace();

            string?error = null;

            if (!blockTracer.Success)
            {
                if (blockTracer.FailedOp is not null)
                {
                    error = blockTracer.FailedOp.ToString() !;
                }
                else
                {
                    error = blockTracer.Error;
                }
                return(false, UserOperationAccessList.Empty, error);
            }

            UserOperationAccessList userOperationAccessList = new(blockTracer.AccessedStorage);

            return(true, userOperationAccessList, error);
        }
        private static void SaveComSetting(XmlDocument config, UserOperation operation, XmlNode operationSetting)
        {
            ComSetting cs        = operation.Setting as ComSetting;
            XmlNode    comNumber = config.CreateNode(XmlNodeType.Element, "ComNumber", null);

            comNumber.InnerText = cs.ComNumber;

            XmlNode baudRate = config.CreateNode(XmlNodeType.Element, "BaudRate", null);

            baudRate.InnerText = cs.BaudRate.ToString();

            XmlNode dataBit = config.CreateNode(XmlNodeType.Element, "DataBit", null);

            dataBit.InnerText = cs.DataBits.ToString();

            XmlNode stopBit = config.CreateNode(XmlNodeType.Element, "StopBit", null);

            stopBit.InnerText = cs.StopBits.ToString();

            XmlNode parity = config.CreateNode(XmlNodeType.Element, "Parity", null);

            parity.InnerText = cs.Parity.ToString();

            operationSetting.AppendChild(comNumber);
            operationSetting.AppendChild(baudRate);
            operationSetting.AppendChild(dataBit);
            operationSetting.AppendChild(stopBit);
            operationSetting.AppendChild(parity);
        }
Пример #8
0
 public static OperationPermission CreateForStudyRole(UserOperation operation, bool appliesOnlyToNonHiddenStudies, params string[] roles)
 {
     return(new OperationPermission()
     {
         Operation = operation, Level = PermissionLevel.StudySpecificRole, AllowedForRoles = new HashSet <string>(roles), AppliesOnlyToNonHiddenStudies = appliesOnlyToNonHiddenStudies
     });
 }
Пример #9
0
 private void btnLogIn_Click(object sender, EventArgs e)
 {
     try
     {
         var ui = new UserInfo();
         ui.username = txtUsername.Text;
         ui.password = txtPassword.Text;
         if (chkRemember.Checked)
         {
             OnlineBookStore2.Properties.Settings.Default.username = txtUsername.Text;
             OnlineBookStore2.Properties.Settings.Default.password = txtPassword.Text;
             OnlineBookStore2.Properties.Settings.Default.Save();
         }
         var uo = new UserOperation();
         if (uo.Login(ui) == 0)
         {
             MyMessageBox.ShowBox("Please enter username and password!!", "Alert");
         }
         else if (uo.Login(ui) == 1)
         {
             this.Hide();
             var md = new MainDashboard(ui.username);
             md.Show();
         }
         else
         {
             MyMessageBox.ShowBox("Username or password invalid!!", "Alert");
         }
     }
     catch (Exception ex)
     {
         MyMessageBox.ShowBox(ex.Message);
     }
 }
Пример #10
0
 public static OperationPermission CreateForAllNonExternalUser(UserOperation operation, bool appliesOnlyToNonHiddenStudies = false)
 {
     return(new OperationPermission()
     {
         Operation = operation, Level = PermissionLevel.AllNonExternalUser, AppliesOnlyToNonHiddenStudies = appliesOnlyToNonHiddenStudies
     });
 }
Пример #11
0
 public static OperationPermission CreateForAppRole(UserOperation operation, bool appliesOnlyToNonHiddenStudies, bool appliesOnlyIfUserIsStudyOwner, params string[] roles)
 {
     return(new OperationPermission()
     {
         Operation = operation, Level = PermissionLevel.AppRoles, AllowedForRoles = new HashSet <string>(roles), AppliesOnlyToNonHiddenStudies = appliesOnlyToNonHiddenStudies, AppliesOnlyIfUserIsStudyOwner = appliesOnlyIfUserIsStudyOwner
     });
 }
Пример #12
0
        public async Task <CharacterOperation> SendUserOperation(UserOperation operation)
        {
            CharacterOperation newOperation = new Speak("s4", operation.OperatorId, "Got UserOperation: " + operation.OperationType, DialogInstance.DialogButtonsType.Ok);

            newOperation.ExpectFeedback = false;
            return(newOperation);
        }
Пример #13
0
        private void LoginClick(object sender, RoutedEventArgs e)
        {
            var responseUser = UserOperation.Login(
                new UserDTO()
            {
                UserName = UserName.Text,
                Password = Password.Password.ToString().BasicCrypt()
            });

            if (responseUser != null)
            {
                ToDoWindow toDoWindow = new ToDoWindow()
                {
                    DataContext = responseUser
                };
                toDoWindow.DataContext = responseUser;
                toDoWindow.Show();
                this.Close();
            }
            else
            {
                MessageBox.Show("Hatalı Giriş !");
                Password.Clear();
            }
        }
Пример #14
0
 private void RegisterClick(object sender, RoutedEventArgs e)
 {
     if (UserName.Text.Trim().Equals("") || Password.Password.ToString().Trim().Equals(""))
     {
         MessageBox.Show("Please Enter UserName and Password...");
     }
     else
     {
         var result = UserOperation.Register(new UserDTO()
         {
             UserName = UserName.Text,
             Password = Password.Password.ToString().BasicCrypt()
         });
         if (result)
         {
             UserName.Clear();
             Password.Clear();
             MessageBox.Show("Register User Success...");
         }
         else
         {
             MessageBox.Show("Register User Failed !");
             Password.Clear();
         }
     }
 }
Пример #15
0
 public static void HasAccessToOperationOrThrow(UserDto currentUser, UserOperation operation)
 {
     if (!HasAccessToOperation(currentUser, operation))
     {
         throw new ForbiddenException($"User {currentUser.EmailAddress} does not have permission to perform operation {operation}");
     }
 }
Пример #16
0
 /// <summary>
 /// 登录按钮
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btn_Login_Click(object sender, EventArgs e)
 {
     /*登陆*/
     UserOperation.Login(Session, tb_UserName.Text, tb_Password.Text);
     /*重新跳转*/
     Response.Redirect(Request.Url.AbsoluteUri);
 }
Пример #17
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="userProxy"></param>
        /// <param name="currentUser"></param>
        /// <param name="userOperation"></param>
        public CreateUserViewModel(IUserProxy userProxy, User currentUser, UserOperation userOperation)
        {
            this.userProxy = userProxy;

            this.userOperation = userOperation;
            if (userOperation == UserOperation.Edit)
            {
                Title = MergedResources.Common_EditUser;
                this.currentUser = currentUser;
                this.LoginIdReadOnly = true;
            }
            else if (userOperation == UserOperation.Add)
            {
                Title = MergedResources.Common_AddUser;
                this.currentUser = new User();
                this.LoginIdReadOnly = false;
            }
            else
            {
                this.currentUser = currentUser;
                this.LoginIdReadOnly = true;
            }
            InitializeCollections(this.currentUser);
            isLanguageChanged = false;
            IsChanged = false;
            IsSaved = true;
        }
        public ActionResult UpdateSysUser(int id)
        {
            UserOperation uo = new UserOperation();
            User          u  = uo.Get(id);

            return(View(u));
        }
Пример #19
0
 /// <summary>
 /// Page_Load
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Page_Load(object sender, EventArgs e)
 {
     /*检查是否已登陆*/
     if (UserOperation.CheckLoged(Session))
     {
         /*设置登陆面板不可见*/
         pnl_Login.Visible = false;
         /*读出用户名*/
         hlUserName.Text = Session["userName"].ToString();
         /*检查是否是管理员*/
         if (UserOperation.CheckIsAdmin(Session))
         {
             /*管理后台链接标签可视*/
             hlAdmin.Visible = true;
         }
         /*用户面板可见*/
         pnl_User.Visible = true;
         return;
     }
     else
     {
         if (Session["loginerror"] == null)
         {
         }
         else if ((bool.Parse(Session["loginerror"].ToString()) == true))
         {
             tb_tip.Visible = true;
         }
         /*登陆面板可见,用户面板不可见*/
         pnl_Login.Visible = true;
         pnl_User.Visible  = false;
     }
 }
Пример #20
0
        public static MvcHtmlString UserOperation(this AjaxHelper helper, UserOperation operation)
        {
            if (operation == null)
            {
                return(MvcHtmlString.Create(string.Empty));
            }

            if (string.IsNullOrEmpty(operation.Action))
            {
                return(MvcHtmlString.Create(operation.Label));
            }

            if (operation.AjaxOptions == null)
            {
                throw new InvalidOperationException("Please use UserOperation for Non-Ajax Operations.");
            }

            var htmlAttributes = CreateConfirmation(operation.Confirmation);

            return(helper.ActionLink(
                       operation.Label,
                       operation.Action,
                       operation.Controller,
                       operation.RouteValues,
                       operation.AjaxOptions,
                       htmlAttributes));
        }
Пример #21
0
 public CreateNewUser(IUserProxy userProxy, User currentUser, UserOperation userOperation)
 {
     InitializeComponent();
     VM = new CreateUserViewModel(userProxy, currentUser, userOperation);
     VM.View = this;
     DataContext = VM;
 }
Пример #22
0
        public async Task <Sandbox> GetByIdForPhaseShiftAsync(int id, UserOperation userOperation)
        {
            var sandboxQueryable = SandboxBaseQueries.SandboxForPhaseShift(_db);
            var sandbox          = await GetSandboxFromQueryableThrowIfNotFoundOrNoAccess(sandboxQueryable, id, userOperation);

            return(sandbox);
        }
Пример #23
0
        public async Task <Sandbox> GetByIdForCostAnalysisLinkAsync(int id, UserOperation userOperation)
        {
            var sandboxQueryable = SandboxBaseQueries.SandboxWithResources(_db).AsNoTracking();
            var sandbox          = await GetSandboxFromQueryableThrowIfNotFoundOrNoAccess(sandboxQueryable, id, userOperation);

            return(sandbox);
        }
        public ActionResult UpdateSysUserSub(User model)
        {
            UserOperation uo = new UserOperation();

            uo.Update(model);
            return(JavaScript("pagesub();"));
        }
Пример #25
0
        /// <summary>
        /// 更新父User.UserExtension的AgentCount/MemberCount
        /// </summary>
        /// <param name="user">当前用户</param>
        /// <param name="roleId">当前用户的角色Id</param>
        /// <param name="userOperation">操作: 增/删/改</param>
        public void UpdateParentUserExtension(User user, int roleId, UserOperation userOperation)
        {
            using (var db = new RacingDbContext())
            {
                var parentUserExtension = db.UserExtension
                                          .Include(nameof(UserExtension.User))
                                          .Where(u => u.UserId == user.ParentUserId).FirstOrDefault();

                if (parentUserExtension != null)
                {
                    switch (userOperation)
                    {
                    case UserOperation.Add:     //新增用户
                        switch (roleId)
                        {
                        case RoleConst.Role_Id_General_Agent:           //新增用户是总代理
                            parentUserExtension.AgentCount = parentUserExtension.AgentCount + 1;
                            break;

                        case RoleConst.Role_Id_Agent:           //新增用户是代理
                            parentUserExtension.AgentCount = parentUserExtension.AgentCount + 1;
                            break;

                        case RoleConst.Role_Id_Member:           //新增用户是会员
                                                                 //更新代理
                            parentUserExtension.MemberCount = parentUserExtension.MemberCount + 1;
                            //更新总代理
                            UpdateParentUserExtension(parentUserExtension.User, RoleConst.Role_Id_Member, UserOperation.Add);
                            break;
                        }
                        break;

                    case UserOperation.Edit:     //修改用户
                        break;

                    case UserOperation.Delete:     //删除用户
                        switch (roleId)
                        {
                        case RoleConst.Role_Id_General_Agent:           //删除用户是总代理
                            parentUserExtension.AgentCount = parentUserExtension.AgentCount - 1;
                            break;

                        case RoleConst.Role_Id_Agent:           //删除用户是代理
                            parentUserExtension.AgentCount  = parentUserExtension.AgentCount - 1;
                            parentUserExtension.MemberCount = parentUserExtension.MemberCount - user.UserExtension.MemberCount;
                            break;

                        case RoleConst.Role_Id_Member:           //删除用户是会员
                            parentUserExtension.MemberCount = parentUserExtension.MemberCount - 1;
                            //更新总代理
                            UpdateParentUserExtension(parentUserExtension.User, RoleConst.Role_Id_Member, UserOperation.Delete);
                            break;
                        }
                        break;
                    }

                    db.SaveChanges();
                }
            }
        }
Пример #26
0
            public void SendUserOperation(Address entryPoint, UserOperation userOperation)
            {
                ResultWrapper <Keccak> resultOfUserOperation = UserOperationPool[entryPoint].AddUserOperation(userOperation);

                resultOfUserOperation.GetResult().ResultType.Should().NotBe(ResultType.Failure, resultOfUserOperation.Result.Error);
                resultOfUserOperation.GetData().Should().Be(userOperation.CalculateRequestId(entryPoint, SpecProvider.ChainId));
            }
        private void 开关电脑ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (_opreations == null)
            {
                Helper.ShowMessageBox("提示", "请选择对应操作项或时间点!");
                return;
            }

            if (_relaySettings == null)
            {
                Helper.ShowMessageBox("提示", "继电器数据未添加!");
            }


            PcSwatch _pcSwitch = new PcSwatch(_relaySettings);

            if (_pcSwitch.ShowDialog() == DialogResult.OK)
            {
                CommunicationType opType = CommunicationType.Com;
                DataType          dType  = DataType.Hex;
                if (_pcSwitch.DataList.Count > 0)
                {
                    UserOperation OnOperation  = new UserOperation(_pcSwitch.OperationNameList[0], opType, dType, _pcSwitch.Setting, _pcSwitch.DataList[0], _pcSwitch.DelayTime);
                    UserOperation OffOperation = new UserOperation(_pcSwitch.OperationNameList[1], opType, dType, _pcSwitch.Setting, _pcSwitch.DataList[1], _pcSwitch.DelayTime);
                    AddOpration(OnOperation);
                    AddOpration(OffOperation);
                }
            }
        }
Пример #28
0
        public UserOperation GetUserOperation()
        {
            UserOperation op = new UserOperation();

            switch (this._operationOption)
            {
            case UserOperationEnum.Read:
            case UserOperationEnum.Share:
            case UserOperationEnum.Favorite:
                op.ArticleId      = Convert.ToInt32(this.actionParams["Id"]);
                op.CreateDateTime = DateTime.Now;
                op.DeviceId       = this.actionParams.ContainsKey("DeviceId") && !string.IsNullOrEmpty((string)this.actionParams["DeviceId"])
                                                    ? Guid.Parse(this.actionParams["DeviceId"].ToString()) : Guid.Empty;
                op.Operation = this._operationOption.ToString();
                op.UserId    = this.actionParams.ContainsKey("userId") && !string.IsNullOrEmpty(this.actionParams["userId"]?.ToString())
                                                    ? Guid.Parse(this.actionParams["userId"].ToString()) : Guid.Empty;
                break;

            case UserOperationEnum.Comment:
                ArticleCommentModel comment = this.actionParams["acm"] as ArticleCommentModel;
                op.ArticleId      = comment.PKID;
                op.CreateDateTime = DateTime.Now;
                op.DeviceId       = Guid.Empty;
                op.Operation      = this._operationOption.ToString();
                op.UserId         = Guid.Parse(comment.UserID);
                break;
            }
            return(op);
        }
        private void 添加ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OprationSetting os = new OprationSetting();

            if (os.ShowDialog() == DialogResult.OK)
            {
                CommunicationType opType = CommunicationType.Com;
                if (os.CommunicationType.ToLower() == "tcp")
                {
                    opType = CommunicationType.TCP;
                }
                else if (os.CommunicationType.ToLower() == "udp")
                {
                    opType = CommunicationType.UDP;
                }
                else if (os.CommunicationType.ToLower() == "串口")
                {
                    opType = CommunicationType.Com;
                }

                DataType dType = DataType.Character;
                if (os.DataType.ToLower() == "十六进制")
                {
                    dType = DataType.Hex;
                }
                else if (os.DataType.ToLower() == "字符串")
                {
                    dType = DataType.Character;
                }

                UserOperation opration = new UserOperation(os.OprationName, opType, dType, os.Setting, os.Data, os.DelayTime);
                AddOpration(opration);
            }
        }
Пример #30
0
        /// <summary>
        ///   <para>カーソルの状態を1フレーム更新する</para>
        ///   <para>userOperation は、カーソル操作系しかあり得ない</para>
        /// </summary>
        /// <param name="userOperation">ユーザーの操作</param>
        public CursorStatus Update(UserOperation userOperation)
        {
            // カーソルが操作不能
            if (CursorWait > 0)
            {
                CursorWait--;
                return(this);
            }
            switch (userOperation)
            {
            case UserOperation.NaN or
                UserOperation.ClickChangeCell or
                UserOperation.Swap or
                UserOperation.ScrollSpeedUp:
                break;

            case UserOperation.CursorUp:
                CursorMove(1, 0);
                break;

            case UserOperation.CursorLeft:
                CursorMove(0, -1);
                break;

            case UserOperation.CursorRight:
                CursorMove(0, 1);
                break;

            case UserOperation.CursorDown:
                CursorMove(-1, 0);
                break;
            }
            return(this);
        }
Пример #31
0
 public bool AddOperation(Guid userId, Guid operationId)
 {
     try
     {
         var userOperationBO = new UserOperationBO();
         var userRole        = userOperationBO.Get(this.ConnectionHandler, userId, operationId);
         if (userRole == null)
         {
             var userOperation = new UserOperation {
                 UserId = userId, OperationId = operationId
             };
             if (!userOperationBO.Insert(this.ConnectionHandler, userOperation))
             {
                 throw new Exception("خطایی در ذخیره  عملیات کاربر  وجود دارد");
             }
         }
         return(true);
     }
     catch (KnownException ex)
     {
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
     catch (Exception ex)
     {
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
 }
        public Transaction BuildTransactionFromUserOperations(
            IEnumerable <UserOperation> userOperations,
            BlockHeader parent,
            long gasLimit,
            UInt256 nonce,
            IReleaseSpec spec)
        {
            byte[] computedCallData;

            // use handleOp is only one op is used, handleOps if multiple
            UserOperation[] userOperationArray = userOperations.ToArray();
            if (userOperationArray.Length == 1)
            {
                UserOperation userOperation = userOperationArray[0];

                AbiSignature abiSignature = _entryPointContractAbi.Functions["handleOp"].GetCallInfo().Signature;
                computedCallData = _abiEncoder.Encode(
                    AbiEncodingStyle.IncludeSignature,
                    abiSignature,
                    userOperation.Abi, _signer.Address);
            }
            else
            {
                AbiSignature abiSignature = _entryPointContractAbi.Functions["handleOps"].GetCallInfo().Signature;
                computedCallData = _abiEncoder.Encode(
                    AbiEncodingStyle.IncludeSignature,
                    abiSignature,
                    userOperationArray.Select(op => op.Abi).ToArray(), _signer.Address);
            }

            Transaction transaction =
                BuildTransaction(gasLimit, computedCallData, _signer.Address, parent, spec, nonce, false);

            return(transaction);
        }
Пример #33
0
        public User(UserOperation operation, TVMViewModel vm)
        {
            InitializeComponent();

            Operation = operation;
            TVM_VM = vm;
            //System.Windows.Forms.TextBox txtPassword = new TextBox();
            //txtPassword.PasswordChar = '*';
            //MainGrid.Children.Add(txtPassword as UIElement);
            txtPassword.PasswordChar = '*';
            

            // Expiration Time DataGrid
            Time expiryTime = new Time(false);
            dataTableExpire = expiryTime.TimeDataTable;
            timeExpiry.ItemsSource = dataTableExpire.AsDataView();

            if (Operation == UserOperation.ADD)
            {
                lblName.IsEnabled = true;
                lblPassword.IsEnabled = true;
                lblExpirtyTime.IsEnabled = true;
                txtName.IsEnabled = true;
                txtPassword.IsEnabled = true;
                lblIsAdmin.IsEnabled = true;
                rbtnIsAdminT.IsEnabled = true;
                rbtnIsAdminF.IsEnabled = true;
                dateExpirty.IsEnabled = true;
                timeExpiry.IsEnabled = true;
            }
            else if (Operation == UserOperation.EDIT)
            {
                lblName.IsEnabled = true;
                lblPassword.IsEnabled = true;
                lblExpirtyTime.IsEnabled = true;
                txtName.IsEnabled = true;
                txtPassword.IsEnabled = true;
                dateExpirty.IsEnabled = true;
                timeExpiry.IsEnabled = true;
                lblIsAdmin.IsEnabled = false;
                rbtnIsAdminT.IsEnabled = false;
                rbtnIsAdminF.IsEnabled = false;
                lblIsAdmin.Visibility = System.Windows.Visibility.Hidden;
                rbtnIsAdminT.Visibility = System.Windows.Visibility.Hidden;
                rbtnIsAdminF.Visibility = System.Windows.Visibility.Hidden;
            }
            else if (Operation == UserOperation.REMOVE)
            {
                lblName.IsEnabled = true;
                lblPassword.IsEnabled = false;
                lblExpirtyTime.IsEnabled = false;
                txtName.IsEnabled = true;
                txtPassword.IsEnabled = false;
                dateExpirty.IsEnabled = false;
                timeExpiry.IsEnabled = false;
                lblIsAdmin.IsEnabled = false;
                rbtnIsAdminT.IsEnabled = false;
                rbtnIsAdminF.IsEnabled = false;

                lblPassword.Visibility = System.Windows.Visibility.Hidden;
                txtPassword.Visibility = System.Windows.Visibility.Hidden;
                dateExpirty.Visibility = System.Windows.Visibility.Hidden;
                timeExpiry.Visibility = System.Windows.Visibility.Hidden;
                lblExpirtyTime.Visibility = System.Windows.Visibility.Hidden;
                s1.Visibility = System.Windows.Visibility.Hidden;
                s2.Visibility = System.Windows.Visibility.Hidden;
                lblIsAdmin.Visibility = System.Windows.Visibility.Hidden;
                rbtnIsAdminT.Visibility = System.Windows.Visibility.Hidden;
                rbtnIsAdminF.Visibility = System.Windows.Visibility.Hidden;

                Grid.SetRow(btnGo, 2);
                Height = 200;
            }
            else
            {
                System.Windows.MessageBox.Show("Invalid user operation - this should NEVER happen");
            }
        }
Пример #34
0
        /// <summary>
        /// 检查是否图元被选中
        /// </summary>
        /// <param name="p">鼠标当前所在点</param>
        public void CheckGraphElementSelected(Point point)
        {
            Point p = AdjustMouseLocation(point);
            RecordLastSelectedPoint(p);          
  
            selectedGraphElement = null;
            ConnectorContainer newLine = null; // 自动新建的连接线
            bool selected = false; // 是否已经有图元被选中
            GraphElement graphElement = null; // 当前图元

            if (lastSelectedGraphElement != null) // 将上一个被选中的图元置为非选中状态
            {
                if (!selectedGraphElementList.Contains(lastSelectedGraphElement)) // 在多选状态需要检查上一个被选中的图元是否在多选容器中
                {
                    lastSelectedGraphElement.Selected = false;
                }
            }

            if (lastResizingGraphElement != null) // 将上一个缩放的插槽容器置为非缩放状态
            {
                lastResizingGraphElement.Resizing = false;
            }

            // 检查游标是否被选中
            if (canvas.CurrentRodman.IsInRegion(p))
            {
                InitMoveGraphElementList();
                graphElement = canvas.CurrentRodman;
                selected = true;
            }

            // 索引检查是否有连接线控制点容器被选中
            foreach (ConnectorContainer connectorContainer in regionManager.GetConnectorContainerList(p))
            {
                if (selected) // 已经有图元被选中时自动跳出循环
                {
                    break;
                }

                // 先遍历检查是否有连接线控制点被选中
                ConnectorGraphElement connector = connectorContainer.GetConnectorInRegion(p);

                if (connector != null)
                {
                    graphElement = connector;
                    selected = true;
                    break;
                }

                if (connectorContainer.IsInRegion(p)) // 连接线被选中
                {
                    graphElement = connectorContainer;
                    selected = true;
                    break;
                }
            }

            foreach (SlotContainer slotContainer in regionManager.GetSlotContainerList(p)) // 索引检查是否有插槽容器被选中
            {
                if (selected) // 如果有图元被选中的话则自动跳出循环
                {
                    break;
                }

                // 检查是否有缩放控制点被选中
                ResizeControler resizeControler = slotContainer.GetResizeControlerInRegion(p);
                
                if (resizeControler != null)
                {
                    graphElement = resizeControler;
                    selected = true;
                    slotContainer.Resizing = true;
                    lastResizingGraphElement = slotContainer;
                    ChangeMouseCursur(resizeControler.CurrentDirection); // 改变鼠标指针形状
                    break;
                }
                
                // 检查是否有按钮被选中
                BaseButton baseButton = slotContainer.GetButtonInRegion(p);

                if (baseButton != null)
                {
                    if (baseButton is ConnectButton) // 是连接按钮
                    {
                        SlotGraphElement slot = (baseButton as ConnectButton).BindingSlot;

                        if (!slot.Binded && slot.IsOutSlot) // 插槽没有绑定连接线控制点,则新建连接线并绑定到当前插槽上
                        {
                            FlowChartCreateLineCommand cmd = new FlowChartCreateLineCommand(this, "创建图元");
                            InitFirstCommand(cmd);

                            if (cmd.Execute(new object[] { slot, p }))
                            {
                                AdjustCommandList(cmd);
                                newLine = selectedGraphElement as ConnectorContainer;
                                ConnectorGraphElement connector = newLine.GetConnectorList()[1];
                                graphElement = connector;
                                selected = true;
                            }

                            break;
                        }
                    }
                    else if (baseButton is AddButton) // 是添加按钮
                    {
                        SlotGraphElement slot = slotContainer.AddOutSlot();
                        graphElement = slotContainer;
                        selected = true;
                        break;
                    }
                }

                // 检查是否有注释图元被选中
                if (slotContainer.RemarkNode != null)
                {
                    if (slotContainer.RemarkNode.IsInRegion(p))
                    {
                        graphElement = slotContainer.RemarkNode;
                        selected = true;
                        break;
                    }
                }
                
                if (slotContainer.IsInRegion(p))
                {
                    SlotGraphElement slot = slotContainer.GetSlotInRegion(p);

                    if (slot != null)
                    {
                        graphElement = slot;
                        selected = true;
                        break;
                    }

                    slotContainer.Resizing = true;
                    lastResizingGraphElement = slotContainer;
                    graphElement = slotContainer;
                    selected = true;
                    break;
                }
            }

            if (selected) // 已经有图元被选中
            {
                SelectGraphElement(graphElement, p);
                userOperation = UserOperation.SingleSelect;

                if (selectedGraphElementList.Contains(selectedGraphElement)) // 进行多图元操作
                {
                    if (controlMode) // 在control模式下需要反选图元
                    {
                        selectedGraphElementList.Remove(selectedGraphElement);
                        selectedGraphElement.Selected = false;
                        selectedGraphElement = null;
                        lastSelectedGraphElement = null;
                        userOperation = UserOperation.None;

                        if (selectedGraphElementList.Count == 0)
                        {
                            canvas.CurrentMultiSelectMark.Visible = false;
                        }
                        else
                        {
                            CreateMultiSelectRegion();
                        }
                    }
                    else
                    {
                        userOperation = UserOperation.MultiSelect;
                    }
                }
                else
                {
                    if (controlMode) // 在control模式下需要加入图元
                    {
                        selectedGraphElementList.Add(selectedGraphElement);
                        CreateMultiSelectRegion();

                        userOperation = UserOperation.MultiSelect;
                    }
                    else
                    {
                        if (graphElement is Rodman)
                        {
                            userOperation = UserOperation.MoveRodman;
                            CreateMultiMoveRegion();
                        }

                        // 清空多选图元链表
                        ClearSelectedGraphElementList();
                    }
                }
            }
            else // 没有图元被选中
            {
                userOperation = UserOperation.RegionSelect;

                // 显示背景属性                
                documentManager.ShowObjectProperty(background);
                multiSelectStartPoint = p;

                // 清空多选图元链表
                ClearSelectedGraphElementList();
            }            

            RefreshCanvas();
        }
Пример #35
0
        /// <summary>
        /// 确认移动操作
        /// </summary>
        /// <param name="p">鼠标当前所在点</param>
        private void ConfirmLocation(Point point)
        {
            Point p = AdjustMouseLocation(point);
            Rectangle multiSelectRegion = canvas.CurrentMultiSelectMark.RegionRectangle;

            switch (userOperation) // 检查用户当前操作状态
            {                        
                case UserOperation.RegionSelect:
                    {
                        SelectGraphElementInRegion(multiSelectRegion);

                        break;
                    }
                case UserOperation.SingleSelect:
                    {
                        bool bind = false; // 是否已经绑定图元
                        bool unbind = false; // 是否已经解除绑定图元
                        selectedGraphElement.Moving = false;

                        // 自动调整绘图板大小
                        AdjustOutOfBorder();

                        if (selectedGraphElement is ConnectorGraphElement) // 拖动的是连接线控制点
                        {
                            ConnectorGraphElement connector = selectedGraphElement as ConnectorGraphElement;
                            SlotContainer slotContainer;
                            SlotGraphElement slot = null;

                            // 先解除绑定连接线控制点
                            if (connector.Binded)
                            {
                                slot = connector.GetBindingSlot();                                

                                if (slot != null)
                                {
                                    FlowChartDisconnectCommand cmd = new FlowChartDisconnectCommand(this, "解除连接图元");
                                    InitFirstCommand(cmd);

                                    if (cmd.Execute(slot)) // 命令执行成功
                                    {
                                        AdjustCommandList(cmd);
                                        unbind = true;
                                    }
                                }                                
                            }

                            if (lastActivatedGraphElement is SlotGraphElement) // 检查是否激活了插槽
                            {
                                slot = lastActivatedGraphElement as SlotGraphElement;

                                if (slot.IsInRegion(p)) // 绑定连接线控制点
                                {
                                    FlowChartConnectCommand cmd = new FlowChartConnectCommand(this, "连接图元");
                                    InitFirstCommand(cmd);

                                    if (cmd.Execute(new object[] { slot, connector })) // 命令执行成功
                                    {
                                        AdjustCommandList(cmd);
                                        bind = true;
                                    }
                                }
                            }
                            else if (lastActivatedGraphElement is SlotContainer) // 检查是否激活了插槽容器
                            {
                                slotContainer = lastActivatedGraphElement as SlotContainer;

                                if (slotContainer.IsInRegion(p)) // 绑定连接线控制点
                                {
                                    if (connector.IsHeadPoint) // 头连接点
                                    {
                                        slot = slotContainer.GetInSlot();
                                    }
                                    else if (connector.IsTailPoint) // 尾连接点
                                    {
                                        slot = slotContainer.GetOutSlot();
                                    }

                                    if (slot != null)
                                    {
                                        FlowChartConnectCommand cmd = new FlowChartConnectCommand(this, "连接图元");
                                        InitFirstCommand(cmd);

                                        if (cmd.Execute(new object[] { slot, connector })) // 命令执行成功
                                        {
                                            AdjustCommandList(cmd);
                                            bind = true;
                                        }
                                        else
                                        {
                                            slotContainer.RemoveSlot(slot);                                            
                                        }
                                    }
                                }
                            }

                            connector.Line.Moving = false;
                            connector.Line.AdjustRectangle();
                            regionManager.ChangeRegion((selectedGraphElement as ConnectorGraphElement).Line);
                        }
                        else if (selectedGraphElement is SlotContainer) // 拖动的是插槽容器
                        {
                            SlotContainer slotContainer = selectedGraphElement as SlotContainer;

                            foreach (ConnectorContainer line in slotContainer.GetConnectedLine())
                            {
                                AdjustLine(line, slotContainer);
                            }

                            slotContainer.RefreshRelevateLine(true);
                            AdjustLine(slotContainer);
                        }
                        else if (selectedGraphElement is ResizeControler) // 拖动的是缩放控制点
                        {
                            regionManager.ChangeRegion((selectedGraphElement as ResizeControler).Owner);
                        }

                        regionManager.ChangeRegion(selectedGraphElement);

                        if (!bind && !unbind) // 没有绑定和接触绑定图元,则是在移动图元
                        {
                            if (moveCommand.Execute(new object[] { selectedGraphElement, p })) // 命令执行成功
                            {
                                AdjustCommandList(moveCommand);
                            }
                        }
                        else // 已经绑定或者解除绑定图元
                        {
                            ConnectorContainer line = (selectedGraphElement as ConnectorGraphElement).Line;
                            
                            // 自动调整连接线
                            ConnectorGraphElement connector = selectedGraphElement as ConnectorGraphElement;
                            SlotContainer currentSlotContainer = null;
                            if (connector.IsHeadPoint)
                            {
                                currentSlotContainer = connector.Line.OutSlotContainer;
                            }
                            else
                            {
                                currentSlotContainer = connector.Line.InSlotContainer;
                            }
                            
                            AdjustLine(line, currentSlotContainer);
                        } 

                        break;
                    }
                case UserOperation.MultiSelect:
                    {                        
                        // 自动调整绘图板大小
                        AdjustOutOfBorder();

                        foreach (GraphElement graphElement in selectedGraphElementList)
                        {
                            if (graphElement is ConnectorContainer) // 连接线
                            {
                                graphElement.Visible = true;                               
                            }
                            else if (graphElement is SlotContainer) // 插槽容器
                            {
                                SlotContainer slotContainer = graphElement as SlotContainer;                                
                                slotContainer.RefreshRelevateLine(true);
                            }

                            regionManager.ChangeRegion(graphElement);
                            graphElement.Moving = false;
                        }
                       
                        // 自动调整连接线
                        List<SlotContainer> affectedSlotContainerList = regionManager.GetSlotContainerList(multiSelectRegion);
                        List<ConnectorContainer> affectedLineList = regionManager.GetConnectorContainerList(multiSelectRegion);

                        foreach (ConnectorContainer line in affectedLineList)
                        {
                            foreach (SlotContainer slotContainer in affectedSlotContainerList)
                            {
                                if (line.LineIntersect(slotContainer))
                                {                                    
                                    AdjustLine(line, null);
                                    break;
                                }
                            }
                        }                        

                        if (moveCommand.Execute(new object[] { selectedGraphElement, p })) // 命令执行成功
                        {
                            AdjustCommandList(moveCommand);
                        }

                        break;
                    }
                case UserOperation.MoveRodman:
                    {
                        // 自动调整绘图板大小
                        AdjustOutOfBorder();

                        foreach (GraphElement graphElement in moveGraphElementList)
                        {
                            if (graphElement is ConnectorContainer) // 连接线
                            {
                                ConnectorContainer line = graphElement as ConnectorContainer;
                                line.Visible = true;
                                line.AdjustRectangle();
                            }
                            else if (graphElement is SlotContainer) // 插槽容器
                            {
                                SlotContainer slotContainer = graphElement as SlotContainer;                                
                                slotContainer.RefreshRelevateLine(true);
                            }

                            regionManager.ChangeRegion(graphElement);
                            graphElement.Moving = false;
                        }

                        // 自动调整连接线
                        List<SlotContainer> affectedSlotContainerList = regionManager.GetSlotContainerList(multiMoveRegion);
                        List<ConnectorContainer> affectedLineList = regionManager.GetConnectorContainerList(multiMoveRegion);

                        foreach (ConnectorContainer line in affectedLineList)
                        {
                            foreach (SlotContainer slotContainer in affectedSlotContainerList)
                            {
                                if (line.LineIntersect(slotContainer))
                                {
                                    AdjustLine(line, null);
                                    break;
                                }
                            }
                        } 

                        if (moveCommand.Execute(new object[] { selectedGraphElement, p })) // 命令执行成功
                        {
                            AdjustCommandList(moveCommand);
                        }

                        break;
                    }
            }

            lockMoveDrag = false; // 拖动图元解锁
            userOperation = UserOperation.None;         
            canvas.Cursor = Cursors.Default; // 恢复绘图板的鼠标形状
            canvas.CurrentGuideLine.ClearGuideLineList();

            RefreshCanvas();
        }
Пример #36
0
 /// <summary>
 /// 开始滚动绘图板
 /// </summary>
 /// <param name="point">当前鼠标位置</param>
 public void BeginScrollCavas(Point point)
 {
     RecordLastSelectedPoint(AdjustMouseLocation(point));
     canvas.Cursor = Cursors.SizeAll;
     userOperation = UserOperation.ScrollCanvas;
 }
Пример #37
0
 /// <summary>
 /// 删除显示缩略的图元
 /// </summary>
 public void DeleteAbbreviateGraphElement()
 {
     userOperation = UserOperation.None;
     canvas.AbbreviatGraphElement = null;
     canvas.AbbreviateLine = null;
     RefreshCanvas();
 }               
Пример #38
0
 /// <summary>
 /// 重设编辑状态
 /// </summary>
 public void ResetUserOperation()
 {
     userOperation = UserOperation.None;
 }
Пример #39
0
        /// <summary>
        /// 创建显示缩略的图元
        /// </summary>
        /// <param name="graphType">图元的类型</param>
        /// <param name="point">图元的位置</param>
        /// <param name="autoConnect">是否自动连接</param>
        /// <param name="jumpConnect">是否跳转连接</param>
        public void CreateAbbreviateGraphElement(GraphType graphType, Point p, bool autoConnect)
        {
            Point point = Point.Empty;

            if (!p.IsEmpty)
            {
                point = p - new Size(canvas.AutoScrollPosition);
            }

            canvas.AbbreviatGraphElement = CreateAbbreviateGraphElement(graphType, point);
            userOperation = UserOperation.Create;
            this.autoConnect = autoConnect;

            if (autoConnect) // 记录当前选中的插槽容器
            {
                lastConnectGraphElement = selectedGraphElement as SlotContainer;

                // 创建缩略图元的连接线
                int tailX = (int)(lastConnectGraphElement.Location.X + lastConnectGraphElement.ElementSize.Width / 2);
                int tailY = (int)(lastConnectGraphElement.Location.Y + lastConnectGraphElement.ElementSize.Height);
                int headX = (int)(canvas.AbbreviatGraphElement.Location.X + canvas.AbbreviatGraphElement.ElementSize.Width / 2);
                int headY = (int)(canvas.AbbreviatGraphElement.Location.Y);

                canvas.AbbreviateLine = new ConnectorContainer(new Point(tailX, tailY), new Point(headX, headY));
                canvas.AbbreviateLine.Init();
            }
            else // 清空连接线
            {
                canvas.AbbreviateLine = null;
            }

            if (!p.IsEmpty) // 显示提示信息
            {
                InitTooltipText(canvas.AbbreviatGraphElement, "<underline>鼠标拖动移动图元\r\n<underline>鼠标点击创建图元\r\n<underline>按Esc键取消创建图元", point);
            }

            RefreshCanvas();
        }
Пример #40
0
 public CharSelectPacket(UserOperation op, string name)
 {
     operation = (int)op;
     this.name = name;
 }
Пример #41
0
 public void registerCallback(UserOperation operation, Action<object> callback)
 {
     this.registerCallback((int)operation, callback);
 }
Пример #42
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

#if TEST
            if (!filterContext.ActionDescriptor.ControllerDescriptor.ControllerType.Equals(typeof(GGCharityWebRole.Controllers.TestServicesController)))
            {
                if (!isDeploymentComplete)
                {
                    isDeploymentComplete = !GGCharityInstance.IsDeploymentPendingAsync().Result;
                    if (!isDeploymentComplete)
                    {
                        // In azure emulation, ports 8080 are used by the azure service and it forwards to 8081
                        // on which IIS actually listens.  The URL is to 8080, but IIS will see a request to 8081.
                        // If we try to return to the requested URL at 8081, we'll fail.
                        Uri returnUrl = filterContext.RequestContext.HttpContext.Request.GetEmulationAwareUrl();
                        filterContext.Result = RedirectToAction("WaitForDeployment", "TestServices", new { returnUrl = returnUrl });
                    }
                }
            }
#endif

            if (TempData.ContainsKey("DevClearCache")
                && (bool)TempData["DevClearCache"])
            {
                GGCharityWebRole.Core.GGCharityOutputCache.Get().Remove(filterContext.ActionDescriptor.ControllerDescriptor.ControllerName, filterContext.ActionDescriptor.ActionName);
            }

            UserOperation = UserOperation.Initialize(Trace, _controllerName, filterContext.ActionDescriptor.ActionName, GetAnonymousId());

            UserOperation.Details.TryAdd("AnonymousUserId", GetAnonymousId());
            UserOperation.Details.TryAdd("WebRoleInstance", RoleEnvironment.CurrentRoleInstance.Id);
            UserOperation.Details.TryAdd("BinaryVersion", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());

            ViewBag.UserOperation = UserOperation;
        }