Beispiel #1
0
        private void AddTeam(CommonResponseData commonResponse)
        {
            TeamData data = new TeamData
            {
                teamName         = team_name_textBox.Text.Trim(),
                projectCode      = projectInfo.projectCode,
                organizationCode = loginUser.OrganizationCode
            };

            TeamRequestService.RequestAddAction(data, loginUser, ref commonResponse);
            if (null != commonResponse)
            {
                if (commonResponse.success)
                {
                    Common.SuccessAlert("新增成功!");
                    DialogResult = DialogResult.OK;
                    Close();
                }
                else
                {
                    Common.ErrAlert("新增操作发生数据解析错误!");
                    DialogResult = DialogResult.Cancel;
                }
            }
            else
            {
                Common.ErrAlert("新增操作异常,请检查网络连接或联系管理员!");
                DialogResult = DialogResult.Cancel;
            }
        }
Beispiel #2
0
        private void UpdateTeam(CommonResponseData commonResponse)
        {
            TeamData data = new TeamData
            {
                id               = teamData.id,
                teamName         = team_name_textBox.Text.Trim(),
                projectCode      = projectInfo.projectCode,
                organizationCode = loginUser.OrganizationCode
            };

            TeamRequestService.RequestUpdateAction(data, loginUser, ref commonResponse);
            log.Debug(JsonConvert.SerializeObject(commonResponse, Formatting.Indented));
            if (null != commonResponse)
            {
                if (commonResponse.success)
                {
                    Common.SuccessAlert("修改操作成功!");
                    DialogResult = DialogResult.OK;
                    Close();
                }
                else
                {
                    Common.ErrAlert("修改操作发生数据解析错误!");
                    DialogResult = DialogResult.Cancel;
                }
            }
            else
            {
                Common.ErrAlert("修改操作异常,请检查网络连接或联系管理员!");
                DialogResult = DialogResult.Cancel;
            }
        }
Beispiel #3
0
        private void submit_button_Click(object sender, System.EventArgs e)
        {
            if (string.Empty.Equals(idCardNumber_textBox.Text) ||
                string.Empty.Equals(workerName_textBox.Text) ||
                string.Empty.Equals(address_textBox.Text) ||
                string.Empty.Equals(startTime_textBox.Text) ||
                string.Empty.Equals(endTime_textBox.Text) ||
                string.Empty.Equals(is_sue_textBox.Text) ||
                string.Empty.Equals(nationName_textBox.Text) ||
                null == idcardNumber_pictureBox.BackgroundImage
                )
            {
                Common.ErrAlert("请先读取二代身份证后再提交!");
                return;
            }
            if (null == picbPreview.Image)
            {
                Common.ErrAlert("请先抓拍人员现场照后再提交!");
                return;
            }
            ImageBase64 = Common.ImageToBase64(picbPreview.Image);
            CommonResponseData    commonResponse       = new CommonResponseData();
            ManagerAddRequestData workerAddRequestData = new ManagerAddRequestData
            {
                idCardPhoto           = Common.ImageToBase64(idcardNumber_pictureBox.BackgroundImage),
                idCardNumber          = idCardNumber_textBox.Text.Trim(),
                ocvFace               = ImageBase64,
                idCardType            = 1,
                workerName            = workerName_textBox.Text.Trim(),
                nation                = Common.GetNationNum(nations, nationName_textBox.Text.Trim()).num.ToString(),
                address               = address_textBox.Text.Trim(),
                isSue                 = is_sue_textBox.Text.Trim(),
                startTime             = startTime_textBox.Text.Trim(),
                endTime               = endTime_textBox.Text.Trim().Equals("长期") ? "99991231" : endTime_textBox.Text.Trim(),
                projectCode           = workerProjectInfo.projectCode,
                gender                = Common.GetGenderFromIDCardNumber(idCardNumber_textBox.Text.Trim()).Equals("男") ? 0 : 1,
                birthday              = Common.GetBirthdayFromIDCardNumber(idCardNumber_textBox.Text.Trim()),
                loginOrganizationCode = loginUser.OrganizationCode//新增的字段
            };

            ManagerRequestService.RequestAddAction(workerAddRequestData, loginUser, ref commonResponse);
            if (null != commonResponse)
            {
                if (commonResponse.success)
                {
                    Common.SuccessAlert("操作成功!");
                }
                else
                {
                    Common.ErrAlert("操作失败!\n" + commonResponse.message);
                }
                DialogResult = DialogResult.OK;
            }
            else
            {
                Common.SuccessAlert("操作异常,请联系管理员!");
                DialogResult = DialogResult.None;
            }
        }
        /// <summary>
        /// 删除班组
        /// </summary>
        /// <param name="teamData"></param>
        /// <param name="loginUser"></param>
        /// <param name="commonResponse"></param>
        public static void RequestDelAction(TeamData teamData, LoginUser loginUser, ref CommonResponseData commonResponse)
        {
            object data = new
            {
                teamData.id,
                teamData.organizationCode
            };

            Common.PostRequest(data, ConfigurationManager.AppSettings["baseURL"].ToString(), Properties.Resources.DeleteTeam, loginUser.LoginToken, "application/x-www-form-urlencoded", ref commonResponse);
        }
        /// <summary>
        /// 新增班组
        /// </summary>
        /// <param name="teamData"></param>
        /// <param name="loginUser"></param>
        /// <param name="commonResponse"></param>
        public static void RequestAddAction(TeamData teamData, LoginUser loginUser, ref CommonResponseData commonResponse)
        {
            object data = new
            {
                teamData.teamName,
                teamData.projectCode,
                teamData.organizationCode
            };

            Common.PostRequest(data, ConfigurationManager.AppSettings["baseURL"].ToString(), Properties.Resources.AddTeam, loginUser.LoginToken, "application/json", ref commonResponse);
        }
