internal void TransferHeadingAggregates()
 {
     if (SubHeading != null)
     {
         SubHeading.TransferHeadingAggregates();
     }
     if (m_grouping != null)
     {
         for (int i = 0; i < m_aggregates.Count; i++)
         {
             m_grouping.Aggregates.Add(m_aggregates[i]);
         }
     }
     m_aggregates = null;
     if (m_grouping != null)
     {
         for (int j = 0; j < m_postSortAggregates.Count; j++)
         {
             m_grouping.PostSortAggregates.Add(m_postSortAggregates[j]);
         }
     }
     m_postSortAggregates = null;
     if (m_grouping != null)
     {
         for (int k = 0; k < m_recursiveAggregates.Count; k++)
         {
             m_grouping.RecursiveAggregates.Add(m_recursiveAggregates[k]);
         }
     }
     m_recursiveAggregates = null;
 }
Esempio n. 2
0
 internal int StaticInitialize(InitializationContext context)
 {
     if (m_grouping != null)
     {
         int num = 1;
         if (SubHeading != null)
         {
             context.Location |= LocationFlags.InGrouping;
             context.RegisterGroupingScope(m_grouping.Name, m_grouping.SimpleGroupExpressions, m_aggregates, m_postSortAggregates, m_recursiveAggregates, m_grouping);
             num = SubHeading.StaticInitialize(context);
             context.UnRegisterGroupingScope(m_grouping.Name);
         }
         return(num + 1);
     }
     if (SubHeading != null)
     {
         m_subtotalSpan = SubHeading.StaticInitialize(context);
     }
     else
     {
         m_subtotalSpan = 1;
     }
     if (m_labels != null)
     {
         LabelCollectionInitialize(context, registerRunningValues: true, isStatic: true);
     }
     return(0);
 }
Esempio n. 3
0
        Product ParseProduct(int ndxRow)
        {
            string[] row           = m_srcData[ndxRow];
            int      colName       = m_colMapping[ColumnKey_t.LabelFr];
            int      colSubHeading = m_colMapping[ColumnKey_t.SubHeading];

            //parsing
            string     name = AdjustInput(row[colName]);
            SubHeading sh   = SubHeading.Parse(row[colSubHeading].Trim());

            if (string.IsNullOrWhiteSpace(name) || sh == null)
            {
                return(null);
            }

            Product prod = FindProduct(sh, name);

            if (prod == null)
            {
                prod = new Product(AppContext.TableManager.Products.CreateUniqID(), name, sh);

                Assert(!m_pendingData.ContainsKey(AppContext.TableManager.Products.ID));
                m_pendingData[AppContext.TableManager.Products.ID] = prod;
            }

            return(prod);
        }
Esempio n. 4
0
 internal void DynamicRegisterReceiver(InitializationContext context)
 {
     if (m_grouping == null)
     {
         if (SubHeading != null)
         {
             context.RegisterReportItems(m_reportItems);
             SubHeading.DynamicRegisterReceiver(context);
             context.UnRegisterReportItems(m_reportItems);
         }
         return;
     }
     if (m_subtotal != null)
     {
         m_subtotal.RegisterReceiver(context);
     }
     context.RegisterReportItems(m_reportItems);
     if (m_visibility != null)
     {
         m_visibility.RegisterReceiver(context, isContainer: true);
     }
     if (SubHeading != null)
     {
         SubHeading.DynamicRegisterReceiver(context);
     }
     m_reportItems.RegisterReceiver(context);
     if (m_visibility != null)
     {
         m_visibility.UnRegisterReceiver(context);
     }
     context.UnRegisterReportItems(m_reportItems);
 }
