Beispiel #1
0
        public static void SetItem(ArticleModels item, int cardStyleID = 1)
        {
            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("Article");
            tableObj.GetDataFromObject(item);
            string sql   = "Select 1 From Article Where ID = " + item.ID;
            bool   isNew = db.GetFirstValue(sql) == null;

            if (isNew)
            {
                MenusModels menu   = MenusDAO.GetInfo(item.SiteID, item.MenuID);
                long        cardNo = WorkV3.Golbal.PubFunc.AddPage(item.SiteID, item.MenuID, menu.SN, "Article", "Content", true, item.Title, CardStyleId: cardStyleID);
                tableObj["CardNo"]     = cardNo;
                tableObj["Creator"]    = MemberDAO.SysCurrent.Id;
                tableObj["CreateTime"] = DateTime.Now;
                tableObj["Sort"]       = 1;

                tableObj.Insert();
            }
            else
            {
                tableObj.Remove("ID");
                tableObj.Remove("SiteID");
                tableObj.Remove("MenuID");
                tableObj.Remove("CardNo");
                tableObj.Remove("Clicks");
                tableObj.Remove("Creator");
                tableObj.Remove("CreateTime");

                tableObj["Modifier"]   = MemberDAO.SysCurrent.Id;
                tableObj["ModifyTime"] = DateTime.Now;

                tableObj.Update(item.ID);
            }
        }
Beispiel #2
0
        public static void SetItem(PageCommentsModels item)
        {
            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("PageComments");
            tableObj.GetDataFromObject(item);

            DateTime now   = DateTime.Now;
            string   sql   = "Select 1 From PageComments Where ID = " + item.ID;
            bool     isNew = db.GetFirstValue(sql) == null;

            if (isNew)
            {
                tableObj["ModifyTime"] = now;
                tableObj.Insert();
            }
            else
            {
                tableObj.Remove("ID");
                tableObj.Remove("PageSN");
                tableObj.Remove("ParentID");
                tableObj.Remove("PostDate");
                tableObj.Remove("ShowStatus");
                tableObj.Remove("MemberShipID");

                Common.Member curUser = Common.Member.Current;
                tableObj["Modifier"] = curUser == null ? Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id : curUser.ID;

                tableObj["ModifyTime"] = now;

                tableObj.Update(item.ID);
            }
        }
Beispiel #3
0
        public static void SetCardInfo(CardsModels card)
        {
            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("Cards");
            tableObj.GetDataFromObject(card);

            string sql   = $"Select 1 From Cards Where No = { card.No } AND Lang = '{ card.Lang.Replace("'", "''") }' AND Ver = { card.Ver }";
            bool   isNew = db.GetFirstValue(sql) == null;

            if (isNew)
            {
                tableObj["Creator"]    = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                tableObj["CreateTime"] = DateTime.Now;

                tableObj.Insert();
            }
            else
            {
                string[] removeFields = { "No", "Lang", "Ver", "Creator", "CreateTime" };
                foreach (string field in removeFields)
                {
                    tableObj.Remove(field);
                }

                tableObj["Modifier"]   = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                tableObj["ModifyTime"] = DateTime.Now;

                SQLData.ParameterCollection keys = new SQLData.ParameterCollection();
                keys.Add("@No", card.No);
                keys.Add("@Lang", card.Lang);
                keys.Add("@Ver", card.Ver);

                tableObj.Update(keys);
            }
        }
Beispiel #4
0
        public static void SetMemberShipRegManagers(MemberShipRegEmailManagersModels item)
        {
            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("MemberShipRegEmailManagers");
            tableObj.GetDataFromObject(item);
            string sql   = $"Select 1 From MemberShipRegEmailManagers Where SiteID={item.SiteID} AND ManagerID='{item.ManagerID}'";
            bool   isNew = db.GetFirstValue(sql) == null;

            if (isNew)
            {
                if (string.IsNullOrEmpty(item.ManagerID))
                {
                    tableObj["ManagerID"] = "";
                }
                tableObj["Creator"]    = MemberDAO.SysCurrent.Id;
                tableObj["CreateTime"] = DateTime.Now;
                tableObj.Insert();
            }
            else
            {
                tableObj.Remove("ID");
                tableObj.Remove("SiteID");
                tableObj.Remove("Creator");
                tableObj.Remove("CreateTime");

                tableObj["Modifier"]   = MemberDAO.SysCurrent.Id;
                tableObj["ModifyTime"] = DateTime.Now;

                tableObj.Update(item.ID);
            }
        }
