示例#1
0
 public pcms_popup EditpopUp(int query)
 {
     try
     {
         pcms_popup     _popup  = new pcms_popup();
         PCMS_DbContext context = new PCMS_DbContext();
         var            res     = context.pcms_popup.Single(popup => popup.POPUP_ID == query);
         pcms_design    dn      = new pcms_design();
         _popup.POPUP_ID          = res.POPUP_ID;
         _popup.POPUP_NAME        = Cryptographys.Decrypt(res.POPUP_NAME);
         _popup.POPUP_DESCRIPTION = Cryptographys.Decrypt(res.POPUP_DESCRIPTION);
         _popup.POPUP_HTML        = Cryptographys.Decrypt(res.POPUP_HTML);
         _popup.INSERTED_BY       = res.INSERTED_BY;
         _popup.INSERTED_DATE     = res.INSERTED_DATE;
         _popup.POPUP_ISDELETED   = res.POPUP_ISDELETED;
         _popup.TS_CNT            = res.TS_CNT;
         return(_popup);
     }
     catch (Exception ex)
     {
         Utilities objUtilities = new Utilities();
         objUtilities.LogError(ex);
         return(null);
     }
 }
示例#2
0
 public pcms_design EditDesign(int query)
 {
     try
     {
         pcms_design    _design = new pcms_design();
         PCMS_DbContext context = new PCMS_DbContext();
         var            res     = context.pcms_design.Single(content => content.DESIGN_ID == query);
         pcms_design    dn      = new pcms_design();
         _design.DESIGN_ID          = res.DESIGN_ID;
         _design.DESIGN_NAME        = Cryptographys.Decrypt(res.DESIGN_NAME);
         _design.DESIGN_DESCRIPTION = Cryptographys.Decrypt(res.DESIGN_DESCRIPTION);
         _design.DESIGN_HTML        = Cryptographys.Decrypt(res.DESIGN_HTML);
         _design.INSERTED_BY        = res.INSERTED_BY;
         _design.INSERTED_DATE      = res.INSERTED_DATE;
         _design.DESIGN_ISDELETED   = res.DESIGN_ISDELETED;
         _design.TS_CNT             = res.TS_CNT;
         return(_design);
     }
     catch (Exception ex)
     {
         Utilities objUtilities = new Utilities();
         objUtilities.LogError(ex);
         return(null);
     }
 }
示例#3
0
        public ActionResult Login(cvmLogin model)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.Message = "Account or Password Error!!";
                return(View(model));
            }

            string str_password = model.UserPassword;

            using (Cryptographys cryp = new Cryptographys())
            {
                str_password = cryp.SHA256Encode(str_password);
            }

            var users = db.users
                        .Where(m => m.maccount == model.UserAccount)
                        .Where(m => m.mpassword == str_password)
                        .FirstOrDefault();

            if (users == null)
            {
                UserAccount.LogOut();
                FormsAuthentication.SignOut();
                ViewBag.Message = "帳號或密碼錯誤!";
                return(View(model));
            }

            UserAccount.Login(users, UserAccount.GetRoleNo(users.role_no));
            UserAccount.IsRememberMe = model.Remember;
            UserAccount.LoginAuthenticate();

            return(RedirectToAction("RedirectToUserPage"));
        }
示例#4
0
        public string SaveURL(string usr, string url, string usrby)
        {
            string Msg = "";

            try
            {
                using (PCMS_DbContext _pcmsDbContext = new PCMS_DbContext())
                {
                    pcms_rules objRules = new pcms_rules();
                    objRules.WEBSITE_URL      = Cryptographys.Encrypt(usr);
                    objRules.RULE_APPLIED_URL = Cryptographys.Encrypt(url);
                    objRules.INSERTED_BY      = usrby;
                    objRules.INSERTED_DATE    = DateTime.Now;
                    objRules.TS_CNT           = 1;
                    objRules.RULE_PK          = Guid.NewGuid();
                    _pcmsDbContext.AddTopcms_rules(objRules);
                    _pcmsDbContext.SaveChanges();
                    Msg = "Inserted";
                    return(Msg);
                }
            }
            catch (Exception ex)
            {
                return(Msg = ex.Message);
            }
        }
示例#5
0
        public ActionResult ResetPassword(cvmResetPassword model)
        {
            if (!ModelState.IsValid) return View(model);

            //自定義檢查
            string str_password = "";
            using (Cryptographys cryp = new Cryptographys())
            { str_password = cryp.SHA256Encode(model.CurrentPassword); }
            bool bln_error = false;

            var check = db.Users
                .Where(m => m.mno == model.UserNo)
                .Where(m => m.password == str_password)
                .FirstOrDefault();
            if (check == null) { ModelState.AddModelError("", "目前密碼輸入錯誤!!"); bln_error = true; }
            if (bln_error) return View(model);

            str_password = model.NewPassword;
            var user = db.Users.Where(m => m.mno == model.UserNo).FirstOrDefault();
            if (user != null)
            {
                //密碼加密
                using (Cryptographys cryp = new Cryptographys())
                { str_password = cryp.SHA256Encode(str_password); }

                user.password = str_password;
                db.Configuration.ValidateOnSaveEnabled = false;
                db.SaveChanges();
                db.Configuration.ValidateOnSaveEnabled = true;
            }
            return RedirectToAction("RedirectToUserPage");
        }
