Esempio n. 1
0
        /// <summary>
        /// 数据库备份
        /// </summary>
        /// <param name="context"></param>
        /// <param name="msg"></param>
        /// <param name="P1"></param>
        /// <param name="P2"></param>
        /// <param name="UserInfo"></param>
        public void DBBACKUP(HttpContext context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
        {
            string strDBName = CommonHelp.GetConfig("DBBACKNAME");
            string path      = context.Server.MapPath("/");

            if (!Directory.Exists(path + "/dbbackup/"))
            {
                Directory.CreateDirectory(path + "/dbbackup/");
            }
            path = path + "/dbbackup/db_" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".bak";
            string strsql = "backup database " + strDBName + " to disk='" + path + "';";

            new JH_Auth_QYB().ExsSql(strsql);

            FileInfo  fi = new FileInfo(path);
            SZHL_DBGL sd = new SZHL_DBGL();

            sd.ComId  = UserInfo.QYinfo.ComId;
            sd.Type   = "1";
            sd.Name   = fi.Name;
            sd.Path   = fi.FullName;
            sd.Size   = (fi.Length / 1024.00).ToString("F2");
            sd.CRUser = UserInfo.User.UserName;
            sd.CRDate = DateTime.Now;
            new SZHL_DBGLB().Insert(sd);
        }
Esempio n. 2
0
        public static string SendSMS(string telephone, string content, int ComId = 0)
        {
            string err = "";

            try
            {
                string  dxqz         = "企捷科技";
                decimal amcountmoney = 0;
                var     qy           = new JH_Auth_QYB().GetEntity(d => d.ComId == ComId);
                if (qy != null)
                {
                    dxqz         = qy.DXQZ;
                    amcountmoney = qy.AccountMoney.HasValue ? qy.AccountMoney.Value : 0;
                }

                string[] tels = telephone.Trim().Replace(" ", "").Replace("\n", "").Replace("\r", "").Replace(',', ',').Split(',');

                //判断金额是否够
                decimal DXCost = decimal.Parse(CommonHelp.GetConfig("DXCost"));
                decimal amount = tels.Length * DXCost;
                if (ComId != 0 && amcountmoney < amount) //短信余额不足
                {
                    err = "短信余额不足";
                }
                else
                {
                    string re = "";
                    foreach (string tel in tels)
                    {
                        re = SendDX(tel, content + "【" + dxqz + "】", "");
                    }

                    err = "发送成功";

                    //扣款
                    if (ComId != 0 && qy != null)
                    {
                        qy.AccountMoney = qy.AccountMoney - amount;
                        new JH_Auth_QYB().Update(qy);

                        //记录明细
                        //SZHL_DDGL_ITEM im = new SZHL_DDGL_ITEM();
                        //im.ComId = qy.ComId;
                        //im.SerialID = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                        //im.Change = -amount;
                        //im.Balance = amcountmoney - amount;
                        //im.Memo = "短信消费";
                        //im.Status = "已消费";
                        //im.CRDate = DateTime.Now;

                        //new SZHL_DDGL_ITEMB().Insert(im);
                    }
                }
            }
            catch { }
            return(err);
        }
Esempio n. 3
0
        /// <summary>
        /// 注册新的文件接口
        /// 传入三个参数,qycode name 和description  第一个不能为空, 后两个可以为空,  第一个如果已经插入,就返回错误, 插入正确就返回true
        /// </summary>
        /// <param name="qycode"></param>
        /// <param name="strQYName"></param>
        /// <returns></returns>
        public void AddQycode(string qycode, string strQYName)
        {
            Dictionary <String, String> DATA = new Dictionary <String, String>();

            DATA.Add("qycode", qycode);
            DATA.Add("name", strQYName);
            string          strFileAPIRegUrl = CommonHelp.GetConfig("FileAPIReg").ToString() + "addqycode";
            HttpWebResponse ResponseData     = CommonHelp.CreatePostHttpResponse(strFileAPIRegUrl, DATA, 0, "", null);

            CommonHelp.GetResponseString(ResponseData);
        }
Esempio n. 4
0
        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="context"></param>
        /// <param name="msg"></param>
        /// <param name="P1"></param>
        /// <param name="P2"></param>
        /// <param name="UserInfo"></param>
        public void REGISTERNEW(HttpContext context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
        {
            JObject tt     = (JObject)JsonConvert.DeserializeObject(P1);
            string  qyName = tt["QYName"].ToString();
            var     qy     = new JH_Auth_QYB().GetEntity(p => p.QYName == qyName);

            if (qy != null)
            {
                msg.ErrorMsg = "企业名称已存在!";
            }
            if (tt["xm"].ToString() == "")
            {
                msg.ErrorMsg = "姓名不能为空!";
            }
            string mobile = tt["mobphone"].ToString();
            var    qy2    = new JH_Auth_QYB().GetEntities(p => p.Mobile == mobile);

            if (qy2.Count() > 0)
            {
                msg.ErrorMsg = "此手机已注册企业,请更换手机号继续注册";
            }
            if (string.IsNullOrEmpty(msg.ErrorMsg))
            {
                string QyScape  = CommonHelp.GetConfig("initSpace").ToString(); //公司初始控件
                string password = CommonHelp.GetMD5(tt["UserPass"].ToString());

                #region 判断获取不重复的qycode随机code,如果表中存在重复code,while继续获取,否则直接执行下一步
                bool   flag   = true;
                string qyCode = "";
                while (flag == true)
                {
                    //生成code随机数
                    Random ran = new Random((int)DateTime.Now.Ticks);
                    qyCode = ran.Next().ToString();
                    if (new JH_Auth_QYB().GetEntities(p => p.QYCode == qyCode).Count() == 0)
                    {
                        flag = false;
                        continue;
                    }
                }
                #endregion

                string fileUrl  = new FileHelp().GetFileServerUrl(qyCode);
                string userName = mobile;

                new JH_Auth_UserB().ExsSclarSql("exec RegistCompany '" + tt["QYName"].ToString() + "','" + tt["mobphone"].ToString() + "','" + userName + "','" + password + "','" + qyCode + "','" + fileUrl + "','" + tt["xm"].ToString() + "'," + QyScape);

                new FileHelp().AddQycode(qyCode, tt["QYName"].ToString());
                string content = "您的[" + tt["QYName"].ToString() + "]公司账号已经注册成功:\r\n登录网站: \r\n管理员账号:" + tt["mobphone"].ToString() + "\r\n管理员密码:" + tt["UserPass"].ToString() + "\r\n";
                CommonHelp.SendSMS(tt["mobphone"].ToString(), content, 0);
                string user = context.Request["ID"] ?? "";
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 数据库还原
        /// </summary>
        /// <param name="context"></param>
        /// <param name="msg"></param>
        /// <param name="P1"></param>
        /// <param name="P2"></param>
        /// <param name="UserInfo"></param>
        public void DBRESTORE(HttpContext context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
        {
            string strDBName = CommonHelp.GetConfig("DBBACKNAME");

            ArrayList list = new ArrayList();

            SqlConnection conn = new SqlConnection();

            conn.ConnectionString = new JH_Auth_QYB().GetDBString().Replace(strDBName, "master");
            conn.Open();
            try
            {
                SqlCommand    cmd = new SqlCommand("use master; select distinct spid FROM sysprocesses ,sysdatabases Where sysprocesses.dbid=sysdatabases.dbid AND sysdatabases.Name='" + strDBName + "'", conn);
                SqlDataReader dr  = cmd.ExecuteReader();
                while (dr.Read())
                {
                    list.Add(dr.GetInt16(0));
                }
                dr.Close();

                conn.Close();

                for (int i = 0; i < list.Count; i++)
                {
                    conn.Open();
                    SqlCommand cmd1 = new SqlCommand(string.Format("KILL {0}", list[i].ToString()), conn);
                    cmd1.ExecuteNonQuery();
                    conn.Close();
                }

                conn.Open();
                SqlCommand cmd2 = new SqlCommand("restore database " + strDBName + " from disk='" + P1 + "' with replace ;", conn);
                cmd2.ExecuteNonQuery();
                conn.Close();

                FileInfo  fi = new FileInfo(P1);
                SZHL_DBGL sd = new SZHL_DBGL();
                sd.ComId  = UserInfo.QYinfo.ComId;
                sd.Type   = "2";
                sd.Name   = fi.Name;
                sd.Path   = fi.FullName;
                sd.Size   = (fi.Length / 1024.00).ToString("F2");
                sd.CRUser = UserInfo.User.UserName;
                sd.CRDate = DateTime.Now;
                new SZHL_DBGLB().Insert(sd);
            }
            catch { msg.ErrorMsg = "还原失败"; }
            finally
            {
                conn.Close();
            }
        }
Esempio n. 6
0
        public void GETWXCONFIG(HttpContext context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
        {
            Dictionary <string, string> param = new Dictionary <string, string>();

            TimeSpan ts           = DateTime.Now - new DateTime(1970, 1, 1);
            long     timestamp    = Convert.ToInt64(ts.TotalSeconds);
            string   appId        = CommonHelp.GetConfig("AppId");
            string   jsapi_ticket = CommonHelp.AppConfig("jsapi_ticket");
            string   nonceStr     = CommonHelp.GetRandomString(15);
            string   url          = P1;

            string TOP_FIELD_SIGN = "";

            param.Add("timestamp", timestamp.ToString());
            param.Add("jsapi_ticket", jsapi_ticket);
            param.Add("noncestr", nonceStr);
            param.Add("url", url);

            SortedDictionary <string, string>            dic = new SortedDictionary <string, string>(param);
            IEnumerator <KeyValuePair <string, string> > em  = dic.GetEnumerator();
            // 第1步:把所有参数名和参数值串在一起
            StringBuilder query = new StringBuilder();

            while (em.MoveNext())
            {
                string key = em.Current.Key;
                if (!TOP_FIELD_SIGN.Equals(key, StringComparison.CurrentCultureIgnoreCase))
                {
                    string value = em.Current.Value;
                    if (!string.IsNullOrWhiteSpace(value) && !string.IsNullOrWhiteSpace(key))
                    {
                        query.Append("&").Append(key).Append("=").Append(value);
                    }
                }
            }
            query = new StringBuilder(query.ToString().TrimStart('&'));
            string querystring = HttpUtility.HtmlDecode(query.ToString());
            // 第2步:使用sha1加密
            string signature = WXFWHelp.EnSha1(querystring);

            msg.Result = new
            {
                appId = appId,
                //jsapi_ticket = jsapi_ticket,
                timestamp = timestamp,
                noncestr  = nonceStr,
                url       = url,
                //query = querystring,
                signature = signature
            };
        }
Esempio n. 7
0
        public void GETDXQTY(HttpContext context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
        {
            decimal DXCost = decimal.Parse(CommonHelp.GetConfig("DXCost"));

            if (UserInfo.QYinfo.ComId != 0)
            {
                int qty = (int)((UserInfo.QYinfo.AccountMoney.HasValue ? UserInfo.QYinfo.AccountMoney.Value : 0) / DXCost);
                msg.Result = qty.ToString();
            }
            else
            {
                msg.Result = "10000";
            }
        }
Esempio n. 8
0
        /// <summary>
        /// 获取文档资源
        /// </summary>
        /// <param name="context"></param>
        /// <param name="msg"></param>
        /// <param name="P1"></param>
        /// <param name="P2"></param>
        /// <param name="UserInfo"></param>
        public void GETWDZY(HttpContext context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
        {
            string strWDYM = CommonHelp.GetConfig("WDYM");

            FT_File ff = new FT_FileB().GetEntities(p => p.YLCode == P1).FirstOrDefault();

            if (ff != null)
            {
                msg.Result  = strWDYM + ff.YLPath;
                msg.Result1 = ff.YLCount;
                msg.Result2 = ff.Name + "." + ff.FileExtendName;
            }
            else
            {
                msg.ErrorMsg = "此文件不存在或您没有权限!";
            }
        }
Esempio n. 9
0
        public string SendSMS(string telephone, string content, int ComId = 0)
        {
            string err = "";

            try
            {
                string  dxqz         = "爱卡养车";
                decimal amcountmoney = 0;
                var     qy           = new JH_Auth_QYB().GetEntity(d => d.ComId == ComId);
                if (qy != null)
                {
                    dxqz         = qy.DXQZ;
                    amcountmoney = qy.AccountMoney.HasValue ? qy.AccountMoney.Value : 0;
                }

                string[] tels = telephone.Trim().Replace(" ", "").Replace("\n", "").Replace("\r", "").Replace(',', ',').Split(',');

                //判断金额是否够
                decimal DXCost = decimal.Parse(CommonHelp.GetConfig("DXCost"));
                decimal amount = tels.Length * DXCost;
                if (ComId != 0 && amcountmoney < amount) //短信余额不足
                {
                    err = "短信余额不足";
                }
                else
                {
                    string re = "";
                    foreach (string tel in tels)
                    {
                        re = CommonHelp.SendDX(tel, content + "【" + dxqz + "】", "");
                    }

                    err = "发送成功";

                    //扣款
                    if (ComId != 0 && qy != null)
                    {
                        qy.AccountMoney = qy.AccountMoney - amount;
                        new JH_Auth_QYB().Update(qy);
                    }
                }
            }
            catch { }
            return(err);
        }
Esempio n. 10
0
 public static string SendDX(string Mobile, string Content, string SendTime)
 {
     try
     {
         string    url = CommonHelp.GetConfig("DXURL") + "&Mobile=" + Mobile + "&Content=" + Content;
         WebClient WC  = new WebClient();
         WC.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
         int    p     = url.IndexOf("?");
         string sData = url.Substring(p + 1);
         url = url.Substring(0, p);
         byte[] postData     = Encoding.GetEncoding("gb2312").GetBytes(sData);
         byte[] responseData = WC.UploadData(url, "POST", postData);
         string returnData   = Encoding.GetEncoding("gb2312").GetString(responseData);
         return(returnData);
     }
     catch (Exception Ex)
     {
         return(Ex.Message);
     }
 }
Esempio n. 11
0
        /// <summary>
        /// 生命周期新加或者修改后给使用人发送短信
        /// </summary>
        /// <param name="ZCGLID"></param>
        public void SENDZCGLMSG(int ZCGLID)
        {
            SZHL_ZCGL ZC = new SZHL_ZCGLB().GetEntity(d => d.ID == ZCGLID);

            if (ZC != null)
            {
                JH_Auth_User USER = new JH_Auth_UserB().GetEntity(d => d.UserName == ZC.UserName);
                if (USER != null)
                {
                    string phone   = "13980444473";
                    string host    = CommonHelp.GetConfig("HostUrl");
                    string url     = CommonHelp.GetShortUrl(host + "/WX/bgxt/zc_Detail.html?id=" + ZCGLID);
                    string content = ZC.Name + "的生命周期发生变动,请查看" + url;
                    if (phone.Trim().Length > 0)
                    {
                        string message = "尊敬的" + USER.UserRealName.Trim() + "," + content;
                        if (CommonHelp.MarchPhoneNumber(phone))
                        {
                            string MASresult = CommonHelp.SendMAS(phone, message);
                        }
                    }
                }
            }
        }
Esempio n. 12
0
        /// <summary>
        /// 获取微信审批数据
        /// </summary>
        /// <param name="strSDate"></param>
        /// <param name="strEDate"></param>
        /// <returns></returns>
        public GetApprovalDataJsonResult GetWXSHData(string strSDate, string strEDate, string strLastNum = "")
        {
            AccessTokenResult Token        = CommonApi.GetToken(Qyinfo.corpId.Trim(), CommonHelp.GetConfig("WXLCDATA"));
            string            strReturn    = "";
            string            access_token = Token.access_token;

            GetApprovalDataJsonResult obj = OaDataOpenApi.GetApprovalData(access_token, DateTime.Parse(strSDate), DateTime.Parse(strEDate), 0);

            return(obj);
        }
Esempio n. 13
0
        /// <summary>
        /// 获取页面html(excel)
        /// </summary>
        /// <param name="context"></param>
        /// <param name="msg"></param>
        /// <param name="P1"></param>
        /// <param name="P2"></param>
        /// <param name="UserInfo"></param>
        public void GETHTML(HttpContext context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
        {
            string strWDYM = CommonHelp.GetConfig("WDYM");

            FT_File ff = new FT_FileB().GetEntities(p => p.YLCode == P1).FirstOrDefault();

            if (ff != null)
            {
                //定义局部变量
                HttpWebRequest  httpWebRequest  = null;
                HttpWebResponse httpWebRespones = null;
                Stream          stream          = null;
                string          htmlString      = string.Empty;
                string          url             = strWDYM + ff.YLPath;

                //请求页面
                try
                {
                    httpWebRequest = WebRequest.Create(url + ".html") as HttpWebRequest;
                }
                //处理异常
                catch
                {
                    msg.ErrorMsg = "建立页面请求时发生错误!";
                }
                httpWebRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; Maxthon 2.0)";
                //获取服务器的返回信息
                try
                {
                    httpWebRespones = (HttpWebResponse)httpWebRequest.GetResponse();
                    stream          = httpWebRespones.GetResponseStream();
                }
                //处理异常
                catch
                {
                    msg.ErrorMsg = "接受服务器返回页面时发生错误!";
                }

                StreamReader streamReader = new StreamReader(stream, System.Text.Encoding.UTF8);
                //读取返回页面
                try
                {
                    htmlString = streamReader.ReadToEnd();
                }
                //处理异常
                catch
                {
                    msg.ErrorMsg = "读取页面数据时发生错误!";
                }
                //释放资源返回结果
                streamReader.Close();
                stream.Close();

                msg.Result  = htmlString;
                msg.Result1 = url;
            }
            else
            {
                msg.ErrorMsg = "此文件不存在或您没有权限!";
            }
        }
Esempio n. 14
0
        public void CoverOffice(string strMD5, string strName, string strType, JH_Auth_UserB.UserInfo UserInfo)
        {
            string CovOfficeUrl = CommonHelp.GetConfig("Covoffice").ToString();

            if (CovOfficeUrl != "")
            {
                Task <string> TaskCover = Task.Factory.StartNew <string>(() =>
                {
                    Dictionary <String, String> DATA = new Dictionary <String, String>();
                    DATA.Add("downloadUrl", UserInfo.QYinfo.FileServerUrl + strMD5);
                    if (strType.ToLower().Contains("pdf"))
                    {
                        DATA.Add("convertType", "14");
                    }
                    else
                    {
                        DATA.Add("convertType", "0");
                    }
                    HttpWebResponse ResponseData = CommonHelp.CreatePostHttpResponse(CovOfficeUrl, DATA, 0, "", null);
                    string Returndata            = CommonHelp.GetResponseString(ResponseData);
                    JObject json  = (JObject)JsonConvert.DeserializeObject(Returndata);
                    JArray array  = (JArray)json["data"];
                    string strUrl = array[0].ToString();

                    string strYear  = DateTime.Now.Year.ToString();
                    string strMonth = DateTime.Now.Month.ToString();
                    string strUrl1  = string.Empty;
                    string strSum   = GetWDPages(CovOfficeUrl, UserInfo.QYinfo.FileServerUrl + strMD5, strType);
                    string strPath  = UserInfo.QYinfo.QYCode + "/" + strYear + "/" + strMonth + strUrl.Substring(strUrl.LastIndexOf('/'), strUrl.Length - strUrl.LastIndexOf('/'));
                    string strWDIP  = CommonHelp.GetConfig("WDIP");
                    string strWDDK  = CommonHelp.GetConfig("WDDK");

                    if (strWDIP != "" && strWDDK != "")
                    {
                        IPAddress ip        = IPAddress.Parse(strWDIP);
                        Socket clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                        try
                        {
                            string str = strUrl.Substring(strUrl.LastIndexOf('/') + 1, strUrl.Length - strUrl.LastIndexOf('/') - 6);
                            strUrl1    = "/ViewV5/Base/" + strType.Substring(0, 3) + ".html?code=" + str;
                            int dk     = Int32.Parse(strWDDK);
                            clientSocket.Connect(new IPEndPoint(ip, dk));                                                                                    //配置服务器IP与端口
                            clientSocket.Send(Encoding.ASCII.GetBytes(str + "_" + UserInfo.QYinfo.QYCode + "_" + strYear + "_" + strMonth + "_" + strType)); //发送请求到服务器
                            //采用新接口获取页码
                            string SQL = string.Format("update FT_File set YLUrl='{0}',ISYL='Y',YLCode='{2}',YLPath='{3}',YLCount='{4}' WHERE FileMD5='{1}'", strUrl1, strMD5, str, strPath.Substring(0, strPath.Length - 5), strSum);
                            Debug.WriteLine("d" + DateTime.Now);

                            new FT_FileB().ExsSclarSql(SQL);
                        }
                        catch (Exception ex)
                        {
                            CommonHelp.WriteLOG(ex.ToString());
                        }
                    }

                    return(strUrl.Replace(":8000", ""));
                });

                TaskCover.ContinueWith((task) =>
                {
                    try
                    {
                        System.Diagnostics.Debug.WriteLine(DateTime.Now);
                        string strUrl = TaskCover.Result;
                    }
                    catch (Exception ex)
                    {
                        CommonHelp.WriteLOG(ex.ToString());
                    }
                });
            }
        }
Esempio n. 15
0
        //获取文件服务器
        public string GetFileServerUrl(string qycode)
        {
            string strFileAPIRegUrl = CommonHelp.GetConfig("FileAPIReg").ToString() + qycode + "/document/";

            return(strFileAPIRegUrl);
        }