Example #1
0
        public static List <orderReport> Report(string fromdate, string todate)
        {
            var list = new List <orderReport>();
            var sql  = new StringBuilder();

            sql.AppendLine(String.Format("SELECT"));
            sql.AppendLine(String.Format("		ODD.ID"));
            sql.AppendLine(String.Format(",		ODD.SKU"));
            sql.AppendLine(String.Format(",		SUM(ISNULL(ODD.Quantity, 0)) AS Quantity"));
            sql.AppendLine(String.Format(",		SUM(ISNULL(ODD.Price, 0)) AS Price"));
            sql.AppendLine(String.Format(",		2 AS ExcuteStatus"));
            sql.AppendLine(String.Format(",		3 AS PaymentStatus"));
            sql.AppendLine(String.Format("FROM"));
            sql.AppendLine(String.Format("		tbl_Order AS ORD"));
            sql.AppendLine(String.Format("INNER JOIN tbl_OrderDetail AS ODD"));
            sql.AppendLine(String.Format("	ON 	ORD.ID = ODD.OrderID"));
            sql.AppendLine(String.Format("WHERE"));
            sql.AppendLine(String.Format("		CONVERT(datetime, ORD.DateDone, 121) BETWEEN CONVERT(datetime, '{0}', 121) AND CONVERT(datetime, '{1}', 121)", fromdate, todate));
            sql.AppendLine(String.Format("	AND ORD.ExcuteStatus = 2"));
            sql.AppendLine(String.Format("	AND ORD.PaymentStatus = 3"));
            sql.AppendLine(String.Format("GROUP BY"));
            sql.AppendLine(String.Format("		ODD.ID"));
            sql.AppendLine(String.Format(",		ODD.SKU"));
            sql.AppendLine(String.Format(";"));

            var reader = (IDataReader)SqlHelper.ExecuteDataReader(sql.ToString());

            while (reader.Read())
            {
                var entity = new orderReport();

                entity.ID = Convert.ToInt32(reader["ID"]);

                entity.SKU = reader["SKU"].ToString();

                entity.Quantity = Convert.ToDouble(reader["Quantity"]);

                entity.Price = Convert.ToDouble(reader["Price"]);

                entity.ExcuteStatus = Convert.ToInt32(reader["ExcuteStatus"]);

                entity.ExcuteStatus = Convert.ToInt32(reader["PaymentStatus"]);

                list.Add(entity);
            }
            reader.Close();
            return(list);
        }
Example #2
0
        public void ReplyDispatchReport()
        {
            SUTI rmsg = new SUTI();


            orgType sender = new orgType();

            sender.name      = "HTD";
            sender.idOrg.id  = "104:HTD_001";
            sender.idOrg.src = "SUTI";

            orgType receiver = new orgType();

            receiver.name      = "HUT";
            receiver.idOrg.id  = "801:HUT_001";
            receiver.idOrg.src = "SUTI";

            rmsg.orgReceiver = receiver;
            rmsg.orgSender   = sender;

            rmsg.msg = new List <SUTIMsg>();

            SUTIMsg msgResponse = new SUTIMsg();
            idType  id          = new idType();

            id.src                   = "104:HTD_001:MSGID";
            id.id                    = System.DateTime.Now.Ticks.ToString();
            msgResponse.idMsg        = id;
            msgResponse.msgName      = "OrderReport";
            msgResponse.msgType      = "6001";
            msgResponse.referencesTo = new msgReferencesTo();
            idType idOrder = new idType();

            idOrder.src = "KELA_ROUTEID";
            idOrder.id  = this.kela_id;
            List <idType> idList = new List <idType>();

            idList.Add(idOrder);

            msgResponse.referencesTo.idOrder = idList;
            if (smsg != null)
            {
                msgResponse.referencesTo.idMsg = smsg.msg[0].idMsg;
            }
            else
            {
                idType idMsg = new idType();
                idMsg.src = "901:HUT:MSGID";
                idMsg.id  = "12345";
                msgResponse.referencesTo.idMsg = idMsg;
            }

            idType idVehicle = new idType();

            idVehicle.id     = this.veh_nbr;
            idVehicle.src    = "104:HTD_001:VEHICLEID";
            idVehicle.unique = true;

            msgResponse.referencesTo.idVehicle = idVehicle;

            msgResponse.referencesTo.idOrder = idList;

            orderReport or = new orderReport();

            or.summaryReport = new List <summaryReport>();
            summaryReport sr = new summaryReport();

            sr.orderEnded = true;
            sr.vehicle    = this.veh_nbr;
            or.summaryReport.Add(sr);

            msgResponse.Item = or;
            //= new List<resourceType>;
            rmsg.msg.Add(msgResponse);

            try
            {
                log.InfoFormat("HTD->HUT " + rmsg.Serialize().ToString());
                //WebRequest request = WebRequest.Create("http://10.100.113.33:8202/default.aspx");
                string response = "<SOAP-ENV:Envelope xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:ZSI='http://www.zolera.com/schemas/ZSI/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body xmlns:ns1='http://tempuri.org/'><ns1:ReceiveSutiMsg><ns1:xmlstring>" +
                                  System.Web.HttpUtility.HtmlEncode(rmsg.Serialize().ToString()) +
                                  "</ns1:xmlstring></ns1:ReceiveSutiMsg></SOAP-ENV:Body></SOAP-ENV:Envelope>";

                byte[] buffer = Encoding.UTF8.GetBytes(response);

                WebRequest request = WebRequest.Create("http://192.168.222.11:7202/SUTI");
                request.Credentials = CredentialCache.DefaultCredentials;
                ((HttpWebRequest)request).UserAgent                 = "ASP.NET from HTD KELA SVC";
                ((HttpWebRequest)request).KeepAlive                 = false;
                ((HttpWebRequest)request).Timeout                   = System.Threading.Timeout.Infinite;
                ((HttpWebRequest)request).ReadWriteTimeout          = System.Threading.Timeout.Infinite;
                ((HttpWebRequest)request).ProtocolVersion           = HttpVersion.Version10;
                ((HttpWebRequest)request).AllowWriteStreamBuffering = false;
                ((HttpWebRequest)request).ContentLength             = buffer.Length;

                request.Method      = "POST";
                request.ContentType = "application/xml";
                Stream writer = request.GetRequestStream();

                log.InfoFormat("HTD->HUT " + response);
                writer.Write(buffer, 0, buffer.Length);
                writer.Close();

                // Response
                WebResponse resp = request.GetResponse();
                writer = resp.GetResponseStream();
                StreamReader rdr = new StreamReader(writer);
                log.InfoFormat("HUT->HTD " + rdr.ReadToEnd());
                rdr.Close();
                writer.Close();
                resp.Close();
            }
            catch (WebException exc)
            {
                log.InfoFormat("Error with KEEP ALIVE - {0}", exc.Message);
            }
            catch (ProtocolViolationException exc)
            {
                log.InfoFormat("Error with KEEP ALIVE - {0}" + exc.Message);
            }

            // *** Test Phase ***
            // ** Cancel Order and Notify *** //


            return;
        }