Example #1
0
 public void TimerSwitch(bool value)
 {
     if (this.InvokeRequired)
     {
         SwitchHandler h = new SwitchHandler(TimerSwitch);
         this.Invoke(h, new object[] { value });
     }
     else
     {
         if (value)
         {
             if (autoSyncCheckBox.Checked)
             {
                 autoSyncInterval.Enabled = autoSyncCheckBox.Checked;
                 syncTimer.Enabled        = autoSyncCheckBox.Checked;
                 nextSyncLabel.Visible    = autoSyncCheckBox.Checked;
             }
         }
         else
         {
             autoSyncInterval.Enabled = value;
             syncTimer.Enabled        = value;
             nextSyncLabel.Visible    = value;
         }
     }
 }
Example #2
0
 public void SetFormEnabled(bool enabled)
 {
     if (this.InvokeRequired)
     {
         SwitchHandler h = new SwitchHandler(SetFormEnabled);
         this.Invoke(h, new object[] { enabled });
     }
     else
     {
         Enabled = enabled;
     }
 }
Example #3
0
        public static async Task ProcessTransactions(List <Transaction> transactionList)
        {
            //Push transactions to payment switch
            SwitchHandler switchHandler = new SwitchHandler("http://172.18.12.224");
            List <TransactionProcessResult> processResults = await switchHandler.ProcessTransaction(transactionList);

            foreach (TransactionProcessResult processResult in processResults)
            {
                if (processResult.Code == StatusCode.Success)
                {
                    foreach (Transaction crud in transactionList)
                    {
                        if (crud.Id == processResult.TransactionId)
                        {
                            crud.Status = Status.Success;
                            crud.InsertDocument("FlourishDB_ARC");
                            crud.Delete();
                        }
                    }
                }
            }
            new DesktopNotification()
            {
                Message = string.Format("Successful Payments: {0} <br/><br/> Failed Payments: <br/> Network Related: {1} <br/> Other: {2}", processResults.Count(x => x.Code == StatusCode.Success), processResults.Count(x => x.Code == StatusCode.Network), processResults.Count(x => x.Code == StatusCode.Other)), Company = transactionList.First().Company, LoginDetails = new LoginDetails()
                {
                    Role = new Role(), Company = new Company()
                }
            }.InsertDocument();

            MailMessage mailMessage = new MailMessage
            {
                Subject = string.Format("Payment Overview for {0}", DateTime.Now.Date),
                Body    = string.Format("Successful Payments: {0} <br/><br/> Failed Payments: <br/> Network Related: {1} <br/> Other: {2}", processResults.Count(x => x.Code == StatusCode.Success), processResults.Count(x => x.Code == StatusCode.Network), processResults.Count(x => x.Code == StatusCode.Other)),
                To      = { new MailAddress("*****@*****.**", "Kieren Gerling") }
            };

            EmailHandler.SendMail(mailMessage);
        }
 ASwitch GetNativeSwitch(SwitchHandler switchHandler) =>
 (ASwitch)switchHandler.View;
Example #5
0
 public DeviceSwitch(bool isPulseSwitch, IGamelogicEngineWithSwitches engine, Player player)
 {
     _isPulseSwitch = isPulseSwitch;
     _switchHandler = new SwitchHandler(player, engine);
 }
Example #6
0
 bool GetNativeIsChecked(SwitchHandler switchHandler) =>
 GetNativeSwitch(switchHandler).On;
Example #7
0
        private void ProcessRequest()
        {
            try
            {
                Response.Clear();

                Response.Headers.Add("Arr-Disable-Session-Affinity", "True");

                // Load all parameter keys to ignore.
                string[] ignoreParams = File.ReadAllText(Path.Combine(
                                                             Request.PhysicalApplicationPath,
                                                             "App_Data",
                                                             "IgnoreParams.txt"
                                                             )).Split(',');

                string parameters = "";

                // Run through all request parameters.
                foreach (string key in Request.Params.AllKeys)
                {
                    if (key == null)
                    {
                        continue;
                    }

                    if (key.StartsWith("404"))
                    {
                        continue;
                    }

                    if (ignoreParams.Contains(key))
                    {
                        continue;
                    }

                    //if (Request.HttpMethod != "GET")
                    parameters += key + "=" + HttpUtility.UrlEncode(Request.Params[key]) + "&";

                    /*else
                     *  parameters += key + "=" + (Request.Params[key]) + "&";*/
                }

                string url;

                if (Request.Params.ToString().Split('&')[0].StartsWith("404"))
                {
                    url = ConfigurationManager.AppSettings["Protocol"] + "://" + "216.176.177.26" +
                          new Uri(HttpUtility.UrlDecode(Request.Params.ToString().Split('&')[0]).Split(';')[1]).PathAndQuery;
                }
                else
                {
                    url = ConfigurationManager.AppSettings["Protocol"] + "://" + "216.176.177.26" + Request.Params["Path_Info"];
                }

                if (parameters.Length > 0)
                {
                    parameters = parameters.Remove(parameters.Length - 1, 1);
                }

                SwitchHandler switchHandler = new SwitchHandler();

                if (switchHandler.Switch(
                        "216.176.177.26",
                        url,
                        parameters
                        ) == false)
                {
                    ServerCollection servers = new ServerCollection(Path.Combine(
                                                                        Request.PhysicalApplicationPath,
                                                                        "App_Data",
                                                                        "Servers.xml"
                                                                        ));
                }

                /*if (Response.Cookies["ASP.NET_SessionId"] == null)
                 * {
                 *  HttpCookie cookie = new HttpCookie("ASP.NET_SessionId", Request.Cookies["ASP.NET_SessionId"].Value);
                 *  cookie.Domain = Request.Url.Host;
                 *  cookie.Path = "/";
                 *
                 *  Response.Cookies.Add(cookie);
                 * }
                 * else if (Response.Cookies["ASP.NET_SessionId"].Value == "")
                 * {
                 *  Response.Cookies["ASP.NET_SessionId"].Value = Request.Cookies["ASP.NET_SessionId"].Value;
                 * }*/
            }
            catch (Exception ex)
            {
                File.WriteAllText(Path.Combine(
                                      Request.PhysicalApplicationPath,
                                      "Log.txt"
                                      ), ex.ToString());
            }
        }
