Exemplo n.º 1
0
        public ConfigurationViewModel GetConfigInfoByProjectId(string projectId)
        {
            int id = -1;

            int.TryParse(projectId, out id);
            var         accounts    = m_dbAdapter.BankAccount.GetAccounts(id, false);
            var         contacts    = m_dbAdapter.Contact.GetContacts(id);
            var         reminders   = m_dbAdapter.Reminder.GetReminders(id);
            var         setting     = m_dbAdapter.RemindSetting.GetSettingByProjectId(id);
            NewsSetting newsSetting = m_dbAdapter.Monitor.GetNewsSettingByProjectId(id);

            if (newsSetting == null)
            {
                newsSetting = new NewsSetting()
                {
                    KeyWords = "", Range = ""
                };
            }

            if (setting == null)
            {
                RemindSettings rs = new RemindSettings()
                {
                    ProjectId   = id,
                    Frequency   = int.Parse(MyEnumConvertor.MyRemindSettingDictionary["H24"]),
                    RemindType  = int.Parse(MyEnumConvertor.MyRemindSettingDictionary["短信加邮件"]),
                    AutoRemind  = false,
                    RemindDaily = false,
                };
                m_dbAdapter.RemindSetting.AddRemindSettings(rs);
                setting = m_dbAdapter.RemindSetting.GetSettingByProjectId(id);
            }

            ConfigurationViewModel model = new ConfigurationViewModel();

            model.AccountList    = accounts;
            model.ContactList    = contacts;
            model.ReminderList   = reminders;
            model.RemindSettings = setting;
            model.NewsSetting    = newsSetting;

            if (id > 0)
            {
                var project = m_dbAdapter.Project.GetProjectById(id);
                model.CurrentProjectGuid = project.ProjectGuid;
            }

            return(model);
        }
Exemplo n.º 2
0
        public NewsSetting GetNewsSettingByProjectId(int projectId)
        {
            NewsSetting newsSetting = m_db.SingleOrDefault <NewsSetting>(" select names as keyWords , range as range from dbo.Objects where project_id = @0", projectId);

            return(newsSetting);
        }