///<summary>Returns definitions that are associated to the defCat, fKey, and defLinkType passed in.</summary> public static List <Def> GetDefsByDefLinkFKey(DefCat defCat, long fKey, DefLinkType defLinkType) { //No need to check RemotingRole; no call to db. List <DefLink> listDefLinks = DefLinks.GetDefLinksByType(defLinkType).FindAll(x => x.FKey == fKey); return(Defs.GetDefs(defCat, listDefLinks.Select(x => x.DefNum).Distinct().ToList())); }
///<summary>Gets one DefLinks by FKey. Must provide DefLinkType. Returns null if not found.</summary> public static DefLink GetOneByFKey(long fKey, DefLinkType defType) { //No need to check RemotingRole; no call to db. return(GetListByFKeys(new List <long>() { fKey }, defType).FirstOrDefault()); }
///<summary>Gets list of DefLinks by FKey. Must provide DefLinkType.</summary> public static List <DefLink> GetListByFKey(long fKey, DefLinkType defType) { //No need to check RemotingRole; no call to db. return(GetListByFKeys(new List <long>() { fKey }, defType)); }
///<summary>Gets list of all DefLinks by defLinkType .</summary> public static List <DefLink> GetDefLinksByType(DefLinkType defType) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <DefLink> >(MethodBase.GetCurrentMethod(), defType)); } string command = "SELECT * FROM deflink WHERE LinkType=" + POut.Int((int)defType); return(Crud.DefLinkCrud.SelectMany(command)); }
public static DefLink CreateDefLink(long defNum, long fKey, DefLinkType linkType) { DefLink defLink = new DefLink() { DefNum = defNum, FKey = fKey, LinkType = linkType, }; DefLinks.Insert(defLink); return(defLink); }
///<summary>Deletes all links for the specified definition and link type.</summary> public static void DeleteAllForDef(long defNum, DefLinkType defType) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), defNum, defType); return; } string command = "DELETE FROM deflink " + "WHERE LinkType=" + POut.Int((int)defType) + " " + "AND DefNum=" + POut.Long(defNum); Db.NonQ(command); }
///<summary>Updates the FKey column on all deflink rows for the corresponding definition and type.</summary> public static void UpdateDefWithFKey(long defNum, long fKey, DefLinkType defType) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), defNum, fKey, defType); return; } string command = "UPDATE deflink SET FKey=" + POut.Long(fKey) + " " + "WHERE LinkType=" + POut.Int((int)defType) + " " + "AND DefNum=" + POut.Long(defNum); Db.NonQ(command); }
///<summary>Gets list of DefLinks by FKeys. Must provide DefLinkType.</summary> public static List <DefLink> GetListByFKeys(List <long> listFKeys, DefLinkType defType) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <DefLink> >(MethodBase.GetCurrentMethod(), listFKeys, defType)); } if (listFKeys.Count == 0) { return(new List <DefLink>()); } string command = "SELECT * FROM deflink WHERE FKey IN(" + string.Join(",", listFKeys.Select(x => POut.Long(x))) + ")" + " AND LinkType =" + POut.Int((int)defType); return(Crud.DefLinkCrud.SelectMany(command)); }
///<summary>Gets list of all DefLinks for the definitions and defLinkType passed in.</summary> public static List <DefLink> GetDefLinksByTypeAndDefs(DefLinkType defType, List <long> listDefNums) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <DefLink> >(MethodBase.GetCurrentMethod(), defType, listDefNums)); } if (listDefNums == null || listDefNums.Count < 1) { return(new List <DefLink>()); } string command = "SELECT * FROM deflink " + "WHERE LinkType=" + POut.Int((int)defType) + " " + "AND DefNum IN(" + string.Join(",", listDefNums.Select(x => POut.Long(x))) + ")"; return(Crud.DefLinkCrud.SelectMany(command)); }
///<summary>Deletes all links for the specified FKey and link type.</summary> public static void DeleteAllForFKeys(List <long> listFKeys, DefLinkType defType) { if (listFKeys == null || listFKeys.Count < 1) { return; } if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), listFKeys, defType); return; } string command = "DELETE FROM deflink " + "WHERE LinkType=" + POut.Int((int)defType) + " " + "AND FKey IN(" + string.Join(",", listFKeys.Select(x => POut.Long(x))) + ")"; Db.NonQ(command); }
///<summary>Inserts or updates the FKey entry for the corresponding definition passed in. ///This is a helper method that should only be used when there can only be a one to one relationship between DefNum and FKey.</summary> public static void SetFKeyForDef(long defNum, long fKey, DefLinkType linkType) { //No need to check RemotingRole; no call to db. //Look for the def link first to decide if we need to run an update or an insert statement. List <DefLink> listDefLinks = GetDefLinksByType(linkType, defNum); if (listDefLinks.Count > 0) { UpdateDefWithFKey(defNum, fKey, linkType); } else { Insert(new DefLink() { DefNum = defNum, FKey = fKey, LinkType = linkType, }); } }
public static void InsertDefLinksForDefs(List <long> listDefNums, long fKey, DefLinkType linkType) { if (listDefNums == null || listDefNums.Count < 1) { return; } if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) //Remoting role check to save on middle tier calls due to loop. { Meth.GetVoid(MethodBase.GetCurrentMethod(), listDefNums, fKey, linkType); return; } foreach (long defNum in listDefNums) { Insert(new DefLink() { DefNum = defNum, FKey = fKey, LinkType = linkType, }); } }