Ejemplo n.º 1
0
        private static Message GetMessage(
			string subjectTemplate
			, string bodyTemplate
			, UserInfo uInfo
			, ArrayList vars
			, int objectTypeId
			, int? objectId
			, Guid? objectUid
			)
        {
            StringBuilder sbSubject = new StringBuilder();
            StringBuilder sbBody = new StringBuilder();
            string name2, name3;

            IFormatProvider prov = new CultureInfo(uInfo.Locale, true);

            sbSubject.Append(subjectTemplate);
            sbBody.Append(bodyTemplate);

            // Replace variables with values
            Hashtable vars2 = new Hashtable();

            string guid = "";
            if (uInfo.IsExternal && objectId.HasValue)
            {
                if (uInfo.UserId > 0)
                    guid = DBCommon.GetGateGuid(objectTypeId, objectId.Value, uInfo.UserId);
                else
                    guid = DBCommon.GetGateGuid(objectTypeId, objectId.Value, uInfo.Email);
            }

            string linkStartValue = string.Empty, linkEndValue = string.Empty;
            foreach (VariableInfo var in vars)
            {
                //VariableInfo var = new VariableInfo(vNode);

                name2 = string.Format("[={0}=]", var.name);
                name3 = string.Format("[=/{0}=]", var.name);

                if (var.IsLink) // Modify link
                {
                    if (uInfo.IsExternal && !var.External)
                        var.value = string.Empty;

                    if (string.IsNullOrEmpty(var.value))
                        linkStartValue = linkEndValue = string.Empty;
                    else
                    {
                        if (uInfo.IsExternal)
                        {
                            if (uInfo.UserId > 0)
                                var.value = MakeExternalLink(var.value, uInfo.Login, guid);
                            else
                                var.value = MakeClientLink(var.value, guid);
                        }

                        // Add NoMenu parameter to the end of link
                        if (!var.DisableNoMenu && !uInfo.MenuInAlerts && var.name != "PortalLink" && var.name != "ServerLink")
                        {
                            if (var.value.IndexOf('?') != -1)
                                var.value += "&";
                            else
                                var.value += '?';
                            var.value += "nomenu=1";
                        }

                        linkStartValue = string.Format(CultureInfo.InvariantCulture, "<a href=\"{0}\">", HttpUtility.HtmlAttributeEncode(var.value));
                        linkEndValue = "</a>";
                    }
                }

                if (var.type == VariableType.Date.ToString())
                    var.value = Alerts2.DateReformat(var.value, prov);
                else if (var.type == VariableType.DateTime.ToString())
                    var.value = Alerts2.DateTimeReformat(var.value, prov, uInfo.TimeZoneId);

                vars2[var.name] = var.value;
                sbSubject.Replace(name2, var.value);

                if (var.IsLink)
                {
                    sbBody.Replace(name2, linkStartValue);
                    sbBody.Replace(name3, linkEndValue);
                }
                else
                {
                    if (!var.IsHtml)
                    {
                        var.value = HttpUtility.HtmlEncode(var.value);
                        var.value = var.value.Replace("\r\n", "<br>");
                    }
                    sbBody.Replace(name2, var.value);
                }
            }
            return new Message(sbSubject.ToString(), sbBody.ToString());

            /*				// Attachments
                            Stream data = null;
                            string fileName = string.Empty;
                            if(eInfo.EventType == AlertEventType.Asset_Object.ToString())
                            {
                                data = Asset.GetVersionContent(eInfo.ObjectId);
                                fileName = (string)vars2["FileName"];
                            }
                            if(data != null)
                                ret.Attachments.Add(new Attachment(fileName, data));
            */
        }
Ejemplo n.º 2
0
        private static void CollectEventsAndRecipients(RecipientsType type, ArrayList recipients, Hashtable events, Hashtable users, string param1, DateTime param2)
        {
            EventInfo eInfo;
            UserInfo uInfo;

            // Load recipients info
            using (IDataReader reader = GetRecipientsReader(type, param1, param2))
            {
                RecipientInfo rInfo;
                while (reader.Read())
                {
                    rInfo = new RecipientInfo();
                    rInfo.Load(reader);
                    recipients.Add(rInfo);
                }
            }

            foreach (RecipientInfo rInfo in recipients)
            {
                eInfo = (EventInfo)events[rInfo.SystemEventId];
                if (eInfo == null)
                {
                    // Load events info
                    using (IDataReader reader = DBSystemEvents.GetEvent(rInfo.SystemEventId))
                    {
                        while (reader.Read())
                        {
                            eInfo = new EventInfo();
                            eInfo.Load(reader);
                            events[rInfo.SystemEventId] = eInfo;
                        }
                    }
                }

                if (rInfo.UserId > 0)
                {
                    eInfo.AddRecipient(rInfo.RecipientId);
                    eInfo.AddUser(rInfo.UserId);

                    uInfo = (UserInfo)users[rInfo.UserId];
                    if (uInfo == null)
                    {
                        uInfo = new UserInfo();
                        uInfo.Load(rInfo.UserId);
                        users[rInfo.UserId] = uInfo;
                    }
                    uInfo.AddEvent(eInfo);
                    uInfo.AddRecipient(rInfo);
                }
            }
        }
Ejemplo n.º 3
0
        private static Message GetMessage(
			Hashtable messages,
			AlertTemplate tmpl,
			RecipientInfo rInfo,
			EventInfo eInfo,
			UserInfo uInfo)
        {
            Message ret = null;

            string key = string.Format("{0}|{1}|{2}", tmpl.Key, eInfo.EventId, uInfo.TimeZoneId);
            ret = (Message)messages[key];
            if (ret == null || uInfo.IsExternal)
            {
                ArrayList variables = eInfo.GetVariablesArrayList(uInfo.LanguageId);

                ret = GetMessage(tmpl.Subject, tmpl.Body, uInfo, variables, eInfo.ObjectTypeId, eInfo.ObjectId, eInfo.ObjectUid);
                if (!uInfo.IsExternal)
                    messages[key] = ret;
            }

            return ret;
        }
