コード例 #1
0
        public ContactStatusWrapper UpdateContactStatus(int id, string title, string description, string color, int sortOrder)
        {
            if (!(CRMSecurity.IsAdmin)) throw CRMSecurity.CreateSecurityException();

            if (id <= 0 || string.IsNullOrEmpty(title)) throw new ArgumentException();

            var curListItemExist = DaoFactory.GetListItemDao().IsExist(id);
            if (!curListItemExist) throw new ItemNotFoundException();

            var listItem = new ListItem
                {
                    ID = id,
                    Title = title,
                    Description = description,
                    Color = color,
                    SortOrder = sortOrder
                };

            DaoFactory.GetListItemDao().EditItem(ListType.ContactStatus, listItem);
            MessageService.Send(_context, MessageAction.ContactTemperatureLevelUpdated, listItem.Title);

            return ToContactStatusWrapper(listItem);
        }
コード例 #2
0
 public static void DemandEdit(ListItem listItem)
 {
     if (!CanEdit(listItem)) throw CreateSecurityException();
 }
コード例 #3
0
        public virtual void EditItem(ListType listType, ListItem enumItem)
        {

            if (HaveRelativeItemsLink(listType, enumItem.ID))
                throw new ArgumentException();

            using (var db = GetDb())
            {
                db.ExecuteNonQuery(Update("crm_list_item")
                                         .Set("description", enumItem.Description)
                                         .Set("title", enumItem.Title)
                                         .Set("additional_params", enumItem.AdditionalParams)
                                         .Set("color", enumItem.Color)
                                         .Where(Exp.Eq("id", enumItem.ID)));
            }

            AdminLog.PostAction("CRM: saved crm category of type \"{0}\" with parameters {1:Json}", listType, enumItem);
        }
コード例 #4
0
 public HistoryCategoryBaseWrapper(ListItem listItem)
     : base(listItem)
 {
     if (!String.IsNullOrEmpty(listItem.AdditionalParams))
         ImagePath = WebImageSupplier.GetAbsoluteWebPath(listItem.AdditionalParams, ProductEntryPoint.ID);
 }
コード例 #5
0
ファイル: ListItemDao.cs プロジェクト: ridhouan/teamlab.v6.5
        public virtual void EditItem(ListType listType, ListItem enumItem)
        {

            if (HaveRelativeItemsLink(listType, enumItem.ID))
                throw new ArgumentException();

            DbManager.ExecuteNonQuery(Update("crm_list_item")
                                      .Set("description", enumItem.Description)
                                      .Set("title", enumItem.Title)
                                      .Set("additional_params", enumItem.AdditionalParams)
                                      .Set("color", enumItem.Color)
                                      .Where(Exp.Eq("id", enumItem.ID)));


        }
コード例 #6
0
 public TaskCategoryWrapper(ListItem listItem)
     : base(listItem)
 {
 }
コード例 #7
0
 public ContactTypeWrapper(ListItem listItem)
     : base(listItem)
 {
 }
コード例 #8
0
        public ContactTypeWrapper UpdateContactType(int id, string title, int sortOrder)
        {
            if (!(CRMSecurity.IsAdmin)) throw CRMSecurity.CreateSecurityException();

            if (id <= 0 || string.IsNullOrEmpty(title)) throw new ArgumentException();

            var curListItemExist = DaoFactory.GetListItemDao().IsExist(id);
            if (!curListItemExist) throw new ItemNotFoundException();

            var listItem = new ListItem
                {
                    ID = id,
                    Title = title,
                    SortOrder = sortOrder
                };

            DaoFactory.GetListItemDao().EditItem(ListType.ContactType, listItem);
            MessageService.Send(Request, MessageAction.ContactTypeUpdated, listItem.Title);

            return ToContactTypeWrapper(listItem);
        }
