Example #1
0
        /// <summary>
        /// stop service method
        /// </summary>
        protected override void OnStop()
        {
            try
            {
                Timer.Stop();
                LogHelper.AddLog("FCC Email Agent Service stopped");

                Emails email = new Emails()
                {
                    FromEmail      = ServiceSettings.AgentEmail,
                    Subject        = "Service Email Agent has been stopped",
                    ReceiverUserId = UsersHelper.CheckExistsUserByEmail(ServiceSettings.AdminCredentials.UserName),
                    TypeId         = 4,
                    Host           = Program.Agent.ServiceSettings.SMTPSettings.Server,
                    Port           = Program.Agent.ServiceSettings.SMTPSettings.Port,
                    Body           = "Service Stopped!",
                };

                EmailHelper.SendMessage(email);
            }
            catch (Exception exception)
            {
                string innerException = exception.InnerException == null ? "" : exception.InnerException.Message;
                string methodName     = System.Reflection.MethodBase.GetCurrentMethod().Name;
                LogHelper.AddLog("Error in method: " + methodName + "; Exception: " + exception.Message + " Innner Exception: " +
                                 innerException);
            }
        }
Example #2
0
        private static int CreateTemplate(WfpictContext db, CreativeVm model)
        {
            IMailChimpManager manager = new MailChimpManager();

            LogHelper.AddLog(db, LogType.MailChimp, model.OrderNumber, "Creating template from creatives");
            var allTemplatesRequest = manager.Templates.GetAllAsync().ConfigureAwait(false);
            var allTemplates        = allTemplatesRequest.GetAwaiter().GetResult();
            int templateIdOld       = -1;

            foreach (var allTemplate in allTemplates)
            {
                if (allTemplate.Name == model.OrderNumber)
                {
                    templateIdOld = allTemplate.Id;
                    break;
                }
            }
            if (templateIdOld != -1)
            {
                LogHelper.AddLog(db, LogType.MailChimp, model.OrderNumber, "Template " + model.OrderNumber + " already exists. Deleting old one.");
                var deleteTemplateRequest = manager.Templates.DeleteAsync(templateIdOld.ToString()).ConfigureAwait(false);
            }

            var template   = manager.Templates.CreateAsync(model.OrderNumber, "", model.Creatives).ConfigureAwait(false);
            var templateId = template.GetAwaiter().GetResult().Id;

            LogHelper.AddLog(db, LogType.MailChimp, model.OrderNumber, "Template creatives created successfully.");
            return(templateId);
        }
Example #3
0
        private static void SendCampaign(WfpictContext db, CreativeVm model, string campaignId)
        {
            IMailChimpManager manager = new MailChimpManager();

            LogHelper.AddLog(db, LogType.MailChimp, model.OrderNumber, "Sending to Test list");
            var sent = manager.Campaigns.SendAsync(campaignId).ConfigureAwait(false);
        }
Example #4
0
        public ActionResult Index(int id)
        {
            _assessmentId         = id;
            TempData["assmentID"] = _assessmentId;
            try
            {
                IDAL dal = (new DALFactory()).GetInstance();
                var  objAssessmentDetails = dal.GetAssessmentDetails(_assessmentId);        //Get assessment details based on Assessment ID

                if (!objAssessmentDetails.AssessmentCompletionStatus && !objAssessmentDetails.MaxAttemptsExceeded)
                {
                    Session["StartAssessment"] = objAssessmentDetails;
                }
                else
                {
                    return(RedirectToAction("Home", "Home"));
                }
            }
            catch (Exception ex)
            {
                UserManager user = (UserManager)Session["CurrentUser"];
                LogHelper.AddLog(new LogEntity(AppConstant.PartitionError, user.EmailID.ToString(), AppConstant.ApplicationName, "Assessment, Index", ex.Message, ex.StackTrace));
            }
            return(View("StartAssessment"));
        }
