public static XElement LoadTemplate(VKLTypes type) { Common.PrevActResult = Results.Ok; try { return XElement.Load(Common.PhysicalPath((type == VKLTypes.Key ? IOLocations.VKLKTemplate : IOLocations.VKLCTemplate))); } catch (Exception ex) { Common.LogError("Error loading template '" + type.ToString() + "': " + ex.Message, "VKM.LoadTemplate", (int)Results.ResourceError); } Common.PrevActResult = Results.SomeError; return null; }
public static VKL GetVKL(string vklName, VKLTypes type) { try { using (DataAccess da = new DataAccess()) { var dt = da.ExecuteQuerySPForDataTable("Sel_VKL", new SqlParameter[] { new SqlParameter("@name", vklName), new SqlParameter("@type", (int)type) }); if (dt.Rows.Count > 0) { var dr = dt.Rows[0]; var vkl = new VKL { Id = (int)dr["VKLId"], LangCode = (string)dr["LangCode"], Name = (string)dr["Name"], UserId = (int)dr["UserId"], Type = (VKLTypes)int.Parse(dr["Type"].ToString()), Visibility = (VKLVisibility)int.Parse(dr["Visibility"].ToString()) }; vkl.Data = XElement.Load(VKLFilePath(vkl.Name, vkl.Type)); return vkl; } else Common.LogError("The VKL " + vklName + " (" + type.ToString() + ") couldn't be found.", Common.GetMethodName(MethodBase.GetCurrentMethod()), (int)Results.NotFound); } } catch (SqlException sqlEx) { Common.LogError(sqlEx.Message, Common.GetMethodName(MethodBase.GetCurrentMethod()), sqlEx.Number); } catch (Exception otherEx) { Common.LogError(otherEx.Message, Common.GetMethodName(MethodBase.GetCurrentMethod())); } return null; }