コード例 #9
0
        public HistoryCategoryWrapper CreateHistoryCategory(String title,
                                               String description,
                                               String imageName,
                                               int sortOrder)
        {

            if (String.IsNullOrEmpty(title))
                throw new ArgumentException();

            var listItem = new ListItem
            {
                Title = title,
                Description = description,
                SortOrder = sortOrder,
                AdditionalParams = imageName
            };

            listItem.ID = DaoFactory.GetListItemDao().CreateItem(ListType.HistoryCategory, listItem);

            return ToHistoryCategoryWrapper(listItem);
        }
コード例 #10
0
        public ContactStatusWrapper CreateContactStatus(string title, string description, string color, int sortOrder)
        {
            if (!(CRMSecurity.IsAdmin)) throw CRMSecurity.CreateSecurityException();

            var listItem = new ListItem
                {
                    Title = title,
                    Description = description,
                    Color = color,
                    SortOrder = sortOrder
                };

            listItem.ID = DaoFactory.GetListItemDao().CreateItem(ListType.ContactStatus, listItem);
            MessageService.Send(Request, MessageAction.ContactTemperatureLevelCreated, listItem.Title);

            return ToContactStatusWrapper(listItem);
        }
コード例 #11
0
        public ContactTypeWrapper CreateContactType(string title, int sortOrder)
        {
            if (!(CRMSecurity.IsAdmin)) throw CRMSecurity.CreateSecurityException();

            var listItem = new ListItem
                {
                    Title = title,
                    Description = string.Empty,
                    SortOrder = sortOrder
                };

            listItem.ID = DaoFactory.GetListItemDao().CreateItem(ListType.ContactType, listItem);
            MessageService.Send(Request, MessageAction.ContactTypeCreated, listItem.Title);

            return ToContactTypeWrapper(listItem);
        }
コード例 #12
0
        public TaskCategoryWrapper UpdateTaskCategory(int id, string title, string description, string imageName, int sortOrder)
        {
            if (!(CRMSecurity.IsAdmin)) throw CRMSecurity.CreateSecurityException();

            if (id <= 0 || string.IsNullOrEmpty(title)) throw new ArgumentException();

            var curTaskCategoryExist = DaoFactory.GetListItemDao().IsExist(id);
            if (!curTaskCategoryExist) throw new ItemNotFoundException();

            var listItem = new ListItem
                {
                    Title = title,
                    Description = description,
                    SortOrder = sortOrder,
                    AdditionalParams = imageName,
                    ID = id
                };

            DaoFactory.GetListItemDao().EditItem(ListType.TaskCategory, listItem);
            MessageService.Send(Request, MessageAction.CrmTaskCategoryUpdated, listItem.Title);

            return ToTaskCategoryWrapper(listItem);
        }
コード例 #13
0
        public TaskCategoryWrapper CreateTaskCategory(string title, string description, string imageName, int sortOrder)
        {
            if (!(CRMSecurity.IsAdmin)) throw CRMSecurity.CreateSecurityException();

            var listItem = new ListItem
                {
                    Title = title,
                    Description = description,
                    SortOrder = sortOrder,
                    AdditionalParams = imageName
                };

            listItem.ID = DaoFactory.GetListItemDao().CreateItem(ListType.TaskCategory, listItem);
            MessageService.Send(Request, MessageAction.CrmTaskCategoryCreated, listItem.Title);

            return ToTaskCategoryWrapper(listItem);
        }