示例#6
0
        public string UpdateUrlList(string weburl, string insertby, DateTime insertdate, int tscnt, string url)
        {
            string Msg = "";

            try
            {
                PCMS_DbContext context  = new PCMS_DbContext();
                pcms_rules     objRules = new pcms_rules();
                objRules.RULE_APPLIED_URL = Cryptographys.Encrypt(url);
                objRules.INSERTED_BY      = insertby;
                objRules.INSERTED_DATE    = insertdate;
                objRules.WEBSITE_URL      = Cryptographys.Encrypt(weburl);
                objRules.TS_CNT           = tscnt;
                objRules.RULE_PK          = Guid.NewGuid();
                context.AddTopcms_rules(objRules);
                context.SaveChanges();
                Msg = "Inserted";
                return(Msg);
            }
            catch (Exception ex)
            {
                Utilities objUtilities = new Utilities();
                objUtilities.LogError(ex);
                Msg = "Something went wrong";
                return(null);
            }
        }
示例#7
0
        public ActionResult Login(cvmLogin model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            string str_password = model.Password;

            using (Cryptographys crpy = new Cryptographys())
            {
                str_password = crpy.SHA256Encode(str_password);
            }
            var users = db.Users
                        .Where(m => m.mno == model.UserNo)
                        .Where(m => m.password == str_password)
                        .FirstOrDefault();

            if (users == null)
            {
                return(View(model));
            }
            UserAccount.Login(model.UserNo, users.mname, UserAccount.GetRoleNo(users.role_no));

            return(RedirectToAction("RedirectToUserPage"));
        }
示例#8
0
 public List <pcms_campaign> getCampaignByid(string query)
 {
     try
     {
         using (PCMS_DbContext _pcmsDbContext = new PCMS_DbContext())
         {
             var campaignList = (_pcmsDbContext.pcms_campaign
                                 .Select(cam => new
             {
                 CAMPAIGN_ID = cam.CAMPAIGN_ID,
                 CAMPAIGN_NAME = cam.CAMPAIGN_NAME,
                 CAMPAIGN_START_DATE = cam.CAMPAIGN_START_DATE,
                 CAMPAIGN_END_DATE = cam.CAMPAIGN_END_DATE,
                 CAMPAIGN_STATUS = cam.CAMPAIGN_STATUS,
                 CAMPAIGN_DESIGN_ID = cam.CAMPAIGN_DESIGN_ID,
                 CAMPAIGN_CONTENT_ID = cam.CAMPAIGN_CONTENT_ID,
                 CAMPAIGN_POPUP_STATUS = cam.CAMPAIGN_POPUP_STATUS,
                 CAMPAIGN_POPUP_ID = cam.CAMPAIGN_POPUP_ID,
                 CAMPAIGN_RULE_ID = cam.CAMPAIGN_RULE_ID,
                 CAMPAIGN_URL = cam.CAMPAIGN_URL,
                 CAMPAIGN_REDIRECT_URL = cam.CAMPAIGN_REDIRECT_URL,
                 CAMPAIGN_CONTAINER_ID = cam.CAMPAIGN_CONTAINER_ID,
                 CAMPAIGN_DESCRIPTION = cam.CAMPAIGN_DESCRIPTION
             }).ToList()
                                 .Select(x => new pcms_campaign()
             {
                 CAMPAIGN_ID = x.CAMPAIGN_ID,
                 CAMPAIGN_NAME = x.CAMPAIGN_NAME,
                 CAMPAIGN_START_DATE = x.CAMPAIGN_START_DATE,
                 CAMPAIGN_END_DATE = x.CAMPAIGN_END_DATE,
                 CAMPAIGN_STATUS = x.CAMPAIGN_STATUS,
                 CAMPAIGN_DESIGN_ID = x.CAMPAIGN_DESIGN_ID,
                 CAMPAIGN_CONTENT_ID = x.CAMPAIGN_CONTENT_ID,
                 CAMPAIGN_POPUP_STATUS = x.CAMPAIGN_POPUP_STATUS,
                 CAMPAIGN_POPUP_ID = x.CAMPAIGN_POPUP_ID,
                 CAMPAIGN_RULE_ID = x.CAMPAIGN_RULE_ID,
                 CAMPAIGN_URL = Cryptographys.Decrypt(x.CAMPAIGN_URL),
                 CAMPAIGN_REDIRECT_URL = Cryptographys.Decrypt(x.CAMPAIGN_REDIRECT_URL),
                 CAMPAIGN_CONTAINER_ID = x.CAMPAIGN_CONTAINER_ID,
                 CAMPAIGN_DESCRIPTION = Cryptographys.Decrypt(x.CAMPAIGN_DESCRIPTION),
             }).Where(y => y.CAMPAIGN_ID == Convert.ToInt16(query)).OrderByDescending(y => y.INSERTED_DATE)).ToList();
             if (campaignList.Count > 0)
             {
                 return(campaignList);
             }
             else
             {
                 return(new List <pcms_campaign>());
             }
         }
     }
     catch (Exception ex)
     {
         Utilities objUtilities = new Utilities();
         objUtilities.LogError(ex);
         return(null);
     }
 }
