Example #1
0
 public void Add(InVarObj inVarObj)
 {
     if (!_list.ContainsKey(inVarObj.ID))
     {
         _list.Add(inVarObj.ID, inVarObj);
     }
 }
Example #2
0
 public void Add(ProCommon.Communal.BoardProperty brdProperty)
 {
     if (!_list.ContainsKey(brdProperty.ID))
     {
         _list.Add(brdProperty.ID, brdProperty);
     }
 }
Example #3
0
 public void Add(ProCommon.Communal.SerialPortProperty serialPortProperty)
 {
     if (!_list.ContainsKey(serialPortProperty.ID))
     {
         _list.Add(serialPortProperty.ID, serialPortProperty);
     }
 }
Example #4
0
 public void Add(ProCommon.Communal.PlcProperty plcProperty)
 {
     if (!_list.ContainsKey(plcProperty.ID))
     {
         _list.Add(plcProperty.ID, plcProperty);
     }
 }
Example #5
0
 public void Add(ProCommon.Communal.CameraProperty camProperty)
 {
     if (!_list.ContainsKey(camProperty.ID))
     {
         _list.Add(camProperty.ID, camProperty);
     }
 }
Example #6
0
 public void Add(ProCommon.Communal.SocketProperty sktProperty)
 {
     if (!_list.ContainsKey(sktProperty.ID))
     {
         _list.Add(sktProperty.ID, sktProperty);
     }
 }
Example #7
0
 public void Add(ProCommon.Communal.WebProperty webProperty)
 {
     if (!_list.ContainsKey(webProperty.ID))
     {
         _list.Add(webProperty.ID, webProperty);
     }
 }
Example #8
0
 public void Add(ProCommon.Communal.Account acc)
 {
     if (!_list.ContainsKey(acc.ID))
     {
         _list.Add(acc.ID, acc);
     }
 }
Example #9
0
 /// <summary>
 /// 方法:添加相机实体
 /// </summary>
 /// <param name="cam"></param>
 public void Add(Camera cam)
 {
     if (!_list.ContainsKey(cam.ID))
     {
         _list.Add(cam.ID, cam);
     }
 }
Example #10
0
 /// <summary>
 /// 方法:增加控制变量实体
 /// </summary>
 /// <param name="outVarObj"></param>
 public void Add(OutVarObj outVarObj)
 {
     if (!_list.ContainsKey(outVarObj.ID))
     {
         _list.Add(outVarObj.ID, outVarObj);
     }
 }
Example #11
0
 public void Add(Axis axis)
 {
     if (!_list.ContainsKey(axis.ID))
     {
         _list.Add(axis.ID, axis);
     }
 }
Example #12
0
        public void Add(string key, T info)
        {
            if (list.ContainsKey(key))
            {
                list.Remove(key);
            }

            list.Add(key, info);
        }
        /// <summary>
        /// вернуть UsageTypes для заданного типа-свойства
        /// </summary>
        /// <param name="DataObjectType"></param>
        /// <param name="propertyName"></param>
        /// <returns></returns>
        public Type[] GetUsageTypes(Type DataObjectType, string propertyName)
        {
            string key = GetTypeUsageKey(DataObjectType, propertyName);

            lock (m_objNull)
            {
                if (!typeusagecollection.ContainsKey(key))
                {
                    System.Type propType = Information.GetPropertyType(DataObjectType, propertyName);
                    if (propType.IsSubclassOf(typeof(DetailArray)))
                    {
                        System.Type[] tps = Information.GetCompatibleTypesForDetailProperty(DataObjectType, propertyName);
                        ICSSoft.STORMNET.Collections.TypesArrayList types = new ICSSoft.STORMNET.Collections.TypesArrayList();
                        foreach (Type t in tps)
                        {
                            if (!types.Contains(t))
                            {
                                types.Add(t);
                            }
                        }

                        typeusagecollection.Add(key, types);
                    }
                    else
                    {
                        System.Type[] tps = Information.GetCompatibleTypesForProperty(DataObjectType, propertyName);
                        ICSSoft.STORMNET.Collections.TypesArrayList types = new ICSSoft.STORMNET.Collections.TypesArrayList();
                        foreach (Type t in tps)
                        {
                            if (!types.Contains(t))
                            {
                                types.Add(t);
                            }
                        }

                        typeusagecollection.Add(key, types);
                    }
                }
            }

            try
            {
                return(((ICSSoft.STORMNET.Collections.TypesArrayList)typeusagecollection[key]).ToArray());
            }
            catch
            {
                return(Type.EmptyTypes);
            }
        }