Ejemplo n.º 4
0
        internal static void SendBroadcastMessage(int messageId, string text)
        {
            if (!AlertsEnabled)
                return;

            ArrayList users = new ArrayList();
            using (IDataReader reader = DbAlert2.GetBroadcastRecipients(messageId))
            {
                while (reader.Read())
                {
                    UserInfo ui = new UserInfo();

                    ui.ImId = (int)reader["ImId"];
                    ui.Locale = reader["Locale"].ToString();

                    users.Add(ui);
                }
            }

            ArrayList vars = new ArrayList();
            AddVariableInitiatedBy(vars);
            vars.Add(new VariableInfo(new AlertVariable(Variable.Text), text, true));

            Hashtable messages = new Hashtable();
            foreach (UserInfo ui in users)
            {
                string message = (string)messages[ui.Locale];
                if (message == null)
                {
                    string subject, body;
                    AlertTemplate.GetTemplate(AlertTemplateTypes.Special, ui.Locale, SpecialMessageType.BroadcastMessage.ToString(), true, out subject, out body);
                    Message msg = GetMessage(subject, body, ui, vars, -1, -1, null);
                    message = msg.Body;
                    messages[ui.Locale] = message;
                }

                try
                {
                    SendMessage(DeliveryType.IBN, ui.GetAddress(DeliveryType.IBN), message, null);
                }
                catch (Exception ex)
                {
                    Log.WriteError(ex.ToString());
                }
            }
        }
Ejemplo n.º 5
0
        internal static void SendForgottenPassword(int userId, string logonLink)
        {
            if (!AlertsEnabled)
                return;

            UserInfo ui = new UserInfo();
            ui.Load(userId);

            ArrayList vars = new ArrayList();
            vars.Add(new VariableInfo(new AlertVariable(Variable.LogonLink, true, false), logonLink));

            string subject, body;
            AlertTemplate.GetTemplate(AlertTemplateTypes.Special, ui.Locale, SpecialMessageType.ForgottenPassword.ToString(), true, out subject, out body);
            Message msg = GetMessage(subject, body, ui, vars, -1, -1, null);

            try
            {
                SendMessage(DeliveryType.Email, ui.GetAddress(DeliveryType.Email), msg.Body, msg.Subject);
            }
            catch (Exception ex)
            {
                Log.WriteError(ex.ToString());
                throw;
            }
        }