コード例 #14
0
ファイル: ListItemDao.cs プロジェクト: vipwan/CommunityServer
        public virtual void EditItem(ListType listType, ListItem enumItem)
        {

            if (HaveRelativeItemsLink(listType, enumItem.ID))
            switch (listType)
            {
                case ListType.ContactStatus:
                case ListType.ContactType:
                    throw new ArgumentException(String.Format("{0}. {1}.", CRMErrorsResource.BasicCannotBeEdited, CRMErrorsResource.HasRelatedContacts));
                case ListType.TaskCategory:
                    throw new ArgumentException(String.Format("{0}. {1}.", CRMErrorsResource.BasicCannotBeEdited, CRMErrorsResource.TaskCategoryHasRelatedTasks));
                case ListType.HistoryCategory:
                    throw new ArgumentException(String.Format("{0}. {1}.", CRMErrorsResource.BasicCannotBeEdited, CRMErrorsResource.HistoryCategoryHasRelatedEvents));
                default:
                    throw new ArgumentException(String.Format("{0}.", CRMErrorsResource.BasicCannotBeEdited));
            }



            using (var db = GetDb())
            {
                db.ExecuteNonQuery(Update("crm_list_item")
                                         .Set("description", enumItem.Description)
                                         .Set("title", enumItem.Title)
                                         .Set("additional_params", enumItem.AdditionalParams)
                                         .Set("color", enumItem.Color)
                                         .Where(Exp.Eq("id", enumItem.ID)));
            }
        }
コード例 #15
0
        public ContactType(ListItem listItem)
            : base(listItem)
        {

        }
コード例 #16
0
        public HistoryCategoryWrapper UpdateHistoryCategory(
           int id, 
           String title,
           String description,
           String imageName,
           int sortOrder)
        {

            if (String.IsNullOrEmpty(title))
                throw new ArgumentException();

            var listItem = new ListItem
            {
                Title = title,
                Description = description,
                SortOrder = sortOrder,
                AdditionalParams = imageName,
                ID = id
            };
            
            CRMSecurity.DemandEdit(listItem);

            DaoFactory.GetListItemDao().EditItem(ListType.HistoryCategory, listItem);

            return ToHistoryCategoryWrapper(listItem);
        }
コード例 #17
0
 public TaskCategoryBaseWrapper(ListItem listItem)
     : base(listItem)
 {
     ImagePath = WebImageSupplier.GetAbsoluteWebPath(listItem.AdditionalParams, ProductEntryPoint.ID);
 }
コード例 #18
0
        public TaskCategory CreateTaskCategory(String title,
                                               String description,
                                               String imageName,
                                               int sortOrder)
        {

            var listItem = new ListItem
            {
                Title = title,
                Description = description,
                SortOrder = sortOrder,
                AdditionalParams = imageName
            };

            listItem.ID = DaoFactory.GetListItemDao().CreateItem(ListType.TaskCategory, listItem);

            return ToTaskCategory(listItem);
        }
コード例 #19
0
 public ContactStatusWrapper(ListItem listItem)
     : base(listItem)
 {
 }
コード例 #20
0
        public TaskCategory UpdateTaskCategory(
           int id,
           String title,
           String description,
           String imageName,
           int sortOrder)
        {

            if (id <= 0)
                throw new ArgumentException();

            var curTaskCategory = DaoFactory.GetListItemDao().GetByID(id);

            if (curTaskCategory == null)
                throw new ItemNotFoundException();

            var listItem = new ListItem
            {
                Title = title,
                Description = description,
                SortOrder = sortOrder,
                AdditionalParams = imageName,
                ID = id 
            };

            CRMSecurity.DemandEdit(listItem);


            DaoFactory.GetListItemDao().EditItem(ListType.TaskCategory, listItem);

            return ToTaskCategory(listItem);
        }
コード例 #21
0
 protected ListItemWrapper(ListItem listItem)
     : base(listItem.ID)
 {
     Title = listItem.Title;
     Description = listItem.Description;
     Color = listItem.Color;
     SortOrder = listItem.SortOrder;
 }
コード例 #22
0
        public ContactType UpdateContactType(
            int id, 
            String title,
            String description,
            String color,
            int sortOrder)
        {
            var listItem = new ListItem
            {
                Title = title,
                Description = description,
                Color = color,
                SortOrder = sortOrder
            };

            
            CRMSecurity.DemandEdit(listItem);

            listItem.ID = DaoFactory.GetListItemDao().CreateItem(ListType.ContactStatus, listItem);

            return ToContactType(listItem);
        }
