Beispiel #1
0
        /// <summary>
        /// Add new companies to an existing sub-campaign
        /// </summary>
        /// <param name="lstAcctIds"></param>
        /// <param name="SubCampaignId"></param>
        public static void AddCompaniesToSubCampaign(List<int> lstAcctIds, int SubCampaignId, string ListSource = "")
        {
            BrightPlatformEntities _efDbModel = new BrightPlatformEntities(UserSession.EntityConnection);
            int? _FinalListId = _efDbModel.final_lists.FirstOrDefault(i => i.sub_campaign_id == SubCampaignId).id;
            if (_FinalListId > 0)
            {
                foreach (int _AcctId in lstAcctIds)
                {
                    sub_campaign_account_lists _item = new sub_campaign_account_lists()
                    {
                        final_list_id = (int)_FinalListId,
                        account_id = _AcctId,
                        created_by = UserSession.CurrentUser.UserId,
                        created_on = DateTime.Now,
                        modified = false,
                        active = true,
                        priority = null,
                        locked = false,
                        locked_by = null,
                        locked_timestamp = null,
                        assigned_to = null,
                        list_source = ListSource,
                        modified_by = UserSession.CurrentUser.UserId,
                        modified_on = DateTime.Now
                    };

                    _efDbModel.sub_campaign_account_lists.AddObject(_item);
                }
                _efDbModel.SaveChanges();
            }
        }
Beispiel #2
0
        public static void Save(List<CTScEventAndFollowUpLog> pEventList)
        {
            using (BrightPlatformEntities _eftDbContext = new BrightPlatformEntities(UserSession.EntityConnection)) {
                event_followup_log _eftEvent = null;
                foreach (CTScEventAndFollowUpLog _item in pEventList) {
                    _eftEvent = _eftDbContext.event_followup_log.FirstOrDefault(i => i.id == _item.id);
                    if (_eftEvent == null)
                        continue;

                    _eftEvent.done = _item.done;
                    _eftEvent.assigned_user = Convert.ToBoolean(_item.user_taken) ? UserSession.CurrentUser.UserId : 0;
                    _eftEvent.date_of_transaction = _item.date_of_transaction;
                    _eftEvent.start_time = Convert.ToDateTime(_item.start_time).TimeOfDay;
                    _eftEvent.end_time = Convert.ToDateTime(_item.end_time).TimeOfDay;
                    _eftEvent.title = _item.title;
                    _eftEvent.event_type = _item.event_type;
                    _eftEvent.short_message = _item.short_message;
                    _eftDbContext.event_followup_log.ApplyCurrentValues(_eftEvent);
                }

                if (pEventList.Count > 0) {
                    _eftDbContext.SaveChanges();
                    _eftDbContext.Detach(_eftEvent);
                }
            }
        }
Beispiel #3
0
 /// <sumamary>
 /// Save language
 /// </sumamary>
 public static int SaveLanguage(language objLanguage)
 {
     BrightPlatformEntities objBrightPlatformEntity = new BrightPlatformEntities(UserSession.EntityConnection);
     objBrightPlatformEntity.languages.AddObject(objLanguage);
     objBrightPlatformEntity.SaveChanges();
     return objLanguage.id;
 }
Beispiel #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(tbxSubject.Text)) {
                NotificationDialog.Information("Bright Manager", "Please specify a default send email suject.");
                return;
            }
            else if (string.IsNullOrEmpty(tbxMessage.Text)) {
                NotificationDialog.Information("Bright Manager", "Please specify a default send email message.");
                return;
            }

            /**
             * build the subject and message into one text only,
             * separated by a separator text "[sep]".
             */
            string _SendEmailConfig = string.Format("{0}[sep]{1}",
                tbxSubject.Text,
                tbxMessage.Text
            );

            using (BrightPlatformEntities _efDbContext = new BrightPlatformEntities(UserSession.EntityConnection)) {
                subcampaign _eftSubCampaign = _efDbContext.subcampaigns.FirstOrDefault(i => i.id == m_SubCampaignId);
                if (_eftSubCampaign != null) {
                    //_eftSubCampaign.send_email_config = _SendEmailConfig;
                    _efDbContext.subcampaigns.ApplyCurrentValues(_eftSubCampaign);
                    _efDbContext.SaveChanges();
                    _efDbContext.Detach(_eftSubCampaign);
                }
            }

            NotificationDialog.Information("Bright Manager", "Saved send email config.");
            this.ParentForm.Close();
        }
