Пример #1
0
    internal static bool blnGenerateimintSettlementFile(out long lngimintUpdateStamp)
    {
        const string udcErrorMethod = "blnGenerateimintSettlementFile";

        string       udcMerchantId = clsSettings.Get("IMINT", "MerchantId", "90009796");
        string       udcTerminalId = clsSettings.Get("IMINT", "TerminalId", "64211677");
        const string udcActionCode = "EARN";
        //const string udcClassificationCode = "CASH_CASH";
        const string udcPaymentType    = "CASH";
        const string udcUnits          = "AMOUNT";
        const string udcHasSKUActivity = "0";

        lngimintUpdateStamp = 0;

        try
        {
            if (System.IO.Directory.Exists(strFolder) == false)
            {
                System.IO.Directory.CreateDirectory(strFolder);
            }
        }
        catch (Exception ex)
        {
            clsLog.blnLogError(udcErrorSource, udcErrorMethod, "Error creating imint Directory : " + strFolder, ex.ToString());
            return(false);
        }

        string       strFileName = "", strSettlementDate = "";
        ArrayList    arlSettlement = new ArrayList();
        ArrayList    arlPaymentId  = new ArrayList();
        clsDBEngine  objDB         = new clsDBEngine();
        StreamWriter stwSettlement;

        System.Text.StringBuilder sbrData;
        string strSQL = "EXECUTE spGetDataForIMINT";

        if (objDB.blnOpenResultSet(strSQL) == true)
        {
            if (objDB.blnHasRecords == true)
            {
                strSettlementDate = DateTime.Now.ToString("ddMMyyyy");
            }

            while (objDB.blnResultsMoveNextRow() == true)
            {
                if (objDB.objResultsValue("Trans_MemberType").ToString() == "IMINT")
                {
                    sbrData = new System.Text.StringBuilder();
                    sbrData.Append(objDB.objResultsValue("Trans_MemberNo").ToString() + "|");
                    sbrData.Append("|||");
                    sbrData.Append(udcMerchantId + "|");
                    sbrData.Append("|");
                    sbrData.Append(udcTerminalId + "|");
                    sbrData.Append("|");
                    sbrData.Append((objDB.objResultsValue("Trans_lngId").ToString() + "|"));
                    sbrData.Append("||");
                    sbrData.Append(udcActionCode + "|");
                    //sbrData.Append(udcClassificationCode + "|");
                    sbrData.Append(objDB.objResultsValue("Trans_strIMINTEventType").ToString() + "|");
                    sbrData.Append("||");
                    sbrData.Append(udcPaymentType + "|");
                    sbrData.Append(objDB.objResultsValue("Trans_strDate").ToString() + "|");
                    sbrData.Append("|");
                    sbrData.Append(float.Parse(objDB.objResultsValue("Trans_mnyTotal").ToString()).ToString("#") + "|");
                    sbrData.Append(udcUnits + "|");
                    sbrData.Append("||");
                    sbrData.Append(udcHasSKUActivity + "|");
                    sbrData.Append(strSettlementDate + "|");
                    sbrData.Append((objDB.objResultsValue("Trans_lngId").ToString() + "|"));
                    sbrData.Append("|||");
                    sbrData.Append((objDB.objResultsValue("Trans_lngId").ToString() + "|"));
                    sbrData.Append("||||||||");
                    arlSettlement.Add(sbrData);
                }

                else if (objDB.objResultsValue("Trans_MemberType").ToString() == "PB_SAM")
                {
                    //Add Payback Samsung Base points

                    sbrData = new System.Text.StringBuilder();
                    sbrData.Append(objDB.objResultsValue("Trans_MemberNo").ToString() + "|");
                    sbrData.Append("|||");
                    sbrData.Append(udcMerchantId + "|");
                    sbrData.Append("|");
                    sbrData.Append(udcTerminalId + "|");
                    sbrData.Append("|");
                    sbrData.Append((objDB.objResultsValue("Trans_lngId").ToString() + "|"));
                    sbrData.Append("||");
                    sbrData.Append(udcActionCode + "|");
                    sbrData.Append(objDB.objResultsValue("Trans_strIMINTEventType").ToString() + "|");
                    sbrData.Append("||");
                    sbrData.Append(udcPaymentType + "|");
                    sbrData.Append(objDB.objResultsValue("Trans_strDate").ToString() + "|");
                    sbrData.Append("|");
                    sbrData.Append(float.Parse(objDB.objResultsValue("Trans_mnyTotal").ToString()).ToString("#") + "|");
                    sbrData.Append(udcUnits + "|");
                    sbrData.Append("||");
                    sbrData.Append(udcHasSKUActivity + "|");
                    sbrData.Append(strSettlementDate + "|");
                    sbrData.Append((objDB.objResultsValue("Trans_lngId").ToString() + "_Samsung_base_point|"));
                    sbrData.Append("|||");
                    sbrData.Append((objDB.objResultsValue("Trans_lngId").ToString() + "|"));
                    sbrData.Append("||||||||");
                    arlSettlement.Add(sbrData);


                    //Add Payback Samsung 2X points

                    sbrData = new System.Text.StringBuilder();
                    sbrData.Append(objDB.objResultsValue("Trans_MemberNo").ToString() + "|");
                    sbrData.Append("|||");
                    sbrData.Append(udcMerchantId + "|");
                    sbrData.Append("|");
                    sbrData.Append(udcTerminalId + "|");
                    sbrData.Append("|");
                    sbrData.Append((objDB.objResultsValue("Trans_lngId").ToString() + "|"));
                    sbrData.Append("||");
                    sbrData.Append(udcActionCode + "|");
                    //sbrData.Append(udcClassificationCode + "|");
                    sbrData.Append("BONUS_POINTS|");

                    sbrData.Append("||");
                    sbrData.Append(udcPaymentType + "|");
                    sbrData.Append(objDB.objResultsValue("Trans_strDate").ToString() + "|");
                    sbrData.Append("|");
                    sbrData.Append(float.Parse(objDB.objResultsValue("Trans_mnyTotal").ToString()).ToString("#") + "|");
                    sbrData.Append(udcUnits + "|");
                    sbrData.Append("||");
                    sbrData.Append(udcHasSKUActivity + "|");
                    sbrData.Append(strSettlementDate + "|");

                    sbrData.Append((objDB.objResultsValue("Trans_lngId").ToString() + "_Samsung_bonus_point|"));
                    sbrData.Append("|||");
                    sbrData.Append((objDB.objResultsValue("Trans_lngId").ToString() + "|"));
                    sbrData.Append("||||||||");
                    arlSettlement.Add(sbrData);
                }
            }

            objDB.blnMoveNextResultSet();

            objDB.blnResultsMoveNextRow();

            lngimintUpdateStamp = long.Parse(objDB.objResultsValue("Trans_intUpdateStamp").ToString());

            if (strSettlementDate.Length > 0)
            {
                strFileName = strFolder + "ACTIVITY_IMINT_BIGTREE_" + strSettlementDate + ".txt";
            }
        }
        else
        {
            objDB.blnCloseConnection();
            clsLog.blnLogError(udcErrorSource, udcErrorMethod, "Error fetching imint Settlement Data from DB", objDB.strErrorMessage);
            return(false);
        }

        objDB.blnCloseConnection();

        if (strFileName.Length > 0)
        {
            try
            {
                stwSettlement = new StreamWriter(strFileName, false);

                for (int intCount = 0; intCount < arlSettlement.Count; intCount++)
                {
                    stwSettlement.WriteLine(arlSettlement[intCount].ToString());
                }
                stwSettlement.Close();
                stwSettlement = null;
            }
            catch (Exception ex)
            {
                stwSettlement = null;
                clsLog.blnLogError(udcErrorSource, udcErrorMethod, "Error creating imint Settlement File", ex.ToString());
                return(false);
            }
        }

        return(true);
    }
