Esempio n. 1
0
        public async Task <TicketSource> Get(long Id)
        {
            TicketSource TicketSource = await DataContext.TicketSource.AsNoTracking()
                                        .Where(x => x.Id == Id).Select(x => new TicketSource()
            {
                CreatedAt   = x.CreatedAt,
                UpdatedAt   = x.UpdatedAt,
                Id          = x.Id,
                Name        = x.Name,
                OrderNumber = x.OrderNumber,
                StatusId    = x.StatusId,
                Used        = x.Used,
                Status      = x.Status == null ? null : new Status
                {
                    Id   = x.Status.Id,
                    Code = x.Status.Code,
                    Name = x.Status.Name,
                },
            }).FirstOrDefaultAsync();

            if (TicketSource == null)
            {
                return(null);
            }

            return(TicketSource);
        }
Esempio n. 2
0
        /// <summary>
        /// 检查应用的认证Cookie是否有效。如果失效,根据autoRedirect参数来决定是否转到认证页面
        /// </summary>
        /// <param name="autoRedirect">是否自动转到认证页面</param>
        public static void CheckAuthenticated(bool autoRedirect)
        {
            Common.CheckHttpContext();
            HttpContext context = HttpContext.Current;

            TicketSource ticketSource = TicketSource.Unknown;
            ITicket      ticket       = GetTicket(out ticketSource);

            if (IsTicketValid(ticket) == false)
            {
                if (autoRedirect)
                {
                    context.Response.Redirect(GetSignInPageUrl(GetReturnUrl()));
                }
            }
            else
            {
                //票据合法
                ticket.SaveToCookie();
                ticket.SaveToHeader();

                //如果不是来源于cookie,说明来源于url。是从认证页面post过来的,直接转到应用页面即可。
                if (ticketSource != TicketSource.FromCookie && ticketSource != TicketSource.FromHeader)
                {
                    if (PassportClientSettings.GetConfig().Method == TicketTransferMethod.HttpPost &&
                        string.Compare(context.Request.HttpMethod, "POST", true) == 0)
                    {
                        context.Response.Redirect(context.Request.Url.ToString());
                    }
                }
            }
        }
Esempio n. 3
0
        public async Task <ActionResult <TicketSource_TicketSourceDTO> > Create([FromBody] TicketSource_TicketSourceDTO TicketSource_TicketSourceDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            if (!await HasPermission(TicketSource_TicketSourceDTO.Id))
            {
                return(Forbid());
            }

            TicketSource TicketSource = ConvertDTOToEntity(TicketSource_TicketSourceDTO);

            TicketSource = await TicketSourceService.Create(TicketSource);

            TicketSource_TicketSourceDTO = new TicketSource_TicketSourceDTO(TicketSource);
            if (TicketSource.IsValidated)
            {
                return(TicketSource_TicketSourceDTO);
            }
            else
            {
                return(BadRequest(TicketSource_TicketSourceDTO));
            }
        }
Esempio n. 4
0
 public async Task <bool> Delete(TicketSource TicketSource)
 {
     if (await ValidateId(TicketSource))
     {
     }
     return(TicketSource.IsValidated);
 }
Esempio n. 5
0
        public async Task <bool> Delete(TicketSource TicketSource)
        {
            await DataContext.TicketSource.Where(x => x.Id == TicketSource.Id).UpdateFromQueryAsync(x => new TicketSourceDAO {
                DeletedAt = StaticParams.DateTimeNow
            });

            return(true);
        }
Esempio n. 6
0
 public async Task <bool> Update(TicketSource TicketSource)
 {
     if (await ValidateId(TicketSource))
     {
         await ValidateName(TicketSource);
     }
     return(TicketSource.IsValidated);
 }
Esempio n. 7
0
        public async Task <TicketSource> Get(long Id)
        {
            TicketSource TicketSource = await UOW.TicketSourceRepository.Get(Id);

            if (TicketSource == null)
            {
                return(null);
            }
            return(TicketSource);
        }
Esempio n. 8
0
        /// <summary>
        /// Redeems the ticket.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        public RedeemResult RedeemTicket(int id)
        {
            RedeemResult result = new RedeemResult(TicketSource.RedeemTicket(id));

            AsyncHelper.FireAsync(TicketRedeemed, this, new TicketEventArgs(id, TicketSource, Client.Address)
            {
                Result = result
            });

            return(result);
        }
