Ejemplo n.º 1
0
        public IEnumerable<MessageWrapper> GetMessageByFilter(int projectid, int tag, Guid departament, Guid participant,
                                                              ApiDateTime createdStart, ApiDateTime createdStop, int lastId,
                                                              bool myProjects, bool follow, MessageStatus? status)
        {
            var messageEngine = EngineFactory.GetMessageEngine();
            var taskFilter = new TaskFilter
            {
                DepartmentId = departament,
                UserId = participant,
                FromDate = createdStart,
                ToDate = createdStop,
                SortBy = _context.SortBy,
                SortOrder = !_context.SortDescending,
                SearchText = _context.FilterValue,
                TagId = tag,
                Offset = _context.StartIndex,
                Max = _context.Count,
                MyProjects = myProjects,
                LastId = lastId,
                Follow = follow,
                MessageStatus = status
            };

            if (projectid != 0)
                taskFilter.ProjectIds.Add(projectid);

            _context.SetDataPaginated();
            _context.SetDataFiltered();
            _context.SetDataSorted();
            _context.TotalCount = messageEngine.GetByFilterCount(taskFilter);

            return messageEngine.GetByFilter(taskFilter).NotFoundIfNull().Select(r => new MessageWrapper(r)).ToSmartList();
        }
Ejemplo n.º 2
0
 public SimpleTaskWrapper(Task task)
 {
     ID = task.ID;
     Title = task.Title;
     Description = task.Description;
     Deadline = (ApiDateTime)task.Deadline;
 }
        public IEnumerable<TimeWrapper> GetTaskTimeByFilter(int projectid, bool myProjects, int? milestone, bool myMilestones, int tag,
            Guid departament, Guid participant, ApiDateTime createdStart, ApiDateTime createdStop, int lastId, PaymentStatus? status)
        {
            var taskFilter = new TaskFilter
            {
                DepartmentId = departament,
                UserId = participant,
                FromDate = createdStart,
                ToDate = createdStop,
                SortBy = _context.SortBy,
                SortOrder = !_context.SortDescending,
                SearchText = _context.FilterValue,
                TagId = tag,
                Offset = _context.StartIndex,
                Max = _context.Count,
                LastId = lastId,
                MyProjects = myProjects,
                MyMilestones = myMilestones,
                Milestone = milestone
            };

            if (projectid != 0)
                taskFilter.ProjectIds.Add(projectid);

            if (status.HasValue)
                taskFilter.PaymentStatuses.Add(status.Value);

            _context.SetDataPaginated();
            _context.SetDataFiltered();
            _context.SetDataSorted();

            return EngineFactory.GetTimeTrackingEngine().GetByFilter(taskFilter).NotFoundIfNull().Select(r => new TimeWrapper(r)).ToSmartList();
        }
Ejemplo n.º 4
0
 public MilestoneWrapper(Milestone milestone)
 {
     Id = milestone.ID;
     ProjectOwner = new SimpleProjectWrapper(milestone.Project);
     Title = milestone.Title;
     Description = milestone.Description;
     Created = (ApiDateTime)milestone.CreateOn;
     CreatedBy = EmployeeWraper.Get(milestone.CreateBy);
     Updated = (ApiDateTime)milestone.LastModifiedOn;
     if (milestone.CreateBy != milestone.LastModifiedBy)
     {
         UpdatedBy = EmployeeWraper.Get(milestone.LastModifiedBy);
     }
     if (!milestone.Responsible.Equals(Guid.Empty))
     {
         Responsible = EmployeeWraper.Get(milestone.Responsible);
     }
     Status = (int)milestone.Status;
     Deadline = new ApiDateTime(milestone.DeadLine, TimeZoneInfo.Local);
     IsKey = milestone.IsKey;
     IsNotify = milestone.IsNotify;
     CanEdit = ProjectSecurity.CanEdit(milestone);
     CanDelete = ProjectSecurity.CanDelete(milestone);
     ActiveTaskCount = milestone.ActiveTaskCount;
     ClosedTaskCount = milestone.ClosedTaskCount;
 }
Ejemplo n.º 5
0
        public ReportTemplateWrapper SaveReportTemplate(string name, string period, int periodItem, int hour, bool autoGenerated, ReportType reportType,
                                         int tag, int project, TaskStatus? status, Guid departament, Guid userId, ReportTimeInterval reportTimeInterval,
                                         ApiDateTime fromDate, ApiDateTime toDate, int viewType, bool noResponsible)
        {
            ProjectSecurity.DemandAuthentication();

            if (name == null || name.Trim().Length == 0) throw new ArgumentNullException("name");

            var filter = new TaskFilter
            {
                TagId = tag,
                DepartmentId = departament,
                UserId = userId,
                TimeInterval = reportTimeInterval,
                FromDate = fromDate,
                ToDate = toDate,
                ViewType = viewType,
                NoResponsible = noResponsible
            };

            if (project != 0)
                filter.ProjectIds.Add(project);

            if (status != null)
                filter.TaskStatuses.Add((TaskStatus)status);

            var template = new ReportTemplate(reportType) { Filter = filter };

            SaveOrUpdateTemplate(template, name, period, periodItem, hour, autoGenerated);

            return new ReportTemplateWrapper(template);
        }
Ejemplo n.º 6
0
 public PageWrapper(Page page)
 {
     Name = page.PageName;
     Content = page.Body;
     UpdatedBy = EmployeeWraper.Get(Core.CoreContext.UserManager.GetUsers(page.UserID));
     Updated = (ApiDateTime)page.Date;
 }
Ejemplo n.º 7
0
        public ReportWrapper BuildContactPopulateReport(
            ApiDateTime fromDate,
            ApiDateTime toDate,
            bool? isCompany,
            string tagName,
            int contactType)
        {
            var reportData = DaoFactory.GetReportDao().BuildContactPopulateReport(fromDate, toDate, isCompany, tagName, contactType);
            var report = new ReportWrapper
                {
                    ReportTitle = CRMReportResource.Report_ContactPopulate_Title,
                    ReportDescription = CRMReportResource.Report_ContactPopulate_Description,
                    Data = reportData.ConvertAll(row => new
                        {
                            Date = (ApiDateTime)TenantUtil.DateTimeFromUtc(DateTime.Parse(Convert.ToString(row[0]))),
                            Count = row[1]
                        }),
                    Lables = new List<string>
                        {
                            CRMCommonResource.Date,
                            CRMCommonResource.Count
                        }
                };

            return report;
        }
Ejemplo n.º 8
0
 public void TestUtc()
 {
     var apiDateTime1 = new ApiDateTime(DateTime.Now,TimeZoneInfo.Utc);
     var dateTime = (DateTime)apiDateTime1;
     var utcTime = apiDateTime1.UtcTime;
     Assert.AreEqual(dateTime.Kind, utcTime.Kind);
     Assert.AreEqual(dateTime, utcTime);
 }