Example #5
0
        /// <summary>
        /// 批量(新增)1010
        /// </summary>
        /// <param name="dtSource">实体对象</param>
        /// <returns></returns>
        public string BatchAddEntityLiao(string keyValue, DataTable dtSource, string dir)
        {
            try
            {
                IRepository         db        = new RepositoryFactory().BaseRepository().BeginTrans();
                Sale_CustomerEntity oldEntity = GetEntity(keyValue);
                if (!string.IsNullOrEmpty(oldEntity.LiangPath))
                {
                    //重复导入,删掉之前导入的所有
                    db.Delete <Produce_OutEntity>(t => t.Code == keyValue);
                    oldEntity.LiangPath = "";
                }

                int rowsCount = dtSource.Rows.Count;

                for (int r = 4; r < rowsCount; r++)
                {
                    string c1 = dtSource.Rows[r][0].ToString();
                    if (!string.IsNullOrEmpty(c1))
                    {
                    }
                }
                oldEntity.LiangPath = dir;
                db.Update <Sale_CustomerEntity>(oldEntity);
                db.Commit();
                return("导入料单Excel文件成功");
            }
            catch (Exception ex)
            {
                LogHelper.AddLog(ex.Message);
                return(ex.Message);
            }
        }
        public PartialViewResult GetLearningJourney()
        {
            List <UserSkillDetail> userLearningJourney = new List <UserSkillDetail>();

            try
            {
                IDAL        dal       = (new DALFactory()).GetInstance();
                UserManager user      = (UserManager)Session["CurrentUser"];
                string      dataStore = ConfigurationManager.AppSettings["DATASTORE"].ToString();

                if (dataStore == "SqlSvr")
                {
                    SqlSvrDAL sqlDAL   = new SqlSvrDAL();
                    int       dbUserId = sqlDAL.GetUserId(user.EmailID);
                    userLearningJourney = dal.GetTrainingJourneyDetails(AppConstant.UserTrainingMapping, dbUserId);
                    user.Competency     = dal.GetUserCompetencyLabel(user.DBUserId);
                }
                else
                {
                    userLearningJourney = dal.GetTrainingJourneyDetails(AppConstant.UserTrainingMapping, user.SPUserId);
                    user.Competency     = dal.GetUserCompetencyLabel(user.SPUserId);
                }

                Session.Add("CurrentUser", user);
            }
            catch (Exception ex)
            {
                UserManager users = (UserManager)Session["CurrentUser"];
                LogHelper.AddLog(new LogEntity(AppConstant.PartitionError, users.EmailID.ToString(), AppConstant.ApplicationName, "Home,CacheSiteMenu", ex.Message, ex.StackTrace));
            }
            return(PartialView("_LearningJourney", userLearningJourney));
        }
Example #7
0
        /// <summary>
        /// 保存表单(新增)
        /// </summary>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public OrdersEntity SaveForm(OrdersEntity entity)
        {
            IRepository db   = new RepositoryFactory().BaseRepository().BeginTrans();
            var         list = db.FindList <OrdersEntity>(t => t.Tel == entity.Tel && (t.ContactTel == entity.ContactTel || t.ContactTel == null) && t.Status == 0);

            if (list.Count() > 0)
            {
                foreach (var item in list)
                {
                    item.DeleteMark = 1;
                    db.Update <OrdersEntity>(item);
                    LogHelper.AddLog("删除未付款订单:" + item.OrderSn);
                }
                //db.Delete<OrdersEntity>(t => t.Tel == entity.Tel && t.ContactTel == entity.ContactTel && t.Status == 0);
                db.Commit();
            }

            entity.Create();
            if (string.IsNullOrEmpty(entity.OrderSn))
            {
                //jsapi会提前生成订单编号,直接用提生成的,保持提交微信的一致
                entity.OrderSn = string.Format("{0}{1}", "LX-", DateTime.Now.ToString("yyyyMMddHHmmss"));//,TenPayV3Util.BuildRandomStr(6)
            }
            this.BaseRepository().Insert(entity);
            return(entity);
        }
Example #8
0
        /// <summary>
        /// 主线程消息循环
        /// </summary>
        private static void Run()
        {
            var nancyServer = new NancyServer();

            if (!nancyServer.Start())
            {
                LogHelper.AddLog("NancyServer start failed.");
                Console.WriteLine("SimpleFileServer start failed.");
                Console.WriteLine("Press any key to exit.");
                Console.ReadKey();
                return;
            }

            LogHelper.AddLog("NancyServer start.");
            Console.WriteLine("SimpleFileServer start.");
            Console.WriteLine("Press key 'q' to stop.");

            while (Console.ReadKey().KeyChar.ToString().ToUpper() != "Q")
            {
                Console.WriteLine();
            }

            nancyServer.Stop();

            LogHelper.AddLog("NancyServer stop.");
            Console.WriteLine();
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
            Console.WriteLine();
        }
