Esempio n. 1
0
 /// <summary>
 /// 开始养护花卉
 /// </summary>
 /// <param name="arrid">摆放的id</param>
 /// <returns></returns>
 public ActionResult StartCurFlowers(string arrid, string ownedUsersId)
 {
     try
     {
         Business.Sys_FlowerTreatment Sys_FlowerTreatment = new Business.Sys_FlowerTreatment();
         int userid = Utility.ChangeText.GetUsersId();
         Business.Sys_FlowerArrangement Sys_FlowerArrangement = new Business.Sys_FlowerArrangement();
         Model.FlowerArrangement        FlowerArrangement     = Sys_FlowerArrangement.GetModel(arrid);
         Model.FlowerTreatment          FTreatment            = Sys_FlowerTreatment.GetModelbyid(arrid.ToString(), ownedUsersId, userid.ToString());
         if (FTreatment == null || (FTreatment.endtime != null && FTreatment.State == "已完成"))//有了结束养护时间说明这个记录完成了
         {
             Model.FlowerTreatment  FlowerTreatment = new Model.FlowerTreatment();
             Business.Sys_UserAdmin Sys_UserAdmin   = new Business.Sys_UserAdmin();
             FlowerTreatment.FlowerTreatmentType = "开始养护";
             FlowerTreatment.State                  = "未完成";
             FlowerTreatment.UsersId                = userid;
             FlowerTreatment.ArrangementId          = arrid;
             FlowerTreatment.FlowerNumber           = FlowerArrangement.ShopId.ToString();
             FlowerTreatment.OwnedUsersId           = ownedUsersId;
             FlowerTreatment.UserRealName           = Utility.ChangeText.GetRealName();
             FlowerTreatment.FlowerTreatmentAddress = FlowerArrangement.arrangement;
             Model.UserAdmin UserAdmin = Sys_UserAdmin.GetUserAdminByUserId(Convert.ToInt32(FlowerTreatment.OwnedUsersId));
             FlowerTreatment.OwnedUsersRealName = UserAdmin.RealName;
             FlowerTreatment.OwnedCompany       = UserAdmin.OwnedCompany;
             FlowerTreatment.LogoPhoto          = UserAdmin.LogoPhoto;
             FlowerTreatment.starttime          = DateTime.Now;//记录开始养护时间
             ////同一登录人,同一公司,一天只能提交一次
             //StringBuilder stb = new StringBuilder();
             //if (userid != 0)
             //{
             //    stb.Append(" t.UsersId=" + userid + "");
             //}
             //if (!string.IsNullOrEmpty(FlowerTreatment.OwnedUsersId))
             //{
             //    stb.Append(" and t.OwnedUsersId='" + FlowerTreatment.OwnedUsersId + "'");
             //}
             //string dt = DateTime.Now.ToShortDateString();
             //{
             //    stb.Append(" and time>'" + dt + "'");
             //}
             //stb.Append(" and starttime !='' ");
             //Utility.Log.WriteTextLog("开始养护花卉", "arrid", arrid, "stb", stb.ToString());
             //if (Sys_FlowerTreatment.FlowerTreatmentList(stb.ToString()).Count == 0)
             //{
             Sys_FlowerTreatment.InsertFlowerTreatment(FlowerTreatment);
             return(Content("1"));
             //}
             //else
             //{
             //    return Content("0");//今天已经开始养护过了
             //}
         }
     }
     catch {
     }
     return(Json(new { resule = '1' }, JsonRequestBehavior.AllowGet));
 }
