Пример #1
0
 /// <summary>
 /// Handles the RowCreated event of the gvUsers control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.Web.UI.WebControls.GridViewRowEventArgs"/> instance containing the event data.</param>
 protected void GvUsersRowCreated(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.Header)
     {
         PresentationUtils.SetSortImageStates(gvUsers, e.Row, 1, SortField, SortAscending);
     }
 }
Пример #2
0
 protected void GrdViewLedger_RowCreated(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.Pager)
     {
         PresentationUtils.SetPagerButtonStates(GrdViewLedger, e.Row, this);
     }
 }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Convert.ToInt32(HostSettingManager.Get(HostSettingNames.UserRegistration)) == (int)UserRegistration.None)
            {
                if (LoginView1.FindControl("RegisterLink") != null)
                {
                    LoginView1.FindControl("RegisterLink").Visible = false;
                }
            }

            var oHelper = new SuckerFishMenuHelper(ProjectId);

            litMenu.Text = oHelper.GetHtml();

            if (HostSettingManager.Get(HostSettingNames.EnableGravatar, true))
            {
                var user = Membership.GetUser(Security.GetUserName());
                if (user != null)
                {
                    Image img = (System.Web.UI.WebControls.Image)LoginView1.FindControl("Avatar");
                    img.ImageUrl = PresentationUtils.GetGravatarImageUrl(user.Email, 32);
                }
            }

            ProjectsList.DataTextField  = "Name";
            ProjectsList.DataValueField = "Id";

            if (!Page.IsPostBack)
            {
                string localizedSelectProject = GetGlobalResourceObject("SharedResources", "SelectProject").ToString();
                if (Page.User.Identity.IsAuthenticated)
                {
                    ProjectsList.DataSource = ProjectManager.GetByMemberUserName(Security.GetUserName(), true);
                    ProjectsList.DataBind();
                    ProjectsList.Items.Insert(0, new ListItem(localizedSelectProject));
                }
                else if (!Page.User.Identity.IsAuthenticated && Boolean.Parse(HostSettingManager.Get(HostSettingNames.AnonymousAccess)))
                {
                    ProjectsList.DataSource = ProjectManager.GetPublicProjects();
                    ProjectsList.DataBind();
                    ProjectsList.Items.Insert(0, new ListItem(localizedSelectProject));
                }
                else
                {
                    ProjectsList.Visible = false;
                }

                var item = ProjectsList.Items.FindByValue(ProjectId.ToString());

                if (item != null)
                {
                    ProjectsList.SelectedValue = item.Value;
                }
            }
        }
Пример #4
0
 protected void GridCust_RowCreated(object sender, GridViewRowEventArgs e)
 {
     try
     {
         if (e.Row.RowType == DataControlRowType.Pager)
         {
             PresentationUtils.SetPagerButtonStates(GridCust, e.Row, this);
         }
     }
     catch (Exception ex)
     {
         TroyLiteExceptionManager.HandleException(ex);
     }
 }
Пример #5
0
 protected void GrdViewJournal_RowCreated(object sender, GridViewRowEventArgs e)
 {
     try
     {
         if (e.Row.RowType == DataControlRowType.Pager)
         {
             PresentationUtils.SetPagerButtonStates(GrdViewJournal, e.Row, this);
         }
         //hdJournal.Value = Convert.ToString(GrdViewJournal.SelectedDataKey.Value);
     }
     catch (Exception ex)
     {
         TroyLiteExceptionManager.HandleException(ex);
     }
 }
Пример #6
0
 protected void gvJob_RowCreated(object sender, GridViewRowEventArgs e)
 {
     try
     {
         if (e.Row.RowType == DataControlRowType.Pager)
         {
             PresentationUtils.SetPagerButtonStates(gvJob, e.Row, this);
         }
         //errPanel.Visible = false;
         ErrMsg.Text = "";
     }
     catch (Exception ex)
     {
         TroyLiteExceptionManager.HandleException(ex);
     }
 }
Пример #7
0
        /// <summary>
        /// Returns a list of QueryClauses for items selected in the Project list (will handle the Select All too)
        /// </summary>
        /// <param name="returnAll">When true will return all project id's from the listbox, otherwise only the selected items</param>
        /// <returns></returns>
        private IEnumerable <QueryClause> GetProjectQueryClauses(bool returnAll)
        {
            var queryClauses = new List <QueryClause>();

            var projects = PresentationUtils.GetSelectedItemsIntegerList(ProjectListBoxFilter, returnAll).Where(project => project > Globals.NEW_ID).ToList();

            if (projects.Count > 0)
            {
                var first = true;

                foreach (var project in projects)
                {
                    queryClauses.Add(new QueryClause((first) ? "AND (" : "OR", "iv.[ProjectId]", "=", project.ToString(), SqlDbType.NVarChar));
                    first = false;
                }

                queryClauses.Add(new QueryClause(")", "", "", "", SqlDbType.NVarChar));
            }

            return(queryClauses);
        }
