Esempio n. 1
0
        /// <summary>
        /// Load the content of the index card from a file stream ( config file )
        /// </summary>
        public void Load(bool BackgroundLoad = false)
        {
            lock (this) // we will load index cards in parallel
            {
                //only load once
                if (GridCells.Count != 0)
                {
                    return;
                }
                long StartTime = Environment.TickCount;
                //load Index card related data
                KeyDataCollection IndexCardCollection = Globals.Config.GetConfigSection(GetName());
                //load all possible grid cells ( phone numbers )
                int PhoneNumberLoading = 0;
                do
                {
                    PhoneNumber pn = Globals.ExtensionManager.FactoryNewPhoneNumber(0, 0, GeneralSettings, GetGUID());
                    //try to load from config having this index
                    //                pn.SetConfigIndex(PhoneNumberLoading);
                    //can we load it ?
                    if (pn.Load(GetName(), PhoneNumberLoading) == false)
                    {
                        break;
                    }
                    //if we loaded it, than add it to our visual grid
                    PhoneNumberAdd(pn.GetX(), pn.GetY(), pn);
                    //try to load more
                    PhoneNumberLoading++;
                } while (true);
                //load ranges
                int RangeNumberLoading = 0;
                do
                {
                    PhoneNumber pn = Globals.ExtensionManager.FactoryNewPhoneNumber(0, 0, GeneralSettings, GetGUID());
                    //try to load from config having this index
                    //                pn.SetConfigIndex(RangeNumberLoading);
                    //can we load it ?
                    if (pn.LoadRange(GetName(), RangeNumberLoading) == false)
                    {
                        break;
                    }
                    //if we loaded it, than add it to our visual grid
                    PhoneNumberAdd(pn.GetX(), pn.GetY(), pn);
                    //try to load more
                    RangeNumberLoading++;
                } while (true);

                //try to place them inside the grid also
                if (BackgroundLoad == true)
                {
                    CreateGridBasedOnSize();
                }

                long Endtime = Environment.TickCount;
                Globals.Logger.LogString(LogManager.LogLevels.LogFlagInfo, "For index card " + GetName() + " we loaded " + PhoneNumberLoading.ToString() + " extensions and " + RangeNumberLoading.ToString() + " ranges in " + (Endtime - StartTime) + " ms");
            }
        }