示例#1
0
 /// <summary>
 /// 一个社区码
 /// </summary>
 /// <param name="communityId">社区码</param>
 /// <returns></returns>
 public Dictionary <string, string> OneCommunity(int communityId)
 {
     try
     {
         var ModelContext = new RabbitMPEntities();
         var community    = ModelContext.CommunityEntities
                            .Include(nameof(CommunityEntities.WechatQrCodes))
                            .FirstOrDefault(item => item.CommunityId == communityId);
         GeneratePictures gp = new GeneratePictures(SaveFile, communityId, communityId, community.Name, community.Name, ServerPath, SaveFile + "sou.jpg", SaveFile + "small.jpg");
         if (community != null && community.WechatQrCodes != null)
         {
             var msg = gp.Generate(community.WechatQrCodes.WechatUrl, WechatQrCodeType.SQ);
             return(msg);
         }
         else if (community != null && community.WechatQrCodes == null)
         {
             var newWechatQR = InsertOneWechatQrCodes(WechatQrCodeType.SQ);
             community.WechatQrCodeId = newWechatQR.Id;
             ModelContext.SaveChanges();
             var msg = gp.Generate(newWechatQR.WechatUrl, WechatQrCodeType.SQ);
             return(msg);
         }
         else
         {
             return(null);
         }
     }
     catch (Exception e)
     {
         AboutLog.WriteBugLog(e);
         return(null);
     }
 }
示例#2
0
        /// <summary>
        /// 一个门
        /// </summary>
        /// <param name="doorId"></param>
        /// <returns></returns>
        public Dictionary <string, string> OneDoorImg(int doorId)
        {
            try
            {
                var ModelContext = new RabbitMPEntities();
                var door         = ModelContext.Doors
                                   .Include(nameof(Doors.CommunityEntities))
                                   .Include(nameof(Doors.WechatQrCodes))
                                   .Include(nameof(Doors.DoorGroups))
                                   .FirstOrDefault(item => item.DoorId == doorId);
                var newDoorName = door.DoorGroups != null
                        ? door.DoorGroups.Name.Split('|')[0] + "-" + door.Name.Split('|')[1]
                        : door.Name.Replace("|", "-");

                GeneratePictures gp = new GeneratePictures(SaveFile, (int)door.CommunityId, doorId, door.CommunityEntities.Name, newDoorName, ServerPath, SaveFile + "sou.jpg", SaveFile + "small.jpg");
                if (door != null && door.WechatQrCodes != null && door.WechatQrCodes.WechatUrl != null)
                {
                    var msg = gp.Generate(door.WechatQrCodes.WechatUrl, WechatQrCodeType.DM);
                    return(msg);
                }
                else if (door != null && (door.WechatQrCodes == null || door.WechatQrCodes.WechatUrl == null))
                {
                    var newWechatQR = InsertOneWechatQrCodes(WechatQrCodeType.DM);
                    door.WechatQrCodeId = newWechatQR.Id;
                    ModelContext.SaveChanges();
                    var msg = gp.Generate(newWechatQR.WechatUrl, WechatQrCodeType.DM);
                    return(msg);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception e)
            {
                AboutLog.WriteBugLog(e);
                return(null);
            }
        }