Ejemplo n.º 1
0
 public static void RollbackBillNo(string billNoReqType, ResBillNoOrIdEntity entity)
 {
     try
     {
         var billNoHelper = new Enterprise3.WebApi.SDK.Common.BillNoHelper(billNoReqType);
         billNoHelper.RollbackBillNo(entity);
     }
     catch (Exception ex)
     {
         throw new Exception("回滚单据用户编码失败:" + ex.Message);
     }
 }
Ejemplo n.º 2
0
 public static List <long> GetBillId(string tablename, string key, int needCount = 1)
 {
     try
     {
         var billNoCommon       = new Enterprise3.WebApi.SDK.Common.BillNoHelper();
         ResBillNoOrIdEntity en = billNoCommon.GetBillId(tablename, key, needCount);
         return(en.BillIdList.ToList());
     }
     catch (Exception ex)
     {
         throw new Exception("获取编码失败:" + ex.Message);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取多个phid
        /// </summary>
        /// <param name="needCount">设置需要返回几个phid</param>
        /// <param name="primaryName">主键名</param>
        /// <param name="step">如果传1返回的phid值为目前表里phid最大的值加1,传2返回最大的值加2,以此类推</param>
        /// <param name="tableName">表名</param>
        /// <param name="connstring">数据库连接串</param>
        /// <returns></returns>
        public IList <long> GetPhidList(int needCount, string primaryName, int step, string tableName)
        {
#if DEBUG
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
#endif
            IList <long> phid = new List <long>();
            try
            {
                string appkey    = System.Configuration.ConfigurationManager.AppSettings["AppKey"] == null ? string.Empty : System.Configuration.ConfigurationManager.AppSettings["AppKey"].ToString();
                string appsecret = System.Configuration.ConfigurationManager.AppSettings["AppSecret"] == null ? string.Empty : System.Configuration.ConfigurationManager.AppSettings["AppSecret"].ToString();

                string dbname = string.Empty;

                Enterprise3.WebApi.Client.Models.AppInfoBase appInfo = new Enterprise3.WebApi.Client.Models.AppInfoBase
                {
                    AppKey    = appkey,                 // "D31B7F91-3068-4A49-91EE-F3E13AE5C48C",
                    AppSecret = appsecret,              //"103CB639-840C-4E4F-8812-220ECE3C4E4D",
                    DbName    = NG3.AppInfoBase.DbName, //可不传,默认为默认账套
                                                        //UserId = 77,
                                                        //OrgId = 166,
                    DbServerName = NG3.AppInfoBase.DbServerName,
                };

                string servicebaseurl = Geti6sUrl();

                WebApiClient client = new WebApiClient(servicebaseurl, appInfo);

                ReqBillIdEntity req = new ReqBillIdEntity
                {
                    NeedCount   = needCount,
                    PrimaryName = primaryName,
                    Step        = step,
                    TableName   = tableName
                };

                var res = client.Post <ResBillNoOrIdEntity, ReqBillIdEntity>("api/common/billno/getbillidincrease", req);

                if (res.IsError || res.Data == null)
                {
                    return(phid);
                }
                //throw new RuleException(Resources.CallBillNoServiceError + System.Environment.NewLine + res.ErrMsg, BillNoReqType);


                ResBillNoOrIdEntity ReqBillNoOrIdCommitEntity = new ResBillNoOrIdEntity
                {
                    BillIdList = res.Data.BillIdList,
                };

                phid = ReqBillNoOrIdCommitEntity.BillIdList;

                return(phid);
            }
            catch (Exception ex)
            {
                return(phid);
            }
#if DEBUG
            stopwatch.Stop();
            Console.WriteLine("编码规则方法,GetBillId方法执行时间总长:{0}毫秒", stopwatch.ElapsedMilliseconds);
#endif
        }
Ejemplo n.º 4
0
        public ActionResult Edit()
        {
            ViewBag.OType   = System.Web.HttpContext.Current.Request.Params["otype"];//操作类型
            ViewBag.wfOType = System.Web.HttpContext.Current.Request.Params["wfotype"];

            //工作流处理
            if (!string.IsNullOrEmpty(ViewBag.wfOType) && ViewBag.OType == "view")
            {
                var wfPiid   = System.Web.HttpContext.Current.Request.Params["wfpiid"];
                var wfTaskId = System.Web.HttpContext.Current.Request.Params["wftaskid"];
                ViewBag.Title = "员工权限申请-审核";

                try
                {
                    var client = new WebApiClient(ServiceURL, ApiReqParam, EnumDataFormat.Json);

                    var param = new ParameterCollection();
                    param.Add("piid", wfPiid);
                    param.Add("taskid", wfTaskId);
                    param.Add("wfotype", ViewBag.wfOType);

                    var res = client.Get <string>("api/workflow3/WorkFlowApi/GetFlowExecutionInfo", param);
                    ViewBag.WorkFlowInfo = res.Data;
                }
                catch (SystemException ex)
                {
                    throw ex;
                }

                ViewBag.Phid = System.Web.HttpContext.Current.Request.Params["id"];
                DataTable dt = proxy.GetHrRightApplyDt(ViewBag.Phid);
                ViewBag.BillNo      = dt.Rows[0]["billno"];
                ViewBag.BillName    = dt.Rows[0]["billname"];
                ViewBag.FillPsnId   = dt.Rows[0]["fillpsnid"];
                ViewBag.FillPsnName = dt.Rows[0]["fillpsnname"];
                ViewBag.FillDate    = dt.Rows[0]["filldate"];
                ViewBag.Remark      = dt.Rows[0]["remark"];
            }
            else
            {
                if (ViewBag.OType == "add")
                {
                    string hrid = proxy.GetUserHrid(NG3.AppInfoBase.UserID.ToString());
                    if (string.IsNullOrEmpty(hrid) || hrid == "0")
                    {
                        HttpContext.Response.Redirect("~/SUP/ErrorPage?msg=操作员没有对应员工,请设置!"); //重定向到错误页面
                    }
                    ViewBag.Hrid = hrid;

                    ResBillNoOrIdEntity en = SUP.Common.Rule.CommonUtil.GetBillNo("HrRightApply");
                    ViewBag.BillNo = en.BillNoList[0];
                    if (en.BillIdList != null)
                    {
                        ViewBag.Phid = en.BillIdList[0];
                    }
                }
                else if (ViewBag.OType == "edit" || ViewBag.OType == "view")
                {
                    ViewBag.Phid        = System.Web.HttpContext.Current.Request.Params["phid"];
                    ViewBag.BillNo      = System.Web.HttpContext.Current.Request.Params["billno"];
                    ViewBag.BillName    = System.Web.HttpContext.Current.Request.Params["billname"];
                    ViewBag.FillPsnId   = System.Web.HttpContext.Current.Request.Params["fillpsnid"];
                    ViewBag.FillPsnName = System.Web.HttpContext.Current.Request.Params["fillpsnname"];
                    ViewBag.FillDate    = System.Web.HttpContext.Current.Request.Params["filldate"];
                    ViewBag.Remark      = System.Web.HttpContext.Current.Request.Params["remark"];
                    ViewBag.Hrid        = proxy.GetUserHrid(ViewBag.FillPsnId);
                }
            }

            return(View("HrRightApplyEdit"));
        }
Ejemplo n.º 5
0
        public bool SaveHrRightApply(string phid, string billno, string billname, string remark, string applicantObj, string orgObj, string roleObj, string otype, string removeApplicant)
        {
            JObject applicantJObj = JObject.Parse(applicantObj);
            JObject orgJObj       = JObject.Parse(orgObj);
            JObject roleJObj      = JObject.Parse(roleObj);

            try
            {
                DbHelper.BeginTran();

                if (otype == "add")
                {
                    if (string.IsNullOrEmpty(phid))
                    {
                        phid = SUP.Common.Rule.CommonUtil.GetPhId("fg3_hrrightapply").ToString();
                    }
                    dac.InsertHrRightApplyDt(phid, billno, billname, remark);
                }
                else if (otype == "edit")
                {
                    dac.UpdateHrRightApplyDt(billno, billname, remark);
                }

                JArray applicantJArr = JArray.Parse(applicantJObj["store"].ToString());
                if (otype == "edit")
                {
                    dac.DeleteApplicantDt(billno);
                }
                foreach (var applicant in applicantJArr)
                {
                    long   applicantphid = SUP.Common.Rule.CommonUtil.GetPhId("fg3_hrrightapplicant");
                    string hrid          = applicant["hrid"].ToString();
                    string userid        = applicant["userid"].ToString();
                    if (otype == "edit" && removeApplicant.IndexOf(userid + ",") > -1)
                    {
                        removeApplicant = removeApplicant.Replace(userid + ",", "");
                    }
                    string hrname          = applicant["hrname"].ToString();
                    string dept            = applicant["dept"].ToString();
                    string station         = applicant["station"].ToString();
                    string applicantremark = applicant["remark"].ToString();

                    dac.InsertApplicantDt(applicantphid, billno, hrid, userid, hrname, dept, station, applicantremark);

                    if (orgJObj[userid] != null)
                    {
                        JArray orgJArr = JArray.Parse(orgJObj[userid].ToString());
                        if (otype == "edit")
                        {
                            dac.DeleteOrgDt(billno, userid);
                        }
                        foreach (var org in orgJArr)
                        {
                            long   orgphid  = SUP.Common.Rule.CommonUtil.GetPhId("fg3_hrrightorg");
                            string orgid    = org["orgid"].ToString();
                            string orgname  = org["orgname"].ToString();
                            int    isselect = org["select"].ToString() == "True" ? 1 : 0;

                            int fillpsnorg   = 0;
                            int applicantorg = 0;
                            if (org["fillpsnorg"].ToString() == "登录组织/信息组织")
                            {
                                fillpsnorg = 1;
                            }
                            else if (org["fillpsnorg"].ToString() == "信息组织")
                            {
                                fillpsnorg = 2;
                            }
                            if (org["applicantorg"].ToString() == "登录组织/信息组织")
                            {
                                applicantorg = 1;
                            }
                            else if (org["applicantorg"].ToString() == "信息组织")
                            {
                                applicantorg = 2;
                            }

                            dac.InsertOrgDt(orgphid, billno, userid, orgid, orgname, isselect, fillpsnorg, applicantorg);

                            if (roleJObj[userid + "|" + orgid] != null)
                            {
                                if (otype == "edit")
                                {
                                    dac.DeleteRoleDt(billno, userid, orgid);
                                }
                                JArray roleJArr = JArray.Parse(roleJObj[userid + "|" + orgid].ToString());
                                foreach (var role in roleJArr)
                                {
                                    long   rolephid = SUP.Common.Rule.CommonUtil.GetPhId("fg3_hrrightrole");
                                    string roleid   = role["roleid"].ToString();
                                    string rolename = role["rolename"].ToString();
                                    if (role["select"].ToString() == "True")
                                    {
                                        dac.InsertRoleDt(rolephid, billno, userid, orgid, roleid, rolename);
                                    }
                                }
                            }
                        }
                    }
                }

                if (otype == "edit" && !string.IsNullOrEmpty(removeApplicant))
                {
                    string[] useridArr = removeApplicant.Split(',');
                    for (int i = 0; i < useridArr.Length - 1; i++)
                    {
                        dac.DeleteRemovedOrgRoleDt(billno, useridArr[i]);
                    }
                }

                if (otype == "add")
                {
                    ResBillNoOrIdEntity entity = SUP.Common.Rule.CommonUtil.GetBillNoIntensive("HrRightApply");
                    SUP.Common.Rule.CommonUtil.CommitBillNo("HrRightApply", entity);//提交单据用户编码,此操作将单据用户编码永久占用
                }

                DbHelper.CommitTran();
            }
            catch
            {
                DbHelper.RollbackTran();
                return(false);
            }

            return(true);
        }