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); } }
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); } }
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); } }
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 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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
public static long GetListCardNo(long menuId) { string sql = $"SELECT No FROM Cards WHERE CardsType = 'Event' AND (ViewAction IS NULL OR ViewAction = 'List') AND ZoneNo IN (SELECT No FROM Zones WHERE PageNo IN (SELECT No FROM Pages WHERE MenuID = { menuId }))"; SQLData.Database db = new SQLData.Database(WebInfo.Conn); return((long)db.GetFirstValue(sql)); }
public static void SetItem(CategoryModels item) { long creator = MemberDAO.SysCurrent.Id; SQLData.Database db = new SQLData.Database(WebInfo.Conn); string sql = "Select 1 From [Categories] Where ID = " + item.ID; item.Icon = item.Icon == null ? "" : item.Icon; bool isNew = db.GetFirstValue(sql) == null; if (isNew) { using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(WebInfo.Conn)) { sql = $"IF not EXISTS (SELECT 1 FROM Categories WHERE ID = @ID)"; sql += $" INSERT INTO [Categories]([ID],[Type],[Title],[RemarkText],[ShowStatus],[Icon],[Sort],[Creator],[CreateTime] ,[Modifier],[ModifyTime],[Image],[MemberSession],[PresetIdentity]) VALUES({ WorkLib.GetItem.NewSN() },@Type,@Title,@RemarkText, @ShowStatus, @Icon, @Sort ,{creator}, getdate(),{creator}, getdate(),@Image,@MemberSession,@PresetIdentity) "; conn.Execute(sql, item); } } else { using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(WebInfo.Conn)) { sql = $"UPDATE Categories SET [Title]=@Title,[RemarkText]=@RemarkText, [ShowStatus]=@ShowStatus,[Icon]=@Icon,[Sort]=@Sort,[Modifier]={creator},ModifyTime=getdate(),[Image]=@Image,[MemberSession]=@MemberSession"; sql += " WHERE ID=@ID "; conn.Execute(sql, item); } } }
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); }
public static long GetMenuID(long cardNo) { string sql = $"SELECT MenuID FROM Pages WHERE [No] = (SELECT PageNo FROM Zones WHERE [No] = (SELECT ZoneNo FROM Cards WHERE [No] = { cardNo }))"; SQLData.Database db = new SQLData.Database(WebInfo.Conn); return((long)db.GetFirstValue(sql)); }
public static void SetItem(MemberModels item) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); string sql = "Select 1 From [Member] Where ID = " + item.Id; bool isNew = db.GetFirstValue(sql) == null; if (isNew) { using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(WebInfo.Conn)) { sql = $"IF not EXISTS (SELECT 1 FROM Member WHERE LoginID = @LoginID)"; sql += $@" INSERT INTO [Member]([ID],[LoginID],[Name],[Email],[MStatus],[Password],[GroupID] ,isSysOnly, [AddDate], [Phone], [Mobile], [Img], ArriveDate, PersonalNote, Salary, SalaryPaymentType, LaborAllowance, LaborPension, JobAdditionPay, ExecutionFee, LaborInsurance, HealthInsurance, Welfare, LeaveFee) VALUES({ WorkLib.GetItem.NewSN()},@LoginID,@Name, @Email, @MStatus,@Password ,@GroupID, 1, getdate(), @Phone, @Mobile, @Img, @ArriveDate, @PersonalNote, @Salary, @SalaryPaymentType, @LaborAllowance, @LaborPension, @JobAdditionPay, @ExecutionFee, @LaborInsurance, @HealthInsurance, @Welfare, @LeaveFee) "; conn.Execute(sql, item); } } else { using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(WebInfo.Conn)) { sql = @"UPDATE Member SET [Name]=@Name, [Email]=@Email,[MStatus]=@MStatus,[GroupID]=@GroupID, [Phone]=@Phone, [Mobile]=@Mobile, [Img]=@Img, [ArriveDate]=@ArriveDate, [PersonalNote]=@PersonalNote, [Salary]=@Salary, [SalaryPaymentType]=@SalaryPaymentType, [LaborAllowance]=@LaborAllowance, [LaborPension]=@LaborPension, [JobAdditionPay]=@JobAdditionPay, [ExecutionFee]=@ExecutionFee, [LaborInsurance]=@LaborInsurance, [HealthInsurance]=@HealthInsurance, [Welfare]=@Welfare, [LeaveFee]=@LeaveFee"; if (!string.IsNullOrEmpty(item.Password)) { sql += ",[Password]=@Password"; } sql += " WHERE ID=@ID "; conn.Execute(sql, item); } } }
public static void SetItem(GroupModels item) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); string sql = "Select 1 From [Group] Where ID = " + item.Id; bool isNew = db.GetFirstValue(sql) == null; if (isNew) { item.SetPermissionsForAllSites(2); using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(WebInfo.Conn)) { sql = $"INSERT INTO [Group]([ID], [Name], [Desc], [Status], [Color], [Icon]) VALUES({ WorkLib.GetItem.NewSN()},@Name, @Desc, @Status, @Color, @Icon) "; conn.Execute(sql, item); } } else { item.SetPermissionForSingleSite(PageCache.SiteID, item.GroupType); using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(WebInfo.Conn)) { sql = @"UPDATE [Group] SET [Name]=@Name,[Desc]=@Desc,[Status]=@Status, [Color]=@Color, [Icon]=@Icon WHERE ID=@ID "; conn.Execute(sql, item); } } }
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); } }
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(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); } }
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); } }
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); }
public static int GetItemCount(long formId, long fieldId, string value, long?formItemId) { string sql = $"Select Count(*) From FieldValue Where FieldID = { fieldId } AND Value = N'{ (value ?? string.Empty).Replace("'", "''") }' " + $"AND FormItemID IN (Select ID From FormItem Where FormID = { formId })"; if (formItemId != null) { sql += " AND FormItemID <> " + formItemId; } SQLData.Database db = new SQLData.Database(WebInfo.Conn); return((int)db.GetFirstValue(sql)); }
public static WorkV3.Common.SitePage GetSearchPage(long siteId) { string sql = $"SELECT No FROM Cards WHERE CardsType = 'SearchResults' AND Status = 1 AND ZoneNo IN (SELECT No FROM Zones WHERE SiteID = { siteId })"; SQLData.Database db = new SQLData.Database(WebInfo.Conn); long? cardNo = db.GetFirstValue(sql) as long?; if (cardNo == null) { return(null); } return(CardsDAO.GetPage((long)cardNo)); }
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); } }
public static int[] GetRegionHierarchy(int id) { List <int> hierarchy = new List <int>(); SQLData.Database db = new SQLData.Database(WebInfo.Conn); int?parentId = id; while (parentId != null) { hierarchy.Insert(0, (int)parentId); parentId = db.GetFirstValue("Select ParentID From WorldRegion Where ID = " + (int)parentId) as int?; } return(hierarchy.ToArray()); }
// 新增自定關鍵字 public bool AddKeyword(KeywordSaveViewModel item) { SQLData.TableObject keywordTableObj = GetTableObj("Keywords"); SQLData.TableObject queriedTableObj = GetTableObj("KeywordQueried"); KeywordQueriedModels keywordQueriedObj = GetKeywordQueriedItemByText(item.Text); bool isNew = keywordQueriedObj == null; // 如果 KeywordQueried 沒有的話,Keywords、KeywordQueried 各 insert 一筆 if (isNew) { queriedTableObj["Text"] = item.Text; queriedTableObj["Count"] = 0; queriedTableObj.Insert(); KeywordQueriedModels keyword = GetKeywordQueriedItemByText(item.Text); long keywordId = keyword.ID; int keywordCount = (int)db.GetFirstValue(" SELECT count(*) FROM Keywords "); int maxKeywordSort = keywordCount == 0? 1: (int)db.GetFirstValue("SELECT Sort FROM Keywords ORDER BY Sort Desc"); keywordTableObj["KeywordQueriedID"] = keywordId; keywordTableObj["Creator"] = Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id; keywordTableObj["CreateTime"] = DateTime.Now; keywordTableObj["IsIssue"] = item.IsIssue; keywordTableObj["Sort"] = maxKeywordSort + 1; keywordTableObj.Insert(); return(true); } else { // 如果有的話,判斷是不是已經加入關鍵字 KeywordModels keywordObj = GetKeywordItemByText(item.Text); // 已經加入的話就不加 if (keywordObj != null) { return(false); } int keywordCount = (int)db.GetFirstValue(" SELECT count(*) FROM Keywords "); int maxKeywordSort = keywordCount == 0 ? 1 : (int)db.GetFirstValue("SELECT Sort FROM Keywords ORDER BY Sort Desc"); keywordTableObj["KeywordQueriedID"] = keywordQueriedObj.ID; keywordTableObj["Modifier"] = Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id; keywordTableObj["ModifyTime"] = DateTime.Now; keywordTableObj["IsIssue"] = item.IsIssue; keywordTableObj["Sort"] = maxKeywordSort + 1; keywordTableObj.Insert(); return(true); } }
/// <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(); } }
/// <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); } }
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); } }
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); } }