Exemplo n.º 1
0
 public UnitOfWorkBase(string root)
 {
     _root           = root;
     CloudProviders  = new CloudProviderRepository(_root);
     Resources       = new ResourceRepository(_root);
     Infrastructures = new InfrastructureRepository(_root);
 }
Exemplo n.º 2
0
        public string GetFileUrl(GetFileUrlParameter param)
        {
            var repository = new InfrastructureRepository();
            var pathObj    = repository.QueryFilePath(new QueryFileParameter()
            {
                AppID   = param.AppID,
                FileKey = param.FileKey
            });
            string outFilePath = pathObj.VirtualPath, fileExt;
            var    size = param.ImageThumbnailSize;

            if (size.HasValue && ImageExts.Contains(fileExt = Path.GetExtension(pathObj.PhysicalPath)))
            {
                string filePath = Path.ChangeExtension(pathObj.PhysicalPath, string.Format("{0},{1}", size.Value.Width, size.Value.Height) + fileExt);
                try
                {
                    if (!File.Exists(filePath))
                    {
                        GDIHelper.MakeThumbnailImage(pathObj.PhysicalPath, filePath, size.Value.Width, size.Value.Height, ThumbnailMode.Zoom);
                    }
                    outFilePath = outFilePath.Replace(Path.GetFileName(pathObj.PhysicalPath), Path.GetFileName(filePath));
                }
                catch (Exception ex)
                {
                    App.LogError(ex, "GetFileUrl");
#if DEBUG
                    throw;
#endif
                }
            }
            return(_config.StorageUrl + outFilePath);
        }
Exemplo n.º 3
0
        public static void SendFindPwdSMS(Guid appID, string receiveMobile, int smsCode)
        {
            string msg = "您的密码修改网址是 " + WebHostUrl + "?authCode=" + receiveMobile + "," + smsCode + " ,请浏览页面完成修改。如非本人操作,可不予理会,谢谢。";
            var    svc = new InfrastructureRepository();

            svc.SendSMS(new SendSMSParameter()
            {
                AppID         = appID,
                ReceiveMobile = receiveMobile,
                SendMessage   = msg
            });
        }
Exemplo n.º 4
0
        public static void SendSignUpSMS(Guid appID, string receiveMobile, int smsCode)
        {
            string msg = "您的手机验证码是" + smsCode + ",请在页面填写验证码完成验证。如非本人操作,可不予理会,谢谢。";
            var    svc = new InfrastructureRepository();

            svc.SendSMS(new SendSMSParameter()
            {
                AppID         = appID,
                ReceiveMobile = receiveMobile,
                SendMessage   = msg
            });
        }
Exemplo n.º 5
0
        public void SaveFile(SaveFileParameter param)
        {
            Guid   checksum;
            string path;

            if (!TryGetPath(param, out checksum, out path))
            {
                return;
            }
            File.WriteAllBytes(path, param.FileData);
            var repository = new InfrastructureRepository();

            repository.SaveFile(checksum.ToString(), param.FileName, path);
        }
Exemplo n.º 6
0
        static void _transfer_Completed(object sender, TransferEventArgs e)
        {
            var    trans          = (FileTransfer)sender;
            var    header         = JsonConvert.DeserializeObject <JsonHeader>(e.Config.State.ToString());
            string sourceFilePath = string.Format(@"{0}{1}\{2}{3}", InfrastructureRepository.RootPath, trans.DirectoryPath, header.FileKey, Path.GetExtension(e.Config.FileName));

            if (header.FileKey != CryptoManaged.MD5HashFile(sourceFilePath).ToString())
            {
                File.Delete(sourceFilePath);
                return;
            }
            var repository = new InfrastructureRepository();

            repository.SaveFile(header.FileKey, e.Config.FileName, sourceFilePath);
        }
Exemplo n.º 7
0
        static void _transfer_Prepare(object sender, TransferEventArgs e)
        {
            var trans = (FileTransfer)sender;

            if (e.Config.State == null)
            {
                throw new InvalidOperationException("Config.State");
            }

            var header = JsonConvert.DeserializeObject <JsonHeader>(e.Config.State.ToString());

            trans.DirectoryPath = header.AppID.ToString("N");
            var repository = new InfrastructureRepository();

            e.Cancel = repository.ExistFile(new QueryFileParameter()
            {
                AppID   = header.AppID,
                FileKey = header.FileKey
            });
        }
Exemplo n.º 8
0
        public static void SendFindPwdEmail(Guid appID, string userName, string recipient, Guid authCode)
        {
            string        url    = WebHostUrl + "Resources/Email/FindPwd.htm";
            var           client = new HttpClient(new Uri(url));
            StringBuilder body   = new StringBuilder(client.GetResponse().GetResponseText());

            //TODO:替换变量
            body.Replace("{$UserName$}", userName);
            body.Replace("{$SiteUrl$}", WebHostUrl);
            body.Replace("{$FindUrl$}", WebHostUrl + "Account/ChangePwd.aspx?authCode=" + authCode.ToString());
            var svc = new InfrastructureRepository();

            svc.SendEmail(new SendEmailParameter()
            {
                AppID      = appID,
                Recipients = new string[] { recipient },
                Subject    = "找回密码帐户,请查收.",
                Body       = body.ToString()
            });
        }
Exemplo n.º 9
0
        public decimal GetSMSBalance(Guid configID)
        {
            var repository = new InfrastructureRepository();

            return(repository.GetSMSBalance(configID));
        }
Exemplo n.º 10
0
        public void SendSMS(SendSMSParameter param)
        {
            var repository = new InfrastructureRepository();

            repository.SendSMS(param);
        }
Exemplo n.º 11
0
        public void SendEmail(SendEmailParameter param)
        {
            var repository = new InfrastructureRepository();

            repository.SendEmail(param);
        }
Exemplo n.º 12
0
        public QueryFileResult QueryFile(QueryFileParameter param)
        {
            var repository = new InfrastructureRepository();

            return(repository.QueryFile(param));
        }