Esempio n. 1
0
 /// <summary>
 /// 添加供求
 /// </summary>
 public bool AddDemand(Demand demand)
 {
     bool result = false;
     try
     {
         if (demand != null)
         {
             result = demandRepository.AddEntitySave(demand);
         }
     }
     catch (Exception e)
     {
         LogService.Log("添加供求失败", e.ToString());
     }
     return result;
 }
Esempio n. 2
0
 public ActionResult Add(Demand demand)
 {
     string result = "发布失败";
     if (!IsUserLogin)
     {
         result = "长时间为操作,请重新登录";
     }
     else if (demand != null)
     {
         if (!string.IsNullOrEmpty(demand.Title) &&
             !string.IsNullOrEmpty(demand.ContentText) &&
             demand.ResourceType != 0)
         {
             User user = Session[USERINFO] as User;
             demand.UserId = user.UserId;
             demand.IsActive = true;
             demand.InsertTime = DateTime.Now;
             demand.StartTime = demand.InsertTime;
             demand.EndTime = demand.StartTime;
             demand.ContentStyle = demand.ContentText;
             if (demand.ContentText.Length > 291)
             {
                 demand.Description = demand.ContentText.Substring(0, 290);
             }
             else
             {
                 demand.Description = demand.ContentText;
             }
             if (demand.Budget == null)
             {
                 demand.Budget = 0;
             }
             if (demandManager.AddDemand(demand))
             {
                 result = "success";
                 Subscription.WorkingThread.Instance.SendDemandByEmail(demand.Id);
             }
         }
         else
         {
             result = "必须项不能为空";
         }
     }
     return Content(result);
 }
Esempio n. 3
0
 /// <summary>
 /// 更新需求
 /// </summary>
 /// <param name="demand"></param>
 /// <returns></returns>
 public bool EditDemand(Demand demand)
 {
     bool result = false;
     var conn = DBHelper.GetSqlConnection();
     try
     {
         conn.Open();
         if (demand != null)
         {
             result = DemandDao.UpdateDemand(demand, conn);
         }
     }
     catch (Exception e)
     {
         LogService.Log("更新需求失败", e.ToString());
     }
     finally
     {
         conn.Close();
     }
     return result;
 }
Esempio n. 4
0
        /// <summary>
        /// 更新需求
        /// </summary>
        public static bool UpdateDemand(Demand demand, SqlConnection conn)
        {
            object Description = DBNull.Value;
            object ContentStyle = DBNull.Value;
            object ContentText = DBNull.Value;
            object Province = DBNull.Value;
            object CityEntity = DBNull.Value;
            object Area = DBNull.Value;
            object Address = DBNull.Value;
            object Phone = DBNull.Value;
            object QQWeixin = DBNull.Value;
            object Email = DBNull.Value;
            object TimeLength = DBNull.Value;
            object PeopleNumber = DBNull.Value;

            #region 转化DBNull
            if (!string.IsNullOrEmpty(demand.Description))
            {
                Description = demand.Description;
            }
            if (!string.IsNullOrEmpty(demand.ContentStyle))
            {
                ContentStyle = demand.ContentStyle;
            }
            if (!string.IsNullOrEmpty(demand.ContentText))
            {
                ContentText = demand.ContentText;
            }
            if (!string.IsNullOrEmpty(demand.Province))
            {
                Province = demand.Province;
            }
            if (!string.IsNullOrEmpty(demand.City))
            {
                CityEntity = demand.City;
            }
            if (!string.IsNullOrEmpty(demand.Area))
            {
                Area = demand.Area;
            }
            if (!string.IsNullOrEmpty(demand.Address))
            {
                Address = demand.Address;
            }
            if (!string.IsNullOrEmpty(demand.Phone))
            {
                Phone = demand.Phone;
            }
            if (!string.IsNullOrEmpty(demand.QQWeixin))
            {
                QQWeixin = demand.QQWeixin;
            }
            if (!string.IsNullOrEmpty(demand.Email))
            {
                Email = demand.Email;
            }
            if (!string.IsNullOrEmpty(demand.TimeLength))
            {
                TimeLength = demand.TimeLength;
            }
            if (!string.IsNullOrEmpty(demand.PeopleNumber))
            {
                PeopleNumber = demand.PeopleNumber;
            }
            #endregion

            SqlParameter[] sqlParameters = new SqlParameter[]
            {
                new SqlParameter("@Id", demand.Id),
                new SqlParameter("@ResourceType", demand.ResourceType),
                new SqlParameter("@ResourceTypeId", demand.ResourceTypeId??-1),
                new SqlParameter("@Title", demand.Title),
                new SqlParameter("@Description", Description),
                new SqlParameter("@ContentStyle", ContentStyle),
                new SqlParameter("@ContentText", ContentText),
                new SqlParameter("@Province", Province),
                new SqlParameter("@City", CityEntity),
                new SqlParameter("@Area", Area),
                new SqlParameter("@Address", Address),
                new SqlParameter("@Phone", Phone),
                new SqlParameter("@QQWeixin", QQWeixin),
                new SqlParameter("@Email", Email),
                new SqlParameter("@StartTime", demand.StartTime),
                new SqlParameter("@EndTime", demand.EndTime),
                new SqlParameter("@TimeLength", TimeLength),
                new SqlParameter("@PeopleNumber", PeopleNumber),
                new SqlParameter("@Budget", demand.Budget),
                new SqlParameter("@IsActive", demand.IsActive)
            };
            return DBHelper.SetDataToDB(conn, sp_DemandUpdate, sqlParameters);
        }