Пример #8
0
        /// <summary>
        ///     Initial settings.
        /// </summary>
        public static void Start()
        {
            // Sets the date format.
            if (DateTimeFormatInfo.CurrentInfo != null)
            {
                Df = DateTimeFormatInfo.CurrentInfo.ShortDatePattern;
            }
            if (Df == "dd/MM yyyy")
            {
                Df = "dd/MM/yyyy";    // Fixes the Uzbek (Latin) issue
            }
            Df = Df.Replace(" ", ""); // Fixes the Slovenian issue
            if (DateTimeFormatInfo.CurrentInfo != null)
            {
                char[]   acDs = DateTimeFormatInfo.CurrentInfo.DateSeparator.ToCharArray();
                string[] asSs = Df.Split(acDs, 3);
                asSs[0] = asSs[0].Substring(0, 1) + asSs[0].Substring(0, 1);
                asSs[1] = asSs[1].Substring(0, 1) + asSs[1].Substring(0, 1);
                asSs[2] = asSs[2].Substring(0, 1) + asSs[2].Substring(0, 1);
                Df      = asSs[0] + acDs[0] + asSs[1] + acDs[0] + asSs[2];

                if (asSs[0].ToUpper() == "YY")
                {
                    Dfs = asSs[1] + acDs[0] + asSs[2];
                }
                else if (asSs[1].ToUpper() == "YY")
                {
                    Dfs = asSs[0] + acDs[0] + asSs[2];
                }
                else
                {
                    Dfs = asSs[0] + acDs[0] + asSs[1];
                }
            }

            var  presentationUtils = new PresentationUtils();
            Size dpi = presentationUtils.GetScreenDpi();

            VDpiScale = dpi.Height / 96.0;
            HDpiScale = dpi.Width / 96.0;

            // Point character
            CultureInfo cultureInfo = CultureInfo.CurrentCulture;

            PointChar = cultureInfo.NumberFormat.NumberDecimalSeparator.ToCharArray()[0];

            // Set the working directories
            ProgramsDir  = Directory.GetCurrentDirectory();
            UserFilesDir = Path.Combine(ProgramsDir, UserFilesDir);

            DefaultOfflineDataDir = Path.Combine(UserFilesDir, OfflineDataDir);
            OfflineDataDir        = DefaultOfflineDataDir;
            OfflineDocsDir        = Path.Combine(UserFilesDir, OfflineDocsDir);
            StrategyDir           = Path.Combine(UserFilesDir, DefaultStrategyDir);
            SourceFolder          = Path.Combine(UserFilesDir, SourceFolder);
            SystemDir             = Path.Combine(UserFilesDir, SystemDir);
            LibraryDir            = Path.Combine(UserFilesDir, LibraryDir);
            LanguageDir           = Path.Combine(SystemDir, LanguageDir);
            ColorDir = Path.Combine(SystemDir, ColorDir);

            // Scanner colors
            PeriodColor.Add(DataPeriod.M1, ColorTranslator.FromHtml("#04FF14"));
            PeriodColor.Add(DataPeriod.M5, ColorTranslator.FromHtml("#87E800"));
            PeriodColor.Add(DataPeriod.M15, ColorTranslator.FromHtml("#FFED00"));
            PeriodColor.Add(DataPeriod.M30, ColorTranslator.FromHtml("#E8C400"));
            PeriodColor.Add(DataPeriod.H1, ColorTranslator.FromHtml("#E8AB00"));
            PeriodColor.Add(DataPeriod.H4, ColorTranslator.FromHtml("#FF8B07"));
            PeriodColor.Add(DataPeriod.D1, ColorTranslator.FromHtml("#E84006"));
            PeriodColor.Add(DataPeriod.W1, ColorTranslator.FromHtml("#FF0E1F"));
        }