Esempio n. 9
0
 public async Task <bool> ValidateName(TicketSource TicketSource)
 {
     if (string.IsNullOrWhiteSpace(TicketSource.Name))
     {
         TicketSource.AddError(nameof(TicketSourceValidator), nameof(TicketSource.Name), ErrorCode.NameEmpty);
     }
     else if (TicketSource.Name.Length > 255)
     {
         TicketSource.AddError(nameof(TicketSourceValidator), nameof(TicketSource.Name), ErrorCode.NameOverLength);
     }
     return(TicketSource.IsValidated);
 }
Esempio n. 10
0
 public TicketSource_TicketSourceDTO(TicketSource TicketSource)
 {
     this.Id          = TicketSource.Id;
     this.Name        = TicketSource.Name;
     this.OrderNumber = TicketSource.OrderNumber;
     this.StatusId    = TicketSource.StatusId;
     this.Used        = TicketSource.Used;
     this.Status      = TicketSource.Status == null ? null : new TicketSource_StatusDTO(TicketSource.Status);
     this.CreatedAt   = TicketSource.CreatedAt;
     this.UpdatedAt   = TicketSource.UpdatedAt;
     this.Errors      = TicketSource.Errors;
 }
Esempio n. 11
0
        private ITicket CheckAuthenticatedAndGetTicket()
        {
            AuthenticateDirElement aDir =
                AuthenticateDirSettings.GetConfig().AuthenticateDirs.GetMatchedElement <AuthenticateDirElement>();

            bool autoRedirect = (aDir == null || aDir.AutoRedirect);

            PassportManager.CheckAuthenticated(autoRedirect);

            TicketSource ticketSource = TicketSource.Unknown;

            return(PassportManager.GetTicket(out ticketSource));
        }
Esempio n. 12
0
        public async Task <TicketSource> Create(TicketSource TicketSource)
        {
            if (!await TicketSourceValidator.Create(TicketSource))
            {
                return(TicketSource);
            }

            try
            {
                await UOW.Begin();

                TicketSourceFilter TicketSourceFilter = new TicketSourceFilter
                {
                    Take      = 1,
                    Selects   = TicketSourceSelect.ALL,
                    OrderBy   = TicketSourceOrder.OrderNumber,
                    OrderType = OrderType.DESC
                };
                if (TicketSource.OrderNumber == 0)
                {
                    List <TicketSource> TicketSources = await UOW.TicketSourceRepository.List(TicketSourceFilter);

                    TicketSource.OrderNumber = TicketSources.Any() ? TicketSources.Max(c => c.OrderNumber) + 1 : 1;
                }

                await UOW.TicketSourceRepository.Create(TicketSource);

                await UOW.Commit();

                TicketSource = await UOW.TicketSourceRepository.Get(TicketSource.Id);

                await Logging.CreateAuditLog(TicketSource, new { }, nameof(TicketSourceService));

                return(TicketSource);
            }
            catch (Exception ex)
            {
                if (ex.InnerException == null)
                {
                    await Logging.CreateSystemLog(ex, nameof(TicketSourceService));

                    throw new MessageException(ex);
                }
                else
                {
                    await Logging.CreateSystemLog(ex.InnerException, nameof(TicketSourceService));

                    throw new MessageException(ex.InnerException);
                }
            }
        }
Esempio n. 13
0
        /// <summary>
        /// 从Cookie中得到Ticket
        /// </summary>
        /// <returns><see cref="ITicket"/> 对象。</returns>
        public static ITicket GetTicket(out TicketSource tickedSource)
        {
            tickedSource = TicketSource.Unknown;

            Common.CheckHttpContext();

            HttpContext context = HttpContext.Current;

            ITicket ticket = null;

            if (PassportClientSettings.GetConfig().Method == TicketTransferMethod.HttpPost &&
                string.Compare(context.Request.HttpMethod, "POST", true) == 0)
            {
                tickedSource = TicketSource.FromForm;
                ticket       = Ticket.LoadFromForm();
            }
            else
            {
                tickedSource = TicketSource.FromUrl;
                ticket       = Ticket.LoadFromUrl();
            }

            if (IsTicketValid(ticket) == false)
            {
                tickedSource = TicketSource.FromHeader;
                ticket       = Ticket.LoadFromHeader();

                if (IsTicketValid(ticket) == false)
                {
                    tickedSource = TicketSource.FromCookie;

                    ticket = Ticket.LoadFromCookie();   //从Cookie中加载Ticket

                    if (ticket != null)
                    {
                        Trace.WriteLine(string.Format("从cookie中找到用户{0}的ticket", ticket.SignInInfo.UserID), "PassportSDK");
                    }
                    else
                    {
                        tickedSource = TicketSource.Unknown;
                    }
                }
            }

            if (IsTicketValid(ticket) == true)
            {
                AdjustSignInTimeout(ticket);
            }

            return(ticket);
        }