Example #14
0
 IActivity getMatchingLogActivity(int index, int count)
 {
     //Note: the activity list may not be in perfect order, sort the tail
     if (activities == null || activities.Count != count)
     {
         activities = new System.Collections.SortedList(count);
         int logIndex = Plugin.Instance.Application.Logbook.Activities.Count - 1;
         for (int i = 0; i < count; i++)
         {
             //TBD: Only use My Activities and ignore My Friends Activities?
             while (logIndex >= 0 && activities.ContainsKey(Plugin.Instance.Application.Logbook.Activities[logIndex].StartTime))
             {
                 logIndex--;
             }
             if (logIndex > 0)
             {
                 IActivity activity = Plugin.Instance.Application.Logbook.Activities[logIndex];
                 activities.Add(activity.StartTime, activity);
             }
             else
             {
                 activities.Add(DateTime.MinValue, null);
             }
         }
     }
     return((IActivity)activities.GetByIndex(index));
 }
Example #15
0
        public clsMessage[] msgHasMessagesToShow(System.DateTime dtDate)
        {
            clsMessage[] msgsReturn = null;

            if ((m_bEnabled) && (!m_bPaused))
            {
                // Ordering
                System.Collections.SortedList sorListMessages = new System.Collections.SortedList();
                for (int i = 0; i < m_arlMessages.Count; i++)
                {
                    clsMessage currMessage = (clsMessage)m_arlMessages[i];
                    if ((currMessage.Show) && (!currMessage.Deleted))
                    {
                        double dSeconds = (currMessage.DateShow.Subtract(dtDate)).TotalSeconds;
                        if ((dSeconds > 0) && (currMessage.Show))
                        {
                            continue;
                        }
                        string strDate = currMessage.DateShow.ToString("ddMMyyyyHHmmss");
                        while (sorListMessages.ContainsKey(strDate))
                        {
                            strDate += "x";
                        }
                        sorListMessages.Add(strDate, currMessage);
                    }
                }
                // Inserting
                msgsReturn = new clsMessage[sorListMessages.Count];
                for (int i = 0; i < sorListMessages.Count; i++)
                {
                    msgsReturn[i] = (clsMessage)sorListMessages.GetByIndex(i);
                }
            }
            return(msgsReturn);
        }
Example #16
0
        private void vArmadoresRefresh(ref System.Windows.Forms.ListView lvArmadores)
        {
            lvArmadores.Items.Clear();

            // Sorting
            System.Collections.SortedList sortListArmadores = new System.Collections.SortedList();
            foreach (mdlDataBaseAccess.Tabelas.XsdTbArmadores.tbArmadoresRow dtrwArmador in m_typDatSetArmadores.tbArmadores.Rows)
            {
                if ((dtrwArmador.RowState != System.Data.DataRowState.Deleted) && (!dtrwArmador.IsstrNomeNull()))
                {
                    if (!sortListArmadores.ContainsKey(dtrwArmador.strNome))
                    {
                        sortListArmadores.Add(dtrwArmador.strNome, dtrwArmador);
                    }
                }
            }

            // Insert
            for (int i = 0; i < sortListArmadores.Count; i++)
            {
                mdlDataBaseAccess.Tabelas.XsdTbArmadores.tbArmadoresRow dtrwArmadorInserir = (mdlDataBaseAccess.Tabelas.XsdTbArmadores.tbArmadoresRow)sortListArmadores.GetByIndex(i);
                System.Windows.Forms.ListViewItem lviInsert = lvArmadores.Items.Add(dtrwArmadorInserir.strNome);
                lviInsert.Tag = dtrwArmadorInserir.nIdArmador;
                if ((m_nIdSelect != -1) && (dtrwArmadorInserir.nIdArmador == m_nIdSelect))
                {
                    lviInsert.Selected = true;
                    m_nIdSelect        = -1;
                }
            }
        }