示例#9
0
        public pcms_KeyRule RuleInformarion(pcms_Rule _rule)
        {
            SqlCommand cmd = null;

            using (SqlConnection con = new SqlConnection(_connectionString))
            {
                con.Open();
                pcms_KeyRule objDAL = new pcms_KeyRule();
                cmd             = new SqlCommand(null, con);
                cmd.CommandText = @"select RULE_ID,RULE_APPLIED_URL,CONTENT_HTML,DESIGN_HTML,
                POPUP_HTML,RULE_PARAMETER_KEY_VALUE,CAMPAIGN_REDIRECT_URL,
                CAMPAIGN_CONTAINER_ID FROM pcms_rules inner join pcms_campaign 
                on CAMPAIGN_RULE_ID=RULE_ID 
                left join pcms_popup on CAMPAIGN_POPUP_ID=POPUP_ID 
                left join pcms_design on CAMPAIGN_DESIGN_ID=  DESIGN_ID 
                left join pcms_content on CAMPAIGN_CONTENT_ID=CONTENT_ID 
                where CAMPAIGN_STATUS='Active' AND RULE_APPLIED_URL=@RULE_APPLIED_URL 
                AND RULE_LOCATION=@RULE_LOCATION
                AND RULE_USER_TYPE =@RULE_USER_TYPE 
                AND (CAMPAIGN_START_DATE <='" + DateTime.Now + "' AND CAMPAIGN_END_DATE >='" + DateTime.Now + "')";
                SqlParameter RULE_APPLIED_URL = new SqlParameter("@RULE_APPLIED_URL", SqlDbType.NVarChar, -1);
                SqlParameter RULE_LOCATION    = new SqlParameter("@RULE_LOCATION", SqlDbType.NVarChar, -1);
                SqlParameter RULE_USER_TYPE   = new SqlParameter("@RULE_USER_TYPE", SqlDbType.NVarChar, -1);
                RULE_APPLIED_URL.Value = Cryptographys.Encrypt(_rule.URL);
                cmd.Parameters.Add(RULE_APPLIED_URL);
                RULE_LOCATION.Value = _rule.COUNTRY;
                cmd.Parameters.Add(RULE_LOCATION);
                RULE_USER_TYPE.Value = _rule.USERTYPE;
                cmd.Parameters.Add(RULE_USER_TYPE);
                cmd.Prepare();
                SqlDataReader dr = cmd.ExecuteReader();
                //DataTable dt = new DataTable();
                //dt.Columns.Add("CONTENT_HTML", typeof(string));
                //dt.Columns.Add("DESIGN_HTML", typeof(string));
                //dt.Columns.Add("POPUP_HTML", typeof(string));
                //dt.Columns.Add("RULE_PARAMETER_KEY_VALUE", typeof(string));
                //dt.Columns.Add("CAMPAIGN_REDIRECT_URL", typeof(string));
                //dt.Columns.Add("CAMPAIGN_CONTAINER_ID", typeof(string));
                // DataRow row;
                while (dr.Read())
                {
                    objDAL = new pcms_KeyRule();
                    // row["RULE_ID"] = dr["RULE_ID"].ToString();
                    objDAL.CAMPAIGN_CONTAINER_ID    = dr["CAMPAIGN_CONTAINER_ID"].ToString();
                    objDAL.RULE_PARAMETER_KEY_VALUE = dr["RULE_PARAMETER_KEY_VALUE"].ToString();
                    // row["RULE_APPLIED_URL"] = Cryptographys.Decrypt(dr["RULE_APPLIED_URL"].ToString());
                    objDAL.CONTENT_HTML          = Cryptographys.Decrypt(dr["CONTENT_HTML"].ToString());
                    objDAL.DESIGN_HTML           = Cryptographys.Decrypt(dr["DESIGN_HTML"].ToString());
                    objDAL.POPUP_HTML            = Cryptographys.Decrypt(dr["POPUP_HTML"].ToString());
                    objDAL.CAMPAIGN_REDIRECT_URL = Cryptographys.Decrypt(dr["CAMPAIGN_REDIRECT_URL"].ToString());
                    // dt.Rows.Add(row);
                }
                con.Close();
                return(objDAL);
            }
        }
示例#10
0
        public string AddWebsite(pcms_List list)
        {
            string Msg = "";

            try
            {
                using (PCMS_DbContext _pcmsDbContext = new PCMS_DbContext())
                {
                    string url = list.url[0].WEBSITE_URL;
                    if (_pcmsDbContext.pcms_website.Any(u => u.WEBSITE_URL == url))
                    {
                        return(Msg = "Duplicate");
                    }
                    else
                    {
                        pcms_website objWebsite = new pcms_website();
                        objWebsite.WEBSITE_URL         = list.url[0].WEBSITE_URL;
                        objWebsite.WEBSITE_SITEMAP_URL = list.url[0].WEBSITE_SITEMAP_URL != null ? list.url[0].WEBSITE_SITEMAP_URL : "";
                        objWebsite.SDK_VERIFIED        = Convert.ToBoolean(list.url[0].SDK_VERIFIED);
                        objWebsite.INSERTED_BY         = list.url[0].INSERTED_BY;
                        objWebsite.INSERTED_DATE       = list.url[0].INSERTED_DATE;
                        objWebsite.TS_CNT     = list.url[0].TS_CNT;
                        objWebsite.WEBSITE_PK = Guid.NewGuid();
                        pcms_rules objRules = new pcms_rules();
                        string     webmap   = list.url[0].WEBSITE_URL != null?Cryptographys.Encrypt(list.url[0].WEBSITE_URL) : "";

                        objRules.RULE_APPLIED_URL = webmap;
                        objRules.INSERTED_BY      = list.url[0].INSERTED_BY;
                        objRules.INSERTED_DATE    = list.url[0].INSERTED_DATE;
                        objRules.WEBSITE_URL      = Cryptographys.Encrypt(list.url[0].WEBSITE_URL);
                        objRules.TS_CNT           = list.url[0].TS_CNT;
                        objRules.RULE_PK          = Guid.NewGuid();
                        _pcmsDbContext.AddTopcms_website(objWebsite);
                        _pcmsDbContext.AddTopcms_rules(objRules);
                        _pcmsDbContext.SaveChanges();
                        Msg = "Inserted";
                        return(Msg);
                    }
                }
            }
            catch (Exception ex)
            {
                Utilities objUtilities = new Utilities();
                objUtilities.LogError(ex);
                Msg = "Something went wrong";
                return(null);
            }
        }
