Beispiel #1
0
        /// <summary>
        /// 获取Token
        /// </summary>
        /// <returns></returns>
        public static string GetToken( )
        {
            if (!string.IsNullOrEmpty(new Infrastructure.Cache.ObjCacheProvider <string>().GetCache("access_token")))
            {
                return(new Infrastructure.Cache.ObjCacheProvider <string>().GetCache("access_token"));
            }
            string _CorpId     = GetCorpId();
            string _CorpSecret = CorpSecret();
            var    result      = new Response <bool>();

            try
            {
                string           url      = string.Format("https://oapi.dingtalk.com/gettoken?corpid={0}&corpsecret={1}", _CorpId, _CorpSecret);
                string           response = Infrastructure.Web.WebHelper.HttpWebRequest(url);
                TokenResultModel resModel = Newtonsoft.Json.JsonConvert.DeserializeObject <TokenResultModel>(response);
                if (resModel != null)
                {
                    if (resModel.errcode == 0)
                    {
                        result.Code = 200;

                        bool falg = new Infrastructure.Cache.ObjCacheProvider <string>().Create("access_token", resModel.access_token, DateTime.Now.AddSeconds(resModel.expires_in));
                        return(resModel.access_token);
                    }
                }
            }
            catch (Exception ex)
            {
                result.Code = 500;
                return("");
            }

            return(null);
        }
Beispiel #2
0
        /// <summary>
        /// 创建数据-点击发送
        /// </summary>
        /// <param name="Id">FEntryID</param>
        public void Add(string FBillNo, string FEntryID)
        {
            //验证 A_PBOM是否存在
            if (Repository.Find(t => t.FEntryID.Equals(FEntryID) && t.BillNo.Equals(FBillNo)).Count() <= 0)
            {
                var list = ProductFeedOrderApp.GetProFeedDataByBillNo(FBillNo, FEntryID);
                if (list.Count <= 0)
                {
                    throw new Exception("找不到数据");
                }
                var temp = list.FirstOrDefault();

                UserWithAccessedCtrls userCurrent = new Infrastructure.Cache.ObjCacheProvider <UserWithAccessedCtrls>().GetCache("userCard");
                if (userCurrent == null)
                {
                    throw new Exception("用户已过期");
                }

                //创建头
                A_PBOM head = new A_PBOM();
                head.BillNo     = FBillNo;
                head.ContactNo  = temp.FHeadSelfS0155;
                head.CrateId    = userCurrent.User.Id;
                head.CreateName = userCurrent.User.Name;
                head.CreateTime = DateTime.Now;
                head.CustomName = temp.ClientName;
                head.DeadLine   = temp.FHeadSelfS0150;
                head.FeedOrder  = temp.productFeed;
                head.FEntryID   = FEntryID;
                head.IsAttach   = false;
                head.MO         = temp.pro_OutSourceOrder;
                head.PBOMStates = 0;
                head.ProName    = temp.FName;
                head.ProNumber  = temp.FNumber;
                head.Remark     = "";
                head.AuxQty     = temp.PlanUsage;
                Repository.Add(head);
                //创建行
                int successcount = 0;
                int failcount    = 0;
                foreach (var item in list)
                {
                    var entry = new A_PBOMEntry();
                    entry.BaseUnit        = item.BaseUnit;
                    entry.CrateId         = userCurrent.User.Id;
                    entry.CreateName      = userCurrent.User.Name;
                    entry.CreateTime      = DateTime.Now;
                    entry.IsOk            = false;
                    entry.PBOMId          = item.BOMOrderNo;
                    entry.A_PBOMId        = head.Id;
                    entry.PlanUsage       = item.PlanUsage;
                    entry.Qty             = item.FHeadSelfS0151;
                    entry.Remark          = "";
                    entry.SonItemName     = item.SonItemName;
                    entry.SonItemNumberNo = item.SonItemNumberNo;
                    entry.RecordId        = Convert.ToString(item.RecordId);
                    try
                    {
                        A_PBOMEntryApp.Add(entry);
                        successcount++;
                    }
                    catch (Exception)
                    {
                        failcount++;
                    }
                }
            }
            else
            {
                throw new Exception("数据已存在");
            }
        }