Beispiel #5
0
        /// <summary>
        /// Add new contacts to an existing sub-campaign
        /// </summary>
        /// <param name="lstContactIds"></param>
        /// <param name="SubCampaignId"></param>
        public static void AddContactsToSubCampaign(List<int> lstContactIds, int SubCampaignId)
        {
            BrightPlatformEntities _efDbModel = new BrightPlatformEntities(UserSession.EntityConnection);
            int? _FinalListId = _efDbModel.final_lists.FirstOrDefault(i => i.sub_campaign_id == SubCampaignId).id;
            if (_FinalListId > 0)
            {
                foreach (int _ContactId in lstContactIds)
                {
                    sub_campaign_contact_lists _item = new sub_campaign_contact_lists()
                    {
                        final_list_id = (int)_FinalListId,
                        contact_id = _ContactId,
                        created_by = UserSession.CurrentUser.UserId,
                        created_on = DateTime.Now,
                        active = true,
                        modified = false,
                        priority = null,
                        in_list = false
                    };

                    _efDbModel.sub_campaign_contact_lists.AddObject(_item);
                }
                _efDbModel.SaveChanges();
            }
        }
Beispiel #6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (gvNurtureSubCampaign.RowCount < 1)
                return;

            WaitDialog.Show("Saving data.");
            List<string> _lstIds = new List<string>();
            for (int i = 0; i < gvNurtureSubCampaign.RowCount; i++) {
                CTSubCampaignNurtureItem _item = gvNurtureSubCampaign.GetRow(i) as CTSubCampaignNurtureItem;
                if (!Convert.ToBoolean(_item.selected))
                    continue;

                _lstIds.Add(string.Format("<item id=\"{0}\" />", _item.sub_campaign_id));
            }

            if (_lstIds.Count > 0) {
                string _xml = string.Format("<sub_campaign_config><nurture_sub_campaign>{0}</nurture_sub_campaign></sub_campaign_config>", string.Join("", _lstIds.ToArray()));
                using (BrightPlatformEntities _efDbContext = new BrightPlatformEntities(UserSession.EntityConnection)) {
                    subcampaign _efSubCampaign = _efDbContext.subcampaigns.FirstOrDefault(i => i.id == m_SubCampaignId);
                    if (_efSubCampaign != null) {
                        _efSubCampaign.xml_nurture_setting = _xml;
                        _efDbContext.subcampaigns.ApplyCurrentValues(_efSubCampaign);
                        _efDbContext.SaveChanges();
                        _efDbContext.Detach(_efSubCampaign);
                    }
                }
            }

            WaitDialog.Close();
            this.ParentForm.Close();
        }
Beispiel #7
0
        public static void LogEventSMS(string pXML, string pMessage, string pComputerName, string pComputerIP, serverside_report_requests _eftRequest)
        {
            string Source = "BrightSales";
            string _Connection = ConfigurationManager.ConnectionStrings["DefaultEntityConnection"].ToString();
            int? requested_by = _eftRequest.requested_by;
            string[] _ids = _eftRequest.sub_campaign_ids.Split(',');
            string _SubCampaignIds = _ids[0];

            using (BrightPlatformEntities _efDbContext = new BrightPlatformEntities(_Connection)) {
                _efDbContext.event_log.AddObject(new event_log() {
                    event_id = (int)EventLog.EventTypes.SEND_SMS,
                    user_id = requested_by,
                    subcampaign_id = int.Parse(_SubCampaignIds),
                    account_id = _eftRequest.account_id,
                    contact_id = null,
                    local_datetime = DateTime.Now,
                    computer_name = pComputerName,
                    param1 = pXML,
                    param2 = pMessage,
                    param3 = Source,
                    param4 = _eftRequest.account_id.ToString(),
                    param5 = pComputerIP,
                    param6 = null
                });

                _efDbContext.SaveChanges();
            }
        }
