public override void Update()
        {
            DB db = new DB("travox_global"); 

            RequestBuilder doExchange = new RequestBuilder("127.0.0.1:3000/API-v3/exchange-rate/");
            doExchange.By = RequestBuilder.Method.POST;
            doExchange.ContentType = "application/x-www-form-urlencoded";
            doExchange.AddHeader("Token-Auth", "ZHNnc2RmaCxrZXIgbmFsZ25zIGRmZ2RzZmc");

            doExchange.AddBody("from", db.GetField("SELECT ISNULL(currency,'') FROM currency FOR XML PATH('')"));
            doExchange.AddBody("to", "THB");
            doExchange.AddBody("amt", "1");

            XHR rate = new XHR().AsyncSend(doExchange).Wait();

            try
            {
                foreach (RateAPI item in JsonConvert.DeserializeObject<List<RateAPI>>(rate.ToString()))
                {
                    SQLCollection param = new SQLCollection();
                    param.Add("@to", DbType.String, item.currency);
                    param.Add("@rate", DbType.Decimal, item.rate);
                    param.Add("@date", DbType.DateTime, DateTime.Parse(item.updated).ToString("dd-MM-yyyy HH:mm:ss"));

                    db.Execute("UPDATE currency SET currency_rate=@rate, last_update=@date WHERE currency = @to", param);
                }
                db.Apply();
            }
            catch (Exception e)
            {
                db.Rollback();
                throw e;
            }
            base.Update();
        }
        public override void Update()
        {
            if (State.CompanyCode == "mos")
            {
                DB db = new DB("travox_global");

                RequestBuilder doExchange = new RequestBuilder("https://api.travox.com/API-v3/exchange-rate/")
                {
                    Method      = RequestBuilder.By.POST,
                    ContentType = "application/x-www-form-urlencoded"
                };

                doExchange.Headers.Add("Token-Auth", "ZHNnc2RmaCxrZXIgbmFsZ25zIGRmZ2RzZmc");

                doExchange.AddBody("from", db.GetField("SELECT ISNULL(currency,'') FROM currency FOR XML PATH('')"));
                doExchange.AddBody("to", "THB");
                doExchange.AddBody("amt", "1");

                try
                {
                    String res = XHR.Request(doExchange, true);

                    foreach (RateAPI item in JsonConvert.DeserializeObject <List <RateAPI> >(res.ToString()))
                    {
                        SQLCollection param = new SQLCollection
                        {
                            { "@to", DbType.String, item.currency },
                            { "@rate", DbType.Decimal, item.rate },
                            { "@date", DbType.DateTime, DateTime.Parse(item.updated).ToString("dd-MM-yyyy HH:mm:ss") }
                        };
                        db.Execute("UPDATE currency SET currency_rate=@rate, last_update=@date WHERE currency = @to", param);
                    }
                    db.Apply();
                    base.Update();
                }
                catch (Exception e)
                {
                    db.Rollback();
                    base.Update();
                    throw new Exception(base.DBName, e);
                }
            }
        }
        private void AppMain_Loaded(object sender, RoutedEventArgs e)
        {
            Point Desktop = new Point(SystemParameters.WorkArea.Width, SystemParameters.WorkArea.Height);
            this.Left = 10;
            this.Top = Desktop.Y - (this.Height + 10);
            this.Topmost = false;

            RequestBuilder nipp = new RequestBuilder("http://www.nipponanime.net/forum/nisekoi/(one-shot)-nisekoi-ch-0-(lightning)/");
           txtTest.Text = XHR.Connect(nipp).ToString();

            nipp = new RequestBuilder("http://upic.me/i/f1/7bx12.jpg");
            nipp.Referer = "http://www.nipponanime.net/forum/nisekoi";
            XHR c = new XHR(nipp);
            ResponseBuilder a = new ResponseBuilder();
            do
            {
                //File.WriteAllBytes("C:\\Users\\HaKko\\Desktop\\"+Path.GetRandomFileName() +".txt", c.ReceiveByte());
                Console.WriteLine(XHR.BytesPerSecond(c.ReceivedData));
            } while (c.ReceivedData > 0);
        }