Esempio n. 2
0
 public ActionResult ConservationFlowers(Model.FlowerTreatment FlowerTreatment)
 {
     try
     {
         string x = string.Empty, y = string.Empty, strReturn = string.Empty;
         string apiurl = "http://api.map.baidu.com/geoconv/v1/?coords=" + Request["longitude"] + "," + Request["latitude"] + "&from=1&to=5&ak=Kl3rqGn6gECfy7mH5rS3fkGkaWYiyVlr";
         string detail = Utility.PostData.GetData(apiurl);
         ERP.MobleControllers.MMainController.BaiDuCoordinates jd     = JsonConvert.DeserializeObject <ERP.MobleControllers.MMainController.BaiDuCoordinates>(detail);
         List <ERP.MobleControllers.MMainController.bc_result> result = jd.result;
         foreach (var item in result)
         {
             x = item.x;
             y = item.y;
         }
         apiurl = "http://api.map.baidu.com/geocoder/v2/?ak=Kl3rqGn6gECfy7mH5rS3fkGkaWYiyVlr&callback=renderReverse&location=" + y + "," + x + "&output=json&pois=1";
         detail = Utility.PostData.GetData(apiurl);
         detail = detail.Replace("renderReverse&&renderReverse(", "");
         detail = detail.TrimEnd(')');
         ERP.MobleControllers.MMainController.GetAddressNew GetAddress = JsonConvert.DeserializeObject <ERP.MobleControllers.MMainController.GetAddressNew>(detail);
         Utility.Log.WriteTextLog("返回定位", "花卉养护当前地址", GetAddress.result.formatted_address, "detail", detail);
         Business.Sys_UserAdmin       Sys_UserAdmin       = new Business.Sys_UserAdmin();
         Business.Sys_FlowerTreatment Sys_FlowerTreatment = new Business.Sys_FlowerTreatment();
         int userid = Utility.ChangeText.GetUsersId();
         FlowerTreatment.FlowerTreatmentType    = "养护花卉";
         FlowerTreatment.UsersId                = userid;
         FlowerTreatment.OwnedUsersId           = Request["deptSelectItems"];
         FlowerTreatment.UserRealName           = Utility.ChangeText.GetRealName();
         FlowerTreatment.FlowerTreatmentAddress = GetAddress.result.formatted_address;
         Model.UserAdmin UserAdmin = Sys_UserAdmin.GetUserAdminByUserId(Convert.ToInt32(FlowerTreatment.OwnedUsersId));
         FlowerTreatment.OwnedUsersRealName = UserAdmin.RealName;
         FlowerTreatment.OwnedCompany       = UserAdmin.OwnedCompany;
         FlowerTreatment.LogoPhoto          = UserAdmin.LogoPhoto;
         //同一登录人,同一公司,一天只能提交一次
         StringBuilder stb = new StringBuilder();
         if (userid != 0)
         {
             stb.Append(" t.UsersId=" + userid + "");
         }
         if (!string.IsNullOrEmpty(FlowerTreatment.OwnedUsersId))
         {
             stb.Append(" and t.OwnedUsersId='" + FlowerTreatment.OwnedUsersId + "'");
         }
         string dt = DateTime.Now.ToShortDateString();
         {
             stb.Append(" and time>'" + dt + "'");
         }
         if (Sys_FlowerTreatment.FlowerTreatmentList(stb.ToString()).Count == 0)
         {
             Sys_FlowerTreatment.InsertFlowerTreatment(FlowerTreatment);
             return(Content("1"));
         }
         else
         {
             return(Content("0"));
         }
     }
     catch (Exception ex)
     {
         Utility.Log.WriteTextLog("返回定位错误", "ConservationFlowers", "养护花卉", "post方法", ex.ToString());
         return(View());
     }
 }
