/// <summary> /// Gets the file locked user id. /// </summary> /// <param name="fileUrl">The file URL.</param> /// <returns></returns> public static UserLight GetFileLockedUserId(string fileUrl) { UserLight retVal = null; try { WebDavTicket ticket = WebDavUrlBuilder.GetWebDavTicket(fileUrl); WebDavAbstractFactory factory = new WebDavAbstractFactory(); WebDavPropertyStorage provider = factory.Create <WebDavElementStorageProvider>(ticket.AbsolutePath.StorageType) as WebDavPropertyStorage; if (provider != null) { WebDavElementInfo elInfo = provider.GetElementInfo(ticket.ToString()); foreach (ActiveLockElement activeLock in provider.GetActiveLocks(elInfo)) { UserLight user = UserLight.Load(activeLock.Owner); if (user != null) { retVal = user; break; } } } } catch (System.Exception) { } return(retVal); }
private void CheckExternal() { if (ExternalLogin != null && ExternalID != null) { try { if (Mediachase.IBN.Business.Configuration.LicenseExpired) { throw new Mediachase.Ibn.LicenseExpiredException(); } int EUserID = Security.UserLoginByExternalGate((int)ExternalObjectType, ExternalObjectID, ExternalID, ExternalLogin); string path = HttpRuntime.AppDomainAppVirtualPath; if (path == "/") { path = ""; } SetAuthCookie(path + "/External", ExternalLogin, false, EUserID); HttpContext.Current.Items.Remove("userlight"); UserLight userLight = UserLight.Load(EUserID); UserLightPropertyCollection pc = userLight.Properties; HttpContext context = HttpContext.Current; context.Items.Add("userlight", userLight); //Response.Redirect(Server.UrlDecode(Request["ReturnUrl"])); // O.R. [2008-04-15] Response.Redirect(Request["ReturnUrl"], true); } catch { } } }
/// <summary> /// Authenticates the specified credentials. /// </summary> /// <param name="credentials">The credentials.</param> private void Authenticate(NetworkCredential credentials) { try { string sUserLight = "userlight"; UserLight currentUser = SessionPrincipal; if (currentUser == null) { // check user's name and password here currentUser = Security.GetUser(credentials.UserName, credentials.Password); //store user to web service session SessionPrincipal = currentUser; } if (HttpContext.Current.Items.Contains(sUserLight)) { HttpContext.Current.Items.Remove(sUserLight); } HttpContext.Current.Items.Add(sUserLight, currentUser); HttpContext.Current.User = new GenericPrincipal(new GenericIdentity(currentUser.Login), null); DataContext.Current.CurrentUserId = Security.CurrentUser.UserID; DataContext.Current.CurrentUserTimeZone = Security.CurrentUser.CurrentTimeZone; } catch (Exception e) { throw SoapErrorCreator.RaiseException(HttpContext.Current.Request.Url.ToString(), new SyncronizationServiceError(SyncronizationServiceError.eServiceErrorType.AuthFailed, e), false); } }
public bool PostComment(string text, string type, string userFrom, string id) { if (!IsUser(userFrom)) { return(false); } var table = ReaderHelper.GetCommentsTable(type); if (table == "") { return(false); } using (_connection = new SqlConnection(Global.WaifString)) { _connection.Open(); using (var cmd = new SqlCommand("SELECT Name FROM Users WHERE Id=@Id", _connection)) { cmd.Parameters.AddWithValue("Id", userFrom); if (String.IsNullOrEmpty(cmd.ExecuteScalar().ToString())) { return(false); } } var postedId = ""; using (var cmd = new SqlCommand("INSERT INTO " + table + " VALUES(@UserId, @Id, @Text, " + "GETDATE()); SELECT TOP 1 Id FROM " + table + " ORDER BY Id DESC;", _connection)) { cmd.Parameters.AddWithValue("UserId", userFrom); cmd.Parameters.AddWithValue("Id", id); cmd.Parameters.AddWithValue("Text", text); postedId = cmd.ExecuteScalar().ToString(); } /* Comment reply notification section */ var ind = text.IndexOf("methods.replyHover("); if (ind != -1) { var tempText = text; ind += 19; tempText = tempText.Substring(ind); tempText = tempText.Remove(tempText.IndexOf("this")); var parameters = tempText.Split(','); var userToId = ""; using (var cmd = new SqlCommand("SELECT UserFrom FROM " + table + " WHERE Id=@Id", _connection)) { cmd.Parameters.AddWithValue("Id", parameters[1]); userToId = cmd.ExecuteScalar().ToString(); } UserLight user = new UserLight(); user.LoadById(userFrom); var notifyContent = String.Format("Пользователь <a href=\"/profile/{0}\">{0}</a> " + "ответил на ваш <a onmouseover=\"notifyCommentHover('{1}',{2}, '{3}',this);\">" + "комментарий</a>", user.Login, type, postedId, id); Notification.AddNew(userToId, notifyContent, false, user.Image, "/profile/" + user.Login); } } return(true); }
private void CheckExternal(string _containerKey) { if (!String.IsNullOrEmpty(ExtId)) { try { string[] mas = _containerKey.Split('_'); int ObjectTypeId = -1; switch (mas[0].ToLower()) { case "taskid": ObjectTypeId = (int)ObjectTypes.Task; break; case "todoid": ObjectTypeId = (int)ObjectTypes.ToDo; break; case "eventid": ObjectTypeId = (int)ObjectTypes.CalendarEntry; break; case "documentid": case "documentvers": ObjectTypeId = (int)ObjectTypes.Document; break; case "incidentid": ObjectTypeId = (int)ObjectTypes.Issue; break; default: break; } if (Mediachase.IBN.Business.User.CheckUserIdByExternalGate(ObjectTypeId, int.Parse(mas[1]), int.Parse(ExtId))) { UserLight userLight = UserLight.Load(int.Parse(ExtId)); HttpContext context = HttpContext.Current; context.Items.Add("userlight", userLight); } else { throw new AccessDeniedException(); } } catch { throw new AccessDeniedException(); } } }
/// <summary> /// Generates the list channel items. /// </summary> /// <param name="rssChannel">The RSS channel.</param> /// <returns></returns> private string GenerateListChannelItems(RssChannel rssChannel) { DateTime lastBuildDate = DateTime.MinValue; MetaClass listMetaClass = DataContext.Current.GetMetaClass(this.Parameters.ClassName); foreach (EntityObject item in BusinessManager.List(this.Parameters.ClassName, this.CurrentProfile.Filters.ToArray(), this.CurrentProfile.Sorting.ToArray())) { RssItem rssItem = new RssItem(); rssItem.Guid = new RssGuid(); rssItem.Title = string.IsNullOrEmpty(listMetaClass.TitleFieldName) ? ("#" + item.PrimaryKeyId.Value.ToString()) : (string)item[listMetaClass.TitleFieldName]; rssItem.Link = MakeFullLink(this.Page.ResolveUrl(string.Format(CultureInfo.CurrentUICulture, "~/Apps/MetaUIEntity/Pages/EntityList.aspx?ClassName={0}", listMetaClass.Name))); rssItem.Guid.IsPermaLink = "false"; rssItem.Guid.Text = item.PrimaryKeyId.Value.ToString(); rssItem.Description = RenderListEntityObjectDescription(listMetaClass, item); DateTime modified = (DateTime)item["Modified"]; if (modified > lastBuildDate) { lastBuildDate = modified; } rssItem.PubDate = RssXmlHelper.ToRfc822(modified); UserLight author = UserLight.Load((int)item["ModifierId"]); if (author != null) { rssItem.Author = string.Format("{0} <{1}>", author.DisplayName, author.Email); } rssChannel.Items.Add(rssItem); } if (lastBuildDate == DateTime.MinValue) { lastBuildDate = DateTime.Now; } return(RssXmlHelper.ToRfc822(lastBuildDate)); }
private void CheckQueryLogin() { if (RegularLogin != null && RegularPassword != null && RegularRedirect != null) { try { int iUserId = Security.UserLogin(RegularLogin, RegularPassword); if (Mediachase.IBN.Business.Configuration.LicenseExpired) { throw new Mediachase.Ibn.LicenseExpiredException(); } // !! Authorisation cookie SetAuthCookie(HttpRuntime.AppDomainAppVirtualPath, RegularLogin, false, iUserId); // not rederect UserLight userLight = UserLight.Load(iUserId); UserLightPropertyCollection pc = userLight.Properties; HttpContext context = HttpContext.Current; context.Items.Add("userlight", userLight); //Response.Redirect("~/" + Server.UrlDecode(RegularRedirect)); // O.R. [2008-04-15] Response.Redirect("~/" + RegularRedirect); } catch (InvalidAccountException) { Response.Redirect("~/Public/default.aspx"); } catch (InvalidPasswordException) { Response.Redirect("~/Public/default.aspx"); } catch (NotActiveAccountException) { Response.Redirect("~/Public/default.aspx"); } catch (ExternalOrPendingAccountException) { Response.Redirect("~/Public/default.aspx"); } catch (Mediachase.Ibn.LicenseExpiredException) { Response.Redirect("~/Public/default.aspx"); } } }
public ActionResult <string> Get(int id) { User user = db.Users.FirstOrDefault(x => x.Id == id); if (user == null) { return(NotFound()); } else { UserLight upload = new UserLight(user.Photo, user.NameOth, user.Family, user.DateTime, user.CompanyId, user.Phone, user.Post); return(new ObjectResult(upload)); } }
private void CheckTicketLogin() { if (!String.IsNullOrEmpty(RegularLogin) && !String.IsNullOrEmpty(RegularTicket) && !String.IsNullOrEmpty(RegularRedirect)) { try { int iUserId = Security.UserLoginByTicket(RegularLogin, new Guid(RegularTicket)); if (Mediachase.IBN.Business.Configuration.LicenseExpired) { throw new Mediachase.Ibn.LicenseExpiredException(); } // !! Authorisation cookie SetAuthCookie(HttpRuntime.AppDomainAppVirtualPath, RegularLogin, false, iUserId); // not rederect UserLight userLight = UserLight.Load(iUserId); UserLightPropertyCollection pc = userLight.Properties; HttpContext context = HttpContext.Current; context.Items.Add("userlight", userLight); Response.Redirect("~/" + RegularRedirect); } catch (InvalidAccountException) { Response.Redirect("~/Public/default.aspx"); } catch (InvalidTicketException) { Response.Redirect("~/Public/default.aspx"); } catch (NotActiveAccountException) { Response.Redirect("~/Public/default.aspx"); } catch (ExternalOrPendingAccountException) { Response.Redirect("~/Public/default.aspx"); } catch (Mediachase.Ibn.LicenseExpiredException) { Response.Redirect("~/Public/default.aspx"); } } }
protected void Page_Load(object sender, System.EventArgs e) { string redirectUrl = "~/Public/WebLogin.aspx?" + Request.QueryString.ToString(); string windowsUserName = Request.ServerVariables["LOGON_USER"]; if (!string.IsNullOrEmpty(windowsUserName)) // Don't search for empty user name. { int userId = Security.UserLoginWindows(windowsUserName); if (userId > 0) { string ibnUserName = GetIbnUserName(userId); SetAuthCookie(HttpRuntime.AppDomainAppVirtualPath, ibnUserName); if (Request["ReturnUrl"] == null) { UserLight userLight = UserLight.Load(userId); UserLightPropertyCollection pc = userLight.Properties; HttpContext context = HttpContext.Current; if (context != null && context.Items.Contains("userlight")) { context.Items.Remove("userlight"); } context.Items.Add("userlight", userLight); if (Security.IsUserInGroup(InternalSecureGroups.Administrator) && PortalConfig.PortalShowAdminWizard) { redirectUrl = "~/Workspace/default.aspx?BTab=Workspace&AdminWizard=1"; } else { redirectUrl = "~/Apps/Shell/Pages/default.aspx"; } } else { redirectUrl = Request["ReturnUrl"]; } } } Response.Redirect(redirectUrl, true); }
/// <summary> /// Gets the outgoing email format body preview. /// </summary> /// <param name="IncidentId">The incident id.</param> /// <returns></returns> public static string GetOutgoingEmailFormatBodyPreview(int issueId) { IncidentBox incidentBox = IncidentBox.Load(Incident.GetIncidentBox(issueId)); string issueTitle = Incident.GetIncidentTitle(issueId); string issueLink = Alerts2.MakeIssueLink(issueId); string issueTicket = TicketUidUtil.Create(incidentBox.IdentifierMask, issueId); StringBuilder sb = new StringBuilder(incidentBox.Document.GeneralBlock.OutgoingEmailFormatBody, 4096); sb.Replace("[=Title=]", issueTitle); sb.Replace("[=Ticket=]", issueTicket); //sb.Replace("[=Text=]", node.Text); string linkStart = string.Format(CultureInfo.InvariantCulture, "<a href=\"{0}\">", HttpUtility.HtmlAttributeEncode(issueLink)); sb.Replace("[=Link=]", linkStart); sb.Replace("[=/Link=]", "</a>"); UserLight currentUser = Security.CurrentUser; if (currentUser != null) { sb.Replace("[=FirstName=]", currentUser.FirstName); sb.Replace("[=LastName=]", currentUser.LastName); sb.Replace("[=Email=]", currentUser.Email); using (IDataReader reader = User.GetUserProfile(currentUser.UserID)) { if (reader.Read()) { sb.Replace("[=Phone=]", reader["Phone"].ToString()); sb.Replace("[=Fax=]", reader["Fax"].ToString()); sb.Replace("[=Mobile=]", reader["Mobile"].ToString()); sb.Replace("[=Position=]", reader["Position"].ToString()); sb.Replace("[=Department=]", reader["Department"].ToString()); sb.Replace("[=Company=]", reader["Company"].ToString()); sb.Replace("[=Location=]", reader["Location"].ToString()); } } } return(sb.ToString()); }
/// <summary> /// Creates the new incident. /// </summary> /// <param name="EMailMessageId">The E mail message id.</param> /// <param name="emailBox">The email box.</param> /// <param name="msg">The MSG.</param> /// <returns></returns> public static int CreateNewIncident(int EMailMessageId, EMailRouterPop3Box emailBox, Pop3Message msg) { IEMailIncidentMapping mappingHandler = EMailIncidentMappingHandler.LoadHandler(emailBox.Settings.SelectedHandlerId); // Step. Mapping IncidentInfo incidentInfo = mappingHandler.Create(emailBox, msg); // Set Creator UserLight prevUser = LogOnCreator(incidentInfo.CreatorId, msg); incidentInfo.CreatorId = Security.CurrentUser.UserID; // Step. Evaluate IncidentBox IncidentBox incidentBox = null; if (incidentInfo.IncidentBoxId != -1) { incidentBox = IncidentBox.Load(incidentInfo.IncidentBoxId); } else { incidentBox = IncidentBoxRule.Evaluate(incidentInfo); } // Step. Create Incident int IncidentId = Incident.CreateFromEmail(incidentInfo.Title, incidentInfo.Description, incidentInfo.ProjectId, incidentInfo.TypeId, incidentInfo.PriorityId, incidentInfo.SeverityId, incidentBox.Document.GeneralBlock.TaskTime, incidentBox.Document.GeneralBlock.ExpectedDuration, incidentBox.Document.GeneralBlock.ExpectedResponseTime, incidentBox.Document.GeneralBlock.ExpectedAssignTime, incidentInfo.GeneralCategories, incidentInfo.IncidentCategories, incidentBox.IncidentBoxId, EMailMessageId, incidentInfo.OrgUid, incidentInfo.ContactUid); return(IncidentId); }
private void btnSave_Click(object sender, EventArgs e) { string sFields = iFields.Value; ArrayList alFields = new ArrayList(); while (sFields.Length > 0) { string s = sFields.Substring(0, sFields.IndexOf(",")); try { int UserId = int.Parse(s); UserLight _ul = UserLight.Load(UserId); if (!alFields.Contains(_ul.Email)) { alFields.Add(_ul.Email); } } catch { if (!alFields.Contains(s)) { alFields.Add(s); } } sFields = sFields.Remove(0, sFields.IndexOf(",") + 1); } sFields = ""; foreach (string _smail in alFields) { string sName = GetNameByEMail(_smail); if (sName != "") { sFields += String.Format("{0} <{1}>; ", sName, _smail); } else { sFields += _smail + "; "; } } Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "<script language=javascript>" + "window.opener.updateEMails('" + sFields + "'); window.close();</script>"); }
/// <summary> /// Makes the auth session. /// </summary> /// <param name="forceCleanup">if set to <c>true</c> [force cleanup].</param> /// <param name="elStorageType">Type of the el storage.</param> /// <param name="objectId">The object id.</param> /// <returns></returns> public static Guid MakeAuthSession(bool forceCleanup, ObjectTypes elStorageType, int objectId) { Guid retVal = Guid.Empty; //Cleanup expiated sessions if (forceCleanup) { CleanupAuthSession(elStorageType); } UserLight currentUser = Security.CurrentUser; if (currentUser == null) { throw new Exception("CurrentUser"); } return(DBCommon.AddGate((int)elStorageType, objectId, currentUser.UserID)); }
private static int TryBasicAuthentificate(string authorizationHeader) { int retVal = -1; String userName = String.Empty; String password = String.Empty; try { ExtractBasicCredentials(authorizationHeader, ref userName, ref password); retVal = Security.UserLogin(userName, password); UserLight user = UserLight.Load(retVal); Security.SetCurrentUser(user); } catch (System.Exception) { } return(retVal); }
/// <summary> /// Creates this instance. /// </summary> /// <returns></returns> public ArrayList Create() { ArrayList retVal = new ArrayList(); //_createdToEmailList.Clear(); foreach (object Recipient in _recipientList) { if (Recipient is string) { if (!_createdToEmailList.ContainsKey(Recipient)) { _createdToEmailList.Add(Recipient, null); retVal.Add(CreateSingle((string)Recipient)); } } else if (Recipient is int) { UserLight user = UserLight.Load((int)Recipient); if (user.Email != null && user.Email != string.Empty && !_createdToEmailList.ContainsKey(user.Email)) { _createdToEmailList.Add(user.Email, null); NameValueCollection headers = new NameValueCollection(); if (_incidentId > 0) { Guid UserTicket = IncidentUserTicket.CreateAndReturnUID(user.UserID, _incidentId); headers.Add("X-IBN-USERTICKET", UserTicket.ToString()); headers.Add("X-IBN-WEBSERVER", GetAbsolutePath("/WebServices/IncidentInfo.asmx")); } retVal.Add(CreateSingle(user.Email, headers)); } } } return(retVal); }
private static int TrySessionAuthentificate(Guid sessionId) { //По умолчанию не используем утентификацию из сессии если пользователь аутентифицирован int retVal = Security.CurrentUser != null ? Security.CurrentUser.UserID : -1; if (retVal == -1) { //Пытаемся получить id пользователя из сессии retVal = WebDavAuthHelper.GetUserIdByAuthToken(sessionId); if (retVal != -1) { //аутентифицируем пользователя из сессии UserLight user = UserLight.Load(retVal); Security.SetCurrentUser(user); //Refresh auth session RefreshAuthSession(sessionId); } } return(retVal); }
/// <summary> /// Webs the dav authenticates. /// </summary> /// <param name="context">The context.</param> /// <param name="ticket">The ticket.</param> /// <returns></returns> internal static bool WebDavAuthentificate(HttpContext context, WebDavTicket ticket) { int userId = -1; if (ticket == null) { throw new Exception("ticket"); } System.Web.Configuration.AuthenticationSection section = (AuthenticationSection)WebConfigurationManager.GetSection("system.web/authentication"); //Если есть сессионный id в тикете if (ticket.SessionId != Guid.Empty) { CleanupAuthSession(ticket.AbsolutePath.StorageType); //Пытаемся получить id пользователя из тикета userId = TrySessionAuthentificate(ticket.SessionId); } //Пытемся аутентифицироваться из сессии if (userId == -1) { UserLight userLight = Security.CurrentUser; if (userLight != null) { userId = userLight.UserID; } } ////Используем стандартный механизм аутентификации //if (userId == -1 && section.Mode == AuthenticationMode.Forms) //{ // System.Web.Security.FormsAuthentication.RedirectToLoginPage(); // return false; //} ////Используем Basic аутентификацию //else if (userId == -1) //{ // userId = BasicAuthentificate(context, ticket); //} return(userId != -1); }
// public static string[] GetExternalSendersByIncidentId(int IncidentId) // { // return EMailMessageRow.GetExternalSendersByIncidentId(IncidentId); // } /// <summary> /// Logs the on creator. /// </summary> /// <param name="DefaultCreatorId">The default creator id.</param> /// <param name="msg">The MSG.</param> /// <returns></returns> internal static UserLight LogOnCreator(int DefaultCreatorId, Pop3Message msg) { if (Security.CurrentUser != null) { return(Security.CurrentUser); } int creatorId = DefaultCreatorId; int emailUser = DBUser.GetUserByEmail(EMailMessage.GetSenderEmail(msg), false); if (emailUser > 0) { // OZ: 2007-01-26: Fix problem: Mediachase.IBN.Business.AccessDeniedException: Access denied. // at Mediachase.IBN.Business.Incident.CreateFromEmail using (IDataReader reader = DBUser.GetUserInfo(emailUser)) { if (reader.Read()) { if (!(bool)reader["IsActive"]) { emailUser = -1; } } else { emailUser = -1; } } // } if (emailUser > 0) { creatorId = emailUser; } UserLight creator = UserLight.Load(creatorId); return(Security.SetCurrentUser(creator)); }
protected string GetNameByEMail(string eMail) { int iUserId = Mediachase.IBN.Business.User.GetUserByEmail(eMail); if (iUserId > 0) { return(UserLight.Load(iUserId).DisplayName); } else { Mediachase.IBN.Business.Client client = Mediachase.IBN.Business.Common.GetClient(eMail); if (client != null) { return(client.Name); } else { return(""); } } }
private void LoginAsDefaultUser(int iUserId, string sDefUser) { SetAuthCookie(HttpRuntime.AppDomainAppVirtualPath, sDefUser, false, iUserId); UserLight userLight = UserLight.Load(iUserId); UserLightPropertyCollection pc = userLight.Properties; HttpContext context = HttpContext.Current; if (context != null && context.Items.Contains("userlight")) { context.Items.Remove("userlight"); } context.Items.Add("userlight", userLight); if (Request["ReturnUrl"] == null) { // not redirect if (Security.IsUserInGroup(InternalSecureGroups.Administrator)) { if (PortalConfig.PortalShowAdminWizard) { Response.Redirect("~/Workspace/default.aspx?BTab=Workspace&AdminWizard=1", true); return; } } Response.Redirect("~/Apps/Shell/Pages/default.aspx"); return; } else { //Response.Redirect(Server.UrlDecode(Request["ReturnUrl"])); // O.R. [2008-04-15] Response.Redirect(Request["ReturnUrl"]); return; } }
public static void LogonUserByRssKey(Guid rssKey) { using (IDataReader reader = DBUser.GetUserInfoByRssKey(rssKey)) { if (!reader.Read()) { throw new Mediachase.Ibn.AccessDeniedException(); } int userId = (int)reader["UserId"]; try { string sUserLight = "userlight"; // check user's name and password here UserLight currentUser = UserLight.Load(userId); if (currentUser == null) { throw new Mediachase.Ibn.AccessDeniedException("Exception in user authentication"); } if (HttpContext.Current.Items.Contains(sUserLight)) { HttpContext.Current.Items.Remove(sUserLight); } HttpContext.Current.Items.Add(sUserLight, currentUser); HttpContext.Current.User = new GenericPrincipal(new GenericIdentity(currentUser.Login), null); } catch (Exception ex) { throw new Mediachase.Ibn.AccessDeniedException("Exception in user authentication", ex); } } }
/// <summary> /// Gets the active locked webdav resources. /// </summary> /// <returns></returns> public static IEnumerable <WebDavLockInfo> GetActiveLocksInfo() { WebDavAbstractFactory factory = new WebDavAbstractFactory(); foreach (WebDavStorageElementPropertiesRow row in WebDavStorageElementPropertiesRow.List()) { WebDavElementStorageProvider provider = factory.Create <WebDavElementStorageProvider>(row.ObjectTypeId); ResourceInfo resInfo = GetResourceInfoFromPropertyRow(row); if (resInfo != null) { foreach (ActiveLockElement activeLockEl in provider.GetActiveLocks(resInfo)) { OpaqueLockToken lockToken = OpaqueLockToken.Parse(activeLockEl.LockToken.InnerText); McLockElement mcLockEl = GetMcLockElement(lockToken, provider.GetProperties(resInfo)); WebDavLockInfo retval = new WebDavLockInfo(); retval.WebDavElementPropertyId = row.PrimaryKeyId.Value; retval.FileName = resInfo.Name; retval.ContentTypeId = ContentTypeResolver.GetContentTypeId(resInfo.ContentType); retval.StartLocking = new DateTime(mcLockEl.CreationDate * TimeSpan.TicksPerSecond); retval.Duration = DateTime.UtcNow - retval.StartLocking; UserLight user = UserLight.Load(activeLockEl.Owner); if (user != null) { retval.LockedBy = user.DisplayName; } else { retval.LockedBy = "Unknow"; } yield return(retval); } } } }
public override void DataBind() { if (DataItem != null) { PropertyValueCollection properties = WorkflowActivityWrapper.GetAssignmentProperties(DataItem); object prop; // User prop = properties[AssignmentEntity.FieldUserId]; if (prop != null) { UserLight user = UserLight.Load((int)prop); UserLabel.Text = user.DisplayName; } // Subject prop = properties[AssignmentEntity.FieldSubject]; if (prop != null) { SubjectLabel.Text = prop.ToString(); } } }
public static string HuntingLife(GameUser user, out string errStr) { #region errStr = string.Empty; int huntingID = UserLightLit(user.UserID); int huntingID2 = UserNextLight(user.UserID, huntingID); UserDailyRestrain userRestrain = new PersonalCacheStruct <UserDailyRestrain>().FindKey(user.UserID); var probabilityInfo = new ShareCacheStruct <ProbabilityInfo>().FindKey(huntingID); //当前猎命人物的概率 if (probabilityInfo == null) { return(errStr); } ProbabilityInfo probability1 = new ShareCacheStruct <ProbabilityInfo>().FindKey(huntingID2); if (userRestrain != null && userRestrain.Funtion2 >= VipHelper.GetVipUseNum(user.VipLv, RestrainType.MianFeiLieMing) && DateTime.Now.Date == userRestrain.RefreshDate.Date) { if (probabilityInfo.Price > user.GameCoin) { errStr = LanguageManager.GetLang().St_GameCoinNotEnough; return(errStr); } } //暑期第三弹 if (huntingID2 == 1001 && !NoviceHelper.IsGianCrystalPack(user)) { errStr = LanguageManager.GetLang().St1305_BeiBaoBackpackFull; return(errStr); } var lightCacheSet = new PersonalCacheStruct <UserLight>(); if (huntingID != 1001) { UserLight userLight1 = lightCacheSet.FindKey(user.UserID, huntingID); if (userLight1.IsLight == 2) { return(string.Empty); } if (userLight1.IsLight == 1) { userLight1.IsLight = 2; } } UserLight userLight = new PersonalCacheStruct <UserLight>().FindKey(user.UserID, huntingID2); if (RandomUtils.IsHit(probability1.Light)) { if (userLight != null) { userLight.IsLight = 1; if (userLight.HuntingID == 1005) { errStr = LanguageManager.GetLang().St1305_HuntingIDLight; } } else { userLight = new UserLight() { UserID = user.UserID, HuntingID = huntingID2, IsLight = 1 }; lightCacheSet.Add(userLight); } } if (userRestrain != null) { if (userRestrain.Funtion2 >= VipHelper.GetVipUseNum(user.VipLv, RestrainType.MianFeiLieMing) && DateTime.Now.Date == userRestrain.RefreshDate.Date) { user.GameCoin = MathUtils.Subtraction(user.GameCoin, probabilityInfo.Price, 0); } else { userRestrain.Funtion2 = MathUtils.Addition(userRestrain.Funtion2, 1, int.MaxValue); } } else { user.GameCoin = MathUtils.Subtraction(user.GameCoin, probabilityInfo.Price, 0); } //每种品质的概率 double[] probabilityArray2 = { (double)probabilityInfo.Gray, (double)probabilityInfo.Green, (double)probabilityInfo.Blue, (double)probabilityInfo.Purple, (double)probabilityInfo.Yellow, (double)probabilityInfo.Red }; int index2 = RandomUtils.GetHitIndex(probabilityArray2); CrystalQualityType qualityType = (CrystalQualityType)Enum.Parse(typeof(CrystalQualityType), (index2 + 1).ToString()); List <CrystalInfo> crystalArray2 = new ShareCacheStruct <CrystalInfo>().FindAll(u => u.CrystalQuality == qualityType && u.DemandLv <= user.UserLv); if (crystalArray2.Count > 0) { int randomNum = RandomUtils.GetRandom(0, crystalArray2.Count); var crystal = new ShareCacheStruct <CrystalInfo>().FindKey(crystalArray2[randomNum].CrystalID); if (crystal != null && crystal.CrystalQuality == CrystalQualityType.Gray) { //wuzf修改 8-15 灰色放在临时背包不存DB CrystalHelper.AppendGrayCrystal(user, crystal.CrystalID); } else if (crystal != null) { var package = UserCrystalPackage.Get(user.UserID); UserCrystalInfo userCrystal = new UserCrystalInfo() { UserCrystalID = Guid.NewGuid().ToString(), CrystalID = crystal.CrystalID, CrystalLv = 1, CurrExprience = 0, GeneralID = 0, IsSale = 1, CreateDate = DateTime.Now }; package.SaveCrystal(userCrystal); UserLogHelper.AppenCtystalLog(user.UserID, 5, crystal.CrystalID, probabilityInfo.Price, 0, null, 1, 0); //高品质聊天通知); if (crystal.CrystalQuality >= CrystalQualityType.Yellow) { var cacheChat = new TjxChatService(); string content = string.Format(LanguageManager.GetLang().St1305_HighQualityNotice, user.NickName, CrystalHelper.GetQualityName(crystal.CrystalQuality), crystal.CrystalName ); cacheChat.SystemSend(ChatType.World, content); } } } return(errStr); #endregion }
public override bool TakeAction() { UserHelper.GetUserLightOpen(ContextUser.UserID); short opType = 0; int huntingID2 = 0; if (huntingID < 1005) { huntingID2 = MathUtils.Addition(huntingID, 1, int.MaxValue); } else { huntingID2 = 1001; //huntingID; } UserHelper.ChechDailyRestrain(ContextUser.UserID); if (!CrystalHelper.CheckAllowCrystall(ContextUser)) { ErrorCode = 1000; ErrorInfo = LanguageManager.GetLang().St1305_FateBackpackFull; return(false); } else { if (!CrystalHelper.CheckAllowCrystall(ContextUser)) { ErrorCode = errorNum; ErrorInfo = LanguageManager.GetLang().St1305_FateBackpackFull; return(false); } } ProbabilityInfo probabilityInfo = null; if (ops == 1) { #region opType = 1; UserDailyRestrain userRestrain = new PersonalCacheStruct <UserDailyRestrain>().FindKey(ContextUser.UserID); probabilityInfo = new ShareCacheStruct <ProbabilityInfo>().FindKey(huntingID); //当前猎命人物的概率 if (probabilityInfo == null) { return(false); } ProbabilityInfo probability1 = new ShareCacheStruct <ProbabilityInfo>().FindKey(huntingID2); if (userRestrain != null && userRestrain.Funtion2 >= VipHelper.GetVipUseNum(ContextUser.VipLv, RestrainType.MianFeiLieMing) && DateTime.Now.Date == userRestrain.RefreshDate.Date) { if (probabilityInfo.Price > ContextUser.GameCoin) { ErrorCode = errorNum; ErrorInfo = LanguageManager.GetLang().St_GameCoinNotEnough; return(false); } } //暑期第三弹 if (huntingID2 == 1001 && !NoviceHelper.IsGianCrystalPack(ContextUser)) { ErrorCode = errorNum; ErrorInfo = LanguageManager.GetLang().St1305_BeiBaoBackpackFull; return(false); } var lightCacheSet = new PersonalCacheStruct <UserLight>(); if (huntingID != 1001) { UserLight userLight1 = lightCacheSet.FindKey(ContextUser.UserID, huntingID); if (userLight1.IsLight == 2) { ErrorCode = LanguageManager.GetLang().ErrorCode; return(false); } if (userLight1.IsLight == 1) { userLight1.IsLight = 2; //userLight1.Update(); } } UserLight userLight = new PersonalCacheStruct <UserLight>().FindKey(ContextUser.UserID, huntingID2); if (RandomUtils.IsHit(probability1.Light)) { ErrorCode = ErrorCode; ErrorInfo = probability1.HuntingName; if (userLight != null) { userLight.IsLight = 1; //userLight.Update(); } else { userLight = new UserLight() { UserID = ContextUser.UserID, HuntingID = huntingID2, IsLight = 1 }; lightCacheSet.Add(userLight); } } if (userRestrain != null) { if (userRestrain.Funtion2 >= VipHelper.GetVipUseNum(ContextUser.VipLv, RestrainType.MianFeiLieMing) && DateTime.Now.Date == userRestrain.RefreshDate.Date) { ContextUser.GameCoin = MathUtils.Subtraction(ContextUser.GameCoin, probabilityInfo.Price, 0); //ContextUser.Update(); } else { userRestrain.Funtion2 = MathUtils.Addition(userRestrain.Funtion2, 1, int.MaxValue); //userRestrain.Update(); } } else { ContextUser.GameCoin = MathUtils.Subtraction(ContextUser.GameCoin, probabilityInfo.Price, 0); //ContextUser.Update(); } lightArray = new PersonalCacheStruct <UserLight>().FindAll(ContextUser.UserID); #endregion } else if (ops == 2) { #region opType = 2; if (ContextUser.VipLv < 5) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St_VipNotEnough; return(false); } probabilityInfo = new ShareCacheStruct <ProbabilityInfo>().FindKey(huntingID); //当前猎命人物的概率 if (probabilityInfo == null) { return(false); } if (ContextUser.GoldNum < probabilityInfo.Price) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough; return(false); } UserLight uLightInfo = new PersonalCacheStruct <UserLight>().FindKey(ContextUser.UserID, probabilityInfo.GoldHunting); if (uLightInfo != null && uLightInfo.IsLight == 1) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1305_HuntingIDLight; return(false); } else if (uLightInfo != null && (uLightInfo.IsLight == 2 || uLightInfo.IsLight == 0)) { uLightInfo.IsLight = 1; } else { uLightInfo = new UserLight() { UserID = ContextUser.UserID, HuntingID = probabilityInfo.GoldHunting, IsLight = 1 }; new PersonalCacheStruct <UserLight>().Add(uLightInfo); } ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, probabilityInfo.Price, int.MaxValue); lightArray = new PersonalCacheStruct <UserLight>().FindAll(ContextUser.UserID); #endregion } //每种品质的概率 double[] probabilityArray2 = { (double)probabilityInfo.Gray, (double)probabilityInfo.Green, (double)probabilityInfo.Blue, (double)probabilityInfo.Purple, (double)probabilityInfo.Yellow, (double)probabilityInfo.Red }; int index2 = RandomUtils.GetHitIndex(probabilityArray2); CrystalQualityType qualityType = (CrystalQualityType)Enum.Parse(typeof(CrystalQualityType), (index2 + 1).ToString()); List <CrystalInfo> crystalArray2 = new ShareCacheStruct <CrystalInfo>().FindAll(u => u.CrystalQuality == qualityType && u.DemandLv <= ContextUser.UserLv); if (crystalArray2.Count > 0) { int randomNum = RandomUtils.GetRandom(0, crystalArray2.Count); crystal = new ShareCacheStruct <CrystalInfo>().FindKey(crystalArray2[randomNum].CrystalID); if (crystal != null && crystal.CrystalQuality == CrystalQualityType.Gray) { //wuzf修改 8-15 灰色放在临时背包不存DB CrystalHelper.AppendGrayCrystal(ContextUser, crystal.CrystalID); } else if (crystal != null) { var package = UserCrystalPackage.Get(Uid); UserCrystalInfo userCrystal = new UserCrystalInfo() { UserCrystalID = Guid.NewGuid().ToString(), CrystalID = crystal.CrystalID, CrystalLv = 1, CurrExprience = 0, GeneralID = 0, IsSale = 1, CreateDate = DateTime.Now }; package.SaveCrystal(userCrystal); UserLogHelper.AppenCtystalLog(ContextUser.UserID, opType, crystal.CrystalID, probabilityInfo.Price, probabilityInfo.Price, null, 1, 0); //高品质聊天通知); if (crystal.CrystalQuality >= CrystalQualityType.Yellow) { var cacheChat = new TjxChatService(); string content = string.Format(LanguageManager.GetLang().St1305_HighQualityNotice, ContextUser.NickName, CrystalHelper.GetQualityName(crystal.CrystalQuality), crystal.CrystalName ); cacheChat.SystemSend(ChatType.World, content); } } } //日常任务-猎命 TaskHelper.TriggerDailyTask(Uid, 4009); return(true); }
private void BindSavedValues() { int managerId = -1; int projectId = ProjectId; if (DocumentId > 0) { using (IDataReader reader = Document.GetDocument(DocumentId)) { if (reader.Read()) { if (reader["ProjectTitle"] != DBNull.Value) { lblProject.Text = reader["ProjectTitle"].ToString(); } else { lblProject.Text = LocRM.GetString("ProjectNotSet"); } Util.CommonHelper.SafeSelect(ddlPriority, reader["PriorityId"].ToString()); // Util.CommonHelper.SafeSelect(ddlStatus, reader["StatusId"].ToString()); txtTitle.Text = HttpUtility.HtmlDecode(reader["Title"].ToString()); ftbDescription.Text = HttpUtility.HtmlDecode(reader["Description"].ToString()); ucTaskTime.Value = DateTime.MinValue.AddMinutes((int)reader["TaskTime"]); if (reader["OrgUid"] != DBNull.Value) { ClientControl.ObjectType = OrganizationEntity.GetAssignedMetaClassName(); ClientControl.ObjectId = PrimaryKeyId.Parse(reader["OrgUid"].ToString()); } else if (reader["ContactUid"] != DBNull.Value) { ClientControl.ObjectType = ContactEntity.GetAssignedMetaClassName(); ClientControl.ObjectId = PrimaryKeyId.Parse(reader["ContactUid"].ToString()); } managerId = (int)reader["ManagerId"]; if (reader["ProjectId"] != DBNull.Value) { projectId = (int)reader["ProjectId"]; } } } using (IDataReader reader = Document.GetListCategories(DocumentId)) { while (reader.Read()) { for (int i = 0; i < lbCategory.Items.Count; i++) { Util.CommonHelper.SafeMultipleSelect(lbCategory, reader["CategoryId"].ToString()); } } } EditControl.ObjectId = DocumentId; EditControl.BindData(); } if (projectId > 0) { FillManagersByProject(projectId); } else { FillManagers(); } // Select current manager if (managerId <= 0) { managerId = Security.CurrentUser.UserID; } ListItem managerItem = ddlManager.Items.FindByValue(managerId.ToString()); if (managerItem == null) { UserLight ul = UserLight.Load(managerId); ddlManager.Items.Add(new ListItem(ul.LastName + " " + ul.FirstName, managerId.ToString())); } CommonHelper.SafeSelect(ddlManager, managerId.ToString()); }
protected void btnSubmit_Click(object sender, System.EventArgs e) { if (this.IsPostBack) { try { string sUserLight = "userlight"; // check user's name and password here UserLight currentUser = Security.GetUser(Login.Value, Password.Value); if (currentUser == null) { throw new HttpException(405, null); } // Security Addon [3/2/2004] UserLight retUser = null; if (HttpContext.Current.Items.Contains(sUserLight)) { retUser = (UserLight)HttpContext.Current.Items[sUserLight]; HttpContext.Current.Items.Remove(sUserLight); } HttpContext.Current.Items.Add(sUserLight, currentUser); // End Security Addon [3/2/2004] int AssetVersionId = Int32.Parse(VersionID.Value); // New Folder System Addon [12/27/2005] string ContainerName = "FileLibrary"; string ContainerKey = "Workspace"; Mediachase.IBN.Business.ControlSystem.BaseIbnContainer bic = Mediachase.IBN.Business.ControlSystem.BaseIbnContainer.Create(ContainerName, ContainerKey); Mediachase.IBN.Business.ControlSystem.FileStorage fs = (Mediachase.IBN.Business.ControlSystem.FileStorage)bic.LoadControl("FileStorage"); fs.LoadFile(AssetVersionId, Response.OutputStream); // EndNew Folder System Addon [12/27/2005] /* * int FolderId = Int32.Parse(FolderID.Value); * using (IDataReader assetVersion = Asset.GetAssetVersion(FolderId,ObjectTypes.Folder,AssetVersionId)) * { * if(assetVersion.Read()) * { * string fileUrl = (string)assetVersion["URL"]; * int assetId = (int)assetVersion["AssetId"]; * * Asset.IncDownloadCount(assetId); * * if((bool)assetVersion["IsInternal"]) * { * DSFile.DownloadFile(fileUrl,Response); * } * else * { * Response.Redirect(fileUrl); * } * } * } */ // Security Addon [3/2/2004] HttpContext.Current.Items.Remove(sUserLight); HttpContext.Current.Items.Add(sUserLight, retUser); // End Security Addon [3/2/2004] } catch { throw new HttpException(405, null); } Response.End(); } }
/// <summary> /// Approves the pending. /// </summary> /// <param name="EMailMessageId">The E mail message id.</param> public static void ApprovePending(int EMailMessageId) { // Stop Double Approve if (!PendingEMailMessageRow.Contains(EMailMessageId)) { return; } using (DbTransaction tran = DbTransaction.Begin()) { // Remove from pending PendingEMailMessageRow.DeleteByEMailMessageId(EMailMessageId); // Load Pop3 Message EMailMessageInfo msgInfo = EMailMessageInfo.Load(EMailMessageId); EMailRouterPop3Box emailBox = EMailRouterPop3Box.Load(msgInfo.EMailRouterPop3BoxId); Pop3Message msg = EMailMessage.GetPop3Message(EMailMessageId); // Add User to White Lits string SenderEmail = EMailMessage.GetSenderEmail(msg); //if(!WhiteListItem.Contains(SenderEmail)) if (PortalConfig.UseAntiSpamFilter && PortalConfig.AutoFillWhiteList) { WhiteListItem.Create(SenderEmail); } string TicketUID = TicketUidUtil.LoadFromString(msg.Subject == null ? string.Empty : msg.Subject); if (TicketUID == string.Empty) { int IncidentId = CreateNewIncident(EMailMessageId, emailBox, msg); // Automaticaly by Incident.CreateFromEmail //EMailRouterOutputMessage.Send(IncidentId, emailBox, msg); } else { // Assign By Ticket int IncidentId = FindIncidentByTicket(TicketUID); if (IncidentId != -1) { int creatorId, issueBoxId; using (IDataReader reader = Incident.GetIncident(IncidentId)) { reader.Read(); creatorId = (int)reader["CreatorId"]; issueBoxId = (int)reader["IncidentBoxId"]; } int stateId, managerId, responsibleId; bool isResposibleGroup; ArrayList users = new ArrayList(); Issue2.GetIssueBoxSettings(issueBoxId, out stateId, out managerId, out responsibleId, out isResposibleGroup, users); UserLight prevUser = LogOnCreator(creatorId, msg); int ThreadNodeId = AddToIncidentMessage(emailBox.IsInternal, IncidentId, EMailMessageId, msg); if (ProcessXIbnHeaders(IncidentId, ThreadNodeId, msg)) { ArrayList excludeUsers = EMailRouterOutputMessage.Send(IncidentId, emailBox, msg); // O.R. [2008-09-09]: Exclude inactive users if (responsibleId > 0 && User.GetUserActivity(responsibleId) != User.UserActivity.Active) { responsibleId = -1; } ArrayList activeUsers = new ArrayList(); foreach (int userId in users) { if (User.GetUserActivity(userId) == User.UserActivity.Active) { activeUsers.Add(userId); } } // Issue2.SendAlertsForNewIssue(IncidentId, managerId, responsibleId, activeUsers, excludeUsers); } } else { IncidentId = CreateNewIncident(EMailMessageId, emailBox, msg); // Automaticaly by Incident.CreateFromEmail //EMailRouterOutputMessage.Send(IncidentId, emailBox, msg); } } tran.Commit(); } }
/// <summary> /// Copies to incident. /// </summary> /// <param name="emailMessageId">The email message id.</param> /// <param name="incidentId">The incident id.</param> public static void CopyToIncident(int emailMessageId, int incidentId) { using (DbTransaction tran = DbTransaction.Begin()) { // Remove from pending PendingEMailMessageRow.DeleteByEMailMessageId(emailMessageId); // Load Pop3 Message EMailMessageInfo msgInfo = EMailMessageInfo.Load(emailMessageId); EMailRouterPop3Box emailBox = EMailRouterPop3Box.Load(msgInfo.EMailRouterPop3BoxId); Pop3Message msg = EMailMessage.GetPop3Message(emailMessageId); // Add User to White Lits string SenderEmail = EMailMessage.GetSenderEmail(msg); //if(!WhiteListItem.Contains(SenderEmail)) if (PortalConfig.UseAntiSpamFilter && PortalConfig.AutoFillWhiteList) { WhiteListItem.Create(SenderEmail); } int creatorId, issueBoxId; using (IDataReader reader = Incident.GetIncident(incidentId)) { reader.Read(); creatorId = (int)reader["CreatorId"]; issueBoxId = (int)reader["IncidentBoxId"]; } int stateId, managerId, responsibleId; bool isResposibleGroup; ArrayList users = new ArrayList(); Issue2.GetIssueBoxSettings(issueBoxId, out stateId, out managerId, out responsibleId, out isResposibleGroup, users); UserLight prevUser = LogOnCreator(creatorId, msg); int ThreadNodeId = AddToIncidentMessage(emailBox.IsInternal, incidentId, emailMessageId, msg); if (ProcessXIbnHeaders(incidentId, ThreadNodeId, msg)) { ArrayList excludeUsers = EMailRouterOutputMessage.Send(incidentId, emailBox, msg); // O.R. [2008-09-09]: Exclude inactive users if (responsibleId > 0 && User.GetUserActivity(responsibleId) != User.UserActivity.Active) { responsibleId = -1; } ArrayList activeUsers = new ArrayList(); foreach (int userId in users) { if (User.GetUserActivity(userId) == User.UserActivity.Active) { activeUsers.Add(userId); } } // Issue2.SendAlertsForNewIssue(incidentId, managerId, responsibleId, activeUsers, excludeUsers); } tran.Commit(); } }