Example #9
0
 // GET: Admin/Home
 public ActionResult Index()
 {
     try
     {
         base.UserCheck();
         if (CurrenUserInfo.IsNotNull())
         {
             ViewBag.UserName = CurrenUserInfo;
             var menuLIst = HttpHelp.Post <List <S_Menu>, string>(ActionEnum.GetMenuList, null);
             var result   = HttpHelp.Post <List <UrlType>, string>(ActionEnum.GetHomePageCount, null);
             ViewBag.CountTool = result;
             ViewBag.menu      = menuLIst;
             var menuType = menuLIst.Select(n => n.Types).Distinct();
             ViewBag.menuType = menuType;
         }
         else
         {
             return(Redirect("../Admin/User/Login"));
         }
     }
     catch (Exception ex)
     {
         LogHelper.AddLog(ex);
     }
     return(View());
 }
Example #10
0
        static void Main(string[] args)
        {
            LogHelper.InitLogPath();
            LogHelper.AddLog("Instance is starting.");

            var list = HardwareHelper.GetCpuId();

            list.ForEach(Console.WriteLine);

            var disks = HardwareHelper.GetRemovableDisk();

            disks.ForEach(Console.WriteLine);

            AppDomain.CurrentDomain.ProcessExit += (sender, eventArgs) =>
            {
                _instanceMutex?.ReleaseMutex();
                _instanceMutex = null;
                LogHelper.AddLog("Instance is shutting down.");
            };

            CheckSingleInstance();
            AddThreadExceptionHandler();

            GlobalConfig.Instance.Init();

            Run();
        }
Example #11
0
 /// <summary>
 /// 异常捕获
 /// </summary>
 private static void AddThreadExceptionHandler()
 {
     AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
     {
         LogHelper.AddLog($"未处理的UI异常:{(Exception) args.ExceptionObject}");
     };
 }
Example #12
0
        /// <summary>
        /// Получаем Эксепшон настройку по айдишнику инпут настройки
        /// </summary>
        /// <param name="parentId"></param>
        /// <returns></returns>
        public static FTPSetting GetFtpExceptionSettings(int parentId)
        {
            using (var db = new FCCPortalEntities())
            {
                try
                {
                    List <FTPSetting> settings = new List <FTPSetting>();

                    var setting = db.FTPSettings.SingleOrDefault(x =>
                                                                 x.ParentId.Value == parentId && x.FtpServiceType == 3);
                    return(new FTPSetting(setting.Id, setting.UserId, setting.UserName,
                                          setting.Host, setting.Port ?? 0, setting.Password, setting.Path,
                                          setting.UseSSL, (bool)setting.DeleteFile, setting.Enabled,
                                          setting.FtpServiceType));
                }
                catch (Exception exception)
                {
                    string innerException = exception.InnerException == null ? "" : exception.InnerException.Message;
                    string methodName     = System.Reflection.MethodBase.GetCurrentMethod().Name;
                    LogHelper.AddLog("Error in method: " + methodName + "; Exception: " + exception.Message + " Innner Exception: " +
                                     innerException);
                    return(null);
                }
            }
        }
Example #13
0
        /// <summary>
        /// Получаем список ФТП настроек Input
        /// </summary>
        /// <returns></returns>
        public static List <FTPSetting> GetFtpInputSettings()
        {
            using (var db = new FCCPortalEntities2())
            {
                try
                {
                    List <FTPSetting> settings = new List <FTPSetting>();

                    db.FTPSettings.Where(x => x.FtpServiceType == 1).ToList().ForEach(x =>
                    {
                        settings.Add(new FTPSetting(x.Id, x.UserId, x.UserName, x.Host, x.Port ?? 0, x.Password, x.Path,
                                                    x.UseSSL, (bool)x.DeleteFile, x.Enabled, x.FtpServiceType));
                    });

                    return(settings);
                }
                catch (Exception exception)
                {
                    string innerException = exception.InnerException == null ? "" : exception.InnerException.Message;
                    string methodName     = System.Reflection.MethodBase.GetCurrentMethod().Name;
                    LogHelper.AddLog("Error in method: " + methodName + "; Exception: " + exception.Message + " Innner Exception: " +
                                     innerException);
                    return(null);
                }
            }
        }