Ejemplo n.º 6
0
        internal static void Send(string tranId)
        {
            if (!AlertsEnabled)
                return;

            ArrayList recipients = new ArrayList();
            Hashtable events = new Hashtable();
            Hashtable users = new Hashtable();
            Hashtable templates = new Hashtable();
            Hashtable messages = new Hashtable();
            Hashtable locales = new Hashtable();
            EventInfo eInfo;
            UserInfo uInfo, currentUser = null;
            AlertTemplate tmpl;
            Message msg;

            CollectEventsAndRecipients(RecipientsType.Transaction, recipients, events, users, tranId, DateTime.MinValue);
            foreach (RecipientInfo rInfo in recipients)
            {
                eInfo = (EventInfo)events[rInfo.SystemEventId];
                if (rInfo.UserId > 0)
                    uInfo = (UserInfo)users[rInfo.UserId];
                else
                {
                    if (currentUser == null)
                    {
                        currentUser = new UserInfo();
                        currentUser.Init(Security.CurrentUser, rInfo.Email, rInfo.EmailFrom);
                    }
                    uInfo = currentUser;
                }

                tmpl = GetMessageTemplate(templates, locales, eInfo.EventTypeId, rInfo.MessageTypeId, uInfo.LanguageId);
                msg = GetMessage(messages, tmpl, rInfo, eInfo, uInfo);
                DeliveryType deliveryType;

                using (DbTransaction tran = DbTransaction.Begin())
                {
                    int LogId = DbAlert2.MessageLogAdd(msg.Subject, msg.Body);
                    DBSystemEvents.RecipientUpdateSend(rInfo.RecipientId, uInfo.IsNotifiedByEmail, PortalConfig.UseIM && uInfo.IsNotifiedByIBN, LogId);

                    tran.Commit();
                }

                // Send New Alert
                /*
                foreach (MessageDeliveryProvider provider in new MessageDeliveryProvider[] { })
                {
                    // Check That Provider Enable
                    if (provider.Enable &&
                        PortalConfig_CheckDeliveryProviderEnable(provider) &&
                        UserConfig_CheckDeliveryProviderEnable(provider))
                    {
                        // Create Message
                        string from = uInfo.EmailFrom;
                        string to = uInfo.GetAddress(deliveryType);

                        EntityObject message = provider.CreateMessage(from, to, msg.Subject, msg.Body);

                        CreateRequest createMessageRequest = new CreateRequest(message);

                        createMessageRequest.Parameters.Add(OutgoingMessageQueuePlugin.AddToQueue, true);
                        createMessageRequest.Parameters.Add(OutgoingMessageQueuePlugin.SourceName, "AlertService");

                        CreateResponse response = (CreateResponse)BusinessManager.Execute(createMessageRequest);

                        // TODO: Save Primary Key Id.
                        // response.PrimaryKeyId;
                    }
                }
                */

                // Send alert to e-mail
                try
                {
                    if (uInfo.IsNotifiedByEmail)
                    {
                        deliveryType = DeliveryType.Email;
                        string body
                            = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN' >"
                            + "<html>"
                            + "<head>"
                            + "<meta http-equiv='Content-Type' content='text/html; charset=utf-8' >"
                            + "<title>"
                            + HttpUtility.HtmlEncode(msg.Subject)
                            + "</title>"
                            + "<style type='text/css'>"
                            + "body { font: 10pt Arial,Helvetica,Sans-Serif; color: #000000; }"
                            + ".subject { color: #999999; font-weight: bold; font-size: 120%; }"
                            + "</style>"
                            + "</head>"
                            + "<body>"
                            + msg.Body
                            + "</body>"
                            + "</html>";

                        using (DbTransaction tran = DbTransaction.Begin())
                        {
                            SendMessage(deliveryType, uInfo.EmailFrom, uInfo.GetAddress(deliveryType), body, msg.Subject /*, (Attachment[])msg.Attachments.ToArray(typeof(Attachment))*/);
                            DBSystemEvents.RecipientUpdateSent(rInfo.RecipientId, (int)deliveryType, true);

                            tran.Commit();
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.WriteError(ex.ToString());
                }

                // Send alert to IM
                try
                {
                    if (uInfo != null && uInfo.IsNotifiedByIBN)
                    {
                        deliveryType = DeliveryType.IBN;
                        using (DbTransaction tran = DbTransaction.Begin())
                        {
                            SendMessage(deliveryType, uInfo.GetAddress(deliveryType), msg.Body, msg.Subject);
                            DBSystemEvents.RecipientUpdateSent(rInfo.RecipientId, (int)deliveryType, true);

                            tran.Commit();
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.WriteError(ex.ToString());
                }
            }
        }
Ejemplo n.º 7
0
        internal static void SendBatch(int userId, DateTime dt)
        {
            if (!AlertsEnabled)
                return;

            ArrayList recipients = new ArrayList();
            Hashtable events = new Hashtable();
            Hashtable users = new Hashtable();

            EventInfo ei;

            CollectEventsAndRecipients(RecipientsType.Batch, recipients, events, users, userId.ToString(provDefault), dt);
            UserInfo ui = (UserInfo)users[userId];
            if (ui == null)
            {
                ui = new UserInfo();
                ui.Load(userId);
                users[userId] = ui;
            }
            else
            {
                string msgSubject, msgBody, itemSubject, itemBody, itemSubjectDel, itemBodyDel;
                AlertTemplate.GetTemplate(AlertTemplateTypes.Special, ui.Locale, SpecialMessageType.BatchAlert.ToString(), true, out msgSubject, out msgBody);
                AlertTemplate.GetTemplate(AlertTemplateTypes.Special, ui.Locale, SpecialMessageType.BatchItem.ToString(), true, out itemSubject, out itemBody);
                AlertTemplate.GetTemplate(AlertTemplateTypes.Special, ui.Locale, SpecialMessageType.BatchItemDeleted.ToString(), true, out itemSubjectDel, out itemBodyDel);

                // Build events list
                ArrayList vars;
                Message msg;
                StringBuilder sbText = new StringBuilder();

                foreach (RecipientInfo ri in ui.Recipients)
                {
                    ei = (EventInfo)events[ri.SystemEventId];

                    vars = ei.GetVariablesArrayList(ui.LanguageId);

                    string subject, body;

                    switch ((SystemEventTypes)ei.EventTypeId)
                    {
                        case SystemEventTypes.CalendarEntry_Deleted:
                        case SystemEventTypes.Document_Deleted:
                        case SystemEventTypes.Issue_Deleted:
                        case SystemEventTypes.IssueRequest_Approved:
                        case SystemEventTypes.IssueRequest_Deleted:
                        case SystemEventTypes.List_Deleted:
                        case SystemEventTypes.Project_Deleted:
                        case SystemEventTypes.Task_Deleted:
                        case SystemEventTypes.Todo_Deleted:
                            subject = itemSubjectDel;
                            body = itemBodyDel;
                            break;
                        default:
                            subject = itemSubject;
                            body = itemBody;
                            break;
                    }

                    vars.Add(new VariableInfo(new AlertVariable(Variable.Link, true, false, true), string.Empty)); // RelLink
                    vars.Add(new VariableInfo(new AlertVariable(Variable.Title, false, true, true), string.Empty)); // RelTitle
                    vars.Add(new VariableInfo(new AlertVariable(Variable.EventDate), DateTimeToString(ei.EventDate), VariableType.DateTime));
                    vars.Add(new VariableInfo(new AlertVariable(Variable.EventName), SystemEvents.GetSystemEventName(ei.EventType, ui.Locale)));

                    msg = GetMessage(subject, body, ui, vars, ei.ObjectTypeId, ei.ObjectId, ei.ObjectUid);
                    vars.Clear();
                    sbText.Append(msg.Body);
                }

                vars = new ArrayList();
                vars.Add(new VariableInfo(new AlertVariable(Variable.End), DateTimeToString(dt), VariableType.DateTime));
                vars.Add(new VariableInfo(new AlertVariable(Variable.Start), DateTimeToString(ui.BatchLastSent), VariableType.DateTime));
                vars.Add(new VariableInfo(new AlertVariable(Variable.Text), sbText.ToString(), true));

                msg = GetMessage(msgSubject, msgBody, ui, vars, -1, -1, null);

                // Add message to log.
                using (DbTransaction tran = DbTransaction.Begin())
                {
                    int logId = DbAlert2.MessageLogAdd(msg.Subject, msg.Body);
                    foreach (RecipientInfo ri in ui.Recipients)
                        DBSystemEvents.RecipientUpdateSend(ri.RecipientId, ui.IsNotifiedByEmail, PortalConfig.UseIM && ui.IsNotifiedByIBN, logId);
                    User.UpdateBatchLastSent(ui.UserId, dt);

                    tran.Commit();
                }

                // Send alert to e-mail
                if (ui.IsNotifiedByEmail)
                    SendBatch(ui, DeliveryType.Email, msg);

                // Send alert to IM
                if (ui.IsNotifiedByIBN)
                    SendBatch(ui, DeliveryType.IBN, msg);
            }

            // Calculate next batch time
            DateTime lastBatch = User.GetLocalDate(ui.TimeZoneId, dt);
            DateTime nextBatch = lastBatch.AddMinutes(ui.Period);
            if (ui.From != ui.Till && nextBatch.Hour >= ui.Till || nextBatch.Hour < ui.From)
                nextBatch = lastBatch.Date.AddDays(1).AddHours(ui.From);

            nextBatch = User.GetUTCDate(ui.TimeZoneId, nextBatch);
            User.UpdateBatchNextSend(ui.UserId, nextBatch);

            // Add next batch time to schedule
            Schedule.AddDateTypeValue(DateTypes.BatchAlert, ui.UserId, nextBatch);
        }
Ejemplo n.º 8
0
        private static void SendBatch(UserInfo ui, DeliveryType deliveryType, Message msg)
        {
            try
            {
                //Attachment[] attachments = null;
                //if (deliveryType == DeliveryType.Email)
                //    attachments = (Attachment[])msg.Attachments.ToArray(typeof(Attachment));

                using (DbTransaction tran = DbTransaction.Begin())
                {
                    SendMessage(deliveryType, ui.EmailFrom, ui.GetAddress(deliveryType), msg.Body, msg.Subject/*, attachments*/);
                    foreach (RecipientInfo ri in ui.Recipients)
                    {
                        DBSystemEvents.RecipientUpdateSent(ri.RecipientId, (int)deliveryType, true);
                    }
                    tran.Commit();
                }
            }
            catch (Exception ex)
            {
                Log.WriteError(ex.ToString());
            }
        }
Ejemplo n.º 9
0
        internal static Message GetMessage(
			string subjectTemplate
			, string bodyTemplate
			, SystemEventTypes eventType
			, int? objectId
			, Guid? objectUid
			, int relObjectId
			, int userId
			)
        {
            ObjectTypes objectType, relObjectType;
            ArrayList vars = GetEventVariables(eventType, objectId, objectUid, relObjectId, out objectType, out relObjectType);

            UserInfo ui = new UserInfo();
            ui.Load(userId);

            return GetMessage(subjectTemplate, bodyTemplate, ui, vars, (int)objectType, objectId, objectUid);
        }
Ejemplo n.º 10
0
        public static UserInfo[] ImportXml(XmlDocument doc)
        {
            ArrayList ret = new ArrayList();
            UserInfo ui;
            string sVal;
            XmlNode prop, val;
            string[] propertyNames = UserInfo.PropertyNamesIbnAll;

            foreach(XmlNode user in doc.SelectNodes("/users/user"))
            {
                ui = new UserInfo();
                foreach(string name in propertyNames)
                {
                    sVal = string.Empty;

                    prop = user.SelectSingleNode(string.Format("prop[@name='{0}']", name));
                    if(prop != null)
                    {
                        val = prop.SelectSingleNode("val");
                        if(val != null)
                            sVal = val.InnerXml;
                    }
                    ui[name] = sVal;
                }
                ret.Add(ui);
            }
            return (UserInfo[])ret.ToArray(typeof(UserInfo));
        }
Ejemplo n.º 11
0
        public static UserInfo[] ImportTxt(TextReader doc)
        {
            ArrayList ret = new ArrayList();
            UserInfo ui;
            string separator, valsLine, propsLine, name;
            string[] aVals, aNames;
            string[] propertyNames = UserInfo.PropertyNamesIbnAll;
            Hashtable props = new Hashtable();

            separator = doc.ReadLine();
            propsLine = doc.ReadLine();
            aNames = Regex.Split(propsLine, separator);
            for(int i=0; i<aNames.Length; i++)
                props[i] = aNames[i];

            while((valsLine = doc.ReadLine()) != null)
            {
                aVals = Regex.Split(valsLine, separator);

                if(aVals.Length != aNames.Length)
                    throw new Exception("Invalid file format.");

                ui = new UserInfo();
                for(int i=0; i<aVals.Length; i++)
                {
                    name = (string)props[i];
                    ui[name] = aVals[i];
                }
                ret.Add(ui);
            }
            return (UserInfo[])ret.ToArray(typeof(UserInfo));
        }
Ejemplo n.º 12
0
        public ArrayList GetUsers()
        {
            ArrayList ret = new ArrayList();

            DirectoryEntry root = new DirectoryEntry(string.Format("LDAP://{0}", m_domain), m_username, m_password);
            DirectorySearcher s = new DirectorySearcher(root, m_filter);

            string ldapName;
            string[] ibnNames = UserInfo.PropertyNamesIbnAll;

            foreach(SearchResult result in s.FindAll())
            {
                UserInfo ui = new UserInfo();
                foreach(string ibnName in ibnNames)
                {
                    if(ibnName == UserInfo.IbnProperty.WindowsLogin.ToString())
                        ldapName = UserInfo.AdProperty.SamAccountName.ToString();
                    else
                        ldapName = m_fields[ibnName];

                    string sVal = Ldap.GetPropertyValue(result, ldapName);

                    if(ibnName == UserInfo.IbnProperty.WindowsLogin.ToString())
                        sVal = string.Format("{0}\\{1}", m_domain, sVal).ToLower();

                    ui[ibnName] = sVal;
                }
                ret.Add(ui);
            }
            return ret;
        }
Ejemplo n.º 13
0
Archivo: Ldap.cs Proyecto: 0anion0/IBN
        public static int Synchronize(int LdapId)
        {
            Ldap.CheckAccess();

            LdapSettings ldap = LdapSettings.Load(LdapId);

            Hashtable users = new Hashtable();
            ArrayList updatedUsers = new ArrayList();

            using(IDataReader reader = User.GetLdap())
            {
                while(reader.Read())
                {
                    UserInfo ui = new UserInfo();
                    ui.Load(reader);
                    users[ui[ldap.IbnKey]] = ui;
                }
            }

            if(users.Count > 0)
            {
                using (DirectoryEntry root = new DirectoryEntry(string.Format("LDAP://{0}", ldap.Domain), ldap.Username, ldap.Password))
                {
                    root.RefreshCache();
                    DirectorySearcher searcher = new DirectorySearcher(root, ldap.Filter);

                    foreach (SearchResult result in searcher.FindAll())
                    {
                        UserInfo ui = users[GetPropertyValue(result, ldap.LdapKey)] as UserInfo;
                        if (ui != null)
                        {
                            foreach (LdapField field in ldap.Fields)
                            {
                                string sVal = GetPropertyValue(result, field.LdapName);

                                if (field.BitField)
                                {
                                    if (sVal.Length < 1)
                                        continue;

                                    int iVal = int.Parse(sVal) & field.BitMask;
                                    if (field.Equal)
                                        sVal = (iVal == field.CompareTo).ToString();
                                    else
                                        sVal = (iVal != field.CompareTo).ToString();
                                }

                                if (field.IbnName == UserInfo.IbnProperty.WindowsLogin.ToString())
                                    sVal = string.Format("{0}\\{1}", ldap.Domain, sVal).ToLower();

                                if (ui[field.IbnName] != sVal && (sVal.Length > 0 || field.IbnName != UserInfo.IbnProperty.Email.ToString()))
                                {
                                    ui.UpdatedValues[field.IbnName] = sVal;

                                    if (!updatedUsers.Contains(ui))
                                        updatedUsers.Add(ui);
                                }
                            }
                        }
                    }
                }
            }

            ldap.LastSynchronization = DateTime.UtcNow;
            DbLdap.SettingsUpdateLastSynchronization(ldap.LdapId, ldap.LastSynchronization);

            int logId;
            using(DbTransaction tran = DbTransaction.Begin())
            {
                logId = DbLdap.SyncLogCreate(ldap.LdapId, ldap.LastSynchronization, updatedUsers.Count);
                foreach(UserInfo ui in updatedUsers)
                {
                    bool wasActive = bool.Parse(ui.IsActive);

                    // Save changes to log
                    foreach(string name in UserInfo.PropertyNamesIbnAll)
                    {
                        string oldVal = ui[name];
                        string newVal = ui.UpdatedValues[name];
                        if(newVal != null || name == UserInfo.IbnProperty.FirstName.ToString() || name == UserInfo.IbnProperty.LastName.ToString())
                        {
                            if(newVal == null)
                                newVal = oldVal;

                            DbLdap.SyncFieldCreate(logId, ui.UserId, name, oldVal, newVal);
                        }

                        // Replace old values with new ones
                        if(newVal != null)
                            ui[name] = newVal;
                    }

                    try
                    {
                        // Update main database
                        DBUser.UpdateMain2(ui.OriginalId, ui.Login, ui.FirstName, ui.LastName, ui.Email);

                        // Update portal database
                        DBUser.Update(ui.UserId, ui.Login, ui.FirstName, ui.LastName, ui.Email, ui.WindowsLogin, ui.LdapUid);
                        DBUser.UpdateProfile(ui.UserId, ui.Phone, ui.Fax, ui.Mobile, ui.JobTitle, ui.Department, ui.Company, ui.Location);

                        // Update activity
                        bool isActive = bool.Parse(ui.IsActive);
                        if(isActive != wasActive && (ldap.Activate && isActive || ldap.Deactivate && !isActive))
                            User.UpdateActivity(ui.UserId, isActive);
                    }
                    catch(Exception ex)
                    {
                        Log.WriteError(ex.ToString());
                    }
                }

                tran.Commit();
            }
            return logId;
        }
Ejemplo n.º 14
0
        private void ShowStep(int step)
        {
            for (int i = 0; i <= _stepCount; i++)
                ((Panel)steps[i]).Visible = false;

            ((Panel)steps[step - 1]).Visible = true;

            #region Step 2
            if (step == 2)
            {
                if (rbSourceObject.SelectedValue == "0")
                {
                    lgdConnectInf.InnerText = LocRM.GetString("ConnectToAD");
                    tblADConnection.Visible = true;
                    tblFileConnection.Visible = false;
                    ChangedLdap();
                    tblFilter.Visible = true;
                }
                else
                {
                    lgdConnectInf.InnerText = LocRM.GetString("tLoadToServer");
                    tblADConnection.Visible = false;
                    tblFileConnection.Visible = true;
                    ((WizardTemplate)Page.Controls[0]).btnNext.Attributes.Add("onclick", "ShowProgress();");
                    tblFilter.Visible = false;
                }
                ViewState["Fields"] = null;
                ViewState["ADFields"] = null;
                ViewState["ldapPassword"] = null;
                grdFields.EditItemIndex = -1;
                tbFilter.Text = "";
                wwwPath.Value = "";

                ((WizardTemplate)Page.Controls[0]).btnNext.Disabled = false;
            }
            #endregion

            #region Step 3
            if (step == 3)
            {
                if (ViewState["Fields"] == null || ViewState["Fields"].ToString().Length == 0)
                {
                    DataTable dtFields = new DataTable();
                    dtFields.Columns.Add(new DataColumn("IBNField", typeof(string)));
                    dtFields.Columns.Add(new DataColumn("IBNFieldDisplay", typeof(string)));
                    dtFields.Columns.Add(new DataColumn("ADField", typeof(string)));
                    dtFields.Columns.Add(new DataColumn("realADField", typeof(string)));
                    DataRow dr1;
                    string[] sarray = null;
                    string[] alIBNFields = UserInfo.PropertyNamesIbn;
                    if (rbSourceObject.SelectedValue == "0")
                    {
                        pc["ADDomain"] = txtDomain.Text;
                        pc["ADUserName"] = txtUserName.Text;
                        pc["ADLDAPSettings"] = ddLDAPSettings.SelectedValue;

                        LdapSettings lsets = null;
                        if (int.Parse(ddLDAPSettings.SelectedValue) > 0)
                            lsets = LdapSettings.Load(int.Parse(ddLDAPSettings.SelectedValue));
                        else
                            lsets = new Mediachase.IBN.Business.LdapSettings();

                        string sPassword = txtPassword.Text;

                        if (txtDomain.Text == lsets.Domain && txtUserName.Text == lsets.Username && txtPassword.Text == "")
                            sPassword = lsets.Password;
                        ViewState["ldapPassword"] = sPassword;

                        ActiveDirectory ad = new ActiveDirectory(txtDomain.Text, txtUserName.Text, sPassword, tbFilter.Text);

                        tbFilter.Text = lsets.Filter;
                        foreach (string name in alIBNFields)
                        {
                            dr1 = dtFields.NewRow();
                            dr1["IBNField"] = name;
                            dr1["IBNFieldDisplay"] = Mediachase.Ibn.Web.UI.CHelper.GetResFileString(String.Format("{{IbnFramework.Common:{0}}}", name));
                            dr1["ADField"] = ad.FieldsMatch[name];
                            dr1["realADField"] = ad.FieldsMatch[name];
                            if (ddLDAPSettings.SelectedValue != "0")
                            {
                                foreach (LdapField lf in lsets.Fields)
                                    if (lf.IbnName == name)
                                    {
                                        dr1["ADField"] = lf.LdapName;
                                        dr1["realADField"] = lf.LdapName;
                                        break;
                                    }
                            }
                            dtFields.Rows.Add(dr1);
                        }
                        sarray = ad.GetProperties();
                    }
                    else
                    {
                        if (fSourceFile.PostedFile != null && fSourceFile.PostedFile.ContentLength > 0)
                        {
                            ProcessFileCache(Server.MapPath(CommonHelper.ChartPath));
                            String dir = CommonHelper.ChartPath;
                            string wwwpath = dir + Guid.NewGuid().ToString();
                            switch (rbSourceType.SelectedValue)
                            {
                                case "0":
                                    //wwwpath += ".xls";
                                    // OZ: Added XLS and XLSX extensions
                                    wwwpath += Path.GetExtension(fSourceFile.PostedFile.FileName);
                                    break;
                                case "1":
                                    wwwpath += ".xml";
                                    break;
                                default:
                                    break;
                            }
                            wwwPath.Value = wwwpath;
                            using (Stream sw = File.Create(Server.MapPath(wwwpath)))
                            {
                                fSourceFile.PostedFile.InputStream.Seek(0, SeekOrigin.Begin);
                                System.IO.BinaryReader br = new System.IO.BinaryReader(fSourceFile.PostedFile.InputStream);
                                int iBufferSize = 655360; // 640 KB
                                byte[] outbyte = br.ReadBytes(iBufferSize);

                                while (outbyte.Length > 0)
                                {
                                    sw.Write(outbyte, 0, outbyte.Length);
                                    outbyte = br.ReadBytes(iBufferSize);
                                }
                                br.Close();
                            }

                            IIncomingDataParser parser = null;
                            DataSet rawData = null;
                            switch (rbSourceType.SelectedIndex)
                            {
                                case 0:
                                    IMCOleDBHelper helper = (IMCOleDBHelper)Activator.GetObject(typeof(IMCOleDBHelper), System.Configuration.ConfigurationManager.AppSettings["McOleDbServiceString"]);
                                    rawData = helper.ConvertExcelToDataSet(Server.MapPath(wwwpath));

                                    break;
                                case 1:
                                    parser = new XmlIncomingDataParser();
                                    rawData = parser.Parse(Server.MapPath(wwwPath.Value), null);
                                    break;
                            }

                            DataTable dtSource = rawData.Tables[0];
                            int i = 0;
                            sarray = new string[dtSource.Columns.Count];
                            foreach (DataColumn dc in dtSource.Columns)
                            {
                                sarray[i++] = dc.ColumnName;
                            }

                            foreach (string name in alIBNFields)
                            {
                                dr1 = dtFields.NewRow();
                                dr1["IBNField"] = name;
                                dr1["IBNFieldDisplay"] = Mediachase.Ibn.Web.UI.CHelper.GetResFileString(String.Format("{{IbnFramework.Common:{0}}}", name));
                                dr1["ADField"] = LocRM.GetString("tNotSet");
                                dr1["realADField"] = "0";

                                foreach (string str in sarray)
                                    if (String.Compare(str, name, true) == 0 ||
                                        String.Compare(str, Mediachase.Ibn.Web.UI.CHelper.GetResFileString(String.Format("{{IbnFramework.Common:{0}}}", name)), true) == 0)
                                    {
                                        dr1["ADField"] = str;
                                        dr1["realADField"] = str;
                                    }
                                dtFields.Rows.Add(dr1);
                            }
                        }
                        else
                            ((WizardTemplate)Page.Controls[0]).btnNext.Disabled = true;
                    }

                    ViewState["Fields"] = dtFields;
                    grdFields.DataSource = dtFields.DefaultView;
                    grdFields.DataBind();

                    if (sarray != null)
                    {
                        string sValues = String.Join(",", sarray);
                        ViewState["ADFields"] = sValues;
                    }
                }
                else
                {
                    BindDG();
                }
                ViewState["Users"] = null;
                ViewState["FullUsers"] = null;
            }
            #endregion

            #region Step 4
            if (step == 4)
            {
                grdFields.EditItemIndex = -1;
                DataView dv = null;
                if (ViewState["FullUsers"] == null || ViewState["FullUsers"].ToString().Length == 0)
                {
                    string[] alIBNFields = UserInfo.PropertyNamesIbn;
                    DataTable dtFields = (DataTable)ViewState["Fields"];

                    DataTable dt = new DataTable();
                    dt.Columns.Add(new DataColumn("Add", typeof(bool)));
                    dt.Columns.Add(new DataColumn("Weight", typeof(int)));
                    dt.Columns.Add(new DataColumn("Login", typeof(string)));
                    dt.Columns.Add(new DataColumn("FirstName", typeof(string)));
                    dt.Columns.Add(new DataColumn("LastName", typeof(string)));
                    dt.Columns.Add(new DataColumn("Email", typeof(string)));
                    dt.Columns.Add(new DataColumn("Phone", typeof(string)));
                    dt.Columns.Add(new DataColumn("Fax", typeof(string)));
                    dt.Columns.Add(new DataColumn("Mobile", typeof(string)));
                    dt.Columns.Add(new DataColumn("Company", typeof(string)));
                    dt.Columns.Add(new DataColumn("JobTitle", typeof(string)));
                    dt.Columns.Add(new DataColumn("Department", typeof(string)));
                    dt.Columns.Add(new DataColumn("Location", typeof(string)));
                    dt.Columns.Add(new DataColumn("BadLogin", typeof(bool)));
                    dt.Columns.Add(new DataColumn("BadEmail", typeof(bool)));
                    //dt.Columns.Add(new DataColumn("BadWinLogin", typeof(bool)));
                    dt.Columns.Add(new DataColumn("IsBad", typeof(bool)));
                    dt.Columns.Add(new DataColumn("IsBadGroup", typeof(bool)));
                    dt.Columns.Add(new DataColumn("Groups", typeof(string)));
                    dt.Columns.Add(new DataColumn("IMGroup", typeof(int)));
                    dt.Columns.Add(new DataColumn("LdapUid", typeof(string)));
                    dt.Columns.Add(new DataColumn("WindowsLogin", typeof(string)));
                    DataRow dr;

                    if (rbSourceObject.SelectedValue == "0")
                    {
                        string sPassword = ViewState["ldapPassword"].ToString();

                        if (String.IsNullOrEmpty(sPassword) && int.Parse(ddLDAPSettings.SelectedValue) > 0)
                        {
                            LdapSettings lsets = LdapSettings.Load(int.Parse(ddLDAPSettings.SelectedValue));
                            if (txtDomain.Text == lsets.Domain && txtUserName.Text == lsets.Username && txtPassword.Text == "")
                                sPassword = lsets.Password;
                        }

                        ActiveDirectory ad = new ActiveDirectory(txtDomain.Text, txtUserName.Text, sPassword, tbFilter.Text);

                        foreach (string s in alIBNFields)
                        {
                            DataRow[] drMas = dtFields.Select("IBNField = '" + s + "'");
                            if (drMas.Length > 0)
                            {
                                string ss = drMas[0]["realADField"].ToString();
                                if (ss != "0" && !ss.Equals(ad.FieldsMatch[s]))
                                {
                                    ad.FieldsMatch[s] = ss;
                                }
                            }
                        }
                        ArrayList alUsers = ad.GetUsers();

                        foreach (UserInfo _ui in alUsers)
                        {
                            dr = dt.NewRow();
                            dr["Login"] = _ui.Login;
                            dr["FirstName"] = _ui.FirstName;
                            dr["LastName"] = _ui.LastName;
                            dr["Email"] = _ui.Email;
                            if (_ui.FirstName != "" && _ui.LastName != "" && _ui.Email != "")
                                dr["Add"] = true;
                            else
                                dr["Add"] = false;
                            if (_ui.FirstName != "" && _ui.LastName != "")
                                dr["Weight"] = 0;
                            else
                                dr["Weight"] = 1;
                            dr["Phone"] = _ui.Phone;
                            dr["Fax"] = _ui.Fax;
                            dr["Mobile"] = _ui.Mobile;
                            dr["Company"] = _ui.Company;
                            dr["JobTitle"] = _ui.JobTitle;
                            dr["Department"] = _ui.Department;
                            dr["Location"] = _ui.Location;
                            dr["BadLogin"] = false;
                            dr["BadEmail"] = false;
                            //dr["BadWinLogin"] = false;
                            dr["IsBad"] = false;
                            dr["IsBadGroup"] = false;
                            dr["Groups"] = ((int)InternalSecureGroups.ProjectManager).ToString() + ",";
                            dr["IMGroup"] = -1;
                            dr["LdapUid"] = _ui.LdapUid;
                            dr["WindowsLogin"] = _ui.WindowsLogin;
                            dt.Rows.Add(dr);
                        }
                    }
                    else
                    {
                        IIncomingDataParser parser = null;
                        DataSet rawData = null;
                        switch (rbSourceType.SelectedIndex)
                        {
                            case 0:
                                // [03.06.05] fix some problems with oledb and asp.net
                                IMCOleDBHelper helper = (IMCOleDBHelper)Activator.GetObject(typeof(IMCOleDBHelper), System.Configuration.ConfigurationManager.AppSettings["McOleDbServiceString"]);
                                rawData = helper.ConvertExcelToDataSet(Server.MapPath(wwwPath.Value));
                                break;
                            case 1:
                                parser = new XmlIncomingDataParser();
                                rawData = parser.Parse(Server.MapPath(wwwPath.Value), null);
                                break;
                        }

                        DataTable dtSource = rawData.Tables[0];

                        string sValues = ViewState["ADFields"].ToString();
                        ArrayList alADFields = new ArrayList(sValues.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries));
                        int count = 1;
                        foreach (DataRow drFile in dtSource.Rows)
                        {
                            dr = dt.NewRow();
                            dr["Add"] = true;
                            dr["Weight"] = 0;
                            dr["BadLogin"] = false;
                            dr["BadEmail"] = false;
                            //dr["BadWinLogin"] = false;
                            dr["IsBad"] = false;
                            dr["IsBadGroup"] = false;
                            dr["Groups"] = ((int)InternalSecureGroups.ProjectManager).ToString() + ",";
                            dr["IMGroup"] = -1;
                            bool flLogin = false;
                            foreach (string sname in alADFields)
                            {
                                DataRow[] drF = dtFields.Select("realADField = '" + sname + "'");
                                if (drF.Length > 0)
                                {
                                    string ss = drF[0]["IBNField"].ToString();
                                    if (ss == "Login")
                                        flLogin = true;
                                    dr[ss] = drFile[sname];
                                }
                            }
                            if (!flLogin)
                                dr["Login"] = "******" + (count++).ToString();
                            dt.Rows.Add(dr);
                        }
                    }

                    ViewState["Users"] = dt;
                    DataTable dtFull = dt.Clone();
                    DataRow drNew;
                    foreach (DataRow dr1 in dt.Rows)
                    {
                        drNew = dtFull.NewRow();
                        drNew.ItemArray = dr1.ItemArray;
                        dtFull.Rows.Add(drNew);
                    }
                    ViewState["FullUsers"] = dtFull;

                    dv = dt.DefaultView;
                }
                else
                    dv = ((DataTable)ViewState["FullUsers"]).DefaultView;

                dv.Sort = "Weight, LastName, FirstName, Login";
                dgUsers.DataSource = dv;
                dgUsers.DataBind();

                ((WizardTemplate)Page.Controls[0]).btnNext.CausesValidation = true;
                ((WizardTemplate)Page.Controls[0]).btnNext.Disabled = false;
            }
            #endregion

            #region Step 5
            if (step == 5)
            {
                DataTable dt = (DataTable)ViewState["Users"];
                DataTable dtFull = (DataTable)ViewState["FullUsers"];
                string sExceptions = "";
                foreach (DataGridItem item in dgUsers.Items)
                {
                    foreach (Control control in item.Cells[0].Controls)
                    {
                        if (control is HtmlInputCheckBox)
                        {
                            HtmlInputCheckBox checkBox = (HtmlInputCheckBox)control;
                            //*****Undo*****
                            //string filterElement = "Login = '******'";
                            try
                            {
                                //DataRow[] dr = dt.Select(filterElement);
                                //DataRow[] drF = dtFull.Select(filterElement);
                                DataRow dr = GetRowIsEqual(dt, "Login", item.Cells[3].Text);
                                DataRow drF = GetRowIsEqual(dtFull, "Login", item.Cells[3].Text);
                                if (!checkBox.Checked)
                                {
                                    //if (dr.Length > 0)
                                    //    dt.Rows.Remove(dr[0]);
                                    //if (drF.Length > 0)
                                    //    drF[0]["Add"] = false;
                                    if (dr != null)
                                        dt.Rows.Remove(dr);
                                    if (drF != null)
                                        drF["Add"] = false;
                                }
                                else
                                {
                                    //if (drF.Length > 0)
                                    //    drF[0]["Add"] = true;
                                    //if (dr.Length == 0 && drF.Length > 0)
                                    //{
                                    //    DataRow drN = dt.NewRow();
                                    //    drN.ItemArray = drF[0].ItemArray;
                                    //    dt.Rows.Add(drN);
                                    //}
                                    if (drF != null)
                                        drF["Add"] = true;
                                    if (dr == null && drF != null)
                                    {
                                        DataRow drN = dt.NewRow();
                                        drN.ItemArray = drF.ItemArray;
                                        dt.Rows.Add(drN);
                                    }
                                }
                            }
                            catch
                            {
                                sExceptions += item.Cells[3].Text + "\r\n";
                            }
                        }
                    }
                }

                foreach (DataRow bad in dt.Rows)
                {
                    string sEmail = bad["Email"].ToString();
                    if (sEmail.Length == 0 || User.GetUserByEmail(sEmail) != -1)
                        bad["BadEmail"] = true;
                    string sLogin = bad["Login"].ToString();
                    if (sLogin.Length == 0 || User.GetUserByLogin(sLogin) != -1)
                        bad["BadLogin"] = true;
                    //string sWinLogin = bad["WindowsLogin"].ToString();
                    //if (sWinLogin.Length == 0 || User.GetUserByWindowsLogin(sWinLogin) != -1)
                    //    bad["BadWinLogin"] = true;

                    if ((bool)bad["BadEmail"] || (bool)bad["BadLogin"]/* || (bool)bad["BadWinLogin"]*/)
                        bad["IsBad"] = true;
                }
                ViewState["Users"] = dt;
                ViewState["UsersGroups"] = null;
                ViewState["FullUsers"] = dtFull;
                if (!String.IsNullOrEmpty(sExceptions))
                    Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(),
                        String.Format("alert('Bad Logins:\r\n{0}');", sExceptions), true);

                DataView dv = dt.DefaultView;
                dv.Sort = "IsBad DESC, Login";

                dlUsers.DataSource = dv;
                dlUsers.DataBind();
                dlUsers.SelectedIndex = 0;
                LinkButton lb = (LinkButton)dlUsers.Items[0].FindControl("lbUser");
                if (lb != null)
                    BinddgGroupsUsers(lb.CommandName);

                ((WizardTemplate)Page.Controls[0]).btnNext.CausesValidation = false;
                ((WizardTemplate)Page.Controls[0]).btnNext.Disabled = false;
            }
            #endregion

            #region Step 6
            if (step == 6)
            {
                ddIMGroups.DataTextField = "IMGroupName";
                ddIMGroups.DataValueField = "IMGroupId";
                ddIMGroups.DataSource = IMGroup.GetListIMGroupsWithoutPartners();
                ddIMGroups.DataBind();

                DataTable dt = (DataTable)ViewState["Users"];
                DataTable dtFullOwn = dt.Clone();
                DataRow drNew;
                foreach (DataRow dr1 in dt.Rows)
                {
                    drNew = dtFullOwn.NewRow();
                    drNew.ItemArray = dr1.ItemArray;
                    dtFullOwn.Rows.Add(drNew);
                }
                foreach (DataRow bad in dtFullOwn.Rows)
                {
                    if ((bool)bad["IsBad"])
                    {
                        string sLogin = bad["Login"].ToString();
                        #region *****Undo*****
                        //DataRow[] dr = dt.Select("Login = '******'");
                        //if (dr.Length > 0)
                        //    dt.Rows.Remove(dr[0]);
                        #endregion
                        DataRow dr = GetRowIsEqual(dt, "Login", sLogin);
                        if (dr != null)
                            dt.Rows.Remove(dr);
                    }
                }

                foreach (DataRow dr1 in dt.Rows)
                {
                    dr1["IMGroup"] = int.Parse(ddIMGroups.SelectedValue);
                    if (dr1["Groups"].ToString().Length < 2)
                        dr1["IsBadGroup"] = true;
                }

                ViewState["UsersGroups"] = dt;

                DataView dv = dt.DefaultView;
                dv.Sort = "IsBadGroup DESC, LastName, FirstName";

                dlUserGroups.DataSource = dv;
                dlUserGroups.DataBind();
                if (dlUserGroups.Items.Count > 0)
                {
                    dlUserGroups.SelectedIndex = 0;
                    LinkButton lb = (LinkButton)dlUserGroups.Items[0].FindControl("lbUser2");
                    if (lb != null)
                        BindGroups(lb.CommandName, true);
                    btnSave2.Disabled = false;
                }
                else
                {
                    ((WizardTemplate)Page.Controls[0]).btnNext.Disabled = true;
                    btnSave2.Disabled = true;
                }
                ((WizardTemplate)Page.Controls[0]).btnNext.CausesValidation = false;
            }
            #endregion

            #region Step 7 - Save
            if (step == 7)
            {
                DataTable dt = (DataTable)ViewState["UsersGroups"];
                ArrayList alUsers = new ArrayList();
                foreach (DataRow saverow in dt.Rows)
                {
                    string sGroups = saverow["Groups"].ToString();
                    ArrayList alGroups = new ArrayList();
                    while (sGroups.Length > 0)
                    {
                        alGroups.Add(Int32.Parse(sGroups.Substring(0, sGroups.IndexOf(","))));
                        sGroups = sGroups.Remove(0, sGroups.IndexOf(",") + 1);
                    }
                    if (alGroups.Count > 0)
                    {
                        UserInfo _ui = new UserInfo();

                        _ui.Login = saverow["Login"].ToString();
                        _ui.FirstName = saverow["FirstName"].ToString();
                        _ui.LastName = saverow["LastName"].ToString();
                        _ui.Email = saverow["EMail"].ToString();
                        _ui.Phone = saverow["Phone"].ToString();
                        _ui.Fax = saverow["Fax"].ToString();
                        _ui.Mobile = saverow["Mobile"].ToString();
                        _ui.Company = saverow["Company"].ToString();
                        _ui.JobTitle = saverow["JobTitle"].ToString();
                        _ui.Department = saverow["Department"].ToString();
                        _ui.Location = saverow["Location"].ToString();
                        _ui.Groups = alGroups;
                        _ui.ImGroupId = int.Parse(saverow["IMGroup"].ToString());
                        _ui.WindowsLogin = saverow["WindowsLogin"].ToString();

                        alUsers.Add(_ui);
                    }
                }
                bool fl = false;
                if (alUsers.Count > 0)
                    try
                    {
                        string password = "******";
                        if (!String.IsNullOrEmpty(txtCommonPassword.Text.Trim()))
                            password = txtCommonPassword.Text.Trim();
                        User.CreateMultiple(alUsers, password, Security.CurrentUser.LanguageId);
                    }
                    catch
                    {
                        fl = true;
                    }
                else
                    fl = true;
                if (fl)
                    lblError.Text = LocRM.GetString("tWereErrors");
                else
                {
                    foreach (UserInfo _ui in alUsers)
                    {
                        lblError.Text += CommonHelper.GetUserStatusUL(User.GetUserByLogin(_ui.Login)) + "<br>";
                    }
                }
            }
            #endregion
        }