//---------------------------------------------------------------------- public CResultAErreur SetParametres(Dictionary <string, object> dicParametres) { CResultAErreur result = CResultAErreur.True; object obj = null; if (dicParametres.TryGetValue(m_cParametreReportId, out obj)) { if (obj is int) { m_rapport = new C2iRapportCrystal(CSc2iWin32DataClient.ContexteCourant); if (!m_rapport.ReadIfExists((int)obj)) { result.EmpileErreur(I.T("There is no Crystal Report Model corresponding to the Id: @1|10006", ((int)obj).ToString())); } } else if (obj is string) { m_rapport = new C2iRapportCrystal(CSc2iWin32DataClient.ContexteCourant); if (!m_rapport.ReadIfExists(CDbKey.CreateFromStringValue((string)obj))) { result.EmpileErreur(I.T("There is no Crystal Report Model corresponding to the Universal : @1", (string)obj)); } } else { result.EmpileErreur(I.T("The Report ID parameter must be an integer value|10007")); } } return(result); }
//---------------------------------------------------------------------- public CFormVisualisationRapport(C2iRapportCrystal rapport) { // Cet appel est requis par le Concepteur Windows Form. InitializeComponent(); m_rapport = rapport; }
public CResultAErreur InitFromContexte(CContexteFormNavigable contexte) { CResultAErreur result = CResultAErreur.True; m_contexte = contexte; C2iRapportCrystal tempRapport = new C2iRapportCrystal(CSc2iWin32DataClient.ContexteCourant); tempRapport.Id = (int)contexte["CHAMP_ID"]; m_rapport = tempRapport; if (AfterInitFromContexte != null) { AfterInitFromContexte(this, contexte); } return(result); }
/// //////////////////////////////////////////////////////// public override CResultAErreur VerifieDonnees() { CResultAErreur result = base.VerifieDonnees(); using (CContexteDonnee contexte = new CContexteDonnee(Process.IdSession, true, false)) { C2iRapportCrystal etat = new C2iRapportCrystal(contexte); if (!etat.ReadIfExists(m_nIdEtatCrystal)) { result.EmpileErreur("Incorrect report model|30042"); return(result); } if (m_listeIdsCategorieStockage.Count < 1 && m_bStockerGed) { result.EmpileErreur("The report must be stored at least in one EDM category|30043"); } CMultiStructureExport multiStruct = etat.MultiStructure; if (multiStruct == null) { result.EmpileErreur("The report does not have a data structure|30044"); return(result); } foreach (IVariableDynamique variable in multiStruct.ListeVariables) { C2iExpression exp = GetExpressionForVariableFiltre(variable.IdVariable); if (exp != null && !exp.TypeDonnee.Equals(variable.TypeDonnee)) { result.EmpileErreur("The value of the variable @1 is not compatible with the variable type|30045", variable.Nom); } } } return(result); }
private void UpdateListeVariables() { m_bListeVariablesRemplie = false; m_variableEnCoursEdition = null; m_txtFormuleVariable.Visible = false; if (!(m_comboModeleEtat.SelectedValue is C2iRapportCrystal)) { m_wndListeVariables.Enabled = false; m_txtFormuleVariable.Visible = false; return; } m_wndListeVariables.Enabled = true; m_txtFormuleVariable.Visible = true; C2iRapportCrystal etat = (C2iRapportCrystal)m_comboModeleEtat.SelectedValue; CMultiStructureExport multiStructure = etat.MultiStructure; if (multiStructure == null) { m_wndListeVariables.Enabled = false; m_txtFormuleVariable.Visible = false; return; } IElementAVariablesDynamiques element = multiStructure; ArrayList lst = new ArrayList(element.ListeVariables); for (int nVar = lst.Count - 1; nVar >= 0; nVar--) { if (!((IVariableDynamique)lst[nVar]).IsChoixUtilisateur()) { lst.RemoveAt(nVar); } } m_wndListeVariables.Remplir(lst, false); m_bListeVariablesRemplie = true; }
//------------------------------------------------------------------- public override CResultAErreur TraitementAvantSauvegarde(CContexteDonnee contexte) { CResultAErreur result = CResultAErreur.True; DataTable table = contexte.Tables[GetNomTable()]; foreach (DataRow row in table.Rows) { C2iRapportCrystal rapport = new C2iRapportCrystal(row); if (row.RowState == DataRowState.Modified) { rapport.NumVersion++; } else if (row.RowState == DataRowState.Added) { lock (this) { CDatabaseRegistre registre = new CDatabaseRegistre(m_nIdSession); rapport.CodeEtat = (int)registre.GetValeurLong(c_strNewCodeEtat, 1000); registre.SetValeur(c_strNewCodeEtat, (rapport.CodeEtat + 1).ToString()); } } } return(result); }
//------------------------------------------------------------------- public override CResultAErreur VerifieDonnees(CObjetDonnee objet) { CResultAErreur result = CResultAErreur.True; try { C2iRapportCrystal rapport = (C2iRapportCrystal)objet; if (rapport.Libelle == "") { result.EmpileErreur(I.T("The report label cannot be empty|103")); } if (!CObjetDonneeAIdNumerique.IsUnique(rapport, C2iRapportCrystal.c_champLibelle, rapport.Libelle)) { result.EmpileErreur(I.T("Another report exists with this label|104")); } } catch (Exception e) { result.EmpileErreur(new CErreurException(e)); } return(result); }
/// //////////////////////////////////////////////////////// protected override CResultAErreur MyExecute(CContexteExecutionAction contexte) { CResultAErreur result = CResultAErreur.True; //Préparation du filtre C2iRapportCrystal rapport = new C2iRapportCrystal(contexte.ContexteDonnee); if (!rapport.ReadIfExists(IdEtatCrystal)) { result.EmpileErreur(I.T("The report @1 does not exist|30046", IdEtatCrystal.ToString())); return(result); } CContexteEvaluationExpression contexteEvaluation = new CContexteEvaluationExpression(Process); CMultiStructureExport multiStructure = rapport.MultiStructure; if (multiStructure == null) { result.EmpileErreur(I.T("The report does not have a data structure|30044")); return(result); } foreach (IVariableDynamique variable in multiStructure.ListeVariables) { if (variable.IsChoixUtilisateur()) { C2iExpression expressionVariable = GetExpressionForVariableFiltre(variable.IdVariable); if (expressionVariable != null) { result = expressionVariable.Eval(contexteEvaluation); if (!result) { result.EmpileErreur(I.T("Error in variable '@1' assignment|30047", variable.Nom)); return(result); } multiStructure.SetValeurChamp(variable, result.Data); } } } ReportDocument report = null; try { result = rapport.CreateFichierExport(multiStructure, m_formatExport, ref report); if (!result) { result.EmpileErreur(I.T("Error while creating the report|30048")); return(result); } CFichierLocalTemporaire fichierPDF = (CFichierLocalTemporaire)result.Data; #region Impression de l'état if (m_bImprimerEtat) { CSessionClient sessionClient = CSessionClient.GetSessionForIdSession(contexte.IdSession); CConfigurationsImpression configuration = sessionClient.ConfigurationsImpression; if (configuration.NomImprimanteSurServeur != "") { report.PrintOptions.PrinterName = configuration.NomImprimanteSurServeur; } try { report.PrintToPrinter(1, false, 0, 0); } catch (Exception e) { result.EmpileErreur(new CErreurException(e)); result.EmpileErreur(I.T("Printing error|30049")); return(result); } /*if ( sessionClient != null ) * { * if ( sessionClient.GetInfoUtilisateur().IdUtilisateur == contexte.Branche.IdUtilisateur ) * { * if ( sessionClient.ConfigurationsImpression.NomImprimanteSurClient != "" ) * report.PrintOptions.PrinterName = sessionClient.ConfigurationsImpression.NomImprimanteSurClient; * CServiceSurClient service = sessionClient.GetServiceSurClient ( CActionImprimerEtat.c_idServiceClientImprimerEtat ); * if ( service != null ) * { * result = service.RunService ( report ); * } * } * }*/ /* * using ( CFichierLocalTemporaire fichierRpt = new CFichierLocalTemporaire("rpt") ) * { * fichierRpt.CreateNewFichier(); * try * { * report.Refresh(); * report.SaveAs (fichierRpt.NomFichier, ReportFileFormat.VSNetFileFormat ); * } * catch ( Exception e ) * { * result.EmpileErreur ( new CErreurException ( e ) ); * } * if ( result ) * { * //Stocke le fichier dans la ged pour pouvoir l'envoyer sur le client * using ( CProxyGED proxy = new CProxyGED ( Process.IdSession, null ) ) * { * proxy.CreateNewFichier(); * proxy.AttacheToLocal ( fichierRpt.NomFichier ); * * proxy.UpdateGed(); * * CReferenceDocument refDoc = proxy.ReferenceAttachee; * result = service.RunService ( refDoc ); * if ( !result ) * { * result.EmpileErreur("Erreur à l'impression du document"); * return result; * } * } * } * } * } * } * }*/ } #endregion #region Stockage dans la ged if (m_bStockerGed) { //On a notre fichier PDF, création du document string strCle = ""; string strDescriptif = ""; string strLibelle = ""; result = ExpressionCle.Eval(contexteEvaluation); if (result) { strCle = result.Data.ToString(); } else { result.EmpileErreur(I.T("Document key could not be evaluated|30050")); return(result); } result = ExpressionLibelle.Eval(contexteEvaluation); if (result) { strLibelle = result.Data.ToString(); } else { result.EmpileErreur(I.T("Document label could not be evaluated|30051")); return(result); } result = ExpressionDescriptif.Eval(contexteEvaluation); if (result) { strDescriptif = result.Data.ToString(); } else { result.EmpileErreur(I.T("Document description could not be evaluated|30052")); return(result); } CDocumentGED doc = new CDocumentGED(contexte.ContexteDonnee); //Si la clé n'est pas nulle, cherche un document avec cette clé if (strCle.Trim() != "") { CFiltreData filtre = new CFiltreData(CDocumentGED.c_champCle + "=@1", strCle); if (!doc.ReadIfExists(filtre)) { doc.CreateNew(); } else { doc.BeginEdit(); } } else { doc.CreateNew(); } doc.Libelle = strLibelle; doc.Descriptif = strDescriptif; doc.Cle = strCle; ArrayList lstToCreate = (ArrayList)ListeIdsCategoriesStockage.Clone(); ArrayList lstToDelete = new ArrayList(); //Affecte les catégories CListeObjetsDonnees listeCategoriesExistantes = CRelationDocumentGED_Categorie.GetRelationsCategoriesForDocument(doc); foreach (CRelationDocumentGED_Categorie rel in listeCategoriesExistantes) { if (!lstToCreate.Contains(rel.Categorie.Id)) { lstToDelete.Add(rel); } lstToCreate.Remove(rel.Categorie.Id); } foreach (CRelationDocumentGED_Categorie rel in lstToDelete) { rel.Delete(); } foreach (int nId in lstToCreate) { CCategorieGED cat = new CCategorieGED(doc.ContexteDonnee); if (cat.ReadIfExists(nId)) { CRelationDocumentGED_Categorie rel = new CRelationDocumentGED_Categorie(doc.ContexteDonnee); rel.CreateNewInCurrentContexte(); rel.Categorie = cat; rel.Document = doc; } } CProxyGED proxy = new CProxyGED(Process.IdSession, doc.IsNew()?null:doc.ReferenceDoc); proxy.AttacheToLocal(fichierPDF.NomFichier); result = proxy.UpdateGed(); if (!result) { return(result); } doc.ReferenceDoc = (CReferenceDocument)result.Data; result = doc.CommitEdit(); fichierPDF.Dispose(); if (VariableResultat != null) { Process.SetValeurChamp(VariableResultat, doc); } } #endregion } catch (Exception e) { result.EmpileErreur(new CErreurException(e)); } finally { if (report != null) { report.Close(); } } return(result); }
/// ////////////////////////////////////////// protected override void InitChamps() { base.InitChamps(); m_wndAideFormule.FournisseurProprietes = ObjetEdite.Process; m_wndAideFormule.ObjetInterroge = typeof(CProcess); m_txtFormuleCle.Init(m_wndAideFormule.FournisseurProprietes, m_wndAideFormule.ObjetInterroge); m_txtFormuleDescriptif.Init(m_wndAideFormule.FournisseurProprietes, m_wndAideFormule.ObjetInterroge); m_txtFormuleLibelle.Init(m_wndAideFormule.FournisseurProprietes, m_wndAideFormule.ObjetInterroge); m_txtFormuleVariable.Init(m_wndAideFormule.FournisseurProprietes, m_wndAideFormule.ObjetInterroge); CListeObjetsDonnees liste = new CListeObjetsDonnees(CSc2iWin32DataClient.ContexteCourant, typeof(CCategorieGED)); m_wndListeCategories.Remplir(liste, false); foreach (ListViewItem item in m_wndListeCategories.Items) { CCategorieGED cat = (CCategorieGED)item.Tag; if (ActionGenererEtat.ListeIdsCategoriesStockage.Contains(cat.Id)) { item.Checked = true; } else { item.Checked = false; } } liste = new CListeObjetsDonnees(CSc2iWin32DataClient.ContexteCourant, typeof(sc2i.documents.C2iRapportCrystal)); m_comboModeleEtat.ListDonnees = liste; C2iRapportCrystal rapport = new C2iRapportCrystal(CSc2iWin32DataClient.ContexteCourant); m_tableIdVariableToFormule.Clear(); if (rapport.ReadIfExists(ActionGenererEtat.IdEtatCrystal)) { m_comboModeleEtat.SelectedValue = rapport; CMultiStructureExport multiStructure = rapport.MultiStructure; if (multiStructure != null) { foreach (IVariableDynamique variable in multiStructure.ListeVariables) { m_tableIdVariableToFormule[variable.IdVariable] = ActionGenererEtat.GetExpressionForVariableFiltre(variable.IdVariable); } } } else { m_comboModeleEtat.SelectedValue = null; } UpdateListeVariables(); m_txtFormuleCle.Text = ActionGenererEtat.ExpressionCle.GetString(); m_txtFormuleDescriptif.Text = ActionGenererEtat.ExpressionDescriptif.GetString(); m_txtFormuleLibelle.Text = ActionGenererEtat.ExpressionLibelle.GetString(); m_cmbFormat.DisplayMember = "Libelle"; m_cmbFormat.ValueMember = "Valeur"; m_cmbFormat.DataSource = CUtilSurEnum.GetCouplesFromEnum(typeof(TypeFormatExportCrystal)); m_cmbFormat.SelectedValue = (int)ActionGenererEtat.FormatExport; m_chkStocker.Checked = ActionGenererEtat.StockerDansLaGed; m_chkImprimer.Checked = ActionGenererEtat.ImprimerSurClient; }
/// ////////////////////////////////////////// protected override sc2i.common.CResultAErreur MAJ_Champs() { CResultAErreur result = base.MAJ_Champs(); OnChangeVariable(); if (!(m_comboModeleEtat.SelectedValue is C2iRapportCrystal)) { result.EmpileErreur(I.T("Select a report|30248")); } C2iRapportCrystal rapport = (C2iRapportCrystal)m_comboModeleEtat.SelectedValue; ActionGenererEtat.IdEtatCrystal = rapport.Id; ActionGenererEtat.ClearExpressionsVariables(); foreach (string strIdVariable in m_tableIdVariableToFormule.Keys) { C2iExpression exp = (C2iExpression)m_tableIdVariableToFormule[strIdVariable]; if (exp != null) { ActionGenererEtat.SetExpressionForVariableFiltre(strIdVariable, exp); } } ActionGenererEtat.ListeIdsCategoriesStockage.Clear(); foreach (ListViewItem item in m_wndListeCategories.CheckedItems) { ActionGenererEtat.ListeIdsCategoriesStockage.Add( ((CCategorieGED)item.Tag).Id); } CResultAErreur resultExp = GetFormule(m_txtFormuleCle); if (!resultExp) { resultExp.EmpileErreur(I.T("Error in key formula|30249")); result.Erreur += resultExp.Erreur; result.Result = false; } else { ActionGenererEtat.ExpressionCle = (C2iExpression)resultExp.Data; } resultExp = GetFormule(m_txtFormuleLibelle); if (!resultExp) { resultExp.EmpileErreur(I.T("Error in label formula|30250")); result.Erreur += resultExp.Erreur; result.Result = false; } else { ActionGenererEtat.ExpressionLibelle = (C2iExpression)resultExp.Data; } resultExp = GetFormule(m_txtFormuleDescriptif); if (!resultExp) { resultExp.EmpileErreur(I.T("Error in description formula|30251")); result.Erreur += resultExp.Erreur; result.Result = false; } else { ActionGenererEtat.ExpressionDescriptif = (C2iExpression)resultExp.Data; } ActionGenererEtat.FormatExport = (TypeFormatExportCrystal)m_cmbFormat.SelectedValue; ActionGenererEtat.StockerDansLaGed = m_chkStocker.Checked; ActionGenererEtat.ImprimerSurClient = m_chkImprimer.Checked; return(result); }