Beispiel #5
0
        public static bool SetItem(SocialSettingModels item)
        {
            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("SocialSetting");
            tableObj.GetDataFromObject(item);
            DateTime now = DateTime.Now;
            string   sql = $"SELECT * FROM SocialSetting WHERE  SiteID='{ item.SiteID }' ";

            bool isNew = db.GetFirstValue(sql) == null;

            if (isNew)
            {
                tableObj["Creator"]    = Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                tableObj["CreateTime"] = now;
                tableObj["Modifier"]   = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                tableObj["ModifyTime"] = now;
                tableObj.Insert();
            }
            else
            {
                tableObj.Remove("SiteID");
                tableObj.Remove("Creator");
                tableObj.Remove("CreateTime");
                tableObj["Modifier"]   = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                tableObj["ModifyTime"] = now;
                tableObj.Update(item.SiteID);
            }
            return(true);
        }
        public static void SetItem(AdsStatisticsLabelsModel item)
        {
            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("AdsStatisticsLabels");
            tableObj.GetDataFromObject(item);
            bool   isNew = false;
            string sql   = "Select 1 From AdsStatisticsLabels Where ID = " + item.ID;

            isNew = db.GetFirstValue(sql) == null;
            if (isNew)
            {
                tableObj["Title"]      = item.Title;
                tableObj["LabelDate"]  = item.LabelDate;
                tableObj["LabelColor"] = item.LabelColor;
                tableObj["ShowStatus"] = item.ShowStatus;
                tableObj["Creator"]    = item.Creator;
                tableObj["CreateTime"] = item.CreateTime;
                tableObj.Insert();
            }
            else
            {
                tableObj.Remove("Creator");
                tableObj.Remove("CreateTime");
                tableObj["Title"]      = item.Title;
                tableObj["LabelDate"]  = item.LabelDate;
                tableObj["ShowStatus"] = item.ShowStatus;
                tableObj["LabelColor"] = item.LabelColor;
                tableObj["Modifier"]   = item.Modifier;
                tableObj["ModifyTime"] = item.ModifyTime;
                tableObj.Update(item.ID);
            }
        }
Beispiel #7
0
        public static void SetItem(ArticlePosterModels item)
        {
            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("ArticlePoster");
            tableObj.GetDataFromObject(item);

            string sql   = "Select 1 From ArticlePoster Where ID = " + item.ID;
            bool   isNew = db.GetFirstValue(sql) == null;

            if (isNew)
            {
                tableObj["Creator"]    = MemberDAO.SysCurrent.Id;
                tableObj["CreateTime"] = DateTime.Now;

                tableObj.Insert();
            }
            else
            {
                tableObj.Remove("ID");
                tableObj.Remove("MenuID");
                tableObj.Remove("Creator");
                tableObj.Remove("CreateTime");

                tableObj["Modifier"]   = MemberDAO.SysCurrent.Id;
                tableObj["ModifyTime"] = DateTime.Now;

                tableObj.Update(item.ID);
            }
        }
Beispiel #8
0
        public static void SetItem(IntraIPlimitModel item)
        {
            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("IntraIPlimit");
            tableObj.GetDataFromObject(item);
            string sql   = "Select 1 From IntraIPlimit Where ID = " + item.ID;
            bool   isNew = db.GetFirstValue(sql) == null;

            if (isNew)
            {
                tableObj["OpenStatus"] = item.OpenStatus == OpenStatus.Open ? 1 : 0;
                tableObj["Creator"]    = MemberDAO.SysCurrent.Id;
                tableObj["CreateTime"] = DateTime.Now;

                tableObj.Insert();
            }
            else
            {
                tableObj.Remove("ID");
                tableObj.Remove("Creator");
                tableObj.Remove("CreateTime");

                tableObj["Modifier"]   = MemberDAO.SysCurrent.Id;
                tableObj["ModifyTime"] = DateTime.Now;

                tableObj.Update(item.ID);
            }
        }