Esempio n. 5
0
        private bool IsDemandMatchWithSubscription(DemandSubscription subscription, Demand demand)
        {
            bool isLocationMatch = false;
            bool isDemandTypeMatch = false;
            bool isKeywordMatch = false;

            if (subscription == null || demand == null)
            {
                return false;
            }

            List<Location> subscribedLocations = new List<Location>();
            List<DemandType> subscribedTypes = new List<DemandType>();
            List<Keyword> subscribedKeywords = new List<Keyword>();

            foreach (DemandSubscriptionDetail item in subscription.SubscriptionDetails)
            {
                if (item.SubscriptionType.Equals(DemandSubscriptionType.Area.ToString(), StringComparison.CurrentCultureIgnoreCase))
                {
                    subscribedLocations.Add(new Location(item.SubscriptionValue));
                }
                else if (item.SubscriptionType.Equals(DemandSubscriptionType.Category.ToString(), StringComparison.CurrentCultureIgnoreCase))
                {
                    subscribedTypes.Add(new DemandType(item.SubscriptionValue));
                }
                else
                {
                    subscribedKeywords.Add(new Keyword(item.SubscriptionValue));
                }
            }

            if (subscribedLocations.Count == 0)
            {
                isLocationMatch = true;
            }
            else
            {
                foreach (var location in subscribedLocations)
                {
                    if (location.IsMatch(demand.Province, demand.City, demand.Area))
                    {
                        isLocationMatch = true;
                        break;
                    }
                }
            }

            if (isLocationMatch)
            {

                if (subscribedTypes.Count == 0)
                {
                    isDemandTypeMatch = true;
                }
                else
                {
                    foreach (var type in subscribedTypes)
                    {
                        if (type.IsMatch(demand.ResourceType, demand.ResourceTypeId))
                        {
                            isDemandTypeMatch = true;
                            break;
                        }
                    }
                }
            }

            if (isLocationMatch && isDemandTypeMatch)
            {
                if (subscribedKeywords.Count == 0)
                {
                    isKeywordMatch = true;
                }
                else
                {
                    foreach (var keyword in subscribedKeywords)
                    {
                        if (keyword.IsMatch(demand.Title))
                        {
                            isKeywordMatch = true;
                            break;
                        }
                    }
                }
            }

            return isLocationMatch && isDemandTypeMatch && isKeywordMatch;
        }
Esempio n. 6
0
        /// <summary>
        /// {0}:需求标题, {1}:立即查看,{2}:需求类型,{3}:需求类别,{4}:需求预算,{5}:参与人数,
        /// {6}:开始时间,{7}:结束时间,{8}:立即查看,{9}:立即查看,{10}:立即查看,{11}:区域位置,{12}:需求详情
        /// </summary>
        /// <param name="emailSubscriptionContentFormat"></param>
        /// <param name="demand"></param>
        /// <returns></returns>
        private string GetEmailSubscriptionContent(string emailSubscriptionContentFormat, Demand demand)
        {
            string resourceSubTypeName = HtmlHelperExtension.GetResourceSubTypeNameById(demand.ResourceType, demand.ResourceTypeId);
            string buget = (!demand.Budget.HasValue || demand.Budget.Value <= 0) ? "面议" : demand.Budget + "元";
            string startTime = demand.StartTime.HasValue ? demand.StartTime.Value.ToString("yyyy-MM-dd") : "不确定";
            string endTime = demand.EndTime.HasValue ? demand.EndTime.Value.ToString("yyyy-MM-dd") : "不确定";
            string peopleCount = !string.IsNullOrEmpty(demand.PeopleNumber) ? demand.PeopleNumber : "不确定";

            string location = StaticUtility.GetProvinceAndCityNameById(demand.Province, demand.City, demand.Area) + " " + demand.Address;
            string titleLink = @"<a href='http://" + StaticUtility.Config.Domain + "/demand/show/"
                + demand.Id + "' target='_blank' style='color:#000;font-weight:bold;text-decoration:none;' title='"
                + demand.Title + "'>" + demand.Title + "</a>";
            string viewLink = @"<a href='http://" + StaticUtility.Config.Domain + "/demand/show/"
                + demand.Id + "' target='_blank' title='立即查看' style='color:#FF9900;font-weight:bold;text-decoration:none;'>立即查看</a>";

            return string.Format(emailSubscriptionContentFormat, titleLink, viewLink, demand.ResourceTypeName, resourceSubTypeName, buget, peopleCount,
                startTime, endTime, viewLink, viewLink, viewLink, location, demand.ContentStyle);
        }