Ejemplo n.º 9
0
 public void TestLocal()
 {
     var apiDateTime1 = new ApiDateTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time"));
     var dateTime = (DateTime)apiDateTime1;
     var utcTime = apiDateTime1.UtcTime;
     Assert.AreEqual(dateTime.Kind, utcTime.Kind);
     Assert.AreEqual(dateTime, utcTime);
 }
Ejemplo n.º 10
0
 public SearchItemWrapper(SearchItem searchItem)
 {
     Id = searchItem.ID;
     Title = searchItem.Title;
     EntityType = searchItem.EntityType;
     Created = (ApiDateTime) searchItem.CreateOn;
     Description = searchItem.Description;
 }
Ejemplo n.º 11
0
 public void Test00()
 {
     var apiDateTime1 = new ApiDateTime(DateTime.Now);
     var stringrep = apiDateTime1.ToString();
     var dateTime = (DateTime)apiDateTime1;
     var utcTime = apiDateTime1.UtcTime;
     Assert.AreEqual(dateTime.Kind, utcTime.Kind);
     Assert.AreEqual(dateTime, utcTime);
 }
Ejemplo n.º 12
0
        public static List<EventWrapper> GetEventWrappers(this BaseCalendar calendar, Guid userId, ApiDateTime startDate, ApiDateTime endDate)
        {   
            var result = new List<EventWrapper>();
            if (calendar != null)
            {
                var events = calendar.LoadEvents(userId, startDate.UtcTime, endDate.UtcTime);
                events.ForEach(e => result.AddRange(new EventWrapper(e, userId, calendar.TimeZone).GetList(startDate.UtcTime, endDate.UtcTime)));
            }

            return result;
        }
Ejemplo n.º 13
0
        public IEnumerable<MailMessageItem> GetFilteredMessages(int? folder,
            bool? unread,
            bool? attachments,
            long? period_from,
            long? period_to,
            bool? important,
            string find_address,
            int? mailbox_id,
            IEnumerable<int> tags,
            string search,
            int? page,
            int? page_size,
            ApiDateTime last_check_date,
            string sort,
            string sortorder
            )
        {
            var filter = new MailFilter
            {
                PrimaryFolder = folder.GetValueOrDefault(MailFolder.Ids.inbox),
                Unread = unread,
                Attachments = attachments.GetValueOrDefault(false),
                Period_from = period_from.GetValueOrDefault(0),
                Period_to = period_to.GetValueOrDefault(0),
                Important = important.GetValueOrDefault(false),
                FindAddress = find_address,
                MailboxId = mailbox_id,
                CustomLabels = new ItemList<int>(tags),
                SearchFilter = search,
                PageSize = page_size.GetValueOrDefault(25),
                SortOrder = sortorder
            };

            MailBoxManager.UpdateUserActivity(TenantId, Username);

            if (null != last_check_date)
            {
                var date_time = MailBoxManager.GetFolderModifyDate(TenantId, Username, filter.PrimaryFolder);
                var api_date = new ApiDateTime(date_time);

                var compare_rez = api_date.CompareTo(last_check_date);

                if (compare_rez == 0) // equals
                    return null;
                if (compare_rez == -1) // less
                    return new List<MailMessageItem>();
            }

            long total_messages;
            var messages = GetFilteredMessages(filter, filter.Page, filter.PageSize, out total_messages);
            CorrectPageValue(filter, total_messages);
            _context.SetTotalCount(total_messages);
            return messages;
        }
Ejemplo n.º 14
0
        public object GetFeed(
            string product,
            ApiDateTime from,
            ApiDateTime to,
            Guid? author,
            bool? onlyNew,
            ApiDateTime timeReaded)
        {
            var filter = new FeedApiFilter
                {
                    Product = product,
                    From = from != null ? from.UtcTime : DateTime.MinValue,
                    To = to != null ? to.UtcTime : DateTime.MaxValue,
                    Offset = (int)context.StartIndex,
                    Max = (int)context.Count - 1,
                    Author = author ?? Guid.Empty,
                    SearchKeys = context.FilterValues,
                    OnlyNew = onlyNew.HasValue && onlyNew.Value
                };

            var feedReadedProvider = new FeedReadedDataProvider();

            var lastTimeReaded = feedReadedProvider.GetTimeReaded();

            var readedDate = timeReaded != null ? (ApiDateTime)timeReaded.UtcTime : (ApiDateTime)lastTimeReaded;
            var commentReadedDate = (ApiDateTime)feedReadedProvider.GetTimeReaded("comments");

            if (filter.OnlyNew)
            {
                filter.From = (ApiDateTime)lastTimeReaded;
                filter.Max = 100;
            }
            else if (timeReaded == null)
            {
                feedReadedProvider.SetTimeReaded();
                feedReadedProvider.SetTimeReaded("comments");
            }

            var feeds = FeedAggregateDataProvider
                .GetFeeds(filter)
                .GroupBy(n => n.GroupId,
                         n => new FeedWrapper(n),
                         (n, group) =>
                             {
                                 var firstFeed = group.First();
                                 firstFeed.GroupedFeeds = group.Skip(1);
                                 return firstFeed;
                             })
                .ToList();

            context.SetDataPaginated();
            return new {feeds, readedDate, commentReadedDate};
        }
 public static CommentWrapper GetSample()
 {
     return(new CommentWrapper
     {
         Author = EmployeeWraper.GetSample(),
         Content = "Comment content",
         Id = Guid.Empty,
         Page = "Some page",
         Inactive = false,
         LastModified = ApiDateTime.GetSample(),
         ParentId = Guid.Empty
     });
 }
Ejemplo n.º 16
0
 public new static CustomFieldWrapper GetSample()
 {
     return(new CustomFieldWrapper(0)
     {
         Position = 10,
         EntityId = 14523423,
         FieldType = CustomFieldType.Date,
         FieldValue = ApiDateTime.GetSample().ToString(),
         Label = "Birthdate",
         Mask = "",
         RelativeItemsCount = 0
     });
 }
Ejemplo n.º 17
0
 public VoipCallWrapper(VoipCall call, ContactWrapper contact = null)
 {
     Id           = call.Id;
     From         = call.From;
     To           = call.To;
     Status       = call.Status;
     AnsweredBy   = EmployeeWraper.Get(call.AnsweredBy);
     DialDate     = new ApiDateTime(call.DialDate);
     DialDuration = call.DialDuration;
     Cost         = call.TotalPrice;
     Contact      = contact;
     History      = call.History.Select(h => new VoipCallHistoryWrapper(h));
 }
