Example #1
0
 private static string VKLFilePath(string Name, VKLTypes type)
 {
     return Common.PhysicalPath(IOLocations.VKLs + (type == VKLTypes.Key ? Name : Name + "_c") + ".vkl");
 }
Example #2
0
 public static bool VKLExists(string VKLName, VKLTypes VKLType)
 {
     if (File.Exists(VKLFilePath(VKLName, VKLType)))
         return true;
     else
         return false;
 }
Example #3
0
 public static XElement LoadVKLData(string name, VKLTypes type)
 {
     try
     {
     return XElement.Load(VKLFilePath(name, type));
     }
     catch (Exception ex)
     {
     Common.LogError("Error loading VKL: " + ex.Message, "VKM.LoadVKL", (int)Results.ResourceError);
     throw;
     }
     return null;
 }
Example #4
0
 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;
 }
Example #5
0
 public static string LoadRawVKLData(string name, VKLTypes type)
 {
     try
     {
     return File.ReadAllText(VKLFilePath(name, type));
     }
     catch (Exception ex)
     {
     Common.LogError("Error loading VKL: " + ex.Message, "VKM.LoadRawVKL", (int)Results.ResourceError);
     }
     return string.Empty;
 }
Example #6
0
        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;
        }