Esempio n. 3
0
        /// <summary>
        /// 扫码页面中的上传图片养护
        ///</summary>
        /// <returns></returns>
        public ActionResult Upload()
        {
            try
            {
                string             FlowerArrangementId = Request["FlowerArrangementId"];
                string             remarks             = Request["remarks"];
                HttpPostedFileBase files = Request.Files["file"];
                if (files == null)
                {
                    Utility.Log.WriteTextLog("扫码页面上传图片养护", "FlowerArrangementId", FlowerArrangementId, "files", files == null ? "true" : "fasle");
                    return(Json("Faild", JsonRequestBehavior.AllowGet));
                }

                Business.Sys_FlowerArrangement Sys_FlowerArrangement = new Business.Sys_FlowerArrangement();
                Model.FlowerArrangement        FlowerArrangement     = Sys_FlowerArrangement.GetModel(FlowerArrangementId);

                Business.Sys_UserAdmin Sys_UserAdmin = new Business.Sys_UserAdmin();

                Business.Sys_FlowerTreatment Sys_FlowerTreatment = new Business.Sys_FlowerTreatment();
                int userid = Utility.ChangeText.GetUsersId();
                Model.FlowerTreatment FTreatment = Sys_FlowerTreatment.GetModelbyArrid(FlowerArrangement.id.ToString(), FlowerArrangement.belongUsersId.ToString(), userid.ToString());
                if (FTreatment == null)//有未上传服务后图,不可以再提交
                {
                    string FilePath = Utility.ChangeText.SaveUploadPicture(files, "img");
                    Model.FlowerTreatment FlowerTreatment = new Model.FlowerTreatment();
                    FlowerTreatment.FlowerTreatmentType = "服务前";
                    FlowerTreatment.State                  = "未完成";
                    FlowerTreatment.UsersId                = userid;
                    FlowerTreatment.ArrangementId          = FlowerArrangement.id.ToString();
                    FlowerTreatment.FlowerNumber           = FlowerArrangement.ShopId.ToString();
                    FlowerTreatment.OwnedUsersId           = FlowerArrangement.belongUsersId.ToString();
                    FlowerTreatment.UserRealName           = Utility.ChangeText.GetRealName();
                    FlowerTreatment.FlowerTreatmentAddress = FlowerArrangement.arrangement;
                    Model.UserAdmin UserAdmin = Sys_UserAdmin.GetUserAdminByUserId(Convert.ToInt32(FlowerTreatment.OwnedUsersId));
                    FlowerTreatment.OwnedUsersRealName = UserAdmin.RealName;
                    FlowerTreatment.OwnedCompany       = UserAdmin.OwnedCompany;
                    FlowerTreatment.LogoPhoto          = UserAdmin.LogoPhoto;
                    FlowerTreatment.Photo      = FilePath; //提交图片
                    FlowerTreatment.ContentMsg = remarks;  //提交内容

                    if (Sys_FlowerTreatment.InsertFlowerTreatment(FlowerTreatment))
                    {
                        Model.Wx_SendMsg Wx_SendMsg = new Model.Wx_SendMsg()
                        {
                            template_id = "MU4CvSNXPYTMjhGJdWuWNvpc5Ls2VPAmcaST4lWrTaM",
                            touser      = Utility.ChangeText.GetOpenId(),
                            url         = "http://www.thuay.com/MMain/GetArrangementInfo?way=Arrangement&ArrangementId=" + FlowerArrangementId,
                            data        = new
                            {
                                first    = new { value = "您好!已经有客户(" + FlowerTreatment.OwnedCompany + ")需要服务,请尽快前往。", color = "#173177" },
                                keyword1 = new { value = FlowerTreatment.FlowerNumber, color = "#173177" },
                                keyword2 = new { value = "养护花卉", color = "#173177" },
                                keyword3 = new { value = "养护", color = "#173177" },
                                keyword4 = new { value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), color = "#173177" },
                                remark   = new { value = "详细内容:" + FlowerTreatment.ContentMsg + ".点击此消息,查看详情。", color = "#173177" },
                            }
                        };
                        WxHelper.WxMain.SendMsg(JsonConvert.SerializeObject(Wx_SendMsg));
                    }
                    return(Content("1"));
                }
                else
                {
                    return(Content("0"));//未完成
                }
            }
            catch (Exception ex)
            {
                Utility.Log.WriteTextLog("扫码页面上传图片养护报错", "FlowerArrangementId", "MFlower", "Upload", ex.ToString());
                return(null);
            }
        }