コード例 #23
0
 public HistoryCategoryWrapper(ListItem listItem)
     : base(listItem)
 {
 }
コード例 #24
0
        public ContactType ToContactType(ListItem listItem)
        {
            var result = new ContactType(listItem)
            {
                RelativeItemsCount = DaoFactory.GetListItemDao().GetRelativeItemsCount(ListType.ContactStatus, listItem.ID)

            };

            return result;
        }
コード例 #25
0
 public static bool CanEdit(ListItem listItem)
 {
     return IsAdmin;
 }
コード例 #26
0
        public HistoryCategoryWrapper ToHistoryCategoryWrapper(ListItem listItem)
        {
            var result = new HistoryCategoryWrapper(listItem)
            {
                                 RelativeItemsCount = DaoFactory.GetListItemDao().GetRelativeItemsCount(ListType.HistoryCategory,listItem.ID)

                             };

            return result;
        }
コード例 #27
0
        public virtual int CreateItem(ListType listType, ListItem enumItem)
        {

            if (IsExist(listType, enumItem.Title))
                return GetByTitle(listType, enumItem.Title).ID;

            if (String.IsNullOrEmpty(enumItem.Title))
                throw new ArgumentException();

            if (listType == ListType.TaskCategory || listType == ListType.HistoryCategory)
                if (String.IsNullOrEmpty(enumItem.AdditionalParams))
                    throw new ArgumentException();
                else
                   enumItem.AdditionalParams = System.IO.Path.GetFileName(enumItem.AdditionalParams);
                
            if (listType == ListType.ContactStatus)
                if (String.IsNullOrEmpty(enumItem.Color))
                    throw new ArgumentException();

            var sortOrder = enumItem.SortOrder;

            using (var db = GetDb())
            {
                if (sortOrder == 0)
                    sortOrder = db.ExecuteScalar<int>(Query("crm_list_item")
                                                            .Where(Exp.Eq("list_type", (int)listType))
                                                            .SelectMax("sort_order")) + 1;

                AdminLog.PostAction("CRM: saved crm category of type \"{0}\" with parameters {1:Json}", listType, enumItem);

                return db.ExecuteScalar<int>(
                                                  Insert("crm_list_item")
                                                  .InColumnValue("id", 0)
                                                  .InColumnValue("list_type", (int)listType)
                                                  .InColumnValue("description", enumItem.Description)
                                                  .InColumnValue("title", enumItem.Title)
                                                  .InColumnValue("additional_params", enumItem.AdditionalParams)
                                                  .InColumnValue("color", enumItem.Color)
                                                  .InColumnValue("sort_order", sortOrder)
                                                  .Identity(1, 0, true));
            }
        }
コード例 #28
0
        public TaskCategory ToTaskCategory(ListItem listItem)
        {

            var result = new TaskCategory(listItem)
                             {
                                 RelativeItemsCount = DaoFactory.GetListItemDao().GetRelativeItemsCount(ListType.TaskCategory,listItem.ID)

                             };

            return result;
        }
コード例 #29
0
        public override void EditItem(ListType listType, ListItem enumItem)
        {
            ResetCache(enumItem.ID);

            base.EditItem(listType, enumItem);
        }
コード例 #30
0
        public HistoryCategoryWrapper CreateHistoryCategory(string title, string description, string imageName, int sortOrder)
        {
            if (!(CRMSecurity.IsAdmin)) throw CRMSecurity.CreateSecurityException();

            if (string.IsNullOrEmpty(title)) throw new ArgumentException();

            var listItem = new ListItem
                {
                    Title = title,
                    Description = description,
                    SortOrder = sortOrder,
                    AdditionalParams = imageName
                };

            listItem.ID = DaoFactory.GetListItemDao().CreateItem(ListType.HistoryCategory, listItem);
            MessageService.Send(_context, MessageAction.HistoryEventCategoryCreated, listItem.Title);

            return ToHistoryCategoryWrapper(listItem);
        }