Esempio n. 1
0
 private void btnOpenFileExcel_Click(object sender, EventArgs e)
 {
     try
     {
         OpenFileDialog op = new OpenFileDialog();
         op.Filter = "Excel .csv|*.csv|Excel .xlsx|*.xlsx|Excel .xls|*.xls";
         if (DialogResult.OK == op.ShowDialog())
         {
             txtPath.Text   = op.FileName;
             dtDataTemp     = new DataTable();
             listDataUpload = new List <Dictionary <string, object> >();
             var x = Path.GetExtension(op.FileName);
             if (x == ".csv")
             {
                 dtDataTemp = ApplicationLibary.getDataExcelFromFileCSVToDataTable(op.FileName);
             }
             else
             {
                 dtDataTemp = ApplicationLibary.getDataExcelFromFileToDataTable(op.FileName);
             }
             loadDataToTable(dtDataTemp);
             ApplicationLibary.writeLog(lsBoxLog, "Success " + dtDataTemp.Rows.Count + " record(s) is opened", 1);
             // testSaveFile();
         }
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show("Error: " + ex.Message);
     }
 }
Esempio n. 2
0
 private void btnClear_Click(object sender, EventArgs e)
 {
     if (lsBoxLog.Items.Count > 0)
     {
         lsBoxLog.Items.Clear();
         ApplicationLibary.writeLog(lsBoxLog, "Cleared", 1);
     }
 }
Esempio n. 3
0
 private void ckUsingFileUpload_CheckedChanged(object sender, EventArgs e)
 {
     if (ckUsingFileUpload.Checked)
     {
         btnOpenFileExcel.Enabled = true;
         ApplicationLibary.writeLog(lsBoxLog, "Enable upload styles using file", 1);
     }
     else
     {
         btnOpenFileExcel.Enabled = false;
         ApplicationLibary.writeLog(lsBoxLog, "Disable upload styles using file", 1);
     }
 }
Esempio n. 4
0
 private void btnChooesImage_Click(object sender, EventArgs e)
 {
     try
     {
         OpenFileDialog op = new OpenFileDialog();
         op.Multiselect = true;
         op.Filter      = "Image .png|*.png";
         if (DialogResult.OK == op.ShowDialog())
         {
             lsImageFileNames = op.FileNames.ToList();
             foreach (var item in lsImageFileNames)
             {
                 lsBoxImage.Items.Add(Path.GetFileName(item));
             }
             ApplicationLibary.writeLog(lsBoxLog, "Selected " + lsImageFileNames.Count + " file(s)", 1);
         }
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show("Error: " + ex.Message);
     }
 }
Esempio n. 5
0
        private void executeLogin(string username, string password)
        {
            try
            {
                var urlLogin = ApplicationLibary.encodeURL("https://partner.spreadshirt.com/api/v1/sessions", "", "POST", "us_US", "json", "");
                //string urlLogin = "******";
                string data2Send = "{\"rememberMe\":false,\"username\":\"" + username + "\",\"password\":\"" + password + "\"}";

                HttpWebRequest wRequestLogin = (HttpWebRequest)WebRequest.Create(urlLogin);
                wRequestLogin.Headers.Add("Accept-Language", "vi-VN,vi;q=0.8,en-US;q=0.5,en;q=0.3");
                wRequestLogin.Accept          = "application/json, text/plain, */*";
                wRequestLogin.Host            = "partner.spreadshirt.com";
                wRequestLogin.ContentType     = "application/json;charset=utf-8";
                wRequestLogin.Referer         = "https://partner.spreadshirt.com/login";
                wRequestLogin.CookieContainer = new CookieContainer();

                Dictionary <string, object> step2Login = PostDataAPI(wRequestLogin, data2Send);
                cookieApplication = (CookieContainer)step2Login["cookies"];
                var rs = step2Login["data"].ToString();
                if (int.Parse(step2Login["status"].ToString()) == -1)
                {
                    XtraMessageBox.Show("Sai thông tin tài khoản hoặc mật khẩu\n" + rs, "Thông báo");
                    return;
                }

                var obj = JObject.Parse(rs);
                User               = new ApplicationUser();
                User.SESSION_ID    = obj["id"].ToString();
                User.SESSION_HREF  = obj["href"].ToString();
                User.IDENTITY_ID   = obj["identity"]["id"].ToString();
                User.IDENTITY_HREF = obj["identity"]["href"].ToString();
                User.USER_ID       = obj["user"]["id"].ToString();
                User.USER_HREF     = obj["user"]["href"].ToString();

                ApplicationLibary.writeLog(lsBoxLog, "Login Successfully", 1);
                string urlShop = User.USER_HREF + "/pointsOfSale";
                urlShop = ApplicationLibary.encodeURL(urlShop, "", "GET", "us_US", "json", "");

                HttpWebRequest wRequestShopping = (HttpWebRequest)WebRequest.Create(urlShop);
                wRequestShopping.Headers.Add("Accept-Language", "vi-VN,vi;q=0.8,en-US;q=0.5,en;q=0.3");
                wRequestShopping.Accept          = "application/json, text/plain, */*";
                wRequestShopping.Host            = "partner.spreadshirt.com";
                wRequestShopping.ContentType     = "application/json;charset=utf-8";
                wRequestShopping.CookieContainer = cookieApplication;
                Dictionary <string, object> dataShop = GetDataAPI(wRequestShopping);

                JObject objShop  = JObject.Parse(dataShop["data"].ToString());
                var     listShop = objShop["list"].ToString();
                JArray  arrShop  = JArray.Parse(listShop);

                lsAllShopItem = new List <UCItemShopSpread>();
                User.SHOPS    = new List <OShop>();
                foreach (var item in arrShop)
                {
                    if (!item["type"].ToString().Equals("MARKETPLACE") && !item["type"].ToString().Equals("CYO"))
                    {
                        OShop o = new OShop();
                        o.Id       = item["id"].ToString();
                        o.Name     = item["name"].ToString();
                        o.TargetID = item["target"]["id"].ToString();
                        o.Type     = item["type"].ToString();
                        User.SHOPS.Add(o);
                    }
                }
                loadAllShop();

                /*
                 *--hoangbap1595
                 * 73338c5b-2cbe-4333-8164-b23e30a6e0da
                 * https://www.spreadshirt.com/api/v1/sessions/73338c5b-2cbe-4333-8164-b23e30a6e0da
                 * NA-2832173b-7196-4e59-bf8d-3740fdb3c71a
                 * https://www.spreadshirt.com/api/v1/identities/NA-2832173b-7196-4e59-bf8d-3740fdb3c71a
                 * 302721328
                 * https://www.spreadshirt.com/api/v1/users/302721328
                 *
                 * --lcoang1995
                 * 4f6e5652-e7a7-47b5-bf0a-d96c8cbaf458
                 * https://www.spreadshirt.com/api/v1/sessions/4f6e5652-e7a7-47b5-bf0a-d96c8cbaf458
                 * NA-776b20df-bfb4-4d47-a225-9d1252f9fd4c
                 * https://www.spreadshirt.com/api/v1/identities/NA-776b20df-bfb4-4d47-a225-9d1252f9fd4c
                 * 302719724
                 * https://www.spreadshirt.com/api/v1/users/302719724
                 *
                 * /*-------------------LOGIN FINISH-------------------*/
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Lỗi");
            }
        }