Exemple #1
0
 private XElement Program(Dictionary <string, string> directions, CommonCourseListItemVM item, string desc, string shortDesc)
 {
     try {
         if (shortDesc == null || !item.HasNearestGroupOrWebinar)
         {
             return(null);
         }
         var c   = item.Course;
         var url = CommonConst.SiteRoot +
                   (c.IsTrackBool
                                 ? _url.Action <TrackController>(x => x.Details(c.UrlName))
                                 : _url.Action <CourseController>(x => x.Details(c.UrlName)));
         var type      = c.IsSchool ? "подготовительные курсы" : "повышение квалификации";
         var audiences = c.IsSchool ? "школьники" : "взрослые";
         return(X("program",
                  A("id", c.Course_ID),
                  X("name", StringUtils.RemoveTags(c.WebName)),
                  X("description", StringUtils.SafeSubstring(shortDesc, 800)),
                  X("link", url),
                  c.CourseDirectionA_TC == null
                                 ? null
                                 : X("rubrics", X("rubric", A("id", c.CourseDirectionA_TC), directions[c.CourseDirectionA_TC])),
                  X("type", type),
                  X("audiences", X("audience", audiences)),
                  X("forms",
                    Form(c, item.GetPrice(PriceTypes.Webinar), item.NearestWebinar, true),
                    Form(c, item.GetPrice(PriceTypes.Main), item.NearestGroup, false)
                    )));
     }
     catch (Exception e) {
         Logger.Exception(e, item.Course.Course_ID + " " + item.Course.Course_TC);
         return(null);
     }
 }
Exemple #2
0
        void Application_Error(object sender, EventArgs e)
        {
            if (IsDebug)
            {
                return;
            }
            var ex   = Server.GetLastError().GetBaseException();
            var user = Container.Resolve <IAuthService>().CurrentUser;

            /*	if(ex is HttpRequestValidationException) {
             *              if(ex.As<HttpRequestValidationException>().Message.Contains("Cookie")) {
             *              /*	Request.Cookies.Clear();
             *                      Response.Cookies.Clear();
             *                      Response.Redirect("/page/cleancookies");
             *                      return;
             *              }
             *      }*/
            if (ex is HttpException)
            {
                Response.StatusCode = ex.As <HttpException>().GetHttpCode();
                Logger.Exception(ex, user);
            }
            else if (Response.StatusCode == (int)HttpStatusCode.OK)
            {
                Logger.Exception(ex, user);
                Response.StatusCode = (int)HttpStatusCode.NotFound;
            }
            else
            {
                Logger.Exception(ex, user);
            }
        }
Exemple #3
0
        List <string> CourseData(CommonCourseListItemVM item, string desc, string shortDesc)
        {
            try {
                var date   = DateTime.Today.AddMonths(6);
                var groups = GroupService.GetGroupsForCourse(item.Course.Course_TC)
                             .Where(x => x.DateBeg <= date)
                             .Select(x => x.DateInterval).Distinct().ToList().JoinWith(", ");

                var c = item.Course;

                var url = CommonConst.SiteRoot +
                          (c.IsTrackBool
                                                ? _url.Action <TrackController>(x => x.Details(c.UrlName))
                                                : _url.Action <CourseController>(x => x.Details(c.UrlName)));
                return(_.List(
                           StringUtils.RemoveTags(c.Name),
                           ((int)item.GetPrice(PriceTypes.Corporate)).ToString(),
                           shortDesc,
                           url,
                           groups));
            } catch (Exception e) {
                Logger.Exception(e, "course error " + item.Course.Course_ID + " " + item.Course.Course_TC);
                return(null);
            }
        }
Exemple #4
0
 private XElement Good(CommonCourseListItemVM item, string desc, string shortDesc)
 {
     try {
         if (shortDesc == null)
         {
             return(null);
         }
         var c     = item.Course;
         var image = Images.Course(c.UrlName).Attribute("src");
         if (image == null)
         {
             return(null);
         }
         return(X("item",
                  X("title", GetShortName(c)),
                  X("description", desc),
                  X("link", CommonConst.SiteRoot +
                    (c.IsTrackBool
                                                 ? _url.Action <TrackController>(x => x.Details(c.UrlName))
                                                 : _url.Action <CourseController>(x => x.Details(c.UrlName))) +
                    StringUtils.GetUtmPart("google", "cpc", "merchant")),
                  X(g + "id", "c" + c.Course_ID),
                  X(g + "image_link", image.Value),
                  X(g + "availability", "in stock"),
                  X(g + "product_type", "Курс"),
                  X(g + "price", (int)item.Prices.First(x => x.IsMain).Price + " RUB"),
                  X(g + "condition", "new")));
     }
     catch (Exception e) {
         Logger.Exception(e, item.Course.Course_ID + " " + item.Course.Course_TC);
         return(null);
     }
 }