Пример #9
0
        /// <summary>
        ///     Initial settings.
        /// </summary>
        public static void Start()
        {
            // Sets the date format.
            if (DateTimeFormatInfo.CurrentInfo != null)
            {
                Df = DateTimeFormatInfo.CurrentInfo.ShortDatePattern;
                if (Df == "dd/MM yyyy")
                {
                    Df = "dd/MM/yyyy";    // Fixes the Uzbek (Latin) issue
                }
                Df = Df.Replace(" ", ""); // Fixes the Sloven issue
                char[]   acDs = DateTimeFormatInfo.CurrentInfo.DateSeparator.ToCharArray();
                string[] asSs = Df.Split(acDs, 3);
                asSs[0] = asSs[0].Substring(0, 1) + asSs[0].Substring(0, 1);
                asSs[1] = asSs[1].Substring(0, 1) + asSs[1].Substring(0, 1);
                asSs[2] = asSs[2].Substring(0, 1) + asSs[2].Substring(0, 1);
                Df      = asSs[0] + acDs[0].ToString(CultureInfo.InvariantCulture) + asSs[1] +
                          acDs[0].ToString(CultureInfo.InvariantCulture) + asSs[2];

                if (asSs[0].ToUpper() == "YY")
                {
                    Dfs = asSs[1] + acDs[0].ToString(CultureInfo.InvariantCulture) + asSs[2];
                }
                else if (asSs[1].ToUpper() == "YY")
                {
                    Dfs = asSs[0] + acDs[0].ToString(CultureInfo.InvariantCulture) + asSs[2];
                }
                else
                {
                    Dfs = asSs[0] + acDs[0].ToString(CultureInfo.InvariantCulture) + asSs[1];
                }
            }

            var  presentationUtils = new PresentationUtils();
            Size dpi = presentationUtils.GetScreenDpi();

            VDpiScale = dpi.Height / 96.0;
            HDpiScale = dpi.Width / 96.0;

            // Point character
            CultureInfo culInf = CultureInfo.CurrentCulture;

            PointChar = culInf.NumberFormat.NumberDecimalSeparator.ToCharArray()[0];

            // Set the working directories
            ProgramDir   = Directory.GetCurrentDirectory();
            UserFilesDir = Path.Combine(ProgramDir, UserFilesDir);

            StrategyDir  = Path.Combine(UserFilesDir, DefaultStrategyDir);
            SourceFolder = Path.Combine(UserFilesDir, SourceFolder);
            SystemDir    = Path.Combine(UserFilesDir, SystemDir);
            LibraryDir   = Path.Combine(UserFilesDir, LibraryDir);
            LanguageDir  = Path.Combine(SystemDir, LanguageDir);
            ColorDir     = Path.Combine(SystemDir, ColorDir);

            try
            {
                SoundConnect         = new SoundPlayer(Path.Combine(SystemDir, @"Sounds\connect.wav"));
                SoundDisconnect      = new SoundPlayer(Path.Combine(SystemDir, @"Sounds\disconnect.wav"));
                SoundError           = new SoundPlayer(Path.Combine(SystemDir, @"Sounds\error.wav"));
                SoundOrderSent       = new SoundPlayer(Path.Combine(SystemDir, @"Sounds\order_sent.wav"));
                SoundPositionChanged = new SoundPlayer(Path.Combine(SystemDir, @"Sounds\position_changed.wav"));
            }
            catch
            {
                SoundConnect         = new SoundPlayer(Resources.sound_connect);
                SoundDisconnect      = new SoundPlayer(Resources.sound_disconnect);
                SoundError           = new SoundPlayer(Resources.sound_error);
                SoundOrderSent       = new SoundPlayer(Resources.sound_order_sent);
                SoundPositionChanged = new SoundPlayer(Resources.sound_position_changed);
            }

            Logger = new Logger();
        }
