public StatistiqueClient(Model.Sage.P_STATISTIQUE SageStatistiqueClient, ObservableCollection <InformationLibreValeursMode> ListInformationLibreMode, ObservableCollection <Model.Prestashop.PsCustomerFeatureLang> ListCustomerFeature) { SageStatistique = SageStatistiqueClient; Model.Local.StatistiqueClientRepository StatistiqueClientRepository = new Local.StatistiqueClientRepository(); StatClient = new Local.StatistiqueClient(); if (StatistiqueClientRepository.ExistStatClient(SageStatistique.S_Intitule)) { StatClient = StatistiqueClientRepository.ReadStatClient(SageStatistique.S_Intitule); } else { StatClient.Sag_StatClient = SageStatistique.S_Intitule; } InfoValeursMode = ListInformationLibreMode.FirstOrDefault(i => i.Marq == StatClient.Inf_Mode); if (StatClient.Cha_Id != 0 && ListCustomerFeature.Count(c => c.IDCustomerFeature == StatClient.Cha_Id) == 1) { CustomerFeature = ListCustomerFeature.FirstOrDefault(c => c.IDCustomerFeature == StatClient.Cha_Id); } else { CanCreateCustomerFeature = (!new Model.Prestashop.PsCustomerFeatureLangRepository().ExistSageInformationLibre(SageStatistique.S_Intitule)) ? true : false; } }
public void Exec(Int32 SageClientSend) { try { if (Core.Global.GetConfig().StatInfolibreClientActif) { Model.Local.CustomerRepository CustomerRepository = new Model.Local.CustomerRepository(); if (CustomerRepository.ExistSage(SageClientSend)) { Model.Local.Customer Customer = CustomerRepository.ReadSage(SageClientSend); Model.Sage.F_COMPTETRepository F_COMPTETRepository = new Model.Sage.F_COMPTETRepository(); if (F_COMPTETRepository.ExistId(Customer.Sag_Id)) { Model.Sage.F_COMPTET F_COMPTET = F_COMPTETRepository.Read(Customer.Sag_Id); #region Informations libre client Model.Local.InformationLibreClientRepository InformationLibreClientRepository = new Model.Local.InformationLibreClientRepository(); foreach (Model.Local.InformationLibreClient InformationLibreClient in InformationLibreClientRepository.ListSync()) { Model.Sage.cbSysLibreRepository.CB_Type TypeInfoLibre = new Model.Sage.cbSysLibreRepository().ReadTypeInformationLibre(InformationLibreClient.Sag_InfoLibreClient, Model.Sage.cbSysLibreRepository.CB_File.F_COMPTET); UInt32 IDCustomerFeatureValue = 0; switch (TypeInfoLibre) { case PRESTACONNECT.Model.Sage.cbSysLibreRepository.CB_Type.SageText: case PRESTACONNECT.Model.Sage.cbSysLibreRepository.CB_Type.SageTable: #region text if (F_COMPTETRepository.ExistArticleInformationLibreText(InformationLibreClient.Sag_InfoLibreClient, F_COMPTET.CT_Num) && !string.IsNullOrWhiteSpace(Core.Global.SageValueReplacement(F_COMPTETRepository.ReadArticleInformationLibreText(InformationLibreClient.Sag_InfoLibreClient, F_COMPTET.CT_Num)))) { IDCustomerFeatureValue = CreateCustomerFeatureValue(Core.Global.SageValueReplacement(F_COMPTETRepository.ReadArticleInformationLibreText(InformationLibreClient.Sag_InfoLibreClient, F_COMPTET.CT_Num)), (uint)InformationLibreClient.Cha_Id, InformationLibreClient.Inf_Mode); } AssociateCustomerFeatureValueWithCustomer((uint)InformationLibreClient.Cha_Id, (uint)Customer.Pre_Id, IDCustomerFeatureValue); #endregion break; case PRESTACONNECT.Model.Sage.cbSysLibreRepository.CB_Type.SageValeur: case PRESTACONNECT.Model.Sage.cbSysLibreRepository.CB_Type.SageMontant: #region decimal if (F_COMPTETRepository.ExistArticleInformationLibreNumerique(InformationLibreClient.Sag_InfoLibreClient, F_COMPTET.CT_Num) && F_COMPTETRepository.ReadArticleInformationLibreNumerique(InformationLibreClient.Sag_InfoLibreClient, F_COMPTET.CT_Num) != null) { IDCustomerFeatureValue = CreateCustomerFeatureValue(Core.Global.SageValueReplacement(F_COMPTETRepository.ReadArticleInformationLibreNumerique(InformationLibreClient.Sag_InfoLibreClient, F_COMPTET.CT_Num).ToString()), (uint)InformationLibreClient.Cha_Id, InformationLibreClient.Inf_Mode); } AssociateCustomerFeatureValueWithCustomer((uint)InformationLibreClient.Cha_Id, (uint)Customer.Pre_Id, IDCustomerFeatureValue); #endregion break; case PRESTACONNECT.Model.Sage.cbSysLibreRepository.CB_Type.SageDate: case PRESTACONNECT.Model.Sage.cbSysLibreRepository.CB_Type.SageSmallDate: #region datetime if (F_COMPTETRepository.ExistArticleInformationLibreDate(InformationLibreClient.Sag_InfoLibreClient, F_COMPTET.CT_Num) && F_COMPTETRepository.ReadArticleInformationLibreDate(InformationLibreClient.Sag_InfoLibreClient, F_COMPTET.CT_Num) != null) { IDCustomerFeatureValue = CreateCustomerFeatureValue(Core.Global.SageValueReplacement(F_COMPTETRepository.ReadArticleInformationLibreDate(InformationLibreClient.Sag_InfoLibreClient, F_COMPTET.CT_Num).ToString()), (uint)InformationLibreClient.Cha_Id, InformationLibreClient.Inf_Mode); } AssociateCustomerFeatureValueWithCustomer((uint)InformationLibreClient.Cha_Id, (uint)Customer.Pre_Id, IDCustomerFeatureValue); #endregion break; case PRESTACONNECT.Model.Sage.cbSysLibreRepository.CB_Type.Deleted: default: break; } } #endregion #region Statistiques client Model.Local.StatistiqueClientRepository StatistiqueClientRepository = new Model.Local.StatistiqueClientRepository(); foreach (Model.Local.StatistiqueClient StatistiqueClient in StatistiqueClientRepository.ListSync()) { Model.Sage.P_STATISTIQUERepository P_STATISTIQUERepository = new Model.Sage.P_STATISTIQUERepository(); if (P_STATISTIQUERepository.ExistStatClient(StatistiqueClient.Sag_StatClient)) { Model.Sage.P_STATISTIQUE P_STATISTIQUE = P_STATISTIQUERepository.ReadStatClient(StatistiqueClient.Sag_StatClient); String stat_value = null; switch (P_STATISTIQUE.cbMarq) { case 1: stat_value = F_COMPTET.CT_Statistique01; break; case 2: stat_value = F_COMPTET.CT_Statistique02; break; case 3: stat_value = F_COMPTET.CT_Statistique03; break; case 4: stat_value = F_COMPTET.CT_Statistique04; break; case 5: stat_value = F_COMPTET.CT_Statistique05; break; case 6: stat_value = F_COMPTET.CT_Statistique06; break; case 7: stat_value = F_COMPTET.CT_Statistique07; break; case 8: stat_value = F_COMPTET.CT_Statistique08; break; case 9: stat_value = F_COMPTET.CT_Statistique09; break; case 10: stat_value = F_COMPTET.CT_Statistique10; break; } UInt32 IDCustomerFeatureValue = 0; if (!String.IsNullOrWhiteSpace(stat_value)) { IDCustomerFeatureValue = CreateCustomerFeatureValue(Core.Global.SageValueReplacement(stat_value), (uint)StatistiqueClient.Cha_Id, StatistiqueClient.Inf_Mode); } AssociateCustomerFeatureValueWithCustomer((uint)StatistiqueClient.Cha_Id, (uint)Customer.Pre_Id, IDCustomerFeatureValue); } } #endregion } } } } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } }