コード例 #1
0
    /// <summary>Generates the HTML code to show JobPosition list</summary>
    private void RenderJobPositionData()
    {
        var graphData = new StringBuilder("[");

        var  res         = new StringBuilder();
        var  sea         = new StringBuilder();
        var  searchItems = new List <string>();
        var  cargos      = JobPosition.JobsPositionByCompany((Company)Session["Company"]).OrderBy(c => c.Responsible.Id);
        int  contData    = 0;
        bool firstGraph  = true;

        foreach (var cargo in cargos)
        {
            res.Append(cargo.TableRow(this.Dictionary, this.user.HasGrantToWrite(ApplicationGrant.JobPosition), this.user.HasGrantToRead(ApplicationGrant.Department)));
            if (!searchItems.Contains(cargo.Description))
            {
                searchItems.Add(cargo.Description);
                contData++;
            }

            if (firstGraph)
            {
                firstGraph = false;
            }
            else
            {
                graphData.Append(",");
            }

            graphData.AppendFormat(
                CultureInfo.InvariantCulture,
                @"[{{""v"": ""{0}"", ""f"": ""{1}<div style='color:#333; font-style:italic;'>{2}</div>""}},""{3}"", ""{4}""]{5}",
                cargo.Id,
                cargo.Description,
                cargo.Department.Description,
                cargo.Responsible.Id == 0 ? string.Empty : cargo.Responsible.Id.ToString(),
                cargo.Description,
                Environment.NewLine);
        }

        graphData.Append("]");
        this.GraphRows            = graphData.ToString();
        this.CargosDataTotal.Text = contData.ToString();

        searchItems.Sort();
        bool first = true;

        foreach (var item in searchItems)
        {
            if (first)
            {
                first = false;
            }
            else
            {
                sea.Append(",");
            }

            if (item.IndexOf("\"") != -1)
            {
                sea.Append(string.Format(@"'{0}'", item));
            }
            else
            {
                sea.Append(string.Format(@"""{0}""", item));
            }
        }

        this.CargosData.Text         = res.ToString();
        this.master.SearcheableItems = sea.ToString();
    }
コード例 #2
0
ファイル: Data.aspx.cs プロジェクト: althera2004/ISSUS
    /// <summary>Page's load event</summary>
    /// <param name="sender">Loaded page</param>
    /// <param name="e">Event's arguments</param>
    protected void Page_Load(object sender, EventArgs e)
    {
        var d1      = DateTime.Now;
        var company = Session["company"] as Company;
        var user    = Session["user"] as ApplicationUser;

        this.dictionary = Session["Dictionary"] as Dictionary <string, string>;
        string userCulture = this.UsedCulture(company, user);

        this.Response.Clear();
        this.Response.ClearHeaders();
        this.Response.ContentType = "text/javascript";

        this.Response.Write(string.Format(CultureInfo.InvariantCulture, @"var user = {0};", user.Json));

        this.Response.Write(Environment.NewLine);
        this.Response.Write(Environment.NewLine);

        this.Response.Write(string.Format(CultureInfo.InvariantCulture, @"var UserCulture = ""{0}"";", userCulture));

        this.Response.Write(Environment.NewLine);
        this.Response.Write(Environment.NewLine);

        this.Response.Write(string.Format(CultureInfo.InvariantCulture, @"var Company = {0};", company.Json));

        this.Response.Write(Environment.NewLine);
        this.Response.Write(Environment.NewLine);

        var  res    = new StringBuilder();
        var  cargos = JobPosition.JobsPositionByCompany((Company)Session["Company"]);
        bool first  = true;

        foreach (var cargo in cargos)
        {
            if (first)
            {
                first = false;
            }
            else
            {
                res.Append(",");
            }

            res.Append(cargo.JsonSimple);
        }

        this.Response.Write(string.Format(CultureInfo.InvariantCulture, @"var jobPositionCompany ={0}[{1}{0}];", Environment.NewLine, res));

        this.Response.Write(Environment.NewLine);
        this.Response.Write(Environment.NewLine);

        this.Response.Write("var processTypeCompany = " + Environment.NewLine + this.ProccessTypeList(company) + ";");
        this.Response.Write(Environment.NewLine);
        this.Response.Write(Environment.NewLine);

        this.Response.Write("var departmentsCompany = " + Environment.NewLine + this.CompanyDepartments(company) + ";");

        this.Response.Write(Environment.NewLine);
        this.Response.Write(Environment.NewLine);

        this.Response.Write("var Dictionary =" + Environment.NewLine);
        this.Response.Write("{" + Environment.NewLine);

        foreach (var item in this.dictionary)
        {
            if (!item.Key.StartsWith("Help_") || true)
            {
                this.Response.Write(this.DictionaryItem(item.Key.Replace(' ', '_'), item.Value));
            }
        }

        this.Response.Write("    \"-\": \"-\"" + Environment.NewLine);
        this.Response.Write("};");
    }