示例#1
0
 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
     }
 }
示例#2
0
        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);
            }
        }
示例#3
0
 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);
 }
示例#4
0
 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
     }
 }
示例#5
0
 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
     }
 }
示例#6
0
        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);
            }
        }
示例#7
0
 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
     }
 }
示例#8
0
        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);
        }
示例#9
0
        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);
        }
示例#10
0
        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);
            }
        }
示例#11
0
        //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);
            }

            //}
        }