Esempio n. 5
0
        internal int DynamicInitialize(bool column, int level, InitializationContext context, ref double cornerSize)
        {
            m_level     = level;
            m_isColumn  = column;
            m_sizeValue = context.ValidateSize(ref m_size, column ? "Height" : "Width");
            cornerSize  = Math.Round(cornerSize + m_sizeValue, Validator.DecimalPrecision);
            if (m_grouping == null)
            {
                if (SubHeading != null)
                {
                    context.RegisterReportItems(m_reportItems);
                    SubHeading.DynamicInitialize(column, ++level, context, ref cornerSize);
                    context.UnRegisterReportItems(m_reportItems);
                }
                return(1);
            }
            context.ExprHostBuilder.MatrixDynamicGroupStart(m_grouping.Name);
            if (m_subtotal != null)
            {
                m_subtotal.RegisterReportItems(context);
                m_subtotal.Initialize(context);
            }
            context.Location |= LocationFlags.InGrouping;
            context.RegisterGroupingScope(m_grouping.Name, m_grouping.SimpleGroupExpressions, m_grouping.Aggregates, m_grouping.PostSortAggregates, m_grouping.RecursiveAggregates, m_grouping, isMatrixGrouping: true);
            ObjectType objectType = context.ObjectType;
            string     objectName = context.ObjectName;

            context.ObjectType = ObjectType.Grouping;
            context.ObjectName = m_grouping.Name;
            Initialize(context);
            context.RegisterReportItems(m_reportItems);
            if (m_visibility != null)
            {
                m_visibility.Initialize(context, isContainer: true, tableRowCol: false);
            }
            if (SubHeading != null)
            {
                m_subtotalSpan = SubHeading.DynamicInitialize(column, ++level, context, ref cornerSize);
            }
            else
            {
                m_subtotalSpan = 1;
            }
            m_reportItems.Initialize(context, registerRunningValues: true);
            if (m_visibility != null)
            {
                m_visibility.UnRegisterReceiver(context);
            }
            context.UnRegisterReportItems(m_reportItems);
            context.ObjectType = objectType;
            context.ObjectName = objectName;
            context.UnRegisterGroupingScope(m_grouping.Name, isMatrixGrouping: true);
            if (m_subtotal != null)
            {
                m_subtotal.UnregisterReportItems(context);
            }
            m_hasExprHost = context.ExprHostBuilder.MatrixDynamicGroupEnd(column);
            return(m_subtotalSpan + 1);
        }
Esempio n. 6
0
        internal int DynamicInitialize(bool column, int level, InitializationContext context)
        {
            m_level    = level;
            m_isColumn = column;
            if (m_grouping == null)
            {
                if (SubHeading != null)
                {
                    SubHeading.DynamicInitialize(column, ++level, context);
                }
                return(1);
            }
            context.ExprHostBuilder.ChartDynamicGroupStart(m_grouping.Name);
            if (m_subtotal != null)
            {
                m_subtotal.RegisterReportItems(context);
                m_subtotal.Initialize(context);
            }
            context.Location |= LocationFlags.InGrouping;
            context.RegisterGroupingScope(m_grouping.Name, m_grouping.SimpleGroupExpressions, m_grouping.Aggregates, m_grouping.PostSortAggregates, m_grouping.RecursiveAggregates, m_grouping);
            ObjectType objectType = context.ObjectType;
            string     objectName = context.ObjectName;

            context.ObjectType = ObjectType.Grouping;
            context.ObjectName = m_grouping.Name;
            Initialize(context);
            if (m_visibility != null)
            {
                m_visibility.Initialize(context, isContainer: true, tableRowCol: false);
            }
            if (SubHeading != null)
            {
                m_subtotalSpan = SubHeading.DynamicInitialize(column, ++level, context);
            }
            else
            {
                m_subtotalSpan = 1;
            }
            if (m_labels != null)
            {
                LabelCollectionInitialize(context, registerRunningValues: true, isStatic: false);
            }
            if (m_visibility != null)
            {
                m_visibility.UnRegisterReceiver(context);
            }
            context.ObjectType = objectType;
            context.ObjectName = objectName;
            context.UnRegisterGroupingScope(m_grouping.Name);
            if (m_subtotal != null)
            {
                m_subtotal.UnregisterReportItems(context);
            }
            m_hasExprHost = context.ExprHostBuilder.ChartDynamicGroupEnd(column);
            return(m_subtotalSpan + 1);
        }
 internal void CopySubHeadingAggregates()
 {
     if (SubHeading != null)
     {
         SubHeading.CopySubHeadingAggregates();
         Pivot.CopyAggregates(SubHeading.Aggregates, m_aggregates);
         Pivot.CopyAggregates(SubHeading.PostSortAggregates, m_postSortAggregates);
         Pivot.CopyAggregates(SubHeading.RecursiveAggregates, m_aggregates);
     }
 }
Esempio n. 8
0
        //protected:
        protected override void DoRead(IReader reader)
        {
            ulong shValue = reader.ReadULong();

            Name = reader.ReadString();

            if (shValue < SubHeading.MinValue || shValue > SubHeading.MaxValue || string.IsNullOrWhiteSpace(Name))
            {
                throw new CorruptedStreamException();
            }

            SubHeading = new SubHeading(shValue);
        }