Ejemplo n.º 18
0
 public static ForumCategoryWrapper GetSample()
 {
     return(new ForumCategoryWrapper()
     {
         Created = ApiDateTime.GetSample(),
         Description = "Sample category",
         Title = "Sample title",
         Updated = ApiDateTime.GetSample(),
         Threads = new List <ForumThreadWrapper> {
             ForumThreadWrapper.GetSample()
         }
     });
 }
Ejemplo n.º 19
0
 public VoipCallWrapper(VoipCall call, ContactWrapper contact = null)
 {
     Id = call.Id;
     From = call.From;
     To = call.To;
     Status = call.Status;
     AnsweredBy = EmployeeWraper.Get(call.AnsweredBy);
     DialDate = new ApiDateTime(call.DialDate);
     DialDuration = call.DialDuration;
     Cost = call.TotalPrice;
     Contact = contact;
     History = call.History.Select(h => new VoipCallHistoryWrapper(h));
 }
Ejemplo n.º 20
0
        public IEnumerable<MailBoxManager.MailFolderInfo> GetFolders(ApiDateTime last_check_time)
        {
            if (null != last_check_time)
            {
                var api_date = new ApiDateTime(mailBoxManager.GetMessagesModifyDate(TenantId, Username));
                var compare_rez = api_date.CompareTo(last_check_time);

                if (compare_rez < 1 && System.DateTime.MinValue != api_date) // if api_date == DateTime.MinValue then there are no folders in mail_folder
                {
                    return null;
                }
            }
            return FoldersList;
        }
 public static ForumThreadWrapper GetSample()
 {
     return(new ForumThreadWrapper()
     {
         Created = ApiDateTime.GetSample(),
         Updated = ApiDateTime.GetSample(),
         Description = "Sample thread",
         Id = 10,
         UpdatedBy = EmployeeWraper.GetSample(),
         RecentTopicId = 1234,
         RecentTopicTitle = "Sample topic",
         Title = "The Thread"
     });
 }
Ejemplo n.º 22
0
 public static RelationshipEventDto GetSample()
 {
     return(new RelationshipEventDto
     {
         CanEdit = true,
         Category = HistoryCategoryBaseDto.GetSample(),
         Entity = EntityDto.GetSample(),
         Contact = ContactBaseDto.GetSample(),
         Created = ApiDateTime.GetSample(),
         CreateBy = EmployeeWraper.GetSample(),
         Files = new[] { FileWrapper <int> .GetSample() },
         Content = @"Agreed to meet at lunch and discuss the client commercial offer"
     });
 }
Ejemplo n.º 23
0
 public static new EventWrapperFull GetSample()
 {
     return(new EventWrapperFull()
     {
         CreatedBy = EmployeeWraper.GetSample(),
         Created = ApiDateTime.GetSample(),
         Id = 10,
         Type = FeedType.News,
         Title = "Sample news",
         Updated = ApiDateTime.GetSample(),
         Text = "Text of feed",
         Poll = PollWrapper.GetSample()
     });
 }
Ejemplo n.º 24
0
 public static BookmarkWrapper GetSample()
 {
     return(new BookmarkWrapper
     {
         Id = 11,
         CreatedBy = EmployeeWraper.GetSample(),
         Created = ApiDateTime.GetSample(),
         Updated = ApiDateTime.GetSample(),
         Description = "Google",
         Thumbnail = "Url to thumbnail",
         Title = "Google inc.",
         Url = "http://www.google.com"
     });
 }
Ejemplo n.º 25
0
        public IEnumerable <MailBoxManager.MailFolderInfo> GetFolders(ApiDateTime last_check_time)
        {
            if (null != last_check_time)
            {
                var api_date    = new ApiDateTime(MailBoxManager.GetMessagesModifyDate(TenantId, Username));
                var compare_rez = api_date.CompareTo(last_check_time);

                if (compare_rez < 1 && System.DateTime.MinValue != api_date) // if api_date == DateTime.MinValue then there are no folders in mail_folder
                {
                    return(null);
                }
            }
            return(FoldersList);
        }
Ejemplo n.º 26
0
        public IEnumerable <TimeWrapper> GetTaskTimeByFilter(
            int projectid,
            bool myProjects,
            int?milestone,
            bool myMilestones,
            int tag,
            Guid departament,
            Guid participant,
            ApiDateTime createdStart,
            ApiDateTime createdStop,
            int lastId,
            PaymentStatus?status)
        {
            var taskFilter = new TaskFilter
            {
                DepartmentId = departament,
                UserId       = participant,
                FromDate     = createdStart,
                ToDate       = createdStop,
                SortBy       = _context.SortBy,
                SortOrder    = !_context.SortDescending,
                SearchText   = _context.FilterValue,
                TagId        = tag,
                Offset       = _context.StartIndex,
                Max          = _context.Count,
                LastId       = lastId,
                MyProjects   = myProjects,
                MyMilestones = myMilestones,
                Milestone    = milestone
            };

            if (projectid != 0)
            {
                taskFilter.ProjectIds.Add(projectid);
            }

            if (status.HasValue)
            {
                taskFilter.PaymentStatuses.Add(status.Value);
            }

            _context.SetDataPaginated();
            _context.SetDataFiltered();
            _context.SetDataSorted();

            _context.TotalCount = EngineFactory.GetTimeTrackingEngine().GetByFilterCount(taskFilter);

            return(EngineFactory.GetTimeTrackingEngine().GetByFilter(taskFilter).NotFoundIfNull().Select(r => new TimeWrapper(r)).ToSmartList());
        }
Ejemplo n.º 27
0
        public IEnumerable <OpportunityWrapper> SetAccessToBatchDeal(
            Guid responsibleid,
            int opportunityStagesid,
            IEnumerable <string> tags,
            int contactid,
            DealMilestoneStatus?stageType,
            bool?contactAlsoIsParticipant,
            ApiDateTime fromDate,
            ApiDateTime toDate,
            bool isPrivate,
            IEnumerable <Guid> accessList
            )
        {
            var result = new List <Deal>();
            var deals  = DaoFactory.GetDealDao()
                         .GetDeals(_context.FilterValue,
                                   responsibleid,
                                   opportunityStagesid,
                                   tags,
                                   contactid,
                                   stageType,
                                   contactAlsoIsParticipant,
                                   fromDate, toDate, 0, 0, null);

            if (!deals.Any())
            {
                return(Enumerable.Empty <OpportunityWrapper>());
            }

            var aList = accessList.ToList();

            foreach (var deal in deals)
            {
                if (deal == null)
                {
                    throw new ItemNotFoundException();
                }

                if (!(CRMSecurity.IsAdmin || deal.CreateBy == SecurityContext.CurrentAccount.ID))
                {
                    continue;
                }

                SetAccessToDeal(deal.ID, isPrivate, aList);
                result.Add(deal);
            }

            return(ToListOpportunityWrapper(result));
        }