Example #14
0
        public static FTPConversionSettingModel GetFtpConersionSettings(int userId)
        {
            using (var db = new FCCPortalEntities2())
            {
                try
                {
                    var dbSetting = db.FTPConversionSettings.SingleOrDefault(x => x.UserId == userId);

                    return(new FTPConversionSettingModel(dbSetting.Id,
                                                         dbSetting.AddProcessed,
                                                         dbSetting.ReturnResults,
                                                         dbSetting.MirrorInput,
                                                         dbSetting.MoveProcessed,
                                                         dbSetting.UserId));
                }
                catch (Exception exception)
                {
                    string innerException = exception.InnerException == null ? "" : exception.InnerException.Message;
                    string methodName     = System.Reflection.MethodBase.GetCurrentMethod().Name;
                    LogHelper.AddLog("Error in method: " + methodName + "; Exception: " + exception.Message + " Innner Exception: " +
                                     innerException);
                    return(null);
                }
            }
        }
Example #15
0
        /// <summary>
        /// 响应前执行登录验证,查看当前用户是否有效
        /// </summary>
        /// <param name="filterContext"></param>
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            //登录拦截是否忽略
            if (_customMode == LoginMode.Ignore)
            {
                return;
            }
            //请求地址
            HttpRequest request    = HttpContext.Current.Request;
            string      RequestUri = request.RawUrl;//AbsoluteUri//FilePath//!string.IsNullOrEmpty(request.Params["urlstr"]) ? request.Params["urlstr"] :

            if (RequestUri.IndexOf("&amp;") > 0)
            {
                //WeChatManage/Liang/Index?organizeId=4da3b884-ac5b-46fb-af10-150beb9e6c69&amp;amp;amp;amp;amp;from=timeline&amp;amp;amp;amp;from=timeline&amp;amp;amp;from=timeline&amp;amp;from=timeline&amp;from=timeline
                //防止提示state参数过长问题,连接转发多次之后会带着一些转发到哪里的冗余信息
                RequestUri = RequestUri.Substring(0, RequestUri.IndexOf("&amp;"));//WeChatManage/Liang/Index?organizeId=4da3b884-ac5b-46fb-af10-150beb9e6c69
            }
            //判断是否微信通过认证
            if (CurrentWxUser.Users == null)
            {
                string url = string.Format(WeixinConfig.GetCodeUrl2, HttpUtility.UrlEncode(RequestUri));
                filterContext.Result = new RedirectResult(url);
                LogHelper.AddLog("filterContext.Result:" + url);
                return;
            }
        }
Example #16
0
        /// <summary>
        /// generate email body
        /// </summary>
        public static string GenerateEmailBody(int typeId, List <EmailContentElementModel> contentElements)
        {
            try
            {
                string result = "";
                using (var db = new FCCEmailAgentEntities())
                {
                    string templateName =
                        db.EmailTypes.Where(x => x.Id == typeId).Select(x => x.TemplateName).FirstOrDefault();

                    string templatePath = Path.Combine(Program.Agent.SystemSettings.TemplatesPath,
                                                       SettingsHelper.GetSettingValueByName(templateName));
                    string template = IOHelper.ReadFile(templatePath);

                    foreach (var contentElement in contentElements)
                    {
                        template = template.Replace(contentElement.Name, contentElement.Value);
                    }
                    result = template;
                }
                return(result);
            }
            catch (Exception exception)
            {
                string innerException = exception.InnerException == null ? "" : exception.InnerException.Message;
                string methodName     = System.Reflection.MethodBase.GetCurrentMethod().Name;
                LogHelper.AddLog("Error in method: " + methodName + "; Exception: " + exception.Message + " Innner Exception: " +
                                 innerException);
                return("");
            }
        }
