private static void AddNewOption(string type, string name, string url, string options) { try { db_config_options dco = new db_config_options(type, name); dco.Open(); // open connection // exist if type of name are empty, you have to define type and url or option can be empty if (type == string.Empty || name == string.Empty) { Generic.JavaScriptInjector("SaveError", "alert('type " + type + " or name " + name + " are empty');"); return; } // if it returns more then zero then name and type are alredy in use if (dco.AllOptions.Count > 0) { Generic.JavaScriptInjector("SaveError", "alert('type " + type + " and name " + name + " already exists');"); return; } Options op = new Options { Name = name, OBJType = type, URL = url, Options1 = options }; dco.Add(op); dco.Close(); // close connection Generic.JavaScriptInjector("alert('Option added'); window.location.reload();"); } catch (Exception ex) { Generic.JavaScriptInjector("SaveError", "alert('" + ex.Message + "');"); } }
public DrawFrames(string pageName, string pageType) { _pageName = pageName; _pageType = pageType; _options = new db_config_options("frame"); _options.Open(); }
/************************ Configurations ************************/ /// <summary> /// Update existing option, the id is used has reference. /// </summary> private static void SaveExistingOption(string opId, string type, string name, string url, string options) { try { // if url does not exists then will add a new option if (opId == string.Empty) AddNewOption(type, name, url, options); db_config_options dco = new db_config_options(); dco.Open(); // open connection int id = Convert.ToInt32(opId); Options op = dco.AllOptions.Single(x => x.ID == id); if (op.ID != id) return; // if id is diferent probabaly because user pressed save with no option selected op.OBJType = type; op.Name = name; op.URL = url; op.Options1 = options; dco.Commit(); dco.Close(); // close connection Generic.JavaScriptInjector("alert('Option Saved'); window.location.reload();"); } catch (Exception ex) { Generic.JavaScriptInjector("SaveError", "alert('" + ex.Message + "');"); } }
public string ListAvailableOptions(string ctrl) { JavaScriptSerializer js = new JavaScriptSerializer(); string crlHash = Generic.GetHash(Generic.GetWebConfigValue("WebServiceKey")); if (ctrl != crlHash) return js.Serialize(""); try { db_config_options dco = new db_config_options(); dco.Open(); List <Options> options = dco.AllOptions.OrderBy(x=> x.OBJType).ToList(); dco.Close(); return js.Serialize(options); } catch (Exception ex) { loging.Error("BackOffice", "Available Options WebService", ex.Message, _logRecord); } return js.Serialize(""); }
public string GetAvailableOption(string objType, string name, string ctrl) { string crlHash = Generic.GetHash(Generic.GetWebConfigValue("WebServiceKey")); if (ctrl != crlHash) return string.Empty; db_config_options dco = null; try { dco = new db_config_options(objType, name); dco.Open(); Options option = dco.Get(name); return option.Options1; } catch (Exception ex) { return ex.Message; } finally { if (dco != null) dco.Close(); } }
public string DeleteAvailableOption(string opId, string ctrl) { string crlHash = Generic.GetHash(Generic.GetWebConfigValue("WebServiceKey")); if (ctrl != crlHash) return ""; db_config_options dco = null; try { dco = new db_config_options(); dco.Open(); // open connection dco.Delete(Convert.ToInt32(opId)); } catch (Exception ex) { return ex.Message; } finally { if (dco != null) dco.Close(); } return "Option Deleted"; }
/// <summary> /// Load available options from loaded frame type /// </summary> private void LoadFrameTypeToOpTextArea(string ftype) { db_config_options dco = null; try { dco = new db_config_options("frame", ftype); dco.Open(); Options op = dco.Get(ftype); aval_type_op.InnerHtml = op.Options1; } catch (Exception ex) { throw new Exception("error: build default frame type (" + ftype + "): " + ex.Message); } finally { if (dco != null) dco.Close(); } }
/// <summary> /// build the schedule interval select box /// </summary> private void BuildScheduleInterval(int? interval) { db_config_options dco = null; f_schedule_interval.Items.Clear(); try { dco = new db_config_options("backoffice", "frame_options"); dco.Open(); Options op = dco.Get("frame_options"); OptionItems oi = new OptionItems(op.Options1); List<string> scheduleList = oi.GetList("schedule_interval"); for (int i = 0; i < scheduleList.Count; i++) { string[] schedule = scheduleList[i].Split(new [] {','}, StringSplitOptions.RemoveEmptyEntries); f_schedule_interval.Items.Add(new ListItem( schedule[1], schedule[0] )); try { if (Convert.ToInt32(schedule[0]) == interval) f_schedule_interval.SelectedIndex = i; } catch {} } } catch (Exception ex) { throw new Exception("error: build frame type " + ex.Message); } finally { if (dco != null) dco.Close(); } }
/// <summary> /// Set the FrameType /// </summary> private void BuildFrameType(string fType) { db_config_options dco = null; f_type.Items.Clear(); try { dco = new db_config_options("frame"); dco.Open(); List<Options> options = dco.AllOptions; options.RemoveAt(options.FindIndex(x=> x.Name == "generic")); for (int i = 0; i < options.Count; i++) { f_type.Items.Add(new ListItem( options[i].Name, options[i].Name )); // Get the option position then set the selector index if (options[i].Name == fType) f_type.SelectedIndex = i; } } catch (Exception ex) { throw new Exception("error: build frame type " + ex.Message); } finally { if (dco != null) dco.Close(); } }