//public bool Login_Forced(int idUser, string pwd, int idClient) //{ // var request = new RestRequest("login_forced", Method.POST); // request.RequestFormat = DataFormat.Json; // JsonObject json = new JsonObject(); // json.Add("id", idUser); // json.Add("pwd", pwd); // json.Add("idClient", idClient); // request.AddBody(json); // IRestResponse response = client.Execute(request); // if (response.Content == "ok") // return true; // return false; //} //public bool Logout() //{ // var request = new RestRequest("logout", Method.GET); // IRestResponse response = client.Execute(request); // return true; //} public bool POSTTrans(SyncForm sync, int idUser, string pwd, int idClient) { Directory.CreateDirectory(pathFolderName); string[] filePaths = Directory.GetFiles(pathFolderName); List <string> upcFiles = new List <string>(); List <string> epcFiles = new List <string>(); List <string> messages = new List <string>(); foreach (String path in filePaths) { if (path.Contains("epc")) { epcFiles.Add(path); } if (path.Contains("message")) { messages.Add(path); } } sync.updateReads(upcFiles.Count.ToString() + " Inventarios"); Application.DoEvents(); int numInventories = upcFiles.Count; foreach (String path1 in epcFiles) { var request = new RestRequest("sync", Method.POST); request.RequestFormat = DataFormat.Json; request.AddBody(buildPOSTRequest(path1, "")); IRestResponse response = client.Execute(request); //MessageBox.Show(response.Content.ToString()); if (!requestError(response.StatusCode.ToString())) { return(false); } numInventories--; sync.updateReads(numInventories + " Lecturas"); Application.DoEvents(); try { String nameFileMessage = path1.Replace("iepcs", "message").Replace("oepcs", "message"); File.Move(nameFileMessage, nameFileMessage.Replace("rfiddata", "rfiddataold")); } catch (Exception exc) {} File.Move(path1, path1.Replace("rfiddata", "rfiddataold")); File.Move(path1.Replace("epc", "upc"), path1.Replace("rfiddata", "rfiddataold").Replace("epc", "upc")); } return(true); }
public MenuForm() { InitializeComponent(); //Set Config Data configInvent = ConfigInventory.getConfigInventory(@"\rfiddata\config_inventory.json"); pathFolderName = getNameFolderVersion(configInvent.version); configData = Config.getConfig(pathFolderName + "config.json"); idClient = configData.id_client; //Set Synchronization sync = new Sync(configData.url, idClient, pathFolderName); //sync.GET_Test(); sync.GET(); //Set Reader rrfid = new SimpleRFID(); //Set Catalogs products = new AssetsList(pathFolderName + "products.csv"); warehouses = new Warehouses(pathFolderName + "warehouses.csv"); if (warehouses.collection.Count == 0) { MessageBox.Show("Agregar zona", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); Application.Exit(); } if (configInvent.version == 3) { configData.id_warehouse = warehouses.collection[0].id; } //Set Current Event Data frmInventory = new InventoryForm(this); reports = new InventoryReportFrm(this); search = new SearchForm(this); upcsearch = new UPCSearchForm(this); locate = new LocateForm(this); frmsync = new SyncForm(this); frmListAsset = new ListAssetsForm(this); frmEditText = new EditTextForm(this, pathFolderName + "config.json", @"\rfiddata\config_inventory.json"); this.setColors(configData); /* * Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"\rfiddata\img\logo.bmp"); * Image image = new Bitmap(stream); * LogoPicture.Image = image; */ string myDir = Path.GetDirectoryName(Assembly.GetCallingAssembly().GetName().CodeBase); myResDir = Path.Combine(myDir, pathFolderName + "img"); Image image; image = new Bitmap(Path.Combine(myResDir, "logo_hqh_med.bmp")); LogoPicture.Image = image; image = new Bitmap(Path.Combine(myResDir, "menu1.bmp")); ReaderPicture.Image = image; image = new Bitmap(Path.Combine(myResDir, "menu2.bmp")); ReportPicture.Image = image; image = new Bitmap(Path.Combine(myResDir, "menu3.bmp")); SearchPicture.Image = image; image = new Bitmap(Path.Combine(myResDir, "menu4.bmp")); SyncPicture.Image = image; if (configInvent.version == 2) { image = new Bitmap(Path.Combine(myResDir, "InventTotal.png")); InventoryPicture.Image = image; } }
public MenuForm() { InitializeComponent(); //Set Config Data pathFolderName = getNameFolderVersion(); configData = Config.getConfig(pathFolderName + "config.json"); ftpConfig = FtpConfig.getConfig(pathFolderName + "ftp.json"); idClient = configData.id_client; showCaptureFolio = true; //Set Synchronization sync = new Sync(configData.url, idClient, pathFolderName); sync.conection = sync.GETTest(); if (sync.conection) { sync.GET(); } //Set Reader rrfid = new SimpleRFID(); //rrfid.changeEPC("30342848A80A5AC0000007D9", "30342848A80A5A400001000A"); //Set Catalogs products = new ProductsList(pathFolderName + "products.csv"); warehouses = new Warehouses(pathFolderName + "warehouses.csv"); //Set Forms reports = new InventoryReportFrm(this); search = new SearchForm(this); upcsearch = new UPCSearchForm(this, pathFolderName); locate = new LocateForm(this); formsync = new SyncForm(this); orderreport = new OrderExitReportForm(this); frmEditText = new EditTextForm(this, pathFolderName + "config.json"); this.setColors(configData); /* * Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"\rfiddata\img\logo.bmp"); * Image image = new Bitmap(stream); * LogoPicture.Image = image; */ string myDir = Path.GetDirectoryName(Assembly.GetCallingAssembly().GetName().CodeBase); myResDir = Path.Combine(myDir, pathFolderName + "img"); Image image; image = new Bitmap(Path.Combine(myResDir, "logo_hqh_med.bmp")); LogoPicture.Image = image; image = new Bitmap(Path.Combine(myResDir, "menu1.bmp")); ReaderPicture.Image = image; image = new Bitmap(Path.Combine(myResDir, "menu2.bmp")); ReportPicture.Image = image; image = new Bitmap(Path.Combine(myResDir, "menu3.bmp")); SearchPicture.Image = image; image = new Bitmap(Path.Combine(myResDir, "menu4.bmp")); SyncPicture.Image = image; image = new Bitmap(Path.Combine(myResDir, "menu5_export.bmp")); OrderExitPicture.Image = image; image = new Bitmap(Path.Combine(myResDir, "menu6.bmp")); OrderExitReportPicture.Image = image; //image = new Bitmap(Path.Combine(myResDir, "exit.bmp")); //ExitPicture.Image = image; }
public bool POSTTrans(SyncForm sync, int idUser, string pwd, int idClient) { Directory.CreateDirectory(pathFolderName); string[] filePaths = Directory.GetFiles(pathFolderName); List <string> upcFiles = new List <string>(); List <string> epcFiles = new List <string>(); List <string> messages = new List <string>(); int numInputs = 0; int numOutputs = 0; foreach (String path in filePaths) { if (path.Contains("epc")) { epcFiles.Add(path); } if (path.Contains("message")) { messages.Add(path); } if (path.Contains("iepc")) { numInputs++; } if (path.Contains("oepc")) { numOutputs++; } } sync.updateInputs(numInputs.ToString() + " Inventarios"); sync.updateOutputs(numOutputs.ToString() + " Salidas"); Application.DoEvents(); foreach (String path1 in epcFiles) { var request = new RestRequest("sync", Method.POST); request.RequestFormat = DataFormat.Json; request.AddBody(buildPOSTRequest(path1, "")); IRestResponse response = client.Execute(request); if (!requestError(response.StatusCode.ToString())) { return(false); } Application.DoEvents(); String nameFileMessage = path1.Replace("iepcs", "message").Replace("oepcs", "message"); File.Move(nameFileMessage, nameFileMessage.Replace("rfiddata", "rfiddataold")); File.Move(path1, path1.Replace("rfiddata", "rfiddataold")); File.Move(path1.Replace("epc", "upc"), path1.Replace("rfiddata", "rfiddataold").Replace("epc", "upc")); if (path1.Contains("iepc")) { numInputs--; sync.updateInputs(numInputs.ToString() + " Entradas"); } else if (path1.Contains("oepc")) { numOutputs--; sync.updateOutputs(numOutputs.ToString() + " Salidas"); } } return(true); }