//public bool RetourneBalanceAuxilliaire_Block(string CodeSite, DateTime? Datefin, bool chk_Excel_IsChecked, string Libelle_Site, string CheminImpression, int Offset, string matricule,string ServerEndPointName,string ServerEndPointPort,string WebAppBaseAdreese) //{ // try // { // DbInterfaceComptable db = new DbInterfaceComptable(); // ErrorManager.WriteInLogFile(this, "debut" + System.DateTime.Now); // List<CsBalance> lats = db.RetourneBalanceAuxilliaireSpx(CodeSite, Datefin); // ErrorManager.WriteInLogFile(this, "Fin" + System.DateTime.Now); // //return lats; // string format = "pdf"; // if (chk_Excel_IsChecked == true) format= "xlsx"; // Dictionary<string, string> param = new Dictionary<string, string>(); // //param.Add("pDateFin", Datefin.ToString()); // //param.Add("pAgence", Libelle_Site); // //List<ServiceAccueil.CsBalance> l = Utility.ConvertListType<ServiceAccueil.CsBalance, ServiceInterfaceComptable.CsBalance>(args.Result); // ActionExportationWithSpliting(lats, param, string.Empty, CheminImpression, "BalanceAuxilliaire", "InterfaceComptable", true, format, Offset,matricule, ServerEndPointName, ServerEndPointPort, WebAppBaseAdreese); // return true; // } // catch (Exception ex) // { // ErrorManager.LogException(this, ex); // return false; // } //} //static int compteur; //static public void ActionExportationWithSpliting(List<CsBalance> ListeDobjects, Dictionary<string, string> param, string NomFichier, string printer, string rdlcUri, string moduleNmae, bool IsLandscape, string Format, int Offset, string matricule, string ServerEndPointName, string ServerEndPointPort, string WebAppBaseAdreese) //{ // // Parsing de originalArray vers Arrays // //int loaderHandler = -1; // //loaderHandler = LoadingManager.BeginLoading("Patientez ... "); // try // { // string key = getKey(matricule); // //Shared.ClasseMEthodeGenerique.SetMachineAndPortFromEndPoint(Utility.EndPoint("Printing")); // SetFromWebPartBalanceWithSplit(ListeDobjects, param, NomFichier, printer, rdlcUri, moduleNmae, IsLandscape, Format, key, Offset, ServerEndPointName, ServerEndPointPort, WebAppBaseAdreese); // } // catch (Exception ex) // { // throw ex; // } //} //public static string getKey(string matricule_param) //{ // try // { // //string strBaseWebAddress = App.Current.Host.Source.AbsoluteUri; // //int PositionOfClientBin = App.Current.Host.Source.AbsoluteUri.ToLower().IndexOf(@"clientbin"); // //string root = strBaseWebAddress.Substring(0, PositionOfClientBin); // //string clientIpAddrss = root.Split(':')[1].Split('/')[2]; // //return clientIpAddrss; // string matricule = matricule_param; // string heure = DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString(); // return matricule + heure; // //return SessionObject.MachineName; // } // catch (Exception ex) // { // string error = ex.Message; // return string.Empty; // } //} //private static void SetFromWebPartBalanceWithSplit(List<CsBalance> ListeDobjects, Dictionary<string, string> param, string NomFichier, string printer, string rdlcUri, string moduleNmae, bool IsLandscape, string Format, string key, int Offset, string ServerEndPointName, string ServerEndPointPort, string WebAppBaseAdreese) //{ // var Reste = ListeDobjects.Count() % Offset; // var Quotient = ListeDobjects.Count() / Offset; // RecursifSet(ListeDobjects, param, NomFichier, printer, rdlcUri, moduleNmae, IsLandscape, Format, key, Offset, Quotient, Reste, ServerEndPointName, ServerEndPointPort, WebAppBaseAdreese); //} //private static void RecursifSet(List<CsBalance> ListeDobjects, Dictionary<string, string> param, string NomFichier, string printer, string rdlcUri, string moduleNmae, bool IsLandscape, string Format, string key, int Offset, int Quotient, int Reste, string ServerEndPointName, string ServerEndPointPort,string WebAppBaseAdreese) //{ // new WcfService.AcceuilService().setFromWebPartBalance(ListeDobjects.GetRange(compteur * Offset, (compteur == Quotient) ? Reste : Offset), key, param); // compteur++; // if (compteur < Quotient) // RecursifSet(ListeDobjects, param, NomFichier, printer, rdlcUri, moduleNmae, IsLandscape, Format, key, Offset, Quotient, Reste, ServerEndPointName, ServerEndPointPort, WebAppBaseAdreese); // else // { // if (compteur == Quotient) // { // //Offset = Reste; // RecursifSet(ListeDobjects, param, NomFichier, printer, rdlcUri, moduleNmae, IsLandscape, Format, key, Offset, Quotient, Reste, ServerEndPointName, ServerEndPointPort, WebAppBaseAdreese); // } // } // if (compteur > Quotient) // { // compteur = 0; // SendToExportTypeEdition(NomFichier, rdlcUri, moduleNmae, key, printer, IsLandscape, Format, "1", ServerEndPointName, ServerEndPointPort, WebAppBaseAdreese); // } //} static void SendToExportTypeEdition(string NomFichier, string rdlcUri, string moduleNmae, string key, string printer, bool IsLandscape, string Format, string TypeEdition, string ServerEndPointName, string ServerEndPointPort, string WebAppBaseAdreese) { try { string parametres = rdlcUri + "|" + moduleNmae + "|" + key + "|" + printer + "|" + IsLandscape + "|" + TypeEdition; System.Net.WebClient objWebClient = new System.Net.WebClient(); objWebClient.UploadStringCompleted += (send, resul) => { try { if (resul.Cancelled || resul.Error != null) { string error = resul.Error.Message; return; } } catch (Exception ex) { throw ex; } }; objWebClient.UploadStringAsync(GetHTTPHandlerURIExportation_TYPEDEMANDE(NomFichier, rdlcUri, moduleNmae, key, printer, IsLandscape, Format, TypeEdition, ServerEndPointName, ServerEndPointPort, WebAppBaseAdreese), parametres); } catch (Exception ex) { throw ex; } }
static void SendToExport(string NomFichier, string rdlcUri, string moduleNmae, string key, string printer, bool IsLandscape, string Format, string ServerEndPointName, string ServerEndPointPort, string hostPort) { try { string parametres = rdlcUri + "|" + moduleNmae + "|" + key + "|" + printer + "|" + IsLandscape; System.Net.WebClient objWebClient = new System.Net.WebClient(); objWebClient.UploadStringCompleted += (send, resul) => { try { if (resul.Cancelled || resul.Error != null) { return; } } catch (Exception ex) { } }; objWebClient.UploadStringAsync(GetHTTPHandlerURIExportation(NomFichier, rdlcUri, moduleNmae, key, printer, IsLandscape, Format, ServerEndPointName, ServerEndPointPort, hostPort), parametres); } catch (Exception ex) { throw ex; } }
/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="uri"></param> /// <param name="datas"></param> /// <param name="method"></param> /// <param name="charset"></param> /// <param name="RunT"></param> public void WebRequestCompleted <T>(Uri uri, IDictionary <string, object> datas = null, string method = "POST", string charset = "UTF8", Action <T> RunT = null) { string data = this.CreateDataJson(datas); using (System.Net.WebClient webClient = new System.Net.WebClient()) { //webClient.Encoding = (Encoding)Enum.Parse(typeof(Encoding), charset); webClient.Headers["Method"] = method.ToString(); webClient.Headers["Content-Type"] = string.Format(@"application/json;charset={0}", charset); if ("POST".Equals(method)) { webClient.UploadStringCompleted += (sender, e) => { var dwstring = e.Result; if (RunT != null) { RunT(JsonConvert.DeserializeObject <T>(dwstring)); } }; webClient.UploadStringAsync(uri, method, data); } else { webClient.DownloadStringCompleted += (sender, e) => { var dwstring = e.Result; if (RunT != null) { RunT(JsonConvert.DeserializeObject <T>(dwstring)); } }; webClient.DownloadStringAsync(uri); } } }
static void SendToMailHandler(string rdlcUri, string moduleNmae, string key, string serveur, string port, string PortWeb, string from, string subject, string body, string smtp, string portSmtp, string sslEnabled, string login, string password) { try { string parametres = rdlcUri + "|" + moduleNmae + "|" + key + "|" + serveur + "|" + port + "|" + from + "|" + subject + "|" + body + "|" + smtp + "|" + portSmtp + "|" + sslEnabled + "|" + login + "|" + password; System.Net.WebClient objWebClient = new System.Net.WebClient(); objWebClient.UploadStringCompleted += (send, resul) => { try { string keyPreview = resul.Result; if (string.IsNullOrEmpty(keyPreview)) { //Message.Show(Langue.preview_error_smg, Langue.msg_error_title); return; } // construire le chemin de la page aspx servant d'apercu d'impression string strBaseWebAddress = objWebClient.BaseAddress; int PositionOfClientBin = objWebClient.BaseAddress.ToLower().IndexOf("clientbin"); string root = strBaseWebAddress.Substring(0, PositionOfClientBin); //string urlAspx = String.Format(@"{0}" + "HandlerPrinting/PreviewPrinting.aspx?key={1}", root, keyPreview); //ShowPreview(root,keyPreview); //ShowPreviewFrame(urlAspx); } catch (Exception ex) { //Message.Show(ex.Message, Galatee.Silverlight.Resources.Langue.errorTitle); } }; var tableau = OperationContext.Current.Host.BaseAddresses.First().AbsoluteUri.Split('/'); string uri = tableau[0] + "//" + tableau[2].Split(':')[0] + ":" + PortWeb + "/"; objWebClient.UploadStringAsync(GetPreviewHTTPHandlerURIForEmail(uri), parametres); } catch (Exception ex) { throw ex; } }
/// <summary> /// 1.开始列表获取 /// </summary> /// <param name="path"></param> /// <param name="iType"></param> public static void StartList(string path, LiuXingType iType) { if (string.IsNullOrEmpty(path)) return; // 解析数据 using ( var datadown = new System.Net.WebClient { Encoding = iType.Encoding, Proxy = iType.Proxy } ) { datadown.Headers.Add(System.Net.HttpRequestHeader.UserAgent, "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1581.2 Safari/537.36"); if (iType.Sign.Contains("M1905List")) { datadown.Headers.Add("order", "listorder"); datadown.Headers.Add("videotype", "3"); datadown.Headers.Add(System.Net.HttpRequestHeader.ContentType, "application/x-www-form-urlencoded"); datadown.UploadStringAsync(new System.Uri(path), "POST", "page=1&pagesize=10&order=listorder&videotype=3", iType); datadown.UploadStringCompleted += Datadown_UploadStringCompleted; } else { if (iType.Sign.Contains("M1905Second")) { datadown.Headers.Add("filmid", iType.Sign.Split(',')[1]); datadown.Headers.Add(System.Net.HttpRequestHeader.ContentType, "application/x-www-form-urlencoded"); datadown.UploadStringAsync(new System.Uri(UrlCodeHelper.GetListHttpPath(0, 0, iType).Replace("filmlist", "filmdetail")), "POST", "filmid=" + iType.Sign.Split(',')[1], iType); datadown.UploadStringCompleted += Datadown_UploadStringCompleted; } else { if (iType.Type == LiuXingEnum.ZhangYuSearchItem) { datadown.Headers.Add("Cookie", "Hm_lvt_69521636d966ad606a32d89b1d70ee73=1376875963,1376889226; Hm_lpvt_69521636d966ad606a32d89b1d70ee73=1376889233; ce=gY1lvwT"); } if (iType.Type == LiuXingEnum.DyfmHotApi) { datadown.Headers.Add("Cookie", "last_visit=" + System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 24) + "Hm_lpvt_10701d9b4e040e37e58bee7e1ec1d252=1376902145"); } datadown.DownloadStringAsync(new System.Uri(path), iType); datadown.DownloadStringCompleted += Datadown_DownloadStringCompleted; } } } }