Example #17
0
        public static string GetMediaLivestreamLink(string mediaLink)
        {
            string data = "";

            LogHelper.AddLog("Get media stream info");
            var youtubeDlProcess = new Process();

            youtubeDlProcess.StartInfo = new ProcessStartInfo("youtube-dl", $"--get-url {mediaLink}");
            youtubeDlProcess.StartInfo.UseShellExecute        = false;
            youtubeDlProcess.StartInfo.CreateNoWindow         = true;
            youtubeDlProcess.StartInfo.RedirectStandardOutput = true;
            youtubeDlProcess.StartInfo.RedirectStandardError  = true;
            youtubeDlProcess.OutputDataReceived += new DataReceivedEventHandler((sender, e) =>
            {
                string output = e.Data;
                if (!string.IsNullOrWhiteSpace(e.Data))
                {
                    data = output;
                }
            });
            youtubeDlProcess.ErrorDataReceived += new DataReceivedEventHandler(OutputHandler);
            youtubeDlProcess.Start();
            youtubeDlProcess.BeginOutputReadLine();
            youtubeDlProcess.BeginErrorReadLine();
            youtubeDlProcess.WaitForExit();
            return(data);
        }
Example #18
0
 /// <summary>
 /// 微信认证
 /// https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx24e47efa56c2e554&redirect_uri=http%3a%2f%2fmap.lywenkai.cn%2fWeChatManage%2fWeiXinHome%2fRedirect&response_type=code&scope=snsapi_userinfo&state=http%3a%2f%2fmap.lywenkai.cn%2fWeChatManage%2fLogin%2fIndex#wechat_redirect
 /// </summary>
 /// <param name="code">snsapi_userinfo</param>
 /// <param name="state">回调url</param>
 /// <returns></returns>
 public ActionResult Redirect(string code, string state)
 {
     LogHelper.AddLog($"微信认证请求地址:{System.Web.HttpContext.Current.Request.Url.ToString()}  参数code: {code},参数state: {state}");
     //若用户禁止授权,则重定向后不会带上code参数
     if (string.IsNullOrEmpty(code))
     {
         return(Redirect(state));
     }
     else
     {
         WeixinToken token = new WeixinToken();
         //判断是否保存微信token,用户网页授权,不限制
         if (Session[WebSiteConfig.WXTOKEN_SESSION_NAME] != null)
         {
             token = Session[WebSiteConfig.WXTOKEN_SESSION_NAME] as WeixinToken;
         }
         else
         {
             string tokenUrl = string.Format(WeixinConfig.GetTokenUrl2, code);
             LogHelper.AddLog($"请求tokenUrl地址: {tokenUrl}");
             token = AnalyzeHelper.Get <WeixinToken>(tokenUrl);
             if (token.errcode != null)
             {
                 return(Content("网页授权Error:" + token.errcode + ":" + token.errmsg));
             }
             Session[WebSiteConfig.WXTOKEN_SESSION_NAME] = token;
         }
         Session["OpenId"] = token.openid;//进行登录
         LogHelper.AddLog($"token.openid: {Session["OpenId"]}");
         //查询用户是否存在
         var userEntity = wechatUserBll.GetEntity(token.openid);
         if (userEntity == null)
         {
             string userInfoUrl = string.Format(WeixinConfig.GetUserInfoUrl2, token.access_token, token.openid);
             var    userInfo    = AnalyzeHelper.Get <WeixinUserInfo>(userInfoUrl);
             if (userInfo.errcode != null)
             {
                 Response.Write(userInfo.errcode + ":" + userInfo.errmsg);
                 Response.End();
             }
             else
             {
                 userEntity = new WeChat_UsersEntity()
                 {
                     City       = userInfo.city,
                     Country    = userInfo.country,
                     HeadimgUrl = userInfo.headimgurl,
                     NickName   = userInfo.nickname,
                     OpenId     = userInfo.openid,
                     Province   = userInfo.province,
                     Sex        = userInfo.sex,
                     AppName    = Config.GetValue("AppName2")
                 };
                 wechatUserBll.SaveForm("", userEntity);
             }
         }
         Session[WebSiteConfig.WXUSER_SESSION_NAME] = userEntity;
         return(Redirect(state));
     }
 }
        /// <summary>
        /// Fetch the banners displayed on the home page
        /// </summary>
        /// <returns></returns>
        private BannersList FetchAndCacheBanners()
        {
            BannersList bannersList = new BannersList();

            try
            {
                if (Session["BannersList"] == null)
                {
                    //IDAL dal = (new DALFactory()).GetInstance();
                    SharePointDAL dal = new SharePointDAL();
                    bannersList.BannersListdetails = dal.GetBanners();
                    Session["BannersList"]         = bannersList;
                }
                else
                {
                    bannersList = (BannersList)Session["BannersList"];
                }
            }
            catch (Exception ex)
            {
                UserManager user = (UserManager)Session["CurrentUser"];
                LogHelper.AddLog(new LogEntity(AppConstant.PartitionError, user.EmailID.ToString(), AppConstant.ApplicationName, "Home,FetchAndCacheBanners", ex.Message, ex.StackTrace));
            }
            return(bannersList);
        }