Esempio n. 14
0
        public Customer_TicketSourceDTO(TicketSource TicketSource)
        {
            this.Id = TicketSource.Id;

            this.Name = TicketSource.Name;

            this.OrderNumber = TicketSource.OrderNumber;

            this.StatusId = TicketSource.StatusId;

            this.Used = TicketSource.Used;

            this.Errors = TicketSource.Errors;
        }
Esempio n. 15
0
        public async Task <ActionResult <TicketSource_TicketSourceDTO> > Get([FromBody] TicketSource_TicketSourceDTO TicketSource_TicketSourceDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            if (!await HasPermission(TicketSource_TicketSourceDTO.Id))
            {
                return(Forbid());
            }

            TicketSource TicketSource = await TicketSourceService.Get(TicketSource_TicketSourceDTO.Id);

            return(new TicketSource_TicketSourceDTO(TicketSource));
        }
Esempio n. 16
0
        /// <summary>
        /// Gets the ticket with the specific code.
        /// </summary>
        /// <param name="code">The code.</param>
        /// <returns></returns>
        public Ticket GetTicket(string code)
        {
            Trace.WriteLine("Ticket requested: " + code);

            ITicket sourceTicket = TicketSource.GetTicket(code);

            if (sourceTicket == null)
            {
                return(null);
            }

            Ticket ticket = new Ticket(sourceTicket);

            AsyncHelper.FireAsync(TicketRequested, this, new TicketEventArgs(sourceTicket, Client.Address));

            return(ticket);
        }
Esempio n. 17
0
        private TicketSource ConvertDTOToEntity(TicketSource_TicketSourceDTO TicketSource_TicketSourceDTO)
        {
            TicketSource TicketSource = new TicketSource();

            TicketSource.Id          = TicketSource_TicketSourceDTO.Id;
            TicketSource.Name        = TicketSource_TicketSourceDTO.Name;
            TicketSource.OrderNumber = TicketSource_TicketSourceDTO.OrderNumber;
            TicketSource.StatusId    = TicketSource_TicketSourceDTO.StatusId;
            TicketSource.Used        = TicketSource_TicketSourceDTO.Used;
            TicketSource.Status      = TicketSource_TicketSourceDTO.Status == null ? null : new Status
            {
                Id   = TicketSource_TicketSourceDTO.Status.Id,
                Code = TicketSource_TicketSourceDTO.Status.Code,
                Name = TicketSource_TicketSourceDTO.Status.Name,
            };
            TicketSource.BaseLanguage = CurrentContext.Language;
            return(TicketSource);
        }
Esempio n. 18
0
        public async Task <bool> Create(TicketSource TicketSource)
        {
            TicketSourceDAO TicketSourceDAO = new TicketSourceDAO();

            TicketSourceDAO.Id          = TicketSource.Id;
            TicketSourceDAO.Name        = TicketSource.Name;
            TicketSourceDAO.OrderNumber = TicketSource.OrderNumber;
            TicketSourceDAO.StatusId    = TicketSource.StatusId;
            TicketSourceDAO.Used        = TicketSource.Used;
            TicketSourceDAO.CreatedAt   = StaticParams.DateTimeNow;
            TicketSourceDAO.UpdatedAt   = StaticParams.DateTimeNow;
            DataContext.TicketSource.Add(TicketSourceDAO);
            await DataContext.SaveChangesAsync();

            TicketSource.Id = TicketSourceDAO.Id;
            await SaveReference(TicketSource);

            return(true);
        }
Esempio n. 19
0
        public async Task <bool> ValidateId(TicketSource TicketSource)
        {
            TicketSourceFilter TicketSourceFilter = new TicketSourceFilter
            {
                Skip = 0,
                Take = 10,
                Id   = new IdFilter {
                    Equal = TicketSource.Id
                },
                Selects = TicketSourceSelect.Id
            };

            int count = await UOW.TicketSourceRepository.Count(TicketSourceFilter);

            if (count == 0)
            {
                TicketSource.AddError(nameof(TicketSourceValidator), nameof(TicketSource.Id), ErrorCode.IdNotExisted);
            }
            return(count == 1);
        }