Beispiel #9
0
        public static void SetItem(ResourceImagesModels item)
        {
            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("ResourceImages");
            tableObj.GetDataFromObject(item);

            string sql   = "Select 1 From ResourceImages Where ID = " + item.ID;
            bool   isNew = db.GetFirstValue(sql) == null;

            if (isNew)
            {
                tableObj.Insert();
            }
            else
            {
                string[] removeFields = { "ID", "SiteID", "SourceNo", "SourceType", "Ver", "AreaID", "Creator", "CreateTime" };
                foreach (string f in removeFields)
                {
                    tableObj.Remove(f);
                }

                SQLData.ParameterCollection keys = new SQLData.ParameterCollection();
                keys.Add("@ID", item.ID);
                keys.Add("@SiteID", item.SiteID);
                keys.Add("@SourceNo", item.SourceNo);
                keys.Add("@SourceType", item.SourceType);
                keys.Add("@Ver", item.Ver);
                keys.Add("@AreaID", item.AreaID);

                tableObj.Update(keys);
            }
        }
Beispiel #10
0
        public static void SetItem(ParagraphModels item)
        {
            item.Title     = item.Title ?? string.Empty;
            item.MatchType = item.MatchType ?? string.Empty;
            item.Contents  = item.Contents ?? string.Empty;

            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("Paragraph");
            tableObj.GetDataFromObject(item);

            string sql   = "Select 1 From Paragraph Where ID = " + item.ID;
            bool   isNew = db.GetFirstValue(sql) == null;

            if (isNew)
            {
                tableObj.Insert();
            }
            else
            {
                tableObj.Remove("ID");
                tableObj.Remove("SourceNo");

                tableObj.Update(item.ID);
            }
        }
Beispiel #11
0
        public static void SetItem(SiteLangMenuModel item)
        {
            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("SiteLangMenu");
            tableObj.GetDataFromObject(item);
            string sql   = "Select 1 From SiteLangMenu Where ID = " + item.ID;
            bool   isNew = db.GetFirstValue(sql) == null;

            if (isNew)
            {
                tableObj["Creator"]    = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                tableObj["CreateTime"] = DateTime.Now;
                tableObj["Sort"]       = 1;
                tableObj.Insert();
            }
            else
            {
                tableObj.Remove("ID");
                tableObj.Remove("SiteID");
                tableObj.Remove("Creator");
                tableObj.Remove("CreateTime");

                tableObj["Modifier"]   = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                tableObj["ModifyTime"] = DateTime.Now;

                tableObj.Update(item.ID);
            }
        }
Beispiel #12
0
        public static void SetItem(FieldValue item)
        {
            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("FieldValue");
            tableObj.GetDataFromObject(item);

            string sql   = $"Select 1 From FieldValue Where FormItemID = { item.FormItemID } AND FieldID = { item.FieldID }";
            bool   isNew = db.GetFirstValue(sql) == null;

            if (isNew)
            {
                tableObj.Insert();
            }
            else
            {
                tableObj.Remove("FormItemID");
                tableObj.Remove("FieldID");

                SQLData.ParameterCollection paras = new SQLData.ParameterCollection();
                paras.Add("@FormItemID", item.FormItemID);
                paras.Add("@FieldID", item.FieldID);

                tableObj.Update(paras);
            }
        }
Beispiel #13
0
        public bool EditKeyword(KeywordSaveViewModel item)
        {
            KeywordQueriedModels queriedObj = GetKeywordQueriedItemByText(item.Text);

            if (queriedObj == null)
            {
                AddSingleKeywordQueried(item.Text, 0);
                queriedObj = GetKeywordQueriedItemByText(item.Text);
            }

            KeywordModels keywordExist = GetKeywordItemByText(item.Text);

            if (keywordExist != null && keywordExist.ID != item.ID)
            {
                return(false);
            }

            KeywordModels keywordObj = GetKeywordItem(item.ID ?? 0);

            SQLData.TableObject tableObj = GetTableObj("Keywords");
            tableObj.GetDataFromObject(keywordObj);

            tableObj["KeywordQueriedID"] = queriedObj.ID;
            tableObj["Modifier"]         = Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
            tableObj["ModifyTime"]       = DateTime.Now;

            tableObj.Update(keywordObj.ID);
            return(true);
        }