Ejemplo n.º 28
0
 public static TaskWrapper GetSample()
 {
     return new TaskWrapper(0)
         {
             Created = ApiDateTime.GetSample(),
             CreateBy = EmployeeWraper.GetSample(),
             DeadLine = ApiDateTime.GetSample(),
             IsClosed = false,
             Responsible = EmployeeWraper.GetSample(),
             Category = TaskCategoryBaseWrapper.GetSample(),
             CanEdit = true,
             Title = "Send a commercial offer",
             AlertValue = 0
         };
 }
Ejemplo n.º 29
0
 public static BlogPostWrapperFull GetSample()
 {
     return(new BlogPostWrapperFull
     {
         CreatedBy = EmployeeWraper.GetSample(),
         Created = ApiDateTime.GetSample(),
         Updated = ApiDateTime.GetSample(),
         Id = Guid.Empty,
         Text = "Post text",
         Tags = new List <string> {
             "Tag1", "Tag2"
         },
         Title = "Example post"
     });
 }
Ejemplo n.º 30
0
 public static BlogPostWrapperSummary GetSample()
 {
     return(new BlogPostWrapperSummary
     {
         CreatedBy = EmployeeWraper.GetSample(),
         Created = ApiDateTime.GetSample(),
         Id = Guid.Empty,
         Preview = "Preview post",
         Tags = new List <string> {
             "Tag1", "Tag2"
         },
         Title = "Example post",
         Updated = ApiDateTime.GetSample()
     });
 }
 public static SubtaskWrapper GetSample()
 {
     return(new SubtaskWrapper
     {
         Id = 1233,
         Title = "Sample subtask",
         Description = "Sample description",
         Status = (int)TaskStatus.Open,
         Responsible = EmployeeWraper.GetSample(),
         Created = ApiDateTime.GetSample(),
         CreatedBy = EmployeeWraper.GetSample(),
         Updated = ApiDateTime.GetSample(),
         UpdatedBy = EmployeeWraper.GetSample(),
     });
 }
 public static ForumTopicPostWrapper GetSample()
 {
     return(new ForumTopicPostWrapper
     {
         Id = 123,
         CreatedBy = EmployeeWraper.GetSample(),
         Created = ApiDateTime.GetSample(),
         Updated = ApiDateTime.GetSample(),
         Subject = "Sample subject",
         Text = "Post text",
         Attachments = new List <ForumTopicPostAttachmentWrapper> {
             ForumTopicPostAttachmentWrapper.GetSample()
         }
     });
 }
 public static MessageWrapper GetSample()
 {
     return(new MessageWrapper
     {
         Id = 10,
         ProjectOwner = SimpleProjectWrapper.GetSample(),
         Title = "Sample Title",
         Text = "Hello, this is sample message",
         Created = ApiDateTime.GetSample(),
         CreatedBy = EmployeeWraper.GetSample(),
         Updated = ApiDateTime.GetSample(),
         UpdatedBy = EmployeeWraper.GetSample(),
         CanEdit = true,
         CommentsCount = 5
     });
 }
Ejemplo n.º 34
0
        public static List<EventWrapper> GetEventWrappers(this BaseCalendar calendar, Guid userId, ApiDateTime startDate, ApiDateTime endDate)
        {   
            var result = new List<EventWrapper>();
            if (calendar != null)
            {
                var events = calendar.LoadEvents(userId, startDate.UtcTime, endDate.UtcTime);
                foreach (var e in events)
                {
                    var wrapper = new EventWrapper(e, userId, calendar.TimeZone);
                    var listWrapper = wrapper.GetList(startDate.UtcTime, endDate.UtcTime);
                    result.AddRange(listWrapper);
                }
            }

            return result;
        }
Ejemplo n.º 35
0
 public static ProjectWrapperFull GetSample()
 {
     return(new ProjectWrapperFull
     {
         Id = 10,
         Title = "Sample Title",
         Description = "Sample description",
         Status = (int)MilestoneStatus.Open,
         Responsible = EmployeeWraper.GetSample(),
         Created = ApiDateTime.GetSample(),
         CreatedBy = EmployeeWraper.GetSample(),
         Updated = ApiDateTime.GetSample(),
         UpdatedBy = EmployeeWraper.GetSample(),
         ProjectFolder = 13234
     });
 }
Ejemplo n.º 36
0
        /// <summary>
        /// 设置系统时间
        /// </summary>
        /// <param name="newDateTime">新时间</param>
        /// <returns></returns>
        public static bool SetDateTime(DateTime newDateTime)
        {
            int UtcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(new DateTime(2001, 09, 01)).Hours;
            newDateTime = newDateTime.AddHours(-UtcOffset);

            ApiDateTime st = new ApiDateTime();
            st.year = Convert.ToUInt16(newDateTime.Year);
            st.month = Convert.ToUInt16(newDateTime.Month);
            st.day = Convert.ToUInt16(newDateTime.Day);
            st.dayofweek = Convert.ToUInt16(newDateTime.DayOfWeek);
            st.hour = Convert.ToUInt16(newDateTime.Hour);
            st.minute = Convert.ToUInt16(newDateTime.Minute);
            st.second = Convert.ToUInt16(newDateTime.Second);
            st.milliseconds = Convert.ToUInt16(newDateTime.Millisecond);
            return SetSystemTime(st);
        }
Ejemplo n.º 37
0
 public new static PersonWrapper GetSample()
 {
     return(new PersonWrapper(0)
     {
         IsPrivate = true,
         IsShared = false,
         IsCompany = false,
         FirstName = "Tadjeddine",
         LastName = "Bachir",
         Company = CompanyWrapper.GetSample(),
         Title = "Programmer",
         About = "",
         Created = ApiDateTime.GetSample(),
         CreateBy = EmployeeWraper.GetSample(),
         ShareType = ShareType.None
     });
 }
Ejemplo n.º 38
0
 public static ForumTopicWrapper GetSample()
 {
     return(new ForumTopicWrapper()
     {
         Created = ApiDateTime.GetSample(),
         Updated = ApiDateTime.GetSample(),
         Id = 10,
         UpdatedBy = EmployeeWraper.GetSample(),
         Text = "This is sample post",
         Status = TopicStatus.Sticky,
         Tags = new List <string> {
             "Tag1", "Tag2"
         },
         Title = "Sample topic",
         Type = TopicType.Informational
     });
 }
 public static new ForumThreadWrapperFull GetSample()
 {
     return(new ForumThreadWrapperFull()
     {
         Created = ApiDateTime.GetSample(),
         Updated = ApiDateTime.GetSample(),
         Description = "Sample thread",
         Id = 10,
         UpdatedBy = EmployeeWraper.GetSample(),
         RecentTopicId = 1234,
         RecentTopicTitle = "Sample topic",
         Title = "The Thread",
         Topics = new List <ForumTopicWrapper> {
             ForumTopicWrapper.GetSample()
         }
     });
 }
