2015-11-24 1 views
1

J'ai écrit un cfc pour gérer toutes les fonctions pour un aspect d'un projet. J'écris généralement dans des balises mais j'ai choisi d'apprendre quelque chose de nouveau, donc je l'ai écrit dans un script. Tout mon travail et mes tests ont été effectués sur une CommandBox exécutant Lucee pour un démarrage rapide et un environnement de développement. Ça a marché comme sur des roulettes. Maintenant, quand je l'ai téléchargé sur notre serveur de production en utilisant ACF 8, il ne lira aucun fichier. Je navigue à l'adresse du cfc et où il afficherait typiquement les fonctions qui sont accessibles je reçois le code dans un paragraphe. Avant de réécrire ceci dans les balises, je veux m'assurer qu'il s'agit d'un problème de compatibilité avec ACF 8 et non de mon code et/ou de mon travail. S'il vous plaît ne me martelez pas pour ne pas utiliser params.Composants et ColdFusion 8

Voici mon code:

component { 
    DSN = 'xxxx'; 

    public function init(){ 
    } 


    remote function BranchContact(MainContactID, BranchOfContactID, UserID) returnformat="plain"{ 

     data = IsBranch(BranchOfContactID); 

     if(data.branchTotal == 0){ 
      // result = 'no branches'; 
      result = InsertBranch(MainContactID, BranchOfContactID, UserID);  
      //WriteBranchingHistory(MainContactID, BranchOfContactID, UserID);  
      result = 1; 
     } 
     else{ 
      // message = 'It appears that you are branching to an account is already a branch - from component'; 
      queryString = 'Select top 1 ParentCID from branches where ChildCID =' & BranchOfContactID; 
      data = RunQuery(queryString); 
      result = data.ParentCID; 
     } 
     return result; 

    } 

    private function IsBranch(BranchOfContactID){ 
     queryString = 'Select count(*) as branchTotal from branches where ChildCID = ' & BranchOfContactID; 
     RunQuery(queryString); 
     return data; 
    } 

    private function InsertBranch(ParentCID, ChildCID, UserID){ 
     // try{   
      queryString = 'Insert into Branches (ParentCID, ChildCID, UserID) values (' & ChildCID & ', ' & ParentCID & ', '& UserID & ')'; 
      data = RunQuery(queryString); 
      //WriteBranchingHistory(MainContactID, BranchOfContactID, UserID); 
      //need to write the branching history to the contact history table so that is can be tracked 
      contactResultsID = 102; 
      note = 'Account branched to - ' & ChildCID; 
      quotedNote = ''''&note&''''; 
      activityType = 'Branched'; 
      quotedActivity = ''''&activityType&''''; 
      campaignID = 0; 
      today = 'getdate()'; 

      AddContactHistory(ParentCID, today, contactresultsID, UserID, quotedActivity, quotedNote, campaignID); 
      //return history; 
      return data; 
     // } 
     // catch(e){ 
     // errorMessage = 'While trying to branch account'; 
     // message = error(errorMessage); 
     // return message; 
     // } 

    } 

    remote function Delete(ChildCID, UserID) returnformat="plain"{ 
     // try{ 
      //have to use a query to get the parentcid since it will be empty when the ajax query is triggered 
      Parent = GetParent(ChildCID); 
      queryString = 'Delete from branches where ChildCID = ' & ChildCID; 
      data = RunQuery(queryString); 
      //WriteBranchingHistory(MainContactID, BranchOfContactID, UserID) 

      contactResultsID = 103; 
      note = 'Account unbranched from - ' & Parent.parentCID; 
      quotedNote = ''''&note&''''; 
      activityType = 'Removed Branch'; 
      quotedActivity = ''''&activityType&''''; 
      campaignID = 0; 
      today = 'getdate()'; 

      AddContactHistory(ChildCID, today, contactresultsID, UserID, quotedActivity, quotedNote, campaignID); 




      return data; 
     // } 
     // catch(e){ 
     // errorMessage = 'While trying to delete branching'; 
     // message = error(errorMessage); 
     // return e; 
     // } 


    } 

    private function Update(){ 

    } 

    <!--- WriteBranchHistory has not been completed 
    public function WriteBranchingHistory(MainContactID, BranchOfContactID, UserID) returnformat="plain"{ 


     try{ 
      queryString = 'insert into BranchHistory(contactID, ChildContactID, UserID, InsertDate) values 
      ('& MainContactiD &', '& BranchContactID & ', ' & UserID & ', getdate());'; 
      data = RunQuery(queryString); 
      // return data; 
      //oldMar = GetOldMar(MainContactID); 
      // writeDump(oldMar); 
      // writeDump(queryString); 
      //return oldMar; 

     } 
     catch(e){ 
      errorMessage = 'While trying to add branch history'; 
      message = error(errorMessage); 
      return message; 
     } 

    } 

    ---> 

    public function GetParent(ChildCID) returnformat="html"{ 

     queryString = 'Select top 1 parentCID from branches where childCID = ' & ChildCID; 
     data = RunQuery(queryString); 
     return data; 
    } 

    public function GetUserInfo(userid){ 
     myQuery = new Query(); 
     myQuery.addParam(name="userid", value=userid, cfsqltype="cf_sql_numeric"); 
     myQuery.setDataSource(DSN); 
     myQuery.setSQL('select * from users where userid = :userid'); 
     data = myQuery.execute().getResult(); 
     return data; 

    } 

    private function RunQuery(queryString){ 
     myQuery = new Query(); 
     // myQuery.addParam(name="ContactID", value=ContactID, cfsqltype="cf_sql_numeric"); 
     myQuery.setDataSource(DSN); 
     myQuery.setSQL(queryString); 
     data = myQuery.execute().getResult(); 
     return data; 
    } 

    private function error(errorMessage){ 
     message = "Oops something went wrong <br/>" & errorMessage; 
     return message; 
    } 

    private function AddContactHistory(ParentCID, today, contactresultsID, UserID, quotedActivity, quotedNote, campaignID) { 
     InsertHistoryString = 'insert into contacthistory (contactid, historydate, contactresultID, userid, activitytype, note, campaignID) values 
       ('&ParentCID& ', ' &today& ', ' &contactresultsID& ', ' &UserID& ', ' &quotedActivity& ', ' &quotedNote& ', ' &CampaignID& ');'; 
     InsertHistory = RunQuery(InsertHistoryString); 

    } 

} 
+0

Vous avez votre réponse, mais en règle générale: ne se développe pas sur une autre plate-forme et/ou une version de cette que vous déployez. –

+1

Je ne le fais généralement pas mais notre système est ACF 8 et nous n'avons pas d'environnement de développement et pas de budget pour en créer un. De plus, en 2015, il est difficile de trouver un moteur cfml aussi vieux. J'ai décidé de lancer la commandbox avec lucee comme test afin que je puisse simplement courir depuis mon système. J'ai vu la nuit dernière alors que je cherchais l'administrateur de Lucee que je pourrais être en mesure de le mettre dans une version antérieure, mais j'ai besoin de demander à Brad. –

Répondre