Exemple #1
0
    /// <summary>
    /// Handles the exception.
    /// </summary>
    /// <param name="e">The e.</param>
    private void handleException(Exception e)
    {
        string sSlxErrorId = null;
        var    sMsg        = ErrorHelper.GetClientErrorHtmlMessage(e, ref sSlxErrorId);

        if (!string.IsNullOrEmpty(sSlxErrorId))
        {
            log.Error(
                ErrorHelper.AppendSlxErrorId("There was an error in SmartParts_Contact_UpdateContactOptions",
                                             sSlxErrorId),
                e);
        }
        DialogService.ShowHtmlMessage(sMsg, ErrorHelper.IsDevelopmentContext() ? 600 : -1,
                                      ErrorHelper.IsDevelopmentContext() ? 800 : -1);
    }
Exemple #2
0
    /// <summary>
    /// Uploads the file.
    /// </summary>
    public void UploadFile()
    {
        if (uplFile.UploadedFiles.Count == 0)
        {
            return;
        }

        lblFileRequired.Visible = false;
        lblRequiredMsg.Visible  = false;
        try
        {
            switch (txtConfirmUpload.Value)
            {
            case "F":
                uplFile.UploadedFiles.Clear();
                break;

            case "O":
                //elected to overwrite existing uploaded file
                ImportManager importManager = GetImportManager();
                importManager.SourceFileName = uplFile.UploadedFiles[0].FileName;
                importManager.ImportMaps.Clear();
                ImportOptions options = new ImportOptions();
                importManager.Options         = options;
                Page.Session["importManager"] = importManager;
                txtConfirmUpload.Value        = "T";
                UploadFileEx();
                break;

            case "T":
                UploadFileEx();
                break;
            }
        }
        catch (Exception ex)
        {
            string sSlxErrorId = null;
            var    sMsg        = ErrorHelper.GetClientErrorHtmlMessage(ex, ref sSlxErrorId);
            if (!string.IsNullOrEmpty(sSlxErrorId))
            {
                log.Error(ErrorHelper.AppendSlxErrorId("The call to StepSelectFile.UploadFile() failed", sSlxErrorId),
                          ex);
            }
            DialogService.ShowHtmlMessage(sMsg, ErrorHelper.IsDevelopmentContext() ? 600 : -1,
                                          ErrorHelper.IsDevelopmentContext() ? 800 : -1);
        }
    }
Exemple #3
0
    /// <summary>
    /// Gets the import manager.
    /// </summary>we
    /// <returns></returns>
    private ImportManager GetImportManager()
    {
        ImportManager importManager = Page.Session["importManager"] as ImportManager;

        if (importManager != null)
        {
            if (importProcessId.Value != importManager.ToString() && String.IsNullOrEmpty(txtImportFile.Value))
            {
                lblFileRequired.Visible = false;
                lblRequiredMsg.Visible  = false;
                importManager           = null;
            }
        }
        if (importManager == null)
        {
            try
            {
                LeadDuplicateProvider duplicateProvider = new LeadDuplicateProvider();
                txtCreateGroupName.Text = DateTime.Now.ToString();
                ImportService importService = new ImportService();
                importManager                   = importService.CreateImportManager(typeof(ILead));
                importProcessId.Value           = importManager.ToString();
                importManager.DuplicateProvider = duplicateProvider;
                importManager.MergeProvider     = new ImportLeadMergeProvider();
                importManager.ActionManager     = GetActionManager();
            }
            catch (Exception ex)
            {
                string sSlxErrorId = null;
                var    sMsg        = ErrorHelper.GetClientErrorHtmlMessage(ex, ref sSlxErrorId);
                if (!string.IsNullOrEmpty(sSlxErrorId))
                {
                    log.Error(
                        ErrorHelper.AppendSlxErrorId("The call to StepSelectFile.GetImportManager() failed", sSlxErrorId),
                        ex);
                }
                divError.Style.Add(HtmlTextWriterStyle.Display, "inline");
                divMainContent.Style.Add(HtmlTextWriterStyle.Display, "none");
                lblError.Text = sMsg;
                (Parent.Parent.FindControl("StartNavigationTemplateContainerID").FindControl("cmdStartButton")).Visible = false;
            }
        }
        return(importManager);
    }
