public static SqlCommand DBStoredProcPrepare(SqlConnection sqlConOfSP, string strStoredProcName, string[] strArrParametersNames, object[] objArrParametersValues) { try { SqlCommand sqcmResult = DBCreateSimpleStoredProc(sqlConOfSP, strStoredProcName); sqcmResult.CommandTimeout = sqlConOfSP.ConnectionTimeout; if ((strArrParametersNames != null) && (objArrParametersValues != null)) { int intArrParNamesCount = strArrParametersNames.GetLength(0) - 1; int intParNamesCount = objArrParametersValues.GetLength(0) - 1; EXException.CheckEXError(intArrParNamesCount == intParNamesCount, "Ο αριθμός των παραμέτρων με τον αριθμό των τιμών δεν είναι ίδιος.\n[EX-{74052B8F-FBBD-4e43-B50A-9F9E5DBE9970}]"); for (int intCounter1 = 0; intCounter1 <= intArrParNamesCount; intCounter1++) { sqcmResult.Parameters[strArrParametersNames[intCounter1]].Value = objArrParametersValues[intCounter1]; } } sqcmResult.CommandTimeout = sqlConOfSP.ConnectionTimeout; return(sqcmResult); } catch (Exception exc) { EXException.ThrowEXException(string.Format("Πρόβλημα στην προετοιμασία της Stored Procedure [{0}].", strStoredProcName), exc); return(null); //never gets here } }
public DataSet FindWordsAA(string strQuery) { if (strQuery.Trim() == string.Empty) { return(null); } DataSet dsSplitString = TTextProcess.SplitString(strQuery, TTextProcess.enmsf_StrFilter.sf_CapitalizeSmart | TTextProcess.enmsf_StrFilter.sf_DenyStopWords, TSWDB_Decl.CMAX_WORD_LENGTH); EXException.CheckEXError(dsSplitString != null, "EX-{60B7D234-F4CB-4f5e-B8CF-988023368446}"); if (dsSplitString.Tables[0].Rows.Count <= 0) { return(null); } DataSet dsResult = CreateSWDB_SearchTableWordsSchema(); string strCurrentWord = string.Empty; System.Collections.IEnumerator enumerator = dsSplitString.Tables[0].Rows.GetEnumerator(); while (enumerator.MoveNext()) { strCurrentWord = ((enumerator.Current) as DataRow)[0].ToString(); dsResult.Tables[0].Rows.Add(new object[] { strCurrentWord, FindWordAA(strCurrentWord) }); } return(dsResult); }
public SWPageRankVisitor(SqlConnection dblgLogin, int intInStepUrls, int inIntHowManyLoops, SWRankHandler inRankHandler, float InPagerankDparameter) : base(dblgLogin, intInStepUrls, inIntHowManyLoops) { RankHandler = inRankHandler; UrlInfo = new SWUrlInfoCache(dblgLogin); PageRankDParameter = InPagerankDparameter; //0.85 usually EXException.CheckEXError((PageRankDParameter > 0.0f) && (PageRankDParameter < 1.0f), "Problem with D Parameter in PageRank."); }
public string SQLBasicStm_FindURLSWithWordsAA(string strQuery, int intMAXWordsToSearch, out DataSet dsFindWordsAA) { StringBuilder sbResult = new StringBuilder(string.Empty); dsFindWordsAA = FindWordsAA(strQuery); if (dsFindWordsAA == null) { return(string.Empty); } DataRow[] dtarRows = dsFindWordsAA.Tables[0].Select(CSWDB_Search_WordAA + " > 0"); if (dtarRows.Length <= 0) { return(string.Empty); } //int intCurrentWordAA = 0; int int_dtarRows_Length = dtarRows.Length; EXException.CheckEXError(int_dtarRows_Length <= intMAXWordsToSearch, "Ο αριθμός των λέξεων προς αναζήτηση είναι μεγαλύτερος του επιτρεπόμενου. Παρακαλώ ξαναπροσπαθήστε με λιγότερες λέξεις."); for (int intCurrentWordAA = 1; intCurrentWordAA <= int_dtarRows_Length; intCurrentWordAA++) { if (intCurrentWordAA == 1) { sbResult.Append("SELECT t1.SWUW_CDUR_URLID AS SWUW_CDUR_URLID,"); } sbResult.Append(string.Format("t{0}.SWUW_AppearCount AS SWUW_AppearCount_t{0},", intCurrentWordAA)); } sbResult.Remove(sbResult.Length - 1, 1); int intCurrWordAA = 0; System.Collections.IEnumerator enumerator = dtarRows.GetEnumerator(); while (enumerator.MoveNext()) { intCurrWordAA++; if (intCurrWordAA == 1) { sbResult.Append(" FROM "); } else { sbResult.Append(" INNER JOIN "); } sbResult.Append(string.Format(" ( SELECT SWUW_CDUR_URLID, SWUW_AppearCount FROM SW_UW_UrlLinkWord WITH (nolock) WHERE (SWUW_SWWDAA = {0})) t{1} ", Convert.ToInt32(((enumerator.Current) as DataRow)[1]), intCurrWordAA)); if (intCurrWordAA > 1) { sbResult.Append(string.Format(" ON t{0}.SWUW_CDUR_URLID = t{1}.SWUW_CDUR_URLID ", intCurrWordAA - 1, intCurrWordAA)); } } return(sbResult.ToString().Trim()); }
public int NewUser(string strUser, string strPassword) { sqcm_NewUser.Parameters["@strUser"].Value = strUser.Trim(); sqcm_NewUser.Parameters["@strPassword"].Value = strPassword.Trim(); sqcm_NewUser.Parameters["@intUserID"].Value = 0; sqcm_NewUser.ExecuteNonQuery(); int intResult = Convert.ToInt32(sqcm_NewUser.Parameters["@intUserID"].Value); EXException.CheckEXError(intResult > 0, (intResult == -1?"Ο χρήστης υπάρχει ήδη.":"Άγνωστο πρόβλημα κατα την εισαγωγή του χρήστη.")); return(intResult); }
public int CheckUser(string strUser, string strPassword) { sqcm_CheckUser.Parameters["@strUser"].Value = strUser.Trim(); sqcm_CheckUser.Parameters["@strPassword"].Value = strPassword.Trim(); sqcm_CheckUser.Parameters["@intUserID"].Value = 0; sqcm_CheckUser.ExecuteNonQuery(); int intResult = Convert.ToInt32(sqcm_CheckUser.Parameters["@intUserID"].Value); EXException.CheckEXError(intResult > 0, (intResult == -1?"Δεν βρέθηκε ο χρήστης.":(intResult == -2?"Δεν βρέθηκε το password.":"Άγνωστο πρόβλημα κατα τον έλεγχο του χρήστη."))); return(intResult); }
static public string EncodeToHexStr(string strToHex) { //char[] charrToHex = strToHex.ToCharArray(); if (strToHex == string.Empty) { return(string.Empty); } try { int intNum1 = strToHex.Length; StringBuilder sbResult = new StringBuilder(strToHex + strToHex + strToHex + strToHex); //sbResult.Length=intNum1*4; //sbResult.EnsureCapacity(intNum1*4); intNum1--; for (int intCounter1 = 0; intCounter1 <= intNum1; intCounter1++) { char chStringChar = strToHex[intCounter1]; //byte[] btarrArray = new byte[]; UInt16 uintChar = (UInt16)chStringChar; byte bt1 = 0; byte bt2 = 0; byte bt3 = 0; byte bt4 = 0; TEXCSMath.UInt32ToFourBytes(uintChar, out bt1, out bt2, out bt3, out bt4); string strChar1 = bt1.ToString("X"); string strChar2 = bt2.ToString("X"); string strChar3 = bt3.ToString("X"); string strChar4 = bt4.ToString("X"); sbResult[intCounter1 * 4] = strChar1[0]; sbResult[(intCounter1 * 4) + 1] = strChar2[0]; sbResult[(intCounter1 * 4) + 2] = strChar3[0]; sbResult[(intCounter1 * 4) + 3] = strChar4[0]; //chStringChar. } return(sbResult.ToString()); } catch (Exception exc) { EXException.ThrowEXException("Πρόβλημα στην κωδικοποίηση σε HEX αλφαριθμητικό.", exc); return(string.Empty); } }
static public decimal XRPriceMinimumStep(decimal dcmXAATickerValue) { if ((dcmXAATickerValue >= 0m) && (dcmXAATickerValue < 3m)) { return(0.01m); } if ((dcmXAATickerValue >= 3m) && (dcmXAATickerValue < 60m)) { return(0.02m); } if ((dcmXAATickerValue > 60m) && (dcmXAATickerValue < 3m)) { return(0.05m); } EXException.ThrowEXException(string.Format("Δεν βρέθηκε σωστό βήμα για την τιμή {0}.", dcmXAATickerValue)); return(0m); }
public static SqlCommand DBStoredProcExecNonQuery(SqlConnection sqlConOfSP, string strStoredProcName, string[] strArrParametersNames, object[] objArrParametersValues) { try { SqlCommand sqcmResult = DBStoredProcPrepare(sqlConOfSP, strStoredProcName, strArrParametersNames, objArrParametersValues); sqcmResult.CommandTimeout = sqlConOfSP.ConnectionTimeout; sqcmResult.ExecuteNonQuery(); return(sqcmResult); } catch (Exception exc) { EXException.ThrowEXException(string.Format("Πρόβλημα στην κλήση της Stored Procedure [{0}].", strStoredProcName), exc); return(null); //never gets here } }
public static SqlCommand DBCreateSimpleStoredProc(SqlConnection sqlConOfSP, string strStoredProcName) { try { SqlCommand sqcmResult = sqlConOfSP.CreateCommand(); sqcmResult.CommandType = CommandType.StoredProcedure; sqcmResult.CommandText = strStoredProcName; //"dbo.sp_SW_CheckUser"; System.Data.SqlClient.SqlCommandBuilder.DeriveParameters(sqcmResult); sqcmResult.CommandTimeout = sqlConOfSP.ConnectionTimeout; return(sqcmResult); } catch (Exception exc) { EXException.ThrowEXException(string.Format("Πρόβλημα στην δημιουργία της Stored Procedure [{0}].", strStoredProcName), exc); return(null); //never gets here } }
static public string DecodeHexStrToStr(string strHex) { if (strHex == string.Empty) { return(string.Empty); } try { int intNum1 = strHex.Length; EXException.CheckEXError((intNum1 % 4) == 0, "EX {30CF8C85-C636-4f3e-B97E-3D3E02B433FE}"); StringBuilder sbResult = new StringBuilder(new string(' ', intNum1 / 4)); //sbResult.Length=intNum1*4; //sbResult.EnsureCapacity(intNum1*4); intNum1--; for (int intCounter1 = 0; intCounter1 <= intNum1; intCounter1 = intCounter1 + 4) { string chStringChar1 = new string(strHex[intCounter1], 1); string chStringChar2 = new string(strHex[intCounter1 + 1], 1); string chStringChar3 = new string(strHex[intCounter1 + 2], 1); string chStringChar4 = new string(strHex[intCounter1 + 3], 1); //byte[] btarrArray = new byte[]; byte bt1 = Convert.ToByte(chStringChar1, 16); byte bt2 = Convert.ToByte(chStringChar2, 16); byte bt3 = Convert.ToByte(chStringChar3, 16); byte bt4 = Convert.ToByte(chStringChar4, 16); UInt32 uintChar = 0; TEXCSMath.FourBytesToUInt32(bt1, bt2, bt3, bt4, out uintChar); sbResult[intCounter1 / 4] = (char)uintChar; //chStringChar. } return(sbResult.ToString()); } catch (Exception exc) { EXException.ThrowEXException("Πρόβλημα στην αποκωδικοποίηση του HEX αλφαριθμητικού.", exc); return(string.Empty); } }
public SqlConnection GetOrCreateConnection(enmdb_EXDBApplUser theDB) { try { int intDBIndex = (int)theDB; if (sqcnArr[intDBIndex] == null) { sqcnArr[intDBIndex] = new SqlConnection(DBGetConnectionStr(theDB)); sqcnArr[intDBIndex].Open(); } return(sqcnArr[intDBIndex]); } catch (Exception exc) { EXException.ThrowEXException("Πρόβλημα στην δημιουργία σύνδεσης με την Βάση Δεδομένων.\n[EX-{FD48C6FC-5193-4392-9560-08D9FB7760F6}]", exc); return(null); //never gets here } }
static public decimal XRRoundXAA(decimal dcmXAATickerValue) { decimal dcmResult = decimal.Round(dcmXAATickerValue, 2); if ((dcmResult >= 0m) && (dcmResult < 3m)) { return(XRRoundBasedOnTickSize(dcmResult, 0.01m, 2)); } if ((dcmResult >= 3m) && (dcmResult < 60m)) { return(XRRoundBasedOnTickSize(dcmResult, 0.02m, 2)); } if (dcmResult > 60m) { return(XRRoundBasedOnTickSize(dcmResult, 0.05m, 2)); } EXException.ThrowEXException(string.Format("Δεν βρέθηκε σωστό βήμα για την τιμή {0}.", dcmXAATickerValue)); return(0m); }
static public SortedList InsertFromStrArray(string[] strarrInputArray, bool blnIgnoreOnDuplicate) { SortedList slResult = new SortedList(); int intStrArrLength = strarrInputArray.Length - 1; for (int intCounter1 = 0; intCounter1 <= intStrArrLength; intCounter1++) { try { slResult.Add(strarrInputArray[intCounter1], null); } catch (Exception exc) { if (!blnIgnoreOnDuplicate) { EXException.ThrowEXException("Διπλό λεκτικό σε πίνακα. EX-{F79B34BB-DC2A-4844-B6ED-8FDBEBE72F6D}", exc); } } } return(slResult); }
public int FindWordAA(string strWord) //returns -1 if not found { const int _C_RESULT_ERROR = -1; try { if (strWord == string.Empty) { return(_C_RESULT_ERROR); } sqcm_FindWordAA.Parameters["@strWord"].Value = strWord; sqcm_FindWordAA.Parameters["@intWordAA"].Value = 0; sqcm_FindWordAA.ExecuteNonQuery(); return(Convert.ToInt32(sqcm_FindWordAA.Parameters["@intWordAA"].Value)); } catch (Exception exc) { EXException.ThrowEXException("Πρόβλημα στην ανεύρεση της λέξης [" + strWord + "]. EX-{920BD494-F896-485d-8C31-5A3D3DA3BB83}", exc); return(_C_RESULT_ERROR); } }
//private System.Data.SqlClient.SqlCommand SQLCmd_SelectURLsToWordProc; //private System.Data.SqlClient.SqlCommand SQLCmd_GetURLData; private void WordProcSingleURL(int intURLID) { using (SqlCommand sqcm_UrlHasProcessedWords = SQLConSW.CreateCommand()) { //sqcm_UrlHasProcessedWords.Transaction = myWordInsTransaction; sqcm_UrlHasProcessedWords.CommandText = "exec dbo.sp_SW_UrlHasProcessedWords " + intURLID.ToString(); sqcm_UrlHasProcessedWords.ExecuteNonQuery(); } string strURLData = string.Empty; //const string CLocalTransName = "Trans_WordProcSingleURL"; SqlDataAdapter daGETUrlData = new SqlDataAdapter("EXEC dbo.sp_SW_GetURLData " + intURLID.ToString(), SQLConSW.ConnectionString); DataSet dsGetURLData = new DataSet(); daGETUrlData.Fill(dsGetURLData); strURLData = dsGetURLData.Tables[0].Rows[0][0].ToString().Trim(); strURLData = TEXStrUtl.StripTagsFromHTML(strURLData).Trim(); if (strURLData == string.Empty) { return; } if (TimeAllowsToReport()) { Report(string.Format("Δεδομένα του URL [{0}:\r\n [{1}]", intURLID, strURLData)); } SqlCommand sqcm_ConnectWord = SQLConSW.CreateCommand(); sqcm_ConnectWord.CommandType = CommandType.StoredProcedure; sqcm_ConnectWord.CommandText = "dbo.sp_SW_ConnectWord"; System.Data.SqlClient.SqlCommandBuilder.DeriveParameters(sqcm_ConnectWord); //using (SqlTransaction myWordInsTransaction = SQLConSW.BeginTransaction(IsolationLevel.ReadCommitted,CLocalTransName )) //{ try { DataSet dsSplitString = TTextProcess.SplitString(strURLData, TTextProcess.enmsf_StrFilter.sf_CapitalizeSmart | TTextProcess.enmsf_StrFilter.sf_DenyStopWords, TSWDB_Decl.CMAX_WORD_LENGTH); EXException.CheckEXError(dsSplitString != null, "EX-{A3270330-505B-4eb5-98E2-313AA1879AE6}"); EXException.CheckEXError(dsSplitString.Tables[0].Rows.Count > 0, "Δεν βρέθηκαν λέξεις. EX-{E06D3CB0-B22F-49e2-87E9-D373704AB80A}"); using (SqlCommand sqcm_UnconnectURLFromUrlLinkWord = SQLConSW.CreateCommand()) { //sqcm_UnconnectURLFromUrlLinkWord.Transaction = myWordInsTransaction; sqcm_UnconnectURLFromUrlLinkWord.CommandText = "exec dbo.sp_SW_UnconnectURLFromUrlLinkWord " + intURLID.ToString(); sqcm_UnconnectURLFromUrlLinkWord.ExecuteNonQuery(); } //sqcm_ConnectWord.Transaction = myWordInsTransaction; System.Collections.IEnumerator enumerator = dsSplitString.Tables[0].Rows.GetEnumerator(); while (enumerator.MoveNext()) { if (CancelProcess) { throw new EXUserBreak(); } sqcm_ConnectWord.Parameters["@intURLID"].Value = intURLID; sqcm_ConnectWord.Parameters["@strWord"].Value = ((enumerator.Current) as DataRow)[TTextProcess.CTPSplitField_Word].ToString(); sqcm_ConnectWord.Parameters["@intAppearCount"].Value = Convert.ToInt32(((enumerator.Current) as DataRow)[TTextProcess.CTPSplitField_CountWord]); if (TimeAllowsToReport()) { Report(string.Format("Σύνδεση του URL:[{0}] με την λέξη:[{1}] και με συχνότητα εμφάνισης:[{2}].", intURLID, ((enumerator.Current) as DataRow)[TTextProcess.CTPSplitField_Word].ToString(), Convert.ToInt32(((enumerator.Current) as DataRow)[TTextProcess.CTPSplitField_CountWord]) )); } sqcm_ConnectWord.ExecuteNonQuery(); } //myWordInsTransaction.Commit(); } catch (Exception exc) { //myWordInsTransaction.Rollback(CLocalTransName); EXException.ThrowEXException("Πρόβλημα κατά την αποκωδικοπόιηση του URL: " + intURLID.ToString(), exc); } //} }