Пример #1
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <returns>登录成功返回信息</returns>
        private JsonLoginBack Login(string s, string d)
        {
            try
            {
                JsonLogin Loginfo = CreateLogininfo(s, d);
                //实体序列化和反序列化
                string        jsonData  = "jsonData=" + JsonHelper.SerializeObject(Loginfo);
                string        url       = "http://wl.yao1.cn:8899/scm/do/supply-chain/userlogin";
                string        LoginRst  = JsonHelper.HttpGet(url, jsonData);
                JsonLoginBack LoginBack = JsonHelper.DeserializeJsonToObject <JsonLoginBack>(LoginRst);
                if (LoginBack.header.respCode == "001")
                {
                    return(LoginBack);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception)
            {
                return(null);

                throw;
            }
        }
Пример #2
0
        public string MainFlow()
        {
            string instkif = HttpUtility.UrlDecode(StockInfo);
            //修改库存中tickect
            JsonStockInfo Stockinfo = JsonHelper.DeserializeJsonToObject <JsonStockInfo>(instkif);

            if (Stockinfo == null)
            {
                return("Failed! Message format is not correct!");
            }



            object obj = DBComm.ExecuteScalar("SELECT TOP 1 [Ticket] FROM [MergeData].[dbo].[YJS_Ticket]");

            if (obj == null)
            {
                //进行登录
                DataTable     dtser     = DBComm.ExecuteDataTable("SELECT TOP 1 [s],[d] FROM [MergeData].[dbo].[YSJ_SerNum]");
                string        s         = dtser.Rows[0]["s"].ToString();
                string        d         = dtser.Rows[0]["d"].ToString();
                JsonLoginBack LoginBack = Login(s, d);
                if (!IsLogin)
                {
                    if (LoginBack != null)
                    {
                        Ticket  = LoginBack.header.ticket[0];
                        IsLogin = true;
                    }
                    else
                    {
                        return("");
                    }
                }
                else
                {
                    return("");
                }
            }
            else
            {
                Ticket = obj.ToString();
            }

            Stockinfo.header.serailNumber = Ticket;
            string Inid = "'";

            for (int ctbdy = 0; ctbdy < Stockinfo.body.Count; ctbdy++)
            {
                Inid = Inid + Stockinfo.body[ctbdy].logisticsCode + "','";
                //Stockinfo.body[ctbdy].stockRemark = "共享库存";
            }



            //实体序列化和反序列化
            string        jsonData      = "jsonData=" + JsonHelper.SerializeObject(Stockinfo);
            string        url           = "http://wl.yao1.cn:8899/scm/do/dispatcher/erpStock/submitErpStock";
            string        LoginRst      = JsonHelper.HttpGet(url, jsonData);
            JsonLoginBack StockinfoBack = JsonHelper.DeserializeJsonToObject <JsonLoginBack>(LoginRst);

            if (StockinfoBack != null)
            {
                if (StockinfoBack.header.ticket == null)
                {
                    DBComm.ExecuteNonQuery_Simple("DELETE  FROM  [MergeData].[dbo].[YJS_Ticket] WHERE TICKET='" + Ticket + "'");
                    return("Failed! ID=" + Inid);
                }
                else
                {
                    string NewTicket = StockinfoBack.header.ticket[0] == null ? "" : StockinfoBack.header.ticket[0];
                    DBComm.ExecuteNonQuery_Simple("insert into [MergeData].[dbo].[YJS_Ticket] (Ticket,CreateDate)values('" +
                                                  NewTicket + "','" + DateTime.Now.ToString("yyyy-MM-dd") + "')");

                    DBComm.ExecuteNonQuery_Simple("DELETE  FROM  [MergeData].[dbo].[YJS_Ticket] WHERE TICKET='" + Ticket + "'");
                    return("Success! ID=" + Inid);
                }
            }
            else
            {
                return("Failed! ID=" + Inid);
            }
        }