Beispiel #14
0
        public static void SetItem(SEOModels item)
        {
            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("SEO");
            tableObj.GetDataFromObject(item);

            string sql   = "Select 1 From SEO Where SourceNo = " + item.SourceNo;
            bool   isNew = db.GetFirstValue(sql) == null;

            if (isNew)
            {
                tableObj.Add("Creator", WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id);
                tableObj.Add("CreateTime", DateTime.Now);

                tableObj.Insert();
            }
            else
            {
                tableObj.Remove("SourceNo");
                tableObj.Remove("MenuID");

                tableObj.Add("Modifier", WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id);
                tableObj.Add("ModifyTime", DateTime.Now);

                tableObj.Update(item.SourceNo);
            }
        }
        public static bool SetMailTemplateItems(MailTemplateSetModels item)
        {
            SQLData.Database db = new SQLData.Database(WebInfo.Conn);
            item.AttFiles = item.AttFiles == null ? "" : item.AttFiles;
            SQLData.TableObject tableObj = db.GetTableObject("MailTemplateSet");
            tableObj.GetDataFromObject(item);
            DateTime now   = DateTime.Now;
            string   sql   = $"SELECT * FROM MailTemplateSet WHERE  TemplateName='{ item.TemplateName.Replace("'", "")}' ";
            bool     isNew = db.GetFirstValue(sql) == null;

            if (isNew)
            {
                tableObj["Creator"]    = Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                tableObj["CreateTime"] = now;
                tableObj["Modifier"]   = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                tableObj["ModifyTime"] = now;
                tableObj.Insert();
            }
            else
            {
                tableObj.Remove("TemplateName");
                tableObj.Remove("Creator");
                tableObj.Remove("CreateTime");
                tableObj["Modifier"]   = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                tableObj["ModifyTime"] = now;
                tableObj.Update(item.TemplateName);
            }
            return(true);
        }
Beispiel #16
0
        public static void SetItem(ArticleIntroModels item)
        {
            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("ArticleIntro");

            item.Icon       = item.Icon ?? string.Empty;
            item.RemarkText = item.RemarkText ?? string.Empty;

            tableObj.GetDataFromObject(item);
            string sql   = "Select 1 From ArticleIntro Where ID = " + item.ID;
            bool   isNew = db.GetFirstValue(sql) == null;

            if (isNew)
            {
                long cardNo = WorkV3.Models.DataAccess.MenusDAO.GetFirstCardNo(item.MenuID, "ArticleIntro") ?? 0;
                tableObj.Add("CardNo", cardNo);

                tableObj.Insert();
            }
            else
            {
                tableObj.Remove("ID");
                tableObj.Remove("MenuID");
                tableObj.Remove("Creator");
                tableObj.Remove("CreateTime");

                tableObj.Update(item.ID);
            }
        }
Beispiel #17
0
        public static void SetItem(FormItem item, bool hasCreateDate = false)
        {
            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("FormItem");
            tableObj.GetDataFromObject(item);

            DateTime now = DateTime.Now;

            tableObj.Add("ModifyDate", now);

            string sql = "Select ID, CheckStatus From FormItem Where ID = " + item.ID;

            SQLData.SelectObject selectObj = db.GetSelectObject(sql);
            bool isNew = selectObj.Count == 0;

            if (isNew)
            {
                if (!hasCreateDate)
                {
                    tableObj["CreateDate"] = now;
                }

                if (item.CheckStatus != (byte)FormCheckStatus.待審核)
                {
                    tableObj["CheckDate"] = DateTime.Now;
                }

                tableObj.Insert();
            }
            else
            {
                tableObj.Remove("ID");
                tableObj.Remove("FormID");
                tableObj.Remove("CreateDate");
                tableObj.Remove("SN");
                tableObj.Remove("IsTemp");
                tableObj.Remove("IsBack");
                tableObj.Remove("CheckDate");
                tableObj.Remove("CheckInDate");

                if (item.CheckStatus != (byte)FormCheckStatus.待審核 && (byte)selectObj["CheckStatus"] != item.CheckStatus)
                {
                    tableObj.Add("CheckDate", DateTime.Now);
                }

                tableObj.Update(item.ID);
            }
        }
