protected void botMigrateModel_Click(object sender, EventArgs e)
    {
        lblStatus.Text = "Start Migration";
        DBHelper.ConnectionString = txtSourceConnection.Text;

        ModeloCompetencias _modelo = ModeloCompetencias.getDBModelo("JC", int.Parse(DDLModelos.SelectedValue));
        // agora vai criar o modelo na base de dados de produção
        _modelo.loadFull("JC", null);

        DBHelper.ConnectionString = this.txtDestConnection.Text;

        // cria o modelo
        ModeloCompetencias NovoModelo = new ModeloCompetencias();
        NovoModelo = _modelo;
        NovoModelo.reset();
        NovoModelo.updateDBModelo("JC");

        for (int i = 0; i < _modelo.Familias.Count; i++)
        {
            FamiliaCompetencias novaFam = new FamiliaCompetencias(NovoModelo);
            novaFam = NovoModelo.Familias.Values[i];
            novaFam.Modelo = NovoModelo;
            novaFam.reset();
            novaFam.SortIndex = i;
            novaFam.cloneDBFamilia("JC");
            for (int j = 0; j < _modelo.Familias.Values[i].Competencias.Count; j++)
            {
                Competencia novaComp = new Competencia();
                novaComp = NovoModelo.Familias.Values[i].Competencias.Values[j];
                novaComp.reset();
                novaComp.SortIndex = j;
                novaComp.Familia = novaFam;
                novaComp.cloneDBCompetencia("JC");
                for (int k = 0; k < _modelo.Familias.Values[i].Competencias.Values[j].Praticas.Count; k++)
                {
                    Pratica novaPrat = new Pratica();
                    novaPrat = NovoModelo.Familias.Values[i].Competencias.Values[j].Praticas.Values[k];
                    novaPrat.Competencia = novaComp;
                    novaPrat.reset();
                    novaPrat.SortIndex = k;
                    novaPrat.cloneDBPratica("JC");

                    for (int l = 0; l < _modelo.Familias.Values[i].Competencias.Values[j].Praticas.Values[k].Perguntas.Count; l++)
                    {
                        Pergunta novaPerg = new Pergunta();
                        novaPerg = NovoModelo.Familias.Values[i].Competencias.Values[j].Praticas.Values[k].Perguntas.Values[l];
                        novaPerg.reset();
                        novaPerg.Pratica = novaPrat;
                        novaPerg.SortIndex = l;
                        novaPerg.cloneDBPergunta("JC");
                    }

                }
            }
        }

        lblStatus.Text = "Migration Ended";
        // depois volta a colocar a limpar a coisa
        DBHelper.ConnectionString = "";
    }
    protected void addNewCompetencia()
    {
        ModeloCompetencias currModelo;
        FamiliaCompetencias currFamilia;
        Competencia novaCompetencia;

        currFamilia = (FamiliaCompetencias)Session["selectedObject"];
        currModelo = currFamilia.Modelo;

        novaCompetencia = new Competencia(currFamilia);
        selectedObject = novaCompetencia;
        Session["selectedObject"] = selectedObject;
        Session.Add("mode", "ADD_NEW");

        View selView;

        selView = CompetenciaView;
        if (selView != null)
        {
            MView.SetActiveView(selView);
        }
        else
        {
            MView.Visible = false;
            commonDataFieldsTable.Visible = false;
        }
        updateCommonFields();
        updateSpecialFields();
    }
    protected void addNewFamilia()
    {
        ModeloCompetencias currModelo;
        FamiliaCompetencias novaFamilia;
        if (Session["selectedObject"].GetType() == typeof(ModeloCompetencias))
        {
            currModelo = (ModeloCompetencias)Session["currModelo"];
        }
        else
        {
            currModelo = ((FamiliaCompetencias)Session["currModelo"]).Modelo;
        }
        novaFamilia = new FamiliaCompetencias(currModelo);
        selectedObject = novaFamilia;
        Session["selectedObject"] = selectedObject;
        Session.Add("mode", "ADD_NEW");

        View selView;

        selView = FamiliaView;
        if (selView != null)
        {
            MView.SetActiveView(selView);
        }
        else
        {
            MView.Visible = false;
            commonDataFieldsTable.Visible = false;
        }
        updateCommonFields();
        updateSpecialFields();
    }
 public FamiliaCompetencias(ModeloCompetencias mod)
 {
     competencias = new SortedList<int, Competencia>();
     creationDate = DateTime.Now;
     familiaID = -1;
     modelo = mod;
 }
        // utilizado nos relatórios One2One
        public RamkoersCalculations(ModeloCompetencias modelo, Pessoa proprio, Pessoa avaliado, Projecto proj)
        {
            _avaliado = null;
            _proprio = null;

            _Modelo = modelo;
            _Projecto = proj;
            _proprio = proprio;
            _avaliado = avaliado;
            _pessoaID = avaliado.PessoaID;
        }
    protected void DDLModelos_SelectedIndexChanged(object sender, EventArgs e)
    {
        currModelo = modelos[int.Parse(DDLModelos.SelectedItem.Value)];
        // carrega o modelo todo
        currModelo.loadFull(Utility.currProjeto.owner, null);
        Session["currModelo"] = currModelo;
        // cria as ddl's de cada Secção

        UpdateDDLContrutos();

        updatePerguntas();
    }
        public RamkoersCalculations(ModeloCompetencias modelo, int pessoaID, Projecto proj)
        {
            _avaliado = null;
            _proprio = null;

            _Modelo = modelo;
            _Projecto = proj;
            _pessoaID = pessoaID;

            ReportGroupCodes = new string[proj.GroupsCodes.Length + 1];
            for (int i = 0; i < ReportGroupCodes.Length-1; i++)
            {
                ReportGroupCodes[i] = proj.GroupsCodes[i];
            }
            ReportGroupCodes[proj.GroupsCodes.Length] = Dicionario.getResource(proj.defaultLangCode,364); // é All no idioma do projecto

            ReportGroupDescriptions = new string[proj.GroupsCodes.Length + 1];
            for (int i = 0; i < ReportGroupDescriptions.Length - 1; i++)
            {
                ReportGroupDescriptions[i] = proj.GroupsDescription[i];
            }
            ReportGroupDescriptions[proj.GroupsCodes.Length] = Dicionario.getResource(proj.defaultLangCode, 364); // é All no idioma do projecto
        }
    protected void getDefaultModelos()
    {
        modelos = ModeloCompetencias.getDBModelos("XXXX");
        // retira da lista os não personalísticos

        if (modelos == null)
        {
            selectedObject = null;
            currModelo = null;
            return;
        }

        DDLModelos.Items.Clear();
        foreach (ModeloCompetencias mod in modelos.Values)
        {
            //if (mod.ModelType == "PERS")
            //{
                ListItem l = new ListItem(mod.Name, mod.ModeloID.ToString());
                DDLModelos.Items.Add(l);
            //}
        }
        Session.Add("modelos", modelos);
        Session.Add("currModelo", modelos.Values[0]);
    }
 public ModeloCompetencias copy()
 {
     ModeloCompetencias novo = new ModeloCompetencias();
     novo.Name = name;
     novo.ModelType = this.ModelType;
     novo.publicName = publicName;
     novo.scale = scale;
     novo.scaleDesc = scaleDesc;
     novo.creationDate = creationDate;
     novo.sortIndex = sortIndex;
     novo.modeloID = modeloID;
     novo.description = description;
     novo.introText = introText;
     novo.allowRespondentComments = allowRespondentComments;
     novo.commentsText = commentsText;
     novo.langCode = langCode;
     return novo;
 }
        public static ModeloCompetencias getModeloEquivalente(ModeloCompetencias MasterModel, string langCode)
        {
            if (langCode == null) return null;
            if (MasterModel.langCode == null) return null;
            if (MasterModel.langCode == langCode) return null ;

            SqlConnection conn = new SqlConnection(DBHelper.ConnectionString);
            SqlCommand command = new SqlCommand();

            String[] res;
            command.Connection = conn;
            command.CommandText = "getModelTranslations";
            command.CommandType = System.Data.CommandType.StoredProcedure;
            command.Parameters.Add(new SqlParameter("MasterModelID", MasterModel.ModeloID));

            SqlDataAdapter da = new SqlDataAdapter(command);
            DataSet ds = new DataSet();

            conn.Open();
            da.Fill(ds);
            conn.Close();

            if (ds.Tables[0].Rows.Count <= 0)
                return null;

            String translationLangCode = "";
            int bestProjectID = 0;

            foreach (DataRow dr in ds.Tables[0].Rows)
            {

                translationLangCode = Convert.IsDBNull(dr["langCode"]) ? "" : Convert.ToString(dr["langCode"]);
                if (translationLangCode.Trim().ToUpper() == langCode.Trim().ToUpper())
                {
                    // este id serve
                    bestProjectID = Convert.IsDBNull(dr["Translated_ID"]) ? 0 : Convert.ToInt32(dr["Translated_ID"]);
                }
                else if (translationLangCode.Trim().ToUpper().Substring(0, 2) == langCode.Trim().ToUpper().Substring(0, 2))
                {
                    // este tb serve
                    bestProjectID = Convert.IsDBNull(dr["Translated_ID"]) ? 0 : Convert.ToInt32(dr["Translated_ID"]);
                }
            }

            if (bestProjectID != 0)
            {
                return ModeloCompetencias.getDBModelo(MasterModel.owner + "_TRANSLATED", bestProjectID);
            }
            return null;
        }
        /// <summary>
        /// Retrona todos os modelo de um owner
        /// </summary>
        /// <param name="owner"> código do owner</param>
        /// <returns>um array de modelos de competências do owner identificado</returns>
        public static SortedList<int, ModeloCompetencias> getDBModelos(string owner)
        {
            SqlConnection conn = new SqlConnection(DBHelper.ConnectionString);
            SqlCommand command = new SqlCommand();
            command.Connection = conn;
            command.CommandText = "getModelos";
            command.CommandType = System.Data.CommandType.StoredProcedure;
            command.Parameters.Add(new SqlParameter("owner", owner));

            SqlDataAdapter da = new SqlDataAdapter(command);
            DataSet ds = new DataSet();

            conn.Open();
            da.Fill(ds);
            conn.Close();

            if (ds.Tables[0].Rows.Count <= 0) return null;
            // cria a estrutura para retorno
            SortedList<int, ModeloCompetencias> returnValue = new SortedList<int, ModeloCompetencias>();
            ModeloCompetencias modelo;

            int i = 0;
            int allow;
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                modelo = new ModeloCompetencias();
                modelo.CreationDate = Convert.ToDateTime(dr["creationDate"]);
                modelo.Name = Convert.ToString(dr["Name"]);
                modelo.PublicName = Convert.ToString(dr["PublicName"]);
                modelo.scale = Convert.IsDBNull(dr["scale"]) ? null : Convert.ToString(dr["scale"]);
                //modelo.Scale = (Escalas)Convert.ToInt32(dr["scale"]);
                modelo.modeloID = Convert.ToInt32(dr["ID"]);
                modelo.introText = Convert.IsDBNull(dr["IntroText"]) ? null : Convert.ToString(dr["IntroText"]);
                modelo.description = Convert.IsDBNull(dr["Description"]) ? null : Convert.ToString(dr["Description"]);
                allow = Convert.IsDBNull(dr["AllowComments"]) ? 0 : Convert.ToInt32(dr["AllowComments"]) == 0 ? 0 : 1;
                modelo.allowRespondentComments = allow == 0 ? false : true;
                modelo.CommentsText = Convert.IsDBNull(dr["CommentsText"]) ? null : Convert.ToString(dr["CommentsText"]);
                modelo.scaleDesc = Convert.IsDBNull(dr["scaleDesc"]) ? null : Convert.ToString(dr["scaleDesc"]);
                modelo.modelType = Convert.IsDBNull(dr["modelType"]) ? null : Convert.ToString(dr["modelType"]);
                modelo.field1 = Convert.IsDBNull(dr["field1"]) ? null : Convert.ToString(dr["field1"]);
                modelo.NR = Convert.IsDBNull(dr["NR"]) ? false : Convert.ToBoolean(dr["NR"]);
                modelo.langCode = Convert.IsDBNull(dr["langCode"]) ? null : Convert.ToString(dr["langCode"]);

                returnValue.Add(modelo.modeloID, modelo);
                i++;
            }

            return returnValue;
        }
        /// <summary>
        /// Retorna um objecto Modelo de Competências sabendo o seu ID e Owner
        /// </summary>
        /// <param name="owner"></param>
        /// <param name="ID"></param>
        /// <returns></returns>
        public static ModeloCompetencias getDBModelo(string owner, int ID)
        {
            SqlConnection conn = new SqlConnection(DBHelper.ConnectionString);
            SqlCommand command = new SqlCommand();
            command.Connection = conn;
            command.CommandText = "getModelo";
            command.CommandType = System.Data.CommandType.StoredProcedure;
            command.Parameters.Add(new SqlParameter("owner", owner));
            command.Parameters.Add(new SqlParameter("ID", ID));

            SqlDataAdapter da = new SqlDataAdapter(command);
            DataSet ds = new DataSet();

            conn.Open();
            da.Fill(ds);
            conn.Close();

            if ((ds.Tables[0].Rows.Count <= 0) && (owner != "TEMPLATE"))
            {
                command.Parameters[0].Value = "TEMPLATE";
                conn.Open();
                da.Fill(ds);
                conn.Close();
            }

            if (ds.Tables[0].Rows.Count <= 0)
                return null;

            int allow;
            ModeloCompetencias returnValue = new ModeloCompetencias();

            DataRow dr = ds.Tables[0].Rows[0];

            returnValue.CreationDate = Convert.ToDateTime(dr["creationDate"]);
            returnValue.Name = Convert.ToString(dr["Name"]);
            returnValue.PublicName = Convert.ToString(dr["PublicName"]);
            returnValue.Scale = Convert.IsDBNull(dr["scale"]) ? null : Convert.ToString(dr["scale"]);
            returnValue.modeloID = Convert.ToInt32(dr["ID"]);
            returnValue.introText = Convert.IsDBNull(dr["IntroText"]) ? null : Convert.ToString(dr["IntroText"]);
            returnValue.description = Convert.IsDBNull(dr["Description"]) ? null : Convert.ToString(dr["Description"]);
            allow = Convert.IsDBNull(dr["AllowComments"]) ? 0 : Convert.ToInt32(dr["AllowComments"]) == 0 ? 0 : 1;
            returnValue.allowRespondentComments = allow == 0 ? false : true;
            returnValue.CommentsText = Convert.IsDBNull(dr["CommentsText"]) ? null : Convert.ToString(dr["CommentsText"]);
            returnValue.scaleDesc = Convert.IsDBNull(dr["scaleDesc"]) ? null : Convert.ToString(dr["scaleDesc"]);
            returnValue.modelType = Convert.IsDBNull(dr["modelType"]) ? null : Convert.ToString(dr["modelType"]);
            returnValue.field1 = Convert.IsDBNull(dr["field1"]) ? null : Convert.ToString(dr["field1"]);
            returnValue.NR = Convert.IsDBNull(dr["NR"]) ? false : Convert.ToBoolean(dr["NR"]);
            returnValue.owner = Convert.ToString(dr["owner"]);
            returnValue.langCode = Convert.IsDBNull(dr["langCode"]) ? null : Convert.ToString(dr["langCode"]);
            return returnValue;
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Context.Session["Dicionario"] != null)
        {
            dic = (Dicionario)Context.Session["Dicionario"];
        }
        else
        {
            Response.Redirect("FO_DICERROR.aspx"); // TODO
        }

        Page.Title = "";
        // validar o ticket
        if (Request["ticket"] == null && Session["ticketList"] == null)
            Response.Redirect("ticketError.aspx");

        getTicketList();
        getProjectInfo();
        setupStyle();

        if (DateTime.Now.Date > projecto.DataFim)
            Response.Redirect("ticketError.aspx?Error=Closed");

        // carrega o modelo
        if (Session["FO_Model"] == null)
        {
            modelo = ModeloCompetencias.getDBModelo(Utility.currProjeto.owner, ticketList[0].ModeloID);
            if (modelo == null)
            {
                Response.Redirect("genericError.aspx");
                return;
            }
            modelo.loadFull(Utility.currProjeto.owner, ticketList[0]);
            Session.Add("FO_Model", modelo);
        }
        else
        {
            modelo = (ModeloCompetencias)Session["FO_Model"];
        }

        tipoDeAvaliacao();

        Page.Title = projecto.Nome;

        RenderPage();

        if (IsPostBack)
        {
            // analisa input do participante
            String comando = txtUserCommand.Value;
            if (comando.Equals("NEXT"))
            {
                nextPage();
            }
        }
    }
 protected void getTicketList()
 {
     if (Page.Session[TicketListSession] == null)
     {
         modelo = null;
         ticketList = null;
     }
     else
     {
         ticketList = (List<Ticket>)Page.Session[TicketListSession];
     }
     proprio = ((Ticket)(ticketList[0])).Proprio;
 }
        public FamiliaCompetencias Copy(ModeloCompetencias mod)
        {
            FamiliaCompetencias novo = new FamiliaCompetencias(mod);

            novo.name = this.name;
            novo.publicName = this.publicName;
            novo.description = this.description;
            novo.introText = this.introText;
            novo.allowRespondentComments = this.allowRespondentComments;
            novo.commentsText = this.commentsText;

            return novo;
        }
        public ModeloCompetencias duplicateModeloFull(ModeloCompetencias oldModelo, String novoOwner, String exclude)
        {
            oldModelo.loadFull("TEMPLATE", null);
            ModeloCompetencias novoModelo = oldModelo.copy();
            FamiliaCompetencias novaFamilia;
            Competencia novaCompetencia;
            Pratica novaPratica;
            Pergunta novaPergunta;

            novoModelo.modeloID = -1;
            novoModelo.Name += " [Custom]";
            novoModelo.PublicName += " [Custom]";

            novoModelo.updateDBModelo(novoOwner);

            try
            {
                foreach (FamiliaCompetencias fam in oldModelo.Familias.Values)
                {
                    novaFamilia = fam.Copy(novoModelo);
                    novaFamilia.FamiliaID = -1;
                    novaFamilia.updateDBFamilia(novoOwner);
                    foreach (Competencia comp in fam.Competencias.Values)
                    {
                        if (exclude.Contains("C" + comp.CompetenciaID.ToString()))
                            continue;
                        novaCompetencia = comp.Copy(novaFamilia);
                        novaCompetencia.CompetenciaID = -1;
                        novaCompetencia.updateDBCompetencia(novoOwner);
                        foreach (Pratica prat in comp.Praticas.Values)
                        {
                            novaPratica = prat.Copy(novaCompetencia);
                            novaPratica.PraticaID = -1;
                            novaPratica.updateDBPratica(novoOwner);
                            foreach (Pergunta perg in prat.Perguntas.Values)
                            {
                                novaPergunta = perg.Copy(novaPratica);
                                novaPergunta.PerguntaID = -1;
                                novaPergunta.Pratica = novaPratica;
                                novaPergunta.updateDBPergunta(novoOwner);
                            }
                        }
                    }
                }

            }
            catch
            {
                return null;
            }

            return novoModelo;
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        // language settings
        if (Context.Session["Dicionario"] != null)
        {
            dic = (Dicionario)Context.Session["Dicionario"];
        }
        else
        {
            Response.Redirect("FO_DICERROR.aspx"); // TODO
        }

        // validar o ticket
        if (Request["ticket"] == null && Session["ticketList"] == null)
            Response.Redirect("ticketError.aspx");

        getTicketList();

        // no caso do ticket já ter iniciado passa para a página de restart

        getProjectInfo();
        setupStyle();

        if (DateTime.Now.Date > projecto.DataFim)
            Response.Redirect("ticketError.aspx?Error=Closed");

        Ticket t = ticketList[0];

        if (t.completo)
        {
            Response.Redirect("FO_concluded.aspx");
        }

        if (t.DataInicio != DateTime.MinValue)
        {
            Response.Redirect("FO_Restart.aspx");
        }

        // carrega o modelo
        if (Session["FO_Model"] == null)
        {
            modelo = ModeloCompetencias.getDBModelo(Utility.currProjeto.owner, ticketList[0].ModeloID);
            if (modelo == null)
            {
                modelo = ModeloCompetencias.getDBModelo("TEMPLATE", ticketList[0].ModeloID);
                if (modelo == null)
                {
                    modelo = ModeloCompetencias.getDBModelo("TEMPLATE_" + Utility.currentAccount.ID, ticketList[0].ModeloID);
                }
            }

            if (modelo == null)
            {
                Response.Redirect("genericError.aspx");
                return;
            }
            modelo.loadFull(Utility.currProjeto.owner, ticketList[0]);
            Session.Add("FO_Model", modelo);
        }
        else
        {
            modelo = (ModeloCompetencias)Session["FO_Model"];
        }

        tipoDeAvaliacao();

        Page.Title = projecto.Nome;

        RenderPage();

        // gestão do popup da capa do projecto
        Label lbl = new Label();
        lbl.ID = "tempholder";
        upShowStuff.ContentTemplateContainer.Controls.Add(lbl);
        mdePopup.TargetControlID = lbl.ID;
        if (projecto.TextoCapa != null)
        {
            if (projecto.TextoCapa.Trim() != "")
            {

                if (Request["Cover"] != null)
                {
                    if (!Request["Cover"].Equals("False"))
                        showCapa();
                }
                else
                    showCapa();
            }
        }

        if (IsPostBack)
        {
            // analisa input do participante
            String comando = txtUserCommand.Value;
            if (comando.Equals("NEXT"))
            {
                nextPage();
                saveUserInput();
            }
        }

        lblAnonimo.Text = dic.getResource(75);
    }