Esempio n. 20
0
        public async Task <bool> Update(TicketSource TicketSource)
        {
            TicketSourceDAO TicketSourceDAO = DataContext.TicketSource.Where(x => x.Id == TicketSource.Id).FirstOrDefault();

            if (TicketSourceDAO == null)
            {
                return(false);
            }
            TicketSourceDAO.Id          = TicketSource.Id;
            TicketSourceDAO.Name        = TicketSource.Name;
            TicketSourceDAO.OrderNumber = TicketSource.OrderNumber;
            TicketSourceDAO.StatusId    = TicketSource.StatusId;
            TicketSourceDAO.Used        = TicketSource.Used;
            TicketSourceDAO.UpdatedAt   = StaticParams.DateTimeNow;
            await DataContext.SaveChangesAsync();

            await SaveReference(TicketSource);

            return(true);
        }
Esempio n. 21
0
        public async Task <TicketSource> Update(TicketSource TicketSource)
        {
            if (!await TicketSourceValidator.Update(TicketSource))
            {
                return(TicketSource);
            }
            try
            {
                var oldData = await UOW.TicketSourceRepository.Get(TicketSource.Id);

                await UOW.Begin();

                await UOW.TicketSourceRepository.Update(TicketSource);

                await UOW.Commit();

                TicketSource = await UOW.TicketSourceRepository.Get(TicketSource.Id);

                await Logging.CreateAuditLog(TicketSource, oldData, nameof(TicketSourceService));

                return(TicketSource);
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

                if (ex.InnerException == null)
                {
                    await Logging.CreateSystemLog(ex, nameof(TicketSourceService));

                    throw new MessageException(ex);
                }
                else
                {
                    await Logging.CreateSystemLog(ex.InnerException, nameof(TicketSourceService));

                    throw new MessageException(ex.InnerException);
                }
            }
        }
        public CreateTicketRequest(TicketStatus status, TicketPriority priority, TicketSource source, string description, string?requesterName = null,
                                   long?requesterId = null, string?email            = null, string?facebookId = null, string?phoneNumber = null,
                                   string?twitterId = null, string?uniqueExternalId = null, long?responderId  = null, string[]?ccEmails  = null,
                                   Dictionary <string, object>?customFields = null, DateTimeOffset?dueBy = null, long?emailConfigId = null,
                                   DateTimeOffset?firstResponseDueBy        = null, long?groupId = null, long?productId = null, string[]?tags = null,
                                   long?companyId = null, string?subject = null, string?ticketType = null, long?parentTicketId                = null,
                                   IEnumerable <FileAttachment>?files = null)
        {
            if (!requesterId.HasValue && email == null && facebookId == null && phoneNumber == null && twitterId == null && uniqueExternalId == null)
            {
                throw new ArgumentException("You must set at least one of requesterId, email, facebookId, phoneNumber, twitterId, uniqueExternalId to denote the requester");
            }

            Status             = status;
            Priority           = priority;
            Source             = source;
            RequesterName      = requesterName;
            Email              = email;
            FacebookId         = facebookId;
            PhoneNumber        = phoneNumber;
            TwitterId          = twitterId;
            UniqueExternalId   = uniqueExternalId;
            Description        = description;
            RequesterId        = requesterId;
            ResponderId        = responderId;
            CcEmails           = ccEmails;
            CustomFields       = customFields;
            DueBy              = dueBy;
            EmailConfigId      = emailConfigId;
            FirstResponseDueBy = firstResponseDueBy;
            GroupId            = groupId;
            ProductId          = productId;
            Tags           = tags;
            CompanyId      = companyId;
            Subject        = subject;
            TicketType     = ticketType;
            ParentTicketId = parentTicketId;
            Files          = files;
        }
