public void UpsertSpinLog(SpinLog spinLog)
 {
     using (kryptonitegamingEntities db = new kryptonitegamingEntities())
     {
         db.SpinLogs.AddOrUpdate(spinLog);
         db.SaveChanges();
     }
 }
Exemplo n.º 2
0
            /// <summary>
            /// Method who writes the txt errors file
            /// </summary>
            internal void SaveMsgErrors(Exception ex)
            {
                string clientIP;

                TargetSite = ex.TargetSite.ToString();
                try
                {
                    clientIP = CallContext.GetData("ClientIPAddress").ToString();
                }
                catch (Exception)
                {
                    clientIP = "localhost";
                }


                if (typeof(SpinException).Equals(ex.GetType()))
                {
                    ErrorMsg = "Client: " + clientIP + " \n" + "Error Message: " + ((SpinException)ex).ErrorMsg + "\n";
                }

                else
                {
                    ErrorMsg = "Client: " + clientIP + "\n" + "Error Message: " + ex.Message + "\n";
                }

                //Write to error file
                try
                {
                    dynamic datos = new ExpandoObject();

                    datos.GetAllMessages  = true;
                    datos.GetLastMessage  = false;
                    datos.LogElementLevel = 0;
                    datos.Message         = new List <string>();

                    SpinLog log = new SpinLog();
                    log.Init(datos);
                    datos.LogElementLevel = 4;
                    datos.Message.Add(DateTime.Now.ToString());
                    datos.Message.Add(this.ErrorMsg.ToString());
                    log.SetData(datos);
                }
                catch (Exception e)
                {
                    System.Console.WriteLine(e.Message);
                }
            }
Exemplo n.º 3
0
        public void ProcessRequest(HttpContext context)
        {
            System.Collections.Specialized.NameValueCollection arrQueryString = context.Request.QueryString;

            String  strMethod  = "";
            String  strReturn  = "";
            Boolean blnHandled = false;

            if (arrQueryString["method"] != null)
            {
                strMethod = arrQueryString["method"].ToString().ToLower();
            }


            if (context.Session != null)
            {
            }

            try
            {
                if (strMethod == "getnextspin")
                {
                    SpinManager SM    = new SpinManager();
                    Batch       batch = SM.GetNextSpin();

                    strReturn = Newtonsoft.Json.JsonConvert.SerializeObject(batch);
                }
                else if (strMethod == "getaccount")
                {
                    String         strID   = arrQueryString["id"].ToString();
                    AccountManager AM      = new AccountManager();
                    Account        account = AM.GetAccount(strID);

                    strReturn = Newtonsoft.Json.JsonConvert.SerializeObject(account);
                }
                else if (strMethod == "updateaccount")
                {
                    String strID     = arrQueryString["accountid"].ToString();
                    String strAmount = arrQueryString["amount"].ToString();

                    AccountManager AM = new AccountManager();
                    AM.UpdateAccountCredits(strID, Convert.ToDecimal(strAmount));
                }
                else if (strMethod == "updatespinlog")
                {
                    String strID     = arrQueryString["accountid"].ToString();
                    String strStatus = arrQueryString["status"].ToString();
                    String strSpinID = arrQueryString["spinid"].ToString();

                    SpinLogManager SLM = new SpinLogManager();

                    SpinLog spinLog = new SpinLog();

                    spinLog.AccountId  = Convert.ToInt32(strID);
                    spinLog.Status     = strStatus;
                    spinLog.CreateDate = DateTime.Now;
                    spinLog.SpinId     = Convert.ToInt32(strSpinID);

                    SLM.UpsertSpinLog(spinLog);

                    if (strStatus == "Accepted")
                    {
                        SpinManager SM = new SpinManager();
                        SM.AcceptSpin(Convert.ToInt32(strSpinID));
                    }
                }
                else
                {
                    strReturn = "Unknown method '" + strMethod + "'.";
                }



                if (!blnHandled)
                {
                    context.Response.Write(strReturn);
                }
            }
            catch (Exception ex)
            {
                context.Response.Write(ex.Message);
            }
        }