Beispiel #18
0
        public static void UpdatePageInfo(PagesModels page)
        {
            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("Pages");
            tableObj.GetDataFromObject(page);

            tableObj.Remove("No");

            tableObj["Modifier"]   = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
            tableObj["ModifyTime"] = DateTime.Now;

            SQLData.ParameterCollection keys = new SQLData.ParameterCollection();
            keys.Add("@No", page.No);

            tableObj.Update(keys);
        }
Beispiel #19
0
        /// <summary>
        /// 使用者動作儲存
        /// </summary>
        /// <param name="AdsCustomizeID"></param>
        /// <param name="PageID"></param>
        /// <param name="Event"></param>
        /// <param name="MemberID"></param>
        public static void SetUserEventLog(long AdsCustomizeID, long PageID, string Event, long?MemberID)
        {
            if (AdsCustomizeID == 0 || PageID == 0 || string.IsNullOrWhiteSpace(Event))
            {
                return;
            }

            if (Event != UserEvent.Browsing && Event != UserEvent.Click)
            {
                return;
            }

            AdsStatisticsModel item = new AdsStatisticsModel()
            {
                AdsCustomizeID = AdsCustomizeID,
                PageID         = PageID,
                SessionID      = System.Web.HttpContext.Current.Session.SessionID,
                DeviceID       = WorkV3.Areas.Backend.Models.DataAccess.AdvertisementDAO.GetCpuID(),
                Browser        = System.Web.HttpContext.Current.Request.Browser.Browser,
                Event          = Event,
                IP             = WorkLib.GetItem.IPAddr(),
                IPNum          = (long)WorkLib.GetItem.GetIPNum(),
                MemberID       = MemberID ?? 0,
                RecordDay      = DateTime.Now,
                RecordTime     = DateTime.Now
            };

            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("AdsStatistics");
            tableObj.GetDataFromObject(item);

            string check = "Select 1 From AdsStatistics " +
                           $"Where AdsCustomizeID={item.AdsCustomizeID} and " +
                           $"PageID={item.PageID} and " +
                           $"SessionID='{item.SessionID}' and " +
                           $"Event='{item.Event}' and " +
                           $"RecordDay='{item.RecordDay.ToString("yyyy/MM/dd")}'";

            bool isNew = db.GetFirstValue(check) == null;

            if (isNew)
            {
                tableObj.Insert();
            }
        }
Beispiel #20
0
        public static bool SetRelationItem(SocialRelationModels item)
        {
            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("SocialRelations");
            tableObj.GetDataFromObject(item);
            DateTime now          = DateTime.Now;
            string   sql          = $"SELECT * FROM SocialRelations WHERE  ID={ item.ID } ";
            string   sql_sort     = $"SELECT Max(Sort)  FROM SocialRelations WHERE  RelationType='{(int)item.RelationType}' AND SiteID={item.SiteID} ";
            bool     isNew        = db.GetFirstValue(sql) == null;
            string   sortIndex    = db.GetFirstValue(sql_sort).ToString();
            int      newSortIndex = 1;

            if (!string.IsNullOrEmpty(sortIndex))
            {
                newSortIndex = int.Parse(sortIndex) + 1;
            }
            if (isNew)
            {
                tableObj["ID"]          = item.ID;
                tableObj["SocialTitle"] = GetSocialTypeTitle(item.SocialType);
                tableObj["Sort"]        = newSortIndex;
                tableObj["LinkTitle"]   = item.LinkTitle == null ? "" : item.LinkTitle;
                tableObj["LinkUrl"]     = item.LinkUrl == null?"":item.LinkUrl;
                tableObj["Creator"]     = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                tableObj["CreateTime"]  = now;
                tableObj["Modifier"]    = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                tableObj["ModifyTime"]  = now;
                tableObj.Insert();
            }
            else
            {
                tableObj.Remove("ID");
                tableObj.Remove("Creator");
                tableObj.Remove("CreateTime");
                tableObj.Remove("Sort");
                tableObj["SocialTitle"] = item.SocialTitle == null ? "" : item.SocialTitle;
                tableObj["LinkTitle"]   = item.LinkTitle == null ? "" : item.LinkTitle;
                tableObj["LinkUrl"]     = item.LinkUrl == null ? "" : item.LinkUrl;
                tableObj["Modifier"]    = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                tableObj["ModifyTime"]  = now;
                tableObj.Update(item.ID);
            }
            return(true);
        }