Esempio n. 7
0
        /// <summary>
        /// 发布需求
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="resourceType"></param>
        /// <param name="resourceSubTypeId"></param>
        /// <param name="title"></param>
        /// <param name="contentStyle"></param>
        /// <param name="provinceId"></param>
        /// <param name="cityId"></param>
        /// <param name="areaId"></param>
        /// <param name="address"></param>
        /// <param name="phone"></param>
        /// <param name="qqweixin"></param>
        /// <param name="email"></param>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <param name="timeLength"></param>
        /// <param name="peopleNumber"></param>
        /// <param name="budget"></param>
        /// <param name="weixinBuyDemandFee"></param>
        /// <param name="errorMessage"></param>
        /// <returns></returns>
        public bool AddDemand(int userId, int resourceType, int resourceSubTypeId, string title, string contentStyle,
            string provinceId, string cityId, string areaId, string address, string phone, string qqweixin, string email,
            string startTime, string endTime, string timeLength, string peopleNumber, int budget, int weixinBuyDemandFee, out string errorMessage, out int demandId)
        {
            bool isAddSuccessfully = false;
            demandId = -1;
            errorMessage = string.Empty;

            try
            {
                DateTime demandStartTime = DateTime.MinValue;
                DateTime demandEndTime = DateTime.MinValue;

                if (resourceType < 0 || resourceSubTypeId < 0)
                {
                    errorMessage = "请选择具体类别与类型";
                }
                else if (string.IsNullOrWhiteSpace(title))
                {
                    errorMessage = "请填写需求标题!如寻找某场地、设备等资源";
                }
                else if (string.IsNullOrWhiteSpace(provinceId) || string.IsNullOrWhiteSpace(cityId))
                {
                    errorMessage = "请选择需求地点!包括省份、城市及区县信息!";
                }
                else if (string.IsNullOrWhiteSpace(startTime) || string.IsNullOrWhiteSpace(endTime) ||
                    !DateTime.TryParse(startTime, out demandStartTime) || !DateTime.TryParse(endTime, out demandEndTime) ||
                    demandStartTime < DateTime.Now.Date || demandEndTime < demandStartTime)
                {
                    errorMessage = "请填写正确需求开始与结束时间!";
                }
                else if (string.IsNullOrWhiteSpace(phone))
                {
                    errorMessage = "为了保证资源提供商能及时联系到您,请勿必填写电话号码!";
                }
                else if (budget < 0)
                {
                    errorMessage = "请填写正确的预算金额!填写0表示面议!";
                }
                else if (string.IsNullOrWhiteSpace(contentStyle))
                {
                    errorMessage = "请填写需求内容!请直接出现电话、邮箱,以及微信联系方式等信息,否则将被系统自动屏蔽!";
                }
                else
                {
                    Demand demand = new Demand();
                    demand.UserId = userId;
                    demand.ResourceType = resourceType;
                    demand.ResourceTypeId = resourceSubTypeId;
                    demand.Title = title;
                    demand.Description = string.Empty;
                    demand.ContentStyle = contentStyle;
                    demand.ContentText = Witbird.SHTS.Common.Html.HtmlUtil.RemoveHTMLTags(demand.ContentStyle);
                    demand.Province = provinceId;
                    demand.City = cityId;
                    demand.Area = areaId;
                    demand.Address = address;
                    demand.Phone = phone;
                    demand.QQWeixin = qqweixin;
                    demand.Email = email;
                    demand.StartTime = demandStartTime;
                    demand.EndTime = demandEndTime;
                    demand.TimeLength = timeLength;
                    demand.PeopleNumber = peopleNumber;
                    demand.Budget = budget;
                    demand.IsActive = true;
                    demand.ViewCount = 0;
                    demand.InsertTime = DateTime.Now;
                    demand.Status = (int)DemandStatus.InProgress;
                    demand.WeixinBuyFee = weixinBuyDemandFee;

                    isAddSuccessfully = demandRepository.AddEntitySave(demand);
                    errorMessage = "success";
                    demandId = demand.Id;
                }
            }
            catch (Exception ex)
            {
                LogService.Log("发布需求失败", ex.ToString());
                errorMessage = "Ooops!发布需求的过程中产生了错误!请重新尝试!如频繁遇到此问题,请联系客户人员!";
                isAddSuccessfully = false;
            }

            return isAddSuccessfully;
        }