Esempio n. 23
0
        /// <summary>
        /// Handles the TicketCreated event of the ticketControlView 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 ticketControlView_TicketCreated(object sender, EventArgs e)
        {
            ITicket ticket = (e as TicketEventArgs).Ticket;

            if (TicketSource.AddTicket(ticket))
            {
                ticket = TicketSource.AllTickets.First(t => t.Code == ticket.Code);
                listBoxTickets.SelectedItem = ticket;
                listBoxTickets.ScrollIntoView(ticket);
            }
            else
            {
                TaskDialog dialog = new TaskDialog();
                dialog.Caption           = Properties.Resources.TicketAddFailedCaption;
                dialog.ExpansionMode     = TaskDialogExpandedDetailsLocation.Hide;
                dialog.Icon              = TaskDialogStandardIcon.Error;
                dialog.OwnerWindowHandle = new WindowInteropHelper(Window.GetWindow(this)).Handle;
                dialog.StandardButtons   = TaskDialogStandardButtons.Ok;
                dialog.StartupLocation   = TaskDialogStartupLocation.CenterOwner;
                dialog.InstructionText   = Properties.Resources.TicketAddFailedHeader;
                dialog.Text              = Properties.Resources.TicketAddFailedText;
                dialog.Show();
            }
        }
Esempio n. 24
0
        public async Task <bool> Create(TicketSource TicketSource)
        {
            await ValidateName(TicketSource);

            return(TicketSource.IsValidated);
        }
Esempio n. 25
0
 public ChannelCreateTicketRequest(long importId, TicketStatus status, TicketPriority priority, TicketSource source, string description,
                                   string?requesterName = null, long?requesterId        = null, string?email     = null, string?facebookId = null, string?phoneNumber = null,
                                   string?twitterId     = null, string?uniqueExternalId = null, long?responderId = null, string[]?ccEmails = null,
                                   Dictionary <string, object>?customFields = null, DateTimeOffset?dueBy = null, long?emailConfigId = null,
                                   DateTimeOffset?firstResponseDueBy        = null, long?groupId = null, long?productId = null, string[]?tags = null,
                                   long?companyId           = null, string?subject = null, string?ticketType = null, long?parentTicketId      = null, DateTimeOffset?createdAt = null,
                                   DateTimeOffset?updatedAt = null) : base(status, priority, source, description, requesterName, requesterId, email, facebookId, phoneNumber, twitterId, uniqueExternalId, responderId, ccEmails, customFields, dueBy, emailConfigId, firstResponseDueBy, groupId, productId, tags, companyId, subject, ticketType, parentTicketId)
 {
     ImportId  = importId;
     CreatedAt = createdAt;
     UpdatedAt = updatedAt;
 }
Esempio n. 26
0
 private async Task SaveReference(TicketSource TicketSource)
 {
 }
Esempio n. 27
0
        public async Task <ActionResult> Import(IFormFile file)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }
            StatusFilter StatusFilter = new StatusFilter
            {
                Skip    = 0,
                Take    = int.MaxValue,
                Selects = StatusSelect.ALL
            };
            List <Status> Statuses = await StatusService.List(StatusFilter);

            List <TicketSource> TicketSources = new List <TicketSource>();

            using (ExcelPackage excelPackage = new ExcelPackage(file.OpenReadStream()))
            {
                ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets.FirstOrDefault();
                if (worksheet == null)
                {
                    return(Ok(TicketSources));
                }
                int StartColumn       = 1;
                int StartRow          = 1;
                int IdColumn          = 0 + StartColumn;
                int NameColumn        = 1 + StartColumn;
                int OrderNumberColumn = 2 + StartColumn;
                int StatusIdColumn    = 3 + StartColumn;
                int UsedColumn        = 7 + StartColumn;

                for (int i = StartRow; i <= worksheet.Dimension.End.Row; i++)
                {
                    if (string.IsNullOrEmpty(worksheet.Cells[i + StartRow, StartColumn].Value?.ToString()))
                    {
                        break;
                    }
                    string IdValue          = worksheet.Cells[i + StartRow, IdColumn].Value?.ToString();
                    string NameValue        = worksheet.Cells[i + StartRow, NameColumn].Value?.ToString();
                    string OrderNumberValue = worksheet.Cells[i + StartRow, OrderNumberColumn].Value?.ToString();
                    string StatusIdValue    = worksheet.Cells[i + StartRow, StatusIdColumn].Value?.ToString();
                    string UsedValue        = worksheet.Cells[i + StartRow, UsedColumn].Value?.ToString();

                    TicketSource TicketSource = new TicketSource();
                    TicketSource.Name        = NameValue;
                    TicketSource.OrderNumber = long.TryParse(OrderNumberValue, out long OrderNumber) ? OrderNumber : 0;
                    Status Status = Statuses.Where(x => x.Id.ToString() == StatusIdValue).FirstOrDefault();
                    TicketSource.StatusId = Status == null ? 0 : Status.Id;
                    TicketSource.Status   = Status;

                    TicketSources.Add(TicketSource);
                }
            }
            TicketSources = await TicketSourceService.Import(TicketSources);

            if (TicketSources.All(x => x.IsValidated))
            {
                return(Ok(true));
            }
            else
            {
                List <string> Errors = new List <string>();
                for (int i = 0; i < TicketSources.Count; i++)
                {
                    TicketSource TicketSource = TicketSources[i];
                    if (!TicketSource.IsValidated)
                    {
                        string Error = $"Dòng {i + 2} có lỗi:";
                        if (TicketSource.Errors.ContainsKey(nameof(TicketSource.Id)))
                        {
                            Error += TicketSource.Errors[nameof(TicketSource.Id)];
                        }
                        if (TicketSource.Errors.ContainsKey(nameof(TicketSource.Name)))
                        {
                            Error += TicketSource.Errors[nameof(TicketSource.Name)];
                        }
                        if (TicketSource.Errors.ContainsKey(nameof(TicketSource.OrderNumber)))
                        {
                            Error += TicketSource.Errors[nameof(TicketSource.OrderNumber)];
                        }
                        if (TicketSource.Errors.ContainsKey(nameof(TicketSource.StatusId)))
                        {
                            Error += TicketSource.Errors[nameof(TicketSource.StatusId)];
                        }
                        if (TicketSource.Errors.ContainsKey(nameof(TicketSource.Used)))
                        {
                            Error += TicketSource.Errors[nameof(TicketSource.Used)];
                        }
                        Errors.Add(Error);
                    }
                }
                return(BadRequest(Errors));
            }
        }
