예제 #1
0
파일: Program.cs 프로젝트: ykebaili/Timos
        private static void ImporterChamps()
        {
            StreamReader reader   = new StreamReader("C:\\Partage\\Import Orange\\Champs controles.txt", Encoding.Default);
            string       strLigne = reader.ReadLine();

            strLigne = reader.ReadLine();
            using (CContexteDonnee contexte = new CContexteDonnee(CSessionClient.GetSessionUnique().IdSession, true, false))
            {
                while (strLigne != null)
                {
                    CRoleChampCustom roleSite            = CRoleChampCustom.GetRole(CSite.c_roleChampCustom);
                    CRoleChampCustom roleWorkBook        = CRoleChampCustom.GetRole(CDossierSuivi.c_roleChampCustom);
                    CRoleChampCustom roleCaracteristique = CRoleChampCustom.GetRole(CCaracteristiqueEntite.c_roleChampCustom);
                    string[]         datas = strLigne.Split('\t');
                    if (datas.Length >= 1)
                    {
                        CChampCustom champ = new CChampCustom(contexte);
                        if (!champ.ReadIfExists(new CFiltreData(CChampCustom.c_champNom + "=@1",
                                                                datas[0])))
                        {
                            champ.CreateNewInCurrentContexte();
                        }
                        champ.Nom = datas[0];
                        C2iTypeDonnee tp = new C2iTypeDonnee(TypeDonnee.tString);
                        if (datas.Length > 1)
                        {
                            if (datas[1].ToUpper() == "BOOL")
                            {
                                tp = new C2iTypeDonnee(TypeDonnee.tBool);
                            }
                            else if (datas[1].ToUpper() == "DATE")
                            {
                                tp = new C2iTypeDonnee(TypeDonnee.tDate);
                            }
                        }
                        champ.TypeDonneeChamp = tp;
                        champ.Categorie       = "";
                        if (datas.Length > 2)
                        {
                            champ.Categorie = datas[2];
                        }
                        CRoleChampCustom role = roleCaracteristique;
                        champ.Role = role;
                    }
                    strLigne = reader.ReadLine();
                }
                reader.Close();
                CResultAErreur result = contexte.SaveAll(true);
                if (!result)
                {
                    CFormAfficheErreur.Show(result.Erreur);
                }
            }
        }
예제 #2
0
        //----------------------------------------------------
        public bool AssociationRapide(CContexteDonnee ctxEnEdition, bool bCreationAutomatique)
        {
            if (Champ == null)
            {
                return(false);
            }
            if (IdChampCustom != null)
            {
                return(true);
            }
            string strNomChamp         = Champ.NomChamp;
            CListeObjetsDonnees lst    = new CListeObjetsDonnees(ctxEnEdition, typeof(CChampCustom));
            CFiltreData         filtre = new CFiltreData(CChampCustom.c_champNom + " like @1",
                                                         strNomChamp);
            CChampCustom champ           = new CChampCustom(ctxEnEdition);
            TypeDonnee   typeChampCustom = GetTypeChampCustom(Champ.TypeChamp);
            int          nIndex          = 0;

            while (champ.ReadIfExists(filtre))
            {
                if (champ.CodeRole == CEntiteSnmp.c_roleChampCustom &&
                    champ.TypeDonneeChamp.TypeDonnee == typeChampCustom)
                {
                    IdChampCustom = champ.Id;
                    return(true);
                }
                nIndex++;
                strNomChamp          = Champ.NomChamp + "_" + nIndex;
                filtre.Parametres[0] = strNomChamp;
            }
            if (!bCreationAutomatique)
            {
                return(false);
            }
            champ = new CChampCustom(ctxEnEdition);
            champ.CreateNewInCurrentContexte();
            champ.Nom           = strNomChamp;
            champ.TypeDonneeInt = (int)typeChampCustom;
            champ.CodeRole      = CEntiteSnmp.c_roleChampCustom;
            IdChampCustom       = champ.Id;
            return(true);
        }