Exemple #4
0
 protected void cmdSchedule_Click(object sender, EventArgs e)
 {
     if (lueContactToScheduleFor.LookupResultValue == null)
     {
         throw new ValidationException(GetLocalResourceObject("error_ScheduleFor.Message").ToString());
     }
     try
     {
         LoadOwner();
         if (cboProcessType.DataSource != null)
         {
             Plugin   selectedPlugin = ((IList <Plugin>)cboProcessType.DataSource)[cboProcessType.SelectedIndex];
             object[] objarray       = new[]
             {
                 lueContactToScheduleFor.LookupResultValue,
                 selectedPlugin.PluginId,
                 selectedPlugin.Family,
                 selectedPlugin.Name,
                 ownProcessOwner.LookupResultValue
             };
             Sage.Platform.Orm.DynamicMethodLibraryHelper.Instance.Execute("Contact.ScheduleProcess", objarray);
             DialogService.CloseEventHappened(sender, e);
             IPanelRefreshService refresher = PageWorkItem.Services.Get <IPanelRefreshService>(true);
             refresher.RefreshTabWorkspace();
         }
         else
         {
             DialogService.ShowMessage(GetLocalResourceObject("Error_ProcessTypes").ToString(), "SalesLogix");
         }
     }
     catch (Exception ex)
     {
         string sSlxErrorId = null;
         var    sMsg        = ErrorHelper.GetClientErrorHtmlMessage(ex, ref sSlxErrorId);
         if (!string.IsNullOrEmpty(sSlxErrorId))
         {
             log.Error(
                 ErrorHelper.AppendSlxErrorId(
                     "The call to SmartParts_Process_ScheduleProcess.cmdSchedule_Click failed", sSlxErrorId), ex);
         }
         DialogService.ShowHtmlMessage(sMsg, ErrorHelper.IsDevelopmentContext() ? 600 : -1,
                                       ErrorHelper.IsDevelopmentContext() ? 800 : -1);
     }
 }
Exemple #5
0
 /// <summary>
 /// Loads the source entity that the de-dup will be performed on.
 /// </summary>
 private void LoadSourceEntity()
 {
     if (DuplicateProvider != null)
     {
         try
         {
             LoadSourceSnapshot();
         }
         catch (Exception ex)
         {
             string sSlxErrorId = null;
             var    sMsg        = ErrorHelper.GetClientErrorHtmlMessage(ex, ref sSlxErrorId);
             if (!string.IsNullOrEmpty(sSlxErrorId))
             {
                 log.Error(ErrorHelper.AppendSlxErrorId("The call to LeadSearchForDuplicates.LoadSourceEntity() failed", sSlxErrorId), ex);
             }
             DialogService.ShowHtmlMessage(sMsg, ErrorHelper.IsDevelopmentContext() ? 600 : -1,
                                           ErrorHelper.IsDevelopmentContext() ? 800 : -1);
         }
     }
 }
 /// <summary>
 /// Resolves the duplicate.
 /// </summary>
 /// <param name="itemId">The item id.</param>
 private void ResolveDuplicate(string itemId)
 {
     try
     {
         IMatchDuplicateProvider dupProvider = GetDuplicateProvider(itemId);
         if (DialogService != null && dupProvider != null)
         {
             DialogService.SetSpecs(200, 200, 600, 800, "LeadSearchAndConvert",
                                    GetLocalResourceObject("Title.Resolve.Duplicate.ImportLead").ToString(), true);
             DialogService.DialogParameters.Add("duplicateProvider", dupProvider);
             DialogService.DialogParameters.Add("importHistoryItemId", itemId);
             DialogService.EntityType = typeof(IImportHistory);
             DialogService.EntityID   = itemId;
             DialogService.ShowDialog();
             chkShowDuplicates.Checked = false;
         }
     }
     catch (Exception exp)
     {
         var sSlxErrorId = ErrorHelper.GetNewLoggingId();
         log.Error(ErrorHelper.AppendSlxErrorId("The call to ImportHistoryDuplicates.ResolveDuplicate() failed", sSlxErrorId), exp);
         throw new UserObservableApplicationException(String.Format(GetLocalResourceObject("LoadErrorMSG").ToString(), sSlxErrorId), exp);
     }
 }