Example #8
0
 ASwitch GetNativeSwitch(SwitchHandler switchHandler) =>
 (ASwitch)switchHandler.PlatformView;
Example #9
0
 private static void ChangeState(SwitchHandler switchHandler, EventArgs e)
 {
     beerTree.SetNodeState(switchHandler.name, switchHandler.currentIndex);
 }
Example #10
0
 public void IconTimerSwitch(bool value)
 {
     if (this.InvokeRequired)
     {
         SwitchHandler h = new SwitchHandler(IconTimerSwitch);
         this.Invoke(h, new object[] { value });
     }
     else
     {
         if (value) //Reset Icon to default icon as starting point for the syncing icon
             notifyIcon.Icon = this.Icon0;
         iconTimer.Enabled = value;
     }
 }
Example #11
0
 public void SetFormEnabled(bool enabled)
 {
     if (this.InvokeRequired)
     {
         SwitchHandler h = new SwitchHandler(SetFormEnabled);
         this.Invoke(h, new object[] { enabled });
     }
     else
         Enabled = enabled;
 }
Example #12
0
        public void TimerSwitch(bool value)
        {
            if (this.InvokeRequired)
            {
                SwitchHandler h = new SwitchHandler(TimerSwitch);
                this.Invoke(h, new object[] { value });
            }
            else
            {

                if (value)
                {
                    if (autoSyncCheckBox.Checked)
                    {
                        autoSyncInterval.Enabled = autoSyncCheckBox.Checked;
                        syncTimer.Enabled = autoSyncCheckBox.Checked;
                        nextSyncLabel.Visible = autoSyncCheckBox.Checked;
                    }
                }
                else
                {
                    autoSyncInterval.Enabled = value;
                    syncTimer.Enabled = value;
                    nextSyncLabel.Visible = value;
                }
            }
        }
