Ejemplo n.º 1
0
        public Result NewShareCode(string qaFolderId, string account, string durationTime)
        {
            var result = new Result();

            try
            {
                var shareCode      = Common.Common.Encrypt(qaFolderId + "," + account + "," + DateTime.Now);
                var pcbEntities    = new PCBEntities();
                var pcbShareCodeTb = new PCB_ShareCodeTB();
                pcbShareCodeTb.QAFolderID     = new Guid(qaFolderId);
                pcbShareCodeTb.ShareCode      = shareCode;
                pcbShareCodeTb.CreateAccount  = account;
                pcbShareCodeTb.EffectDatetime = DateTime.Now.AddMinutes(int.Parse(durationTime));
                pcbShareCodeTb.CreateDateTime = DateTime.Now;
                pcbEntities.AddToPCB_ShareCodeTB(pcbShareCodeTb);
                var list = pcbEntities.PCB_ShareCodeTB.Where(p => p.EffectDatetime < DateTime.Now);

                foreach (var item in list)
                {
                    pcbEntities.DeleteObject(item);
                }

                result.IsOK = Convert.ToBoolean(pcbEntities.SaveChanges());
                if (!result.IsOK)
                {
                    result.Description = "生成失败";

                    return(result);
                }
                result.Description = "生成成功";
                result.ExtData     = shareCode;
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(GetType()).Info(ex.StackTrace);
                result.IsOK        = false;
                result.Description = ex.Message;
            }

            return(result);
        }