Exemple #7
0
    /// <summary>
    /// Handles the Error event of the Application control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    private void Application_Error(object sender, EventArgs e)
    {
        Exception fullException = null;
        var       logged        = false;
        string    sSlxErrorId   = null;

        try
        {
            var exception = Server.GetLastError();
            if (exception == null)
            {
                return;
            }

            fullException = exception;

            var eKind           = ErrorHelper.GetTargetedException(fullException, out exception);
            var eMitigationType = ErrorHelper.GetMitigationType(eKind, Request);
            sSlxErrorId = ErrorHelper.GetNewLoggingId();

            ErrorHelper.LogException(fullException, Request, Log, "SalesLogix Web Client unhandled exception",
                                     sSlxErrorId, ErrorHelper.GetCurrentEventLogSource());
            logged = true;

            Server.ClearError();

            var oErrorMessage = ErrorHelper.GetErrorMessage(exception, Request, eKind, sSlxErrorId, true, true,
                                                            Resources.SalesLogix.MailDetailsLink, Request.Url.ToString(),
                                                            true, ErrorHelper.LogMode.Client, true,
                                                            Resources.SalesLogix.ReturnLink, true);

            var redirectUrl = ErrorHelper.GetLoginRedirectUrl();

            // Note: Just the act of accessing the Session object (e.g. Session.*) can throw an
            // HttpException in certain scenarios with the message "Session state is not available in this context."
            // IsAuthenticated() relies on access to the current Session.
            var session = ErrorHelper.GetCurrentHttpSessionState(this);
            if (session != null && IsAuthenticated() == ErrorHelper.ResultKind.False)
            {
                var path        = Request.Path;
                var isLoginPage = !string.IsNullOrEmpty(path) && path.IndexOf(redirectUrl, StringComparison.InvariantCultureIgnoreCase) != -1;
                // If the Exception came from the login page, go to error page instead; otherwise, the user could get into an unrecoverable loop.)
                if (!isLoginPage || ErrorHelper.LooksLikeAjaxRequest(Request))
                {
                    var eLoginMitigationType = ErrorHelper.LooksLikeAjaxRequest(Request)
                                                   ? ErrorHelper.MitigationType.AjaxLoginRedirect
                                                   : ErrorHelper.MitigationType.LoginRedirect;
                    if (eMitigationType != eLoginMitigationType)
                    {
                        Log.WarnFormat(
                            "The current user is not authenticated. Switching from a mitigation of {0} ({1}) to {2} ({3}).",
                            eMitigationType, (int)eMitigationType, eLoginMitigationType, (int)eLoginMitigationType);
                        eMitigationType = eLoginMitigationType;
                    }
                }
            }

            // Mitigate the scenario
            switch (eMitigationType)
            {
            case ErrorHelper.MitigationType.AjaxLoginRedirect:
                /* Send an Ajax HTTP response status of 575 (handled in Sage.Utility.ErrorHandler.js)
                 * with the response header named "Sage-SalesLogix-Exception-Redirect" with a value of "Login.aspx". */

                // Abandon the Session and SignOut of FormsAuthentication (if applicable).
                // SignOut() will also set the FormsAuthentication cookie value to an empty string.
                SignOut();

                // Save the auth cookie since all cookies will be cleared in ClearHeaders().
                // .SLXAUTH=; expires=Tue, 12-Oct-1999 05:00:00 GMT; path=/; HttpOnly
                var authCookie = Response.Cookies[FormsAuthentication.FormsCookieName];

                if (Log.IsDebugEnabled)
                {
                    Log.Debug("Redirect to Login.aspx (Ajax AuthTokenNullException)");
                }

                Response.ClearHeaders();
                Response.ClearContent();
                Response.Clear();
                Response.StatusCode             = (int)eMitigationType;
                Response.StatusDescription      = eMitigationType.ToString();
                Response.TrySkipIisCustomErrors = true;
                // NOTE: AppendHeader() must be used for IIS6 instead of Response.Headers.Add()
                Response.AppendHeader(ErrorHelper.ExceptionRedirectHttpHeader, redirectUrl);
                Response.AppendHeader(ErrorHelper.ExceptionRedirectFromHttpHeader, "Global Application_Error");     //DNL
                Response.AppendHeader(ErrorHelper.ErrorIdHttpHeader, sSlxErrorId);
                Response.ContentType = "text/plain";

                if (authCookie != null)
                {
                    // Set .SLXAUTH cookie to an empty value
                    // .SLXAUTH=; expires=Tue, 12-Oct-1999 05:00:00 GMT; path=/; HttpOnly
                    Response.Cookies.Add(authCookie);
                }

                Response.Write(exception.Message);
                break;

            case ErrorHelper.MitigationType.LoginRedirect:
                /* Send a Response.Redirect("Login.aspx"). */

                // Abandon the Session and SignOut of FormsAuthentication (if applicable).
                SignOut();

                if (Log.IsDebugEnabled)
                {
                    Log.Debug("Redirect to Login.aspx (AuthTokenNullException)");
                }

                // Redirect
                if (redirectUrl.EndsWith(".aspx", StringComparison.InvariantCultureIgnoreCase))
                {
                    // Server.Transfer is being used to avoid ASP.NET errors caused by a reload of the current page
                    // that occurs during Response.Redirect().
                    Server.Transfer(redirectUrl);
                }
                else
                {
                    Response.Redirect(redirectUrl, false);
                }
                break;

            case ErrorHelper.MitigationType.ErrorContent:
                /* Send error content in the form of raw HTML. */

                if (Log.IsDebugEnabled)
                {
                    Log.DebugFormat("Write the error page back to the response. URL: {0}. Referrer: {1}",
                                    Request.Url,
                                    Request.UrlReferrer);
                }

                Response.ClearHeaders();
                Response.ClearContent();
                Response.Clear();
                Response.StatusCode             = (int)ErrorHelper.MitigationType.ErrorResponse;
                Response.StatusDescription      = ErrorHelper.InternalServerError;
                Response.TrySkipIisCustomErrors = true;
                // NOTE: AppendHeader() must be used for IIS6 instead of Response.Headers.Add()
                Response.AppendHeader(ErrorHelper.ErrorIdHttpHeader, sSlxErrorId);

                if (ErrorHelper.IsRuntimeErrorPostTooLargeException(fullException) &&
                    StringUtility.IsTrueValueString(Request.Params["iframe"]))
                {
                    /* This special HTTP response is designed to work in conjunction with the
                     * Sage.Utility.File.FallbackFilePicker during a file upload. The FallbackFilePicker
                     * uses an IFrame for the upload and an IFrame cannot process the HTTP status,
                     * but it can process the content of the HTTP response...which will be the literal
                     * string "RuntimeErrorPostTooLarge". If the corresponding Exception occurs by another
                     * upload means, a 583 (text/html) or a 576 (Ajax/json) error will be returned. Note that
                     * sending an HTTP status of 500 into an IFrame can lead to an "access is denied" error
                     * because IE will attempt to load a resource into the IFrame (i.e. res://ieframe.dll/http_500.htm);
                     * using a custom HTTP status does [not] lead to the same issue. In addition, sending the
                     * error page HTML will cause the IFrame to incorrectly navigate the page leading to other errors. */
                    Response.Write("RuntimeErrorPostTooLarge");     //DNL
                    Response.ContentType = "text/plain";
                }
                else
                {
                    Response.Write(GetErrorPageHtml(oErrorMessage));
                    Response.ContentType = "text/html";
                }
                break;

            default:
                /* Send an Ajax HTTP response status of 57x-58x with exception content (handled in Sage.Utility.ErrorHandler.js). */
                if (Log.IsDebugEnabled)
                {
                    Log.DebugFormat(
                        "Write the response back to the XMLHttpRequest object with a StatusCode of {0} ({1})",
                        (int)eMitigationType, eMitigationType);
                }

                Response.ClearHeaders();
                Response.ClearContent();
                Response.Clear();
                Response.StatusCode             = (int)eMitigationType;
                Response.StatusDescription      = eMitigationType.ToString();
                Response.TrySkipIisCustomErrors = true;
                // NOTE: AppendHeader() must be used for IIS6 instead of Response.Headers.Add()
                Response.AppendHeader(ErrorHelper.ErrorIdHttpHeader, sSlxErrorId);

                string sLogData;
                if (ErrorHelper.GetExceptionLogData(Request, exception, fullException, sSlxErrorId,
                                                    ErrorHelper.LogMode.Client,
                                                    eMitigationType, out sLogData))
                {
                    // JSON
                    Response.ContentType = "application/json";
                    Response.Write(sLogData);
                }
                else
                {
                    // Plain text
                    Response.ContentType = "text/plain";
                    Response.Write(oErrorMessage.ToString(MessageProperty.FormatType.Text));
                }
                break;
            }

            CompleteRequest();
        }
        catch (Exception ex)
        {
            Log.ErrorEx("There was an error in Application_Error()", EventIds.AdHocEvents.ErrApplicationError, ex);

            if (logged || fullException == null)
            {
                return;
            }

            if (sSlxErrorId == null)
            {
                sSlxErrorId = ErrorHelper.GetNewLoggingId();
            }

            Log.Error(ErrorHelper.AppendSlxErrorId("SalesLogix Web Client unhandled exception", sSlxErrorId),
                      fullException);
        }
    }
    private void CopySelectedUsers(IList <string> targetUserIds)
    {
        var           ums         = ApplicationContext.Current.Services.Get <IUserManagementService>();
        IList <IUser> newUserList = new List <IUser>();

        var userManagementSvc = ApplicationContext.Current.Services.Get <IUserManagementService>();

        try
        {
            foreach (string id in targetUserIds)
            {
                IUser existingUser = EntityFactory.GetById <IUser>(id);
                if (existingUser != null && existingUser.UserInfo != null)
                {
                    if (existingUser.Type == UserType.Retired)
                    {
                        throw new Sage.Platform.Application.ValidationException(GetLocalResourceObject("ErrorCannotCopyRetiredUser").ToString());
                    }

                    AddUserOptions options = SetAddUserOptions(existingUser);

                    // create the new user with default data
                    IUser newUser = ums.AddUser("", options);

                    // sometimes the copy of... name is too long for the data type
                    string nameFormat = " {0}, {1}";
                    if (string.IsNullOrEmpty(existingUser.UserInfo.FirstName))
                    {
                        nameFormat = " {0}{1}";
                    }
                    string fullNameFormat = string.Concat("(", GetLocalResourceObject("CopyOfNameTemplate").ToString(), nameFormat, ")");
                    string newName        = string.Format(fullNameFormat, existingUser.UserInfo.LastName, existingUser.UserInfo.FirstName);

                    /* the following could be used to improve the user experience, but it doesn't match the lan product */
                    //string copyOfTemplate = GetLocalResourceObject("CopyOfNameTemplate").ToString();
                    //string fullNameFormat = string.Concat("<", copyOfTemplate, nameFormat, ">");
                    //string newLastName = existingUser.UserInfo.LastName;
                    //if (newLastName.Contains(string.Concat("<", copyOfTemplate)))
                    //{
                    //    Match match = Regex.Match(newLastName, string.Concat("<", copyOfTemplate, "(.*)", ">"), RegexOptions.IgnoreCase);
                    //    if (match.Groups.Count > 0)
                    //        newLastName = match.Groups[1].Value;
                    //}
                    //string newName = string.Format(fullNameFormat, newLastName, existingUser.UserInfo.FirstName);

                    newUser.UserInfo.LastName = newName.Length > 32 ? newName.Substring(0, 32) : newName;
                    newUser.UserInfo.UserName = newName.Length > 64 ? newName.Substring(0, 64) : newName;

                    string userTemplate = existingUser.UserInfo.UserName;
                    newUser.UserTemplate = userTemplate.Length > 30 ? userTemplate.Substring(0, 30) : userTemplate;

                    newUser.Save();

                    if (newUser != null)
                    {
                        newUserList.Add(newUser);
                    }
                }

                if (newUserList.Count > 0)
                {
                    LinkHandler linkHandler = new LinkHandler(Page);
                    linkHandler.RedirectToNewGroupDetail(newUserList);
                }
            }
        }
        catch (ValidationException)
        {
            throw;
        }
        catch (Exception exp)
        {
            string sSlxErrorId = null;
            var    sMsg        = ErrorHelper.GetClientErrorHtmlMessage(exp, ref sSlxErrorId);
            if (!string.IsNullOrEmpty(sSlxErrorId))
            {
                log.Error(ErrorHelper.AppendSlxErrorId("The call to CopySelectedUsers() failed", sSlxErrorId), exp);
            }
            DialogService.ShowHtmlMessage(sMsg, GetLocalResourceObject("ErrorMessageTitle").ToString(),
                                          ErrorHelper.IsDevelopmentContext() ? 600 : -1,
                                          ErrorHelper.IsDevelopmentContext() ? 800 : -1);
        }
    }
