Exemple #1
0
        public static string GetLicence()
        {
            var licence = Configs.GetValue("LicenceKey");

            if (string.IsNullOrEmpty(licence))
            {
                licence = Common.GuId();
                Configs.SetValue("LicenceKey", licence);
            }
            return(EncryptProvider.Md5(licence, Internal.MD5Length.L32));
        }
Exemple #2
0
        public static string GetLicence()
        {
            var licence = Configs.GetValue("LicenceKey");

            if (string.IsNullOrEmpty(licence))
            {
                licence = Common.GuId();
                Configs.SetValue("LicenceKey", licence);
            }
            return(Md5.md5(licence, 32));
        }
        /// <summary>
        /// 短信发送
        /// </summary>
        /// <param name="msg">信息</param>
        /// <param name="phones">电话</param>
        /// <returns></returns>
        public static string sendMsg(string msg, string phones)
        {
            string un          = Configs.GetValue("Account").Trim();
            string pw          = DESEncrypt.Decrypt(Configs.GetValue("Password").Trim());//解密
            string PostUrl     = Configs.GetValue("PostUrl").Trim();
            string Msgtitle    = Configs.GetValue("Msgtitle").Trim();
            string content     = Msgtitle + HttpContext.Current.Server.UrlEncode(msg);
            string postJsonTpl = "\"account\":\"{0}\",\"password\":\"{1}\",\"phone\":\"{2}\",\"report\":\"true\",\"msg\":\"{3}\"";
            string jsonBody    = string.Format(postJsonTpl, un, pw, phones, content);
            string result      = doPostMethodToObj(PostUrl, "{" + jsonBody + "}");//请求地址请登录zz.253.com获取

            return(result);
        }
        public static bool IsLicence(string key)
        {
            throw new NotImplementedException();
            string host = "";// HttpContext.Current.Request.Host.Host.ToLower();

            if (host.Equals("localhost"))
            {
                return(true);
            }
            string licence = Configs.GetValue("LicenceKey");

            if (licence != null && licence == Md5.md5(key, 32))
            {
                return(true);
            }

            return(false);
        }
Exemple #5
0
        /// <summary>
        /// 图片上传保存
        /// </summary>
        /// <param name="files"></param>
        /// <returns></returns>
        public static UpLoadResult UploadImage(HttpPostedFileBase files)
        {
            UpLoadResult uploadResult = new UpLoadResult();
            DateTime     N            = System.DateTime.Now;
            Random       R            = new Random();

            if (files.ContentLength > 0)
            {
                HttpPostedFileBase PostFile = files;
                //新的文件名称
                string AttachmentsName = N.Year.ToString() + N.Month.ToString() + N.Day.ToString() + N.Hour.ToString() + N.Minute.ToString() + N.Second.ToString() + R.Next();
                //文件后缀
                string FileExt = System.IO.Path.GetExtension(PostFile.FileName).ToLower();
                if (("|.jpg|.png|.jepg|").IndexOf("|" + FileExt + "|") < 0)   //判断上传附件是否是允许上传的附件
                {
                    uploadResult.file_path = "";
                    uploadResult.result    = "请上传类型为.jpg|.png|.jepg|的图片";
                }
                StringBuilder sb       = new StringBuilder();
                string        filename = AttachmentsName;
                //从配置文件中获取图片保存的路径
                var path = Configs.GetValue("ImgSrc");
                if (!FileHelper.IsExistDirectory(path))
                {
                    FileHelper.CreateDir(path);
                }
                PostFile.SaveAs(path + filename + "." + FileExt);
                uploadResult.file_path = path + filename + "." + FileExt;
                uploadResult.result    = "上传成功";
            }
            else
            {
                uploadResult.file_path = "";
                uploadResult.result    = "没有选择要上传的文件";
            }
            return(uploadResult);
        }
Exemple #6
0
        public static FileModel Upload(HttpPostedFileBase postedFile)
        {
            //上传和返回(保存到数据库中)的路径
            string      uppath   = string.Empty;
            string      savepath = string.Empty;
            HttpContext context  = HttpContext.Current;
            //创建图片新的名称
            string nameImg = DateTime.Now.ToString("yyyyMMddHHmmssfff");
            string strPath = postedFile.FileName;
            string type    = strPath.Substring(strPath.LastIndexOf(".") + 1).ToLower();

            if (ValidateImg(postedFile))
            {
                //拼写上传图片的路径
                savepath  = context.Server.MapPath(Configs.GetValue("FileSrc") + type + "/");
                savepath += nameImg + "." + type;
                uppath    = context.Server.MapPath(Configs.GetValue("FileSrc")) + type;
                FileHelper.CreateDirectory(uppath);
                FileHelper.CreateDirectory(uppath + "/水印"); //水印图片地址
                FileHelper.CreateDirectory(uppath + "/文字"); //文字图片地址
                //uppath += nameImg + "." + type;
                //上传图片
                postedFile.SaveAs(savepath);
                ImageManager writer = new ImageManager();

                //调用很简单 im.SaveWatermark(原图地址, 水印地址, 透明度, 水印位置, 边距,保存到的位置);
                writer.SaveWatermark(savepath, context.Server.MapPath(Configs.GetValue("FileSrc")) + "Logo.png", 0.9f, ImageManager.WatermarkPosition.RigthBottom, 10, uppath + "/水印/" + nameImg + "." + type);
                writer.AddTextToImg(savepath, "蓝色星球", uppath + "/文字/" + nameImg + "." + type);
            }
            return(new FileModel()
            {
                RealName = nameImg + "." + type,
                FileName = strPath,
                FileMax = postedFile.ContentLength.ToString()
            });
        }
Exemple #7
0
 public static string SEOSiteName()
 {
     return(Configs.GetValue("SiteName"));
 }