Ejemplo n.º 40
0
 public static OpportunityWrapper GetSample()
 {
     return(new OpportunityWrapper(0)
     {
         CreateBy = EmployeeWraper.GetSample(),
         Created = ApiDateTime.GetSample(),
         Responsible = EmployeeWraper.GetSample(),
         Title = "Hotel catalogue",
         Description = "",
         ExpectedCloseDate = ApiDateTime.GetSample(),
         Contact = ContactBaseWrapper.GetSample(),
         IsPrivate = false,
         SuccessProbability = 65,
         BidType = BidType.FixedBid,
         Stage = DealMilestoneBaseWrapper.GetSample()
     });
 }
Ejemplo n.º 41
0
        public InvoiceWrapper UpdateInvoice(
            int id,
            string number,
            ApiDateTime issueDate,
            int templateType,
            int contactId,
            int consigneeId,
            int entityId,
            ApiDateTime dueDate,
            string language,
            string currency,
            decimal exchangeRate,
            string purchaseOrderNumber,
            string terms,
            string description,
            IEnumerable <InvoiceLineWrapper> invoiceLines)
        {
            var invoice = DaoFactory.GetInvoiceDao().GetByID(id);

            if (invoice == null)
            {
                throw new ItemNotFoundException();
            }

            invoice.Number              = number;
            invoice.IssueDate           = issueDate;
            invoice.TemplateType        = (InvoiceTemplateType)templateType;
            invoice.ContactID           = contactId;
            invoice.ConsigneeID         = consigneeId;
            invoice.EntityType          = EntityType.Opportunity;
            invoice.EntityID            = entityId;
            invoice.DueDate             = dueDate;
            invoice.Language            = language;
            invoice.Currency            = !String.IsNullOrEmpty(currency) ? currency.ToUpper(): null;;
            invoice.ExchangeRate        = exchangeRate;
            invoice.PurchaseOrderNumber = purchaseOrderNumber;
            invoice.Terms       = terms;
            invoice.Description = description;

            CRMSecurity.DemandCreateOrUpdate(invoice);

            DaoFactory.GetInvoiceDao().SaveOrUpdateInvoice(invoice);

            return(ToInvoiceWrapper(invoice));
        }
    IEnumerator DownloadConfig(string configUrl)
    {
        var url = configUrl + "?" + ApiDateTime.SecondsFromBegin();
        var www = new WWW(url);

        yield return(www);

        if (!string.IsNullOrEmpty(www.error))
        {
            if (retried >= retryTime)
            {
                if (delDownloadFailed != null)
                {
                    delDownloadFailed();
                }
            }
            else
            {
                retried++;
                AOutput.Log(url + " error:" + www.error);
                StartCoroutine(DownloadConfig(configUrl));
            }
        }
        else
        {
            var      text   = www.text;
            string[] alines = text.Split(new string[] { "\r", "\n" }, System.StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < alines.Length; i++)
            {
                if (alines[i].StartsWith("#") || alines[i].StartsWith("//"))
                {
                    continue;
                }
                string[] akeyvalue = alines[i].Split(new char[] { '=' }, 2);
                dKeyValue.Add(akeyvalue[0], akeyvalue[1]);
            }

            if (delDownloadComplete != null)
            {
                delDownloadComplete();
            }
            UEventListener.Instance.DispatchEvent(UEvents.DownloadCompleteEvent, true);
        }
        www.Dispose();
    }
Ejemplo n.º 43
0
        public float GetTotalTaskTimeByFilter(
            int projectid,
            bool myProjects,
            int?milestone,
            bool myMilestones,
            int tag,
            Guid departament,
            Guid participant,
            ApiDateTime createdStart,
            ApiDateTime createdStop,
            int lastId,
            PaymentStatus?status)
        {
            var taskFilter = new TaskFilter
            {
                DepartmentId = departament,
                UserId       = participant,
                FromDate     = createdStart,
                ToDate       = createdStop,
                SortBy       = _context.SortBy,
                SortOrder    = !_context.SortDescending,
                SearchText   = _context.FilterValue,
                TagId        = tag,
                LastId       = lastId,
                MyProjects   = myProjects,
                MyMilestones = myMilestones,
                Milestone    = milestone
            };

            if (projectid != 0)
            {
                taskFilter.ProjectIds.Add(projectid);
            }

            if (status.HasValue)
            {
                taskFilter.PaymentStatuses.Add(status.Value);
            }

            _context.SetDataPaginated();
            _context.SetDataFiltered();
            _context.SetDataSorted();

            return(EngineFactory.GetTimeTrackingEngine().GetByFilterTotal(taskFilter));
        }
        public IEnumerable <MilestoneWrapper> GetMilestonesByFilter(
            int projectid,
            int tag,
            MilestoneStatus?status,
            ApiDateTime deadlineStart,
            ApiDateTime deadlineStop, Guid?taskResponsible,
            int lastId,
            bool myProjects,
            Guid milestoneResponsible)
        {
            var milestoneEngine = EngineFactory.GetMilestoneEngine();

            var filter = new TaskFilter
            {
                UserId        = milestoneResponsible,
                ParticipantId = taskResponsible,
                TagId         = tag,
                FromDate      = deadlineStart,
                ToDate        = deadlineStop,
                SortBy        = _context.SortBy,
                SortOrder     = !_context.SortDescending,
                SearchText    = _context.FilterValue,
                Offset        = _context.StartIndex,
                Max           = _context.Count,
                LastId        = lastId,
                MyProjects    = myProjects
            };

            if (projectid != 0)
            {
                filter.ProjectIds.Add(projectid);
            }

            if (status != null)
            {
                filter.MilestoneStatuses.Add((MilestoneStatus)status);
            }

            _context.SetDataPaginated();
            _context.SetDataFiltered();
            _context.SetDataSorted();
            _context.TotalCount = milestoneEngine.GetByFilterCount(filter);

            return(milestoneEngine.GetByFilter(filter).NotFoundIfNull().Select(r => new MilestoneWrapper(r)).ToSmartList());
        }