Example #20
0
        public ActionResult EditProjects(string projectName)
        {
            if (projectName.Equals(String.Empty))
            {
                ModelState.AddModelError("ProjectName", "Project Name is required");
            }
            try
            {
                if (ModelState.IsValid)
                {
                    Project project = (Project)Session["EditProject"];
                    project.ProjectName = projectName;

                    IDAL dal = (new DALFactory()).GetInstance();
                    dal.UpdateProject(project);

                    return(RedirectToAction("AddProject", new Project()));
                }
                else
                {
                    return(View());
                }
            }
            catch (Exception ex)
            {
                UserManager user = (UserManager)Session["CurrentUser"];
                LogHelper.AddLog(new LogEntity(AppConstant.PartitionError, user.EmailID.ToString(), AppConstant.ApplicationName, "Project, EditProjects", ex.Message, ex.StackTrace));

                return(View());
            }
        }
Example #21
0
        public ActionResult productJsApi(int?id, string host)
        {
            TelphoneLiangH5Entity entity = tlbll.GetEntity(id);
            var sp_billno = string.Format("{0}{1}", "LX-", DateTime.Now.ToString("yyyyMMddHHmmss"));
            var openId    = (string)Session["OpenId"];
            var nonceStr  = TenPayV3Util.GetNoncestr();
            var timeStamp = TenPayV3Util.GetTimestamp();

            //商品Id,用户自行定义
            var xmlDataInfoH5 = new TenPayV3UnifiedorderRequestData(WeixinConfig.AppID2, tenPayV3Info.MchId, "JSAPI购买靓号", sp_billno,
                                                                    Convert.ToInt32(Convert.ToDecimal(entity.Price) * 100),
                                                                    Request.UserHostAddress, tenPayV3Info.TenPayV3Notify, TenPayV3Type.JSAPI, openId, tenPayV3Info.Key, nonceStr);
            var result = TenPayV3.Unifiedorder(xmlDataInfoH5); //调用统一订单接口

            LogHelper.AddLog(result.ResultXml);                //记录日志
            var package = string.Format("prepay_id={0}", result.prepay_id);

            if (result.return_code == "SUCCESS")
            {
                WFTWxModel jsApiPayData = new WFTWxModel()
                {
                    appId        = WeixinConfig.AppID2,
                    timeStamp    = timeStamp,
                    nonceStr     = nonceStr,
                    package      = package,
                    paySign      = TenPayV3.GetJsPaySign(WeixinConfig.AppID2, timeStamp, nonceStr, package, WeixinConfig.Key),
                    callback_url = "https://shop.jnlxsm.net/webapp/jinan2/paymentFinish/" + id
                };
                ViewBag.WxModel = jsApiPayData;
                LogHelper.AddLog(JsonConvert.SerializeObject(jsApiPayData));//记录日志
            }
            ViewBag.OrderSn = sp_billno;
            ViewBag.Host    = host;
            return(View(entity));
        }
Example #22
0
        public ActionResult AddProject(string projectName)
        {
            IDAL dal = (new DALFactory()).GetInstance();

            if (projectName.Equals(String.Empty))
            {
                ModelState.AddModelError("ProjectName", "Project Name is required");
            }

            try
            {
                if (ModelState.IsValid)
                {
                    dal.AddProject(projectName);
                    List <Project> lstProjects = dal.GetAllProjects();
                    if (lstProjects.Count != 0)
                    {
                        Session["Projects"] = lstProjects;
                    }
                    return(RedirectToAction("AddProject"));
                }
                else
                {
                    return(View());
                }
            }
            catch (Exception ex)
            {
                UserManager user = (UserManager)Session["CurrentUser"];
                LogHelper.AddLog(new LogEntity(AppConstant.PartitionError, user.EmailID.ToString(), AppConstant.ApplicationName, "Project, AddProject", ex.Message, ex.StackTrace));

                return(View());
            }
        }