Beispiel #8
0
 /// <summary>
 /// De-activate a contact
 /// </summary>
 public static void DeActivateContact(int ContactId)
 {
     BrightPlatformEntities objBrightPlatformEntity = new BrightPlatformEntities(UserSession.EntityConnection);
     var objContact = objBrightPlatformEntity.contacts.Where(i => i.id == ContactId).Single();
     objContact.active = false;
     objContact.modified_date = DateTime.Now;
     objContact.modified_by = UserSession.CurrentUser.UserId;
     objBrightPlatformEntity.SaveChanges();
 }
Beispiel #9
0
 public static void Delete(int pEventId)
 {
     using (BrightPlatformEntities _eftDbContext = new BrightPlatformEntities(UserSession.EntityConnection)) {
         event_followup_log _eftEvent = _eftDbContext.event_followup_log.FirstOrDefault(i => i.id == pEventId);
         if (_eftEvent != null) {
             _eftDbContext.event_followup_log.DeleteObject(_eftEvent);
             _eftDbContext.SaveChanges();
             _eftDbContext.Detach(_eftEvent);
         }
     }
 }
Beispiel #10
0
 public static int SaveLanguage(language pLanguage)
 {
     using (BrightPlatformEntities _efDbContext = new BrightPlatformEntities(UserSession.EntityConnection))
     {
         //_efDbContext.ExecuteStoreQuery
         //_efDbContext.FIGetCallLists(0,0).encrypt;
         _efDbContext.languages.AddObject(pLanguage);
         _efDbContext.SaveChanges();
         return pLanguage.id;
     }
 }
Beispiel #11
0
 /// <sumamary>
 /// Save languages
 /// </sumamary>
 public static void SaveUpdatedLanguages(List<LanguageInstance> objList)
 {
     BrightPlatformEntities objBrightPlatformEntity = new BrightPlatformEntities(UserSession.EntityConnection);
     foreach (LanguageInstance Item in objList)
     {
         var objItem = objBrightPlatformEntity.languages.Where(element => element.id == Item.id).FirstOrDefault();
         objItem.code = Item.code;
         objItem.name = Item.description;
         objBrightPlatformEntity.SaveChanges();
     }
 }
Beispiel #12
0
 /// <sumamary>
 /// Save titles
 /// </sumamary>
 public static void SaveUpdatedTitles(List<TitleInstance> objList)
 {
     BrightPlatformEntities objBrightPlatformEntity = new BrightPlatformEntities(UserSession.EntityConnection);
     foreach (TitleInstance Item in objList)
     {
         var objItem = objBrightPlatformEntity.titles.Where(element => element.id == Item.id).FirstOrDefault();
         objItem.language_id = Item.language_id;
         objItem.ssyk = Item.ssyk;
         objItem.date_created = Item.datecreated;
         objBrightPlatformEntity.SaveChanges();
     }
 }
Beispiel #13
0
 public static void SaveUpdatedLanguages(List<LanguageInstance> pList)
 {
     using (BrightPlatformEntities _efDbContext = new BrightPlatformEntities(UserSession.EntityConnection)) {
         foreach (LanguageInstance Item in pList) {
             language _eftLanguage = _efDbContext.languages.Where(element => element.id == Item.id).FirstOrDefault();
             _eftLanguage.code = Item.code;
             _eftLanguage.name = Item.description;
             _efDbContext.SaveChanges();
             _efDbContext.Detach(_eftLanguage);
         }
     }
 }
Beispiel #14
0
        public static void DeleteUser(int UserId)
        {
            BrightPlatformEntities m_objBrightPlatformEntity = new BrightPlatformEntities(UserSession.EntityConnection);
            var objEntityUser = m_objBrightPlatformEntity.users.Where(objField => objField.id == UserId).SingleOrDefault();
            var objEntityUserComment = m_objBrightPlatformEntity.users_comments.Where(i => i.user_id == UserId).SingleOrDefault();

            m_objBrightPlatformEntity.users.DeleteObject(objEntityUser);

            if (objEntityUserComment != null)
                m_objBrightPlatformEntity.users_comments.DeleteObject(objEntityUserComment);

            m_objBrightPlatformEntity.SaveChanges();
        }
