Beispiel #1
0
        public static string GetId()
        {
            var i6Info  = (I6WebAppInfo)System.Web.HttpContext.Current.Session["NGWebAppInfo"];
            var appInfo = new Enterprise3.WebApi.Client.Models.AppInfoBase
            {
                /**********************************
                * 从应用信息中读取;
                **********************************/
                OCode    = i6Info.OCode,  //"001",
                OrgName  = "组织名称",
                TokenKey = string.Empty,
                //UCode = i6Info.UCode, //"0006",
                //UName = "",
                UserKey      = i6Info.LoginID,                         //"9999",
                UserName     = "******",
                AppKey       = "D31B7F91-3068-4A49-91EE-F3E13AE5C48C", // 从xml文件中读取;
                AppSecret    = "103CB639-840C-4E4F-8812-220ECE3C4E4D",
                DbServerName = "10.0.17.118",
            };

            if (_client == null)
            {
                /***********************************************
                * 目前的服务地址是日志服务器地址;
                * 之后会从表fg_info中的i6WebApiUri字段读取;
                ***********************************************/
                _client = new Enterprise3.WebApi.Client.WebApiClient("http://10.0.15.106:9094/", appInfo,
                                                                     Enterprise3.WebApi.Client.Enums.EnumDataFormat.Json);
            }

            var billIdEntity = new Enterprise3.Common.Model.ReqBillIdEntity
            {
                TableName   = "c_pbc_field_service",   // 修改成可配置;
                PrimaryName = "c_code",
                NeedCount   = 1,
                Step        = 1
            };
            var res = _client.Post <Enterprise3.Common.Model.ReqBillIdEntity>("api/common/BillNo/GetBillIdIncrease",
                                                                              billIdEntity);
            var billNo = (BillNoInfo)JsonConvert.DeserializeObject(res.Content, typeof(BillNoInfo));

            return(billNo.BillIdList[0].ToString());
        }
Beispiel #2
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
        }