Beispiel #21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="item"></param>
        /// <param name="IsManually">是否手動新增</param>
        public static void SetItem(PointsModel item, bool IsManually = false)
        {
            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("Points");

            tableObj.GetDataFromObject(item);

            DateTime now   = DateTime.Now;
            string   sql   = "Select 1 From Points Where ID = " + item.ID;
            bool     isNew = db.GetFirstValue(sql) == null;

            tableObj["SiteID"]       = item.SiteID;
            tableObj["MemberShipID"] = item.MemberShipID;
            tableObj["Remark"]       = string.IsNullOrEmpty(item.Remark) ? "" : item.Remark;
            tableObj["Description"]  = string.IsNullOrEmpty(item.Description) ? "" : item.Description;
            tableObj["Point"]        = item.Point;
            tableObj["IsManually"]   = IsManually;
            tableObj["PointType"]    = item.PointType;

            if (isNew)
            {
                if (item.Creator == 0)
                {
                    tableObj["Creator"] = Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                }
                tableObj["CreateTime"] = now;

                tableObj.Insert();
            }
            else
            {
                tableObj.Remove("ID");
                tableObj.Remove("SiteID");
                tableObj.Remove("Creator");
                tableObj.Remove("CreateTime");

                Common.Member curUser = Common.Member.Current;
                tableObj["Modifier"]   = curUser == null ? Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id : curUser.ID;
                tableObj["ModifyTime"] = now;

                tableObj.Update(item.ID);
            }
        }
Beispiel #22
0
        public static void SetItem(ResourceVideosModels item)
        {
            item.Spec       = item.Spec ?? string.Empty;
            item.Duration   = item.Duration ?? string.Empty;
            item.Screenshot = item.Screenshot ?? string.Empty;

            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("ResourceVideos");
            tableObj.GetDataFromObject(item);

            string sql   = "Select 1 From ResourceVideos Where ID = " + item.ID;
            bool   isNew = db.GetFirstValue(sql) == null;

            if (isNew)
            {
                tableObj["Creator"]    = MemberDAO.SysCurrent.Id;
                tableObj["CreateTime"] = DateTime.Now;

                tableObj.Insert();
            }
            else
            {
                string[] removeFields = { "ID", "SiteID", "SourceNo", "SourceType", "Ver", "AreaID", "Code", "Creator", "CreateTime" };
                foreach (string f in removeFields)
                {
                    tableObj.Remove(f);
                }

                tableObj["Modifier"]   = MemberDAO.SysCurrent.Id;
                tableObj["ModifyTime"] = DateTime.Now;

                SQLData.ParameterCollection keys = new SQLData.ParameterCollection();
                keys.Add("@ID", item.ID);
                keys.Add("@SiteID", item.SiteID);
                keys.Add("@SourceNo", item.SourceNo);
                keys.Add("@SourceType", item.SourceType);
                keys.Add("@Ver", item.Ver);
                keys.Add("@AreaID", item.AreaID);

                tableObj.Update(keys);
            }
        }
Beispiel #23
0
        public static void SetItem(MemberShipMailModel item)
        {
            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("MemberShipSendMail");
            tableObj.GetDataFromObject(item);
            string sql   = "Select 1 From MemberShipSendMail Where ID = " + item.ID;
            bool   isNew = db.GetFirstValue(sql) == null;

            if (isNew)
            {
                tableObj.Insert();
            }
            else
            {
                tableObj.Remove("ID");
                tableObj.Remove("SendDate");

                tableObj.Update(item.ID);
            }
        }
Beispiel #24
0
        public static void SetItem(FormModel item)
        {
            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("Form");
            tableObj.GetDataFromObject(item);
            string sql   = "Select 1 From Form Where ID = " + item.ID;
            bool   isNew = db.GetFirstValue(sql) == null;

            if (isNew)
            {
                tableObj.Insert();
            }
            else
            {
                tableObj.Remove("ID");
                tableObj.Remove("SiteID");
                tableObj.Remove("SourceID");
                tableObj.Remove("IsRemove");

                tableObj.Update(item.ID);
            }
        }