Exemple #5
0
        private XElement Course(CommonCourseListItemVM item, string desc, string shortDesc)
        {
            try {
                if ((desc.IsEmpty() && shortDesc.IsEmpty()) || item.NearestWebinar == null)
                {
                    return(null);
                }
                var groups = GroupService.GetGroupsForCourse(item.Course.Course_TC).Take(15).ToList();

                if (!groups.Any())
                {
                    return(null);
                }
                var c        = item.Course;
                var category = _directions.GetValueOrDefault(c.CourseDirectionA_TC);
                shortDesc = shortDesc ?? category;
                var maxLength    = 240;
                var shortDesc160 = shortDesc.Length > maxLength
                                ? StringUtils.SafeSubstring(shortDesc, maxLength - 3) + "..."
                                        : shortDesc;

                return(X("course",
                         X("id", c.Course_ID),
                         X("name", StringUtils.RemoveTags(c.WebName)),
                         X("short-description", category),
                         X("description", desc),
                         X("tags", X("tag", category)),
                         X("lessons", groups.SelectMany(Lesson))
                         ));
            }
            catch (Exception e) {
                Logger.Exception(e, "course error " + item.Course.Course_ID + " " + item.Course.Course_TC);
                return(null);
            }
        }
Exemple #6
0
        public void SberMerchant(Entities.Context.Order order, string operation)
        {
            var operationName = SberOperationNames.GetValueOrDefault(operation) ?? operation;
            var body          = H.b[operationName] + Br +
                                H.b["Email: "] + order.User.Email + Br +
                                GetOrderDescription(order, true) + Br +
                                GetOrderCmsAnchor(order) + Br;

            SendSync(info, sberbankPayment, body, "[ПАО Сбербанк] {0} {1} {2}"
                     .FormatWith(operationName, order.User.FullName, order.CommonOrderId), ptolochko);
            if (!order.User.Email.IsEmpty())
            {
                body = H.b["Описание покупки: "] + order.GetDescription(false) + Br +
                       H.b["Стоимость покупки: "] + order.TotalPriceWithDescount.MoneyString() + " RUB" + Br +
                       H.b["Номер заказа: "] + order.CommonOrderId + Br +
                       H.b["Дата платежа: "] + DateTime.Now.DefaultString() + Br +
                       H.b["Результат: "] + operationName + Br + Br +
                       "Это письмо сгенерировано автоматически и не требует ответа.";
                try {
                    Send(info, new MailAddress(order.User.Email), body,
                         "Оплата заказа {0} на сайте www.specialist.ru".FormatWith(order.CommonOrderId));
                }
                catch (Exception ex) {
                    Logger.Exception(ex, "sber mail");
                }
            }
        }
Exemple #7
0
 static void UpdateStatusForGroups(User user, List <Group> groups, string template)
 {
     try {
         var message = string.Empty;
         if (groups.First().MegaGroup_ID.HasValue)
         {
             message = UpdateMegaStatus(user, groups, template);
         }
         else
         {
             message = UpdateStatus(user, groups.First(), template);
             CreateEvent(groups.First(), user, message);
         }
     }
     catch (Exception e) {
         Logger.Exception(e, "groups {0} user {1}".FormatWith(
                              groups.Select(x => x.Group_ID.ToString()).JoinWith(", "), user.Email));
         if (e.InnerException != null)
         {
             if (e.InnerException is FacebookOAuthException)
             {
                 ClearUser(user.UserID);
             }
             else
             {
                 Logger.Exception(e.InnerException, "inner");
             }
         }
     }
 }
Exemple #8
0
 private List <string> Good(CommonCourseListItemVM item, string desc, string shortDesc)
 {
     try {
         if (shortDesc == null)
         {
             return(null);
         }
         var c     = item.Course;
         var image = Images.Course(c.UrlName).Attribute("src");
         if (image == null)
         {
             return(null);
         }
         return(_.List(
                    "c" + c.Course_ID,
                    StringUtils.RemoveTags(c.GetShortName()),
                    CommonConst.SiteRoot +
                    (c.IsTrackBool
                                                 ? _url.Action <TrackController>(x => x.Details(c.UrlName))
                                                 : _url.Action <CourseController>(x => x.Details(c.UrlName))),
                    image.Value,
                    image.Value,
                    shortDesc,
                    "«Специалист» при МГТУ им.Баумана",
                    "курсы;обучение;вебинар;семинар"));
     }
     catch (Exception e) {
         Logger.Exception(e, item.Course.Course_ID + " " + item.Course.Course_TC);
         return(null);
     }
 }