Example #13
0
        private void _ProcessRequest()
        {
            try
            {
                Response.Clear();

                string sessionId = CheckSession();

                if (sessionId == null)
                {
                    return;
                }

                if (Request.Params["SwitchDebugVar1"] != null)
                {
                    Response.Write(Global.Sessions[sessionId]);
                    Response.End();
                    return;
                }

                if (Request.Params["DeleteSwitchCache"] != null)
                {
                    DeleteCacheDirectory("Images");
                    DeleteCacheDirectory("Scripts");
                    DeleteCacheDirectory("Stylesheets");
                }

                if (Request.Url.ToString().EndsWith("favicon.ico"))
                {
                    Response.BinaryWrite(new byte[0]);
                    Response.End();
                }

                Response.Headers.Add("Arr-Disable-Session-Affinity", "True");

                // Load all parameter keys to ignore.
                string[] ignoreParams = File.ReadAllText(Path.Combine(
                                                             Request.PhysicalApplicationPath,
                                                             "App_Data",
                                                             "IgnoreParams.txt"
                                                             )).Split(',');

                string parameters = "";

                // Run through all request parameters.
                foreach (string key in Request.Params.AllKeys)
                {
                    if (key == null)
                    {
                        continue;
                    }

                    if (key.StartsWith("404"))
                    {
                        continue;
                    }

                    if (ignoreParams.Contains(key))
                    {
                        continue;
                    }

                    if (Request.HttpMethod != "GET")
                    {
                        parameters += key + "=" + HttpUtility.UrlEncode(Request.Params[key]) + "&";
                    }
                    else
                    {
                        parameters += key + "=" + (Request.Params[key]) + "&";
                    }
                }

                string url;

                if (Request.Params.ToString().Split('&')[0].StartsWith("404"))
                {
                    url = ConfigurationManager.AppSettings["Protocol"] + "://" + Global.Sessions[sessionId] +
                          new Uri(HttpUtility.UrlDecode(Request.Params.ToString().Split('&')[0]).Split(';')[1]).PathAndQuery;
                }
                else
                {
                    url = ConfigurationManager.AppSettings["Protocol"] + "://" + Global.Sessions[sessionId] + Request.Params["Path_Info"];
                }

                if (parameters.Length > 0)
                {
                    parameters = parameters.Remove(parameters.Length - 1, 1);
                }

                SwitchHandler switchHandler = new SwitchHandler();

                if (switchHandler.Switch(
                        Global.Sessions[sessionId],
                        url,
                        parameters
                        ) == false)
                {
                    ServerCollection servers = new ServerCollection(Path.Combine(
                                                                        Request.PhysicalApplicationPath,
                                                                        "App_Data",
                                                                        "Servers.xml"
                                                                        ));

                    if (servers.Items.ContainsKey(Global.Sessions[sessionId]))
                    {
                        try
                        {
                            SendServerOfflineNotification(servers.Items[Global.Sessions[sessionId]]);
                        }
                        catch { }

                        servers.Items[Global.Sessions[sessionId]].State = ServerState.Offline;
                        servers.Save();

                        ProcessRequest();
                        return;
                    }
                }

                Response.AddHeader("LiNK_Server", Global.Sessions[sessionId]);

                /*if (Response.Cookies["ASP.NET_SessionId"] == null)
                 * {
                 *  HttpCookie cookie = new HttpCookie("ASP.NET_SessionId", Request.Cookies["ASP.NET_SessionId"].Value);
                 *  cookie.Domain = Request.Url.Host;
                 *  cookie.Path = "/";
                 *
                 *  Response.Cookies.Add(cookie);
                 * }
                 * else if (Response.Cookies["ASP.NET_SessionId"].Value == "")
                 * {
                 *  Response.Cookies["ASP.NET_SessionId"].Value = Request.Cookies["ASP.NET_SessionId"].Value;
                 * }*/
            }
            catch (Exception ex)
            {
                File.WriteAllText(Path.Combine(
                                      Request.PhysicalApplicationPath,
                                      "Log.txt"
                                      ), ex.ToString());
            }
        }
Example #14
0
 // This will not fire a ValueChanged event on native
 void SetIsOn(SwitchHandler switchHandler, bool value) =>
 switchHandler.PlatformView.SetState(value, true);
Example #15
0
 public void SetFormEnabled(bool enabled)
 {
     if (this.InvokeRequired)
     {
         SwitchHandler h = new SwitchHandler(SetFormEnabled);
         this.Invoke(h, new object[] { enabled });
     }
     else
     {
         resetMatchesLinkLabel.Enabled = enabled;
         settingsGroupBox.Enabled = enabled;
         syncButton.Enabled = enabled;
         cancelButton.Enabled = !enabled;
     }
 }
Example #16
0
 bool GetNativeIsOn(SwitchHandler switchHandler) =>
 GetNativeSwitch(switchHandler).On;
Example #17
0
 public void TimerSwitch(bool value)
 {
     if (this.InvokeRequired)
     {
         SwitchHandler h = new SwitchHandler(TimerSwitch);
         this.Invoke(h, new object[] { value });
     }
     else
     {
         //If PC resumes or unlocks or is started, give him 5 minutes to recover everything before the sync starts
         if (lastSync <= DateTime.Now.AddSeconds(300) - new TimeSpan(0, (int)autoSyncInterval.Value, 0))
             lastSync = DateTime.Now.AddSeconds(300) - new TimeSpan(0, (int)autoSyncInterval.Value, 0);
         autoSyncInterval.Enabled = autoSyncCheckBox.Checked && value;
         syncTimer.Enabled = autoSyncCheckBox.Checked && value;
         nextSyncLabel.Visible = autoSyncCheckBox.Checked && value;
     }
 }
Example #18
0
 public static void Subscribe(SwitchHandler s)
 {
     s.click += new SwitchHandler.ClickHandler(ChangeState);
 }
Example #19
0
 public void AddSwitchListener(SwitchHandler handler)
 {
     switchListeners += handler;
 }
Example #20
0
 void SetIsOn(SwitchHandler switchHandler, bool value) =>
 GetNativeSwitch(switchHandler).Checked = value;
Example #21
0
 UISwitch GetNativeSwitch(SwitchHandler switchHandler) =>
 (UISwitch)switchHandler.NativeView;
Example #22
0
 bool GetNativeIsOn(SwitchHandler switchHandler) =>
 GetNativeSwitch(switchHandler).Checked;
Example #23
0
 // This will not fire a ValueChanged event on native
 void SetIsOn(SwitchHandler switchHandler, bool value) =>
 switchHandler.NativeView.SetState(value, true);