Beispiel #25
0
        public static void SetZoneInfo(ZonesModels zone)
        {
            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("Zones");
            tableObj.GetDataFromObject(zone);

            string sql   = $"Select 1 From Zones Where No = { zone.No } AND Ver = { zone.Ver } AND SiteID = { zone.SiteID } AND PageNo = { zone.PageNo }";
            bool   isNew = db.GetFirstValue(sql) == null;

            if (isNew)
            {
                tableObj["Creator"]    = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                tableObj["CreateTime"] = DateTime.Now;

                tableObj.Insert();
            }
            else
            {
                string[] removeFields = { "No", "Ver", "SiteID", "PageNo", "Creator", "CreateTime" };
                foreach (string field in removeFields)
                {
                    tableObj.Remove(field);
                }

                tableObj["Modifier"]   = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                tableObj["ModifyTime"] = DateTime.Now;

                SQLData.ParameterCollection keys = new SQLData.ParameterCollection();
                keys.Add("@No", zone.No);
                keys.Add("@Ver", zone.Ver);
                keys.Add("@SiteID", zone.SiteID);
                keys.Add("@PageNo", zone.PageNo);

                tableObj.Update(keys);
            }
        }
Beispiel #26
0
        public static void SetItem(FieldModel item)
        {
            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("Field");
            tableObj.GetDataFromObject(item);
            string sql   = "Select 1 From Field Where ID = " + item.ID;
            bool   isNew = db.GetFirstValue(sql) == null;

            if (isNew)
            {
                sql            = "Select IsNull(Max(SN), 0) From Field Where ParentID = " + item.ParentID;
                tableObj["SN"] = (int)db.GetFirstValue(sql) + 1;

                tableObj.Insert();
            }
            else
            {
                tableObj.Remove("ID");
                tableObj.Remove("ParentID");
                tableObj.Remove("SN");

                tableObj.Update(item.ID);
            }
        }
Beispiel #27
0
        /// <summary>
        /// 新增一組使用者搜尋字串
        /// </summary>
        /// <param name="strSearch">搜尋字串</param>
        /// <returns>新增後的 ID ,若已存在也回傳 ID </returns>
        public long AddSingleKeywordQueried(string strSearch, int count = 1)
        {
            KeywordQueriedModels keywordQueriedObj = GetKeywordQueriedItemByText(strSearch);

            SQLData.TableObject keywordQueriedTableObj = GetTableObj("KeywordQueried");

            if (keywordQueriedObj == null)
            {
                keywordQueriedTableObj["Text"]  = strSearch;
                keywordQueriedTableObj["Count"] = count;
                keywordQueriedTableObj.Insert();

                keywordQueriedObj = GetKeywordQueriedItemByText(strSearch);
                return(keywordQueriedObj.ID);
            }
            else
            {
                keywordQueriedTableObj.GetDataFromObject(keywordQueriedObj);
                keywordQueriedTableObj["Count"] = keywordQueriedObj.Count + 1;
                keywordQueriedTableObj.Update(keywordQueriedObj.ID);

                return(keywordQueriedObj.ID);
            }
        }
        public static MailTemplateSetModels GetMailTemplateItems(string TemplateName)
        {
            string sel_sql = $"SELECT * FROM MailTemplateSet WHERE  TemplateName='{ TemplateName.Replace("'", "")}' ";

            using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(WebInfo.Conn))
            {
                var qResult = conn.Query <MailTemplateSetModels>(sel_sql);
                if (qResult != null && qResult.Count() > 0)
                {
                    MailTemplateSetModels model = qResult.First();
                    model.AttShowFiles = "";
                    if (!string.IsNullOrEmpty(model.AttFiles))
                    {
                        List <ViewModels.MemberShipSetFile>      fileShowList = new List <ViewModels.MemberShipSetFile>();
                        List <WorkV3.Models.ResourceFilesModels> fileList     = Newtonsoft.Json.JsonConvert.DeserializeObject <List <WorkV3.Models.ResourceFilesModels> >(model.AttFiles);
                        foreach (WorkV3.Models.ResourceFilesModels fileModel in fileList)
                        {
                            ViewModels.MemberShipSetFile showFile = new ViewModels.MemberShipSetFile()
                            {
                                FileInfo     = fileModel.FileInfo,
                                FileSize     = fileModel.FileSize.HasValue ? fileModel.FileSize.Value : 0,
                                FileSizeDesc = "0",
                                ShowName     = fileModel.ShowName
                            };
                            showFile.FileSizeDesc = WorkLib.uFiles.SizeToText((long)showFile.FileSize);
                            fileShowList.Add(showFile);
                        }
                        model.AttShowFiles = Newtonsoft.Json.JsonConvert.SerializeObject(fileShowList);
                    }
                    return(model);
                }
                else
                {
                    MailTemplateSetModels item = new MailTemplateSetModels();
                    item.TemplateName = TemplateName;
                    System.Xml.XmlDocument xmldoc = new System.Xml.XmlDocument();
                    xmldoc.Load(HttpContext.Current.Server.MapPath("~/App_Data/mailContent/MailTemplates.xml"));
                    System.Xml.XmlNode templateNode = xmldoc.SelectSingleNode(string.Format("/Mails/Template[@ID='{0}']", TemplateName));

                    item.MailTitle       = templateNode.SelectSingleNode("Subject").InnerXml;
                    item.MailContent     = templateNode.SelectSingleNode("Content").InnerXml;
                    item.MailFromName    = (string)WorkLib.GetItem.appSet("MailSender");
                    item.MailFromAddress = (string)WorkLib.GetItem.appSet("MailFrom");
                    item.AttFiles        = "";
                    SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
                    SQLData.TableObject tableObj = db.GetTableObject("MailTemplateSet");
                    tableObj.GetDataFromObject(item);
                    if (Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent != null)
                    {
                        tableObj["Creator"] = Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                    }
                    else
                    {
                        tableObj["Creator"] = 0;
                    }
                    tableObj["CreateTime"] = DateTime.Now;
                    if (Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent != null)
                    {
                        tableObj["Modifier"] = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                    }
                    else
                    {
                        tableObj["Modifier"] = 0;
                    }
                    tableObj["ModifyTime"] = DateTime.Now;
                    tableObj.Insert();
                    return(item);
                }
            }
            //return new MailTemplateSetModels();
        }
