| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486 |
- 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<string> lw = new List<string>();
- 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<string>(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<string> lw = new List<string>();
- 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<string> lw = new List<string>();
- 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<string> lw = new List<string>();
- 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<string> lw = new List<string>();
- 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<string> lw = new List<string>();
- 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);
- //}
- ///// <summary>
- ///// 不做catch处理,需要在外部做
- ///// </summary>
- ///// <param name="url"></param>
- ///// <param name="method">默认GET,空则补充为GET</param>
- ///// <param name="contenttype">默认json,空则补充为json</param>
- ///// <param name="header">请求头部</param>
- ///// <param name="data">请求body内容</param>
- ///// <returns></returns>
- //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;
- //}
- }
- }
|