using BizCom; using BizCom.Enum; using SiteCore.Redis; using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.IO; using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; using Utils; namespace SiteCore.Handler { public partial class sync { public void distribute_xiumaster() { if(UrlPostParmsCheck("fid,uname,upwd")) { int fid = GetPostInt("fid"); string uname = GetPostString("uname"); string upwd = GetPostString("upwd"); SXiuMaster entity = SXiuMaster.Get(fid); if(entity!=null) { if (entity.UserID>0) { } else { SXiuUser userEntity = new SXiuUser(); userEntity.lgName = uname; userEntity.lgPwd = SecurityHelper.EncryptSymmetric(upwd); userEntity.State = 2; userEntity.Create(); entity.UserID = userEntity.ID; entity.Update(); } } returnSuccessMsg("操作成功"); } } public void resetpwd_xiumaster() { if (UrlPostParmsCheck("fid,uid,upwd")) { int fid = GetPostInt("fid"); int uid = GetPostInt("uid"); string upwd = GetPostString("upwd"); SXiuMaster entity = SXiuMaster.Get(fid); if (entity != null) { SXiuUser userEntity = SXiuUser.Get(uid); userEntity.lgPwd = SecurityHelper.EncryptSymmetric(upwd); userEntity.Update(); } returnSuccessMsg("操作成功"); } } public void get_xiurecord() { DataStruct dStruct = GetPostStruct(); List lw = new List(); string key = GetPostString("key"); if (key.Length > 0) lw.Add(string.Format("summary like '%{0}%'", key)); dStruct.Order = "addtime desc"; dStruct.MainWhere = string.Join(" and ", lw.ToArray()); DataTable dt = WebCache.GetData("view_XiuRecord", dStruct); writeGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)); } public void del_xiurecord() { if(UrlPostParmsCheck("rid")) { int rid = GetPostInt("rid"); SXiuRecord.Del(rid); returnSuccessMsg("删除成功"); } } public void receive_xiurecord() { if(UrlPostParmsCheck("rid,openid")) { int rid = GetPostInt("rid"); string openid = GetPostString("openid"); SXiuRecord entity = SXiuRecord.Get(rid); if (entity != null) { entity.State = (int)XiuState.Receive;// entity.ReceiveTime = DateTime.Now; entity.Update(); string form_key = "form_" + entity.UserID; string fid= xiuRedis.RedisHelper.ListLeftPop(form_key); if (fid != "") { XiuNotifyHelper.sendReceiveMsg(openid, fid, entity); } SXiuTiding.addTiding(rid, "wx", entity.UserID, "订单己受理", "工程师会尽快与你取得联系"); returnSuccessMsg("已接受"); } } } public void finish_xiurecord() { if (UrlPostParmsCheck("rid")) { int rid = GetPostInt("rid"); SXiuRecord entity = SXiuRecord.Get(rid); if (entity != null) { entity.State = (int)XiuState.Finish;// entity.Update(); returnSuccessMsg("已接受"); } } } public void get_xiumaster() { DataStruct dStruct = GetPostStruct(); List lw = new List(); string key = GetPostString("key"); if (key.Length > 0) lw.Add(string.Format("name like '%{0}%'", key)); dStruct.Order = "addtime desc"; dStruct.MainWhere = string.Join(" and ", lw.ToArray()); DataTable dt = WebCache.GetData("view_XiuMaster", dStruct); foreach(DataRow dr in dt.Rows) { dr["lgPwd"] = SecurityHelper.DecryptSymmetric(dr["lgPwd"].ToString()); } writeGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)); } public void save_xiumaster() { if (UrlPostParmsCheck("name")) { //,address,phone,contex int mid = GetPostInt("mid"); string name = GetPostString("name"); string phone = GetPostString("phone"); string duties = GetPostString("Duties"); string tids = GetPostString("tids"); string tags = GetPostString("Tags"); string intro = GetPostString("intro"); double star = GetPostDouble("star"); int sort = GetPostInt("sort"); //string lnglat = GetPostString("lnglat"); //string blnglat = GetPostString("blnglat"); SXiuMaster entity = null; if (mid > 0) entity = SXiuMaster.Get(mid); else entity = new SXiuMaster(); entity.Name = name; entity.Phone = phone; entity.Duties = duties; entity.Tids = tids; entity.Tags = tags; entity.Star = star; entity.Sort = sort; entity.Intro = getFormartBr(intro); //if (lnglat != "") //{ // string[] lArr = lnglat.Split(','); // entity.lng = lArr[0]; // entity.lat = lArr[1]; //} //if (blnglat != "") //{ // string[] lArr = blnglat.Split(','); // entity.blng = lArr[0]; // entity.blat = lArr[1]; //} //entity.Con = intro; if (mid > 0) entity.Update(); else { entity.AddTime = DateTime.Now; entity.Create(); } returnSuccessMsg("保存成功!"); } } public void del_xiumaster() { if (UrlPostParmsCheck("mid")) { int mid = GetPostInt("mid"); SXiuMaster.Del(mid); returnSuccessMsg("删除成功"); } } #region indexdev public void get_xiunav() { DataStruct dStruct = GetStruct(); IList lw = new List(); string key = GetPostString("key"); if (key.Length > 0) lw.Add(string.Format(" (title like '%{0}%' or tag like '%{0}%')", key)); if (lw.Count > 0) dStruct.SecondWhere = string.Join(" and ", lw.ToArray()); dStruct.Order = "sort asc"; DataTable dt = WebCache.GetData("s_xiunav", dStruct); writeGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)); } public void del_xiunav() { if (UrlParmsCheck("id")) { int id = GetInt("id"); SXiuNav.Del(id); returnSuccessMsg("删除成功!"); } } #endregion public void get_xiu_corp() { DataStruct dStruct = GetStruct(); List lw = new List(); dStruct.Order = "id desc"; dStruct.Fileds="*,(select count(0) from s_xiuuser where corpid=s_xiucorp.id) as uc"; DataTable dt = WebCache.GetData("S_XiuCorp", dStruct); writeGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)); } public void save_xiu_corp() { if (UrlPostParmsCheck("name")) { int sid = GetPostInt("sid"); string name = GetPostString("name"); string address = GetPostString("address"); string phone = GetPostString("phone"); string stime = GetPostString("stime"); string etime = GetPostString("etime"); string summary = GetPostString("summary"); string acc = GetPostString("acc"); string pwd = GetPostString("pwd"); bool isnew = false; SXiuCorp entity = null; if (sid > 0) entity = SXiuCorp.Get(sid); else { entity = new SXiuCorp(); isnew = true; } entity.Name = name; entity.Address = address; entity.Phone = phone; if (stime.Length > 0) entity.StartTime = Convert.ToDateTime(stime); if (etime.Length > 0) entity.EndTime = Convert.ToDateTime(etime); entity.Summary = summary; if (isnew) { entity.Create(); if (acc.Length > 0 && pwd.Length > 0) { SXiuUser uentity = new SXiuUser(); uentity.AddTime = DateTime.Now; isnew = true; uentity.lgName = acc; uentity.lgPwd = SecurityHelper.EncryptSymmetric(pwd); uentity.UserType = 2; uentity.CorpID = entity.ID; uentity.Create(); } } else entity.Update(); xiuRedis.RedisHelper.KeyDelete("xiu_corp"); returnSuccessMsg("保存成功"); } } public void del_xiu_corp() { if (UrlPostParmsCheck("cid")) { int cid = GetPostInt("cid"); SXiuCorp.Del(cid); xiuRedis.RedisHelper.KeyDelete("xiu_corp"); returnSuccessMsg("删除成功"); } } public void get_xiu_acc() { DataStruct dStruct = GetStruct(); //List lw = new List(); dStruct.Order = "id desc"; dStruct.Fileds = "*,STUFF((select ','+name from s_xiucorp where charindex(convert(varchar,id)+',',corpids+',')>0 for xml path('')),1,1,'') as cnames"; dStruct.MainWhere = "corpid=0 and usertype=1"; DataTable dt = WebCache.GetData("S_XiuUser", dStruct); foreach (DataRow dr in dt.Rows) { dr["lgPwd"] = SecurityHelper.DecryptSymmetric(dr["lgPwd"].ToString()); } writeGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)); } public void save_xiu_acc() { if (UrlPostParmsCheck("acc")) { int aid = GetPostInt("aid"); string acc = GetPostString("acc"); string pwd = GetPostString("pwd"); string name = GetPostString("name"); string mobile = GetPostString("mobile"); int st = GetPostInt("st"); int leader = GetPostInt("leader"); string cids = GetPostString("cids"); bool isnew = false; SXiuUser entity = null; if (aid > 0) entity = SXiuUser.Get(aid); else { entity = new SXiuUser(); entity.AddTime = DateTime.Now; isnew = true; } entity.lgName = acc; entity.lgPwd = SecurityHelper.EncryptSymmetric(pwd); entity.RealName = name ==""? acc : name; entity.Mobile = mobile; entity.State = st; entity.UserType = 1; entity.isLeader = leader == 1 ? true : false; entity.CorpIDs = cids; if (isnew) entity.Create(); else entity.Update(); returnSuccessMsg("保存成功"); } } public void del_xiu_acc() { if (UrlPostParmsCheck("aid")) { int aid = GetPostInt("aid"); SXiuUser.Del(aid); returnSuccessMsg("删除成功"); } } public void get_xiu_corpacc() { DataStruct dStruct = GetStruct(); //List lw = new List(); dStruct.Order = "id desc"; string cid = GetPostString("cid"); if (cid == "") { writeGridJson(0, "[]"); return; } dStruct.MainWhere = "corpid=" + cid; DataTable dt = WebCache.GetData("S_XiuUser", dStruct); foreach (DataRow dr in dt.Rows) { dr["lgPwd"] = SecurityHelper.DecryptSymmetric(dr["lgPwd"].ToString()); } writeGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)); } public void save_xiu_corpacc() { if (UrlPostParmsCheck("acc")) { int aid = GetPostInt("aid"); int cid = GetPostInt("cid"); string acc = GetPostString("acc"); string name = GetPostString("name"); string pwd = GetPostString("pwd"); string mobile = GetPostString("mobile"); int st = GetPostInt("st"); bool isnew = false; SXiuUser entity = null; if (aid > 0) entity = SXiuUser.GetByCorp(aid,cid); else { entity = new SXiuUser(); entity.AddTime = DateTime.Now; isnew = true; } entity.RealName = name; entity.lgName = acc; entity.lgPwd = SecurityHelper.EncryptSymmetric(pwd); entity.Mobile = mobile; entity.UserType = 2; entity.CorpID = cid; entity.State = st; if (isnew) entity.Create(); else entity.Update(); returnSuccessMsg("保存成功"); } } public void del_xiu_corpacc() { if (UrlPostParmsCheck("aid,cid")) { int aid = GetPostInt("aid"); int cid = GetPostInt("cid"); SXiuUser.DelCorpUser(aid, cid); returnSuccessMsg("删除成功"); } } //public void trades_sold_get() //{ // string sg = GetSign(); // string _url = "http://api.taoesoft.com/Api.aspx?action=executeTopApi&methodName=taobao.trades.sold.get&requestObjectJson=" + System.Text.Encoding.UTF8.GetBytes("{\"fields\":\"tid, type, status, payment, orders, rx_audit_status\"}")+"&SessionKey=2201404768885&format=1&sign=" + sg; // string xxx = Http(_url); // returnSuccessMsg(xxx); //} ///// ///// 不做catch处理,需要在外部做 ///// ///// ///// 默认GET,空则补充为GET ///// 默认json,空则补充为json ///// 请求头部 ///// 请求body内容 ///// //public static string Http(string url, string method = "POST", string contenttype = "application/json;charset=utf-8", Hashtable header = null, string data = null) //{ // HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); // request.Method = string.IsNullOrEmpty(method) ? "GET" : method; // request.ContentType = string.IsNullOrEmpty(contenttype) ? "application/json;charset=utf-8" : contenttype; // if (header != null) // { // foreach (var i in header.Keys) // { // request.Headers.Add(i.ToString(), header[i].ToString()); // } // } // if (!string.IsNullOrEmpty(data)) // { // Stream RequestStream = request.GetRequestStream(); // byte[] bytes = Encoding.UTF8.GetBytes(data); // RequestStream.Write(bytes, 0, bytes.Length); // RequestStream.Close(); // } // HttpWebResponse response = (HttpWebResponse)request.GetResponse(); // Stream ResponseStream = response.GetResponseStream(); // StreamReader StreamReader = new StreamReader(ResponseStream, Encoding.GetEncoding("utf-8")); // string re = StreamReader.ReadToEnd(); // StreamReader.Close(); // ResponseStream.Close(); // return re; //} } }