Exemple #4
0
        private void AppMain_Loaded(object sender, RoutedEventArgs e)
        {
            Point Desktop = new Point(SystemParameters.WorkArea.Width, SystemParameters.WorkArea.Height);

            this.Left    = 10;
            this.Top     = Desktop.Y - (this.Height + 10);
            this.Topmost = false;

            RequestBuilder nipp = new RequestBuilder("http://www.nipponanime.net/forum/nisekoi/(one-shot)-nisekoi-ch-0-(lightning)/");

            txtTest.Text = XHR.Connect(nipp).ToString();

            nipp         = new RequestBuilder("http://upic.me/i/f1/7bx12.jpg");
            nipp.Referer = "http://www.nipponanime.net/forum/nisekoi";
            XHR             c = new XHR(nipp);
            ResponseBuilder a = new ResponseBuilder();

            do
            {
                //File.WriteAllBytes("C:\\Users\\HaKko\\Desktop\\"+Path.GetRandomFileName() +".txt", c.ReceiveByte());
                Console.WriteLine(XHR.BytesPerSecond(c.ReceivedData));
            } while (c.ReceivedData > 0);
        }
        public override void Update()
        {
            base.Update();
            const String ViewerPath = @"C:\inetpub\wwwroot\travox.com\viewer\";

            SecretaryEvent Period = SecretaryEvent.Unknow;

            SQLCollection param = new SQLCollection("@id", DbType.Int32, base.State.CompanyID);

            foreach (DataRow Row in new DB("travox_system").GetTable(@"
                SELECT secretary_id, period, output_email, output_printer, email, report_name, report_key, template_name
                FROM crawler.secretary s LEFT JOIN document.report r ON r.report_id = s.report_id
                WHERE s.status = 'ACTIVE' AND (site_customer_id = @id OR site_customer_id IS NULL)
            ", param).Rows)
            {
                ParameterDate SystemDate;

                switch (Row["period"].ToString())
                {
                case "Daily": Period = SecretaryEvent.Daily; break;

                case "Weekly": Period = SecretaryEvent.Weekly; break;

                case "Monthly": Period = SecretaryEvent.Monthly; break;
                }

                SystemDate.From = DateTime.Now.Date;
                SystemDate.To   = DateTime.Now.Date;
                DateTime DateEndMonth    = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(1).AddDays(-1);
                String   OutputEmailType = Row["output_email"].ToString().Trim();
                String   OutputPrinter   = Row["output_printer"].ToString().Trim();

                if (Period == SecretaryEvent.Monthly && (DateTime.Now.Date == DateEndMonth || App.DebugMode))
                {
                    SystemDate.From = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
                    SystemDate.To   = DateEndMonth;
                }
                else if (Period == SecretaryEvent.Weekly && (DateTime.Now.DayOfWeek == DayOfWeek.Sunday || App.DebugMode))
                {
                    SystemDate.From = SystemDate.To.AddDays(-7);
                }
                else if (Period == SecretaryEvent.Daily)
                {
                }
                else
                {
                    Period = SecretaryEvent.Unknow;
                }

                if ((!MBOS.Null(OutputEmailType) || MBOS.Bool(OutputPrinter)) && Period != SecretaryEvent.Unknow)
                {
                    RequestBuilder ReportViewer = new RequestBuilder(App.DebugMode ? "https://viewer.travox.com/default.aspx" : "http://localhost:8026/Default.aspx")
                    {
                        Method      = RequestBuilder.By.POST,
                        ContentType = "application/json"
                    };

                    ReportViewer.Headers.Add("Travox-Sentinel", "true");
                    ReportViewer.SetCookie("ASP.NET_SessionId", SessionID);
                    ReportViewer.SetCookie("DATABASE_NAME", base.State.DatabaseName);
                    ReportViewer.SetCookie("CUSTOMER_CODE", base.State.CompanyCode);
                    ReportViewer.SetCookie("STAFF_ID", "-4");
                    ReportViewer.SetCookie("STAFF_CODE", "TX");
                    ReportViewer.SetCookie("REMEMBER", "true");

                    ReportViewer.RawBody.Append(JsonConvert.SerializeObject(new HandlerItem {
                        OnEmail      = !MBOS.Null(OutputEmailType),
                        OnPrinter    = MBOS.Bool(OutputPrinter),
                        ID           = Row["secretary_id"].ToString(),
                        Email        = Row["email"].ToString(),
                        Period       = Row["period"].ToString(),
                        TemplateName = Row["template_name"].ToString(),
                        PeriodDate   = SystemDate,
                        ItemType     = new ItemType {
                            ExportType = OutputEmailType
                        },
                        Report = new ItemReport {
                            Name = Row["report_key"].ToString(), Filename = Row["report_key"].ToString() + ".rpt"
                        }
                    }));

                    String ex = XHR.Request(ReportViewer, true);
                    if (!MBOS.Null(ex))
                    {
                        Console.WriteLine(base.State.CompanyCode + " --- " + Row["template_name"].ToString());
                        Console.WriteLine(ex);
                    }
                }
            }
        }
Exemple #6
-1
        public override void Start()
        {
            // LOGIN 
            
            RequestBuilder doLogin = new RequestBuilder("forum.tirkx.com/main/login.php?do=login");
            doLogin.By = RequestBuilder.Method.POST;
            doLogin.CacheControl = "max-age=0";
            doLogin.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
            doLogin.Origin = "http://forum.tirkx.com";
            doLogin.ContentType = "application/x-www-form-urlencoded";
            doLogin.Referer = "http://forum.tirkx.com/main/forum.php";

            doLogin.AddBody("vb_login_username", Username);
            doLogin.AddBody("vb_login_password", "");
            doLogin.AddBody("vb_login_password_hint", "Password");
            doLogin.AddBody("cookieuser", "1");
            doLogin.AddBody("s", "");
            doLogin.AddBody("securitytoken", "guest");
            doLogin.AddBody("do", "login");
            doLogin.AddBody("vb_login_md5password", Password);
            doLogin.AddBody("vb_login_md5password_utf", Password);

            Trikx = new XHR();
            //Trikx.AsyncSend(doLogin, true);

            //Trikx.AsyncReceive();
            //Trikx.WaitResponse();

            doLogin.Clear();

            base.Start();
        }