private bool LoadMyInfo(bool bShowSuccessfulPopup = false)
        {
            //加载数据
            UserInfo_API_Get uiToGet;

            try
            {
                uiToGet = WebApiClientHelper.DoJsonRequest <UserInfo_API_Get>(GlobalData.GetResUri(string.Format("usersinfo/{0}", GlobalData.CurrentUserName)), EnuHttpMethod.Get);
            }
            catch (ClientException ex)
            {
                Commands.ShowPopupAlert.Execute(new ShowPopupAlertParam {
                    AlertMessage = ex.Message, AlertType = EnuPopupAlertType.Error
                }, this);
                return(false);
            }

            UserInfo_VM ui_vm = Mapper.Map <UserInfo_VM>(uiToGet);

            ui_vm.ModelType           = EnuModelType.View;
            gridMyInfoTab.DataContext = ui_vm;

            if (bShowSuccessfulPopup)
            {
                Commands.ShowPopupAlert.Execute(new ShowPopupAlertParam {
                    AlertMessage = "刷新我的信息成功.", AlertType = EnuPopupAlertType.Info
                }, this);
            }

            return(true);
        }
        private void buttonOK_Click(object sender, RoutedEventArgs e)
        {
            ChangePassword_VM vm = DataContext as ChangePassword_VM;

            if (vm != null)
            {
                if (vm.IsModelValid())
                {
                    Password_API_Put objectToPut = new Password_API_Put();
                    objectToPut.Password = WebApiClientHelper.MakeConfidentialMessage(vm.ConfirmPwd);
                    try
                    {
                        WebApiClientHelper.DoJsonRequest <Password_API_Put>(
                            GlobalData.GetResUri(string.Format("password/{0}", GlobalData.CurrentUserName)),
                            EnuHttpMethod.Put,
                            objToSend: objectToPut);
                    }
                    catch (ClientException ex)
                    {
                        vm.SetExtraError(ex.Message);
                        return;
                    }

                    WebApiClientHelper.Password = vm.ConfirmPwd;
                    DialogResult = true;
                    Close();
                }
            }
        }
        private void btnConfirm_Click(object sender, RoutedEventArgs e)
        {
            UserInfo_VM ui_vm = gridMyInfoTab.DataContext as UserInfo_VM;

            if (ui_vm != null)
            {
                if (ui_vm.IsModelValid())
                {
                    try
                    {
                        UserInfo_API_Put userput = Mapper.Map <UserInfo_VM, UserInfo_API_Put>(ui_vm);
                        WebApiClientHelper.DoJsonRequest <UserInfo_API_Put>(GlobalData.GetResUri(string.Format("usersinfo/{0}", ui_vm.UserName)), EnuHttpMethod.Put, objToSend: userput, tick: ui_vm.UpdateTicks);
                    }
                    catch (ClientException ex)
                    {
                        ui_vm.SetExtraError(ex.Message); //这是Popup以外的另一种异常显示方式
                        return;
                    }

                    LoadMyInfo();

                    Commands.ShowPopupAlert.Execute(new ShowPopupAlertParam {
                        AlertMessage = "修改信息成功.", AlertType = EnuPopupAlertType.Info
                    }, this);

                    Commands.GoToViewMode.Execute(null, this);
                }
            }
        }
 private void btnClearAvatar_Click(object sender, RoutedEventArgs e)
 {
     if (MessageBoxResult.OK == MessageBox.Show("要删除头像吗?", "确认", MessageBoxButton.OKCancel, MessageBoxImage.Question))
     {
         try
         {
             WebApiClientHelper.DoJsonRequest <int>(GlobalData.GetResUri(string.Format("avatars/{0}", GlobalData.CurrentUserName)),
                                                    EnuHttpMethod.Delete);
         }
         catch (ClientException ex)
         {
             Commands.ShowPopupAlert.Execute(new ShowPopupAlertParam {
                 AlertMessage = ex.Message, AlertType = EnuPopupAlertType.Error
             }, this);
             return;
         }
         SetAvatarImage(null);
     }
 }
Exemplo n.º 5
0
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            string   pwd     = Md5.MD5TwiceEncode("123456");
            Login_VM vmLogin = DataContext as Login_VM;

            if (vmLogin == null)
            {
                return;
            }

            if (vmLogin.IsModelValid())
            {
                WebApiClientHelper.UserName = vmLogin.UserName;
                WebApiClientHelper.Password = vmLogin.Password;
                UserInfo_API_Get userInfo;
                try
                {
                    userInfo = WebApiClientHelper.DoJsonRequest <UserInfo_API_Get>(GlobalData.GetResUri("entrance"), EnuHttpMethod.Get);
                }
                catch (ClientException ex)
                {
                    vmLogin.SetExtraError(ex.Message);
                    return;
                }

                //验证成功,记录用户信息
                GlobalData.CurrentUserName = userInfo.UserName;
                GlobalData.CurrentDispName = userInfo.RealName;
                GlobalData.CurrentRole     = userInfo.Role;

                //转入主窗口
                MainWindow main = new MainWindow();
                Application.Current.MainWindow = main;
                Close();
                main.Show();
            }
        }
        private bool LoadAllUsersInfo(bool bShowSuccessfulPopup = false)
        {
            //加载数据
            IEnumerable <UserInfo_API_Get> uisToGet;

            try
            {
                uisToGet =
                    WebApiClientHelper.DoJsonRequest <IEnumerable <UserInfo_API_Get> >(GlobalData.GetResUri("usersinfo"),
                                                                                       EnuHttpMethod.Get);
            }
            catch (ClientException ex)
            {
                Commands.ShowPopupAlert.Execute(new ShowPopupAlertParam {
                    AlertMessage = ex.Message, AlertType = EnuPopupAlertType.Error
                }, this);
                return(false);
            }

            IEnumerable <UserInfo_VM> uis_vm = Mapper.Map <IEnumerable <UserInfo_VM> >(uisToGet);

            foreach (var ui in uis_vm)
            {
                ui.ModelType = EnuModelType.View;
            }
            gridAllUsersInfoTab.DataContext = uis_vm;

            if (bShowSuccessfulPopup)
            {
                Commands.ShowPopupAlert.Execute(new ShowPopupAlertParam {
                    AlertMessage = "刷新所有用户信息成功.", AlertType = EnuPopupAlertType.Info
                }, this);
            }

            return(true);
        }