Example #17
0
        private void vContatosRefresh(int nIdTerminal, ref System.Windows.Forms.ListView lvContatos)
        {
            lvContatos.Items.Clear();

            // Sorting
            System.Collections.SortedList sortListContatos = new System.Collections.SortedList();
            foreach (mdlDataBaseAccess.Tabelas.XsdTbTerminaisContatos.tbTerminaisContatosRow dtrwContato in m_typDatSetTerminaisContatos.tbTerminaisContatos.Rows)
            {
                if ((dtrwContato.RowState != System.Data.DataRowState.Deleted) && (dtrwContato.nIdTerminal == nIdTerminal) && (!dtrwContato.IsstrNomeNull()))
                {
                    if (!sortListContatos.ContainsKey(dtrwContato.strNome))
                    {
                        sortListContatos.Add(dtrwContato.strNome, dtrwContato);
                    }
                }
            }

            // Insert
            for (int i = 0; i < sortListContatos.Count; i++)
            {
                mdlDataBaseAccess.Tabelas.XsdTbTerminaisContatos.tbTerminaisContatosRow dtrwContatoInserir = (mdlDataBaseAccess.Tabelas.XsdTbTerminaisContatos.tbTerminaisContatosRow)sortListContatos.GetByIndex(i);
                System.Windows.Forms.ListViewItem lviInsert = lvContatos.Items.Add(dtrwContatoInserir.strNome);
                lviInsert.Tag = dtrwContatoInserir.nIdContato;
                if ((m_nIdSelectContato != -1) && (dtrwContatoInserir.nIdContato == m_nIdSelectContato))
                {
                    lviInsert.Selected = true;
                    m_nIdSelectContato = -1;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            GooglePageBase google = Page as GooglePageBase;

            DataQuery query = new DataQuery();

            query.Ids         = "ga:" + google.Settings.Current.Id;
            query.Metrics     = "ga:pageviews";
            query.Dimensions  = "ga:browser,ga:browserVersion";
            query.Sort        = "ga:browser,ga:pageviews";
            query.GAStartDate = DateTime.Now.AddMonths(-1).AddDays(-1).ToString("yyyy-MM-dd");
            query.GAEndDate   = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");

            if (google.Referringpage != null)
            {
                query.Filters = "ga:pagePath==" + google.Referringpage;
            }

            DataFeed actual = google.Analytics.Query(query);

            System.Data.DataTable browsers = new System.Data.DataTable("Browser");
            browsers.Columns.Add("Browser");
            browsers.Columns.Add("Views", typeof(int));

            System.Data.DataTable versions = new System.Data.DataTable("BrowserVersion");
            versions.Columns.Add("Browser");
            versions.Columns.Add("Version");
            versions.Columns.Add("Views", typeof(int));

            System.Collections.SortedList values = new System.Collections.SortedList();
            foreach (DataEntry entry in actual.Entries)
            {
                string browser = entry.Dimensions[0].Value.ToString();
                string version = entry.Dimensions[1].Value.ToString();
                int    visits  = int.Parse(entry.Metrics[0].Value);

                if (values.ContainsKey(browser))
                {
                    int current = int.Parse(values[browser].ToString());
                    current        += int.Parse(entry.Metrics[0].Value);
                    values[browser] = current;
                }
                else
                {
                    values.Add(browser, int.Parse(entry.Metrics[0].Value));
                }

                versions.Rows.Add(new object[] { browser, version, visits });
            }

            foreach (String key in values.Keys)
            {
                browsers.Rows.Add(new object[] { key, int.Parse(values[key].ToString()) });
            }

            this.pie_Browsers.GviEnableEvents = true;
            this.pie_Browsers.ChartData(browsers);

            this.tbl_Versions.ChartData(versions);
        }
Example #19
0
        static void Main(string[] args)
        {
            //very similar as hashtable
            //sorted list has two arrays behind it, keys and values,  keys is sorted so that values is to
            System.Collections.SortedList table = new System.Collections.SortedList();
            table["Ryan"] = 22;
            table["Mike"] = 25;
            table["Josh"] = 15;

            Console.WriteLine("Ryan is found at index {0}", table.IndexOfKey("Ryan"));
            Console.WriteLine("Mike is found at index {0}", table.IndexOfKey("Mike"));
            Console.WriteLine("Josh is found at index {0}", table.IndexOfKey("Josh"));

            Console.WriteLine("Ryan is {0} years old", table["Ryan"]);
            Console.WriteLine("ContainsKey foo? {0}", table.ContainsKey("foo"));
            Console.WriteLine("ContainsKey Ryan? {0}", table.ContainsKey("Ryan"));
        }
Example #20
0
        public void vRetornaValores(int nIdOrdemProduto, out double dPrecoUnitario)
        {
            dPrecoUnitario = 0;

            if (!m_bDataLoaded)
            {
                bCarregaDados();
            }

            // Calc Fatura
            if (m_sortLstProdutosFatura == null)
            {
                bCalculaProdutosFatura();
            }
            if (m_bFaturaOutput)
            {
                // Fatura
                if (m_sortLstProdutosFatura.ContainsKey(nIdOrdemProduto))
                {
                    clsProdutoData cls_DataProduct = (clsProdutoData)m_sortLstProdutosFatura[nIdOrdemProduto];
                    dPrecoUnitario = cls_DataProduct.PrecoUnitario;
                }
            }
            else
            {
                // Calc EXW
                if (m_sortLstProdutosEXW == null)
                {
                    bCalculaProdutosExw();
                }
                // Calc Retorno
                if (m_sortLstProdutosRetorno == null)
                {
                    bCalculaProdutosRetorno();
                }
                // Retorno
                if (m_sortLstProdutosRetorno.ContainsKey(nIdOrdemProduto))
                {
                    clsProdutoData cls_DataProduct = (clsProdutoData)m_sortLstProdutosRetorno[nIdOrdemProduto];
                    dPrecoUnitario = cls_DataProduct.PrecoUnitario;
                }
            }
        }
Example #21
0
 public static System.Collections.Specialized.ListDictionary GetAddressbook(System.String name, System.Object books)
 {
     if (name == null || name.Length == 0 || books == null || !(books is System.Collections.SortedList))
     {
         return(null);
     }
     System.Collections.SortedList addressbooks = (System.Collections.SortedList)books;
     if (addressbooks.ContainsKey(name))
     {
         return((System.Collections.Specialized.ListDictionary)addressbooks[name]);
     }
     return(null);
 }
Example #22
0
        private string _sysLogFilePath, _exLogFilePath; //系统日志文件路径,异常日志文件路径

        /// <summary>
        /// 方法:创建设备列表
        /// </summary>
        private void CreateDeviceList()
        {
            try
            {
                Device.Device_Camera devCam = new Device.Device_Camera(Manager.ConfigManager.Instance);
                if (devCam != null)
                {
                    if (!DeviceList.ContainsKey(ProCommon.Communal.CtrllerCategory.Camera))
                    {
                        DeviceList.Add(ProCommon.Communal.CtrllerCategory.Camera, devCam);
                    }
                }
            }
            catch (System.Exception ex)
            {
                //ProCommon.Communal.LogWriter.WriteException(_exLogFilePath, ex);
                //ProCommon.Communal.LogWriter.WriteLog(_sysLogFilePath, string.Format("错误:创建设备列表失败!\n异常描述:{0}", ex.Message));
            }
        }
 private System.Collections.SortedList retornaEnderecosOrdenados()
 {
     System.Collections.SortedList srlEnderecos = new System.Collections.SortedList();
     try
     {
         foreach (mdlDataBaseAccess.Tabelas.XsdTbImportadoresEndEntrega.tbImportadoresEndEntregaRow dtrwRowTbImportadoresEndEntrega in m_typDatSetTbImportadoresEndEntrega.tbImportadoresEndEntrega.Rows)
         {
             if (dtrwRowTbImportadoresEndEntrega.RowState != System.Data.DataRowState.Deleted)
             {
                 if (!srlEnderecos.ContainsKey(dtrwRowTbImportadoresEndEntrega.mstrEndEntrCli + dtrwRowTbImportadoresEndEntrega.idEndEntrega.ToString()))
                 {
                     srlEnderecos.Add(dtrwRowTbImportadoresEndEntrega.mstrEndEntrCli + dtrwRowTbImportadoresEndEntrega.idEndEntrega.ToString(), dtrwRowTbImportadoresEndEntrega);
                 }
             }
         }
     }
     catch (Exception err)
     {
         m_cls_ter_tratadorErro.trataErro(ref err);
     }
     return(srlEnderecos);
 }
Example #24
0
 private System.Collections.SortedList retornaContasOrdenadas()
 {
     System.Collections.SortedList srlContas = new System.Collections.SortedList();
     try
     {
         foreach (mdlDataBaseAccess.Tabelas.XsdTbExportadores.tbExportadoresRow dtrwTbExportadores in m_typDatSetTbExportadores.tbExportadores.Rows)
         {
             if (dtrwTbExportadores.RowState != System.Data.DataRowState.Deleted)
             {
                 if (!srlContas.ContainsKey(dtrwTbExportadores.marca + dtrwTbExportadores.idExportador.ToString()))
                 {
                     srlContas.Add(dtrwTbExportadores.marca + dtrwTbExportadores.idExportador.ToString(), dtrwTbExportadores);
                 }
             }
         }
     }
     catch (Exception err)
     {
         m_cls_ter_tratadorErro.trataErro(ref err);
     }
     return(srlContas);
 }
Example #25
0
        private void InitPlayers()
        {
            System.Collections.SortedList playerRankSort = new System.Collections.SortedList();
            int playerSortKey;

            // Initialize without rank
            for (var i = 0; i < PlayerRank.Length; i++)
            {
                PlayerRank[i].Initialize(this, i);
            }

            // Give every Player On dial for rank
            foreach (var p in PlayerRank)
            {
                _activePlayer = p.Index;
                NextPlayer?.Invoke(ActivePlayer);
                DiceRollResult result = p.DelegateDiceRoll();
                playerSortKey = result.DiceSum * 10;
                while (playerRankSort.ContainsKey(-playerSortKey))
                {
                    playerSortKey += 1;
                }
                playerRankSort.Add(-playerSortKey, p); // negativ for sorting
            }


            playerRankSort.Values.CopyTo(PlayerRank, 0);

            // Initialize Part 2 with rank
            for (ushort i = 0; i < PlayerRank.Length; i++)
            {
                PlayerRank[i].Index = i;
            }

            _activePlayer = -1;

            RaisePlayerRankChanged();
        }
Example #26
0
        private void vContatosRefresh(int nIdDespachante, ref System.Windows.Forms.ListView lvContatos)
        {
            lvContatos.Items.Clear();

            // Sorting
            System.Collections.SortedList sortListContatos = new System.Collections.SortedList();
            foreach (mdlDataBaseAccess.Tabelas.XsdTbDespachantesContatos.tbDespachantesContatosRow dtrwContato in m_typDatSetDespachantesContatos.tbDespachantesContatos.Rows)
            {
                if ((dtrwContato.RowState != System.Data.DataRowState.Deleted) && (dtrwContato.nIdDespachante == nIdDespachante) && (!dtrwContato.IsstrNomeNull()))
                {
                    if (!sortListContatos.ContainsKey(dtrwContato.strNome))
                    {
                        sortListContatos.Add(dtrwContato.strNome, dtrwContato);
                    }
                }
            }

            // Insert
            for (int i = 0; i < sortListContatos.Count; i++)
            {
                mdlDataBaseAccess.Tabelas.XsdTbDespachantesContatos.tbDespachantesContatosRow dtrwContatoInserir = (mdlDataBaseAccess.Tabelas.XsdTbDespachantesContatos.tbDespachantesContatosRow)sortListContatos.GetByIndex(i);
                lvContatos.Items.Add(dtrwContatoInserir.strNome).Tag = dtrwContatoInserir.nIdContato;
            }
        }
Example #27
0
 public bool ContainsTable(string tablename)
 {
     return(m_TablesByName.ContainsKey(tablename));
 }
Example #28
0
        /// <summary>
        /// Retrieve OID name by OID string.
        /// </summary>
        /// <param name="inOidStr">source OID string.</param>
        /// <returns>OID name.</returns>
        public string GetOidName(string inOidStr)
        {
            if (oidDictionary == null) //Initialize oidDictionary:
            {
                oidDictionary = new StringDictionary();
                string path = Application.ExecutablePath;
                string oidFile = System.IO.Path.GetDirectoryName(path) + "\\OID.txt";
                string oidBackupFile = System.IO.Path.GetDirectoryName(path) + "\\OID.Backup.txt";
                string oidStr = "";
                string oidDesc = "";
                bool loadOidError = false;
                int dbCounter = 0;
                try
                {
                    using (StreamReader sr = new StreamReader(oidFile))
                    {
                        string line;
                        while ((line = sr.ReadLine()) != null)
                        {
                            string[] strs = line.Split(',');
                            if (strs.Length < 2) continue;
                            oidStr = strs[0].Trim();
                            oidDesc = strs[1].Trim();
                            try
                            {
                                oidDictionary.Add(oidStr, oidDesc);
                            }
                            catch(Exception ex)
                            {
                                loadOidError = true;
                                string msg = ex.Message;
                                dbCounter ++;
                            }
                        }
                    }
                    if (loadOidError)
                    {
                        using (StreamWriter sw = new StreamWriter(oidBackupFile))
                        {

                            using (StreamReader sr = new StreamReader(oidFile))
                            {
                                string line;
                                while ((line = sr.ReadLine()) != null)
                                {
                                    sw.Write(line+"\r\n");
                                }
                            }
                        }

                        System.Collections.SortedList sList = new System.Collections.SortedList();
                        using (StreamWriter sw = new StreamWriter(oidFile))
                        {
                            string val = "";
                            foreach ( System.Collections.DictionaryEntry de in oidDictionary )
                            {
                                if (!sList.ContainsKey(de.Key))
                                    sList.Add(de.Key, de.Value);
                            }
                            for(int i=0; i<sList.Count; i++)
                            {
                                val = String.Format("{0}, {1}\r\n", sList.GetKey(i), sList.GetByIndex(i));
                                sw.Write(val);
                            }
                        }
                        MessageBox.Show(String.Format("Duplicated OIDs were found in the OID table: {0}.\r\n" +
                            "The duplicate has been removed; the table is sorted.\r\n" +
                            "The original OID file is copied as: {1}\r\n", oidFile, oidBackupFile));
                    }
                }
                catch(Exception ex)
                {
                    MessageBox.Show("Failed to read OID values from file." + ex.Message);
                }
            }
            return oidDictionary[inOidStr];
        }
Example #29
0
	/// <summary/>
		public void ResetSortedList(ref System.Collections.SortedList list, string[] saContents)
		{
			list = new System.Collections.SortedList();
			foreach (string s in saContents)
				if (s != null && !list.ContainsKey(s))
					list.Add(s, s);

#if TestingOnly
			Console.WriteLine("sorted list contains:");
			for ( int i = 0; i < list.Count; i++ )
			{
				Console.WriteLine( "  {0}:{1}", list.GetKey(i), list.GetByIndex(i) );
			}
#endif
		}
Example #30
0
        /// <summary>
        /// Заполнить объект данных.
        /// </summary>
        /// <param name="dobject">Объект данных.</param>
        /// <param name="values">Значения для заполнения.</param>
        /// <param name="storageStruct">Метаданные структуры хранения.</param>
        /// <param name="customizationStruct">Настройка выборки данных.</param>
        /// <param name="typesByKeys">Служебная структура, увязывающая типы мастеров и их ключи.</param>
        /// <param name="advCols">Дополнительные колонки.</param>
        /// <param name="dataObjectCache">Кэш объектов данных.</param>
        /// <param name="securityManager">Менеджер полномочий.</param>
        public static void FillRowSetToDataObject(DataObject dobject, object[] values, StorageStructForView storageStruct, LoadingCustomizationStruct customizationStruct, System.Collections.SortedList typesByKeys, AdvansedColumn[] advCols, DataObjectCache dataObjectCache, ISecurityManager securityManager)
        {
            Type dobjectType = dobject.GetType();

            /* access type */

            if (!securityManager.AccessObjectCheck(dobjectType, tTypeAccess.Full, false))
            {
                securityManager.AccessObjectCheck(dobjectType, tTypeAccess.Read, true);
            }

            /* access type */

            // Заливаем данные в объект данных.
            int customizationStructViewPropertiesLength = customizationStruct.View.Properties.Length;
            int advColsLength = advCols.Length;

            Information.SetPropValueByName(dobject, "__PrimaryKey", values[customizationStructViewPropertiesLength + advColsLength]);

            // 1. создаем структуру мастеров(свойств-объектов данных).
            System.Collections.SortedList assList = new System.Collections.SortedList();
            int index = customizationStructViewPropertiesLength + 1 + advColsLength;

            CreateMastersStruct(dobject, values, ref index, 0, storageStruct.sources, assList, typesByKeys, dataObjectCache);
            assList.Add(storageStruct.sources, new object[] { dobject, 0 });

            // 2. заливаем данные.
            System.Collections.ArrayList properiesValues = new System.Collections.ArrayList();
            StringCollection             allAdvCols      = new StringCollection();

            int masterPosition = index;

            for (int i = 0; i < advColsLength; i++)
            {
                object value = values[i + customizationStructViewPropertiesLength];
                if (value == DBNull.Value)
                {
                    value = null;
                }

                properiesValues.Add(new[] { advCols[i].Name, value, dobject });
                allAdvCols.Add(advCols[i].Name);
                dobject.DynamicProperties.Add(advCols[i].Name, null);
            }

            for (int i = 0; i < customizationStructViewPropertiesLength; i++)
            {
                StorageStructForView.PropStorage prop = storageStruct.props[i];
                if (Information.IsStoredProperty(dobjectType, prop.Name) || prop.Expression != null)
                {
                    if (prop.MastersTypes == null)
                    {
                        object[] tmp = (object[])assList[prop.source];
                        object   value;
                        if (customizationStruct.ColumnsOrder != null && customizationStruct.ColumnsOrder.Length >= customizationStructViewPropertiesLength)
                        {
                            value = values[Array.IndexOf(customizationStruct.ColumnsOrder, prop.Name)];
                        }
                        else
                        {
                            value = values[i];
                        }

                        if (value == DBNull.Value)
                        {
                            value = null;
                        }

                        if (tmp != null)
                        {
                            properiesValues.Add(
                                new[] { prop.simpleName, value, tmp[0] });
                        }
                    }
                    else
                    {
                        object[] tmp = (object[])assList[prop.source];
                        if (tmp != null)
                        {
                            // Ищем позицию.
                            int tmp1 = (int)tmp[1];
                            int curMasterPosition = masterPosition;
                            for (int j = 0; j < tmp1; j++)
                            {
                                curMasterPosition += prop.MastersTypes[j].Length;
                            }

                            int    k     = 0;
                            object value = values[curMasterPosition];
                            if (value == DBNull.Value)
                            {
                                value = null;
                            }

                            while (k < prop.MastersTypes[tmp1].Length - 1 && value == null)
                            {
                                k++;
                                value = values[curMasterPosition + k];
                                if (value == DBNull.Value)
                                {
                                    value = null;
                                }
                            }

                            object tmp0 = tmp[0];
                            if (value != null)
                            {
                                if (Information.GetPropValueByName((DataObject)tmp0, prop.simpleName) == null)
                                {
                                    DataObject no = dataObjectCache.CreateDataObject(prop.MastersTypes[tmp1][k], value);
                                    if (no.GetStatus(false) == ObjectStatus.Created)
                                    {
                                        no.SetStatus(ObjectStatus.UnAltered);
                                        no.SetLoadingState(LoadingState.LightLoaded);
                                        no.InitDataCopy(dataObjectCache);
                                    }

                                    value = no;
                                    properiesValues.Add(new[] { prop.simpleName, value, tmp0 });
                                }
                                else
                                {
                                    // changed by fat
                                    properiesValues.Add(new[] { prop.simpleName, Information.GetPropValueByName((DataObject)tmp0, prop.simpleName), tmp0 });
                                }
                            }
                            else
                            {
                                properiesValues.Add(new[] { prop.simpleName, null, tmp0 });
                            }
                        }

                        masterPosition += prop.MastersTypesCount;
                    }
                }
            }

            // 2.2 Записываем в объекты.
            System.Collections.SortedList curObjProperiesValues = new System.Collections.SortedList();
            while (properiesValues.Count > 0)
            {
                // a. Выбираем для текущего объекта все свойства.
                object[]   tmp    = (object[])properiesValues[0];
                DataObject curobj = (DataObject)tmp[2];
                dobjectType = curobj.GetType();
                curObjProperiesValues.Clear();

                List <string> loadedPropsColl = curobj.GetLoadedPropertiesList();

                for (int i = properiesValues.Count - 1; i >= 0; i--)
                {
                    tmp = (object[])properiesValues[i];
                    if (tmp[2] == curobj)
                    {
                        object tmp0 = tmp[0];
                        if (!curObjProperiesValues.ContainsKey(tmp0))
                        {
                            curObjProperiesValues.Add(tmp0, tmp[1]);
                            if (!loadedPropsColl.Contains((string)tmp0))
                            {
                                loadedPropsColl.Add((string)tmp0);
                            }
                        }

                        properiesValues.RemoveAt(i);
                    }
                }

                // b. Раскидываем согласно LoadOrder;
                string[] loadOrder       = Information.GetLoadingOrder(dobjectType);
                int      loadOrderLength = loadOrder.Length;
                for (int i = 0; i < loadOrderLength; i++)
                {
                    string propName = loadOrder[i];
                    if (curObjProperiesValues.ContainsKey(propName))
                    {
                        Information.SetPropValueByName(curobj, propName, curObjProperiesValues[propName]);
                        curObjProperiesValues.Remove(propName);
                    }
                }

                int curObjPropertiesValuesCount = curObjProperiesValues.Count;
                for (int i = 0; i < curObjPropertiesValuesCount; i++)
                {
                    Information.SetPropValueByName(curobj, (string)curObjProperiesValues.GetKey(i), curObjProperiesValues.GetByIndex(i));
                }

                if (loadedPropsColl.Count >= Information.GetAllPropertyNames(dobjectType).Length)
                {
                    curobj.SetLoadingState(LoadingState.Loaded);
                }
                else
                {
                    curobj.SetLoadingState(LoadingState.LightLoaded);
                    curobj.AddLoadedProperties(loadedPropsColl);
                }

                curobj.SetStatus(ObjectStatus.UnAltered);
            }
        }
    /// <summary>
    /// This function will return the smallest possible group number, which is currently not in use.
    /// </summary>
    /// <returns>The smallest unused group number (starting at 0).</returns>
    public int GetUnusedColumnGroupNumber()
    {
      System.Collections.SortedList groupNums = new System.Collections.SortedList();
      for(int i=0;i<ColumnCount;i++)
      {
        int group = this.GetColumnGroup(i);
        if(!groupNums.ContainsKey(group))
          groupNums.Add(group,null);
      }

      for(int i=0;i<int.MaxValue;i++)
      {
        if(!groupNums.Contains(i))
          return i;
      }
      return 0;
    }
        static private void AddPredifinedConvertion(Type systemtype, Type[] from, Type[] to)
        {
            if (!_checkedTypes.Contains(systemtype.FullName))
            {
                lock (_lockConst)
                {
                    if (!_checkedTypes.Contains(systemtype.FullName))
                    {
                        _checkedTypes.Add(systemtype.FullName);
                    }
                }
            }

            ThisIsKnownType(systemtype);

            System.Collections.Specialized.StringCollection sl;
            if (!_canConvertTo.ContainsKey(systemtype.FullName))
            {
                lock (_lockConst)
                {
                    if (!_canConvertTo.ContainsKey(systemtype.FullName))
                    {
                        _canConvertTo.Add(systemtype.FullName, new System.Collections.Specialized.StringCollection());
                    }
                }
            }

            sl = (System.Collections.Specialized.StringCollection)_canConvertTo[systemtype.FullName];

            for (int i = 0; i < to.Length; i++)
            {
                ThisIsKnownType(to[i]);
                if (!sl.Contains(to[i].FullName))
                {
                    lock (_lockConst)
                    {
                        if (!sl.Contains(to[i].FullName))
                        {
                            sl.Add(to[i].FullName);
                        }
                    }
                }
            }
            for (int i = 0; i < from.Length; i++)
            {
                ThisIsKnownType(from[i]);
                if (!_canConvertTo.ContainsKey(from[i].FullName))
                {
                    lock (_lockConst)
                    {
                        if (!_canConvertTo.ContainsKey(from[i].FullName))
                        {
                            _canConvertTo.Add(from[i].FullName, new System.Collections.Specialized.StringCollection());
                        }
                    }
                }
                sl = (System.Collections.Specialized.StringCollection)_canConvertTo[from[i].FullName];

                if (!sl.Contains(systemtype.FullName))
                {
                    lock (_lockConst)
                    {
                        if (!sl.Contains(systemtype.FullName))
                        {
                            sl.Add(systemtype.FullName);
                        }
                    }
                }
            }
        }
Example #33
0
        /// <summary>
        /// Retrieve OID name by OID string.
        /// </summary>
        /// <param name="inOidStr">source OID string.</param>
        /// <returns>OID name.</returns>
        public string GetOidName(string inOidStr)
        {
            if (oidDictionary == null) //Initialize oidDictionary:
            {
                oidDictionary = new StringDictionary();
                string path          = Application.ExecutablePath;
                string oidFile       = System.IO.Path.GetDirectoryName(path) + "\\OID.txt";
                string oidBackupFile = System.IO.Path.GetDirectoryName(path) + "\\OID.Backup.txt";
                string oidStr        = "";
                string oidDesc       = "";
                bool   loadOidError  = false;
                int    dbCounter     = 0;
                try
                {
                    using (StreamReader sr = new StreamReader(oidFile))
                    {
                        string line;
                        while ((line = sr.ReadLine()) != null)
                        {
                            string[] strs = line.Split(',');
                            if (strs.Length < 2)
                            {
                                continue;
                            }
                            oidStr  = strs[0].Trim();
                            oidDesc = strs[1].Trim();
                            try
                            {
                                oidDictionary.Add(oidStr, oidDesc);
                            }
                            catch (Exception ex)
                            {
                                loadOidError = true;
                                string msg = ex.Message;
                                dbCounter++;
                            }
                        }
                    }
                    if (loadOidError)
                    {
                        using (StreamWriter sw = new StreamWriter(oidBackupFile))
                        {
                            using (StreamReader sr = new StreamReader(oidFile))
                            {
                                string line;
                                while ((line = sr.ReadLine()) != null)
                                {
                                    sw.Write(line + "\r\n");
                                }
                            }
                        }

                        System.Collections.SortedList sList = new System.Collections.SortedList();
                        using (StreamWriter sw = new StreamWriter(oidFile))
                        {
                            string val = "";
                            foreach (System.Collections.DictionaryEntry de in oidDictionary)
                            {
                                if (!sList.ContainsKey(de.Key))
                                {
                                    sList.Add(de.Key, de.Value);
                                }
                            }
                            for (int i = 0; i < sList.Count; i++)
                            {
                                val = String.Format("{0}, {1}\r\n", sList.GetKey(i), sList.GetByIndex(i));
                                sw.Write(val);
                            }
                        }
                        MessageBox.Show(String.Format("Duplicated OIDs were found in the OID table: {0}.\r\n" +
                                                      "The duplicate has been removed; the table is sorted.\r\n" +
                                                      "The original OID file is copied as: {1}\r\n", oidFile, oidBackupFile));
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Failed to read OID values from file." + ex.Message);
                }
            }
            return(oidDictionary[inOidStr]);
        }
		/// <summary>
		/// Create an ASCII Ramp with from the given font and characters
		/// </summary>
		/// <param name="font">Font to be used</param>
		/// <param name="characters">The characters to be used for the ramp</param>
		/// <returns>A new ASCII ramp</returns>
		public static string CreateRamp(Font font, string characters)
		{
			if (characters == null || characters.Length < 1)
				return null;

			if (characters.Length == 1)
				return characters;

			string characterstring = "";

			foreach (char c in characters.ToCharArray())
			{
				if (characterstring.IndexOf(c) == -1)
				{
					characterstring += c.ToString();
				}
			}

			System.Collections.SortedList list = new System.Collections.SortedList();

			int min = 255;
			int max = 0;

			CharacterValue charval;

			for (int i = 0; i < characterstring.Length; i++)
			{
				charval = new CharacterValue(characterstring[i], font);

				if (list.ContainsKey(charval.Value))
				{
					if (charval.Score < ((CharacterValue)list[charval.Value]).Score)
					{
						list[charval.Value] = charval;
					}
				}
				else
				{
					if (charval.Value < min)
						min = charval.Value;

					if (charval.Value > max)
						max = charval.Value;

					list.Add(charval.Value, charval);
				}
			}

			list.TrimToSize();


			string result = "";

			System.Collections.IDictionaryEnumerator idenu = list.GetEnumerator();

			// move to the first object
			idenu.MoveNext();

			int current = (int)idenu.Key;
			int next, mid;

			// loop through and fill in the gaps
			while (idenu.MoveNext())
			{
				next = (int)idenu.Key;
				mid = ((next - current) / 2) + current;

				for (int i = current; i < mid; i++)
				{
					result += list[current];
				}

				for (int i = mid; i < next; i++)
				{
					result += list[next];
				}

				current = next;
			}

			return result;
		}