Beispiel #15
0
 /// <summary>
 /// De-activate a company
 /// </summary>
 public static void DeActivateCompany(int AccountId, string Reason)
 {
     BrightPlatformEntities objBrightPlatformEntity = new BrightPlatformEntities(UserSession.EntityConnection);
     var objCompany = objBrightPlatformEntity.accounts.FirstOrDefault(i => i.id == AccountId) as account;
     if (objCompany != null) {
         //objCompany.active = false;
         objCompany.de_activate_reason = Reason;
         objCompany.modified_by = UserSession.CurrentUser.UserId;
         objCompany.modified_date = DateTime.Now;
         objCompany.de_activate_by = UserSession.CurrentUser.UserId; ;
         objCompany.de_activate_date = DateTime.Now;
         objBrightPlatformEntity.SaveChanges();
     }
 }
Beispiel #16
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //DialogResult _dlg = MessageBox.Show("Are you sure to re-assign selected follow-up?", "Bright Manager", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            //if (_dlg == DialogResult.No)
            //    return;

            using (BrightPlatformEntities _efDbContext = new BrightPlatformEntities(UserSession.EntityConnection)) {
                event_followup_log _item = _efDbContext.event_followup_log.FirstOrDefault(i => i.id == m_EventFollowUpLogId);
                _item.assigned_user = Convert.ToInt32(cboSubCampaignUsers.EditValue);
                _efDbContext.event_followup_log.ApplyCurrentValues(_item);
                _efDbContext.SaveChanges();
            }

            if (AfterSave != null)
                AfterSave(new AfterSaveArgs() {
                    UserId = Convert.ToInt32(cboSubCampaignUsers.EditValue),
                    UserName = cboSubCampaignUsers.Text
                });

            this.ParentForm.Close();
        }
Beispiel #17
0
        public static long? SaveMail(string pXml, serverside_report_requests _eftRequest)
        {
            string _Connection = ConfigurationManager.ConnectionStrings["DefaultEntityConnection"].ToString();
            using (BrightPlatformEntities _efDbContext = new BrightPlatformEntities(_Connection)) {
                int? requested_by = _eftRequest.requested_by;

                string[] _ids = _eftRequest.sub_campaign_ids.Split(',');
                string _SubCampaignIds = _ids[0];

                message_log _eftMessageLog = new message_log() {
                    message_type = (int)SendMail.eMailType.Send_Mail_To_Prospect,
                    sub_campaign_id = int.Parse(_SubCampaignIds),
                    company_id = _eftRequest.account_id,
                    user_id = _eftRequest.requested_by,
                    XML = pXml,
                    created_date = DateTime.Now
                };
                _efDbContext.message_log.AddObject(_eftMessageLog);
                _efDbContext.SaveChanges();
                _efDbContext.Detach(_eftMessageLog);
                return _eftMessageLog.id;
            }
        }