Exemple #9
0
    /// <summary>
    /// Handles the Error event of the Application control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    private void Application_Error(object sender, EventArgs e)
    {
        Exception fullException = null;
        var       logged        = false;
        string    sSlxErrorId   = null;

        try
        {
            var exception = Server.GetLastError();
            if (exception == null)
            {
                return;
            }

            fullException = exception;

            var eKind           = ErrorHelper.GetTargetedException(fullException, out exception);
            var eMitigationType = ErrorHelper.GetMitigationType(eKind, Request);
            sSlxErrorId = ErrorHelper.GetNewLoggingId();

            ErrorHelper.LogException(fullException, Request, Log, "SalesLogix Web Client unhandled exception",
                                     sSlxErrorId);

            logged = true;

            Server.ClearError();

            var oErrorMessage = ErrorHelper.GetErrorMessage(exception, Request, eKind, sSlxErrorId, true, true,
                                                            Resources.SalesLogix.MailDetailsLink, Request.Url.ToString(),
                                                            true, ErrorHelper.LogMode.Client, true,
                                                            Resources.SalesLogix.ReturnLink, true);

            // Note: Just the act of accessing the Session object (e.g. Session.*) can throw an
            // HttpException in certain scenarios with the message "Session state is not available in this context."
            // IsAuthenticated() relies on access to the current Session.
            var session = ErrorHelper.GetCurrentHttpSessionState(this);
            if (session != null && IsAuthenticated() == false)
            {
                var path        = Request.AppRelativeCurrentExecutionFilePath;
                var isLoginPage = !string.IsNullOrEmpty(path) &&
                                  path.EndsWith("Login.aspx", StringComparison.InvariantCultureIgnoreCase);
                // If the Exception came from the login page, go to error page instead; otherwise,
                // the user could get into an unrecoverable loop.)
                if (isLoginPage == false)
                {
                    var eLoginMitigationType = ErrorHelper.LooksLikeAjaxRequest(Request)
                                                   ? ErrorHelper.MitigationType.AjaxLoginRedirect
                                                   : ErrorHelper.MitigationType.LoginRedirect;
                    if (eMitigationType != eLoginMitigationType)
                    {
                        Log.WarnFormat(
                            "The current user is not authenticated. Switching from a mitigation of {0} ({1}) to {2} ({3}).",
                            eMitigationType, (int)eMitigationType, eLoginMitigationType, (int)eLoginMitigationType);
                        eMitigationType = eLoginMitigationType;
                    }
                }
            }

            // Mitigate the scenario
            switch (eMitigationType)
            {
            case ErrorHelper.MitigationType.AjaxLoginRedirect:
                /* Send an Ajax HTTP response status of 575 (handled in Sage.Utility.ErrorHandler.js)
                 * with the response header named "Sage-SalesLogix-Exception-Redirect" with a value of "Login.aspx". */

                // Abandon the Session and SignOut of FormsAuthentication (if applicable).
                // SignOut() will also set the FormsAuthentication cookie value to an empty string.
                SignOut();

                HttpCookie authCookie = null;
                if (FormsAuthentication.IsEnabled)
                {
                    // Save the auth cookie since all cookies will be cleared in ClearHeaders().
                    // .SLXAUTH=; expires=Tue, 12-Oct-1999 05:00:00 GMT; path=/; HttpOnly
                    authCookie = Response.Cookies[FormsAuthentication.FormsCookieName];
                }

                // Ajax redirect
                Log.Debug("Redirect to Login.aspx (Ajax AuthTokenNullException)");

                Response.ClearHeaders();
                Response.ClearContent();
                Response.Clear();
                Response.StatusCode             = (int)eMitigationType;
                Response.StatusDescription      = eMitigationType.ToString();
                Response.TrySkipIisCustomErrors = true;
                // NOTE: AppendHeader() must be used for IIS6 instead of Response.Headers.Add()
                Response.AppendHeader(ErrorHelper.ExceptionRedirectHttpHeader, "Login.aspx");
                Response.AppendHeader(ErrorHelper.ErrorIdHttpHeader, sSlxErrorId);
                Response.ContentType = "text/plain";

                if (authCookie != null)
                {
                    // Set .SLXAUTH cookie to an empty value
                    // .SLXAUTH=; expires=Tue, 12-Oct-1999 05:00:00 GMT; path=/; HttpOnly
                    Response.Cookies.Add(authCookie);
                }

                Response.Write(exception.Message);
                break;

            case ErrorHelper.MitigationType.LoginRedirect:
                /* Send a Response.Redirect("Login.aspx"). */

                // Abandon the Session and SignOut of FormsAuthentication (if applicable).
                SignOut();

                // Redirect
                Log.Debug("Redirect to Login.aspx (AuthTokenNullException)");
                Response.Redirect("Login.aspx", false);
                break;

            case ErrorHelper.MitigationType.ErrorContent:
                /* Send error content in the form of raw HTML. */

                Log.DebugFormat("Write the error page back to the response. URL: {0}. Referrer: {1}", Request.Url,
                                Request.UrlReferrer);
                Response.Write(GetErrorPageHtml(oErrorMessage));
                break;

            default:
                /* Send an Ajax HTTP response status of 57x-58x with exception content (handled in Sage.Utility.ErrorHandler.js). */

                Log.DebugFormat("Write the response back to the XMLHttpRequest object with a StatusCode of {0} ({1})",
                                (int)eMitigationType, eMitigationType);

                Response.ClearHeaders();
                Response.ClearContent();
                Response.Clear();
                Response.StatusCode             = (int)eMitigationType;
                Response.StatusDescription      = eMitigationType.ToString();
                Response.TrySkipIisCustomErrors = true;
                // NOTE: AppendHeader() must be used for IIS6 instead of Response.Headers.Add()
                Response.AppendHeader(ErrorHelper.ErrorIdHttpHeader, sSlxErrorId);

                string sLogData;
                if (ErrorHelper.GetExceptionLogData(Request, exception, fullException, sSlxErrorId,
                                                    ErrorHelper.LogMode.Client,
                                                    eMitigationType, out sLogData))
                {
                    // JSON
                    Response.ContentType = "application/json";
                    Response.Write(sLogData);
                }
                else
                {
                    // Plain text
                    Response.ContentType = "text/plain";
                    Response.Write(oErrorMessage.ToString(MessageProperty.FormatType.Text));
                }
                break;
            }

            CompleteRequest();
        }
        catch (Exception ex)
        {
            Log.ErrorEx("There was an error in Application_Error()", EventIds.AdHocEvents.ErrApplicationError, ex);

            if (logged || fullException == null)
            {
                return;
            }

            if (sSlxErrorId == null)
            {
                sSlxErrorId = ErrorHelper.GetNewLoggingId();
            }

            Log.Error(ErrorHelper.AppendSlxErrorId("SalesLogix Web Client unhandled exception", sSlxErrorId),
                      fullException);
        }
    }