Ejemplo n.º 45
0
        public IEnumerable<MilestoneWrapper> GetMilestonesByFilter(
            int projectid,
            int tag,
            MilestoneStatus? status,
            ApiDateTime deadlineStart,
            ApiDateTime deadlineStop, Guid? taskResponsible,
            int lastId,
            bool myProjects,
            Guid milestoneResponsible)
        {
            var milestoneEngine = EngineFactory.GetMilestoneEngine();

            var filter = new TaskFilter
                {
                    UserId = milestoneResponsible,
                    ParticipantId = taskResponsible,
                    TagId = tag,
                    FromDate = deadlineStart,
                    ToDate = deadlineStop,
                    SortBy = _context.SortBy,
                    SortOrder = !_context.SortDescending,
                    SearchText = _context.FilterValue,
                    Offset = _context.StartIndex,
                    Max = _context.Count,
                    LastId = lastId,
                    MyProjects = myProjects
                };

            if (projectid != 0)
            {
                filter.ProjectIds.Add(projectid);
            }

            if (status != null)
            {
                filter.MilestoneStatuses.Add((MilestoneStatus)status);
            }

            _context.SetDataPaginated();
            _context.SetDataFiltered();
            _context.SetDataSorted();
            _context.TotalCount = milestoneEngine.GetByFilterCount(filter);

            return milestoneEngine.GetByFilter(filter).NotFoundIfNull().Select(r => new MilestoneWrapper(r)).ToSmartList();
        }
Ejemplo n.º 46
0
        /// <summary>
        /// 设置系统时间
        /// </summary>
        /// <param name="newDateTime">新时间</param>
        /// <returns></returns>
        public static bool SetDateTime(DateTime newDateTime)
        {
            int UtcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(new DateTime(2001, 09, 01)).Hours;

            newDateTime = newDateTime.AddHours(-UtcOffset);

            ApiDateTime st = new ApiDateTime();

            st.year         = Convert.ToUInt16(newDateTime.Year);
            st.month        = Convert.ToUInt16(newDateTime.Month);
            st.day          = Convert.ToUInt16(newDateTime.Day);
            st.dayofweek    = Convert.ToUInt16(newDateTime.DayOfWeek);
            st.hour         = Convert.ToUInt16(newDateTime.Hour);
            st.minute       = Convert.ToUInt16(newDateTime.Minute);
            st.second       = Convert.ToUInt16(newDateTime.Second);
            st.milliseconds = Convert.ToUInt16(newDateTime.Millisecond);
            return(SetSystemTime(st));
        }
Ejemplo n.º 47
0
    public static void DailyCheck(string psid)
    {
        var cake = new CakeAvatar(psid);

        if (ApiDateTime.IsSameDay(cake.GetIntValue(ParamNameDefs.LastDailyCheckTime)))
        {
            return;
        }
        var icount = cake.AddValue(ParamNameDefs.DailyCheckCount);
        var data   = DailyCheckLoader.Instance.OnGetData(icount);

        if (data == null)
        {
            icount = 1;
            cake.SetValue(ParamNameDefs.DailyCheckCount, icount);
            data = DailyCheckLoader.Instance.OnGetData(icount);
        }
    }
Ejemplo n.º 48
0
 /// <summary>
 /// </summary>
 /// <returns></returns>
 public static FolderWrapper GetSample()
 {
     return(new FolderWrapper
     {
         Access = FileShare.ReadWrite,
         Updated = ApiDateTime.GetSample(),
         Created = ApiDateTime.GetSample(),
         CreatedBy = EmployeeWraper.GetSample(),
         Id = new Random().Next(),
         RootFolderType = FolderType.BUNCH,
         SharedByMe = false,
         Title = "Some titile",
         UpdatedBy = EmployeeWraper.GetSample(),
         FilesCount = new Random().Next(),
         FoldersCount = new Random().Next(),
         ParentId = new Random().Next(),
         IsShareable = false
     });
 }
Ejemplo n.º 49
0
 public static TimeWrapper GetSample()
 {
     return(new TimeWrapper
     {
         Id = 10,
         Date = ApiDateTime.GetSample(),
         Hours = 3.5F,
         Note = "Sample note",
         RelatedProject = 123,
         RelatedTask = 13456,
         RelatedTaskTitle = "Sample task",
         CreatedBy = EmployeeWraper.GetSample(),
         Person = EmployeeWraper.GetSample(),
         CanEdit = true,
         PaymentStatus = PaymentStatus.Billed,
         StatusChanged = ApiDateTime.GetSample(),
         CanEditPaymentStatus = true
     });
 }
        public float GetTotalTaskTimeByFilter(
            int projectid,
            bool myProjects,
            int? milestone,
            bool myMilestones,
            int tag,
            Guid departament,
            Guid participant,
            ApiDateTime createdStart,
            ApiDateTime createdStop,
            int lastId,
            PaymentStatus? status)
        {
            var taskFilter = new TaskFilter
                {
                    DepartmentId = departament,
                    UserId = participant,
                    FromDate = createdStart,
                    ToDate = createdStop,
                    SortBy = _context.SortBy,
                    SortOrder = !_context.SortDescending,
                    SearchText = _context.FilterValue,
                    TagId = tag,
                    LastId = lastId,
                    MyProjects = myProjects,
                    MyMilestones = myMilestones,
                    Milestone = milestone
                };

            if (projectid != 0)
            {
                taskFilter.ProjectIds.Add(projectid);
            }

            if (status.HasValue)
            {
                taskFilter.PaymentStatuses.Add(status.Value);
            }

            _context.SetDataPaginated();
            _context.SetDataFiltered();
            _context.SetDataSorted();

            return EngineFactory.GetTimeTrackingEngine().GetByFilterTotal(taskFilter);
        }
Ejemplo n.º 51
0
        public IEnumerable<SimpleTaskWrapper> GetSimpleTaskByFilter(int projectid, bool myProjects, int? milestone, bool myMilestones, int tag,
                                                                    TaskStatus? status, bool follow, Guid departament, Guid? participant, Guid creator,
                                                                    ApiDateTime deadlineStart, ApiDateTime deadlineStop, int lastId)
        {
            var taskFilter = new TaskFilter
                {
                    DepartmentId = departament,
                    ParticipantId = participant,
                    UserId = creator,
                    Milestone = milestone,
                    FromDate = deadlineStart,
                    ToDate = deadlineStop,
                    SortBy = _context.SortBy,
                    SortOrder = !_context.SortDescending,
                    SearchText = _context.FilterValue,
                    TagId = tag,
                    Offset = _context.StartIndex,
                    Max = _context.Count,
                    LastId = lastId,
                    MyProjects = myProjects,
                    MyMilestones = myMilestones,
                    Follow = follow
                };

            if (projectid != 0)
                taskFilter.ProjectIds.Add(projectid);

            if (status != null)
                taskFilter.TaskStatuses.Add((TaskStatus)status);

            var filterResult = EngineFactory.GetTaskEngine().GetByFilter(taskFilter).NotFoundIfNull();

            _context.SetDataPaginated();
            _context.SetDataFiltered();
            _context.SetDataSorted();
            _context.TotalCount = filterResult.FilterCount.TasksTotal;

            return filterResult.FilterResult.Select(r => new SimpleTaskWrapper(r)).ToSmartList();
        }
