public override void Process(iZip owner, ref ZipFile zip) { string globalPath = owner.Directory + "\\Web\\"; if (zip != null && !string.IsNullOrEmpty(File)) { if (File.StartsWith("../")) { File = File.Replace("../", "").Replace("/", "\\"); } string filePath = globalPath + File; if (!System.IO.File.Exists(filePath)) { filePath = globalPath + owner.Project + "\\" + File; if (!System.IO.File.Exists(filePath)) { filePath = ""; } } if (!string.IsNullOrEmpty(filePath)) { owner.Properties.Items++; zip.AddFile(filePath, ""); } else if (!string.IsNullOrEmpty(Content)) { zip.AddEntry(Path.GetFileName(File), Encoding.Default.GetBytes(Content)); } } }
protected override bool ProcessRequest(CefRequest request, CefCallback callback) { Task task = new Task(() => { try { //var serializer = new JavaScriptSerializer(); //serializer.MaxJsonLength = Int32.MaxValue; //serializer.RegisterConverters(new[] { new DynamicJsonConverter() }); var zip = new iZip(configuration.Application, Environment.CurrentDirectory, JsonMapper.ToObject <object>(zipString)); var zipBytes = Data = iZip.CreateZip(zip); var dir = Environment.CurrentDirectory + "\\Web\\" + configuration.Application + "\\reports"; if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } var dt = DateTime.Now.ToString("yyyyMMddHmmssfff"); var file = zip.Properties.Title.Replace(" ", "_") + "_" + dt + "_" + zip.Properties.Items + ".zip"; var path = dir + "\\" + file; File.WriteAllBytes(path, zipBytes); var echo = JsonMapper.ToJson(new FileHelper("OK", "reports/" + file, zip.Properties.Title, zip.Properties.Items)); Data = Encoding.UTF8.GetBytes(echo); } catch (Exception ex) { Log.Trace(ex.Message, ex.StackTrace); var echo = JsonMapper.ToJson(new ErrorHelper(ex.Message, ex.StackTrace)); Data = Encoding.UTF8.GetBytes(echo); } callback.Continue(); }); task.Start(); return(true); }
private static void Start() { var appSettings = ConfigurationManager.AppSettings; // You will need a license #, userid and password to utilize the UPS provider. var upsLicenseNumber = "############"; var upsUserId = "############"; var upsPassword = ("############*"); // You will need an account # and meter # to utilize the FedEx provider. var fedexKey = "############"; //Test Key: "ffMloFez7JlC6YaK"; var fedexPassword = "******"; //Test Password: "******"; var fedexAccountNumber = "############"; var fedexMeterNumber = "############"; //Productin Meter#:"118918154"; var fedexHubId = "5531"; // 5531 is the hubId to use in FedEx's test environment var fedexUseProduction = true; //Convert.ToBoolean(appSettings["FedExUseProduction"]); // You will need a userId to use the USPS provider. Your account will also need access to the production servers. var uspsUserId = "############"; //Gets state zipcode for destination (required by UPS for negotiated rates) var myZips = new ZipTastic.getZipInfo(); var myZipCodeData = new iZip(); try { myZipCodeData = myZips.getZipData(zipcode, "US"); }catch (Exception e) { try { myZipCodeData = myZips.getZipData(zipcode, "CA"); } catch (Exception l) { MessageBox.Show("Please enter a valid zipcode."); return; } } // Sets package destination/ origin addresses // origin: hard coded to Humboldt var origin = new Address("", "", "#####", "US", false); var destination = new Address("", myZipCodeData.state_short, zipcode, myZipCodeData.country, res); // US Address //var destination = new Address("", "", "00907", "PR"); // Puerto Rico Address //var destination = new Address("", "", "L4W 1S2", "CA"); // Canada Address //var destination = new Address("", "", "SW1E 5JL", "GB"); // UK Address // Create RateManager var rateManager = new RateManager(); // Add desired DotNetShippingProviders rateManager.AddProvider(new UPSProvider(upsLicenseNumber, upsUserId, upsPassword) { UseProduction = true }); //rateManager.AddProvider(new UPSProvider(upsLicenseNumber, upsUserId, upsPassword, "UPS Ground")); rateManager.AddProvider(new FedExProvider(fedexKey, fedexPassword, fedexAccountNumber, fedexMeterNumber, fedexUseProduction, res)); rateManager.AddProvider(new FedExSmartPostProvider(fedexKey, fedexPassword, fedexAccountNumber, fedexMeterNumber, fedexHubId, fedexUseProduction)); rateManager.AddProvider(new USPSProvider(uspsUserId, "Priority Commercial")); //rateManager.AddProvider(new USPSInternationalProvider(uspsUserId)); // (Optional) Add RateAdjusters rateManager.AddRateAdjuster(new PercentageRateAdjuster(1.05M)); // Call GetRates() var shipment = rateManager.GetRates(origin, destination, packages); if (shipment.Rates.Count == 0) { MessageBox.Show("Something went wrong, Check inputs"); } decimal[] rates = new decimal[shipment.Rates.Count]; string result = ""; shipment.Rates.Sort((x, y) => decimal.Compare(x.TotalCharges, y.TotalCharges)); foreach (var rate in shipment.Rates) { result += rate.Name + Environment.NewLine + " $" + rate.TotalCharges.ToString("#,##0.00") + Environment.NewLine; } if (result != "") { MessageBox.Show(result); } //string restart = Console.ReadLine(); //if(restart.ToLower() == "y") //{ // Console.WriteLine(); // Main(); //}; }
public virtual void Process(iZip owner, ref ZipFile zip) { }
public override void Process(iZip owner, ref ZipFile zip) { }