Beispiel #6
0
        private void submit_button_Click(object sender, System.EventArgs e)
        {
            if (string.Empty.Equals(team_name_textBox.Text.Trim()))
            {
                Common.ErrAlert("请填写班组名称!");
                return;
            }
            CommonResponseData commonResponse = new CommonResponseData();

            if (null == teamData)
            {
                AddTeam(commonResponse);
            }
            else
            {
                UpdateTeam(commonResponse);
            }
        }
Beispiel #7
0
        public static void RequestDelAction(ManagerListData manager,
                                            LoginUser loginUser,
                                            ref CommonResponseData commonResponse)
        {
            object data = new
            {
                manager.projectCode,
                idCardType = 1,
                manager.idCardNumber
            };

            Common.PostRequest(data,
                               ConfigurationManager.AppSettings["baseURL"].ToString(),
                               Properties.Resources.DeleteWorker,
                               loginUser.LoginToken,
                               "application/json",
                               ref commonResponse);
        }
Beispiel #8
0
        T Convert_TemplateResponse <T>(string api_type, string paramJson, ref bool IsSuccess, ref string msg)
        {
            try
            {
                string             returnContent      = GetApiResponse(api_type, paramJson);
                CommonResponseData commonResponseData = returnContent.ToJsonObject <CommonResponseData>();
                if (!commonResponseData.IsEmpty() && commonResponseData.status == 0)
                {
                    IsSuccess = true;
                    return(commonResponseData.data.ToJsonStr().ToJsonObject <T>());
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(default(T));
        }
Beispiel #9
0
        private void manager_del_button_Click(object sender, EventArgs e)
        {
            if (manager_dataGridView.SelectedRows.Count == 0)
            {
                Common.ErrAlert("请选择一行再删除!");
                return;
            }
            ManagerListData manager = managerListData.ToList()[manager_dataGridView.SelectedRows[0].Index];

            if (null == manager)
            {
                Common.ErrAlert("加载选择的管理人员数据发生错误,请重试!");
                return;
            }
            if (null == ManagerProjectInfo)
            {
                Common.ErrAlert("请选择项目后再操作!");
                return;
            }
            if (MessageBox.Show(string.Format("真的要删除管理人员 {0} 吗?", manager.workerName), "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
            {
                return;
            }
            CommonResponseData commonResponseData = new CommonResponseData();

            ManagerRequestService.RequestDelAction(manager, loginUser, ref commonResponseData);
            if (null != commonResponseData)
            {
                if (commonResponseData.success)
                {
                    Common.SuccessAlert("删除成功!");
                    LoadManagersData(manager_comboBox);
                }
                else
                {
                    Common.ErrAlert("删除失败!\n" + commonResponseData.message);
                }
            }
            else
            {
                Common.ErrAlert("网络或服务异常,请联系管理员!");
            }
        }
Beispiel #10
0
        private void del_team_button_Click(object sender, EventArgs e)
        {
            if (null == TeamProjectInfo)
            {
                Common.ErrAlert("请选择项目后再操作!");
                return;
            }
            if (team_dataGridView.SelectedRows.Count == 0)
            {
                Common.ErrAlert("请选择一行再修改!");
                return;
            }
            TeamData teamData = teamDatas.ToList()[team_dataGridView.SelectedRows[0].Index];

            if (null == teamData)
            {
                Common.ErrAlert("加载选择的班组数据发生错误!");
                return;
            }
            if (MessageBox.Show(string.Format("真的要删除班组 {0} 吗?", teamData.teamName), "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
            {
                return;
            }
            CommonResponseData commonResponse = new CommonResponseData();

            TeamRequestService.RequestDelAction(teamData, loginUser, ref commonResponse);
            if (null != commonResponse)
            {
                if (commonResponse.success)
                {
                    Common.SuccessAlert("删除操作成功!");
                    TeamDataGridViewLoad();
                }
                else
                {
                    Common.ErrAlert("删除失败!\n" + commonResponse.message);
                }
            }
            else
            {
                Common.ErrAlert("删除操作异常,请检查网络连接或联系管理员!");
            }
        }
Beispiel #11
0
        public static void RequestAddAction(ManagerAddRequestData managerAddRequestData,
                                            LoginUser loginUser,
                                            ref CommonResponseData commonResponse)
        {
            List <ManagerAddRequestData> list = new List <ManagerAddRequestData>();

            list.Add(managerAddRequestData);
            object data = new
            {
                employeeListStr = JsonConvert.SerializeObject(list),
                type            = 3
            };

            Common.PostRequest(data,
                               ConfigurationManager.AppSettings["baseURL"].ToString(),
                               Properties.Resources.AddEmployees,
                               loginUser.LoginToken,
                               "application/json",
                               ref commonResponse);
        }
Beispiel #12
0
        public async void Send(string _apiUrl, string jsonData, Action <string> _call, string customHost = null, Action pFinishedNoSuccess = null)
        {
            if (WebMessageHelper.IsNeedShowJuhua(_apiUrl))
            {
                UIComponent.Instance.Prompt();
            }
            string url = customHost == null ? $"{GlobalData.Instance.WebURL}{_apiUrl}" : $"{customHost}{_apiUrl}";

            Log.Debug($"send-> url = {url}");

            requests.Add(GameUtil.HttpsPost(url, jsonData, (request, response) =>
            {
                RemoveRequest(request);
                switch (request.State)
                {
                case HTTPRequestStates.Finished:
                    if (response.IsSuccess)
                    {
                        Log.Debug($"response-> url = {url} jsonData = {jsonData} 结果= {response.DataAsText}");
                        CommonResponseData data = JsonHelper.FromJson <CommonResponseData>(response.DataAsText);
                        if (data.status == 105)
                        {
                            //维护弹窗
                            UIComponent.Instance.ShowNoAnimation(UIType.UIDialog,
                                                                 new UIDialogComponent.DialogData()
                            {
                                type          = UIDialogComponent.DialogData.DialogType.Commit,
                                title         = "",
                                content       = string.Format(LanguageMgr.mInstance.GetLanguageForKey("ServerMaintenance"), data.msg),
                                contentCommit = CPErrorCode.LanguageDescription(10008),
                                actionCommit  = null,
                                actionCancel  = null
                            });
                        }
                        if (_call != null)
                        {
                            _call(response.DataAsText);
                        }
                    }
                    else
                    {
                        UIComponent.Instance.Toast(response.StatusCode);
                        if (pFinishedNoSuccess != null)
                        {    //追加的.下拉列表 不成功时 收缩下(加载中...)
                            pFinishedNoSuccess();
                        }
                    }
                    break;

                case HTTPRequestStates.Error:
                    string exception = request.Exception != null
                                ? (request.Exception.Message + "\n" + request.Exception.StackTrace) : "No Exception";
                    Log.Debug($"Request Finished with Error!  {exception}");
                    // UIComponent.Instance.Toast("请求错误");
                    if (pFinishedNoSuccess != null)
                    {
                        pFinishedNoSuccess();
                    }
                    break;

                case HTTPRequestStates.Aborted:
                    Log.Debug($"Request Aborted!");
                    // UIComponent.Instance.Toast("请求拒绝");
                    if (pFinishedNoSuccess != null)
                    {
                        pFinishedNoSuccess();
                    }
                    break;

                case HTTPRequestStates.ConnectionTimedOut:
                    Log.Debug($"Connection Timed Out!");
                    // UIComponent.Instance.Toast("连接超时");
                    if (pFinishedNoSuccess != null)
                    {
                        pFinishedNoSuccess();
                    }
                    break;

                case HTTPRequestStates.TimedOut:
                    Log.Debug($"Processing the request Timed Out!");
                    // UIComponent.Instance.Toast("网络超时");
                    if (pFinishedNoSuccess != null)
                    {
                        pFinishedNoSuccess();
                    }
                    break;

                default:
                    UIComponent.Instance.Toast($"未知错误 State = {request.State} ");
                    if (pFinishedNoSuccess != null)
                    {
                        pFinishedNoSuccess();
                    }
                    break;
                }
            }), (int)HTTPRequestStates.Initial);
        }