Ejemplo n.º 52
0
        public string AddTagToBatchContacts(
            IEnumerable<string> tags,
            int contactStage,
            int contactType,
            ContactListViewType contactListView,
            ApiDateTime fromDate,
            ApiDateTime toDate,
            string tagName)
        {
            var contacts = DaoFactory
                .GetContactDao()
                .GetContacts(_context.FilterValue,
                             tags,
                             contactStage,
                             contactType,
                             contactListView,
                             fromDate,
                             toDate,
                             0,
                             0,
                             null).Where(CRMSecurity.CanAccessTo).ToList();

            foreach (var contact in contacts)
            {
                AddTagTo("contact", contact.ID, tagName);
            }

            return tagName;
        }
        public MilestoneWrapper UpdateMilestone(int id, string title, ApiDateTime deadline, bool isKey, MilestoneStatus status, bool isNotify, string description, int projectID, Guid responsible, bool notifyResponsible)
        {
            if (title == null) throw new ArgumentNullException("title");
            if (deadline == DateTime.MinValue) throw new ArgumentNullException("deadline");

            var milestoneEngine = EngineFactory.GetMilestoneEngine();

            var milestone = milestoneEngine.GetByID(id).NotFoundIfNull();

            ProjectSecurity.DemandEdit(milestone);

            milestone.Description = Update.IfNotEquals(milestone.Description, description);
            milestone.Title = Update.IfNotEmptyAndNotEquals(milestone.Title, title);
            milestone.DeadLine = Update.IfNotEmptyAndNotEquals(milestone.DeadLine, deadline);
            milestone.IsKey = isKey;
            milestone.IsNotify = isNotify;
            milestone.Responsible = Update.IfNotEmptyAndNotEquals(milestone.Responsible, responsible);
            if (projectID != 0)
            {
                var project = EngineFactory.GetProjectEngine().GetByID(projectID).NotFoundIfNull();
                milestone.Project = project;
            }

            milestoneEngine.SaveOrUpdate(milestone, notifyResponsible);

            return new MilestoneWrapper(milestone);
        }
Ejemplo n.º 54
0
        public IEnumerable<ContactWithTaskWrapper> GetSimpleContacts(
            IEnumerable<string> tags,
            int? contactStage,
            int? contactType,
            ContactListViewType contactListView,
            Guid? responsibleid,
            bool? isShared,
            ApiDateTime fromDate,
            ApiDateTime toDate)
        {
            IEnumerable<ContactWithTaskWrapper> result;

            OrderBy contactsOrderBy;

            ContactSortedByType sortBy;

            var searchString = _context.FilterValue;
            if (Web.CRM.Classes.EnumExtension.TryParse(_context.SortBy, true, out sortBy))
            {
                contactsOrderBy = new OrderBy(sortBy, !_context.SortDescending);
            }
            else if (String.IsNullOrEmpty(_context.SortBy))
            {
                contactsOrderBy = new OrderBy(ContactSortedByType.DisplayName, true);
            }
            else
            {
                contactsOrderBy = null;
            }

            var fromIndex = (int)_context.StartIndex;
            var count = (int)_context.Count;
            var contactStageInt = contactStage.HasValue ? contactStage.Value : -1;
            var contactTypeInt = contactType.HasValue ? contactType.Value : -1;

            if (contactsOrderBy != null)
            {
                result = ToSimpleListContactWrapper(DaoFactory.GetContactDao().GetContacts(
                    searchString,
                    tags,
                    contactStageInt,
                    contactTypeInt,
                    contactListView,
                    fromDate,
                    toDate,
                    fromIndex,
                    count,
                    contactsOrderBy,
                    responsibleid,
                    isShared));
                _context.SetDataPaginated();
                _context.SetDataFiltered();
                _context.SetDataSorted();
            }
            else
            {
                result = ToSimpleListContactWrapper(DaoFactory.GetContactDao().GetContacts(
                    searchString,
                    tags,
                    contactStageInt,
                    contactTypeInt,
                    contactListView,
                    fromDate,
                    toDate,
                    0,
                    0,
                    null,
                    responsibleid,
                    isShared));
            }

            int totalCount;

            if (result.Count() < count)
            {
                totalCount = fromIndex + result.Count();
            }
            else
            {
                totalCount = DaoFactory.GetContactDao().GetContactsCount(
                    searchString,
                    tags,
                    contactStageInt,
                    contactTypeInt,
                    contactListView,
                    fromDate,
                    toDate,
                    responsibleid,
                    isShared);
            }

            _context.SetTotalCount(totalCount);

            return result;
        }
Ejemplo n.º 55
0
        public IEnumerable<ContactBaseWrapper> DeleteBatchContacts(
            IEnumerable<String> tags,
            int? contactStage,
            int? contactType,
            ContactListViewType contactListView,
            ApiDateTime fromDate,
            ApiDateTime toDate)
        {
            int contactStageInt = contactStage.HasValue ? contactStage.Value : -1;
            int contactTypeInt = contactType.HasValue ? contactType.Value : -1;


            var contacts = DaoFactory.GetContactDao().GetContacts(
                _context.FilterValue,
                tags,
                contactStageInt,
                contactTypeInt,
                contactListView,
                fromDate,
                toDate,
                0,
                0,
                null);

            contacts = DaoFactory.GetContactDao().DeleteBatchContact(contacts);
            MessageService.Send(Request, MessageAction.ContactsDeleted, contacts.Select(c => c.ID.ToString(CultureInfo.InvariantCulture)));

            return contacts.Select(ToContactBaseWrapper);
        }
Ejemplo n.º 56
0
        public IEnumerable<ContactWrapper> SetAccessToBatchContact(
            IEnumerable<String> tags,
            int? contactStage,
            int? contactType,
            ContactListViewType contactListView,
            ApiDateTime fromDate,
            ApiDateTime toDate,
            bool isPrivate,
            IEnumerable<Guid> managerList
            )
        {
            int contactStageInt = contactStage.HasValue ? contactStage.Value : -1;
            int contactTypeInt = contactType.HasValue ? contactType.Value : -1;

            var result = new List<Contact>();

            var contacts = DaoFactory.GetContactDao().GetContacts(
                _context.FilterValue,
                tags,
                contactStageInt,
                contactTypeInt,
                contactListView,
                fromDate, toDate,
                0, 0, null);

            if (!contacts.Any())
                return Enumerable.Empty<ContactWrapper>();

            foreach (var contact in contacts)
            {
                if (contact == null)
                    throw new ItemNotFoundException();

                if (!CRMSecurity.CanEdit(contact)) continue;

                SetAccessToContact(contact, isPrivate, managerList, false);

                result.Add(contact);
            }
            return ToListContactWrapper(result);
        }
