Beispiel #1
0
        private void SendWxToAdmin(BaoxiuBill bxBill)
        {
            Tiyi.Weixin.Work.Article article = new Tiyi.Weixin.Work.Article();
            article.Title = "设备故障报修";
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.AppendLine("设备类型:" + bxBill.BigClass + bxBill.AppType);
            sb.AppendLine("详细地址:" + bxBill.DepName + bxBill.Address);
            sb.AppendLine("联系方式:" + bxBill.UserName + " " + bxBill.UserMobilePhone + " (短号:" + bxBill.UserMobileShort + ")");
            sb.AppendLine("派工时间:" + DateTime.Now.ToString() + "\n");
            sb.AppendLine("故障现象:" + bxBill.FaultPhenomenon);
            sb.AppendLine("备注信息:" + bxBill.Remark);
            article.Description = sb.ToString();
            article.Url         = "";
            System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();
            string articleJson = js.Serialize(article);

            ws_wxSender.SendArticleToUser("101527", articleJson, "34");
        }
    protected void PaigongBillView_ItemCommand(object sender, FormViewCommandEventArgs e)
    {
        Guid bxId = Guid.Empty;

        Guid.TryParse(hfBxId.Value, out bxId);

        if (e.CommandName == "InsertBill")
        {
            Tiyi.JD.SQLServerDAL.BaoxiuBill bxBill = bll_baoxiu.GetBaoxiuBill(bxId);
            if (bxBill == null)
            {
                return;
            }

            Tiyi.JD.SQLServerDAL.PaigongBill pgBill = new Tiyi.JD.SQLServerDAL.PaigongBill();

            pgBill.BxId      = bxBill.BxId;
            pgBill.AppId     = bxBill.AppId;
            pgBill.ProductSN = bxBill.ProductSN;
            pgBill.BigClass  = bxBill.BigClass;
            pgBill.AppType   = bxBill.AppType;
            pgBill.DepName   = bxBill.DepName;


            TextBox tbUserName = formView.FindControl("tbUserName") as TextBox;
            pgBill.UserName = tbUserName.Text;

            TextBox tbUserMobilePhone = formView.FindControl("tbUserMobilePhone") as TextBox;
            pgBill.UserMobilePhone = tbUserMobilePhone.Text;

            TextBox tbUserMobileShort = formView.FindControl("tbUserMobileShort") as TextBox;
            pgBill.UserMobileShort = tbUserMobileShort.Text;

            TextBox tbAddress = formView.FindControl("tbAddress") as TextBox;
            pgBill.Address = tbAddress.Text;

            TextBox tbFaultPhenomenon = formView.FindControl("tbFaultPhenomenon") as TextBox;
            pgBill.FaultPhenomenon = tbFaultPhenomenon.Text;

            TextBox tbRemark = formView.FindControl("tbRemark") as TextBox;
            pgBill.Remark = tbRemark.Text;

            DropDownList ddlWxg = formView.FindControl("ddlWxg") as DropDownList;
            Guid         wxgId  = Guid.Empty;
            Guid.TryParse(ddlWxg.SelectedValue, out wxgId);
            Tiyi.JD.SQLServerDAL.Repairman wxg = bll_wxg.GetRepairmanById(wxgId);
            if (wxg != null)
            {
                pgBill.WxgId          = wxgId;
                pgBill.WxgRealName    = wxg.RealName;
                pgBill.WxgMobilePhone = wxg.MobilePhone;
                pgBill.WxgMobileShort = wxg.MobileShort;
            }


            Tiyi.JD.SQLServerDAL.PaigongBill newBill = bll_Paigong.CreatePaigongBill(pgBill);
            if (newBill != null && BillCreated != null)
            {
                hfPgId.Value = newBill.PgId.ToString();
                BillInsertedEventArgs args = new BillInsertedEventArgs(newBill);
                BillCreated(this, args);
            }
        }

        if (e.CommandName == "UpdateBill")
        {
            Guid pgId = Guid.Empty;
            Guid.TryParse(hfPgId.Value, out pgId);
            Tiyi.JD.SQLServerDAL.PaigongBill pgBill = bll_Paigong.GetPaigongBill(pgId);

            TextBox tbUserName = formView.FindControl("tbUserName") as TextBox;
            pgBill.UserName = tbUserName.Text;

            TextBox tbUserMobilePhone = formView.FindControl("tbUserMobilePhone") as TextBox;
            pgBill.UserMobilePhone = tbUserMobilePhone.Text;

            TextBox tbUserMobileShort = formView.FindControl("tbUserMobileShort") as TextBox;
            pgBill.UserMobileShort = tbUserMobileShort.Text;

            TextBox tbAddress = formView.FindControl("tbAddress") as TextBox;
            pgBill.Address = tbAddress.Text;

            TextBox tbFaultPhenomenon = formView.FindControl("tbFaultPhenomenon") as TextBox;
            pgBill.FaultPhenomenon = tbFaultPhenomenon.Text;

            TextBox tbRemark = formView.FindControl("tbRemark") as TextBox;
            pgBill.Remark = tbRemark.Text;

            DropDownList ddlWxg = formView.FindControl("ddlWxg") as DropDownList;
            Guid         wxgId  = Guid.Empty;
            Guid.TryParse(ddlWxg.SelectedValue, out wxgId);
            Tiyi.JD.SQLServerDAL.Repairman wxg = bll_wxg.GetRepairmanById(wxgId);
            if (wxg != null)
            {
                pgBill.WxgId          = wxgId;
                pgBill.WxgRealName    = wxg.RealName;
                pgBill.WxgMobilePhone = wxg.MobilePhone;
                pgBill.WxgMobileShort = wxg.MobileShort;
            }

            bll_Paigong.UpdatePaigongBill(pgBill);
            if (Updated != null)
            {
                Updated(this, new EventArgs());
            }
        }

        if (e.CommandName == "InsertCancel" || e.CommandName == "UpdateCancel")
        {
            if (Updated != null)
            {
                Updated(this, new EventArgs());
            }
        }

        if (e.CommandName == "EditBill")
        {
            formView.ChangeMode(FormViewMode.Edit);
        }

        if (e.CommandName == "WxRemind")
        {
            Guid pgId = Guid.Empty;
            Guid.TryParse(hfPgId.Value, out pgId);
            Tiyi.JD.SQLServerDAL.PaigongBill pgBill = bll_Paigong.GetPaigongBill(pgId);

            Tiyi.Weixin.Work.Article article = new Tiyi.Weixin.Work.Article();
            article.Title = "收到维修派工单";
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.AppendLine("设备类型:" + pgBill.BigClass + pgBill.AppType);
            sb.AppendLine("详细地址:" + pgBill.Address);
            sb.AppendLine("联系方式:" + pgBill.UserName + " " + pgBill.UserMobilePhone + " (短号:" + pgBill.UserMobileShort + ")");
            sb.AppendLine("派工时间:" + DateTime.Now.ToString() + "\n");
            sb.AppendLine("故障现象:" + pgBill.FaultPhenomenon);
            sb.AppendLine("备注信息:" + pgBill.Remark);
            article.Description = sb.ToString();
            article.Url         = "";
            System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();
            string articleJson = js.Serialize(article);
            ws_wxSender.SendArticleToUser("101527", articleJson, "34");

            Literal ltlSendWxResult = formView.FindControl("ltlSendWxResult") as Literal;
            ltlSendWxResult.Text = "微信提醒发送成功";
        }
    }