示例#11
0
        public ActionResult Register(cvmRegister model)
        {
            if (!ModelState.IsValid) return View(model);

            //自定義檢查
            bool bln_error = false;
            var check = db.Users.Where(m => m.mno == model.mno).FirstOrDefault();
            if (check != null) { ModelState.AddModelError("mno", "帳號重覆註冊!!"); bln_error = true; }
            check = db.Users.Where(m => m.email == model.email).FirstOrDefault();
            if (check != null) { ModelState.AddModelError("email", "電子信箱重覆註冊!!"); bln_error = true; }
 
            if (bln_error) return View(model);

            //密碼加密
            using (Cryptographys cryp = new Cryptographys())
            {
                model.password = cryp.SHA256Encode(model.password);
                model.ConfirmPassword = model.password;
            }

            Users user = new Users();
            user.mno = model.mno;
            user.mname = model.mname;
            user.password = model.password;
            user.email = model.email;
            user.birthday = model.birthday;
            user.remark = model.remark;
            user.role_no = "Member";  
            user.varify_code = UserAccount.GetNewVarifyCode(); //產生驗證碼
            user.isvarify = 0;

            //寫入資料庫
            try
            {
                db.Configuration.ValidateOnSaveEnabled = false;
                db.Users.Add(user);
                db.SaveChanges();
                db.Configuration.ValidateOnSaveEnabled = true;
            }
            catch (Exception ex)
            {
                string str_message = ex.Message;
            }

            //寄出驗證信
            SendVerifyMail(model.email, user.varify_code);
            return RedirectToAction("SendEmailResult");
        }
示例#12
0
        public string InsertCampaignData(pcms_campaign _campaign)
        {
            string         Msg     = "";
            PCMS_DbContext context = new PCMS_DbContext();

            try
            {
                if (!context.pcms_campaign.Any(u => u.CAMPAIGN_NAME == _campaign.CAMPAIGN_NAME))
                {
                    pcms_campaign cm = new pcms_campaign();
                    cm.PK_CAMPAIGN           = Guid.NewGuid();
                    cm.CAMPAIGN_NAME         = _campaign.CAMPAIGN_NAME;
                    cm.CAMPAIGN_DESCRIPTION  = Cryptographys.Encrypt(_campaign.CAMPAIGN_DESCRIPTION);
                    cm.CAMPAIGN_START_DATE   = Convert.ToDateTime(_campaign.CAMPAIGN_START_DATE);
                    cm.CAMPAIGN_END_DATE     = Convert.ToDateTime(_campaign.CAMPAIGN_END_DATE);
                    cm.CAMPAIGN_STATUS       = _campaign.CAMPAIGN_STATUS;
                    cm.CAMPAIGN_DESIGN_ID    = _campaign.CAMPAIGN_DESIGN_ID;
                    cm.CAMPAIGN_CONTENT_ID   = _campaign.CAMPAIGN_CONTENT_ID;
                    cm.CAMPAIGN_POPUP_STATUS = _campaign.CAMPAIGN_POPUP_STATUS;
                    cm.CAMPAIGN_POPUP_ID     = _campaign.CAMPAIGN_POPUP_ID;
                    cm.CAMPAIGN_RULE_ID      = _campaign.CAMPAIGN_RULE_ID;
                    cm.CAMPAIGN_URL          = Cryptographys.Encrypt(_campaign.CAMPAIGN_URL);
                    cm.CAMPAIGN_REDIRECT_URL = Cryptographys.Encrypt(_campaign.CAMPAIGN_REDIRECT_URL);
                    cm.CAMPAIGN_CONTAINER_ID = _campaign.CAMPAIGN_CONTAINER_ID;
                    cm.INSERTED_BY           = _campaign.INSERTED_BY;
                    cm.INSERTED_DATE         = _campaign.INSERTED_DATE;
                    cm.TS_CNT = _campaign.TS_CNT;
                    context.AddTopcms_campaign(cm);
                    context.SaveChanges();
                    Msg = "Inserted";
                }
                else
                {
                    Msg = "Duplicate";
                }
                return(Msg);
            }
            catch (Exception ex)
            {
                Utilities objUtilities = new Utilities();
                objUtilities.LogError(ex);
                Msg = "Something went wrong";
                return(null);
            }
        }