Exemple #10
0
    protected void cmdOK_Click(object sender, EventArgs e)
    {
        ClearErrors();
        try
        {
            if (!ValidateUIRequirements())
            {
                return;
            }
            MoveArguments arguments = new MoveArguments
            {
                SourceContact        = Contact,
                SourceAccount        = Contact.Account,
                TargetAccount        = (IAccount)lueTargetAccount.LookupResultValue,
                UseSourceContactInfo = chkUseSourceAddressPhn.Checked
            };
            //Add the move/reassign options for each of the items
            //Activity Options
            MoveItemOption moveOption = rdbMoveActivity.Checked
                                            ? new MoveItemOption {
                Entity = "Activity", MoveToAccount = true, ReassignTo = arguments.TargetAccount.Id
            }
                                            : new MoveItemOption {
                Entity = "Activity", ReassignTo = (lueReassignActivity.LookupResultValue as IContact).Id, MoveToAccount = false
            };
            arguments.Items.Add(moveOption);

            //History/Notes Options
            moveOption = rdbMoveHistory.Checked
                             ? new MoveItemOption {
                Entity = "History", MoveToAccount = true, ReassignTo = arguments.TargetAccount.Id
            }
                             : new MoveItemOption {
                Entity = "History", ReassignTo = (lueReassignNotesHistory.LookupResultValue as IContact).Id, MoveToAccount = false
            };
            arguments.Items.Add(moveOption);

            object openItemsReassignContact        = lueReassignOpenItems.LookupResultValue != null ? (lueReassignOpenItems.LookupResultValue as IContact).Id : null;
            object closedItemsReassignContact      = lueReassignClosedItems.LookupResultValue != null ? (lueReassignClosedItems.LookupResultValue as IContact).Id : null;
            object openSupportItemsReassignContact = lueReassignSupportItems.LookupResultValue != null
                                                         ? (lueReassignSupportItems.LookupResultValue as IContact).Id
                                                         : null;
            //Attachment Options
            moveOption = new MoveItemOption
            {
                Entity        = "Attachment",
                ReassignTo    = openItemsReassignContact,
                MoveToAccount = false
            };
            arguments.Items.Add(moveOption);

            //Literature Requests Options
            moveOption = new MoveItemOption
            {
                Entity           = "LitRequest",
                OpenItemsOnly    = true,
                ClosedItemsOnly  = true,
                ReassignTo       = openItemsReassignContact,
                ReassignToClosed = closedItemsReassignContact,
                MoveToAccount    = false
            };
            arguments.Items.Add(moveOption);

            //Opportunity Options
            moveOption = new MoveItemOption
            {
                Entity           = "OpportunityContact",
                OpenItemsOnly    = true,
                ClosedItemsOnly  = true,
                ReassignTo       = openItemsReassignContact,
                ReassignToClosed = closedItemsReassignContact,
                MoveToAccount    = false
            };
            arguments.Items.Add(moveOption);

            //Sales Order Options
            moveOption = new MoveItemOption
            {
                Entity        = "SalesOrder",
                OpenItemsOnly = true,
                ReassignTo    = openItemsReassignContact,
                MoveToAccount = false
            };
            arguments.Items.Add(moveOption);

            //Ticket Options
            moveOption = new MoveItemOption
            {
                Entity        = "Ticket",
                ReassignTo    = openSupportItemsReassignContact,
                OpenItemsOnly = true,
                MoveToAccount = false
            };
            arguments.Items.Add(moveOption);
            //Return Options
            moveOption = new MoveItemOption
            {
                Entity        = "Return",
                ReassignTo    = openSupportItemsReassignContact,
                OpenItemsOnly = true,
                MoveToAccount = false
            };
            arguments.Items.Add(moveOption);
            //Contract Options
            moveOption = new MoveItemOption
            {
                Entity        = "Contract",
                ReassignTo    = openSupportItemsReassignContact,
                OpenItemsOnly = true,
                MoveToAccount = false
            };
            arguments.Items.Add(moveOption);

            Contact.MoveContact(arguments);

            // redirect back to page so new info can be displayed
            if (Contact.Id != null)
            {
                Response.Redirect(string.Format("Contact.aspx?entityId={0}", (Contact.Id)), false);
            }
        }
        catch (Exception ex)
        {
            string sSlxErrorId = null;
            var    sMsg        = ErrorHelper.GetClientErrorHtmlMessage(ex, ref sSlxErrorId);
            if (!string.IsNullOrEmpty(sSlxErrorId))
            {
                log.Error(ErrorHelper.AppendSlxErrorId("The call to SmartParts_Contact_MoveContact.cmdOK_Click failed", sSlxErrorId),
                          ex);
            }
            DialogService.ShowHtmlMessage(sMsg, ErrorHelper.IsDevelopmentContext() ? 600 : -1,
                                          ErrorHelper.IsDevelopmentContext() ? 800 : -1);
        }
    }