protected override void vRefreshProdutosAssociados(ref mdlComponentesGraficos.TreeView tvProdutosAssociados) { tvProdutosAssociados.Nodes.Clear(); System.Windows.Forms.TreeNode tvnNorma = null; System.Windows.Forms.TreeNode tvnClassificacao = null; System.Windows.Forms.TreeNode tvnProduto = null; // Produtos Certificado System.Collections.ArrayList arlProdutosCertificado = arlProdutosCertificadoOrigem(); // Ordenamento System.Collections.SortedList sortProdutosCertificado = new System.Collections.SortedList(new mdlComponentesColecoes.clsComparerNumbersTexts()); for (int i = 0; i < arlProdutosCertificado.Count; i++) { mdlDataBaseAccess.Tabelas.XsdTbProdutosCertificadoOrigem.tbProdutosCertificadoOrigemRow dtrwProdutoCertificado = (mdlDataBaseAccess.Tabelas.XsdTbProdutosCertificadoOrigem.tbProdutosCertificadoOrigemRow)arlProdutosCertificado[i]; if (dtrwProdutoCertificado.RowState != System.Data.DataRowState.Deleted) { if (!sortProdutosCertificado.ContainsKey(dtrwProdutoCertificado.idOrdem)) { sortProdutosCertificado.Add(dtrwProdutoCertificado.idOrdem, dtrwProdutoCertificado.idOrdem); } } } // Inserindo string strNormaUltima = ""; string strClassificacaoUltima = ""; for (int i = 0; i < sortProdutosCertificado.Count; i++) { int nIdOrdem = (int)sortProdutosCertificado.GetByIndex(i); for (int j = 0; j < arlProdutosCertificado.Count; j++) { mdlDataBaseAccess.Tabelas.XsdTbProdutosCertificadoOrigem.tbProdutosCertificadoOrigemRow dtrwProdutoCertificado = (mdlDataBaseAccess.Tabelas.XsdTbProdutosCertificadoOrigem.tbProdutosCertificadoOrigemRow)arlProdutosCertificado[j]; if ((dtrwProdutoCertificado.RowState != System.Data.DataRowState.Deleted) && (dtrwProdutoCertificado.idOrdem == nIdOrdem)) { // Norma string strNorma = strRetornaNorma(dtrwProdutoCertificado.idNorma); if (!dtrwProdutoCertificado.IsmstrNormaNull()) { strNorma = dtrwProdutoCertificado.mstrNorma; } if (strNorma != strNormaUltima) { tvnNorma = tvProdutosAssociados.Nodes.Add(strNorma); tvnNorma.Tag = dtrwProdutoCertificado.idNorma; strNormaUltima = strNorma; strClassificacaoUltima = ""; } // Classificacao string strClassificacao = strRetornaClassificacao(dtrwProdutoCertificado.idOrdemProduto); // Denominacao string strDenominacao = ""; if (!dtrwProdutoCertificado.IsmstrDenominacaoNull()) { strDenominacao = dtrwProdutoCertificado.mstrDenominacao; } else { strDenominacao = strRetornaDenominacao(dtrwProdutoCertificado.idOrdemProduto); } if (strClassificacao != strClassificacaoUltima) { tvnClassificacao = tvnNorma.Nodes.Add(strClassificacao + " " + strDenominacao); tvnClassificacao.Tag = strClassificacao; strClassificacaoUltima = strClassificacao; } // Descricao string strDescricao = ""; if (!dtrwProdutoCertificado.IsmstrDescricaoNull()) { strDescricao = dtrwProdutoCertificado.mstrDescricao; } else { strDescricao = strRetornaDescricaoProduto(dtrwProdutoCertificado.idOrdemProduto); } if (tvnClassificacao == null) { tvnClassificacao = tvnNorma.Nodes.Add(strClassificacao + " " + strDenominacao); tvnClassificacao.Tag = strClassificacao; } tvnProduto = tvnClassificacao.Nodes.Add(strDescricao); tvnProduto.Tag = dtrwProdutoCertificado.idOrdemProduto; } } } }
private void RotateShapes() { try { System.Collections.SortedList arr = new System.Collections.SortedList(); for (int i = 0; i < g.MapWin.View.SelectedShapes.NumSelected; i++) { arr.Add(g.MapWin.View.SelectedShapes[i].ShapeIndex, g.MapWin.View.SelectedShapes[i].ShapeIndex); } if (arr.Count > 0) { MapWinGIS.Shapefile sf = g.CurrentLayer; if (sf.StartEditingShapes(true, null)) { System.Diagnostics.Debug.WriteLine(sf.get_ErrorMsg(sf.LastErrorCode)); bool allCancelled = false; for (int j = arr.Count - 1; j >= 0; j--) { // Show the dialog to get input -- rotation amount, // rotate about point, etc. Note that dialog defaults // to rotate about the centroid, which is calculated // when the shape is set. // Actual rotation will be done here as well. dlg = new Forms.RotateShapeForm(g); dlg.sf = sf; dlg.Shape = sf.get_Shape((int)arr.GetByIndex(j)); // Note -- don't show modally; we want the user // to be able to click the map to choose a point if needed dlg.Show(g.MapWindowForm); // However, execution should not proceed until the user has finished... // So we use a really old-style waiting scheme while (dlg.Visible) { System.Windows.Forms.Application.DoEvents(); } if (dlg.DialogResult == System.Windows.Forms.DialogResult.Cancel) { allCancelled = true; break; } } if (!allCancelled) { g.CreateUndoPoint(); if (sf.StopEditingShapes(true, true, null) == false) { MapWinUtility.Logger.Message("Failed to save the changes that were made.", "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error, System.Windows.Forms.DialogResult.OK); } } else { sf.StopEditingShapes(false, true, null); MapWinUtility.Logger.Message("Shape resizing has been cancelled - no changes were saved.", "Cancelled", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information, System.Windows.Forms.DialogResult.OK); } } } } catch (System.Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message.ToString()); } }
protected void vRefreshNormas(ref mdlComponentesGraficos.ListView lvNormas) { try { System.Windows.Forms.ListViewItem lviNorma; lvNormas.Items.Clear(); // Normas Ordenando | Filtrando System.Collections.SortedList sortListNormas = new System.Collections.SortedList(); foreach (mdlDataBaseAccess.Tabelas.XsdTbCertificadosOrigemNormas.tbCertificadosOrigemNormasRow dtrwNormaResource in m_typDatSetTbCertificadosOrigemNormasResource.tbCertificadosOrigemNormas.Rows) { string strDescricao = dtrwNormaResource.mstrNome; mdlDataBaseAccess.Tabelas.XsdTbCertificadosOrigemNormas.tbCertificadosOrigemNormasRow dtrwNormaDataBase = m_typDatSetTbCertificadosOrigemNormasDataBase.tbCertificadosOrigemNormas.FindBynIdTipoCOnIdNorma(m_nIdTipoCO, dtrwNormaResource.nIdNorma); if ((dtrwNormaDataBase != null) && (dtrwNormaDataBase.RowState != System.Data.DataRowState.Deleted) && (!dtrwNormaDataBase.IsmstrNomeNull()) && (dtrwNormaDataBase.mstrNome.Trim() != "")) { strDescricao = dtrwNormaDataBase.mstrNome; } if (dtrwNormaResource.IsdtInicioNull()) { if (dtrwNormaResource.IsdtFimNull()) { sortListNormas.Add(strDescricao, dtrwNormaResource.nIdNorma); } else { if (dtrwNormaResource.dtFim > m_dtEmissaoCertificado) { sortListNormas.Add(strDescricao, dtrwNormaResource.nIdNorma); } } } else { if (dtrwNormaResource.IsdtFimNull()) { if (dtrwNormaResource.dtInicio < m_dtEmissaoCertificado) { sortListNormas.Add(strDescricao, dtrwNormaResource.nIdNorma); } } else { if ((dtrwNormaResource.dtInicio < m_dtEmissaoCertificado) && (dtrwNormaResource.dtFim > m_dtEmissaoCertificado)) { sortListNormas.Add(strDescricao, dtrwNormaResource.nIdNorma); } } } } // Normas Inserindo for (int i = 0; i < sortListNormas.Count; i++) { lviNorma = lvNormas.Items.Add(sortListNormas.GetKey(i).ToString()); lviNorma.Tag = sortListNormas.GetByIndex(i); if (bNormaUtilizadaCertificado(Int32.Parse(sortListNormas.GetByIndex(i).ToString()))) { lviNorma.ForeColor = m_clrUsed; } } } catch (Exception err) { Object erro = err; m_cls_ter_tratadorErro.trataErro(ref erro); } }
protected void carregaDadosInterfaceCadEdit(ref mdlComponentesGraficos.TextBox ctbNome, ref mdlComponentesGraficos.TextBox ctbEndereco, ref mdlComponentesGraficos.TextBox ctbCidade, ref mdlComponentesGraficos.TextBox ctbEstado, ref mdlComponentesGraficos.ComboBox cbPaises, ref mdlComponentesGraficos.TextBox ctbTelefone, ref mdlComponentesGraficos.TextBox ctbFax, ref mdlComponentesGraficos.TextBox ctbEMail, ref mdlComponentesGraficos.TextBox ctbSite, ref System.Windows.Forms.TextBox ctbObs) { try { #region Pesquisa System.Collections.ArrayList arlOrdenacaoTipo = new System.Collections.ArrayList(); System.Collections.ArrayList arlOrdenacaoValor = new System.Collections.ArrayList(); arlOrdenacaoTipo.Add(mdlDataBaseAccess.TipoOrdenacao.Crescente); arlOrdenacaoValor.Clear(); arlOrdenacaoValor.Add("nmPais"); m_cls_dba_ConnectionDB.FonteDosDados = mdlDataBaseAccess.FonteDados.Resource; m_typDatSetTbPaises = m_cls_dba_ConnectionDB.GetTbPaises(null, null, null, /*arlOrdenacaoValor,arlOrdenacaoTipo*/ null, null); m_cls_dba_ConnectionDB.FonteDosDados = mdlDataBaseAccess.FonteDados.DataBase; mdlDataBaseAccess.Tabelas.XsdTbPaises.tbPaisesRow dtrwRowTbPaises; System.Collections.SortedList srlPaises = new System.Collections.SortedList(); foreach (mdlDataBaseAccess.Tabelas.XsdTbPaises.tbPaisesRow dtrwRowTbPaisesSorted in m_typDatSetTbPaises.tbPaises.Rows) { srlPaises.Add(dtrwRowTbPaisesSorted.nmPais, dtrwRowTbPaisesSorted); } #endregion #region Adicionando Items ao Formulário ctbNome.Text = m_strImportador; ctbEndereco.Text = m_strEndereco; ctbCidade.Text = m_strCidade; ctbEstado.Text = m_strEstado; if (srlPaises != null) { for (int nCont = 0; nCont < srlPaises.Count; nCont++) { dtrwRowTbPaises = (mdlDataBaseAccess.Tabelas.XsdTbPaises.tbPaisesRow)srlPaises.GetByIndex(nCont); cbPaises.AddItem(dtrwRowTbPaises.nmPais, dtrwRowTbPaises.idPais); if (dtrwRowTbPaises.idPais == m_nIdPais) { cbPaises.SelectedIndex = nCont; m_strPais = dtrwRowTbPaises.nmPais; } } } ctbTelefone.Text = m_strTelefone; ctbFax.Text = m_strFax; ctbEMail.Text = m_strEMail; ctbSite.Text = m_strSite; ctbObs.Text = m_strObs; #endregion } catch (Exception err) { Object erro = err; m_cls_ter_tratadorErro.trataErro(ref erro); } }
/// <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 }
protected void carregaDadosInterfaceImportadorConsignatario(ref mdlComponentesGraficos.TextBox ctbNome, ref mdlComponentesGraficos.TextBox ctbEndereco, ref mdlComponentesGraficos.TextBox ctbCidade, ref mdlComponentesGraficos.TextBox ctbEstado, ref mdlComponentesGraficos.ComboBox cbPaises) { try { System.Collections.SortedList srlPaises = new System.Collections.SortedList(); foreach (mdlDataBaseAccess.Tabelas.XsdTbPaises.tbPaisesRow dtrwRowTbPaisesSorted in m_typDatSetTbPaises.tbPaises.Rows) { srlPaises.Add(dtrwRowTbPaisesSorted.nmPais, dtrwRowTbPaisesSorted); } mdlDataBaseAccess.Tabelas.XsdTbPaises.tbPaisesRow dtrwRowTbPaises; ctbNome.Text = m_strImportadorConsignatario; ctbEndereco.Text = m_strEnderecoConsignatario; ctbCidade.Text = m_strCidade; ctbEstado.Text = m_strEstado; if (srlPaises != null) { for (int nCont = 0; nCont < srlPaises.Count; nCont++) { dtrwRowTbPaises = (mdlDataBaseAccess.Tabelas.XsdTbPaises.tbPaisesRow)srlPaises.GetByIndex(nCont); cbPaises.AddItem(dtrwRowTbPaises.nmPais, dtrwRowTbPaises.idPais); if (dtrwRowTbPaises.idPais == m_nIdPais) { cbPaises.SelectedIndex = nCont; m_strPais = dtrwRowTbPaises.nmPais; } } } } catch (Exception err) { Object erro = err; m_cls_ter_tratadorErro.trataErro(ref erro); } }
private void vNaviosRefresh(int nIdArmador, ref System.Windows.Forms.ListView lvNavios) { lvNavios.Items.Clear(); // Sorting System.Collections.SortedList sortListNavios = new System.Collections.SortedList(); foreach (mdlDataBaseAccess.Tabelas.XsdTbArmadoresNavios.tbArmadoresNaviosRow dtrwNavio in m_typDatSetArmadoresNavios.tbArmadoresNavios.Rows) { if ((dtrwNavio.RowState != System.Data.DataRowState.Deleted) && (dtrwNavio.nIdArmador == nIdArmador) && (!dtrwNavio.IsstrNomeNull())) { if (!sortListNavios.ContainsKey(dtrwNavio.strNome)) { sortListNavios.Add(dtrwNavio.strNome, dtrwNavio); } } } // Insert for (int i = 0; i < sortListNavios.Count; i++) { mdlDataBaseAccess.Tabelas.XsdTbArmadoresNavios.tbArmadoresNaviosRow dtrwNavioInserir = (mdlDataBaseAccess.Tabelas.XsdTbArmadoresNavios.tbArmadoresNaviosRow)sortListNavios.GetByIndex(i); System.Windows.Forms.ListViewItem lviInsert = lvNavios.Items.Add(dtrwNavioInserir.strNome); lviInsert.Tag = dtrwNavioInserir.nIdNavio; if ((m_nIdSelectNavio != -1) && (dtrwNavioInserir.nIdNavio == m_nIdSelectNavio)) { lviInsert.Selected = true; m_nIdSelectNavio = -1; } } }
protected override string CarregaDataMultiplaDefault() { mdlDataBaseAccess.Tabelas.XsdTbREs typDatSetREs = GetTbREs(); mdlDataBaseAccess.Tabelas.XsdTbREsPEs typDatSetREsPEs = GetTbREsPEs(); mdlDataBaseAccess.Tabelas.XsdTbSDs typDatSetSDs = GetTbSDs(); System.Text.StringBuilder strbDefault = new System.Text.StringBuilder(); // Ordernando System.Collections.SortedList srtlstSD = new System.Collections.SortedList(new mdlComponentesColecoes.clsComparerNumbersTexts()); for (int i = 0; i < typDatSetREsPEs.tbREsPEs.Rows.Count; i++) { mdlDataBaseAccess.Tabelas.XsdTbREsPEs.tbREsPEsRow dtrwREPE = (mdlDataBaseAccess.Tabelas.XsdTbREsPEs.tbREsPEsRow)typDatSetREsPEs.tbREsPEs.Rows[i]; if ((dtrwREPE.nIdExportador == m_nIdExportador) && (dtrwREPE.strIdPE == m_strIdPE)) { mdlDataBaseAccess.Tabelas.XsdTbREs.tbREsRow dtrwRE = typDatSetREs.tbREs.FindBynIdExportadornIdRe(m_nIdExportador, dtrwREPE.nIdRe); if ((dtrwRE != null) && (!dtrwRE.IsnIdSDNull())) { mdlDataBaseAccess.Tabelas.XsdTbSDs.tbSDsRow dtrwSD = typDatSetSDs.tbSDs.FindBynIdExportadornIdSD(m_nIdExportador, dtrwRE.nIdSD); if ((dtrwSD != null) && (!srtlstSD.Contains(dtrwSD.mstrNumero))) { srtlstSD.Add(dtrwSD.mstrNumero, dtrwSD); } } } } // Inserindo for (int i = 0; i < srtlstSD.Count; i++) { mdlDataBaseAccess.Tabelas.XsdTbSDs.tbSDsRow dtrwSD = (mdlDataBaseAccess.Tabelas.XsdTbSDs.tbSDsRow)srtlstSD.GetByIndex(i); if (strbDefault.ToString() != "") { strbDefault.Append(" - "); } if (!dtrwSD.IsdtEmissaoNull()) { strbDefault.Append(dtrwSD.dtEmissao.ToString(this.Formato)); } else { strbDefault.Append(" "); } } return(strbDefault.ToString()); }
private void vRefreshREs(ref mdlComponentesGraficos.ListView lvRes) { lvRes.Items.Clear(); System.Collections.SortedList sortLstRE = new System.Collections.SortedList(new mdlComponentesColecoes.clsComparerNumbersTexts()); // Ordenando for (int i = 0; i < m_typDatSetRes.tbREs.Rows.Count; i++) { mdlDataBaseAccess.Tabelas.XsdTbREs.tbREsRow dtrwRE = (mdlDataBaseAccess.Tabelas.XsdTbREs.tbREsRow)m_typDatSetRes.tbREs.Rows[i]; if ((dtrwRE.RowState != System.Data.DataRowState.Deleted)) { sortLstRE.Add(dtrwRE.mstrNumero, dtrwRE); } } // Inserindo System.Windows.Forms.ListViewItem lviInserir; for (int i = sortLstRE.Count - 1; i >= 0; i--) { mdlDataBaseAccess.Tabelas.XsdTbREs.tbREsRow dtrwRE = (mdlDataBaseAccess.Tabelas.XsdTbREs.tbREsRow)sortLstRE.GetByIndex(i); lviInserir = lvRes.Items.Add(GetName(dtrwRE)); lviInserir.Tag = dtrwRE.nIdRe; } }
private void vAgentesCargaRefresh(ref System.Windows.Forms.ListView lvAgentesCarga) { lvAgentesCarga.Items.Clear(); // Sorting System.Collections.SortedList sortListAgentesCarga = new System.Collections.SortedList(); foreach (mdlDataBaseAccess.Tabelas.XsdTbAgentesCargas.tbAgentesCargasRow dtrwAgenteCarga in m_typDatSetAgentesCargas.tbAgentesCargas.Rows) { if ((dtrwAgenteCarga.RowState != System.Data.DataRowState.Deleted) && (!dtrwAgenteCarga.IsstrNomeNull())) { if (!sortListAgentesCarga.ContainsKey(dtrwAgenteCarga.strNome)) { sortListAgentesCarga.Add(dtrwAgenteCarga.strNome, dtrwAgenteCarga); } } } // Insert for (int i = 0; i < sortListAgentesCarga.Count; i++) { mdlDataBaseAccess.Tabelas.XsdTbAgentesCargas.tbAgentesCargasRow dtrwAgentesCargaInserir = (mdlDataBaseAccess.Tabelas.XsdTbAgentesCargas.tbAgentesCargasRow)sortListAgentesCarga.GetByIndex(i); System.Windows.Forms.ListViewItem lviAgente = lvAgentesCarga.Items.Add(dtrwAgentesCargaInserir.strNome); lviAgente.Tag = dtrwAgentesCargaInserir.nIdAgenteCarga; if ((m_nIdSelect != -1) && (dtrwAgentesCargaInserir.nIdAgenteCarga == m_nIdSelect)) { lviAgente.Selected = true; m_nIdSelect = -1; } } }
public T this[int index] { get { return((T)list.GetByIndex(index)); } }
/// <summary> /// Analyzes the first <code>nLines</code> of the ascii stream. /// </summary> /// <param name="nLines">The number of lines to analyze. It is no error if the stream contains a less number of lines than provided here.</param> /// <param name="defaultImportOptions">The default import options.</param> /// <returns>Import options that can be used in a following step to read in the ascii stream. Null is returned if the stream contains no data.</returns> public AsciiImportOptions Analyze(int nLines, AsciiImportOptions defaultImportOptions) { string sLine; stream.Position = 0; System.IO.StreamReader sr = new System.IO.StreamReader(stream, System.Text.Encoding.Default, true); System.Collections.ArrayList result = new System.Collections.ArrayList(); for (int i = 0; i < nLines; i++) { sLine = sr.ReadLine(); if (null == sLine) { break; } result.Add(new AsciiLineAnalyzer(i, sLine)); } if (result.Count == 0) { return(null); // there is nothing to analyze } // now view the results // calc the frequency o System.Collections.SortedList sl = new System.Collections.SortedList(); int nItems; // first the tabs /* * sl.Clear(); * for(int i=0;i<result.Count;i++) * { * nItems = ((AsciiLineAnalyzer)result[i]).nNumberOfTabs; * if(0!=nItems) * { * if(null==sl[nItems]) * sl.Add(nItems,1); * else * sl[nItems] = 1+(int)sl[nItems]; * } * } * // get the tab count with the topmost frequency * int nMaxNumberOfSameTabs = 0; * int nMaxTabsOfSameNumber = 0; * for(int i=0;i<sl.Count;i++) * { * if(nMaxNumberOfSameTabs<(int)sl.GetByIndex(i)) * { * nMaxNumberOfSameTabs = (int)sl.GetByIndex(i); * nMaxTabsOfSameNumber = (int)sl.GetKey(i); * } * } */ // Count the commas sl.Clear(); for (int i = 0; i < result.Count; i++) { nItems = ((AsciiLineAnalyzer)result[i]).nNumberOfCommas; if (0 != nItems) { if (null == sl[nItems]) { sl.Add(nItems, 1); } else { sl[nItems] = 1 + (int)sl[nItems]; } } } // get the comma count with the topmost frequency int nMaxNumberOfSameCommas = 0; int nMaxCommasOfSameNumber = 0; for (int i = 0; i < sl.Count; i++) { if (nMaxNumberOfSameCommas < (int)sl.GetByIndex(i)) { nMaxNumberOfSameCommas = (int)sl.GetByIndex(i); nMaxCommasOfSameNumber = (int)sl.GetKey(i); } } // Count the semicolons sl.Clear(); for (int i = 0; i < result.Count; i++) { nItems = ((AsciiLineAnalyzer)result[i]).nNumberOfSemicolons; if (0 != nItems) { if (null == sl[nItems]) { sl.Add(nItems, 1); } else { sl[nItems] = 1 + (int)sl[nItems]; } } } // get the tab count with the topmost frequency int nMaxNumberOfSameSemicolons = 0; int nMaxSemicolonsOfSameNumber = 0; for (int i = 0; i < sl.Count; i++) { if (nMaxNumberOfSameSemicolons < (int)sl.GetByIndex(i)) { nMaxNumberOfSameSemicolons = (int)sl.GetByIndex(i); nMaxSemicolonsOfSameNumber = (int)sl.GetKey(i); } } NumberAndStructure[] st = new NumberAndStructure[3]; for (int i = 0; i < 3; i++) { st[i].nLines = GetPriorityOf(result, (AsciiLineAnalyzer.Separation)i, ref st[i].structure); } // look for the top index int nMaxLines = int.MinValue; double maxprtylines = 0; int nBestSeparator = int.MinValue; for (int i = 0; i < 3; i++) { double prtylines = (double)st[i].nLines * st[i].structure.Priority; if (prtylines == maxprtylines) { if (st[i].nLines > nMaxLines) { nMaxLines = st[i].nLines; nBestSeparator = i; } } else if (prtylines > maxprtylines) { maxprtylines = prtylines; nBestSeparator = i; nMaxLines = st[i].nLines; } } AsciiImportOptions opt = defaultImportOptions.Clone(); opt.bDelimited = true; opt.cDelimiter = nBestSeparator == 0 ? '\t' : (nBestSeparator == 1 ? ',' : ';'); opt.recognizedStructure = st[nBestSeparator].structure; // look how many header lines are in the file by comparing the structure of the first lines with the recognized structure for (int i = 0; i < result.Count; i++) { opt.nMainHeaderLines = i; if (((AsciiLineAnalyzer)result[i]).structure[nBestSeparator].IsCompatibleWith(opt.recognizedStructure)) { break; } } // calculate the total statistics of decimal separators opt.m_DecimalSeparatorCommaCount = 0; opt.m_DecimalSeparatorDotCount = 0; for (int i = 0; i < result.Count; i++) { opt.m_DecimalSeparatorDotCount += ((AsciiLineAnalyzer)result[i]).structure[nBestSeparator].DecimalSeparatorDotCount; opt.m_DecimalSeparatorCommaCount += ((AsciiLineAnalyzer)result[i]).structure[nBestSeparator].DecimalSeparatorCommaCount; } return(opt); }
/// <summary> /// renew all guids of xmlString /// </summary> /// <param name="xmlString"></param> /// <returns></returns> public string RefreshAllGuids(ref string xmlString) { System.Xml.XmlDocumentFragment fragdoc = xmlDoc.CreateDocumentFragment(); fragdoc.InnerXml = xmlString; System.Collections.IEnumerator ie = fragdoc.ChildNodes.GetEnumerator(); System.Collections.SortedList listGUID = new System.Collections.SortedList(); string strFirstGUID = null; xmlString = ""; while (ie.MoveNext()) { System.Xml.XmlNode node = (System.Xml.XmlNode)ie.Current; string OldGUID = GetAttributeByName(node, PazDocumentLegacy.TAG_GUID); string NewGUID = Guid.NewGuid().ToString(); string ParentGUID = GetAttributeByName(node, PazDocumentLegacy.TAG_PARENTGUID); if (strFirstGUID == null) { strFirstGUID = NewGUID; } listGUID.Add(OldGUID, NewGUID); if (listGUID.Contains(ParentGUID)) { SetAttributeByName(node, PazDocumentLegacy.TAG_PARENTGUID, (string)listGUID.GetByIndex(listGUID.IndexOfKey(ParentGUID))); } SetAttributeByName(node, PazDocumentLegacy.TAG_GUID, NewGUID); SetAttributeByName(node, PazDocumentLegacy.TAG_TIMESTAMP, DateTime.Now.Ticks.ToString()); xmlString += node.OuterXml; } return(strFirstGUID); }
/// <summary> /// Analyzes the first <code>nLines</code> of the ascii stream. /// </summary> /// <param name="nLines">The number of lines to analyze. It is no error if the stream contains a less number of lines than provided here.</param> /// <param name="defaultImportOptions">The default import options.</param> /// <returns>Import options that can be used in a following step to read in the ascii stream. Null is returned if the stream contains no data.</returns> public AsciiImportOptions Analyze(int nLines, AsciiImportOptions defaultImportOptions) { string sLine; stream.Position = 0; System.IO.StreamReader sr = new System.IO.StreamReader(stream,System.Text.Encoding.Default,true); System.Collections.ArrayList result = new System.Collections.ArrayList(); for(int i=0;i<nLines;i++) { sLine = sr.ReadLine(); if(null==sLine) break; result.Add(new AsciiLineAnalyzer(i,sLine)); } if(result.Count==0) return null; // there is nothing to analyze // now view the results // calc the frequency o System.Collections.SortedList sl= new System.Collections.SortedList(); int nItems; // first the tabs /* sl.Clear(); for(int i=0;i<result.Count;i++) { nItems = ((AsciiLineAnalyzer)result[i]).nNumberOfTabs; if(0!=nItems) { if(null==sl[nItems]) sl.Add(nItems,1); else sl[nItems] = 1+(int)sl[nItems]; } } // get the tab count with the topmost frequency int nMaxNumberOfSameTabs = 0; int nMaxTabsOfSameNumber = 0; for(int i=0;i<sl.Count;i++) { if(nMaxNumberOfSameTabs<(int)sl.GetByIndex(i)) { nMaxNumberOfSameTabs = (int)sl.GetByIndex(i); nMaxTabsOfSameNumber = (int)sl.GetKey(i); } } */ // Count the commas sl.Clear(); for(int i=0;i<result.Count;i++) { nItems = ((AsciiLineAnalyzer)result[i]).nNumberOfCommas; if(0!=nItems) { if(null==sl[nItems]) sl.Add(nItems,1); else sl[nItems] = 1+(int)sl[nItems]; } } // get the comma count with the topmost frequency int nMaxNumberOfSameCommas = 0; int nMaxCommasOfSameNumber = 0; for(int i=0;i<sl.Count;i++) { if(nMaxNumberOfSameCommas<(int)sl.GetByIndex(i)) { nMaxNumberOfSameCommas = (int)sl.GetByIndex(i); nMaxCommasOfSameNumber = (int)sl.GetKey(i); } } // Count the semicolons sl.Clear(); for(int i=0;i<result.Count;i++) { nItems = ((AsciiLineAnalyzer)result[i]).nNumberOfSemicolons; if(0!=nItems) { if(null==sl[nItems]) sl.Add(nItems,1); else sl[nItems] = 1+(int)sl[nItems]; } } // get the tab count with the topmost frequency int nMaxNumberOfSameSemicolons = 0; int nMaxSemicolonsOfSameNumber = 0; for(int i=0;i<sl.Count;i++) { if(nMaxNumberOfSameSemicolons<(int)sl.GetByIndex(i)) { nMaxNumberOfSameSemicolons = (int)sl.GetByIndex(i); nMaxSemicolonsOfSameNumber = (int)sl.GetKey(i); } } NumberAndStructure[] st = new NumberAndStructure[3]; for(int i=0;i<3;i++) { st[i].nLines = GetPriorityOf(result,(AsciiLineAnalyzer.Separation)i,ref st[i].structure); } // look for the top index int nMaxLines = int.MinValue; double maxprtylines=0; int nBestSeparator = int.MinValue; for(int i=0;i<3;i++) { double prtylines = (double)st[i].nLines * st[i].structure.Priority; if(prtylines==maxprtylines) { if(st[i].nLines > nMaxLines) { nMaxLines = st[i].nLines; nBestSeparator = i; } } else if(prtylines>maxprtylines) { maxprtylines = prtylines; nBestSeparator = i; nMaxLines=st[i].nLines; } } AsciiImportOptions opt = defaultImportOptions.Clone(); opt.bDelimited = true; opt.cDelimiter = nBestSeparator==0 ? '\t' : (nBestSeparator==1 ? ',' : ';'); opt.recognizedStructure = st[nBestSeparator].structure; // look how many header lines are in the file by comparing the structure of the first lines with the recognized structure for(int i=0;i<result.Count;i++) { opt.nMainHeaderLines=i; if(((AsciiLineAnalyzer)result[i]).structure[nBestSeparator].IsCompatibleWith(opt.recognizedStructure)) break; } // calculate the total statistics of decimal separators opt.m_DecimalSeparatorCommaCount=0; opt.m_DecimalSeparatorDotCount=0; for(int i=0;i<result.Count;i++) { opt.m_DecimalSeparatorDotCount += ((AsciiLineAnalyzer)result[i]).structure[nBestSeparator].DecimalSeparatorDotCount; opt.m_DecimalSeparatorCommaCount += ((AsciiLineAnalyzer)result[i]).structure[nBestSeparator].DecimalSeparatorCommaCount; } return opt; }
protected override bool bIntegridadeDados() { bool bRetorno = false; int nNextIdOrdemCertificado = 0; // Produtos Certificado System.Collections.ArrayList arlProdutosCertificado = arlProdutosCertificadoOrigem(); // Normas - Ordenamento System.Collections.SortedList sortListNormas = new System.Collections.SortedList(); for (int i = 0; i < arlProdutosCertificado.Count; i++) { mdlDataBaseAccess.Tabelas.XsdTbProdutosCertificadoOrigem.tbProdutosCertificadoOrigemRow dtrwProdutoCertificado = (mdlDataBaseAccess.Tabelas.XsdTbProdutosCertificadoOrigem.tbProdutosCertificadoOrigemRow)arlProdutosCertificado[i]; if (dtrwProdutoCertificado.RowState != System.Data.DataRowState.Deleted) { string strNorma = ""; if (!dtrwProdutoCertificado.IsmstrNormaNull()) { strNorma = dtrwProdutoCertificado.mstrNorma; } else { strNorma = strRetornaNorma(dtrwProdutoCertificado.idNorma); } if (!sortListNormas.ContainsKey(strNorma)) { sortListNormas.Add(strNorma, dtrwProdutoCertificado.idNorma); } } } // Normas - Insercao for (int i = 0; i < sortListNormas.Count; i++) { // Classificacao - Ordenamento int nIdNorma = Int32.Parse(sortListNormas.GetByIndex(i).ToString()); System.Collections.SortedList sortListClassificacao = new System.Collections.SortedList(); for (int j = 0; j < arlProdutosCertificado.Count; j++) { mdlDataBaseAccess.Tabelas.XsdTbProdutosCertificadoOrigem.tbProdutosCertificadoOrigemRow dtrwProdutoCertificado = (mdlDataBaseAccess.Tabelas.XsdTbProdutosCertificadoOrigem.tbProdutosCertificadoOrigemRow)arlProdutosCertificado[j]; if ((dtrwProdutoCertificado.RowState != System.Data.DataRowState.Deleted) && (!dtrwProdutoCertificado.IsidNormaNull()) && (dtrwProdutoCertificado.idNorma == nIdNorma)) { string strClassificacao = strRetornaClassificacao(dtrwProdutoCertificado.idOrdemProduto); if (!sortListClassificacao.Contains(strClassificacao)) { sortListClassificacao.Add(strClassificacao, strClassificacao); } } } // Classificacao - Insercao for (int j = 0; j < sortListClassificacao.Count; j++) { string strClassificacao = sortListClassificacao.GetByIndex(j).ToString(); string strUnidadeUltima = ""; for (int k = 0; k < arlProdutosCertificado.Count; k++) { mdlDataBaseAccess.Tabelas.XsdTbProdutosCertificadoOrigem.tbProdutosCertificadoOrigemRow dtrwProdutoCertificado = (mdlDataBaseAccess.Tabelas.XsdTbProdutosCertificadoOrigem.tbProdutosCertificadoOrigemRow)arlProdutosCertificado[k]; string strClassificacaoProduto = strRetornaClassificacao(dtrwProdutoCertificado.idOrdemProduto); if ((dtrwProdutoCertificado.RowState != System.Data.DataRowState.Deleted) && (!dtrwProdutoCertificado.IsidNormaNull()) && (dtrwProdutoCertificado.idNorma == nIdNorma) && (strClassificacao == strClassificacaoProduto)) { string strUnidadeProduto = strRetornaUnidadeProduto(dtrwProdutoCertificado.idOrdemProduto); if (strUnidadeUltima != strUnidadeProduto) { nNextIdOrdemCertificado++; strUnidadeUltima = strUnidadeProduto; } dtrwProdutoCertificado.idOrdem = nNextIdOrdemCertificado; } } } } bRetorno = true; return(bRetorno); }
private void vRefreshREsDisponiveis(ref mdlComponentesGraficos.ListView lvRes) { lvRes.Items.Clear(); if (!bDSEVinculado(m_strIdPe)) { System.Collections.SortedList sortLstRE = new System.Collections.SortedList(new mdlComponentesColecoes.clsComparerNumbersTexts()); mdlDataBaseAccess.Tabelas.XsdTbFaturasComerciais.tbFaturasComerciaisRow dtrwFaturaComercial = GetRowFaturaComercial(m_strIdPe); if ((dtrwFaturaComercial == null) || (dtrwFaturaComercial.IsidImportadorNull())) { return; } int nIdImportadorPE = dtrwFaturaComercial.idImportador; // Ordenando for (int i = 0; i < m_typDatSetRes.tbREs.Rows.Count; i++) { mdlDataBaseAccess.Tabelas.XsdTbREs.tbREsRow dtrwRE = (mdlDataBaseAccess.Tabelas.XsdTbREs.tbREsRow)m_typDatSetRes.tbREs.Rows[i]; if ((dtrwRE.RowState != System.Data.DataRowState.Deleted)) { int nIdImportadorRE = GetREImportador(dtrwRE.nIdRe); if ((nIdImportadorRE == -1) || (nIdImportadorRE == nIdImportadorPE) && (!bReVinculado(dtrwRE.nIdRe, m_strIdPe))) { sortLstRE.Add(dtrwRE.mstrNumero, dtrwRE); } } } // Inserindo System.Windows.Forms.ListViewItem lviInserir; for (int i = 0; i < sortLstRE.Count; i++) { mdlDataBaseAccess.Tabelas.XsdTbREs.tbREsRow dtrwRE = (mdlDataBaseAccess.Tabelas.XsdTbREs.tbREsRow)sortLstRE.GetByIndex(i); lviInserir = lvRes.Items.Add(GetName(dtrwRE)); lviInserir.Tag = dtrwRE.nIdRe; } } }
protected void carregaDadosInterface(ref mdlComponentesGraficos.ListView lvConsignatarios, ref System.Windows.Forms.Button btEditar, ref System.Windows.Forms.Button btExcluir, ref System.Windows.Forms.Label lNomeImportador) { try { System.Collections.SortedList srlConsignatarios = retornaConsignatariosOrdenado(); // List View Item System.Windows.Forms.ListViewItem lvItemConsignatario; // Limpa os Items da List View lvConsignatarios.Items.Clear(); mdlDataBaseAccess.Tabelas.XsdTbImportadoresConsignatarios.tbImportadoresConsignatariosRow dtrwRowTbImportadoresConsignatario; // Preenche os itens da List View for (int nCont = 0; nCont < srlConsignatarios.Count; nCont++) { dtrwRowTbImportadoresConsignatario = (mdlDataBaseAccess.Tabelas.XsdTbImportadoresConsignatarios.tbImportadoresConsignatariosRow)srlConsignatarios.GetByIndex(nCont); if (dtrwRowTbImportadoresConsignatario.RowState != System.Data.DataRowState.Deleted) { lvItemConsignatario = lvConsignatarios.Items.Add(dtrwRowTbImportadoresConsignatario.strNome); lvItemConsignatario.Tag = dtrwRowTbImportadoresConsignatario.nIdConsignatario; if ((int)lvItemConsignatario.Tag == m_nIdConsignatario) { lvItemConsignatario.Selected = true; } } } if (lvConsignatarios.Items.Count == 0) { btEditar.Enabled = false; btExcluir.Enabled = false; } else { btEditar.Enabled = true; btExcluir.Enabled = true; } lNomeImportador.Text = m_strImportador; } catch (Exception err) { Object erro = err; m_cls_ter_tratadorErro.trataErro(ref erro); } }
private void vRefreshPEsVinculados(int nIdRe, ref mdlComponentesGraficos.ListView lvPEsVinculados) { lvPEsVinculados.Items.Clear(); System.Collections.SortedList sortLstREPE = new System.Collections.SortedList(new mdlComponentesColecoes.clsComparerNumbersTexts()); // Ordenando for (int i = 0; i < m_typDatSetResPes.tbREsPEs.Rows.Count; i++) { mdlDataBaseAccess.Tabelas.XsdTbREsPEs.tbREsPEsRow dtrwREPE = (mdlDataBaseAccess.Tabelas.XsdTbREsPEs.tbREsPEsRow)m_typDatSetResPes.tbREsPEs.Rows[i]; if ((dtrwREPE.RowState != System.Data.DataRowState.Deleted) && (dtrwREPE.nIdExportador == m_nIdExportador) && (dtrwREPE.nIdRe == nIdRe)) { sortLstREPE.Add(dtrwREPE.strIdPE, dtrwREPE); } } // Inserindo System.Windows.Forms.ListViewItem lviInserir; for (int i = 0; i < sortLstREPE.Count; i++) { mdlDataBaseAccess.Tabelas.XsdTbREsPEs.tbREsPEsRow dtrwREPE = (mdlDataBaseAccess.Tabelas.XsdTbREsPEs.tbREsPEsRow)sortLstREPE.GetByIndex(i); lviInserir = lvPEsVinculados.Items.Add(sortLstREPE.GetKey(i).ToString()); lviInserir.Tag = dtrwREPE.strIdPE; } }
protected void carregaDadosInterfacePaises(ref mdlComponentesGraficos.ComboBox cbPaises) { try { System.Collections.SortedList srlPaises = new System.Collections.SortedList(); foreach (mdlDataBaseAccess.Tabelas.XsdTbPaises.tbPaisesRow dtrwRowTbPaisesSorted in m_typDatSetTbPaises.tbPaises.Rows) { srlPaises.Add(dtrwRowTbPaisesSorted.nmPais, dtrwRowTbPaisesSorted); } mdlDataBaseAccess.Tabelas.XsdTbPaises.tbPaisesRow dtrwRowTbPaises; if (srlPaises != null) { for (int nCont = 0; nCont < srlPaises.Count; nCont++) { dtrwRowTbPaises = (mdlDataBaseAccess.Tabelas.XsdTbPaises.tbPaisesRow)srlPaises.GetByIndex(nCont); cbPaises.AddItem(dtrwRowTbPaises.nmPais, dtrwRowTbPaises.idPais); } } } catch (Exception err) { Object erro = err; m_cls_ter_tratadorErro.trataErro(ref erro); } }
private void vGeraPersonalizavel() { System.Text.StringBuilder strbPersonalizavel = new System.Text.StringBuilder(); System.Collections.SortedList sortLstDSEPE = new System.Collections.SortedList(new mdlComponentesColecoes.clsComparerNumbersTexts()); // Ordenando for (int i = 0; i < m_typDatSetResPes.tbREsPEs.Rows.Count; i++) { mdlDataBaseAccess.Tabelas.XsdTbREsPEs.tbREsPEsRow dtrwREPE = (mdlDataBaseAccess.Tabelas.XsdTbREsPEs.tbREsPEsRow)m_typDatSetResPes.tbREsPEs.Rows[i]; if ((dtrwREPE.RowState != System.Data.DataRowState.Deleted) && (dtrwREPE.nIdExportador == m_nIdExportador) && (dtrwREPE.strIdPE == m_strIdPe)) { sortLstDSEPE.Add(GetRENumero(dtrwREPE.nIdRe), dtrwREPE); } } // Inserindo for (int i = 0; i < sortLstDSEPE.Count; i++) { mdlDataBaseAccess.Tabelas.XsdTbREsPEs.tbREsPEsRow dtrwREPE = (mdlDataBaseAccess.Tabelas.XsdTbREsPEs.tbREsPEsRow)sortLstDSEPE.GetByIndex(i); if (strbPersonalizavel.ToString() != "") { strbPersonalizavel.Append(" , "); } strbPersonalizavel.Append(GetName(GetRE(dtrwREPE.nIdRe))); } m_strPersonalizavel = strbPersonalizavel.ToString(); if (m_typDatSetPes.tbPEs.Rows.Count > 0) { mdlDataBaseAccess.Tabelas.XsdTbPes.tbPEsRow dtrwPE = (mdlDataBaseAccess.Tabelas.XsdTbPes.tbPEsRow)m_typDatSetPes.tbPEs.Rows[0]; dtrwPE.mstrRE = m_strPersonalizavel; dtrwPE.SetmstrSDNull(); } }
protected void carregaDadosInterface(ref mdlComponentesGraficos.ListView lvContas, ref System.Windows.Forms.Button btEditar, ref System.Windows.Forms.Button btExcluir, ref System.Windows.Forms.Button btNovo) { try { System.Collections.SortedList srlContas = retornaContasOrdenadas(); // List View Item System.Windows.Forms.ListViewItem lvItemConta; // Limpa os Items da List View lvContas.Items.Clear(); mdlDataBaseAccess.Tabelas.XsdTbExportadores.tbExportadoresRow dtrwRowTbExportadores; // Preenche os itens da List View for (int nCont = 0; nCont < srlContas.Count; nCont++) { dtrwRowTbExportadores = (mdlDataBaseAccess.Tabelas.XsdTbExportadores.tbExportadoresRow)srlContas.GetByIndex(nCont); if (dtrwRowTbExportadores.RowState != System.Data.DataRowState.Deleted) { lvItemConta = lvContas.Items.Add(dtrwRowTbExportadores.marca); lvItemConta.Tag = dtrwRowTbExportadores.idExportador; lvItemConta.ImageIndex = 0; if ((int)lvItemConta.Tag == m_nIdExportador) { lvItemConta.Selected = true; } } } if (lvContas.Items.Count == 0) { btEditar.Enabled = false; btExcluir.Enabled = false; btNovo.Enabled = true; if (m_bMostrarBaloes) { m_mgblBalaoToolTip = new mdlComponentesGraficos.MessageBalloon(); m_mgblBalaoToolTip.Caption = mdlConstantes.clsConstantes.BALLONTIP_DEFAULT_CAPTION; m_mgblBalaoToolTip.Content = mdlMensagens.clsRepositorioMensagens.GetMensagem(mdlMensagens.Mensagem.BALLOONTIP_mdlContas_clsContas_CriarNovaConta.ToString()); m_mgblBalaoToolTip.Icon = System.Drawing.SystemIcons.Information; m_mgblBalaoToolTip.CloseOnMouseClick = true; m_mgblBalaoToolTip.CloseOnDeactivate = true; m_mgblBalaoToolTip.CloseOnKeyPress = true; m_mgblBalaoToolTip.ShowBalloon((System.Windows.Forms.Control)btNovo); } } else { btEditar.Enabled = true; btExcluir.Enabled = true; btNovo.Enabled = !m_bExportadorPJ; } } catch (Exception err) { Object erro = err; m_cls_ter_tratadorErro.trataErro(ref erro); } }
private void vRefreshProdutos(ref mdlComponentesGraficos.TreeView tvProdutos) { tvProdutos.Nodes.Clear(); System.Collections.ArrayList arlProdutosNaoAssociados = arlProdutosFaturaNaoAssociadosCertificados(); // Classificacao Ordenando string strClassificacao = ""; string strDenominacao = ""; System.Collections.SortedList sortLstClassificacao = new System.Collections.SortedList(); for (int i = 0; i < arlProdutosNaoAssociados.Count; i++) { mdlDataBaseAccess.Tabelas.XsdTbProdutosFaturaComercial.tbProdutosFaturaComercialRow dtrwProdutoFatura = (mdlDataBaseAccess.Tabelas.XsdTbProdutosFaturaComercial.tbProdutosFaturaComercialRow)arlProdutosNaoAssociados[i]; mdlDataBaseAccess.Tabelas.XsdTbProdutos.tbProdutosRow dtrwProduto = m_typDatSetTbProdutos.tbProdutos.FindByidExportadoridProduto(m_nIdExportador, dtrwProdutoFatura.idProduto); if ((dtrwProdutoFatura != null) && (dtrwProdutoFatura.IsnIdOrdemProdutoParentNull() || dtrwProdutoFatura.nIdOrdemProdutoParent == 0) && (dtrwProduto != null)) { switch (m_enumClassificacao) { case Classificacao.Ncm: if (!dtrwProdutoFatura.IsstrNcmNull()) { strClassificacao = dtrwProdutoFatura.strNcm; } else if (!dtrwProduto.IsstrNcmNull()) { strClassificacao = dtrwProduto.strNcm; } else { strClassificacao = ""; } if (!dtrwProdutoFatura.IsmstrNcmDenominacaoNull()) { strDenominacao = dtrwProdutoFatura.mstrNcmDenominacao; } else { mdlDataBaseAccess.Tabelas.XsdTbProdutosNcm.tbProdutosNcmRow dtrwNcm = m_typDatSetTbProdutosNcm.tbProdutosNcm.FindBynIdExportadorstrNcm(m_nIdExportador, strClassificacao); if (dtrwNcm != null) { strDenominacao = dtrwNcm.mstrDenominacao; } else { strDenominacao = ""; } } if (strClassificacao != "") { if (!sortLstClassificacao.ContainsKey(strClassificacao + strDenominacao)) { sortLstClassificacao.Add(strClassificacao + strDenominacao, strClassificacao); } } break; case Classificacao.Naladi: if (!dtrwProdutoFatura.IsstrNaladiNull()) { strClassificacao = dtrwProdutoFatura.strNaladi; } else if (!dtrwProduto.IsstrNaladiNull()) { strClassificacao = dtrwProduto.strNaladi; } else { strClassificacao = ""; } if (!dtrwProdutoFatura.IsmstrNaladiDenominacaoNull()) { strDenominacao = dtrwProdutoFatura.mstrNaladiDenominacao; } else { mdlDataBaseAccess.Tabelas.XsdTbProdutosNaladi.tbProdutosNaladiRow dtrwNaladi = m_typDatSetTbProdutosNaladi.tbProdutosNaladi.FindBynIdExportadorstrNaladi(m_nIdExportador, strClassificacao); if (dtrwNaladi != null) { strDenominacao = dtrwNaladi.mstrDenominacao; } else { strDenominacao = ""; } } if (strClassificacao != "") { if (!sortLstClassificacao.ContainsKey(strClassificacao + strDenominacao)) { sortLstClassificacao.Add(strClassificacao + strDenominacao, strClassificacao); } } break; } } } // Classificacao Inserindo string strClassificacaoProduto, strDenominacaoProduto; for (int i = 0; i < sortLstClassificacao.Count; i++) { string strClassificacaoDenominacao = sortLstClassificacao.GetKey(i).ToString(); strClassificacao = sortLstClassificacao.GetByIndex(i).ToString(); strDenominacao = strClassificacaoDenominacao.Substring(strClassificacao.Length); System.Windows.Forms.TreeNode tvnClassificacao = tvProdutos.Nodes.Add(strClassificacao + " " + strDenominacao); System.Windows.Forms.TreeNode tvnProduto = null; tvnClassificacao.Tag = strClassificacao; // Produtos Inserindo for (int j = 0; j < arlProdutosNaoAssociados.Count; j++) { mdlDataBaseAccess.Tabelas.XsdTbProdutosFaturaComercial.tbProdutosFaturaComercialRow dtrwProdutoFatura = (mdlDataBaseAccess.Tabelas.XsdTbProdutosFaturaComercial.tbProdutosFaturaComercialRow)arlProdutosNaoAssociados[j]; mdlDataBaseAccess.Tabelas.XsdTbProdutos.tbProdutosRow dtrwProduto = m_typDatSetTbProdutos.tbProdutos.FindByidExportadoridProduto(m_nIdExportador, dtrwProdutoFatura.idProduto); if (dtrwProduto != null) { switch (m_enumClassificacao) { case Classificacao.Ncm: if (!dtrwProdutoFatura.IsstrNcmNull()) { strClassificacaoProduto = dtrwProdutoFatura.strNcm; } else if (!dtrwProduto.IsstrNcmNull()) { strClassificacaoProduto = dtrwProduto.strNcm; } else { strClassificacaoProduto = ""; } if (!dtrwProdutoFatura.IsmstrNcmDenominacaoNull()) { strDenominacaoProduto = dtrwProdutoFatura.mstrNcmDenominacao; } else { mdlDataBaseAccess.Tabelas.XsdTbProdutosNcm.tbProdutosNcmRow dtrwNcm = m_typDatSetTbProdutosNcm.tbProdutosNcm.FindBynIdExportadorstrNcm(m_nIdExportador, strClassificacaoProduto); if (dtrwNcm != null) { strDenominacaoProduto = dtrwNcm.mstrDenominacao; } else { strDenominacaoProduto = ""; } } if (strClassificacaoDenominacao == strClassificacaoProduto + strDenominacaoProduto) { tvnProduto = tvnClassificacao.Nodes.Add(dtrwProduto.mstrDescricao); tvnProduto.Tag = dtrwProdutoFatura.idOrdem; } break; case Classificacao.Naladi: if (!dtrwProdutoFatura.IsstrNaladiNull()) { strClassificacaoProduto = dtrwProdutoFatura.strNaladi; } else if (!dtrwProduto.IsstrNaladiNull()) { strClassificacaoProduto = dtrwProduto.strNaladi; } else { strClassificacaoProduto = ""; } if (!dtrwProdutoFatura.IsmstrNaladiDenominacaoNull()) { strDenominacaoProduto = dtrwProdutoFatura.mstrNaladiDenominacao; } else { mdlDataBaseAccess.Tabelas.XsdTbProdutosNaladi.tbProdutosNaladiRow dtrwNaladi = m_typDatSetTbProdutosNaladi.tbProdutosNaladi.FindBynIdExportadorstrNaladi(m_nIdExportador, strClassificacao); if (dtrwNaladi != null) { strDenominacaoProduto = dtrwNaladi.mstrDenominacao; } else { strDenominacaoProduto = ""; } } if (strClassificacaoDenominacao == strClassificacaoProduto + strDenominacaoProduto) { tvnProduto = tvnClassificacao.Nodes.Add(dtrwProduto.mstrDescricao); tvnProduto.Tag = dtrwProdutoFatura.idOrdem; } break; } } } } }
protected void Page_Load(object sender, EventArgs e) { if (!base.IsPostBack) { string personCode = CurrentUserInfo.Personcode; string companyId = CurrentUserInfo.CompanyId; string module_Code = this.Request.QueryString["ModuleCode"].ToString(); ModuleCode.Value = module_Code; dt = hrmDepartmentBll.getOrgTree(personCode, companyId, module_Code); //=================加載樹================= this.UltraWebTreeData.Nodes.Clear(); System.Collections.SortedList allTreeNodes = new System.Collections.SortedList(); Color foreColor; string strDeleted = ""; foreach (System.Data.DataRow row in dt.Rows) { switch (row["levelcode"].ToString()) { case "0": foreColor = Color.Blue; break; case "1": foreColor = Color.Maroon; break; case "2": foreColor = Color.SaddleBrown; break; case "3": foreColor = Color.Red; break; default: foreColor = Color.Black; break; } if (row["Deleted"].ToString() == "Y") { foreColor = Color.DarkGray; strDeleted = "[Disabled]"; } else { strDeleted = ""; } allTreeNodes.Add(System.Convert.ToString(row["depcode"]), base.CreateNode(System.Convert.ToString(row["depcode"]), System.Convert.ToString(row["depname"]) + "[" + System.Convert.ToString(row["depcode"]) + "]" + strDeleted, false, System.Convert.ToDecimal(dt.Compute("count(depcode)", "parentdepcode='" + row["depcode"] + "'")) == 0, foreColor)); if (row["parentdepcode"].ToString().Trim().Length > 0) { if (allTreeNodes.IndexOfKey(row["parentdepcode"]) >= 0) { ((Infragistics.WebUI.UltraWebNavigator.Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["parentdepcode"]))).Nodes.Add((Infragistics.WebUI.UltraWebNavigator.Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["depcode"]))); } else { this.UltraWebTreeData.Nodes.Add((Infragistics.WebUI.UltraWebNavigator.Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(System.Convert.ToString(row["depcode"])))); } } else { this.UltraWebTreeData.Nodes.Add((Infragistics.WebUI.UltraWebNavigator.Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(System.Convert.ToString(row["depcode"])))); } } //=================加載完成================= foreach (Node node in this.UltraWebTreeData.Nodes) { node.Expand(false); } } }
internal void ReadFromDB() { lock ( lockobject ) { //dodatkowe oczekiwanie int timetosleep = Convert.ToInt32(mSym.values[(int)Simulator.signalsIdx.TransmissionDelayInMs] / 2) + (rnd.Next(Convert.ToInt32(mSym.values[(int)Simulator.signalsIdx.TransmissionDelayInMs]))); System.Threading.Thread.Sleep(timetosleep); for (int idx = ((IBlockDescription)this).startAddress; idx < ((IBlockDescription)this).startAddress + ((IBlockDescription)this).length; idx++ ) { long hashindex = HashIndex(((IBlockAddress)this).station, idx, ((IBlockDescription)this).dataType); int curIdx = allCreatedTags.IndexOfKey(hashindex); object currVal = null; if (curIdx < 0) { #region switch(((IBlockDescription)this).dataType) switch ((Medium_T)((IBlockDescription)this).dataType) { case Medium_T.SimulationRegister: if (idx < mSym.values.Length) { currVal = mSym.values[idx]; } else { currVal = (double)0; } break; case Medium_T.SimulationFlags: if (idx < mSym.valuesCMD.Length) { currVal = mSym.valuesCMD[idx]; } else { currVal = false; } break; case Medium_T.Flag: case Medium_T.Input: case Medium_T.Output: { currVal = false; break; } case Medium_T.Counter: case Medium_T.Register: case Medium_T.Timer: { currVal = (int)0; break; } case Medium_T.SByte: currVal = (sbyte)0; break; case Medium_T.Byte: currVal = (byte)0; break; case Medium_T.UShort: currVal = (ushort)0; break; case Medium_T.Int: currVal = (int)0; break; case Medium_T.Uint: currVal = (uint)0; break; case Medium_T.Long: currVal = (long)0; break; case Medium_T.Ulong: currVal = (ulong)0; break; case Medium_T.Float: currVal = (float)0; break; case Medium_T.Double: currVal = (double)0; break; case Medium_T.Decimal: currVal = (decimal)0; break; case Medium_T.Bool: currVal = (bool)false; break; case Medium_T.DateTime: currVal = DateTime.Now; break; case Medium_T.TimeSpan: currVal = TimeSpan.Zero; break; case Medium_T.String: currVal = (string)""; break; case Medium_T.Object: currVal = new object(); break; case Medium_T.ArrayOfDoulbes: currVal = new double[] { (double)0.0, (double)0.0, (double)0.0 }; break; case Medium_T.ArrayOfInts: currVal = new int[] { 0, 0, 0 }; break; case Medium_T.ArrayOfStrings: currVal = new string[] { "", "", "" }; break; } #endregion allCreatedTags.Add(hashindex, currVal); } else { try { switch ((Medium_T)((IBlockDescription)this).dataType) { case Medium_T.SimulationRegister: if (idx < mSym.values.Length) { currVal = mSym.values[idx]; } else { currVal = (double)0; } break; break; case Medium_T.SimulationFlags: if (idx < mSym.valuesCMD.Length) { currVal = mSym.valuesCMD[idx]; } else { currVal = false; } break; break; default: currVal = allCreatedTags.GetByIndex(curIdx); break; } } catch (Exception ex) { throw new Exception("allCreatedTags.GetByIndex( curIdx ):" + ex.Message); } } //tutaj zrobimy podzial na zmienne statyczne i dynamiczne - statyczne beda mialy adresy ponizej 1000 //dynamiczne - adres powyzej 1000 try { if (((IBlockDescription)this).startAddress < 1000) { buffor[idx - ((IBlockDescription)this).startAddress] = currVal; } else { //bedziemy losowac #region switch(((IBlockDescription)this).dataType) switch ((Medium_T)((IBlockDescription)this).dataType) { case Medium_T.Flag: case Medium_T.Input: case Medium_T.Output: { currVal = !(bool)currVal; break; } case Medium_T.Counter: case Medium_T.Register: case Medium_T.Timer: { currVal = (int)rnd.Next(Int16.MaxValue); break; } case Medium_T.SByte: currVal = (sbyte)rnd.Next(SByte.MaxValue); break; case Medium_T.Byte: currVal = (byte)rnd.Next(Byte.MaxValue); break; case Medium_T.UShort: currVal = (ushort)rnd.Next(UInt16.MaxValue); break; case Medium_T.Int: currVal = (int)rnd.Next(Int16.MaxValue); break; case Medium_T.Uint: currVal = (uint)rnd.Next(UInt16.MaxValue); break; case Medium_T.Long: currVal = (long)rnd.Next(Int32.MaxValue); break; case Medium_T.Ulong: currVal = (ulong)rnd.Next(UInt16.MaxValue); break; case Medium_T.Float: currVal = (float)(rnd.NextDouble() * 100.0); break; case Medium_T.Double: currVal = (double)(rnd.NextDouble() * 100.0); break; case Medium_T.Decimal: currVal = (decimal)0; break; case Medium_T.Bool: currVal = (bool)false; break; case Medium_T.DateTime: currVal = new DateTime(rnd.Next(200) + 1900, rnd.Next(11) + 1, rnd.Next(27) + 1, rnd.Next(24), rnd.Next(60), rnd.Next(60)); break; case Medium_T.TimeSpan: currVal = new TimeSpan(rnd.Next(24), rnd.Next(60), rnd.Next(60)); break; case Medium_T.String: currVal = (string)text_array[rnd.Next(text_array.Length)]; break; case Medium_T.Object: currVal = new object(); break; case Medium_T.ArrayOfDoulbes: currVal = new double[rnd.Next(10) + 1]; for (int myidx = 0; myidx < ((double[])currVal).Length; myidx++) { ((double[])currVal)[myidx] = (double)(rnd.NextDouble() * 100.0); } break; case Medium_T.ArrayOfInts: int[] values_ints = new int[rnd.Next(10) + 1]; for (int myidx = 0; myidx < values_ints.Length; myidx++) { values_ints[myidx] = (int)rnd.Next(Int16.MaxValue); } currVal = values_ints; break; case Medium_T.ArrayOfStrings: string[] values_strings = new string[rnd.Next(10) + 1]; for (int myidx = 0; myidx < values_strings.Length; myidx++) { values_strings[myidx] = (string)text_array[rnd.Next(text_array.Length)]; } currVal = values_strings; break; } #endregion buffor[idx - ((IBlockDescription)this).startAddress] = currVal; } } catch (Exception ex) { throw new System.Exception("buffor[ idx - ( (IBlockDescription)this ).startAddress ]:" + ex.Message); } } } }
/// <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]; }
public void SetTime(System.Collections.SortedList timeList) { try { stackPanel_day.Children.Clear(); stackPanel_time.Children.Clear(); if (timeList.Count == 0) { return; } TimePosInfo startPos = timeList.GetByIndex(0) as TimePosInfo; DateTime startTime = startPos.Time; TimePosInfo endPos = timeList.GetByIndex(timeList.Count - 1) as TimePosInfo; DateTime endTime = endPos.Time; DateTime itemTime = new DateTime(startTime.Year, startTime.Month, startTime.Day, 0, 0, 0); while (itemTime < endTime) { Button day = new Button(); if (Settings.Instance.NoStyle == 0) { day.Style = (Style)App.Current.Resources["ButtonStyle1"]; } day.Width = 120; day.Content = itemTime.ToString("M/d(ddd)"); if (itemTime.DayOfWeek == DayOfWeek.Saturday) { day.Foreground = Brushes.Blue; } else if (itemTime.DayOfWeek == DayOfWeek.Sunday) { day.Foreground = Brushes.Red; } day.DataContext = itemTime; day.Click += new RoutedEventHandler(button_time_Click); stackPanel_day.Children.Add(day); Button hour6 = new Button(); if (Settings.Instance.NoStyle == 0) { hour6.Style = (Style)App.Current.Resources["ButtonStyle1"]; } hour6.Width = 40; hour6.Content = itemTime.ToString("6時"); hour6.DataContext = itemTime.AddHours(6); hour6.Click += new RoutedEventHandler(button_time_Click); stackPanel_time.Children.Add(hour6); Button hour12 = new Button(); if (Settings.Instance.NoStyle == 0) { hour12.Style = (Style)App.Current.Resources["ButtonStyle1"]; } hour12.Width = 40; hour12.Content = itemTime.ToString("12時"); hour12.DataContext = itemTime.AddHours(12); hour12.Click += new RoutedEventHandler(button_time_Click); stackPanel_time.Children.Add(hour12); Button hour18 = new Button(); if (Settings.Instance.NoStyle == 0) { hour18.Style = (Style)App.Current.Resources["ButtonStyle1"]; } hour18.Width = 40; hour18.Content = itemTime.ToString("18時"); hour18.DataContext = itemTime.AddHours(18); hour18.Click += new RoutedEventHandler(button_time_Click); stackPanel_time.Children.Add(hour18); itemTime = itemTime.AddDays(1); } } catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); } }