Exemplo n.º 1
0
        /// <summary>
        /// 保存远程文件(自动获取扩展名)Ext任填True/False不影响任何结果
        /// </summary>
        /// <param name="Url">远程url</param>
        /// <param name="Path">保存到的路径</param>
        /// <returns></returns>
        public string RemoteSave(string Url, string Path, bool Ext)
        {
            Random ra             = new Random();
            string StringFileName = DateRndName(ra) + "." + GetFileExtends(Url);
            string StringFilePath = Path + StringFileName;

            MSXML2.XMLHTTP _xmlhttp = new MSXML2.XMLHTTPClass();
            _xmlhttp.open("GET", Url, false, null, null);
            _xmlhttp.send("");
            if (_xmlhttp.readyState == 4)
            {
                if (System.IO.File.Exists(StringFilePath))
                {
                    System.IO.File.Delete(StringFilePath);
                }
                System.IO.FileStream   fs = new System.IO.FileStream(StringFilePath, System.IO.FileMode.Create);
                System.IO.BinaryWriter w  = new System.IO.BinaryWriter(fs);
                w.Write((byte[])_xmlhttp.responseBody);
                w.Close();
                fs.Close();
            }
            else
            {
                throw new Exception(_xmlhttp.statusText);
            }
            return(StringFilePath);
        }
Exemplo n.º 2
0
    protected void btnHandLoad_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            int      rowIndex  = Convert.ToInt32(this.hidRowIndex.Value);
            string[] fileNames = this.grdLog.Rows[rowIndex].Cells[6].Text.Split('\\');
            string   fileName  = fileNames[fileNames.Length - 1];
            string   path      = "../../Logerror/" + DateTime.Now.ToShortDateString();;
            if (!Directory.Exists(Server.MapPath(path)))
            {
                Directory.CreateDirectory(Server.MapPath(path));
            }
            XmlDocument doc = new XmlDocument();
            doc.Load("http://" + Common.INTERFACESERVER + "/acctruewms/" + fileName);
            doc.Save(Server.MapPath(path) + "/" + fileName);//保存本地文件

            MSXML2.XMLHTTP xmlhttp = new MSXML2.XMLHTTPClass();
            xmlhttp.open("post", Common.NCWERBSERVER, false, "", "");
            DOMDocument sDoc = new DOMDocument();
            sDoc.loadXML(doc.InnerXml);
            xmlhttp.send(sDoc);
            if (xmlhttp.status == 200)
            {
                string comResult = "";
                string comDes    = "";
                doc.LoadXml(xmlhttp.responseText);
                XmlElement rootRoot = doc.DocumentElement;
                string     rootTag  = rootRoot.GetAttribute("roottag");
                XmlNode    node     = rootRoot.SelectSingleNode(rootTag + "/resultcode");
                if (node != null)
                {
                    comResult = node.InnerText.Trim();
                }
                XmlNode nodeDes = rootRoot.SelectSingleNode(rootTag + "/resultdescription");
                if (nodeDes != null)
                {
                    comDes = nodeDes.InnerText.Trim();
                }
                HtmlInputHidden hidCom  = (HtmlInputHidden)this.grdLog.Rows[rowIndex].Cells[0].FindControl("hidComid");
                string          comID   = hidCom.Value;
                int             uResult = DataOperClass.ReLoadLog(comResult, comDes, comID);
                if (uResult == -1)
                {
                    PrintfError("数据访问失败!");
                    return;
                }
                BindGridView();
                PrintfError("手工加载成功");
            }
        }
        catch
        {
            this.PrintfError("数据访问错误!");
            return;
        }
    }