Пример #2
0
        /// <summary>
        ///  Execute the sp and return collection of array the contain companies, cinemas, events and session data for given User
        /// </summary>
        /// <param name="strUserLogin"></param>
        /// <returns></returns>
        public static string strGetData(string strUserLogin)
        {
            clsDBEngine objDB = new clsDBEngine();
            string      strSQL = "EXEC spForUserData @strUserLogin = '******'";
            string      strLine = "", strReturnData = "";
            int         intLineCount = 0;
            string      strArrayName = "arrcompanies";

            strLine        = "<script type='text/javascript' language='javascript'>";
            strLine       += "var " + strArrayName + " = new Array();\n";
            strReturnData += strLine;

            if (objDB.blnOpenResultSet(strSQL) == true)
            {
                while (objDB.blnResultsMoveNextRow() == true)
                {
                    strLine = "";
                    for (int intCount = 0; intCount < objDB.lngResultsNumCols; intCount++)
                    {
                        if (strLine.Length > 0)
                        {
                            strLine += ", ";
                        }
                        string strValue = strConvertForJavaScript(objDB.objResultsValue(intCount).ToString());
                        strLine += "'" + strValue + "'";
                    }
                    if (objDB.lngResultsNumCols > 1)
                    {
                        strLine = strArrayName + "[" + intLineCount + "] = new Array(" + strLine + ");\n";
                    }
                    else
                    {
                        strLine = strArrayName + "[" + intLineCount + "] = " + strLine + ";\n";
                    }
                    strReturnData += strLine;
                    intLineCount++;
                }
            }
            //For Cinema
            if (objDB.blnMoveNextResultSet())
            {
                intLineCount = 0;
                string arrCinema = "arrCinemas";
                strReturnData += "var " + arrCinema + " = new Array();\n";
                while (objDB.blnResultsMoveNextRow() == true)
                {
                    strLine = "";
                    for (int intCount = 0; intCount < objDB.lngResultsNumCols; intCount++)
                    {
                        if (strLine.Length > 0)
                        {
                            strLine += ", ";
                        }
                        string strValue = strConvertForJavaScript(objDB.objResultsValue(intCount).ToString());
                        strLine += "'" + strValue + "'";
                    }
                    if (objDB.lngResultsNumCols > 1)
                    {
                        strLine = arrCinema + "[" + intLineCount + "] = new Array(" + strLine + ");\n";
                    }
                    else
                    {
                        strLine = arrCinema + "[" + intLineCount + "] = " + strLine + ";\n";
                    }
                    strReturnData += strLine;
                    intLineCount++;
                }
            }
            if (objDB.blnMoveNextResultSet())
            {
                intLineCount = 0;
                string arrEvents = "arrEvents";
                strReturnData += "var " + arrEvents + " = new Array();\n";
                while (objDB.blnResultsMoveNextRow() == true)
                {
                    strLine = "";
                    for (int intCount = 0; intCount < objDB.lngResultsNumCols; intCount++)
                    {
                        if (strLine.Length > 0)
                        {
                            strLine += ", ";
                        }
                        string strValue = strConvertForJavaScript(objDB.objResultsValue(intCount).ToString());
                        strLine += "'" + strValue + "'";
                    }
                    if (objDB.lngResultsNumCols > 1)
                    {
                        strLine = arrEvents + "[" + intLineCount + "] = new Array(" + strLine + ");\n";
                    }
                    else
                    {
                        strLine = arrEvents + "[" + intLineCount + "] = " + strLine + ";\n";
                    }
                    strReturnData += strLine;
                    intLineCount++;
                }
            }
            if (objDB.blnMoveNextResultSet())
            {
                intLineCount = 0;
                string arrSession = "arrSessions";
                strReturnData += "var " + arrSession + " = new Array();\n";
                while (objDB.blnResultsMoveNextRow() == true)
                {
                    strLine = "";
                    for (int intCount = 0; intCount < objDB.lngResultsNumCols; intCount++)
                    {
                        if (strLine.Length > 0)
                        {
                            strLine += ", ";
                        }
                        string strValue = strConvertForJavaScript(objDB.objResultsValue(intCount).ToString());
                        strLine += "'" + strValue + "'";
                    }
                    if (objDB.lngResultsNumCols > 1)
                    {
                        strLine = arrSession + "[" + intLineCount + "] = new Array(" + strLine + ");\n";
                    }
                    else
                    {
                        strLine = arrSession + "[" + intLineCount + "] = " + strLine + ";\n";
                    }
                    strReturnData += strLine;
                    intLineCount++;
                }
            }
            else
            {
                clsLog.blnLogError("clsMisc", "strGetData()", "SQL Failed : " + strSQL, objDB.strErrorMessage);
            }
            strReturnData += "</script>";
            objDB.blnCloseConnection();
            return(strReturnData);
        }