本文整理汇总了C#中ASC.Web.Studio.Utility.AjaxResponse类的典型用法代码示例。如果您正苦于以下问题:C# AjaxResponse类的具体用法?C# AjaxResponse怎么用?C# AjaxResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AjaxResponse类属于ASC.Web.Studio.Utility命名空间,在下文中一共展示了AjaxResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveUserLanguageSettings
public AjaxResponse SaveUserLanguageSettings(string lng)
{
var resp = new AjaxResponse();
try
{
var user = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);
var changelng = false;
if (SetupInfo.EnabledCultures.Find(c => String.Equals(c.Name, lng, StringComparison.InvariantCultureIgnoreCase)) != null)
{
if (user.CultureName != lng)
{
user.CultureName = lng;
changelng = true;
}
}
CoreContext.UserManager.SaveUserInfo(user);
if (changelng)
{
resp.rs1 = "1";
}
else
{
resp.rs1 = "2";
resp.rs2 = "<div class=\"okBox\">" + Resources.Resource.SuccessfullySaveSettingsMessage + "</div>";
}
}
catch (Exception e)
{
resp.rs1 = "0";
resp.rs2 = "<div class=\"errorBox\">" + e.Message.HtmlEncode() + "</div>";
}
return resp;
}
示例2: RemoveUser
public AjaxResponse RemoveUser(Guid userID)
{
var resp = new AjaxResponse();
try
{
SecurityContext.DemandPermissions(Constants.Action_AddRemoveUser);
var user = CoreContext.UserManager.GetUsers(userID);
var userName = user.DisplayUserName(false);
UserPhotoManager.RemovePhoto(Guid.Empty, userID);
CoreContext.UserManager.DeleteUser(userID);
MessageService.Send(HttpContext.Current.Request, MessageAction.UserDeleted, userName);
resp.rs1 = "1";
resp.rs2 = Resource.SuccessfullyDeleteUserInfoMessage;
}
catch(Exception e)
{
resp.rs1 = "0";
resp.rs2 = HttpUtility.HtmlEncode(e.Message);
}
return resp;
}
示例3: RemaindPwd
public AjaxResponse RemaindPwd(string email)
{
AjaxResponse responce = new AjaxResponse();
responce.rs1 = "0";
if (!email.TestEmailRegex())
{
responce.rs2 = "<div>" + Resources.Resource.ErrorNotCorrectEmail + "</div>";
return responce;
}
try
{
UserManagerWrapper.SendUserPassword(email);
responce.rs1 = "1";
responce.rs2 = String.Format(Resources.Resource.MessageYourPasswordSuccessfullySendedToEmail, email);
}
catch (Exception exc)
{
responce.rs2 = "<div>" + HttpUtility.HtmlEncode(exc.Message) + "</div>";
}
return responce;
}
示例4: SubscribeOnTopic
public AjaxResponse SubscribeOnTopic(int idTopic, int statusNotify)
{
var resp = new AjaxResponse();
if (statusNotify == 1 && Subscribe != null)
{
Subscribe(this, new SubscribeEventArgs(SubscriptionConstants.NewPostInTopic,
idTopic.ToString(),
SecurityContext.CurrentAccount.ID));
resp.rs1 = "1";
resp.rs2 = RenderTopicSubscription(false, idTopic);
resp.rs3 = "subscribed";
}
else if (UnSubscribe != null)
{
UnSubscribe(this, new SubscribeEventArgs(SubscriptionConstants.NewPostInTopic,
idTopic.ToString(),
SecurityContext.CurrentAccount.ID));
resp.rs1 = "1";
resp.rs2 = RenderTopicSubscription(true, idTopic);
resp.rs3 = "unsubscribed";
}
else
{
resp.rs1 = "0";
resp.rs2 = Resources.ForumResource.ErrorSubscription;
}
return resp;
}
示例5: RemindPwd
public AjaxResponse RemindPwd(string email)
{
var responce = new AjaxResponse {rs1 = "0"};
if (!email.TestEmailRegex())
{
responce.rs2 = "<div>" + Resource.ErrorNotCorrectEmail + "</div>";
return responce;
}
try
{
UserManagerWrapper.SendUserPassword(email);
responce.rs1 = "1";
responce.rs2 = String.Format(Resource.MessageYourPasswordSuccessfullySendedToEmail, "<b>" + email + "</b>");
var user = CoreContext.UserManager.GetUserByEmail(email).DisplayUserName(false);
MessageService.Send(HttpContext.Current.Request, MessageAction.UserSentPasswordChangeInstructions, user);
}
catch(Exception exc)
{
responce.rs2 = "<div>" + HttpUtility.HtmlEncode(exc.Message) + "</div>";
}
return responce;
}
示例6: SendJoinInviteMail
public AjaxResponse SendJoinInviteMail(string email)
{
email = (email ?? "").Trim();
AjaxResponse resp = new AjaxResponse();
resp.rs1 = "0";
try
{
if (!email.TestEmailRegex())
resp.rs2 = Resources.Resource.ErrorNotCorrectEmail;
var user = CoreContext.UserManager.GetUserByEmail(email);
if (!user.ID.Equals(ASC.Core.Users.Constants.LostUser.ID))
{
resp.rs1 = "0";
resp.rs2 = CustomNamingPeople.Substitute<Resources.Resource>("ErrorEmailAlreadyExists").HtmlEncode();
return resp;
}
var tenant = CoreContext.TenantManager.GetCurrentTenant();
if (tenant.TrustedDomainsType == TenantTrustedDomainsType.Custom)
{
var address = new MailAddress(email);
foreach (var d in tenant.TrustedDomains)
{
if (address.Address.EndsWith("@" + d, StringComparison.InvariantCultureIgnoreCase))
{
StudioNotifyService.Instance.InviteUsers(email, "", true, false);
resp.rs1 = "1";
resp.rs2 = Resources.Resource.FinishInviteJoinEmailMessage;
return resp;
}
}
}
else if (tenant.TrustedDomainsType == TenantTrustedDomainsType.All)
{
StudioNotifyService.Instance.InviteUsers(email, "", true, false);
resp.rs1 = "1";
resp.rs2 = Resources.Resource.FinishInviteJoinEmailMessage;
return resp;
}
resp.rs2 = Resources.Resource.ErrorNotCorrectEmail;
}
catch (FormatException)
{
resp.rs2 = Resources.Resource.ErrorNotCorrectEmail;
}
catch (Exception e)
{
resp.rs2 = HttpUtility.HtmlEncode(e.Message);
}
return resp;
}
示例7: SendInviteMails
public AjaxResponse SendInviteMails(string text, string emails, bool withFullAccessPrivileges)
{
SecurityContext.DemandPermissions(ASC.Core.Users.Constants.Action_AddRemoveUser);
AjaxResponse resp = new AjaxResponse();
resp.rs1 = "0";
try
{
SecurityContext.DemandPermissions(ASC.Core.Users.Constants.Action_AddRemoveUser);
string[] addresses = null;
try
{
addresses = StudioNotifyService.Instance.GetEmails(emails);
if (addresses == null || addresses.Length == 0)
resp.rs2 = Resources.Resource.ErrorNoEmailsForInvite;
else
{
foreach (var emailStr in addresses)
{
var email = (emailStr ?? "").Trim();
if (!email.TestEmailRegex())
{
resp.rs1 = "0";
resp.rs2 = email + " - " + Resources.Resource.ErrorNotCorrectEmail;
return resp;
}
var user = CoreContext.UserManager.GetUserByEmail(email);
if (!user.ID.Equals(ASC.Core.Users.Constants.LostUser.ID))
{
resp.rs1 = "0";
resp.rs2 = email + " - " + CustomNamingPeople.Substitute<Resources.Resource>("ErrorEmailAlreadyExists").HtmlEncode();
return resp;
}
}
StudioNotifyService.Instance.InviteUsers(emails, text, false, withFullAccessPrivileges);
resp.rs1 = "1";
resp.rs2 = Resources.Resource.FinishInviteEmailTitle;
}
}
catch
{
resp.rs2 = Resources.Resource.ErrorNoEmailsForInvite;
}
}
catch (Exception e)
{
resp.rs2 = HttpUtility.HtmlEncode(e.Message);
}
return resp;
}
示例8: TestSmtpSettings
public object TestSmtpSettings(string email)
{
AjaxResponse resp = new AjaxResponse();
if (!email.TestEmailRegex())
return new { Status = 0, Message = Resources.Resource.ErrorNotCorrectEmail };
try
{
SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);
MailMessage mail = new MailMessage();
mail.To.Add(email);
mail.Subject = Resources.Resource.TestSMTPEmailSubject;
mail.Priority = MailPriority.Normal;
mail.IsBodyHtml = false;
mail.BodyEncoding = System.Text.Encoding.UTF8;
mail.From = new MailAddress(CoreContext.Configuration.SmtpSettings.SenderAddress,
CoreContext.Configuration.SmtpSettings.SenderDisplayName,
System.Text.Encoding.UTF8);
mail.Body = Resources.Resource.TestSMTPEmailBody;
SmtpClient client = new SmtpClient(CoreContext.Configuration.SmtpSettings.Host, CoreContext.Configuration.SmtpSettings.Port ?? 25);
client.EnableSsl = CoreContext.Configuration.SmtpSettings.EnableSSL;
if (client.EnableSsl)
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;
}
if (String.IsNullOrEmpty(CoreContext.Configuration.SmtpSettings.CredentialsUserName))
{
client.UseDefaultCredentials = true;
}
else
{
client.Credentials = new NetworkCredential(
CoreContext.Configuration.SmtpSettings.CredentialsUserName,
CoreContext.Configuration.SmtpSettings.CredentialsUserPassword,
CoreContext.Configuration.SmtpSettings.CredentialsDomain);
}
client.Send(mail);
return new { Status = 1, Message = Resources.Resource.SuccessfullySMTPTestMessage };
}
catch (Exception e)
{
return new { Status = 0, Message = e.Message.HtmlEncode() };
}
}
示例9: RequestPayPal
public AjaxResponse RequestPayPal(int qoutaId)
{
var res = new AjaxResponse();
try
{
if (!HttpRuntime.Cache.Get(PartnerCache).Equals(DateTime.UtcNow))
HttpRuntime.Cache.Insert(PartnerCache, DateTime.UtcNow);
var partnerId = CoreContext.TenantManager.GetCurrentTenant().PartnerId;
var partner = CoreContext.PaymentManager.GetPartner(partnerId);
if (partner == null || partner.Status != PartnerStatus.Approved || partner.Removed || partner.PaymentMethod != PartnerPaymentMethod.PayPal)
{
throw new MethodAccessException(Resource.PartnerPayPalExc);
}
var tenantQuota = TenantExtra.GetTenantQuota(qoutaId);
var curruntQuota = TenantExtra.GetTenantQuota();
if (TenantExtra.GetCurrentTariff().State == TariffState.Paid
&& tenantQuota.ActiveUsers < curruntQuota.ActiveUsers
&& tenantQuota.Year == curruntQuota.Year)
{
throw new MethodAccessException(Resource.PartnerPayPalDowngrade);
}
if (tenantQuota.Price > partner.AvailableCredit)
{
CoreContext.PaymentManager.RequestClientPayment(partnerId, qoutaId, false);
throw new Exception(Resource.PartnerRequestLimitInfo);
}
var usersCount = TenantStatisticsProvider.GetUsersCount();
var usedSize = TenantStatisticsProvider.GetUsedSize();
if (tenantQuota.ActiveUsers < usersCount || tenantQuota.MaxTotalSize < usedSize)
{
res.rs2 = "quotaexceed";
return res;
}
res.rs1 = CoreContext.PaymentManager.GetButton(partner.Id, qoutaId);
}
catch (Exception e)
{
res.message = e.Message;
}
return res;
}
示例10: JoinToAffiliateProgram
public AjaxResponse JoinToAffiliateProgram()
{
var resp = new AjaxResponse();
try
{
resp.rs1 = "1";
resp.rs2 = AffiliateHelper.Join();
}
catch (Exception e)
{
resp.rs1 = "0";
resp.rs2 = HttpUtility.HtmlEncode(e.Message);
}
return resp;
}
示例11: RemindPwd
public AjaxResponse RemindPwd(string email)
{
var response = new AjaxResponse {rs1 = "0"};
if (!email.TestEmailRegex())
{
response.rs2 = "<div>" + Resource.ErrorNotCorrectEmail + "</div>";
return response;
}
var tenant = CoreContext.TenantManager.GetCurrentTenant();
if (tenant != null)
{
var settings = SettingsManager.Instance.LoadSettings<IPRestrictionsSettings>(tenant.TenantId);
if (settings.Enable && !IPSecurity.IPSecurity.Verify(tenant.TenantId))
{
response.rs2 = "<div>" + Resource.ErrorAccessRestricted + "</div>";
return response;
}
}
try
{
UserManagerWrapper.SendUserPassword(email);
response.rs1 = "1";
response.rs2 = String.Format(Resource.MessageYourPasswordSuccessfullySendedToEmail, "<b>" + email + "</b>");
var userInfo = CoreContext.UserManager.GetUserByEmail(email);
if (userInfo.Sid != null)
{
response.rs2 = "<div>" + Resource.CouldNotRecoverPasswordForLdapUser + "</div>";
return response;
}
string displayUserName = userInfo.DisplayUserName(false);
MessageService.Send(HttpContext.Current.Request, MessageAction.UserSentPasswordChangeInstructions, displayUserName);
}
catch(Exception ex)
{
response.rs2 = "<div>" + HttpUtility.HtmlEncode(ex.Message) + "</div>";
}
return response;
}
示例12: SaveNotifyBarSettings
public AjaxResponse SaveNotifyBarSettings(bool showPromotions)
{
AjaxResponse resp = new AjaxResponse();
_studioNotifyBarSettings = SettingsManager.Instance.LoadSettings<StudioNotifyBarSettings>(TenantProvider.CurrentTenantID);
_studioNotifyBarSettings.ShowPromotions = showPromotions;
if (SettingsManager.Instance.SaveSettings<StudioNotifyBarSettings>(_studioNotifyBarSettings, TenantProvider.CurrentTenantID))
{
resp.rs1 = "1";
resp.rs2 = "<div class=\"okBox\">" + Resources.Resource.SuccessfullySaveSettingsMessage + "</div>";
}
else
{
resp.rs1 = "0";
resp.rs2 = "<div class=\"errorBox\">" + Resources.Resource.UnknownError + "</div>";
}
return resp;
}
示例13: SaveLanguageTimeSettings
public object SaveLanguageTimeSettings(string lng, string timeZoneID)
{
var resp = new AjaxResponse();
try
{
SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);
var tenant = CoreContext.TenantManager.GetCurrentTenant();
var culture = CultureInfo.GetCultureInfo(lng);
var changelng = false;
if (SetupInfo.EnabledCultures.Find(c => String.Equals(c.Name, culture.Name, StringComparison.InvariantCultureIgnoreCase)) != null)
{
if (!String.Equals(tenant.Language, culture.Name, StringComparison.InvariantCultureIgnoreCase))
{
tenant.Language = culture.Name;
changelng = true;
}
}
var oldTimeZone = tenant.TimeZone;
tenant.TimeZone = new List<TimeZoneInfo>(TimeZoneInfo.GetSystemTimeZones()).Find(tz => String.Equals(tz.Id, timeZoneID));
CoreContext.TenantManager.SaveTenant(tenant);
if (!tenant.TimeZone.Id.Equals(oldTimeZone.Id) || changelng)
{
AdminLog.PostAction("Settings: saved language and time zone settings with parameters language={0},time={1}", lng, timeZoneID);
}
if (changelng)
{
return new { Status = 1, Message = String.Empty };
}
else
{
return new { Status = 2, Message = Resources.Resource.SuccessfullySaveSettingsMessage };
}
}
catch (Exception e)
{
return new { Status = 0, Message = e.Message.HtmlEncode() };
}
}
示例14: GetSuggest
public AjaxResponse GetSuggest(Guid settingsID, string text, string varName)
{
AjaxResponse resp = new AjaxResponse();
string startSymbols = text;
int ind = startSymbols.LastIndexOf(",");
if (ind != -1)
startSymbols = startSymbols.Substring(ind + 1);
startSymbols = startSymbols.Trim();
var tags = new List<Tag>();
if (!String.IsNullOrEmpty(startSymbols))
tags = ForumDataProvider.SearchTags(TenantProvider.CurrentTenantID, startSymbols);
int counter = 0;
string resNames = "", resHelps = "";
foreach (var tag in tags)
{
if (counter > 10)
break;
resNames += tag.Name + "$";
resHelps += tag.ID + "$";
counter++;
}
resNames = resNames.TrimEnd('$');
resHelps = resHelps.TrimEnd('$');
resp.rs1 = resNames;
resp.rs2 = resHelps;
resp.rs3 = text;
resp.rs4 = varName;
return resp;
}
示例15: SubscribeOnComments
public AjaxResponse SubscribeOnComments(Guid postID, int statusNotify)
{
var resp = new AjaxResponse();
try
{
if (statusNotify == 1)
{
_subscriptionProvider.Subscribe(
ASC.Blogs.Core.Constants.NewComment,
postID.ToString(),
IAmAsRecipient
);
resp.rs1 = "1";
resp.rs2 = RenderCommentsSubscription(false, postID);
}
else
{
_subscriptionProvider.UnSubscribe(
ASC.Blogs.Core.Constants.NewComment,
postID.ToString(),
IAmAsRecipient
);
resp.rs1 = "1";
resp.rs2 = RenderCommentsSubscription(true, postID);
}
}
catch (Exception e)
{
resp.rs1 = "0";
resp.rs2 = HttpUtility.HtmlEncode(e.Message);
}
return resp;
}