Example #23
0
        /// <summary>
        /// 支付结果页面
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult paymentFinish(int?id)
        {
            ViewBag.Id = id;
            OrdersEntity ordersEntity = ordersbll.GetEntity(id);//第一次打开,微信回调还没完成,一般是未支付状态

            for (int i = 0; i < 3; i++)
            {
                ordersEntity = ordersbll.GetEntity(id); //第二次才会成功获取到支付成功状态
                if (ordersEntity.PayStatus == 1)        //如果支付成功直接返回
                {
                    ViewBag.Result  = "支付成功";
                    ViewBag.icon    = "success";
                    ViewBag.display = "none";
                    ViewBag.Tel     = ordersEntity.Tel;
                    LogHelper.AddLog(id + "支付成功");
                    return(View());
                }
                else
                {
                    Thread.Sleep(3000);//当前线程休眠3秒,等待微信回调执行完成
                    LogHelper.AddLog(id + "支付结果获取:" + i);
                }
            }
            //如果超过15秒还未支付成功,返回未支付,防止直接跳转结果页面,显示失败,微信回调还没有完成
            ViewBag.Result  = "未支付";
            ViewBag.icon    = "warn";
            ViewBag.display = "block";
            ViewBag.id      = OperatorAgentProvider.Provider.Current().Id.ToString();
            ViewBag.orderno = ordersEntity.OrderSn;
            return(View());
        }
        public static void SaveNotificationRecord(WfpictContext db,
                                                  Guid?campaignId, string orderNumber, string segmentNumber,
                                                  QcRule qcRule, string message)
        {
            var alreadyNoted = db.Notifications
                               .FirstOrDefault(x => x.CampaignId == campaignId && x.OrderNumber == orderNumber && x.SegmentNumber == segmentNumber &&
                                               x.QcRule == (int)qcRule && x.Status == (int)NotificationStatus.Found);

            if (alreadyNoted != null)
            {
                return;
            }

            LogHelper.AddLog(db, LogType.RulesProcessing, orderNumber, $"Problem found. QCRule {qcRule} , Message {message}");
            db.Notifications.Add(new Notification()
            {
                Id            = Guid.NewGuid(),
                CreatedAt     = DateTime.Now,
                CampaignId    = campaignId,
                OrderNumber   = orderNumber,
                SegmentNumber = segmentNumber,
                Status        = (int)NotificationStatus.Found,
                Message       = message,
                CheckTime     = DateTime.Now,
                FoundAt       = DateTime.Now,
                QcRule        = (int)qcRule
            });
            db.SaveChanges();
        }