Esempio n. 28
0
        /// <summary>
        /// 获取登录或注销的url,设置url中的认证后重定向的returnUrl,设置注销后重定向的logOffAutoRedirect
        /// </summary>
        /// <param name="returnUrl">认证后重定向的地址</param>
        /// <param name="logOffAutoRedirect">是否注销后重定向</param>
        /// <param name="logOffAll">是否注销所有应用</param>
        /// <returns>登录或是注销url</returns>
        public static string GetLogOnOrLogOffUrl(string returnUrl, bool logOffAutoRedirect, bool logOffAll)
        {
            Common.CheckHttpContext();

            if (returnUrl.IsNullOrEmpty())
            {
                returnUrl = UriHelper.RemoveUriParams(HttpContext.Current.Request.Url.ToString(), "t");
            }

            returnUrl = ChangeToAbsoluteUrl(returnUrl);

            string strResult = string.Empty;

            TicketSource ticketSource = TicketSource.Unknown;
            ITicket      ticket       = GetTicket(out ticketSource);

            HttpContext context = HttpContext.Current;
            HttpRequest request = context.Request;

            PassportClientSettings settings = PassportClientSettings.GetConfig();
            string strPassportPath          = settings.SignInUrl.ToString();

            int nSplit = strPassportPath.LastIndexOf("/");

            strPassportPath = strPassportPath.Substring(0, nSplit + 1);

            if (IsTicketValid(ticket) == true)
            {
                StringBuilder strB = new StringBuilder(1024);

                strB.Append(settings.LogOffUrl);

                if (settings.LogOffUrl.ToString().IndexOf("?") == -1)
                {
                    strB.Append("?");
                }
                else
                {
                    strB.Append("&");
                }

                NameValueCollection parameters = new NameValueCollection();

                parameters.Add("asid", ticket.SignInInfo.SignInSessionID);
                parameters.Add("ru", returnUrl);
                parameters.Add("lar", logOffAutoRedirect.ToString().ToLower());
                parameters.Add("appID", ticket.AppID);
                parameters.Add("lou", GetLogOffCallBackUrl().ToString());
                parameters.Add("loa", logOffAll.ToString().ToLower());
                parameters.Add("wi", ticket.SignInInfo.WindowsIntegrated.ToString().ToLower());
                parameters.Add("lu", ticket.SignInInfo.OriginalUserID);

                if (TenantContext.Current.Enabled)
                {
                    parameters.Add(TenantExtensions.TenantCodeParamName, TenantContext.Current.TenantCode);
                }

                strB.Append(parameters.ToUrlParameters(true));

                strResult = strB.ToString();
            }
            else
            {
                strResult = GetSignInPageUrl(returnUrl);
            }

            return(strResult);
        }