Exemplo n.º 1
0
        private void CheckExternal()
        {
            if (ExternalLogin != null && ExternalID != null)
            {
                try
                {
                    if (Mediachase.IBN.Business.Configuration.LicenseExpired)
                    {
                        throw new Mediachase.Ibn.LicenseExpiredException();
                    }

                    int    EUserID = Security.UserLoginByExternalGate((int)ExternalObjectType, ExternalObjectID, ExternalID, ExternalLogin);
                    string path    = HttpRuntime.AppDomainAppVirtualPath;
                    if (path == "/")
                    {
                        path = "";
                    }
                    SetAuthCookie(path + "/External", ExternalLogin, false, EUserID);
                    HttpContext.Current.Items.Remove("userlight");
                    UserLight userLight            = UserLight.Load(EUserID);
                    UserLightPropertyCollection pc = userLight.Properties;
                    HttpContext context            = HttpContext.Current;
                    context.Items.Add("userlight", userLight);

                    //Response.Redirect(Server.UrlDecode(Request["ReturnUrl"]));
                    // O.R. [2008-04-15]
                    Response.Redirect(Request["ReturnUrl"], true);
                }
                catch
                {
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the file locked user id.
        /// </summary>
        /// <param name="fileUrl">The file URL.</param>
        /// <returns></returns>
        public static UserLight GetFileLockedUserId(string fileUrl)
        {
            UserLight retVal = null;

            try
            {
                WebDavTicket          ticket   = WebDavUrlBuilder.GetWebDavTicket(fileUrl);
                WebDavAbstractFactory factory  = new WebDavAbstractFactory();
                WebDavPropertyStorage provider =
                    factory.Create <WebDavElementStorageProvider>(ticket.AbsolutePath.StorageType) as WebDavPropertyStorage;
                if (provider != null)
                {
                    WebDavElementInfo elInfo = provider.GetElementInfo(ticket.ToString());
                    foreach (ActiveLockElement activeLock in provider.GetActiveLocks(elInfo))
                    {
                        UserLight user = UserLight.Load(activeLock.Owner);
                        if (user != null)
                        {
                            retVal = user;
                            break;
                        }
                    }
                }
            }
            catch (System.Exception)
            {
            }

            return(retVal);
        }
Exemplo n.º 3
0
        private void CheckExternal(string _containerKey)
        {
            if (!String.IsNullOrEmpty(ExtId))
            {
                try
                {
                    string[] mas          = _containerKey.Split('_');
                    int      ObjectTypeId = -1;
                    switch (mas[0].ToLower())
                    {
                    case "taskid":
                        ObjectTypeId = (int)ObjectTypes.Task;
                        break;

                    case "todoid":
                        ObjectTypeId = (int)ObjectTypes.ToDo;
                        break;

                    case "eventid":
                        ObjectTypeId = (int)ObjectTypes.CalendarEntry;
                        break;

                    case "documentid":
                    case "documentvers":
                        ObjectTypeId = (int)ObjectTypes.Document;
                        break;

                    case "incidentid":
                        ObjectTypeId = (int)ObjectTypes.Issue;
                        break;

                    default:
                        break;
                    }
                    if (Mediachase.IBN.Business.User.CheckUserIdByExternalGate(ObjectTypeId, int.Parse(mas[1]), int.Parse(ExtId)))
                    {
                        UserLight   userLight = UserLight.Load(int.Parse(ExtId));
                        HttpContext context   = HttpContext.Current;
                        context.Items.Add("userlight", userLight);
                    }
                    else
                    {
                        throw new AccessDeniedException();
                    }
                }
                catch
                {
                    throw new AccessDeniedException();
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Generates the list channel items.
        /// </summary>
        /// <param name="rssChannel">The RSS channel.</param>
        /// <returns></returns>
        private string GenerateListChannelItems(RssChannel rssChannel)
        {
            DateTime lastBuildDate = DateTime.MinValue;

            MetaClass listMetaClass = DataContext.Current.GetMetaClass(this.Parameters.ClassName);

            foreach (EntityObject item in BusinessManager.List(this.Parameters.ClassName,
                                                               this.CurrentProfile.Filters.ToArray(),
                                                               this.CurrentProfile.Sorting.ToArray()))
            {
                RssItem rssItem = new RssItem();
                rssItem.Guid = new RssGuid();

                rssItem.Title = string.IsNullOrEmpty(listMetaClass.TitleFieldName) ?
                                ("#" + item.PrimaryKeyId.Value.ToString()) :
                                (string)item[listMetaClass.TitleFieldName];

                rssItem.Link             = MakeFullLink(this.Page.ResolveUrl(string.Format(CultureInfo.CurrentUICulture, "~/Apps/MetaUIEntity/Pages/EntityList.aspx?ClassName={0}", listMetaClass.Name)));
                rssItem.Guid.IsPermaLink = "false";
                rssItem.Guid.Text        = item.PrimaryKeyId.Value.ToString();

                rssItem.Description = RenderListEntityObjectDescription(listMetaClass, item);

                DateTime modified = (DateTime)item["Modified"];

                if (modified > lastBuildDate)
                {
                    lastBuildDate = modified;
                }

                rssItem.PubDate = RssXmlHelper.ToRfc822(modified);
                UserLight author = UserLight.Load((int)item["ModifierId"]);
                if (author != null)
                {
                    rssItem.Author = string.Format("{0} <{1}>", author.DisplayName, author.Email);
                }

                rssChannel.Items.Add(rssItem);
            }

            if (lastBuildDate == DateTime.MinValue)
            {
                lastBuildDate = DateTime.Now;
            }

            return(RssXmlHelper.ToRfc822(lastBuildDate));
        }
Exemplo n.º 5
0
        private void CheckQueryLogin()
        {
            if (RegularLogin != null && RegularPassword != null && RegularRedirect != null)
            {
                try
                {
                    int iUserId = Security.UserLogin(RegularLogin, RegularPassword);

                    if (Mediachase.IBN.Business.Configuration.LicenseExpired)
                    {
                        throw new Mediachase.Ibn.LicenseExpiredException();
                    }

                    // !! Authorisation cookie
                    SetAuthCookie(HttpRuntime.AppDomainAppVirtualPath, RegularLogin, false, iUserId);
                    // not rederect
                    UserLight userLight            = UserLight.Load(iUserId);
                    UserLightPropertyCollection pc = userLight.Properties;
                    HttpContext context            = HttpContext.Current;
                    context.Items.Add("userlight", userLight);

                    //Response.Redirect("~/" + Server.UrlDecode(RegularRedirect));
                    // O.R. [2008-04-15]
                    Response.Redirect("~/" + RegularRedirect);
                }
                catch (InvalidAccountException)
                {
                    Response.Redirect("~/Public/default.aspx");
                }
                catch (InvalidPasswordException)
                {
                    Response.Redirect("~/Public/default.aspx");
                }
                catch (NotActiveAccountException)
                {
                    Response.Redirect("~/Public/default.aspx");
                }
                catch (ExternalOrPendingAccountException)
                {
                    Response.Redirect("~/Public/default.aspx");
                }
                catch (Mediachase.Ibn.LicenseExpiredException)
                {
                    Response.Redirect("~/Public/default.aspx");
                }
            }
        }
Exemplo n.º 6
0
        private void CheckTicketLogin()
        {
            if (!String.IsNullOrEmpty(RegularLogin) && !String.IsNullOrEmpty(RegularTicket) && !String.IsNullOrEmpty(RegularRedirect))
            {
                try
                {
                    int iUserId = Security.UserLoginByTicket(RegularLogin, new Guid(RegularTicket));

                    if (Mediachase.IBN.Business.Configuration.LicenseExpired)
                    {
                        throw new Mediachase.Ibn.LicenseExpiredException();
                    }

                    // !! Authorisation cookie
                    SetAuthCookie(HttpRuntime.AppDomainAppVirtualPath, RegularLogin, false, iUserId);
                    // not rederect
                    UserLight userLight            = UserLight.Load(iUserId);
                    UserLightPropertyCollection pc = userLight.Properties;
                    HttpContext context            = HttpContext.Current;
                    context.Items.Add("userlight", userLight);

                    Response.Redirect("~/" + RegularRedirect);
                }
                catch (InvalidAccountException)
                {
                    Response.Redirect("~/Public/default.aspx");
                }
                catch (InvalidTicketException)
                {
                    Response.Redirect("~/Public/default.aspx");
                }
                catch (NotActiveAccountException)
                {
                    Response.Redirect("~/Public/default.aspx");
                }
                catch (ExternalOrPendingAccountException)
                {
                    Response.Redirect("~/Public/default.aspx");
                }
                catch (Mediachase.Ibn.LicenseExpiredException)
                {
                    Response.Redirect("~/Public/default.aspx");
                }
            }
        }
Exemplo n.º 7
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            string redirectUrl = "~/Public/WebLogin.aspx?" + Request.QueryString.ToString();

            string windowsUserName = Request.ServerVariables["LOGON_USER"];

            if (!string.IsNullOrEmpty(windowsUserName))             // Don't search for empty user name.
            {
                int userId = Security.UserLoginWindows(windowsUserName);
                if (userId > 0)
                {
                    string ibnUserName = GetIbnUserName(userId);
                    SetAuthCookie(HttpRuntime.AppDomainAppVirtualPath, ibnUserName);

                    if (Request["ReturnUrl"] == null)
                    {
                        UserLight userLight            = UserLight.Load(userId);
                        UserLightPropertyCollection pc = userLight.Properties;
                        HttpContext context            = HttpContext.Current;
                        if (context != null && context.Items.Contains("userlight"))
                        {
                            context.Items.Remove("userlight");
                        }

                        context.Items.Add("userlight", userLight);

                        if (Security.IsUserInGroup(InternalSecureGroups.Administrator) && PortalConfig.PortalShowAdminWizard)
                        {
                            redirectUrl = "~/Workspace/default.aspx?BTab=Workspace&AdminWizard=1";
                        }
                        else
                        {
                            redirectUrl = "~/Apps/Shell/Pages/default.aspx";
                        }
                    }
                    else
                    {
                        redirectUrl = Request["ReturnUrl"];
                    }
                }
            }

            Response.Redirect(redirectUrl, true);
        }
Exemplo n.º 8
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string    sFields  = iFields.Value;
            ArrayList alFields = new ArrayList();

            while (sFields.Length > 0)
            {
                string s = sFields.Substring(0, sFields.IndexOf(","));
                try
                {
                    int       UserId = int.Parse(s);
                    UserLight _ul    = UserLight.Load(UserId);
                    if (!alFields.Contains(_ul.Email))
                    {
                        alFields.Add(_ul.Email);
                    }
                }
                catch
                {
                    if (!alFields.Contains(s))
                    {
                        alFields.Add(s);
                    }
                }
                sFields = sFields.Remove(0, sFields.IndexOf(",") + 1);
            }
            sFields = "";
            foreach (string _smail in alFields)
            {
                string sName = GetNameByEMail(_smail);
                if (sName != "")
                {
                    sFields += String.Format("{0} <{1}>; ", sName, _smail);
                }
                else
                {
                    sFields += _smail + "; ";
                }
            }

            Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(),
                                                    "<script language=javascript>" +
                                                    "window.opener.updateEMails('" + sFields + "'); window.close();</script>");
        }
Exemplo n.º 9
0
        private static int TryBasicAuthentificate(string authorizationHeader)
        {
            int    retVal   = -1;
            String userName = String.Empty;
            String password = String.Empty;

            try
            {
                ExtractBasicCredentials(authorizationHeader, ref userName, ref password);
                retVal = Security.UserLogin(userName, password);
                UserLight user = UserLight.Load(retVal);
                Security.SetCurrentUser(user);
            }
            catch (System.Exception)
            {
            }

            return(retVal);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Creates this instance.
        /// </summary>
        /// <returns></returns>
        public ArrayList        Create()
        {
            ArrayList retVal = new ArrayList();

            //_createdToEmailList.Clear();

            foreach (object Recipient in _recipientList)
            {
                if (Recipient is string)
                {
                    if (!_createdToEmailList.ContainsKey(Recipient))
                    {
                        _createdToEmailList.Add(Recipient, null);

                        retVal.Add(CreateSingle((string)Recipient));
                    }
                }
                else if (Recipient is int)
                {
                    UserLight user = UserLight.Load((int)Recipient);

                    if (user.Email != null && user.Email != string.Empty &&
                        !_createdToEmailList.ContainsKey(user.Email))
                    {
                        _createdToEmailList.Add(user.Email, null);

                        NameValueCollection headers = new NameValueCollection();

                        if (_incidentId > 0)
                        {
                            Guid UserTicket = IncidentUserTicket.CreateAndReturnUID(user.UserID, _incidentId);

                            headers.Add("X-IBN-USERTICKET", UserTicket.ToString());
                            headers.Add("X-IBN-WEBSERVER", GetAbsolutePath("/WebServices/IncidentInfo.asmx"));
                        }

                        retVal.Add(CreateSingle(user.Email, headers));
                    }
                }
            }

            return(retVal);
        }
Exemplo n.º 11
0
        private static int TrySessionAuthentificate(Guid sessionId)
        {
            //По умолчанию не используем утентификацию из сессии если пользователь аутентифицирован
            int retVal = Security.CurrentUser != null ? Security.CurrentUser.UserID : -1;

            if (retVal == -1)
            {
                //Пытаемся получить id пользователя из сессии
                retVal = WebDavAuthHelper.GetUserIdByAuthToken(sessionId);
                if (retVal != -1)
                {
                    //аутентифицируем пользователя из сессии
                    UserLight user = UserLight.Load(retVal);
                    Security.SetCurrentUser(user);
                    //Refresh auth session
                    RefreshAuthSession(sessionId);
                }
            }
            return(retVal);
        }
Exemplo n.º 12
0
        //		public static string[] GetExternalSendersByIncidentId(int IncidentId)
        //		{
        //			return EMailMessageRow.GetExternalSendersByIncidentId(IncidentId);
        //		}

        /// <summary>
        /// Logs the on creator.
        /// </summary>
        /// <param name="DefaultCreatorId">The default creator id.</param>
        /// <param name="msg">The MSG.</param>
        /// <returns></returns>
        internal static UserLight LogOnCreator(int DefaultCreatorId, Pop3Message msg)
        {
            if (Security.CurrentUser != null)
            {
                return(Security.CurrentUser);
            }

            int creatorId = DefaultCreatorId;

            int emailUser = DBUser.GetUserByEmail(EMailMessage.GetSenderEmail(msg), false);

            if (emailUser > 0)
            {
                // OZ: 2007-01-26: Fix problem: Mediachase.IBN.Business.AccessDeniedException: Access denied.
                //   at Mediachase.IBN.Business.Incident.CreateFromEmail
                using (IDataReader reader = DBUser.GetUserInfo(emailUser))
                {
                    if (reader.Read())
                    {
                        if (!(bool)reader["IsActive"])
                        {
                            emailUser = -1;
                        }
                    }
                    else
                    {
                        emailUser = -1;
                    }
                }
                //
            }

            if (emailUser > 0)
            {
                creatorId = emailUser;
            }

            UserLight creator = UserLight.Load(creatorId);

            return(Security.SetCurrentUser(creator));
        }
Exemplo n.º 13
0
        protected string GetNameByEMail(string eMail)
        {
            int iUserId = Mediachase.IBN.Business.User.GetUserByEmail(eMail);

            if (iUserId > 0)
            {
                return(UserLight.Load(iUserId).DisplayName);
            }
            else
            {
                Mediachase.IBN.Business.Client client = Mediachase.IBN.Business.Common.GetClient(eMail);
                if (client != null)
                {
                    return(client.Name);
                }
                else
                {
                    return("");
                }
            }
        }
Exemplo n.º 14
0
        private void LoginAsDefaultUser(int iUserId, string sDefUser)
        {
            SetAuthCookie(HttpRuntime.AppDomainAppVirtualPath, sDefUser, false, iUserId);

            UserLight userLight            = UserLight.Load(iUserId);
            UserLightPropertyCollection pc = userLight.Properties;
            HttpContext context            = HttpContext.Current;

            if (context != null && context.Items.Contains("userlight"))
            {
                context.Items.Remove("userlight");
            }
            context.Items.Add("userlight", userLight);

            if (Request["ReturnUrl"] == null)
            {
                // not redirect
                if (Security.IsUserInGroup(InternalSecureGroups.Administrator))
                {
                    if (PortalConfig.PortalShowAdminWizard)
                    {
                        Response.Redirect("~/Workspace/default.aspx?BTab=Workspace&AdminWizard=1", true);
                        return;
                    }
                }

                Response.Redirect("~/Apps/Shell/Pages/default.aspx");
                return;
            }
            else
            {
                //Response.Redirect(Server.UrlDecode(Request["ReturnUrl"]));
                // O.R. [2008-04-15]
                Response.Redirect(Request["ReturnUrl"]);
                return;
            }
        }
Exemplo n.º 15
0
        public static void LogonUserByRssKey(Guid rssKey)
        {
            using (IDataReader reader = DBUser.GetUserInfoByRssKey(rssKey))
            {
                if (!reader.Read())
                {
                    throw new Mediachase.Ibn.AccessDeniedException();
                }

                int userId = (int)reader["UserId"];

                try
                {
                    string sUserLight = "userlight";

                    // check user's name and password here
                    UserLight currentUser = UserLight.Load(userId);
                    if (currentUser == null)
                    {
                        throw new Mediachase.Ibn.AccessDeniedException("Exception in user authentication");
                    }

                    if (HttpContext.Current.Items.Contains(sUserLight))
                    {
                        HttpContext.Current.Items.Remove(sUserLight);
                    }

                    HttpContext.Current.Items.Add(sUserLight, currentUser);
                    HttpContext.Current.User = new GenericPrincipal(new GenericIdentity(currentUser.Login), null);
                }
                catch (Exception ex)
                {
                    throw new Mediachase.Ibn.AccessDeniedException("Exception in user authentication", ex);
                }
            }
        }
Exemplo n.º 16
0
        public override void DataBind()
        {
            if (DataItem != null)
            {
                PropertyValueCollection properties = WorkflowActivityWrapper.GetAssignmentProperties(DataItem);

                object prop;

                // User
                prop = properties[AssignmentEntity.FieldUserId];
                if (prop != null)
                {
                    UserLight user = UserLight.Load((int)prop);
                    UserLabel.Text = user.DisplayName;
                }

                // Subject
                prop = properties[AssignmentEntity.FieldSubject];
                if (prop != null)
                {
                    SubjectLabel.Text = prop.ToString();
                }
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Gets the active locked webdav resources.
        /// </summary>
        /// <returns></returns>
        public static IEnumerable <WebDavLockInfo> GetActiveLocksInfo()
        {
            WebDavAbstractFactory factory = new WebDavAbstractFactory();

            foreach (WebDavStorageElementPropertiesRow row in WebDavStorageElementPropertiesRow.List())
            {
                WebDavElementStorageProvider provider = factory.Create <WebDavElementStorageProvider>(row.ObjectTypeId);
                ResourceInfo resInfo = GetResourceInfoFromPropertyRow(row);
                if (resInfo != null)
                {
                    foreach (ActiveLockElement activeLockEl in provider.GetActiveLocks(resInfo))
                    {
                        OpaqueLockToken lockToken = OpaqueLockToken.Parse(activeLockEl.LockToken.InnerText);
                        McLockElement   mcLockEl  = GetMcLockElement(lockToken, provider.GetProperties(resInfo));

                        WebDavLockInfo retval = new WebDavLockInfo();
                        retval.WebDavElementPropertyId = row.PrimaryKeyId.Value;
                        retval.FileName      = resInfo.Name;
                        retval.ContentTypeId = ContentTypeResolver.GetContentTypeId(resInfo.ContentType);
                        retval.StartLocking  = new DateTime(mcLockEl.CreationDate * TimeSpan.TicksPerSecond);
                        retval.Duration      = DateTime.UtcNow - retval.StartLocking;
                        UserLight user = UserLight.Load(activeLockEl.Owner);
                        if (user != null)
                        {
                            retval.LockedBy = user.DisplayName;
                        }
                        else
                        {
                            retval.LockedBy = "Unknow";
                        }

                        yield return(retval);
                    }
                }
            }
        }
Exemplo n.º 18
0
        protected void btnLogin_Click(object sender, System.EventArgs e)
        {
            string LoginString          = tbLogin.Text;
            string PasswordString       = tbPassword.Text;
            int    ClientTimeZoneOffset = int.Parse(hdnOffset.Value);

            if (LoginString.IndexOf("@") >= 0)
            {
                LoginString = LoginString.Substring(0, LoginString.IndexOf("@"));
            }

            try
            {
                if (Mediachase.IBN.Business.Configuration.LicenseExpired)
                {
                    throw new Mediachase.Ibn.LicenseExpiredException();
                }
                int iUserId = Security.UserLogin(LoginString, PasswordString);
                if (cbRemember.Checked)
                {
                    HttpCookie loginCookie = new HttpCookie("login", tbLogin.Text);
                    loginCookie.Expires = DateTime.Now.AddMonths(1);
                    loginCookie.Path    = HttpRuntime.AppDomainAppVirtualPath;
                    Response.Cookies.Add(loginCookie);
                }
                else
                if (Response.Cookies["login"] != null)
                {
                    HttpCookie cookie = Response.Cookies["login"];
                    cookie.Expires = DateTime.Now.AddYears(-10);
                }

                HttpCookie cbCookie = new HttpCookie("Remember", cbRemember.Checked.ToString());
                cbCookie.Path    = HttpRuntime.AppDomainAppVirtualPath;
                cbCookie.Expires = DateTime.Now.AddMonths(1);
                Response.Cookies.Add(cbCookie);

                int TimeZoneOffset       = 0;
                int TimeZoneOffsetLatest = 0;

                using (IDataReader rdr = User.GetUserPreferences(iUserId))
                {
                    if (rdr.Read())
                    {
                        TimeZoneOffset       = User.GetCurrentBias((int)rdr["TimeZoneId"]);
                        TimeZoneOffsetLatest = (int)rdr["TimeOffsetLatest"];
                    }
                }

                // !! Authorisation cookie
                SetAuthCookie(HttpRuntime.AppDomainAppVirtualPath, LoginString, false, iUserId);

                if (Request["ReturnUrl"] == null ||
                    Request["ReturnUrl"] == "/" ||
                    Request["ReturnUrl"].ToLower() == HttpRuntime.AppDomainAppVirtualPath.ToLower() ||
                    Request["ReturnUrl"].ToLower() == HttpRuntime.AppDomainAppVirtualPath.ToLower() + "/")
                {
                    // not rederect
                    UserLight userLight            = UserLight.Load(iUserId);
                    UserLightPropertyCollection pc = userLight.Properties;
                    HttpContext context            = HttpContext.Current;
                    context.Items.Add("userlight", userLight);

                    if (Security.IsUserInGroup(InternalSecureGroups.Administrator) && PortalConfig.PortalShowAdminWizard)
                    {
                        Response.Redirect("~/Workspace/default.aspx?BTab=Workspace&AdminWizard=1", true);
                        return;
                    }

                    // check for startup wizard

                    /*if (pc["USetup_ShowStartupWizard"]==null || pc["USetup_ShowStartupWizard"]=="True")
                     * {
                     *      // Show Startup Wizard
                     *      if (!Security.IsUserInGroup(InternalSecureGroups.Administrator))
                     *              Response.Redirect("~/Workspace/Default.aspx?BTab=Workspace&BTab=Workspace&wizard=1", true);
                     * }*/

                    // check for time zone
                    if (TimeZoneOffset != ClientTimeZoneOffset && TimeZoneOffsetLatest != ClientTimeZoneOffset)
                    {
                        //Response.Redirect("~/Directory/ChangeZone.aspx?TimeOffset=" + ClientTimeZoneOffset + "&ReturnUrl=" + Server.UrlEncode("~/Workspace/default.aspx?BTab=Workspace"), true);
                        // O.R. [2008-04-15]
                        Response.Redirect("~/Directory/ChangeZone.aspx?TimeOffset=" + ClientTimeZoneOffset, true);
                        return;
                    }

                    Response.Redirect("~/Apps/Shell/Pages/default.aspx");
                    return;
                }
                else
                {
                    if (TimeZoneOffset != ClientTimeZoneOffset && TimeZoneOffsetLatest != ClientTimeZoneOffset)
                    {
                        Response.Redirect("~/Directory/ChangeZone.aspx?TimeOffset=" + ClientTimeZoneOffset + "&ReturnUrl=" + Server.UrlEncode(Request["ReturnUrl"]), true);
                    }
                    else
                    {
                        //Response.Redirect(Server.UrlDecode(Request["ReturnUrl"]));
                        // O.R. [2008-04-15]
                        Response.Redirect(Request["ReturnUrl"]);
                    }
                    return;
                }
            }
            catch (Exception ex)
            {
                if (ex is InvalidAccountException ||
                    ex is InvalidPasswordException ||
                    ex is NotActiveAccountException ||
                    ex is ExternalOrPendingAccountException)
                {
                    lblPassword.Text = LocRM.GetString("InvalidLoginPassword");
                }
                else if (ex is Mediachase.Ibn.LicenseExpiredException)
                {
                    lblPassword.Text = LocRM.GetString("tLicExpired");
                }
                else
                {
                    throw ex;
                }

                //cvInvalidLogin.IsValid = false;
                //if (ex is InvalidAccountException
                //    || ex is InvalidPasswordException
                //    || ex is NotActiveAccountException
                //    || ex is ExternalOrPendingAccountException)
                //    cvInvalidLogin.ErrorMessage = LocRM.GetString("InvalidLoginPassword");
                //else if (ex is Mediachase.Ibn.LicenseExpiredException)
                //    cvInvalidLogin.ErrorMessage = LocRM.GetString("tLicExpired");
                //else throw ex;
            }
        }
Exemplo n.º 19
0
        private void BindSavedValues()
        {
            int managerId = -1;
            int projectId = ProjectId;

            if (DocumentId > 0)
            {
                using (IDataReader reader = Document.GetDocument(DocumentId))
                {
                    if (reader.Read())
                    {
                        if (reader["ProjectTitle"] != DBNull.Value)
                        {
                            lblProject.Text = reader["ProjectTitle"].ToString();
                        }
                        else
                        {
                            lblProject.Text = LocRM.GetString("ProjectNotSet");
                        }

                        Util.CommonHelper.SafeSelect(ddlPriority, reader["PriorityId"].ToString());
                        //					Util.CommonHelper.SafeSelect(ddlStatus, reader["StatusId"].ToString());

                        txtTitle.Text       = HttpUtility.HtmlDecode(reader["Title"].ToString());
                        ftbDescription.Text = HttpUtility.HtmlDecode(reader["Description"].ToString());

                        ucTaskTime.Value = DateTime.MinValue.AddMinutes((int)reader["TaskTime"]);

                        if (reader["OrgUid"] != DBNull.Value)
                        {
                            ClientControl.ObjectType = OrganizationEntity.GetAssignedMetaClassName();
                            ClientControl.ObjectId   = PrimaryKeyId.Parse(reader["OrgUid"].ToString());
                        }
                        else if (reader["ContactUid"] != DBNull.Value)
                        {
                            ClientControl.ObjectType = ContactEntity.GetAssignedMetaClassName();
                            ClientControl.ObjectId   = PrimaryKeyId.Parse(reader["ContactUid"].ToString());
                        }

                        managerId = (int)reader["ManagerId"];

                        if (reader["ProjectId"] != DBNull.Value)
                        {
                            projectId = (int)reader["ProjectId"];
                        }
                    }
                }

                using (IDataReader reader = Document.GetListCategories(DocumentId))
                {
                    while (reader.Read())
                    {
                        for (int i = 0; i < lbCategory.Items.Count; i++)
                        {
                            Util.CommonHelper.SafeMultipleSelect(lbCategory, reader["CategoryId"].ToString());
                        }
                    }
                }

                EditControl.ObjectId = DocumentId;
                EditControl.BindData();
            }

            if (projectId > 0)
            {
                FillManagersByProject(projectId);
            }
            else
            {
                FillManagers();
            }

            // Select current manager
            if (managerId <= 0)
            {
                managerId = Security.CurrentUser.UserID;
            }

            ListItem managerItem = ddlManager.Items.FindByValue(managerId.ToString());

            if (managerItem == null)
            {
                UserLight ul = UserLight.Load(managerId);
                ddlManager.Items.Add(new ListItem(ul.LastName + " " + ul.FirstName, managerId.ToString()));
            }
            CommonHelper.SafeSelect(ddlManager, managerId.ToString());
        }