protected void Page_Load(object sender, EventArgs e) { SuperOfficeAuthHelper.Authorize(); // First choose the correct installation: SuperOffice.Configuration.ConfigFile.WebServices.RemoteBaseURL = SuperOfficeAuthHelper.Context.NetServerUrl; var selPar = Request.QueryString["SelectionId"]; int selId = Convert.ToInt32(selPar); using (var selAgent = new SelectionAgent()) { SelectionEntity sel = selAgent.GetSelectionEntity(selId); IAddressFetcher fetcher = null; switch (sel.TargetTableNumber) { case 5: // Contact fetcher = new AddressFetcherFromContactSelection(); break; default: fetcher = new AddressFetcherFromOtherSelections(sel.TargetTableNumber); break; } Page.ClientScript.RegisterStartupScript(this.GetType(), "MapScript", fetcher.GetScript(selId), true); } }
protected void Page_Load(object sender, EventArgs e) { SuperOfficeAuthHelper.Authorize(); CreateWebPanelInUsersInstallation(); this.ProvideFeedbackToTheUser(); }
protected void UninstallButton_Click(object sender, EventArgs e) { SuperOfficeAuthHelper.Authorize(); var wpHelper = new WebPanelHelper(); wpHelper.DeleteAllWebPanels(); this.ProvideFeedbackToTheUser(); }
private void CreateWebPanelsInUsersInstallation(IEnumerable <Product> selectedProducts) { SuperOfficeAuthHelper.Authorize(); var helper = new WebPanelHelper(); foreach (var selectedProduct in selectedProducts) { helper.CreateAndSaveWebPanel(Global.AppName, selectedProduct.LinkName, selectedProduct.Url, selectedProduct.GetNavigation()); } }
protected void UninstallButton_Click(object sender, EventArgs e) { SuperOfficeAuthHelper.Authorize(); if (SoContext.CurrentPrincipal.HasFunctionRight("admin-all")) { var wpHelper = new WebPanelHelper(); wpHelper.DeleteAllWebPanels(); this.ProvideFeedbackToTheUser(); } }
protected void Page_Load(object sender, EventArgs e) { SuperOfficeAuthHelper.Authorize(); // First choose the correct installation: SuperOffice.Configuration.ConfigFile.WebServices.RemoteBaseURL = SuperOfficeAuthHelper.Context.NetServerUrl; var par = Request.QueryString["UserId"]; int id = Convert.ToInt32(par); var fetcher = new AddressFetcherFromDiary(); Page.ClientScript.RegisterStartupScript(this.GetType(), "MapScript", fetcher.GetScript(id), true); }
protected void Install_Click(object sender, EventArgs e) { SuperOfficeAuthHelper.Authorize(); if (_isAnUpdate) { var helper = new WebPanelHelper(); var installedWebPanels = helper.GetAllWebPanels(); // Four possibilities: // Installed Selected Result // x x Do nothing // x Delete // x Install // Do nothing foreach (var product in _products.Values) { var isInstalled = installedWebPanels.Any(wp => wp.Name == product.LinkName); if (isInstalled) // or exists.. { var webPanelId = installedWebPanels.Where(wp => wp.Name == product.LinkName).FirstOrDefault(); if (!product.IsSelected && webPanelId != null) // -> Delete { if (webPanelId.WebPanelId > 0) { helper.DeleteWebPanel(webPanelId.WebPanelId); } } else // -> Undelete { _ = helper.CreateWebPanel(webPanelId.Name, webPanelId.Url, webPanelId.VisibleIn); } } else { if (product.IsSelected) // -> Install { helper.CreateAndSaveWebPanel(Global.AppName, product.LinkName, product.Url, product.GetNavigation()); } } } } else { CreateWebPanelsInUsersInstallation(_products.Values.Where(pr => pr.IsSelected)); } ProvideFeedbackToTheUser(); }
public ActionResult Index(string state, string code) { string error = string.Empty; var sessionState = HttpContext.Session["state"]; if (sessionState.Equals(state)) { OidcModel oauthModel = SuperOfficeAuthHelper.GetOAuthModel(code); if (SuperOfficeAuthHelper.TryLogin(oauthModel, out error)) { var context = SuperOfficeAuthHelper.Context; //Store the System User Information in the Database CustomerDataSource dataSource = new CustomerDataSource(); var customer = dataSource.Customers.FirstOrDefault(c => c.ContextIdentifier == context.ContextIdentifier); //var databaseContext = new PartnerDatabaseContext(); //var customer = databaseContext.Customers.FirstOrDefault(c => c.ContextIdentifier == context.ContextIdentifier); if (customer == null) { dataSource.Customers.Add(new CustomerInfo { AssociateID = context.AssociateId, ContextIdentifier = context.ContextIdentifier, IsActive = true, LastSync = new DateTime(2000, 1, 1), SystemUserToken = context.SystemToken }); dataSource.Save(); } // Redirect to original request var redirectUr = Session["RedirectUrl"] as string; if (!String.IsNullOrEmpty(redirectUr)) { return(Redirect(redirectUr)); } else { return(RedirectToAction("Index", "Home")); } } } return(RedirectToAction("Welcome", "Home", new { Error = error })); }
protected void Page_Load(object sender, EventArgs e) { SuperOfficeAuthHelper.Authorize(); // First choose the correct installation: SuperOffice.Configuration.ConfigFile.WebServices.RemoteBaseURL = SuperOfficeAuthHelper.Context.NetServerUrl; var contPar = Request.QueryString["ContactId"]; int contId = Convert.ToInt32(contPar); using (var contAgent = new ContactAgent()) { var cont = contAgent.GetContactEntity(contId); var addr = cont.Address; string address = string.Empty; if (addr.LocalizedAddress != null && addr.LocalizedAddress.Length > 1) { if (addr.LocalizedAddress[0] != null) { address = addr.LocalizedAddress[0].Aggregate(address, (current, addrLine) => current.Add(addrLine.Value, ", ")); } if (addr.LocalizedAddress[1] != null) { address = addr.LocalizedAddress[1].Aggregate(address, (current, addrLine) => current.Add(addrLine.Value, ", ")); } address = address.Add(cont.Country.EnglishName, ", "); string lat, lng; GoogleMaps.GeocodeAddress(address, out lat, out lng ); var contactName = System.Web.HttpUtility.JavaScriptStringEncode(cont.Name); var script = "<script>\nfunction initializeMarkers() {\n"; script += string.Format("AddMarker(map, '{0}', '{1}', '{2}' );\n", contactName, lat, lng); script += "}\n</script>"; loadMarkersScript.Text = script; } } }
protected void Page_Load(object sender, EventArgs e) { SuperOfficeAuthHelper.Authorize(); Page.Title = "SuperOffice Maps example Uninstall"; _username.InnerText = SuperOfficeAuthHelper.Context.Name; _company.InnerText = SuperOfficeAuthHelper.Context.Company; var masterPage = Master as MapsExample; if (masterPage != null) { masterPage.DescriptionText = "Uninstall SuperOffice Maps from your SuperOffice CRM online installation?"; masterPage.ExtraHeaderText = "Uninstall"; } InsertWebPanelListItems(); }
protected void Page_Load(object sender, EventArgs e) { SuperOfficeAuthHelper.Authorize(); Page.Title = "Company News Uninstall"; _username.InnerText = SuperOfficeAuthHelper.Context.Name; _company.InnerText = SuperOfficeAuthHelper.Context.Company; var masterPage = Master as SiteMaster; if (masterPage != null) { masterPage.DescriptionText = "Uninstall Company News from your SuperOffice CRM online installation?"; masterPage.ExtraHeaderText = "Uninstall"; } // Only an admin can remove this app: UninstallButton.Enabled = SoContext.CurrentPrincipal.HasFunctionRight("admin-all"); }
public ActionResult SuperIdLogout() { // ToDo: Should do federated logout... but it is easier debug if I don't SuperOfficeAuthHelper.Logout(); return(RedirectToAction("Index", "Home")); }
protected void Page_Load(object sender, EventArgs e) { string error = string.Empty; SetupVisibleParts(); var requestType = Context.Request.RequestType; if (requestType.ToUpper() == "POST") { var callbackModel = new CallbackModel { Saml = Context.Request["saml"], Jwt = Context.Request["jwt"], }; if (SuperOfficeAuthHelper.TryLogin(callbackModel, out error)) { var redirectUr = Context.Session["RedirectUrl"] as string; Context.Session["RedirectUrl"] = ""; if (!String.IsNullOrEmpty(redirectUr)) { Context.Response.Redirect(redirectUr); } } else { explanationText.Visible = true; explanationText.InnerText = "Login unsuccessful, reason: " + error; } } else { var code = Context.Request["code"]; var state = Context.Request["state"]; var sessionState = Context.Session["state"] as string; if (sessionState.Equals(state)) { OidcModel oauthModel = SuperOfficeAuthHelper.GetOAuthModel(code); if (SuperOfficeAuthHelper.TryLogin(oauthModel, out error)) { var redirectUr = Context.Session["RedirectUrl"] as string; Context.Session["RedirectUrl"] = ""; if (!String.IsNullOrEmpty(redirectUr)) { Context.Response.Redirect(redirectUr); } } } else { explanationText.Visible = true; explanationText.InnerText = "Login unsuccessful, reason: " + error; } } }
protected void Page_Load(object sender, EventArgs e) { SuperOfficeAuthHelper.Authorize(); var p = new Product(); _products = p.GetProductsDic(); // Is this the first time, or later? var helper = new WebPanelHelper(); var installedWebPanels = helper.GetAllWebPanels(); if (installedWebPanels != null && installedWebPanels.Length != 0) { _isAnUpdate = true; if (!IsPostBack) { // The system has been installed, now the user wants to change the configuration: foreach (var product in _products.Values) { var id = installedWebPanels.FirstOrDefault(w => w.Name == product.LinkName); if (id != null) { product.IsSelected = id.Name == product.LinkName && !id.Deleted; } else { product.IsSelected = false; } } } } Page.Title = "SuperOffice Maps example setup"; var masterPage = Master as MapsExample; if (masterPage != null) { masterPage.ExtraHeaderText = "Configure"; } if (!IsPostBack) { _repeater.DataSource = _products.Values; this.DataBind(); } if (IsPostBack) { //set checked on the data var checkboxes = _repeater.FindDescendants <CheckBox>().ToArray(); var buyAll = GetBuyAllCheckBox(checkboxes); foreach (var checkbox in checkboxes) { if (checkbox != buyAll) { GetProduct(checkbox).IsSelected = checkbox.Checked; } } } }
public ActionResult Index(CallbackModel callbackModel) { if (callbackModel == null) { return(RedirectToAction("Index", "Home")); } /* * Here it is up to the partner intercept the callback from SuperID * and route the user to the correct partner application instance. * * This is also the opportunity for the Partner to create a system user * in the customers superoffice database for future use and storage. * * This is where any additional setup or configuration options are input into * the partners application for future use. */ string error = string.Empty; if (SuperOfficeAuthHelper.TryLogin(callbackModel, out error)) { var context = SuperOfficeAuthHelper.Context; //Store the System User Information in the Database CustomerDataSource dataSource = new CustomerDataSource(); var customer = dataSource.Customers.FirstOrDefault(c => c.ContextIdentifier == context.ContextIdentifier); //var databaseContext = new PartnerDatabaseContext(); //var customer = databaseContext.Customers.FirstOrDefault(c => c.ContextIdentifier == context.ContextIdentifier); if (customer == null) { dataSource.Customers.Add(new CustomerInfo { AssociateID = context.AssociateId, ContextIdentifier = context.ContextIdentifier, IsActive = true, LastSync = new DateTime(2000, 1, 1), SystemUserToken = context.SystemToken }); dataSource.Save(); } // Redirect to original request var redirectUr = Session["RedirectUrl"] as string; if (!String.IsNullOrEmpty(redirectUr)) { return(Redirect(redirectUr)); } else { return(RedirectToAction("Index", "Home")); } } else { return(RedirectToAction("Welcome", "Home", new { Error = error })); } }
public ActionResult Index(string jwt) { if (String.IsNullOrWhiteSpace(jwt)) { return(RedirectToAction("Index", "Home")); } /* * Here it is up to the partner intercept the callback from SuperID * and route the user to the correct partner application instance. * * This is also the opportunity for the Partner to create a system user * in the customers superoffice database for future use and storage. * * This is where any additional setup or configuration options are input into * the partners application for future use. */ if (SuperOfficeAuthHelper.TryLogin(jwt)) { var context = SuperOfficeAuthHelper.Context; AppDB.Initialize(); AppDB.UpgradeDatabase(); using (var db = new AppDB()) { bool newCustomer = false; var utcNow = DateTime.UtcNow; User user = null; var customer = db.Customers.FirstOrDefault(c => c.ContextIdentifier == context.ContextIdentifier); if (customer == null) { customer = new Customer { ContextIdentifier = context.ContextIdentifier, Registered = utcNow, LastUsed = utcNow, }; db.Customers.Add(customer); newCustomer = true; db.SaveChanges(); // Save one first.... } if (!newCustomer) { user = customer.Users.FirstOrDefault(u => u.AssociateId == context.AssociateId); } if (user == null) { user = new User { Customer = customer, AssociateId = context.AssociateId, }; db.Users.Add(user); } user.UserPrincipalName = context.Username; user.Email = context.Email; if (newCustomer) { customer.RegisteredBy = user; } customer.LastUsedBy = user; customer.LastUsed = utcNow; customer.Name = context.Company; customer.NetServerUrl = context.NetServerUrl; customer.SystemUserToken = context.SystemToken; db.SaveChanges(); SystemUserManager.ClearCachedItem(context.ContextIdentifier); } //Store the System User Information in the Database //var databaseContext = new PartnerDatabaseContext(); //var customer = databaseContext.Customers.FirstOrDefault(c => c.ContextIdentifier == context.ContextIdentifier); //if (customer == null) //{ // databaseContext.Customers.Add(new CustomerInfo // { // AssociateID = context.AssociateId, // ContextIdentifier = context.ContextIdentifier, // IsActive = true, // LastSync = new DateTime(2000, 1, 1), // SystemUserToken = context.SystemToken // }); // databaseContext.SaveChanges(); //} // Redirect to original request var redirectUr = Session["RedirectUrl"] as string; if (!String.IsNullOrEmpty(redirectUr)) { return(Redirect(redirectUr)); } else { return(RedirectToAction("Index", "Home")); } } else { return(RedirectToAction("Index", "Home")); } }