Пример #10
0
        /// <summary>
        /// Handles the ItemDataBound event of the rptComments control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.RepeaterItemEventArgs"/> instance containing the event data.</param>
        protected void rptComments_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            {
                return;
            }

            var currentComment = (IssueComment)e.Item.DataItem;

            //if (currentComment.CreatorUserId == _issueOwnerUserId)
            //    ((HtmlControl)e.Item.FindControl("CommentArea")).Attributes["class"] = "commentContainerOwner";

            // The edit panel is default not shown.
            var pnlEditComment = e.Item.FindControl("pnlEditComment") as Panel;

            if (pnlEditComment != null)
            {
                pnlEditComment.Visible = false;
            }

            var creatorDisplayName = (Label)e.Item.FindControl("CreatorDisplayName");

            creatorDisplayName.Text = UserManager.GetUserDisplayName(currentComment.CreatorUserName);

            var lblDateCreated = (Label)e.Item.FindControl("lblDateCreated");

            lblDateCreated.Text = currentComment.DateCreated.ToString("f");

            var ltlComment = (Literal)e.Item.FindControl("ltlComment");

            // WARNING: Do not decode the text from the HTML control (which supplied the comment),
            // as this was encoded already.
            //
            // However it is still possible to edit the raw contents of the htmlcontrol
            // using hacked client side javascript or using a httprequest editor
            // and poison the system that way! Does viewstate protect this in any way??

            ltlComment.Text = currentComment.Comment;


            var avatar = (Image)e.Item.FindControl("Avatar");

            if (HostSettingManager.Get(HostSettingNames.EnableGravatar, true))
            {
                var user = Membership.GetUser(currentComment.CreatorUserName);
                if (user != null && user.Email != null)
                {
                    avatar.Attributes.Add("src", PresentationUtils.GetGravatarImageUrl(user.Email, 64));
                }
            }

            var hlPermaLink = (HyperLink)e.Item.FindControl("hlPermalink");

            hlPermaLink.NavigateUrl = String.Format("{0}#{1}", HttpContext.Current.Request.Url, currentComment.Id);


            var cmdEditComment = e.Item.FindControl("cmdEditComment") as ImageButton;

            // Check if the current user is Authenticated and has permission to edit a comment.
            if (cmdEditComment != null)
            {
                cmdEditComment.Visible = false;

                // Check if the current user is Authenticated and has permission to edit a comment.//If user can edit comments
                if (Page.User.Identity.IsAuthenticated && UserManager.HasPermission(ProjectId, Common.Permission.EditComment.ToString()))
                {
                    cmdEditComment.Visible = true;
                }
                // Check if the project admin or a super user trying to edit the comment.
                else if ((Page.User.Identity.IsAuthenticated && UserManager.IsSuperUser()) || (Page.User.Identity.IsAuthenticated && UserManager.IsInRole(ProjectId, Globals.ProjectAdminRole)))
                {
                    cmdEditComment.Visible = true;
                }
                // Check if it is the original user, the project admin or a super user trying to edit the comment.
                else if (currentComment.CreatorUserName.ToLower() == Context.User.Identity.Name.ToLower() && UserManager.HasPermission(ProjectId, Common.Permission.OwnerEditComment.ToString()))
                {
                    cmdEditComment.Visible = true;
                }
            }

            var cmdDeleteComment = e.Item.FindControl("cmdDeleteComment") as ImageButton;

            // Check if the current user is Authenticated and has the permission to delete a comment
            if (!Page.User.Identity.IsAuthenticated || !UserManager.HasPermission(ProjectId, Common.Permission.DeleteComment.ToString()))
            {
                return;
            }

            if (cmdDeleteComment == null)
            {
                return;
            }

            cmdDeleteComment.Attributes.Add("onclick", string.Format("return confirm('{0}');", GetLocalResourceObject("DeleteComment").ToString().Trim().JsEncode()));
            cmdDeleteComment.Visible = false;

            // Check if it is the original user, the project admin or a super user trying to delete the comment.
            if (currentComment.CreatorUserName.ToLower() == Context.User.Identity.Name.ToLower() || UserManager.IsSuperUser() || UserManager.IsInRole(ProjectId, Globals.ProjectAdminRole))
            {
                cmdDeleteComment.Visible = true;
            }
        }