Beispiel #29
0
        public static bool SetItem(SiteSeoSettingModels item)
        {
            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("SiteSeoSetting");
            tableObj.GetDataFromObject(item);
            DateTime now = DateTime.Now;
            string   sql = $"SELECT * FROM SiteSeoSetting WHERE  SiteID='{ item.SiteID }' ";

            bool isNew = db.GetFirstValue(sql) == null;

            if (isNew)
            {
                tableObj["Creator"]    = Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                tableObj["CreateTime"] = now;
                tableObj["Modifier"]   = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                tableObj["ModifyTime"] = now;
                tableObj.Insert();
            }
            else
            {
                tableObj.Remove("SiteID");
                tableObj.Remove("Creator");
                tableObj.Remove("CreateTime");
                if (string.IsNullOrEmpty(item.Title))
                {
                    tableObj["Title"] = "";
                }
                if (string.IsNullOrEmpty(item.Description))
                {
                    tableObj["Description"] = "";
                }
                if (string.IsNullOrEmpty(item.Author))
                {
                    tableObj["Author"] = "";
                }
                if (string.IsNullOrEmpty(item.Copyright))
                {
                    tableObj["Copyright"] = "";
                }
                if (string.IsNullOrEmpty(item.Keywords))
                {
                    tableObj["Keywords"] = "";
                }
                if (string.IsNullOrEmpty(item.GA))
                {
                    tableObj["GA"] = "";
                }
                if (string.IsNullOrEmpty(item.GTM))
                {
                    tableObj["GTM"] = "";
                }
                if (string.IsNullOrEmpty(item.Baidu))
                {
                    tableObj["Baidu"] = "";
                }
                if (string.IsNullOrEmpty(item.Alexa))
                {
                    tableObj["Alexa"] = "";
                }
                if (string.IsNullOrEmpty(item.GoogleSearch))
                {
                    tableObj["GoogleSearch"] = "";
                }
                if (string.IsNullOrEmpty(item.BaiduMA))
                {
                    tableObj["BaiduMA"] = "";
                }
                if (string.IsNullOrEmpty(item.Bing))
                {
                    tableObj["Bing"] = "";
                }
                if (string.IsNullOrEmpty(item.ExtraCode))
                {
                    tableObj["ExtraCode"] = "";
                }

                tableObj["Modifier"]   = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                tableObj["ModifyTime"] = now;
                tableObj.Update(item.SiteID);
            }
            return(true);
        }