Exemplo n.º 3
0
        private void button4_Click(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<ufinterface sender=\"001 \" receiver=\"u8 \" roottag=\"department \" docid=\" \" proc=\"Query \" codeexchanged=\"n \">")
            .Append("<department>")
            .Append("</department>")
            .Append("</ufinterface>");
            System.Xml.XmlDocument dom = new System.Xml.XmlDocument();
            dom.LoadXml(sb.ToString());
            MSXML2.XMLHTTPClass xmlHttp = new MSXML2.XMLHTTPClass();
            xmlHttp.open("POST", "http://localhost:8080/U8EAI/import.asp", false, null, null);
            xmlHttp.send(dom.OuterXml);
            String responseXml = xmlHttp.responseText;

            MessageBox.Show(responseXml);
            System.Runtime.InteropServices.Marshal.FinalReleaseComObject(xmlHttp);       //COM释放
        }
Exemplo n.º 4
0
        /**********************************
        * 函数名称:GetRemoteHtmlCode
        * 功能说明:获取远程文件源代码
        * 参    数:Url:远程url
        * 调用示例:
        *          GetRemoteObj o = new GetRemoteObj();
        *          string url = @"http://www.baidu.com";
        *          string s = o.GetRemoteHtmlCode(url);
        *          Response.Write(s);
        *          o.Dispose();
        * ********************************/
        /// <summary>
        /// 获取远程文件源代码
        /// </summary>
        /// <param name="url">远程url</param>
        /// <returns></returns>
        public string GetRemoteHtmlCode(string Url)
        {
            string s = "";

            MSXML2.XMLHTTP _xmlhttp = new MSXML2.XMLHTTPClass();
            if (Url.Contains("?"))
            {
                Url = Url + "&dt=" + DateTime.Now.ToShortTimeString() + DateTime.Now.Millisecond;
            }
            else
            {
                Url = Url + "?dt=" + DateTime.Now.ToShortTimeString() + DateTime.Now.Millisecond;
            }
            _xmlhttp.open("GET", Url, false, null, null);
            _xmlhttp.send("");
            if (_xmlhttp.readyState == 4)
            {
                s = System.Text.Encoding.UTF8.GetString((byte[])_xmlhttp.responseBody);
            }
            return(s);
        }
