예제 #1
0
        void CorrectionCode(CAPA.Modeles.Action a)
        {
            string code = a.Code;

            //Cas d'une action
            if (code.Substring(0, 3) == "ACT")
            {
                string plan = "";
                string OS = ""; string OG = ""; string OP = "";
                string Autre = "";

                string[] lst = code.Split('-');

                plan = lst[1].ToUpper().Trim();
                if (lst.Length >= 3)
                {
                    OS = lst[2].ToUpper().Trim();
                }
                if (lst.Length >= 4)
                {
                    OG = lst[3].ToUpper().Trim();
                }
                if (lst.Length >= 5)
                {
                    OP = lst[4].ToUpper().Trim();
                }
                if (lst.Length >= 6)
                {
                    Autre = lst[5].ToUpper().Trim();
                }

                code = "ACT-" + plan;

                if (OS.Length > 0)
                {
                    OS = OS.Replace("OS", ""); code += "-OS" + string.Format("{0:00}", int.Parse(OS));
                }
                if (OG.Length > 0)
                {
                    OG = OS.Replace("OS", ""); code += "-OG" + string.Format("{0:00}", int.Parse(OG));
                }
                if (OP.Length > 0)
                {
                    OP = OS.Replace("OS", ""); code += "-OP" + string.Format("{0:00}", int.Parse(OP));
                }
                if (Autre.Length > 0)
                {
                    code += "+" + string.Format("{0:000}", int.Parse(Autre));
                }
                //MessageBox.Show(Code + "-->" + code);
                a.Code       = code;
                a.TypeAction = TypeAction.ACTION;
            }
            else
            {
                //Opération
                code         = code.Replace("OPE-", "");
                code         = "OPE-" + code;
                a.Code       = code;
                a.TypeAction = TypeAction.OPERATION;
            }
        }
예제 #2
0
        //Extraction d'une page Opération
        void Extraction_Opération(string Code)
        {
            string repert = Chemin + "//Import//Operation//";

            if (!(Directory.Exists(repert)))
            {
                Directory.CreateDirectory(repert);
            }
            string Fichier = repert + Code + ".xml";

            //Test le mode d'extraction
            if (!(optSave.Checked))
            {
                //Téléchargement de la page
                string url     = "https://ars-hdf.xwiki.com/xwiki/rest/wikis/plansactions/spaces/Projet/pages/" + Code + "/objects/Projet.Code.ProjetClass/0";
                string command = "curl -o " + Fichier + " --cookie " + Chemin + "/Import/loginCookies " + url;
                ExecuteCommandSync(command);
            }

            //Lecture des informations
            DataSet ds = new DataSet();

            try
            {
                ds.ReadXml(Fichier);
            }
            catch { lst.Items.Add("Erreur Opération : " + Code); return; }

            //Traitement des informations
            bool    modif = false;
            lAction lp    = new lAction();

            lp.Acces = Acces;
            lp.ChargeCode(Code);

            //Enregistrement des informations
            CAPA.Modeles.Action p;
            if (lp.Liste.Count > 0)
            {
                p     = lp.Liste[0];
                modif = true;
            }
            else
            {
                p            = new CAPA.Modeles.Action();
                p.Code       = Code;
                p.TypeAction = TypeAction.OPERATION;
                p.Actif      = true;
            }

            //Traitement des données
            foreach (DataRow r in ds.Tables["Property"].Rows)
            {
                switch (r["name"].ToString())
                {
                case "operation_libelle":
                    p.Libelle = r["value"].ToString();
                    break;
                }
            }

            if (!modif)
            {
                lp.Ajouter(p);
                lst.SelectedIndex = lst.Items.Count - 1;
                lst.Items[lst.Items.Count - 1] += lst.Items[lst.Items.Count - 1] + "-->Créé";
            }
            else
            {
                lp.Enregistrer();
                lst.SelectedIndex = lst.Items.Count - 1;
                lst.Items[lst.Items.Count - 1] += lst.Items[lst.Items.Count - 1] + "-->Modifié";
            }
        }