Exemple #18
0
    private ModeloCompetencias SaveNewModelForCustomProject(int templateID, String exclude)
    {
        // Temos de criar um modelo novo

        ModeloCompetencias templateModelo = ModeloCompetencias.getDBModelo("TEMPLATE", templateID);
        ModeloCompetencias dummyModelo = new ModeloCompetencias();
        ModeloCompetencias novoModelo;
        novoModelo = dummyModelo.duplicateModeloFull(templateModelo, Utility.currentAccount.AccountSignature, exclude);
        novoModelo.updateDBModelo(Utility.currentAccount.AccountSignature);
        // já temos o novo ID, podemos guardar nas configurações do projecto
        Utility.currProjeto.setCurrentConfig("MODEL", novoModelo.ModeloID.ToString());
        Utility.currProjeto.ModeloID = novoModelo.ModeloID;
        Utility.currModelo = novoModelo;
        return Utility.currModelo;
    }
 protected override void OnLoad(EventArgs e)
 {
     base.OnLoad(e);
     getTicketList();
     // carrega o modelo
     String owner = ((Ticket)(ticketList[0])).Projecto.owner;
     // String owner = (HttpContext.Current.Session["currSIProjeto"] as Projecto).owner;
     if (Page.Session["FO_Model"] == null)
     {
         modelo = ModeloCompetencias.getDBModelo(owner, ticketList[0].ModeloID);
         modelo.loadFull(owner, ticketList[0]);
     }
     else
     {
         modelo = (ModeloCompetencias) Page.Session["FO_Model"];
     }
 }
 public bool duplicateModeloFamilias(ModeloCompetencias oldModelo)
 {
     return duplicateModeloFull(oldModelo);
 }
        public Boolean duplicateModeloFull(ModeloCompetencias oldModelo)
        {
            oldModelo.loadFull("TEMPLATE", null);
            ModeloCompetencias novoModelo = DBHelper.Clone<ModeloCompetencias>(oldModelo);
            FamiliaCompetencias novaFamilia;
            Competencia novaCompetencia;
            Pratica novaPratica;
            Pergunta novaPergunta;

            novoModelo.modeloID = -1;
            novoModelo.Name += " [DUP]";
            novoModelo.PublicName += " [DUP]";

            novoModelo.updateDBModelo("TEMPLATE");

            try
            {
                foreach (FamiliaCompetencias fam in oldModelo.Familias.Values)
                {
                    novaFamilia = DBHelper.Clone<FamiliaCompetencias>(fam);
                    novaFamilia.FamiliaID = -1;
                    novaFamilia.Modelo = novoModelo;
                    novaFamilia.updateDBFamilia("JC");
                    foreach (Competencia comp in fam.Competencias.Values)
                    {
                        novaCompetencia = DBHelper.Clone<Competencia>(comp);
                        novaCompetencia.CompetenciaID = -1;
                        novaCompetencia.Familia = novaFamilia;
                        novaCompetencia.updateDBCompetencia("JC");
                        foreach (Pratica prat in comp.Praticas.Values)
                        {
                            novaPratica = DBHelper.Clone<Pratica>(prat);
                            novaPratica.PraticaID = -1;
                            novaPratica.Competencia = novaCompetencia;
                            novaPratica.updateDBPratica("JC");
                            foreach (Pergunta perg in prat.Perguntas.Values)
                            {
                                novaPergunta = DBHelper.Clone<Pergunta>(perg);
                                novaPergunta.PerguntaID = -1;
                                novaPergunta.Pratica = novaPratica;
                                novaPergunta.updateDBPergunta("JC");

                            }
                        }
                    }
                }

            }
            catch
            {
                return false;
            }
            return true;
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["PESSOA_ID"] == null)
            Response.Redirect("Login.aspx");

        this.Page.Title = "multiRater 360º - Gestão de Modelo Personalístico";

        if (!IsPostBack)
        {
            getDefaultModelos();
            DivEstModelo.Visible = false;
        }
        else
        {
            // recupera o array de modelos
            modelos = (SortedList<int, ModeloCompetencias>)Session["modelos"];
        }

        if (Session["currModelo"] != null)
        {
            currModelo = (ModeloCompetencias)Session["currModelo"];
        }

        updatePerguntas();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Page.Title = "Dados Sócio Demográficos";

        getTicketList();
        getProjectInfo();
        setupStyle();

        // carrega o modelo
        if (Session["FO_Model"] == null)
        {
            modelo = ModeloCompetencias.getDBModelo(Utility.currProjeto.owner, ticketList[0].ModeloID);
            if (modelo == null)
            {
                Response.Redirect("GenericError.aspx");
                return;
            }
            modelo.loadFull(Utility.currProjeto.owner,ticketList[0]);
            Session.Add("FO_Model", modelo);
        }
        else
        {
            modelo = (ModeloCompetencias)Session["FO_Model"];
        }

        tipoDeAvaliacao();

        if (projecto.validaPagina == 1)
            NaoValidaPagina = "";
        else
            ValidaPagina = "";

        if (IsPostBack)
        {
            validateInput();
        }
        else
        {
            // carrega as combos

            fillDDL(DDLFuncao, "EDPFU");
            fillDDL(DDLAntiguidade, "EDPAN");
            fillDDL(DDLIdade, "EDPID");
            fillDDL(DDLAreaOrganica, "EDPAR");

        }

        if (DateTime.Now.Date > projecto.DataFim)
            Response.Redirect("ticketError.aspx?Error=Closed");

        Page.Title = projecto.Nome;
    }
    protected void ddlModelos_SelectedIndexChanged(object sender, EventArgs e)
    {
        currModelo = ModeloCompetencias.getDBModelo("JC", int.Parse(ddlModelos.SelectedValue));
        if (currModelo.ModelType == null || currModelo.ModelType == "")
            lblModelType.Text = "??????";
        else
            lblModelType.Text = currModelo.ModelType;

        Session.Add("currModelo", currModelo);
    }
 public void duplicate(ModeloCompetencias modelo)
 {
     this.familiaID = -1;
     this.modelo = modelo;
     this.name += "(duplicado)";
     this.updateDBFamilia("JC");
     modelo.addFamilia(this);
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        dsModelos.ConnectionString = DBHelper.ConnectionString;
        dsProjectos.ConnectionString = DBHelper.ConnectionString;

        if (Session["PESSOA_ID"] == null)
            Response.Redirect("Login.aspx");

        this.Page.Title = "multiRater 360º - Gestão de Tickets";
        chavesEmpresa.Visible = false;
        if (Session["currProjecto"] == null)
        {
            // selecciona a view de selcção de projecto
            mvTickets.ActiveViewIndex = 0;
        }
        else {
            currProjecto = (Projecto)Session["currProjecto"];
            mvTickets.ActiveViewIndex = 1; // muda para a vista seguinte
            lblProjectName.Text = "PROJECTO:" + currProjecto.Nome;
        }

        if (Session["currModelo"] != null)
        {
            currModelo = (ModeloCompetencias)Session["currModelo"];
        }

        if (IsPostBack)
        {
        }
        else
        {
        }

        InputDadosProprio.Visible = false;
        InputDadosAvaliado.Visible = false;
        chavesEmpresa.Visible = false;

        // update de links manager tickets

        updateManagerLink();
    }
        public bool GenerateReport(String templatePath, String destinationPath, DateTime dataDocumento, Pessoa self, Ticket ticket, Projecto proj, string endMarker)
        {
            try
            {
                this.rootPath = templatePath;
                this.destPath = destinationPath;
                this._self = self;
                this._ticket = ticket;
                this._projecto = proj;
                this._endMarker = endMarker;

                _Modelo = ModeloCompetencias.getDBModelo("JC", ModeloCompetencias.getPessoaModelo(_self.PessoaID, _projecto.ProjectoID));
                _Modelo.loadFull(_projecto.owner, null);

                repCalcs = new RamkoersCalculations(_Modelo, _self.PessoaID, _projecto);

                if (!repCalcs.Init())
                    repCalcs = null;

                CountUps = 0;
                CountHoriz = 0;
                CountDown = 0;
            }
            catch (Exception e)
            {
                return false;
            }

            // tudo inicializado, podemos iniciar a geração do relatório
            this.Start();

            return true;
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        Page.Title = "multiRater 360º - Take Survey";

        getTicketList();

        getProjectInfo();
        setupStyle();

        // carrega o modelo
        if (Session["FO_Model"] == null)
        {
            modelo = ModeloCompetencias.getDBModelo(Utility.currProjeto.owner, ticketList[0].ModeloID);
            if (modelo == null)
            {
                Response.Redirect("GenericError.aspx");
                return;
            }
            modelo.loadFull(Utility.currProjeto.owner, null);
            Session.Add("FO_Model", modelo);
        }
        else
        {
            modelo = (ModeloCompetencias)Session["FO_Model"];
        }

        tipoDeAvaliacao();

        if ((currCompetenciaIndex == -1) && (currFamiliaIndex == -1))
        {
            initFormulario();
        }

        currFamilia = modelo.Familias.Values[currFamiliaIndex];
        currCompetencia = currFamilia.Competencias.Values[currCompetenciaIndex];

        if (projecto.validaPagina == 1)
            NaoValidaPagina = "";
        else
            ValidaPagina = "";

        if (IsPostBack)
        {
            closing = false;

            // analisa input do participante
            String comando = txtUserCommand.Value;
            if (comando.Equals("NEXT"))
            {
                nextPage();
                saveUserInput();
            }
            else if (comando.Equals("BACK"))
            {
                prevPage();
                saveUserInput();
            }
            else if (comando.Equals("PAUSE"))
            {
                saveUserInput();
                Response.Redirect("FO_DashBoard.aspx?Ticket=" + ticketList[0].Chave + "&Cover=False&Refresh=True");
            }
            else if (comando.Equals("CLOSE"))
            {
                closing = true;
                saveUserInput();
                Response.Redirect("FO_DashBoard.aspx?Ticket=" + ticketList[0].Chave + "&Cover=False&Refresh=True");
            }
        }

        if (!IsPostBack)
        {
            int menor = int.MaxValue;
            // determina para que página temos de avançar
            foreach (Ticket t in ticketList)
            {
                if (t.pagina < menor)
                    menor = t.pagina;
            }

            for (int i = 0; i < menor; i++)
            {
                nextPage();
            }
        }

        progressBar.Comprimento = 120;

        if (DateTime.Now.Date > projecto.DataFim)
            Response.Redirect("ticketError.aspx?Error=Closed");

        RenderPage();

        ScriptManager.RegisterStartupScript(this, typeof(Page), "UniqueID", js.ToString(), true);
        ScriptManager.RegisterStartupScript(this, typeof(Page), "UniqueID1", "initCheckBoxs(); pageScroll();", true);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        getTicketList();
        getProjectInfo();
        Session.Timeout = 15;
        // language settings
        if (Context.Session["Dicionario"] != null)
        {
            dic = (Dicionario)Context.Session["Dicionario"];
        }
        else
        {
            // 2.2 OBTER INFORMAÇÃO SOBRE O IDIOMA
            String langCode;
            if (ticketList[0].LangCode != null)
                langCode = ticketList[0].LangCode;
            else if (projecto.defaultLangCode != null)
                langCode = projecto.defaultLangCode;
            else if (projecto.defaultLangCode != null && projecto.defaultLangCode.Trim() == "")
                langCode = "pt";
            else
                langCode = "pt";

            dic = new Dicionario(langCode);
            Session.Add("Dicionario", dic);
        }

        setupStyle();
        MyGlobal.addTickets(ticketList);

        // 3.1 obter outros ticket neste contexto
        List<Ticket> TMP_listaTickets = Ticket.getAllTickets(proprio.PessoaID, projecto.ProjectoID, projecto.owner);

        // 3.2 tem um ou mais ?
        if (TMP_listaTickets.Count == 1)
            Session["ONE_SHOT"] = true;

        // 3.3 há necessidade de obter dados demográficos?
        if (proprio.Demographics != null)
        {
            if (proprio.Demographics != "")
            {
                if (proprio.Demographics.StartsWith("GET"))
                {
                    // temos de recolher dados, salta para lá
                    // guarda também o endereço de retorno
                    String tickets = Request["ticket"] == null ? "" : "?ticket=" + Request["ticket"];
                    Response.Redirect("FO_Demographics.aspx" + tickets);
                }
            }
        }

        // carrega o modelo
        if (Session["FO_Model"] == null)
        {
            modelo = ModeloCompetencias.getDBModelo(Utility.currProjeto.owner, ticketList[0].ModeloID);
            if (modelo == null)
                modelo = ModeloCompetencias.getDBModelo("TEMPLATE", ticketList[0].ModeloID);

            if (modelo == null)
            {
                Response.Redirect("GenericError.aspx");
                return;
            }

            modelo.loadFull(Utility.currProjeto.owner, ticketList[0]);

            Session.Add("FO_Model", modelo);
        }
        else
        {
            modelo = (ModeloCompetencias)Session["FO_Model"];
        }
        setUpHistograma();
        tipoDeAvaliacao();

        if ((currCompetenciaIndex == -1) && (currFamiliaIndex == -1))
        {
            initFormulario();
        }

        if (IsPostBack)
        {
            closing = false;

            currFamilia = modelo.Familias.Values[currFamiliaIndex];
            currCompetencia = currFamilia.Competencias.Values[currCompetenciaIndex];

            // analisa input do participante
            String comando = txtUserCommand.Value;
            if (comando.Equals("NEXT"))
            {
                saveUserInput();
                nextPage();
            }
            else if (comando.Equals("BACK"))
            {
                saveUserInput();
                prevPage();
            }
            else if (comando.Equals("NEVER_TIMEOUT"))
            {
                saveUserInput();
            }
            else if (comando.Equals("PAUSE"))
            {
                saveUserInput();
                if (Session["ONE_SHOT"] != null)
                    Response.Redirect("FO_Suspend.aspx");
                else
                    Response.Redirect("FO_DashBoard.aspx?Ticket=" + ticketList[0].Chave + "&Cover=False&Refresh=True");
            }
            else if (comando.Equals("CLOSE"))
            {
                closing = true;

                saveUserInput();
                if (Session["ONE_SHOT"] != null)
                    Response.Redirect("FO_Complete.aspx");
                else
                    Response.Redirect("FO_DashBoard.aspx?Ticket=" + ticketList[0].Chave + "&Cover=False&Refresh=True");
            }
        }

        if (!IsPostBack)
        {
            int menor = int.MaxValue;
            // determina para que página temos de avançar
            currPage = 0;
            currCompetenciaIndex = 0;
            currFamiliaIndex = 0;

            currFamilia = modelo.Familias.Values[currFamiliaIndex];
            currCompetencia = currFamilia.Competencias.Values[currCompetenciaIndex];

            foreach (Ticket t in ticketList)
            {
                if (t.pagina < menor)
                    menor = t.pagina;
            }

            for (int i = 0; i < menor; i++)
            {
                if (!nextPage())
                    break;
            }

        }

        progressBar.Comprimento = 120;

        if (DateTime.Now.Date > projecto.DataFim)
            Response.Redirect("ticketError.aspx?Error=Closed");

        totalPaginas = (int)Math.Round(((float)(totalPerguntas / (float)(perguntasPorPagina) + 0.5f)), 0);
        if (totalPerguntas % perguntasPorPagina == 0)
            totalPaginas--;

        RenderPage();

        if (currCompetencia != null)
        {
            if ((projecto.validaPagina == 1) && (currCompetencia.Opcional == true))
                ValidaPagina = "";
            else if ((projecto.validaPagina == 1))
                NaoValidaPagina = "";
            else
                ValidaPagina = "";
        }
        else
        {
            if ((projecto.validaPagina == 1))
                NaoValidaPagina = "";
            else
                ValidaPagina = "";
        }

        Page.Title = projecto.Nome;
        lblStatsTitle.Text = dic.getResource(45); /*Estatísticas*/
        lblProgressoTit.Text = dic.getResource(39); /*Progresso*/
        lblHistTit.Text = dic.getResource(40); /*Histograma*/
        lblRelFunc.Text = dic.getResource(42); /*Relevância para a Função*/
        if (currCompetencia.Type == "C" || currCompetencia.Type == "D")
            lblCompCritic.Text = "";
        else
            lblCompCritic.Text = dic.getResource(41); /*Comportamentos Críticos*/

        lblRelFunc2.Text = dic.getResource(42); /*Relevância para a Função*/
        lblComents.Text = dic.getResource(63); /*Comentários e Observações*/

        // acerta o tamanho da escala
        histVertical.TamanhoEscala = projecto.TamanhoEscala;
        histRelev.TamanhoEscala = projecto.TamanhoEscala;

        String messes = "";
        messes += "var mensagem1 = \"" + dic.getResource(64) + "\";";
        messes += "var mensagem2 = \"" + dic.getResource(65) + "\";";
        messes += "var mensagem3 = \"" + dic.getResource(66) + "\";";
        messes += "var mensagem4 = \"" + dic.getResource(67) + "\";";
        messes += "var mensagem5 = \"" + "Por favor complete a sua resposta." + "\";";

        MensagensIdioma = MensagensIdioma.Replace("####", messes);

        ScriptManager.RegisterStartupScript(this, typeof(Page), "UniqueID", js.ToString(), true);
        //ScriptManager.RegisterStartupScript(this, typeof(Page), "UniqueID1", "initCheckBoxs();", true);
    }
 protected void translate(ModeloCompetencias DestLang)
 {
     this.TextoComentarios = DestLang.TextoComentarios;
     this.Scale = DestLang.Scale;
     this.ScaleDesc = DestLang.ScaleDesc;
     this.Name = DestLang.Name;
     this.PublicName = DestLang.PublicName;
     this.Description = DestLang.Description;
     this.IntroText = DestLang.IntroText;
     this.AllowRespondentComments = DestLang.AllowRespondentComments;
     this.CommentsText = DestLang.CommentsText;
     this.field1 = DestLang.field1;
     this.langCode = DestLang.langCode;
 }