Exemplo n.º 5
0
        private void sendSMS(string sendMobilePhone)
        {
            if (sendMobilePhone.Length == 11)
            {
                try
                {
                    string spNumber = string.Empty;

                    switch (sendMobilePhone.Substring(2, 1))
                    {
                    case "0":
                        spNumber = "9002733";
                        break;

                    case "1":
                        spNumber = "9002733";
                        break;

                    case "2":
                        spNumber = "9002733";
                        break;

                    case "3":
                        spNumber = "9002733";
                        break;

                    case "4":
                        spNumber = "9002733";
                        break;

                    case "5":
                        spNumber = "8002733";
                        break;

                    case "6":
                        spNumber = "8002733";
                        break;

                    case "7":
                        spNumber = "8002733";
                        break;

                    case "8":
                        spNumber = "8002733";
                        break;

                    case "9":
                        spNumber = "8002733";
                        break;
                    }

                    string url = "http://202.96.236.81:7783/testDownMsg.asp?"
                                 + "UID=sap&psd=0F3E419C71C500FA1FC8&source=" + spNumber + "&mobile="
                                 + sendMobilePhone + "&message=" + memoEdit_Content.Text;

                    MSXML2.XMLHTTPClass xmlHttp = new MSXML2.XMLHTTPClass();
                    xmlHttp.open("POST", url, false, null, null);
                    xmlHttp.setRequestHeader("Accept-Lauguage", "zh-cn");

                    xmlHttp.send(null);

                    if (xmlHttp.status == 200)
                    {
                        if (xmlHttp.responseText == "0")
                        {
                            MessageBox.Show("短信发送成功!", "成功!",
                                            MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("短信发送失败,请重试!", "出错了!",
                                            MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                    }
                    else
                    {
                        MessageBox.Show("短信发送失败,请重试!", "出错了!",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

            else
            {
                sendMobilePhone = sendMobilePhone.Substring(0, sendMobilePhone.Length - 1);

                string[] sendMobilePhones = sendMobilePhone.Split(new char[] { ',' });

                foreach (string phoneNumber in sendMobilePhones)
                {
                    try
                    {
                        string spNumber = string.Empty;

                        switch (phoneNumber.Substring(2, 1))
                        {
                        case "0":
                            spNumber = "9002733";
                            break;

                        case "1":
                            spNumber = "9002733";
                            break;

                        case "2":
                            spNumber = "9002733";
                            break;

                        case "3":
                            spNumber = "9002733";
                            break;

                        case "4":
                            spNumber = "9002733";
                            break;

                        case "5":
                            spNumber = "8002733";
                            break;

                        case "6":
                            spNumber = "8002733";
                            break;

                        case "7":
                            spNumber = "8002733";
                            break;

                        case "8":
                            spNumber = "8002733";
                            break;

                        case "9":
                            spNumber = "8002733";
                            break;
                        }

                        string url = "http://202.96.236.81:7783/testDownMsg.asp?"
                                     + "UID=sap&psd=0F3E419C71C500FA1FC8&source=" + spNumber + "&mobile="
                                     + phoneNumber + "&message=" + memoEdit_Content.Text;

                        XMLHTTP xmlHttp = new XMLHTTPClass();
                        xmlHttp.open("POST", url, false, null, null);
                        xmlHttp.setRequestHeader("Accept-Lauguage", "zh-cn");

                        xmlHttp.send(null);

                        if (xmlHttp.status == 200)
                        {
                            if (xmlHttp.responseText == "0")
                            {
                            }
                            else
                            {
                                MessageBox.Show("短信发送失败,请重试!", "出错了!",
                                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                        }
                        else
                        {
                            MessageBox.Show("短信发送失败,请重试!", "出错了!",
                                            MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "出错了!",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }

                MessageBox.Show("操作完成!", "完成!",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 6
0
    protected void btndataUp_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            string  YSDH   = this.txtYSDH.Text.Trim();
            DataSet dsYSDH = PDParam.GetPDDNC("YSDH = '" + YSDH + "'");
            if (dsYSDH != null && dsYSDH.Tables[0].Rows.Count > 0)
            {
                string DJZT = dsYSDH.Tables[0].Rows[0]["DJZT"].ToString();
                if (DJZT != "已盘")
                {
                    this.PrintfError("只有审核过的单据才能上传");
                    return;
                }
            }
            else
            {
                this.PrintfError("没有可导出的数据");
                return;
            }
            string Fdownweb   = Common.RFWEBSERVER;     // RF服务器地址
            string Fuploadweb = Common.NCWERBSERVER;    //NC服务器地址
            string wmsserver  = Common.INTERFACESERVER; //接口地址

            //string Fdownweb = "http://192.168.1.171/";//测试地址
            //string Fuploadweb = "http://localhost:800/WebSiteXML/Default.aspx";
            //string wmsserver = "http://192.168.1.171/";

            if ((string.IsNullOrEmpty(Fdownweb)) || (string.IsNullOrEmpty(Fuploadweb)))
            {
                this.PrintfError("服务器尚未正确设置");
            }
            else
            {
                XmlDocument docC = new XmlDocument();

                string filename = YSDH + ".xml";
                docC.Load(Fdownweb + filename);     //用XmlDocument类来下载Xml文件
                DOMDocument doc       = new DOMDocument();
                XmlDocument resultdoc = new XmlDocument();
                string      xml       = docC.InnerXml;
                doc.loadXML(docC.InnerXml);     //将Xml文件赋给DOMDocument类型的doc
                IXMLDOMElement rootnode    = doc.documentElement;
                bool           XmlIsSended = PDParam.XmlIsSended(filename);
                if (XmlIsSended)
                {
                    rootnode.setAttribute("replace", "Y");
                    rootnode.setAttribute("proc", "update");
                }
                else
                {
                    rootnode.setAttribute("replace", "N");
                    rootnode.setAttribute("proc", "add");
                }
                string ArrSender   = rootnode.getAttribute("sender").ToString();
                string Aroottag    = rootnode.getAttribute("roottag").ToString();
                string ArrReceiver = rootnode.getAttribute("receiver").ToString();
                rootnode.setAttribute("sender", ArrReceiver);
                rootnode.setAttribute("receiver", ArrSender);
                DataSet     dsNCDetail = PDParam.GetNCDetail(YSDH, "");
                string      WLH;
                string      PCH;
                string      SX;
                string      vfree1;
                string      vfree2;
                string      vfree3;
                string      SPSL;
                string      SPZL;
                IXMLDOMNode node;
                foreach (DataRow dr in dsNCDetail.Tables[0].Rows)
                {
                    WLH    = dr["barcode"].ToString();
                    PCH    = dr["PCH"].ToString();
                    SX     = dr["SX"].ToString();
                    vfree1 = dr["vfree1"].ToString();
                    vfree2 = dr["vfree2"].ToString();
                    vfree3 = dr["vfree3"].ToString();
                    SPSL   = dr["SPSL"].ToString();
                    SPZL   = dr["SPZL"].ToString();
                    //修改实盘数量
                    node = rootnode.selectSingleNode(Aroottag + "/bill_body/item[cinventorycode/text()='" + WLH + "'][vbatchcode/text()='" + PCH + "'][cqualitylevelname/text()='" + SX + "'][vfree1/text()='" + vfree1 + "'][vfree2/text()='" + vfree2 + "'][vfree3/text()='" + vfree3 + "']/ncheckastnum");
                    if (node != null)
                    {
                        node.text = SPSL;
                    }
                    node = rootnode.selectSingleNode(Aroottag + "/bill_body/item[cinventorycode/text()='" + WLH + "'][vbatchcode/text()='" + PCH + "'][cqualitylevelname/text()='" + SX + "'][vfree1/text()='" + vfree1 + "'][vfree2/text()='" + vfree2 + "'][vfree3/text()='" + vfree3 + "']/nchecknum");
                    if (node != null)
                    {
                        node.text = SPZL;
                    }
                }
                //上传
                MSXML2.XMLHTTP MyHttp = new MSXML2.XMLHTTPClass();
                MyHttp.open("post", Fuploadweb, false, "", "");
                MyHttp.send(doc);

                int    ComResult = 0;
                string Comdes    = string.Empty;
                if (MyHttp.status == 200)
                {
                    resultdoc.LoadXml(MyHttp.responseText);
                    XmlElement resultRootnode = resultdoc.DocumentElement;
                    string     Roottag        = resultRootnode.GetAttribute("roottag");
                    XmlNode    resultnode     = resultRootnode.SelectSingleNode(Roottag + "/resultcode");
                    if (resultnode != null)
                    {
                        ComResult = Convert.ToInt32(resultnode.InnerText.Trim());
                    }
                    resultnode = resultRootnode.SelectSingleNode(Roottag + "/resultdescription");
                    if (resultnode != null)
                    {
                        Comdes = resultnode.InnerText.Trim();
                    }
                }
                string CKID = dsYSDH.Tables[0].Rows[0]["CK"].ToString();
                PDParam.AddXmlLog(CKID, filename, YSDH, Comdes, ComResult);
                if (ComResult == 1)
                {
                    this.PrintfError("传输成功");
                }
                else
                {
                    this.PrintfError("传输失败");
                }
                string apppathxml = "../../webinfo/xml";
                string pathName   = Server.MapPath(apppathxml);
                if (!Directory.Exists(pathName))
                {
                    Directory.CreateDirectory(pathName);
                }
                doc.save(pathName + "/" + filename);
                SaveLocalXml(doc, Aroottag, YSDH);
            }
        }
        catch
        {
            this.PrintfError("上传出现错误,请确认服务器地址是否正确");
            return;
        }
    }
Exemplo n.º 7
0
		private void sendSMS(string sendMobilePhone)
		{
			if(sendMobilePhone.Length==11)
			{
				try
				{
					string spNumber = string.Empty;

					switch(sendMobilePhone.Substring(2,1))
					{
						case "0":
							spNumber = "9002733";
							break;
						case "1":
							spNumber = "9002733";
							break;
						case "2":
							spNumber = "9002733";
							break;
						case "3":
							spNumber = "9002733";
							break;
						case "4":
							spNumber = "9002733";
							break;
						case "5":
							spNumber = "8002733";
							break;
						case "6":
							spNumber = "8002733";
							break;
						case "7":
							spNumber = "8002733";
							break;
						case "8":
							spNumber = "8002733";
							break;
						case "9":
							spNumber = "8002733";
							break;
					}

					string url = "http://202.96.236.81:7783/testDownMsg.asp?"
						+"UID=sap&psd=0F3E419C71C500FA1FC8&source="+spNumber+"&mobile="
						+sendMobilePhone+"&message="+memoEdit_Content.Text;

					MSXML2.XMLHTTPClass xmlHttp = new MSXML2.XMLHTTPClass();
					xmlHttp.open("POST" , url , false , null , null  );          
					xmlHttp.setRequestHeader( "Accept-Lauguage" , "zh-cn" );    

					xmlHttp.send( null );          
                                    
					if(xmlHttp.status == 200)
					{
						if(xmlHttp.responseText == "0")
						{

							MessageBox.Show("短信发送成功!","成功!",
								MessageBoxButtons.OK,MessageBoxIcon.Information);
						}
						else
						{

							MessageBox.Show("短信发送失败,请重试!","出错了!",
								MessageBoxButtons.OK,MessageBoxIcon.Information);
							return;
						}
					}
					else
					{	
						MessageBox.Show("短信发送失败,请重试!","出错了!",
							MessageBoxButtons.OK,MessageBoxIcon.Information);
						return;
					}
				}
				catch(Exception ex)
				{
					MessageBox.Show(ex.Message);
				}
			}

			else
			{
				sendMobilePhone = sendMobilePhone.Substring(0,sendMobilePhone.Length-1);

				string[] sendMobilePhones = sendMobilePhone.Split(new char[]{','});

				foreach(string phoneNumber in sendMobilePhones)
				{
					try
					{
						string spNumber = string.Empty;

						switch(phoneNumber.Substring(2,1))
						{
							case "0":
								spNumber = "9002733";
								break;
							case "1":
								spNumber = "9002733";
								break;
							case "2":
								spNumber = "9002733";
								break;
							case "3":
								spNumber = "9002733";
								break;
							case "4":
								spNumber = "9002733";
								break;
							case "5":
								spNumber = "8002733";
								break;
							case "6":
								spNumber = "8002733";
								break;
							case "7":
								spNumber = "8002733";
								break;
							case "8":
								spNumber = "8002733";
								break;
							case "9":
								spNumber = "8002733";
								break;
						}

						string url = "http://202.96.236.81:7783/testDownMsg.asp?"
							+"UID=sap&psd=0F3E419C71C500FA1FC8&source="+spNumber+"&mobile="
							+phoneNumber+"&message="+memoEdit_Content.Text;

						XMLHTTP xmlHttp = new XMLHTTPClass();
						xmlHttp.open("POST" , url , false , null , null  );          
						xmlHttp.setRequestHeader( "Accept-Lauguage" , "zh-cn" );

						xmlHttp.send(null);

						if(xmlHttp.status == 200)
						{
							if(xmlHttp.responseText == "0")
							{
							}
							else
							{

								MessageBox.Show("短信发送失败,请重试!","出错了!",
									MessageBoxButtons.OK,MessageBoxIcon.Information);
								return;
							}
						}
						else
						{	
							MessageBox.Show("短信发送失败,请重试!","出错了!",
								MessageBoxButtons.OK,MessageBoxIcon.Information);
							return;
						}
					}
					catch(Exception ex)
					{
						MessageBox.Show(ex.Message,"出错了!",
							MessageBoxButtons.OK,MessageBoxIcon.Information);
					}
				}

				MessageBox.Show("操作完成!","完成!",
					MessageBoxButtons.OK,MessageBoxIcon.Information);
			}
		}