Beispiel #18
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (tbxReportTemplateName.Text.Length < 1)
                return;

            using (BrightPlatformEntities _efDbModel = new BrightPlatformEntities(UserSession.EntityConnection)) {
                if (_efDbModel.additional_data_report_templates.FirstOrDefault(i => i.template_name.Equals(tbxReportTemplateName.Text)) != null) {
                    MessageBox.Show("Report template name already exists.", "Bright Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                var defaultTemplate = _efDbModel.additional_data_report_templates.FirstOrDefault(i => i.is_default);
                if (defaultTemplate == null) {
                    defaultTemplate = new additional_data_report_templates();
                    defaultTemplate.layout_config = string.Empty;
                    defaultTemplate.data_config = string.Empty;
                }
                WaitDialog.Show("Saving new data.");
                additional_data_report_templates _item = new additional_data_report_templates() {
                    template_name = tbxReportTemplateName.Text,
                    created_on = DateTime.Now,
                    created_by = UserSession.CurrentUser.UserId,
                    layout_config = defaultTemplate.layout_config
                };
                _efDbModel.additional_data_report_templates.AddObject(_item);
                _efDbModel.SaveChanges();

                if (AfterSave != null)
                    AfterSave(this, new AddReportTemplateArgs() { ReportTemplateId = _item.id });

                if (_item != null)
                    _efDbModel.Detach(_item);
            }

            WaitDialog.Close();
            this.ParentForm.Close();
        }
Beispiel #19
0
        public ActionResult PlayAudio(string pData)
        {
            /**
             * connection info.
             */
            #region Code Logic
            string _Connection = ConfigurationManager.ConnectionStrings["DefaultEntityConnection"].ToString();
            if (string.IsNullOrEmpty(_Connection))
                Response.Redirect(Url.RouteUrl(new { action = "DisplayError", pExceptionMessage = "No available connection. Please kindly contact your administrator." }));
            #endregion

            /**
             * user and request infos.
             */
            #region Code Logic
            serverside_report_requests _eftRequest = null;
            using (BrightPlatformEntities _efDbContext = new BrightPlatformEntities(_Connection)) {
                try {
                    Guid _id = new Guid(pData);
                    _eftRequest = _efDbContext.serverside_report_requests.FirstOrDefault(i => i.id == _id);
                    if (_eftRequest == null)
                        Response.Redirect(Url.RouteUrl(new { action = "DisplayError", pExceptionMessage = "Invalid web service request. Please kindly contact your administrator." }));

                    _eftRequest.processed = true;
                    _efDbContext.SaveChanges();
                    _efDbContext.Detach(_eftRequest);
                }
                catch {
                    Response.Redirect(Url.RouteUrl(new { action = "DisplayError", pExceptionMessage = "Invalid web service request. Please kindly contact your administrator." }));
                }
            }
            #endregion

            Stream stream = WebRequest.Create("https://lii.blob.core.windows.net/old/0a4b23f7-eab8-4043-ad84-36b4b5d23f1e_.mp3").GetResponse().GetResponseStream();
            return new FileStreamResult(stream, "audio/mpeg");
        }
Beispiel #20
0
 public static void SaveUserStatus(int UserId, bool IsActivated)
 {
     BrightPlatformEntities m_objBrightPlatformEntity = new BrightPlatformEntities(UserSession.EntityConnection);
     var objEntityUser = m_objBrightPlatformEntity.users.Where(i => i.id == UserId).SingleOrDefault();
     //objEntityUser.disabled = Convert.ToByte(IsActivated);
     objEntityUser.disabled = IsActivated == true ? (byte)0 : (byte)1;
     objEntityUser.modified_date = DateTime.Now;
     objEntityUser.modified_by = UserSession.CurrentUser.UserId;
     m_objBrightPlatformEntity.SaveChanges();
 }
Beispiel #21
0
        public static void SaveUserRole(int UserId, int RoleId, bool IsEnabled)
        {
            BrightPlatformEntities m_objBrightPlatformEntity = new BrightPlatformEntities(UserSession.EntityConnection);
            var objEntityUserRole = m_objBrightPlatformEntity.roles_users.Where(i => i.role_id == RoleId && i.user_id == UserId).SingleOrDefault();
            switch (IsEnabled)
            {
                case true:
                {
                    if (objEntityUserRole == null)
                    {
                        objEntityUserRole = m_objBrightPlatformEntity.roles_users.CreateObject();
                        objEntityUserRole.role_id = RoleId;
                        objEntityUserRole.user_id = UserId;
                        m_objBrightPlatformEntity.roles_users.AddObject(objEntityUserRole);
                    }

                    break;
                }
                case false:
                {
                    if (objEntityUserRole != null)
                        m_objBrightPlatformEntity.roles_users.DeleteObject(objEntityUserRole);

                    break;
                }
            }

            m_objBrightPlatformEntity.SaveChanges();
        }
Beispiel #22
0
        public static bool SaveUserPassword(string pEmail, string pNewPassword, ref string pOldPassword)
        {
            var _Connection = UserSession.DefaultEntityConnection;
            if (_Connection == null)
                return false;

            using (BrightPlatformEntities _efDbContext = new BrightPlatformEntities(_Connection)) {
                user _eftUser = _efDbContext.users.FirstOrDefault(i => i.email == pEmail && i.internal_user == true);
                if (_eftUser == null) {
                    BrightVision.Common.UI.NotificationDialog.Error("Error", "No match found for the user.\nPlease contact system administrator.");
                    return false;
                }

                if (Convert.ToBoolean(_eftUser.disabled)) {
                    _efDbContext.Detach(_eftUser);
                    return false;
                }

                if (_eftUser != null) {
                    _efDbContext.change_password_logs.AddObject(new change_password_logs() {
                        user_id = _eftUser.id,
                        old_password = _eftUser.password,
                        new_password = pNewPassword,
                        updated_by = _eftUser.id,
                        updated_on = DateTime.Now,
                        machine_name = UserSession.CurrentUser.ComputerName,
                        machine_ip = UserSession.CurrentUser.ComputerIP
                    });

                    pOldPassword = _eftUser.password;
                    _eftUser.password = HashUtility.GetHashPassword(pNewPassword);
                    _efDbContext.SaveChanges();
                    _efDbContext.Detach(_eftUser);
                }
                else
                    return false;
            }

            return true;
        }
Beispiel #23
0
        public static bool SaveUserPassword(string pEmail, string pNewPassword)
        {
            var _Connection = UserSession.DefaultEntityConnection;
            if (_Connection == null)
                return false;

            using (BrightPlatformEntities _efDbContext = new BrightPlatformEntities(_Connection)) {
                user _eftUser = _efDbContext.users.FirstOrDefault(i => i.email == pEmail && i.internal_user == true);
                if (Convert.ToBoolean(_eftUser.disabled)) {
                    _efDbContext.Detach(_eftUser);
                    return false;
                }

                if (_eftUser != null) {
                    _efDbContext.change_password_logs.AddObject(new change_password_logs() {
                        user_id = _eftUser.id,
                        old_password = _eftUser.password,
                        new_password = pNewPassword,
                        updated_by = _eftUser.id,
                        updated_on = DateTime.Now
                    });
                    _eftUser.password = HashUtility.GetHashPassword(pNewPassword);
                    _efDbContext.SaveChanges();
                    _efDbContext.Detach(_eftUser);
                }
                else
                    return false;
            }

            return true;
        }
Beispiel #24
0
        public static void SaveUserCustomer(int UserId, int CustomerId)
        {
            BrightPlatformEntities m_objBrightPlatformEntity = new BrightPlatformEntities(UserSession.EntityConnection);
            var objEntityUserCustomer = m_objBrightPlatformEntity.user_customers.Where(i => i.user_id == UserId).SingleOrDefault();
            if (objEntityUserCustomer != null)
            {
                m_objBrightPlatformEntity.user_customers.DeleteObject(objEntityUserCustomer);
                m_objBrightPlatformEntity.SaveChanges();
            }

            user_customers objUserCustomer = new user_customers();
            objUserCustomer.user_id = UserId;
            objUserCustomer.customer_id = CustomerId;
            m_objBrightPlatformEntity.user_customers.AddObject(objUserCustomer);
            m_objBrightPlatformEntity.SaveChanges();
        }
Beispiel #25
0
        public static void SaveUserComment(int UserId, string UserComment)
        {
            BrightPlatformEntities m_objBrightPlatformEntity = new BrightPlatformEntities(UserSession.EntityConnection);
            bool isNewRecord = false;

            var objEntityUserComment = m_objBrightPlatformEntity.users_comments.Where(i => i.user_id == UserId).SingleOrDefault();
            if (objEntityUserComment == null)
            {
                objEntityUserComment = m_objBrightPlatformEntity.users_comments.CreateObject();
                objEntityUserComment.user_id = UserId;
                isNewRecord = true;
            }

            objEntityUserComment.comments = UserComment;

            if (isNewRecord)
                m_objBrightPlatformEntity.users_comments.AddObject(objEntityUserComment);

            m_objBrightPlatformEntity.SaveChanges();
        }
Beispiel #26
0
        private void SaveEventLog(EventLog.EventTypes pType)
        {
            BrightPlatformEntities m_efDbContext = new BrightPlatformEntities(UserSession.EntityConnection);
            int? _ContactId = null;
            int? _SubCampaignId = null;
            int? _AccountId = null;

            if (ContactPerson != null) {
                if (ContactPerson.id > 0)
                    _ContactId = ContactPerson.id;
            }

            if (SubCampaignId > 0)
                _SubCampaignId = SubCampaignId;

            if (AccountId > 0)
                _AccountId = AccountId;

            m_efDbContext.event_log.AddObject(
                new event_log() {
                    event_id = (int)pType,
                    user_id = UserSession.CurrentUser.UserId,
                    subcampaign_id = _SubCampaignId,
                    account_id = _AccountId,
                    contact_id = _ContactId,
                    local_datetime = DateTime.Now,
                    computer_name = UserSession.CurrentUser.ComputerName,
                    param1 = null,
                    param2 = null,
                    param3 = null,
                    param4 = null,
                    param5 = null,
                    param6 = null
                }
            );

            m_efDbContext.SaveChanges();
            m_EventBus.Notify(new CallViewBarEvents.PhoneCallAttempt());

            //if (CallAttemptMade != null)
            //    CallAttemptMade(this, new EventArgs());
        }
Beispiel #27
0
        private void tbxPassword_Leave(object sender, EventArgs e)
        {
            TextEdit _control = sender as TextEdit;
            if (gridViewUsers.RowCount < 1 || _control.Text.Length < 1)
                return;

            WaitDialog.Show("Saving data ...");
            using (BrightPlatformEntities _efDbContext = new BrightPlatformEntities(UserSession.EntityConnection)) {
                ObjectUser.UserInstance _item = gridViewUsers.GetFocusedRow() as ObjectUser.UserInstance;
                user _efoUser = _efDbContext.users.FirstOrDefault(i => i.id == _item.id);
                _efoUser.password = HashUtility.GetHashPassword(_control.Text);
                _efoUser.modified_by = UserSession.CurrentUser.UserId;
                _efoUser.modified_date = DateTime.Now;
                _efDbContext.users.ApplyCurrentValues(_efoUser);
                _efDbContext.SaveChanges();
                _efDbContext.Detach(_efoUser);
            }

            gridViewUsers.SetRowCellValue(gridViewUsers.FocusedRowHandle, "password", _control.Text);
            WaitDialog.Close();
        }
Beispiel #28
0
 public static void SaveUserType(int UserId, bool IsInternal)
 {
     BrightPlatformEntities m_objBrightPlatformEntity = new BrightPlatformEntities(UserSession.EntityConnection);
     var objEntityUser = m_objBrightPlatformEntity.users.Where(i => i.id == UserId).SingleOrDefault();
     objEntityUser.internal_user = IsInternal;
     objEntityUser.modified_date = DateTime.Now;
     objEntityUser.modified_by = UserSession.CurrentUser.UserId;
     m_objBrightPlatformEntity.SaveChanges();
 }
Beispiel #29
0
        private void btnSaveToContact_Click(object sender, EventArgs e)
        {
            try
            {
                bool _editable = true;
                using (BrightPlatformEntities _efDbContext = new BrightPlatformEntities(UserSession.EntityConnection))
                {
                    sub_campaign_account_lists _eftCurrentCompany = _efDbContext.sub_campaign_account_lists.FirstOrDefault(i => i.final_list_id == m_BrightSalesProperty.CommonProperty.FinalListId && i.account_id == m_BrightSalesProperty.CommonProperty.AccountId);
                    if (_eftCurrentCompany != null)
                    {
                        if (_eftCurrentCompany.locked_by != null && _eftCurrentCompany.locked_by != UserSession.CurrentUser.UserId)
                            _editable = false;

                        _efDbContext.Detach(_eftCurrentCompany);
                    }
                }

                if (!_editable)
                {
                    NotificationDialog.Error("Bright Sales", "Currently worked by another user.");
                    return;
                }

                if (txtAddressBar.Text.Trim() == "" && BrightVision.Common.Utilities.ValidationUtility.IFNullString(wbLinkedIn.Url, "").Contains("/profile/view?id="))
                    txtAddressBar.Text = wbLinkedIn.Url.ToString();

                if (!CheckValidURL(txtAddressBar.Text))
                {
                    NotificationDialog.Error("Error", "Invalid URL");
                    return;
                }

                using (BrightPlatformEntities _efDbCOntext = new BrightPlatformEntities(UserSession.EntityConnection))
                {
                    contact _eftContacts = _efDbCOntext.contacts.FirstOrDefault(i => i.id == m_contactId);
                    if (_eftContacts != null)
                    {
                        _eftContacts.linkedin_url = txtAddressBar.Text;
                    }
                    _efDbCOntext.SaveChanges();

                    _efDbCOntext.Detach(_eftContacts);

                    m_linkedin = txtAddressBar.Text;
                    btnLoadContact.Enabled = true;

                    if (m_BrightSalesProperty.CommonProperty.CurrentTab == SelectionProperty.CurrentTab.CampaignBooking)
                    {
                        m_EventBus.Notify(new LinkedInEvents.OnSave.ManageCampaignBooking()
                        {
                            OnSaveArgs = new LinkedInEvents.LinkedInArgs()
                            {
                                LinkedInUrl = txtAddressBar.Text
                            }
                        });
                    }
                }

                NotificationDialog.Information("Bright Sales", "Successfully updated LinkedIn url.");
            }
            catch(Exception ex)
            {
                NotificationDialog.Error("Bright Sales", "An error has been encountered while trying to save LinkedIn url.\nPlease consult system administrator.");
            }
        }
Beispiel #30
0
        /// <summary>
        /// Function to save user data
        /// </summary>
        public static int SaveUser(bool isNew, UserInstance objParams, bool hasChangedPassword)
        {
            user objEntityUser = null;
            using (BrightPlatformEntities m_objBrightPlatformEntity = new BrightPlatformEntities(UserSession.EntityConnection)) {
                objEntityUser = m_objBrightPlatformEntity.users.CreateObject();
                if (!isNew) {
                    objEntityUser = null;
                    objEntityUser = m_objBrightPlatformEntity.users.Where(i => i.id == objParams.id).FirstOrDefault();
                }
                else {
                    objEntityUser.created_by = UserSession.CurrentUser.UserId;
                    objEntityUser.created_date = DateTime.Now;
                }

                string _OldPassword = objEntityUser.password;

                objEntityUser.fullname = objParams.full_name;
                //objEntityUser.last_name = objParams.last_name;
                objEntityUser.title = objParams.title;
                objEntityUser.reports_to = Convert.ToInt16(objParams.reports_to);
                objEntityUser.site = objParams.site;
                objEntityUser.disabled = Convert.ToInt16(objParams.active == true ? 0 : 1);
                objEntityUser.sip_id = objParams.sip_id;
                objEntityUser.phone1 = objParams.phone;
                objEntityUser.mobile_no = objParams.mobile;
                objEntityUser.email = objParams.email;
                objEntityUser.username = objParams.username;
                objEntityUser.internal_user = objParams.internal_user;
                objEntityUser.modified_by = UserSession.CurrentUser.UserId;
                objEntityUser.modified_date = DateTime.Now;

                if (hasChangedPassword)
                    objEntityUser.password = HashUtility.GetHashPassword(objParams.password);

                if (isNew)
                    m_objBrightPlatformEntity.users.AddObject(objEntityUser);

                m_objBrightPlatformEntity.change_password_logs.AddObject(new change_password_logs() {
                    user_id = objParams.id,
                    new_password = objParams.password,
                    old_password = _OldPassword,
                    updated_by = UserSession.CurrentUser.UserId,
                    updated_on = DateTime.Now
                });

                m_objBrightPlatformEntity.SaveChanges();
                m_objBrightPlatformEntity.Detach(objEntityUser);
            }
            return objEntityUser.id;
        }