Esempio n. 9
0
        //handlers:
        private void Search_Click(object sender , EventArgs e)
        {
            var subHeading = SubHeading.Parse(m_tbSubHeading.Text);

            if (subHeading == null)
            {
                MessageBox.Show(Parent , "Contenu ou format de la sous-position tarifaire incorrect." , null , MessageBoxButtons.OK ,
                    MessageBoxIcon.Error);
                return;
            }

            DateTime date = m_dtpSpotDate.Value;
            var ict = m_cbIncoterm.SelectedItem as Incoterm;
            var ctry = (m_cbOrigin.SelectedItem as CountryEntry).Country;

            SearchAsyncSubHeading(subHeading , date , ict , ctry);
        }
Esempio n. 10
0
        Product FindProduct(SubHeading sh, string label)
        {
            Product         prod = null;
            List <IDataRow> data;

            if (m_importedData.TryGetValue(AppContext.TableManager.Products.ID, out data))
            {
                prod = data.Cast <Product>().SingleOrDefault(p =>
                                                             p.SubHeading.Equals(sh) && string.Compare(p.Name, label, true) == 0);
            }

            if (prod == null)
            {
                prod = ProductSubHeadingIndexer.Get(sh).Cast <Product>().SingleOrDefault(p =>
                                                                                         string.Compare(p.Name, label, true) == 0);
            }

            return(prod);
        }
Esempio n. 11
0
 internal void StaticRegisterReceiver(InitializationContext context)
 {
     if (m_grouping != null)
     {
         if (SubHeading != null)
         {
             context.RegisterReportItems(m_reportItems);
             SubHeading.StaticRegisterReceiver(context);
             context.UnRegisterReportItems(m_reportItems);
         }
         return;
     }
     context.RegisterReportItems(m_reportItems);
     if (SubHeading != null)
     {
         SubHeading.StaticRegisterReceiver(context);
     }
     m_reportItems.RegisterReceiver(context);
     context.UnRegisterReportItems(m_reportItems);
 }
Esempio n. 12
0
 public Product(uint id, string name, SubHeading subHeading) :
     base(id, name, subHeading)
 {
 }
Esempio n. 13
0
        void Save()
        {
            Assert(!InvokeRequired);

            string     name       = m_tbName.GetInputText();
            SubHeading subHeading = SubHeading.Parse(m_tbSubHeading.GetInputText());

            //is input ok?
            if (string.IsNullOrWhiteSpace(name) || subHeading == null)
            {
                this.ShowWarning("Champs mal servis. Veuillez compléter le formulaire.");

                if (string.IsNullOrWhiteSpace(name))
                {
                    m_tbName.SelectAll();
                }
                else
                {
                    m_tbSubHeading.Select();
                }

                return;
            }

            //any modif.?
            if (m_datum != null && name == m_datum.Name && subHeading.Value == m_datum.SubHeading.Value)
            {
                TextLogger.Info("Aucune modification détectée, enregistrement non-nécessaire.");
                Close();
                return;
            }


            //any duplicates?
            Predicate <IDatum> filter = d =>
            {
                var prod = d as Product;
                return(prod.SubHeading.Value == subHeading.Value &&
                       string.Compare(name, prod.Name, true) == 0 &&
                       (m_datum == null || m_datum.ID != prod.ID));
            };

            bool duplicate = true;

            using (var dp = new DatumProvider(m_ndxerProducts.Source, filter))
                using (new AutoReleaser(() => UseWaitCursor = false))
                {
                    UseWaitCursor = true;

                    dp.Connect();

                    if (dp.Count == 0)
                    {
                        duplicate = false;
                    }
                    else
                    {
                        Product prod = dp.Get(0) as Product;

                        var logger = new TextLogger(LogSeverity.Warning);
                        logger.Put("Duplication de données détectée.");
                        logger.Put("Elément trouvé:\n");
                        logger.Put("ID: {0}\n", prod.ID);
                        logger.Put("Pays: {0}\n", prod.Name);
                        logger.Put("Code: {0}", prod.SubHeading);
                        logger.Flush();
                    }
                }

            if (duplicate)
            {
                this.ShowWarning("La validation de  données a échouée. " +
                                 "Consultez le journal des événements pour plus d’informations.");
            }
            else
            {
                uint id   = (m_datum?.ID) ?? AppContext.TableManager.Products.CreateUniqID();
                var  prod = new Product(id, name, subHeading);

                if (m_datum == null)
                {
                    m_ndxerProducts.Source.Insert(prod);
                    ClearForm();
                }
                else
                {
                    int ndx = m_ndxerProducts.IndexOf(m_datum.ID);
                    m_ndxerProducts.Source.Replace(ndx, prod);

                    Close();
                }

                TextLogger.Info("Enregistrement réussi.");
            }
        }