示例#13
0
        public ActionResult ResetPassword(int id)
        {
            bool status = false;

            using (dbcon db = new dbcon())
            {
                var model = db.users.Where(m => m.rowid == id).FirstOrDefault();
                if (model != null)
                {
                    using (Cryptographys crpy = new Cryptographys())
                    {
                        model.mpassword = crpy.SHA256Encode(model.mno);
                        db.SaveChanges();
                    }
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
示例#14
0
        public string UpdateCamaign(pcms_campaign _campaign)
        {
            string Msg = "";

            try
            {
                using (PCMS_DbContext _pcmsDbContext = new PCMS_DbContext())
                {
                    //Perform Update operation
                    pcms_campaign cm = _pcmsDbContext.pcms_campaign.Single(u => u.CAMPAIGN_ID == _campaign.CAMPAIGN_ID);
                    cm.CAMPAIGN_NAME         = _campaign.CAMPAIGN_NAME;
                    cm.CAMPAIGN_DESCRIPTION  = Cryptographys.Encrypt(_campaign.CAMPAIGN_DESCRIPTION);
                    cm.CAMPAIGN_START_DATE   = Convert.ToDateTime(_campaign.CAMPAIGN_START_DATE);
                    cm.CAMPAIGN_END_DATE     = Convert.ToDateTime(_campaign.CAMPAIGN_END_DATE);
                    cm.CAMPAIGN_STATUS       = _campaign.CAMPAIGN_STATUS;
                    cm.CAMPAIGN_DESIGN_ID    = _campaign.CAMPAIGN_DESIGN_ID;
                    cm.CAMPAIGN_CONTENT_ID   = _campaign.CAMPAIGN_CONTENT_ID;
                    cm.CAMPAIGN_POPUP_STATUS = _campaign.CAMPAIGN_POPUP_STATUS;
                    cm.CAMPAIGN_POPUP_ID     = _campaign.CAMPAIGN_POPUP_ID;
                    cm.CAMPAIGN_RULE_ID      = _campaign.CAMPAIGN_RULE_ID;
                    cm.CAMPAIGN_URL          = Cryptographys.Encrypt(_campaign.CAMPAIGN_URL);
                    cm.CAMPAIGN_REDIRECT_URL = Cryptographys.Encrypt(_campaign.CAMPAIGN_REDIRECT_URL);
                    cm.CAMPAIGN_CONTAINER_ID = _campaign.CAMPAIGN_CONTAINER_ID;
                    cm.INSERTED_BY           = _campaign.INSERTED_BY;
                    cm.INSERTED_DATE         = _campaign.INSERTED_DATE;
                    cm.TS_CNT = _campaign.TS_CNT;
                    _pcmsDbContext.SaveChanges();
                    Msg = "Updated";
                    return(Msg);
                }
            }
            catch (Exception ex)
            {
                Utilities objUtilities = new Utilities();
                objUtilities.LogError(ex);
                Msg = "Something went wrong";
                return(null);
            }
        }
示例#15
0
        public string updateRules(pcms_rules Rule)
        {
            string Msg = "";

            try
            {
                PCMS_DbContext context = new PCMS_DbContext();
                if (!context.pcms_rules.Any(u => u.RULE_NAME == Rule.RULE_NAME))
                {
                    pcms_rules pu = new pcms_rules();
                    pu.RULE_NAME                = Cryptographys.Encrypt(Rule.RULE_NAME);
                    pu.RULE_LOCATION            = Rule.RULE_LOCATION;
                    pu.RULE_USER_TYPE           = Rule.RULE_USER_TYPE;
                    pu.RULE_PK                  = Guid.NewGuid();
                    pu.RULE_PARAMETER_KEY_VALUE = Rule.RULE_PARAMETER_KEY_VALUE;
                    pu.RULE_APPLIED_URL         = Cryptographys.Encrypt(Rule.RULE_APPLIED_URL);
                    pu.RULE_ISDELETED           = Rule.RULE_ISDELETED;
                    pu.INSERTED_BY              = Rule.INSERTED_BY;
                    pu.INSERTED_DATE            = Rule.INSERTED_DATE;
                    pu.WEBSITE_URL              = Cryptographys.Encrypt(Rule.WEBSITE_URL);
                    pu.TS_CNT = Rule.TS_CNT;
                    context.AddTopcms_rules(pu);
                    context.SaveChanges();
                    Msg = "Inserted";
                }
                else
                {
                    Msg = "Duplicate";
                }
                return(Msg);
            }
            catch (Exception ex)
            {
                Utilities objUtilities = new Utilities();
                objUtilities.LogError(ex);
                Msg = "Something went wrong";
                return(null);
            }
        }
示例#16
0
        public string UpdatepopUp(pcms_popup _Popup)
        {
            string Msg = "";

            try
            {
                PCMS_DbContext context = new PCMS_DbContext();
                pcms_popup     nUser   = context.pcms_popup.Single(u => u.POPUP_ID == _Popup.POPUP_ID);
                nUser.POPUP_DESCRIPTION = Cryptographys.Encrypt(_Popup.POPUP_DESCRIPTION);
                nUser.POPUP_HTML        = Cryptographys.Encrypt(_Popup.POPUP_HTML);
                context.SaveChanges();
                Msg = "Updated";
                return(Msg);
            }
            catch (Exception ex)
            {
                Utilities objUtilities = new Utilities();
                objUtilities.LogError(ex);
                Msg = "Something went wrong";
                return(null);
            }
        }
示例#17
0
        public string UpdateContent(pcms_content _content)
        {
            string Msg = "";

            try
            {
                PCMS_DbContext context = new PCMS_DbContext();
                pcms_content   nUser   = context.pcms_content.Single(u => u.CONTENT_ID == _content.CONTENT_ID);
                nUser.CONTENT_DESCRIPTION = Cryptographys.Encrypt(_content.CONTENT_DESCRIPTION);
                nUser.CONTENT_HTML        = Cryptographys.Encrypt(_content.CONTENT_HTML);
                context.SaveChanges();
                Msg = "Updated";
                return(Msg);
            }
            catch (Exception ex)
            {
                Utilities objUtilities = new Utilities();
                objUtilities.LogError(ex);
                Msg = "Something went wrong";
                return(null);
            }
        }
示例#18
0
        public string UpdateDesign(pcms_design _Design)
        {
            string Msg = "";

            try
            {
                PCMS_DbContext context = new PCMS_DbContext();
                pcms_design    nUser   = context.pcms_design.Single(u => u.DESIGN_ID == _Design.DESIGN_ID);
                nUser.DESIGN_DESCRIPTION = Cryptographys.Encrypt(_Design.DESIGN_DESCRIPTION);
                nUser.DESIGN_HTML        = Cryptographys.Encrypt(_Design.DESIGN_HTML);
                context.SaveChanges();
                Msg = "Updated";
                return(Msg);
            }
            catch (Exception ex)
            {
                Utilities objUtilities = new Utilities();
                objUtilities.LogError(ex);
                Msg = "Something went wrong";
                return(null);
            }
        }
示例#19
0
 public List <pcms_content> getContents()
 {
     try
     {
         using (PCMS_DbContext _pcmsDbContext = new PCMS_DbContext())
         {
             var content = (_pcmsDbContext.pcms_content
                            .Select(cam => new
             {
                 CONTENT_ID = cam.CONTENT_ID,
                 CONTENT_NAME = cam.CONTENT_NAME,
                 CONTENT_DESCRIPTION = cam.CONTENT_DESCRIPTION,
             }).ToList()
                            .Select(x => new pcms_content()
             {
                 CONTENT_ID = x.CONTENT_ID,
                 CONTENT_NAME = Cryptographys.Decrypt(x.CONTENT_NAME),
                 CONTENT_DESCRIPTION = Cryptographys.Decrypt(x.CONTENT_DESCRIPTION)
             }).OrderByDescending(y => y.INSERTED_DATE)).ToList();
             if (content.Count > 0)
             {
                 return(content);
             }
             else
             {
                 return(new List <pcms_content>());
             }
         }
     }
     catch (Exception ex)
     {
         Utilities objUtilities = new Utilities();
         objUtilities.LogError(ex);
         return(null);
     }
 }
示例#20
0
        public string AddDesign(pcms_design _Design)
        {
            string Msg = "";

            try
            {
                PCMS_DbContext context = new PCMS_DbContext();
                if (!context.pcms_campaign.Any(u => u.CAMPAIGN_NAME == _Design.DESIGN_NAME))
                {
                    pcms_design dn = new pcms_design();
                    dn.DESIGN_PK          = Guid.NewGuid();
                    dn.DESIGN_NAME        = Cryptographys.Encrypt(_Design.DESIGN_NAME);
                    dn.DESIGN_DESCRIPTION = Cryptographys.Encrypt(_Design.DESIGN_DESCRIPTION);
                    dn.DESIGN_HTML        = Cryptographys.Encrypt(_Design.DESIGN_HTML);
                    dn.INSERTED_BY        = _Design.INSERTED_BY;
                    dn.INSERTED_DATE      = _Design.INSERTED_DATE;
                    dn.DESIGN_ISDELETED   = _Design.DESIGN_ISDELETED;
                    dn.TS_CNT             = _Design.TS_CNT;
                    context.AddTopcms_design(dn);
                    context.SaveChanges();
                    Msg = "Inserted";
                }
                else
                {
                    Msg = "Duplicate";
                }
                return(Msg);
            }
            catch (Exception ex)
            {
                Utilities objUtilities = new Utilities();
                objUtilities.LogError(ex);
                Msg = "Something went wrong";
                return(null);
            }
        }
示例#21
0
 public pcms_content EditContent(int query)
 {
     try
     {
         pcms_content   _content = new pcms_content();
         PCMS_DbContext context  = new PCMS_DbContext();
         var            res      = context.pcms_content.Single(content => content.CONTENT_ID == query);
         _content.CONTENT_ID          = res.CONTENT_ID;
         _content.CONTENT_NAME        = Cryptographys.Decrypt(res.CONTENT_NAME);
         _content.CONTENT_DESCRIPTION = Cryptographys.Decrypt(res.CONTENT_DESCRIPTION);
         _content.CONTENT_HTML        = Cryptographys.Decrypt(res.CONTENT_HTML);
         _content.INSERTED_BY         = res.INSERTED_BY;
         _content.INSERTED_DATE       = res.INSERTED_DATE;
         _content.CONTENT_ISDELETED   = res.CONTENT_ISDELETED;
         _content.TS_CNT = res.TS_CNT;
         return(_content);
     }
     catch (Exception ex)
     {
         Utilities objUtilities = new Utilities();
         objUtilities.LogError(ex);
         return(null);
     }
 }
示例#22
0
        public string AddpopUp(pcms_popup _Popup)
        {
            string Msg = "";

            try
            {
                PCMS_DbContext context = new PCMS_DbContext();
                if (!context.pcms_popup.Any(u => u.POPUP_NAME == _Popup.POPUP_NAME))
                {
                    pcms_popup pu = new pcms_popup();
                    pu.POPUP_PK          = Guid.NewGuid();
                    pu.POPUP_NAME        = Cryptographys.Encrypt(_Popup.POPUP_NAME);
                    pu.POPUP_DESCRIPTION = Cryptographys.Encrypt(_Popup.POPUP_DESCRIPTION);
                    pu.POPUP_HTML        = Cryptographys.Encrypt(_Popup.POPUP_HTML);
                    pu.INSERTED_BY       = _Popup.INSERTED_BY;
                    pu.INSERTED_DATE     = _Popup.INSERTED_DATE;
                    pu.POPUP_ISDELETED   = _Popup.POPUP_ISDELETED;
                    pu.TS_CNT            = _Popup.TS_CNT;
                    context.AddTopcms_popup(pu);
                    context.SaveChanges();
                    Msg = "Inserted";
                }
                else
                {
                    Msg = "Duplicate";
                }
                return(Msg);
            }
            catch (Exception ex)
            {
                Utilities objUtilities = new Utilities();
                objUtilities.LogError(ex);
                Msg = "Something went wrong";
                return(null);
            }
        }
示例#23
0
 public List <pcms_design> getDesignTemplates()
 {
     try
     {
         using (PCMS_DbContext _pcmsDbContext = new PCMS_DbContext())
         {
             var designList = (_pcmsDbContext.pcms_design
                               .Select(cam => new
             {
                 DESIGN_ID = cam.DESIGN_ID,
                 DESIGN_NAME = cam.DESIGN_NAME,
                 DESIGN_DESCRIPTION = cam.DESIGN_DESCRIPTION,
             }).ToList()
                               .Select(x => new pcms_design()
             {
                 DESIGN_ID = x.DESIGN_ID,
                 DESIGN_NAME = Cryptographys.Decrypt(x.DESIGN_NAME),
                 DESIGN_DESCRIPTION = Cryptographys.Decrypt(x.DESIGN_DESCRIPTION)
             }).OrderByDescending(y => y.INSERTED_DATE)).ToList();
             if (designList.Count > 0)
             {
                 return(designList);
             }
             else
             {
                 return(new List <pcms_design>());
             }
         }
     }
     catch (Exception ex)
     {
         Utilities objUtilities = new Utilities();
         objUtilities.LogError(ex);
         return(null);
     }
 }
示例#24
0
 public List <pcms_popup> getpopUp()
 {
     try
     {
         using (PCMS_DbContext _pcmsDbContext = new PCMS_DbContext())
         {
             var popupDesign = (_pcmsDbContext.pcms_popup
                                .Select(cam => new
             {
                 POPUP_ID = cam.POPUP_ID,
                 POPUP_NAME = cam.POPUP_NAME,
                 POPUP_DESCRIPTION = cam.POPUP_DESCRIPTION,
             }).ToList()
                                .Select(x => new pcms_popup()
             {
                 POPUP_ID = x.POPUP_ID,
                 POPUP_NAME = Cryptographys.Decrypt(x.POPUP_NAME),
                 POPUP_DESCRIPTION = Cryptographys.Decrypt(x.POPUP_DESCRIPTION)
             }).OrderByDescending(y => y.INSERTED_DATE)).ToList();
             if (popupDesign.Count > 0)
             {
                 return(popupDesign);
             }
             else
             {
                 return(new List <pcms_popup>());
             }
         }
     }
     catch (Exception ex)
     {
         Utilities objUtilities = new Utilities();
         objUtilities.LogError(ex);
         return(null);
     }
 }
示例#25
0
 public List <pcms_rules> getListofRules()
 {
     try
     {
         using (PCMS_DbContext _pcmsDbContext = new PCMS_DbContext())
         {
             var rules = (_pcmsDbContext.pcms_rules
                          .Select(cam => new
             {
                 RULE_ID = cam.RULE_ID,
                 RULE_NAME = cam.RULE_NAME,
                 RULE_DESCRIPTION = cam.RULE_DESCRIPTION,
             }).ToList()
                          .Select(x => new pcms_rules()
             {
                 RULE_ID = x.RULE_ID,
                 RULE_NAME = Cryptographys.Decrypt(x.RULE_NAME),
                 RULE_DESCRIPTION = Cryptographys.Decrypt(x.RULE_DESCRIPTION)
             }).OrderByDescending(y => y.INSERTED_DATE)).ToList();
             if (rules.Count > 0)
             {
                 return(rules);
             }
             else
             {
                 return(new List <pcms_rules>());
             }
         }
     }
     catch (Exception ex)
     {
         Utilities objUtilities = new Utilities();
         objUtilities.LogError(ex);
         return(null);
     }
 }
示例#26
0
 public List <pcms_rules> getURLBYID(string query)
 {
     try
     {
         using (PCMS_DbContext _pcmsDbContext = new PCMS_DbContext())
         {
             var rules = (_pcmsDbContext.pcms_rules
                          .Select(cam => new
             {
                 RULE_ID = cam.RULE_ID,
                 RULE_APPLIED_URL = cam.RULE_APPLIED_URL,
                 WEBSITE_URL = cam.WEBSITE_URL,
             }).ToList()
                          .Select(x => new pcms_rules()
             {
                 RULE_ID = x.RULE_ID,
                 RULE_APPLIED_URL = Cryptographys.Decrypt(x.RULE_APPLIED_URL),
                 WEBSITE_URL = Cryptographys.Decrypt(x.WEBSITE_URL)
             }).Where(y => y.RULE_ID == Convert.ToInt16(query)).OrderByDescending(y => y.INSERTED_DATE)).ToList();
             if (rules.Count > 0)
             {
                 return(rules);
             }
             else
             {
                 return(new List <pcms_rules>());
             }
         }
     }
     catch (Exception ex)
     {
         Utilities objUtilities = new Utilities();
         objUtilities.LogError(ex);
         return(null);
     }
 }
示例#27
0
        public ActionResult Register(cvmRegister model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            //自定義檢查
            bool bln_error = false;
            var  user      = db.users.Where(m => m.maccount == model.maccount).FirstOrDefault();

            if (user != null)
            {
                ModelState.AddModelError("", "帳號重複註冊!"); bln_error = true;
            }
            user = db.users.Where(m => m.memail == model.memail).FirstOrDefault();
            if (user != null)
            {
                ModelState.AddModelError("", "電子信箱重複註冊!"); bln_error = true;
            }
            if (bln_error)
            {
                return(View(model));
            }

            //密碼加密
            using (Cryptographys cryp = new Cryptographys())
            {
                model.mpassword       = cryp.SHA256Encode(model.mpassword);
                model.ConfirmPassword = model.mpassword;
            }

            users new_user = new users();

            new_user.maccount    = model.maccount;
            new_user.mname       = model.mname;
            new_user.mpassword   = model.mpassword;
            new_user.memail      = model.memail;
            new_user.birthday    = model.birthday;
            new_user.remark      = model.remark;
            new_user.role_no     = "Member";                       //設定角色代號為 Member
            new_user.varify_code = UserAccount.GetNewVarifyCode(); //產生驗證碼
            new_user.isvarify    = 0;

            //寫入資料庫
            try
            {
                db.Configuration.ValidateOnSaveEnabled = false;
                db.users.Add(new_user);
                db.SaveChanges();
                db.Configuration.ValidateOnSaveEnabled = true;
            }
            catch (Exception ex)
            {
                string str_message = ex.Message;
            }

            //寄出驗證信
            SendVerifyMail(model.memail, new_user.varify_code);
            return(RedirectToAction("SendEmailResult"));
        }
示例#28
0
 public List <pcms_rules> getUrlList(string url)
 {
     try
     {
         using (PCMS_DbContext _pcmsDbContext = new PCMS_DbContext())
         {
             if (!string.IsNullOrEmpty(url))
             {
                 string urls    = Cryptographys.Encrypt(url);
                 var    content = (_pcmsDbContext.pcms_rules
                                   .Select(cam => new
                 {
                     RULE_ID = cam.RULE_ID,
                     RULE_APPLIED_URL = cam.RULE_APPLIED_URL,
                     WEBSITE_URL = cam.WEBSITE_URL
                 }).Where(y => y.WEBSITE_URL == urls).ToList()
                                   .Select(x => new pcms_rules()
                 {
                     RULE_ID = x.RULE_ID,
                     RULE_APPLIED_URL = x.RULE_APPLIED_URL == "" ? "" : Cryptographys.Decrypt(x.RULE_APPLIED_URL),
                     WEBSITE_URL = x.WEBSITE_URL == "" ? "" : Cryptographys.Decrypt(x.WEBSITE_URL)
                 }).OrderByDescending(y => y.INSERTED_DATE)).ToList();
                 if (content.Count > 0)
                 {
                     return(content);
                 }
                 else
                 {
                     return(new List <pcms_rules>());
                 }
             }
             else
             {
                 var content = (_pcmsDbContext.pcms_rules
                                .Select(cam => new
                 {
                     RULE_ID = cam.RULE_ID,
                     RULE_NAME = cam.RULE_NAME,
                     RULE_APPLIED_URL = cam.RULE_APPLIED_URL,
                     WEBSITE_URL = cam.WEBSITE_URL
                 }).ToList()
                                .Select(x => new pcms_rules()
                 {
                     RULE_ID = x.RULE_ID,
                     RULE_APPLIED_URL = Cryptographys.Decrypt(x.RULE_APPLIED_URL),
                     WEBSITE_URL = Cryptographys.Decrypt(x.WEBSITE_URL)
                 }).OrderByDescending(y => y.INSERTED_DATE)).ToList();
                 if (content.Count > 0)
                 {
                     return(content);
                 }
                 else
                 {
                     return(new List <pcms_rules>());
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Utilities objUtilities = new Utilities();
         objUtilities.LogError(ex);
         return(null);
     }
 }
示例#29
0
        // 点击登录
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string userName = uname.Text.Trim();
            string userPwd  = pswd.Text.Trim();
            string pwdMd5   = new Cryptographys().MD5Encrypt(userPwd);

            string ip    = DNRequest.GetIP();
            string agent = HttpContext.Current.Request.UserAgent;
            var    bll   = new AuthBLL();

            TokenDto token  = new TokenDto();
            var      result = bll.Login(userName, userPwd, agent, ip, out token);

            if (result == ERROR_CODE.SUCCESS)
            {
                Common.WriteCookie("Token", "DoneNOW", token.token);
                Application["isFromLogin"] = "******";
                Response.Redirect("index.aspx");
            }
            else
            {
                if (result == ERROR_CODE.PARAMS_ERROR)
                {
                    msgtip.InnerHtml = "请使用邮箱或手机号登录!";
                }
                if (result == ERROR_CODE.PASSWORD_ERROR)
                {
                    msgtip.InnerHtml = "密码错误!";
                }
                if (result == ERROR_CODE.USER_NOT_FIND)
                {
                    msgtip.InnerHtml = "输入用户不存在!";
                }
                if (result == ERROR_CODE.LOCK)
                {
                    msgtip.InnerHtml = "您的账户已被锁定,登录失败";
                }
                msgtip.Visible = true;
            }

            /*
             * var result = bll.Login(userName, userPwd, ip, agent, out user);
             * if (result== DTO.ERROR_CODE.SUCCESS)
             * {
             *  Session["dn_session_user_info"] = user;
             *  Session["dn_session_user_permits"] = bll.GetUserPermit(user.id);
             *  EMT.Tools.Common.WriteCookie("UserName", "DoneNOW", userName);
             *  EMT.Tools.Common.WriteCookie("UserPwd", "DoneNOW", pwdMd5);
             *  Response.Redirect("index.aspx");
             * }
             * else
             * {
             *  if (result == ERROR_CODE.PARAMS_ERROR)
             *      msgtip.InnerHtml = "请使用邮箱或手机号登录!";
             *  if (result == ERROR_CODE.PASSWORD_ERROR)
             *      msgtip.InnerHtml = "密码错误!";
             *  if (result == ERROR_CODE.USER_NOT_FIND)
             *      msgtip.InnerHtml = "输入用户不存在!";
             *  msgtip.Visible = true;
             * }
             */
        }