Exemple #9
0
        private XElement Good(CommonCourseListItemVM item, string desc, string shortDesc)
        {
            try {
                if (shortDesc == null)
                {
                    return(null);
                }
                var f     = "False";
                var t     = "True";
                var c     = item.Course;
                var image = Images.Course(c.UrlName).Attribute("src");
                if (image == null)
                {
                    return(null);
                }
                return(X("Good",
                         A("article", "c" + c.Course_ID),
                         A("name", c.WebName),
                         A("cargoRegistered", f),
                         A("isVirtual", t),
                         A("img", image.Value),

                         A("cost", (int)item.Prices.First(x => x.IsMain).Price),
                         A("shortDescription", shortDesc),
                         A("description", desc),
                         A("categories", rootCategory)));
            }
            catch (Exception e) {
                Logger.Exception(e, item.Course.Course_ID + " " + item.Course.Course_TC);
                return(null);
            }
        }
Exemple #10
0
 private MailAddress MailAddress(User user)
 {
     try {
         return(new MailAddress(user.Email, user.FullName));
     } catch (Exception e) {
         Logger.Exception(e, this + " wrong email " + user.Email);
     }
     return(null);
 }
Exemple #11
0
 public void OrderInfoForManager(Entities.Context.Order order,
                                 string confirmInfo = null, bool notComplete = false)
 {
     try {
         var user      = order.User;
         var userInfo  = GetUserInfo(user);
         var socialUrl = order.SocialUrl;
         var body      = userInfo +
                         (order.PromoCode.IsEmpty() ? "" : "Промокод: ".Tag("strong") + order.PromoCode + Br) +
                         (socialUrl.IsEmpty() ? "" : "Ссылка на соц. сеть для скидки: ".Tag("strong") + socialUrl + Br) +
                         GetOrderDescription(order, true) + Br +
                         GetOrderCmsAnchor(order) + Br;
         var subject = string.Empty;
         if (notComplete)
         {
             subject = "[Незавершенный заказ] " + user.FullName;
         }
         else if (!confirmInfo.IsEmpty())
         {
             subject = "[Подтверждение оплаты] " + user.FullName;
             body   += OrderConfirmVM.ConfirmInfoName.Tag("strong") + Br +
                       confirmInfo;
         }
         else
         {
             subject = "[{0}][{1}][Заказ] {2}".FormatWith(order.PaymentType_TC,
                                                          order.OurOrgOrDefault, user.FullName);
         }
         if (!order.IsOrganization)
         {
             var managerTc = order.Manager_TC;
             var email     = GetEmployeeMail(managerTc);
             if (order.PaymentTypeIsSet && order.OrderDetails.Any(x => x.IsDopUsl))
             {
                 Send(info, siteOrders, body, subject, bt1c, email);
             }
             else if (order.OrderDetails.Any(x => x.IsTestCert))
             {
                 Send(info, siteOrders, body, subject, siteCertOrders, email);
             }
             else
             {
                 Send(info, siteOrders, body, subject, email);
             }
         }
         else
         {
             Send(info, secrko, body, subject);
             Send(info, corporatesiteorders, body, subject);
         }
     } catch (Exception e) {
         Logger.Exception(e, "orderId = " + order.OrderID);
         throw;
     }
 }
Exemple #12
0
 public void Send(MailAddress from, MailAddress to, string body, string subject,
                  List <UploadFile> uploadFiles, string fileName = null, int replyMinutes = 0,
                  params MailAddress[] cc)
 {
     ThreadPool.QueueUserWorkItem(o => {
         try {
             SendSync(@from, to, body, subject, uploadFiles, fileName, replyMinutes, cc);
         } catch (Exception e) {
             Logger.Exception(e, this + " " + to.Address +
                              " " + subject);
         }
     });
 }
Exemple #13
0
 void _timer_Elapsed(object sender, ElapsedEventArgs e)
 {
     try {
         if (!_nextCheck.HasValue || _nextCheck.Value < DateTime.Now)
         {
             _nextCheck = DateTime.Now.AddMinutes(Minutes);
             TimerTick();
         }
     }
     catch (AggregateException ex) {
         Logger.Exception(Logger.GetFromAggregate(ex), "error in " + this.GetType().Name);
     }
     catch (Exception ex)
     {
         Logger.Exception(ex, "error in " + this.GetType().Name);
     }
 }