Esempio n. 14
0
 public ProductRow(uint id, string name, SubHeading subHeading) :
     this(subHeading, name, id)
 {
 }
Esempio n. 15
0
 private ProductRow(SubHeading subHeading, string name, uint id) :
     base(id)
 {
     Name       = name;
     SubHeading = subHeading;
 }
Esempio n. 16
0
        void SearchAsyncSubHeading(SubHeading subHeading , DateTime date , Incoterm ict , Country origin)
        {
            IDisposable releaser = Log.LogEngin.PushMessage("Recherche en cours...");
            m_tsbSearch.Enabled = false;

            Func<SpotValue , SpotValue , bool> isSameVC = (sv1 , sv2) =>
                {
                    if (sv1.ValueContextID == sv2.ValueContextID)
                        return true;

                    ValueContext vc1 = sv1.ValueContext, vc2 = sv2.ValueContext;

                    return vc1.IncotermID == vc2.IncotermID && vc1.OriginID == vc2.OriginID;
                };


            Func<SpotViewItem[]> search = () =>
            {
                IDBColumnIndexer<SubHeading> ndxer =
                    Program.TablesManager.GetSubHeadingIndexer(TablesID.SPOT_VALUE , TablesManager.ColumnID_t.SubHeading);

                IEnumerable<SpotValue> seq = from SpotValue sv in ndxer.Get(subHeading)
                                             select sv;

                var candidatesValue = new List<SpotValue>();

                foreach (SpotValue sv in seq)
                {
                    if (sv.SpotTime > date)
                        continue;

                    int ndx = candidatesValue.FindIndex(v => v.Product.ID == sv.Product.ID && isSameVC(v , sv));

                    if (ndx == -1)
                        candidatesValue.Add(sv);
                    else if (candidatesValue[ndx].SpotTime < sv.SpotTime)
                        candidatesValue[ndx] = sv;
                }

                seq = candidatesValue;

                if (ict.ID != 0)
                    seq = from SpotValue sv in seq
                          where sv.ValueContext.IncotermID == ict.ID
                          select sv;


                if (origin != null)
                    seq = from SpotValue sv in seq
                          where sv.ValueContext.OriginID == origin.ID
                          select sv;


                IEnumerable<SpotViewItem> items = from SpotValue sv in seq
                                                  select new SpotViewItem(sv);

                return items.ToArray();
            };

            Action<Task<SpotViewItem[]>> onSuccess = (t) =>
            {
                EmptyMode = t.Result.Length == 0;

                if (!EmptyMode)
                {
                    m_lvSearchResult.BeginUpdate();
                    m_lvSearchResult.Items.AddRange(t.Result);

                    if (m_lvSearchResult.View == View.Details)
                        m_lvSearchResult.AdjustColumnsSize();

                    m_lvSearchResult.EndUpdate();
                }



                string txtLog = $"Module valeurs boursières: recherche de la SPT {subHeading}, date: {date.ToShortDateString()}, " +
                    $"incoterm: {(ict.ID == 0 ? AppText.UNSPECIFIED : ict.Name)}, origine: {(origin == null ? AppText.UNSPECIFIED : origin.Name)}, " +
                    $"Nbre d'enregistrements trouvés: {t.Result.Length}";

                Program.DialogManager.PostLog(txtLog , false);


                m_tsbSearch.Enabled = true;
                releaser.Dispose();
                Log.LogEngin.PushFlash($"{t.Result.Length} élément(s) trouvé(s).");
            };

            Action<Task> onErr = (t) =>
            {
                m_tsbSearch.Enabled = true;
                Log.LogEngin.PushFlash(t.Exception.InnerException.Message);

                string errLog = "Module valeurs boursiére: Erreur lors de la recherche, " + t.Exception.InnerException.Message;
                Program.DialogManager.PostLog(errLog , true);
            };

            var task = new Task<SpotViewItem[]>(search , TaskCreationOptions.LongRunning);
            task.OnSuccess(onSuccess);
            task.OnError(onErr);
            task.Start();
        }