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);
            }
        }
예제 #2
0
        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());
            }
        }
예제 #5
0
        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();
        }
        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();
        }
예제 #10
0
        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");
        }
        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;
                    }
                }
            }
        }