Ejemplo n.º 57
0
        public string AddTagToBatchDeals(
            Guid responsibleid,
            int opportunityStagesid,
            IEnumerable<string> tags,
            int contactid,
            DealMilestoneStatus? stageType,
            bool? contactAlsoIsParticipant,
            ApiDateTime fromDate,
            ApiDateTime toDate,
            string tagName)
        {
            var deals = DaoFactory
                .GetDealDao()
                .GetDeals(
                    _context.FilterValue,
                    responsibleid,
                    opportunityStagesid,
                    tags,
                    contactid,
                    stageType,
                    contactAlsoIsParticipant,
                    fromDate, toDate, 0, 0, null).Where(CRMSecurity.CanAccessTo).ToList();

            foreach (var deal in deals)
            {
                AddTagTo("opportunity", deal.ID, tagName);
            }
            return tagName;
        }
        public IEnumerable<RelationshipEventWrapper> GetHistory(
            String entityType,
            int entityId,
            int categoryId,
            Guid createBy,
            ApiDateTime fromDate,
            ApiDateTime toDate)
        {

            if (!String.IsNullOrEmpty(entityType) && !(
                                                          String.Compare(entityType, "contact", true) == 0 ||
                                                          String.Compare(entityType, "opportunity", true) == 0 ||
                                                          String.Compare(entityType, "case", true) == 0))
                throw new ArgumentException();

            RelationshipEventByType eventByType;

            IEnumerable<RelationshipEventWrapper> result;

            OrderBy eventOrderBy;

            if (Web.CRM.Classes.EnumExtension.TryParse(_context.SortBy, true, out eventByType))
                eventOrderBy = new OrderBy(eventByType, !_context.SortDescending);
            else if (String.IsNullOrEmpty(_context.SortBy))
                eventOrderBy = new OrderBy(RelationshipEventByType.Created, false);
            else
                eventOrderBy = null;

            if (eventOrderBy != null)
            {

                result = ToListRelationshipEventWrapper(DaoFactory.GetRelationshipEventDao().GetItems(
                    _context.FilterValue,
                    ToEntityType(entityType),
                    entityId,
                    createBy,
                    categoryId,
                    fromDate,
                    toDate,
                    (int)_context.StartIndex,
                    (int)_context.Count,
                    eventOrderBy));

                _context.SetDataPaginated();
                _context.SetDataFiltered();
                _context.SetDataSorted();
            }
            else
                result =ToListRelationshipEventWrapper(DaoFactory.GetRelationshipEventDao().GetItems(
                    _context.FilterValue,
                    ToEntityType(entityType),
                    entityId,
                    createBy,
                    categoryId,
                    fromDate,
                    toDate,
                    0,
                    0,
                    null));

            return result.ToSmartList();
        }
        public RelationshipEventWrapper AddHistoryTo(
            String entityType,
            int entityId,
            int contactId,
            String content,
            int categoryId,
            ApiDateTime created,
            IEnumerable<int> fileId,
            IEnumerable<Guid> notifyUserList)
        {

            if (!String.IsNullOrEmpty(entityType) &&
                !(String.Compare(entityType, "opportunity", true) == 0 ||
                  String.Compare(entityType, "case", true) == 0))
                throw new ArgumentException();

            var relationshipEvent = new RelationshipEvent
                                        {
                                            CategoryID = categoryId,
                                            EntityType = ToEntityType(entityType),
                                            EntityID = entityId,
                                            Content = content,
                                            ContactID = contactId,
                                            CreateOn = created,
                                            CreateBy = Core.SecurityContext.CurrentAccount.ID
                                        };

            if (categoryId > 0)
            {
                var category = DaoFactory.GetListItemDao().GetByID(categoryId);

                if (category == null)
                    throw new ArgumentException();
            }

            var item = DaoFactory.GetRelationshipEventDao().CreateItem(relationshipEvent);

            var fileListInfoHashtable = new Hashtable();

            if (fileId != null)
            {
                var fileIds = fileId.ToList();

                var files = FilesDaoFactory.GetFileDao().GetFiles(fileIds.Cast<object>().ToArray());

                foreach (var file in files)
                {
                    var fileInfo = String.Format("{0} ({1})", file.Title, Path.GetExtension(file.Title).ToUpper());
                    fileListInfoHashtable.Add(fileInfo, file.ViewUrl);
                }

                DaoFactory.GetRelationshipEventDao().AttachFiles(item.ID, fileIds.ToArray());
            }

            if (notifyUserList != null && notifyUserList.Count() > 0)
                NotifyClient.Instance.SendAboutAddRelationshipEventAdd(item, fileListInfoHashtable, notifyUserList.ToArray());

            return ToRelationshipEventWrapper(item);
        }
Ejemplo n.º 60
0
        public TaskWrapper UpdateProjectTask(
            int taskid,
            string description,
            ApiDateTime deadline,
            ApiDateTime startDate,
            TaskPriority? priority,
            string title,
            int milestoneid,
            IEnumerable<Guid> responsibles,
            int? projectID,
            bool notify,
            TaskStatus? status,
            int? progress)
        {
            var taskEngine = EngineFactory.GetTaskEngine();
            var task = taskEngine.GetByID(taskid).NotFoundIfNull();

            if (string.IsNullOrEmpty(title)) throw new ArgumentException(@"title can't be empty", "title");

            if (!EngineFactory.GetMilestoneEngine().IsExists(milestoneid) && milestoneid > 0)
            {
                throw new ItemNotFoundException("Milestone not found");
            }

            task.Responsibles = new List<Guid>(responsibles.Distinct());

            task.Deadline = Update.IfNotEquals(task.Deadline, deadline);
            task.Description = Update.IfNotEquals(task.Description, description);

            if (priority.HasValue)
            {
                task.Priority = Update.IfNotEquals(task.Priority, priority.Value);
            }

            task.Title = Update.IfNotEmptyAndNotEquals(task.Title, title);
            task.Milestone = Update.IfNotEquals(task.Milestone, milestoneid);
            task.StartDate = Update.IfNotEquals(task.StartDate, startDate);

            if (projectID.HasValue)
            {
                var project = EngineFactory.GetProjectEngine().GetByID((int)projectID).NotFoundIfNull();
                task.Project = project;
            }

            if (progress.HasValue)
            {
                task.Progress = progress.Value;
            }

            task = taskEngine.SaveOrUpdate(task, null, notify);

            if (status.HasValue)
            {
                taskEngine.ChangeStatus(task, status.Value);
            }

            MessageService.Send(Request, MessageAction.TaskUpdated, task.Project.Title, task.Title);

            return GetTask(task.ID);
        }