Exemplo n.º 7
0
        public void Execute(IJobExecutionContext context)
        {
            var flowEntities = FormulaHelper.GetEntities <WorkflowEntities>();

            #region 设定自动发送时间

            var taskExecList = flowEntities.S_WF_InsTaskExec.Where(c => c.ExecTime == null && c.TimeoutAutoPass == null).ToList();
            foreach (var taskExec in taskExecList)
            {
                int timeout = 0;
                var step    = taskExec.S_WF_InsTask.S_WF_InsDefStep;
                if (step.TimeoutAutoPass != null)
                {
                    timeout = (int)step.TimeoutAutoPass;
                }
                //TimeoutAutoPass 为负数时 轮巡直接自动通过
                if (timeout == 0)
                {
                    taskExec.TimeoutAutoPass       = DateTime.MaxValue;
                    taskExec.TimeoutAutoPassResult = "无设定";
                    continue;
                }
                var calendarService = FormulaHelper.GetService <ICalendarService>();
                taskExec.TimeoutAutoPass = calendarService.GetTimeoutTime((DateTime)taskExec.CreateTime, timeout);
            }
            flowEntities.SaveChanges();

            #endregion

            #region 超时自动执行任务

            taskExecList = flowEntities.S_WF_InsTaskExec.Where(c => c.ExecTime == null && string.IsNullOrEmpty(c.TimeoutAutoPassResult) && DateTime.Now > c.TimeoutAutoPass).ToList();
            string FlowApiUrl = System.Configuration.ConfigurationManager.AppSettings["FlowApiUrl"];
            if (FlowApiUrl.EndsWith("/"))
            {
                FlowApiUrl = FlowApiUrl.TrimEnd('/');
            }

            foreach (var taskExec in taskExecList)
            {
                try
                {
                    var    agentUser = FormulaHelper.GetUserInfoByID(taskExec.ExecUserID);
                    FlowFO flowFO    = new FlowFO();
                    //flowFO.AutoExecTask(taskExec.ID, "自动通过");

                    var routingList = flowFO.AutoExecGetRoutingList(taskExec.ID);
                    if (routingList.Count == 0)
                    {
                        continue;
                    }
                    var routing = routingList[0];
                    if (routing.Type == Workflow.Logic.RoutingType.Branch.ToString())
                    {
                        continue;
                    }

                    var    formInstanceID = taskExec.S_WF_InsFlow.FormInstanceID;
                    var    param          = flowFO.GetRoutingParams(routing, taskExec, formInstanceID);
                    string nextUserIDs    = param.userIDs;

                    var uri = string.Format("{0}/FlowTaskAPI/SubmitForm?id={1}&FormInstanceID={2}&TaskExecID={3}&NextExecUserIDs={4}&Comment={5}&ExecUserID={6}&UserAccount={7}&IsMobileRequest=6",
                                            FlowApiUrl, routingList[0].ID, formInstanceID, taskExec.ID, nextUserIDs, "自动通过", taskExec.TaskUserID, agentUser.Code);
                    var str = WebApiClientHelper.DoJsonRequest(uri, EnuHttpMethod.Post, new { FormDic = "{ID:\"" + formInstanceID + "\"}", FlowCode = "" });

                    //5.3平台FlowTaskAPI
                    //var uri = string.Format("{0}/FlowTaskAPI/0/Submit?id={1}&FormInstanceID={2}&TaskExecID={3}&NextExecUserIDs={4}&Comment={5}&ExecUserID={6}&UserAccount={7}",
                    //    FlowApiUrl, routingList[0].ID, formInstanceID, taskExec.ID, nextUserIDs, "自动通过", taskExec.TaskUserID, agentUser.Code);
                    //var str = WebApiClientHelper.DoJsonRequest(uri, EnuHttpMethod.Get);

                    if (str.ToLower() == "true")
                    {
                        taskExec.TimeoutAutoPassResult = "Success";
                        flowEntities.SaveChanges();
                    }
                    else
                    {
                        throw new Exception("FlowTaskAPI报错");
                    }
                }
                catch (Exception e)
                {
                    SQLHelper sqlHelper = SQLHelper.CreateSqlHelper(ConnEnum.WorkFlow);
                    string    sql       = "update S_WF_InsTaskExec set TimeoutAutoPassResult='{0}' where ID='{1}'";
                    string    str       = e.Message ?? "";
                    if (str.Length > 500)
                    {
                        str = str.Substring(0, 500);
                    }
                    sql = string.Format(sql, str, taskExec.ID);
                    sqlHelper.ExecuteNonQuery(sql); //记录错误
                }
            }

            #endregion
        }