protected bool SaveAppInDatabase(string app, string page_name) { try { ClearMessages(); Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID]; State["CreatePageMessage"] = null; //save application Util util = new Util(); XmlUtil x_util = new XmlUtil(); State["PageHtml"] = x_util.FilterCanvasOutput(SavedCanvasHtml.Text); string html = State["PageHtml"].ToString(); if ( State["SelectedDeviceType"] == null /*|| State["SelectedDeviceView"] == null*/) { State["SelectedDeviceType"] = Constants.IPHONE; DeviceType.Text = State["SelectedDeviceType"].ToString(); } util.CreateApp(State, page_name, State["SelectedDeviceType"].ToString(), AppDescription.Text); util.SetDefaultButton(State, DefaultButtonImage.Text); Hashtable duplicates = x_util.EncodeAppPageToAppXml(State, page_name, html); if (duplicates != null) { State["SelectedApp"] = app; util.DeleteApplication(State); ResetAppStateVariables(); UpdateAppLists(); AppPages.Items.Clear(); StringBuilder errors = new StringBuilder(); foreach (string duplicate in duplicates.Keys) { errors.Append(duplicate + " internal name in current page also found on " + duplicates[duplicate].ToString() + " page; "); } Message.Text = errors.ToString() + " This application was not saved because duplicate identifiers are not allowed."; return false; } x_util.SetBackgroundImage(State); SetViewForDevice(); ShowPage(page_name); CurrentApp.Items.Add(new RadComboBoxItem(app, app)); CurrentApp.SelectedIndex = CurrentApp.Items.Count - 1; AppPages.Items.Clear(); AppPages.Items.Add(new RadComboBoxItem(page_name, page_name)); AppPages.SelectedIndex = 0; SavedCanvasHtml.Text = ""; return true; } catch (Exception ex) { Util util = new Util(); Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID]; util.LogError(State, ex); Message.Text = "Internal Error: " + ex.Message + ": " + ex.StackTrace; return false; } }