Пример #11
0
        /// <summary>
        /// Binds the issues.
        /// </summary>
        private void BindIssues()
        {
            string userId = ViewIssueMemberDropDown.SelectedValue;

            if (userId == null)
            {
                return;
            }

            var queryClauses = new List <QueryClause>
            {
                // do not include disabled projects
                new QueryClause("AND", "iv.[ProjectDisabled]", "=", "0", SqlDbType.Int),

                // do not include disabled issues
                new QueryClause("AND", "iv.[Disabled]", "=", "0", SqlDbType.Int),
            };

            // return the projects selected in the list box, this represents all the projects the user has access to
            // pre filtered on the page load
            var selectedProjects = GetProjectQueryClauses(false);

            // hack yes but does the trick to make sure that all projects are loaded when select all is selected
            queryClauses.AddRange(GetProjectQueryClauses(selectedProjects.Count().Equals(0)));

            var sortColumns = new List <KeyValuePair <string, string> >();
            var sorter      = ctlDisplayIssues.SortString;

            foreach (var sort in sorter.Split(','))
            {
                var args = sort.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                if (args.Length.Equals(2))
                {
                    sortColumns.Add(new KeyValuePair <string, string>(args[0], args[1]));
                }
            }

            if (ViewIssuesDropDownFilter.SelectedValue == "Monitored")
            {
                var projects = PresentationUtils.GetSelectedItemsIntegerList(ProjectListBoxFilter, false).Where(project => project > Globals.NEW_ID).ToList();

                ctlDisplayIssues.RssUrl     = string.Format("~/Feed.aspx?channel=15&ec={0}", ExcludeClosedIssuesFilter.Checked);
                ctlDisplayIssues.DataSource = IssueManager.GetMonitoredIssuesByUserName(userId, sortColumns, projects, ExcludeClosedIssuesFilter.Checked);
                ctlDisplayIssues.DataBind();
            }
            else
            {
                switch (ViewIssuesDropDownFilter.SelectedValue)
                {
                case "Assigned":

                    if (ExcludeClosedIssuesFilter.Checked)
                    {
                        queryClauses.Add(new QueryClause("AND", "iv.[IsClosed]", "=", "0", SqlDbType.Int));
                    }

                    queryClauses.Add(new QueryClause("AND", "iv.[IssueAssignedUserId]", "=", userId, SqlDbType.NVarChar));

                    ctlDisplayIssues.RssUrl = string.Format("~/Feed.aspx?channel=7&u={0}&ec={1}", Security.GetUserName(), ExcludeClosedIssuesFilter.Checked);

                    break;

                case "Closed":

                    queryClauses.Add(new QueryClause("AND", "iv.[IsClosed]", "=", "1", SqlDbType.Int));

                    queryClauses.Add(new QueryClause("AND", "iv.[IssueAssignedUserId]", "=", userId, SqlDbType.NVarChar));

                    ctlDisplayIssues.RssUrl = string.Format("~/Feed.aspx?channel=7&u={0}&ec={1}", Security.GetUserName(), bool.FalseString);

                    break;

                case "Owned":

                    if (ExcludeClosedIssuesFilter.Checked)
                    {
                        queryClauses.Add(new QueryClause("AND", "iv.[IsClosed]", "=", "0", SqlDbType.Int));
                    }

                    queryClauses.Add(new QueryClause("AND", "iv.[IssueOwnerUserId]", "=", userId, SqlDbType.NVarChar));
                    ctlDisplayIssues.RssUrl = string.Format("~/Feed.aspx?channel=7&ou={0}&ec={1}", Security.GetUserName(), ExcludeClosedIssuesFilter.Checked);
                    break;

                case "Created":

                    if (ExcludeClosedIssuesFilter.Checked)
                    {
                        queryClauses.Add(new QueryClause("AND", "iv.[IsClosed]", "=", "0", SqlDbType.Int));
                    }

                    queryClauses.Add(new QueryClause("AND", "iv.[IssueCreatorUserId]", "=", userId, SqlDbType.NVarChar));
                    ctlDisplayIssues.RssUrl = string.Format("~/Feed.aspx?channel=7&ru={0}&ec={1}", Security.GetUserName(), bool.FalseString);
                    break;

                default:

                    if (ExcludeClosedIssuesFilter.Checked)
                    {
                        queryClauses.Add(new QueryClause("AND", "iv.[IsClosed]", "=", "0", SqlDbType.Int));
                    }
                    break;
                }

                ctlDisplayIssues.DataSource = IssueManager.PerformQuery(queryClauses, sortColumns);
                ctlDisplayIssues.DataBind();
            }
        }
Пример #12
0
        // STATES --------------------------------------------------------------------------------------------
        public void SetState(CellState cellState)
        {
            //if (isInitialized) throw new InvalidOperationException("Cell was already initialized!");

            //check if this state is one of the finite states of this cell
            if (!finiteStates.Contains(cellState))
            {
                throw new InvalidOperationException(string.Format("The specified state: {0} is invalid for this type of cell! Please use one of the following: {1}", cellState, PresentationUtils.ListToString(finiteStates)));
            }
            //if it is valid, initialize the cell
            this.cellState = cellState;
            isInitialized  = true;
        }
Пример #13
0
 public override String ToString()
 {
     return("Dead cell comes to life when it has exactly " + PresentationUtils.ListToString <int>(LivingNeighborsRequirements) + " living neighbors");
 }
Пример #14
0
 public override String ToString()
 {
     return("Random State Configuration distributing randomly the following Cell states: " + PresentationUtils.ListToString(states));
 }
Пример #15
0
 public override String ToString()
 {
     return("A living cell remains alive only when surrounded by " + PresentationUtils.ListToString <int>(LivingNeighborsRequirements) + " living neighbors");
 }