Example #25
0
        private static string CreateCampignWithTemplate(WfpictContext db, CreativeVm model, string listId, int templateId)
        {
            IMailChimpManager manager = new MailChimpManager();

            LogHelper.AddLog(db, LogType.MailChimp, model.OrderNumber, "Creating campaign with template");
            var campaign = manager.Campaigns.AddAsync(new MailChimp.Net.Models.Campaign
            {
                Recipients = new Recipient
                {
                    ListId = listId
                },
                Settings = new Setting
                {
                    ReplyTo     = "*****@*****.**",
                    Title       = model.SubjectLine,
                    FromName    = "Josh Silver",
                    SubjectLine = model.SubjectLine,
                    TemplateId  = templateId,
                },
                Type = CampaignType.Regular,
            }).ConfigureAwait(false);

            var campaignId = campaign.GetAwaiter().GetResult().Id;

            return(campaignId);
        }
        /// <summary>
        /// 批量(删除)
        /// </summary>
        /// <param name="dtSource">实体对象</param>
        /// <returns></returns>
        public string BatchDeleteEntity(DataTable dtSource)
        {
            int rowsCount = dtSource.Rows.Count;
            int columns   = dtSource.Columns.Count;
            int ok        = 0;

            for (int i = 0; i < rowsCount; i++)
            {
                try
                {
                    string telphone = dtSource.Rows[i][0].ToString().Trim();
                    if (telphone.Length == 11)
                    {
                        IRepository db         = new RepositoryFactory().BaseRepository().BeginTrans();
                        var         liang_Data = db.FindList <TelphoneLiangH5Entity>(t => t.Telphone == telphone && t.DeleteMark != 1);//删除过的可以再次导入
                        foreach (var item in liang_Data)
                        {
                            db.Delete(item);
                            ok++;
                        }
                        db.Commit();
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.AddLog(ex.Message);
                    return(ex.Message);
                }
            }
            return("批量删除完成!" + ok);
        }
Example #27
0
        public static void TestSend(CreativeVm model)
        {
            using (var db = new WfpictContext())
            {
                var logs = db.SystemLogs.Where(x => x.OrderNumber == model.OrderNumber && x.LogType == (int)LogType.MailChimp);
                foreach (var log in logs)
                {
                    db.SystemLogs.Remove(log);
                }
                db.SaveChanges();

                LogHelper.AddLog(db, LogType.MailChimp, model.OrderNumber, "Starting Test send. Order Number : " + model.OrderNumber);
                string listId = CreateList(db, model);
                CreateMembers(db, listId, model);

                // Wait 5 min
                Thread.Sleep(1000 * 60 * 5);

                //CreateTemplateFolder(model);
                int templateId = CreateTemplate(db, model);

                string campaignId = CreateCampignWithTemplate(db, model, listId, templateId);

                SendCampaign(db, model, campaignId);

                LogHelper.AddLog(db, LogType.MailChimp, model.OrderNumber, "Test send completed successfully.");
            }
        }
Example #28
0
        /// <summary>
        /// 发起GET请求
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="requestUrl"></param>
        /// <returns></returns>
        public static T Get <T>(String requestUrl) where T : WeixinResponse, new()
        {
            String resultJson = HttpClientHelper.Get(requestUrl);

            LogHelper.AddLog(resultJson);
            return(AnalyzeResult <T>(resultJson));
        }
Example #29
0
        /// <summary>
        /// 服务器异步通知页面
        /// </summary>
        public ActionResult ReturnUrl()
        {
            /* 实际验证过程建议商户添加以下校验。
             * 1、商户需要验证该通知数据中的out_trade_no是否为商户系统中创建的订单号,
             * 2、判断total_amount是否确实为该订单的实际金额(即商户订单创建时的金额),
             * 3、校验通知中的seller_id(或者seller_email) 是否为out_trade_no这笔单据的对应的操作方(有的时候,一个商户可能有多个seller_id/seller_email)
             * 4、验证app_id是否为该商户本身。
             */
            Dictionary <string, string> sArray = GetRequestGet();

            if (sArray.Count != 0)
            {
                //订单号
                string orderno = sArray["out_trade_no"];
                bool   flag    = AlipaySignature.RSACheckV1(sArray, WeixinConfig.payKey, WeixinConfig.charset, WeixinConfig.signType, false);//支付宝公钥
                if (flag)
                {
                    ViewBag.Result = "支付成功";
                    ViewBag.icon   = "success";
                    //ViewBag.display = "none";
                    LogHelper.AddLog("同步验证通过! 订单号:" + orderno);
                }
                else
                {
                    ViewBag.Result = "未支付";
                    ViewBag.icon   = "warn";
                    //ViewBag.display = "block";
                    LogHelper.AddLog("同步验证失败! 订单号:" + orderno);
                }
                ViewBag.orderno = orderno;
                //ViewBag.id = OperatorAgentProvider.Provider.Current().Id.ToString();
            }
            return(View());
        }
Example #30
0
        public bool Start()
        {
            var ret = true;

            try
            {
                var hostConfigs = new HostConfiguration
                {
                    UrlReservations = new UrlReservations()
                    {
                        CreateAutomatically = true
                    }
                };

                _host = new NancyHost(hostConfigs, new Uri("http://localhost:9000"));
                _host.Start();

                //The Nancy self host was unable to start, as no namespace reservation existed for the provided url(s).
                //    Please either enable UrlReservations.CreateAutomatically on the HostConfiguration provided to
                //the NancyHost, or create the reservations manually with the (elevated) command(s):
                //netsh http add urlacl url="http://+:9000/" user="******"
            }
            catch (Exception exception)
            {
                ret = false;
                LogHelper.AddLog(exception);
                Console.WriteLine(exception);
            }

            return(ret);
        }