예제 #1
0
        private void GetActicityInfo(HttpContext context)
        {
            var id = context.Request.QueryString["id"];

            if (!string.IsNullOrEmpty(id))
            {
                var acti = new com_activity_dal().FindNoDeleteById(long.Parse(id));
                if (acti != null)
                {
                    string accountName = "";
                    string actiType    = "";
                    if (acti.account_id != null)
                    {
                        var thisAcc = new CompanyBLL().GetCompany((long)acti.account_id);
                        accountName = thisAcc != null ? thisAcc.name : "";
                    }
                    var thisDic   = new d_general_dal().FindNoDeleteById(acti.action_type_id);
                    var startDate = Tools.Date.DateHelper.ConvertStringToDateTime(acti.start_date);
                    var endDate   = Tools.Date.DateHelper.ConvertStringToDateTime(acti.end_date);
                    var durHours  = ((decimal)acti.end_date - (decimal)acti.start_date) / 1000 / 60 / 60;
                    actiType = thisDic != null ? thisDic.name : "";
                    context.Response.Write(new Tools.Serialize().SerializeJson(new { accName = accountName, actiType = actiType, startDateString = startDate.ToString("yyyy-MM-dd"), startTimeString = startDate.ToString("HH:mm"), endDateString = endDate.ToString("yyyy-MM-dd"), endTimeString = endDate.ToString("HH:mm"), durHours = durHours.ToString("#0.00") }));
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 返回备注的相关信息
        /// </summary>
        private void GetNoteInfo(HttpContext context, long note_id)
        {
            var thisNote = new com_activity_dal().FindNoDeleteById(note_id);

            if (thisNote != null)
            {
                var thisRes      = new sys_resource_dal().FindNoDeleteById(thisNote.create_user_id);
                var thisNoteType = new d_general_dal().FindNoDeleteById(thisNote.action_type_id);
                context.Response.Write(new Tools.Serialize().SerializeJson(new { title = thisNote.name, createUser = thisRes != null?thisRes.name:"", type = thisNoteType != null?thisNoteType.name:"", createDate = Tools.Date.DateHelper.ConvertStringToDateTime(thisNote.create_time).ToString("yyyy-MM-dd"), description = thisNote.description }));
            }
        }
예제 #3
0
        /// <summary>
        /// 获取到相关信息
        /// </summary>
        private void GetActivity(HttpContext context)
        {
            var id = context.Request.QueryString["id"];

            if (!string.IsNullOrEmpty(id))
            {
                var acti = new com_activity_dal().FindNoDeleteById(long.Parse(id));
                if (acti != null)
                {
                    context.Response.Write(new Tools.Serialize().SerializeJson(acti));
                }
            }
        }
예제 #4
0
        /// <summary>
        /// 判断是否是 待办
        /// </summary>
        private void IsTodo(HttpContext context)
        {
            var result = "";
            var id     = context.Request.QueryString["objetcId"];

            if (!string.IsNullOrEmpty(id))
            {
                var todo = new com_activity_dal().FindNoDeleteById(long.Parse(id));
                var call = new sdk_service_call_dal().FindNoDeleteById(long.Parse(id));
                if (todo != null)
                {
                    result = "1";
                }
                else if (call != null)
                {
                    result = "2";
                }
            }
            context.Response.Write(new Tools.Serialize().SerializeJson(result));
        }
예제 #5
0
파일: DispatchBLL.cs 프로젝트: evelh/Done
        /// <summary>
        /// 编辑约会
        /// </summary>
        public bool EditTodo(long tId, string startTime, decimal duraHours, long resId, long userId)
        {
            var caDal    = new com_activity_dal();
            var thisTodo = caDal.FindNoDeleteById(tId);

            if (thisTodo == null)
            {
                return(false);
            }
            var startDate = DateTime.Parse(startTime);

            thisTodo.start_date     = Tools.Date.DateHelper.ToUniversalTimeStamp(startDate);
            thisTodo.end_date       = thisTodo.start_date + (long)(duraHours * 60 * 60 * 1000);
            thisTodo.resource_id    = resId;
            thisTodo.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            thisTodo.update_user_id = userId;
            var oldTodo = caDal.FindNoDeleteById(tId);

            caDal.Update(thisTodo);
            OperLogBLL.OperLogUpdate <com_activity>(thisTodo, oldTodo, thisTodo.id, userId, DicEnum.OPER_LOG_OBJ_CATE.ACTIVITY, "编辑待办");
            return(true);
        }
예제 #6
0
        /// <summary>
        /// 执行联系人活动信息
        /// </summary>
        public bool ExectueContactAction(ExexuteContactDto param, long userId)
        {
            if (string.IsNullOrEmpty(param.ids))
            {
                return(false);
            }
            if (!param.isHasNote && !param.isHasTodo)
            {
                return(false);
            }
            var conList = GetListByIds(param.ids);

            if (conList == null || conList.Count == 0)
            {
                return(false);
            }
            var timeNow = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            var caDal   = new com_activity_dal();
            var accBll  = new CompanyBLL();

            foreach (var contact in conList)
            {
                if (param.isHasNote)
                {
                    var thisNote = new com_activity()
                    {
                        id             = caDal.GetNextIdCom(),
                        cate_id        = (int)DicEnum.ACTIVITY_CATE.NOTE,
                        account_id     = contact.account_id,
                        action_type_id = param.note_action_type,
                        contact_id     = contact.id,
                        object_id      = contact.id,
                        object_type_id = (int)DicEnum.OBJECT_TYPE.CONTACT,
                        description    = param.note_content,
                        create_time    = timeNow,
                        update_time    = timeNow,
                        create_user_id = userId,
                        resource_id    = userId,
                        update_user_id = userId,
                    };
                    caDal.Insert(thisNote);
                    OperLogBLL.OperLogAdd <com_activity>(thisNote, thisNote.id, userId, DicEnum.OPER_LOG_OBJ_CATE.ACTIVITY, "新增备注");
                }
                if (param.isHasTodo)
                {
                    long?resId = param.assignRes;
                    if (resId == -1)
                    {
                        var thisAcc = accBll.GetCompany(contact.account_id);
                        if (thisAcc != null)
                        {
                            resId = thisAcc.resource_id;
                        }
                    }
                    var thisTodo = new com_activity()
                    {
                        id             = caDal.GetNextIdCom(),
                        cate_id        = (int)DicEnum.ACTIVITY_CATE.TODO,
                        account_id     = contact.account_id,
                        action_type_id = param.todo_action_type,
                        contact_id     = contact.id,
                        object_id      = contact.id,
                        resource_id    = resId,
                        object_type_id = (int)DicEnum.OBJECT_TYPE.CONTACT,
                        description    = param.todo_content,
                        create_time    = timeNow,
                        update_time    = timeNow,
                        create_user_id = userId,
                        update_user_id = userId,
                        start_date     = param.startDate,
                        end_date       = param.endDate,
                    };
                    caDal.Insert(thisTodo);
                    OperLogBLL.OperLogAdd <com_activity>(thisTodo, thisTodo.id, userId, DicEnum.OPER_LOG_OBJ_CATE.ACTIVITY, "新增备注");
                }
            }
            return(true);
        }
예제 #7
0
파일: TaskView.aspx.cs 프로젝트: evelh/Done
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                var id = Request.QueryString["id"];
                thisTask = new sdk_task_dal().FindNoDeleteById(long.Parse(id));
                if (thisTask != null && thisTask.project_id != null)
                {
                    thisBookMark = new IndexBLL().GetSingBook(Request.Url.LocalPath + "?id=" + id, LoginUserId);
                    tvbDto.Add(new DictionaryEntryDto("type", "类型", 0));
                    tvbDto.Add(new DictionaryEntryDto("time", "操作时间", 0));
                    tvbDto.Add(new DictionaryEntryDto("resouName", "员工", 0));
                    tvbDto.Add(new DictionaryEntryDto("workHours", "实际工作时间", 0));
                    tvbDto.Add(new DictionaryEntryDto("notTiltle", "说明/标题", 0));
                    tvbDto.Add(new DictionaryEntryDto("billabled", "是否计费", 0));
                    tvbDto.Add(new DictionaryEntryDto("billed", "已计费", 0));

                    expDto.Add(new DictionaryEntryDto("type_id", "类型", 0));
                    expDto.Add(new DictionaryEntryDto("add_date", "费用日期", 0));
                    expDto.Add(new DictionaryEntryDto("create_user_id", "创建人", 0));
                    expDto.Add(new DictionaryEntryDto("expense_cost_code_id", "费用类别", 0));
                    expDto.Add(new DictionaryEntryDto("amount", "总额", 0));
                    expDto.Add(new DictionaryEntryDto("is_billable", "计费的", 0));
                    expDto.Add(new DictionaryEntryDto("approve_and_post_user_id", "已计费", 0));


                    v_task = new v_task_all_dal().FindById(thisTask.id);
                    if (thisTask.type_id == (int)DicEnum.TASK_TYPE.PROJECT_ISSUE)
                    {
                        taskType = "问题";
                    }
                    else if (thisTask.type_id == (int)DicEnum.TASK_TYPE.PROJECT_TASK)
                    {
                        taskType = "任务";
                    }
                    else
                    {
                        Response.End();
                    }
                    #region 记录浏览历史
                    var account = new CompanyBLL().GetCompany(thisTask.account_id);
                    var history = new sys_windows_history()
                    {
                        title = $"查看{taskType}:" + (thisProject != null ? thisProject.name : "") + " " + thisTask.title + " " + (account != null ? account.name : ""),
                        url   = Request.RawUrl,
                    };
                    new IndexBLL().BrowseHistory(history, LoginUserId);
                    #endregion
                    thisProject = new pro_project_dal().FindNoDeleteById((long)thisTask.project_id);
                    if (thisProject != null)
                    {
                        thisAccount = new crm_account_dal().FindNoDeleteById(thisProject.account_id);
                        if (thisProject.contract_id != null)
                        {
                            thisContract = new ctt_contract_dal().FindNoDeleteById((long)thisProject.contract_id);
                        }
                    }
                    thisTaskResList = new sdk_task_resource_dal().GetTaskResByTaskId(thisTask.id);
                    var roleList = dic.FirstOrDefault(_ => _.Key == "role").Value as List <sys_role>;
                    var sysList  = dic.FirstOrDefault(_ => _.Key == "sys_resource").Value as List <DictionaryEntryDto>;

                    #region 工时备注附件
                    var tasEntryList = new sdk_work_entry_dal().GetByTaskId(thisTask.id);
                    if (tasEntryList != null && tasEntryList.Count > 0)
                    {
                        var newList = (from a in tasEntryList
                                       join b in roleList on a.role_id equals b.id
                                       join c in sysList on a.resource_id equals long.Parse(c.val)
                                       select new TaskViewDto {
                            id = a.id, type = "entry", time = Tools.Date.DateHelper.ConvertStringToDateTime((long)(a.end_time ?? a.start_time)), resouName = c.show + "(" + b.name + ")", workHours = a.hours_worked, notTiltle = a.summary_notes, billabled = a.is_billable == 1?"✓":"", billed = a.approve_and_post_date == null?"": "✓", startDate = Tools.Date.DateHelper.ConvertStringToDateTime((long)a.start_time), workTypeId = a.cost_code_id, contractId = a.contract_id, showOnInv = a.show_on_invoice == 1, serviceId = a.service_id
                        }).ToList();

                        tvdList.AddRange(newList);
                    }
                    var conAttDal      = new com_attachment_dal();
                    var allTaskAttList = new List <com_attachment>();
                    var taskNoteList   = new com_activity_dal().GetActiList($" and (task_id ={thisTask.id} or object_id={thisTask.id} )");
                    if (taskNoteList != null && taskNoteList.Count > 0)
                    {
                        var newList = (from a in taskNoteList
                                       join c in sysList on a.resource_id equals long.Parse(c.val) into temp
                                       from tt in temp.DefaultIfEmpty()
                                       select new TaskViewDto {
                            id = a.id, type = "note", time = Tools.Date.DateHelper.ConvertStringToDateTime(a.create_time), resouName = tt == null ? "" : tt.show, notTiltle = a.name, noteDescr = a.description
                        }).ToList();
                        tvdList.AddRange(newList);

                        foreach (var thisTaskNote in taskNoteList)
                        {
                            var thisNoteAttList = conAttDal.GetAttListByOid(thisTaskNote.id);
                            if (thisNoteAttList != null && thisNoteAttList.Count > 0)
                            {
                                allTaskAttList.AddRange(thisNoteAttList);
                            }
                        }
                    }
                    var taskAttList = conAttDal.GetAttListByOid(thisTask.id);
                    if (taskAttList != null && taskAttList.Count > 0)
                    {
                        allTaskAttList.AddRange(taskAttList);
                    }
                    if (allTaskAttList.Count > 0)
                    {
                        var newList = (from a in allTaskAttList
                                       join c in sysList on a.create_user_id equals long.Parse(c.val) into temp
                                       from tt in temp.DefaultIfEmpty()
                                       select new TaskViewDto {
                            id = a.id, type = "atach", time = Tools.Date.DateHelper.ConvertStringToDateTime(a.create_time), resouName = tt == null?"":tt.show, notTiltle = a.title, fileType = a.type_id
                        }).ToList();
                        tvdList.AddRange(newList);
                    }
                    if (tvdList != null && tvdList.Count > 0)
                    {
                        tvbOrder = Request.QueryString["tvbOrder"];
                        tvdList  = tvdList.OrderBy(_ => _.time).ToList();
                        if (!string.IsNullOrEmpty(tvbOrder))
                        {
                            var tvbOrderArr = tvbOrder.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries);
                            var orderFile   = tvbDto.FirstOrDefault(_ => _.val == tvbOrderArr[0]);
                            if (tvbOrderArr[1] == "desc")
                            {
                                //tvdList = (from a in tvdList
                                //           orderby tvbOrderArr[0]  descending
                                //           select a).ToList();
                                tvdList.Sort(delegate(TaskViewDto t1, TaskViewDto t2) {
                                    return(GetObjectPropertyValue(t2, tvbOrderArr[0]).CompareTo(GetObjectPropertyValue(t1, tvbOrderArr[0])));
                                });
                                orderFile.select = orderFile != null ? 2 : orderFile.select;
                            }
                            else
                            {
                                //tvdList = (from a in tvdList
                                //           orderby tvbOrderArr[0]
                                //           select a).ToList();
                                tvdList.Sort(delegate(TaskViewDto t1, TaskViewDto t2) {
                                    return(GetObjectPropertyValue(t1, tvbOrderArr[0]).CompareTo(GetObjectPropertyValue(t2, tvbOrderArr[0])));
                                });
                                orderFile.select = orderFile != null ? 1 : orderFile.select;
                            }
                        }
                    }
                    #endregion

                    #region 费用
                    taskExpList = new sdk_expense_dal().GetExpByTaskId(thisTask.id);
                    if (taskExpList != null && taskExpList.Count > 0)
                    {
                        taskExpList = taskExpList.OrderByDescending(_ => _.add_date).ToList();
                        expOrder    = Request.QueryString["expOrder"];
                        if (!string.IsNullOrEmpty(expOrder))
                        {
                            var expOrderArr = expOrder.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                            var orderFile   = expDto.FirstOrDefault(_ => _.val == expOrderArr[0]);
                            if (expOrderArr[1] == "desc")
                            {
                                //taskExpList = (from a in taskExpList
                                //           orderby expOrderArr[0] descending
                                //           select a).ToList();
                                taskExpList.Sort(delegate(sdk_expense t1, sdk_expense t2) {
                                    return(GetObjectPropertyValue(t2, expOrderArr[0]).CompareTo(GetObjectPropertyValue(t1, expOrderArr[0])));
                                });
                                orderFile.select = orderFile != null ? 2 : orderFile.select;
                            }
                            else
                            {
                                //taskExpList = (from a in taskExpList
                                //           orderby expOrderArr[0]
                                //           select a).ToList();
                                taskExpList.Sort(delegate(sdk_expense t1, sdk_expense t2) {
                                    return(GetObjectPropertyValue(t1, expOrderArr[0]).CompareTo(GetObjectPropertyValue(t2, expOrderArr[0])));
                                });

                                orderFile.select = orderFile != null ? 1 : orderFile.select;
                            }
                        }
                    }
                    #endregion
                }
                else
                {
                    Response.End();
                }
            }
            catch (Exception msg)
            {
                Response.End();
            }
        }
예제 #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            thisUser = new sys_resource_dal().FindNoDeleteById(GetLoginUserId());
            var caDal  = new com_activity_dal();
            var stDal  = new sdk_task_dal();
            var ppDal  = new pro_project_dal();
            var accDal = new crm_account_dal();
            var ccDal  = new ctt_contract_dal();
            var id     = Request.QueryString["id"];

            if (!string.IsNullOrEmpty(id))
            {
                thisNote = caDal.FindNoDeleteById(long.Parse(id));
                if (thisNote != null)
                {
                    isAdd = false;

                    thisNoteAtt = new com_attachment_dal().GetAttListByOid(thisNote.id);

                    thisTicket = stDal.FindNoDeleteById(thisNote.object_id);
                    if (thisTicket != null)
                    {
                        object_id = thisTicket.id;
                    }
                    else
                    {
                        thisProject = ppDal.FindNoDeleteById(thisNote.object_id);
                        if (thisProject != null)
                        {
                            object_id   = thisProject.id;
                            thisAccount = accDal.FindNoDeleteById(thisProject.account_id);
                        }
                        else
                        {
                            thisContract = ccDal.FindNoDeleteById(thisNote.object_id);
                            if (thisContract != null)
                            {
                                object_id   = thisContract.id;
                                thisAccount = accDal.FindNoDeleteById(thisContract.account_id);
                            }
                        }
                    }
                }
            }

            var ticketId = Request.QueryString["ticket_id"];

            if (!string.IsNullOrEmpty(ticketId))
            {
                thisTicket = stDal.FindNoDeleteById(long.Parse(ticketId));
            }
            if (thisTicket != null)
            {
                object_id = thisTicket.id;
                if (thisTicket.type_id == (int)DicEnum.TASK_TYPE.PROJECT_PHASE)
                {
                    // isPhase = true;
                }
                if (thisTicket.contact_id != null)
                {
                    thisContact = new crm_contact_dal().FindNoDeleteById((long)thisTicket.contact_id);
                }
                thisAccount    = accDal.FindNoDeleteById(thisTicket.account_id);
                ticket_creator = new sys_resource_dal().FindNoDeleteById(thisTicket.create_user_id);
                if (!IsPostBack)
                {
                    //status_id.SelectedValue = thisTicket.status_id.ToString();
                }

                if (thisTicket.project_id != null)
                {
                    thisProject = ppDal.FindNoDeleteById((long)thisTicket.project_id);
                    if (thisProject != null && thisAccount != null)
                    {
                        thisAccount = accDal.FindNoDeleteById(thisProject.account_id);
                    }
                }
            }
            if (thisAccount == null)
            {
                Response.End();
            }
            else
            {
                if (thisAccount.resource_id != null)
                {
                    thisAccManger = new sys_resource_dal().FindNoDeleteById((long)thisAccount.resource_id);
                }
            }

            if (!IsPostBack)
            {
                publish_type_id.DataTextField  = "name";
                publish_type_id.DataValueField = "id";
                var pushList = new d_general_dal().GetGeneralByTableId((int)GeneralTableEnum.NOTE_PUBLISH_TYPE);
                if (pushList != null && pushList.Count > 0)
                {
                    pushList = pushList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.TICKET_NOTE).ToString()).ToList();
                }
                publish_type_id.DataSource = pushList;
                publish_type_id.DataBind();

                status_id.DataTextField  = "show";
                status_id.DataValueField = "val";
                status_id.DataSource     = dic.FirstOrDefault(_ => _.Key == "ticket_status").Value;
                status_id.DataBind();
                if (thisTicket != null)
                {
                    status_id.SelectedValue = thisTicket.status_id.ToString();
                }

                action_type_id.DataTextField  = "name";
                action_type_id.DataValueField = "id";
                var actList = new d_general_dal().GetGeneralByTableId((int)GeneralTableEnum.ACTION_TYPE);
                actList = actList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.TASK_NOTE).ToString()).ToList();
                action_type_id.DataSource = actList;
                action_type_id.DataBind();


                if (thisNote != null)
                {
                    if (!IsPostBack)
                    {
                        if (thisNote.publish_type_id != null)
                        {
                            publish_type_id.SelectedValue = thisNote.publish_type_id.ToString();
                        }
                        action_type_id.SelectedValue = thisNote.action_type_id.ToString();
                    }
                }
                //else
                //{
                //    if (isContract)
                //    {
                //        publish_type_id.SelectedValue = ((int)DicEnum.NOTE_PUBLISH_TYPE.CONTRACT_INTERNA_USER).ToString();
                //    }
                //}

                var tempList = new sys_notify_tmpl_dal().GetTempByEvent(DicEnum.NOTIFY_EVENT.NONE);
                notify_id.DataTextField  = "name";
                notify_id.DataValueField = "id";
                notify_id.DataSource     = tempList;
                notify_id.DataBind();
            }
        }
예제 #9
0
        /// <summary>
        /// 新增附件
        /// </summary>
        /// <param name="objType">对象类型</param>
        /// <param name="objId">对象id</param>
        /// <param name="typeId">附件类型</param>
        /// <param name="title">附件名</param>
        /// <param name="attLink">附件内容</param>
        /// <param name="fileName">上传的文件名</param>
        /// <param name="fileSaveName">文件保存服务器的名称</param>
        /// <param name="contentType">文件类型</param>
        /// <param name="size">文件大小</param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public bool AddAttachment(int objType, long objId, int typeId, string title, string attLink, string fileName, string fileSaveName, string contentType, int size, long userId, string pubTypeId = "")
        {
            com_attachment att = new com_attachment();


            att.object_type_id = objType;
            att.object_id      = objId;

            // 备注和附件的下级备注和附件不能再添加附件
            if (objType == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.NOTES)
            {
                var note = new com_activity_dal().FindById(objId);
                if (note.object_type_id == (int)DicEnum.OBJECT_TYPE.NOTES)
                {
                    att.object_type_id = (int)DicEnum.ATTACHMENT_OBJECT_TYPE.NOTES;
                    att.object_id      = note.object_id;
                }
                else if (note.object_type_id == (int)DicEnum.OBJECT_TYPE.ATTACHMENT)
                {
                    att.object_type_id = (int)DicEnum.ATTACHMENT_OBJECT_TYPE.ATTACHMENT;
                    att.object_id      = note.object_id;
                }
            }
            else if (objType == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.ATTACHMENT)
            {
                var attachment = dal.FindById(objId);
                if (attachment.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.NOTES)
                {
                    att.object_type_id = (int)DicEnum.ATTACHMENT_OBJECT_TYPE.NOTES;
                    att.object_id      = attachment.object_id;
                }
                else if (attachment.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.ATTACHMENT)
                {
                    att.object_type_id = (int)DicEnum.ATTACHMENT_OBJECT_TYPE.ATTACHMENT;
                    att.object_id      = attachment.object_id;
                }
            }
            else if (objType == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.LABOUR)
            {
                var labour = new sdk_work_entry_dal().FindById(objId);
                if (labour.parent_id != null)
                {
                    att.object_type_id = (int)DicEnum.ATTACHMENT_OBJECT_TYPE.LABOUR;
                    att.object_id      = (long)labour.parent_id;
                }
                else if (labour.parent_attachment_id != null)
                {
                    att.object_type_id = (int)DicEnum.ATTACHMENT_OBJECT_TYPE.ATTACHMENT;
                    att.object_id      = (long)labour.parent_attachment_id;
                }
                else if (labour.parent_note_id != null)
                {
                    att.object_type_id = (int)DicEnum.ATTACHMENT_OBJECT_TYPE.NOTES;
                    att.object_id      = (long)labour.parent_note_id;
                }
            }

            if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.ATTACHMENT)
            {
                var attachment = dal.FindById(att.object_id);
                att.account_id = attachment.account_id;
                att.parent_id  = attachment.id;
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.NOTES)
            {
                var note = new com_activity_dal().FindById(att.object_id);
                att.account_id = note.account_id;
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.OPPORTUNITY)
            {
                var opp = new crm_opportunity_dal().FindById(att.object_id);
                att.account_id = opp.account_id;
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.SALES_ORDER)
            {
                var so  = new crm_sales_order_dal().FindById(att.object_id);
                var opp = new crm_opportunity_dal().FindById(so.opportunity_id);
                att.account_id = opp.account_id;
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.CONTRACT)
            {
                var contract = new ctt_contract_dal().FindById(att.object_id);
                att.account_id = contract.account_id;
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.COMPANY)
            {
                att.account_id = att.object_id;
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.PROJECT)
            {
                var project = new pro_project_dal().FindNoDeleteById(att.object_id);
                att.account_id = project.account_id;
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.EXPENSE_REPORT)
            {
                // 从报表添加附件 - 默认使用声联(oid=0) 的客户
                var defaultAccount = new CompanyBLL().GetDefaultAccount();
                att.account_id = defaultAccount.id;
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.TASK)
            {
                var task = new sdk_task_dal().FindNoDeleteById(att.object_id);
                if (task != null)
                {
                    att.account_id = task.account_id;
                    #region 更新客户最后活动时间
                    crm_account thisAccount = new CompanyBLL().GetCompany(task.account_id);
                    if (thisAccount != null)
                    {
                        thisAccount.last_activity_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); new CompanyBLL().EditAccount(thisAccount, userId);
                    }
                    #endregion
                }
                if (!string.IsNullOrEmpty(pubTypeId))
                {
                    att.publish_type_id = int.Parse(pubTypeId);
                }
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.LABOUR)
            {
                var labour = new sdk_work_entry_dal().FindNoDeleteById(att.object_id);
                if (labour == null)
                {
                    return(false);
                }
                var ticket = new sdk_task_dal().FindNoDeleteById(labour.task_id);
                if (ticket == null)
                {
                    return(false);
                }
                att.account_id = ticket.account_id;
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.KNOWLEDGE)
            {
                var thisArt = new sdk_kb_article_dal().FindNoDeleteById(att.object_id);
                if (thisArt == null)
                {
                    return(false);
                }
                att.account_id = thisArt.account_id;
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.RESOURCE)
            {
            }
            else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.CONFIGITEM)
            {
                crm_installed_product insPro = new crm_installed_product_dal().FindNoDeleteById(att.object_id);
                if (insPro == null)
                {
                    return(false);
                }
                att.account_id = insPro.account_id;
            }
            else
            {
                return(false);
            }

            att.id             = dal.GetNextIdCom();
            att.create_time    = Tools.Date.DateHelper.ToUniversalTimeStamp();
            att.create_user_id = userId;
            att.update_time    = att.create_time;
            att.update_user_id = userId;
            att.title          = title;
            att.type_id        = typeId;
            if (typeId == (int)DicEnum.ATTACHMENT_TYPE.FILE_LINK ||
                typeId == (int)DicEnum.ATTACHMENT_TYPE.FOLDER_LINK)
            {
                att.uncpath  = attLink;
                att.filename = @"file://" + attLink;
            }
            else if (typeId == (int)DicEnum.ATTACHMENT_TYPE.URL)
            {
                if (attLink.IndexOf(@"http://") == 0)
                {
                    attLink      = attLink.Remove(0, 7);
                    att.urlpath  = attLink;
                    att.filename = @"http://" + attLink;
                }
                else if (attLink.IndexOf(@"https://") == 0)
                {
                    attLink      = attLink.Remove(0, 8);
                    att.urlpath  = attLink;
                    att.filename = @"https://" + attLink;
                }
                else
                {
                    att.urlpath  = attLink;
                    att.filename = @"http://" + attLink;
                }
            }
            else if (typeId == (int)DicEnum.ATTACHMENT_TYPE.ATTACHMENT)
            {
                att.href         = fileSaveName;
                att.filename     = fileName;
                att.sizeinbyte   = size;
                att.content_type = contentType;
            }
            else
            {
                return(false);
            }

            dal.Insert(att);
            OperLogBLL.OperLogAdd <com_attachment>(att, att.id, userId, DicEnum.OPER_LOG_OBJ_CATE.ATTACHMENT, "新增附件");
            return(true);
        }
예제 #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                thisUser = new sys_resource_dal().FindNoDeleteById(GetLoginUserId());
                var caDal  = new com_activity_dal();
                var stDal  = new sdk_task_dal();
                var ppDal  = new pro_project_dal();
                var accDal = new crm_account_dal();
                var ccDal  = new ctt_contract_dal();
                var id     = Request.QueryString["id"];
                if (!string.IsNullOrEmpty(id))
                {
                    thisNote = caDal.FindNoDeleteById(long.Parse(id));
                    if (thisNote != null)
                    {
                        isAdd = false;

                        thisNoteAtt = new com_attachment_dal().GetAttListByOid(thisNote.id);

                        thisTask = stDal.FindNoDeleteById(thisNote.object_id);
                        if (thisTask != null)
                        {
                            object_id = thisTask.id;
                            if (thisTask.type_id == (int)DicEnum.TASK_TYPE.SERVICE_DESK_TICKET)
                            {
                                isTicket   = true;
                                thisTask   = null;
                                thisTicket = stDal.FindNoDeleteById(thisNote.object_id);
                            }
                        }
                        else
                        {
                            thisProject = ppDal.FindNoDeleteById(thisNote.object_id);
                            if (thisProject != null)
                            {
                                isProject   = true;
                                object_id   = thisProject.id;
                                thisAccount = accDal.FindNoDeleteById(thisProject.account_id);
                            }
                            else
                            {
                                thisContract = ccDal.FindNoDeleteById(thisNote.object_id);
                                if (thisContract != null)
                                {
                                    isContract  = true;
                                    object_id   = thisContract.id;
                                    thisAccount = accDal.FindNoDeleteById(thisContract.account_id);
                                }
                            }
                        }
                    }
                }
                var taskId      = Request.QueryString["task_id"];
                var project_id  = Request.QueryString["project_id"];
                var contract_id = Request.QueryString["contract_id"];
                var ticket_id   = Request.QueryString["ticket_id"];
                var call_id     = Request.QueryString["call_id"];
                if (!string.IsNullOrEmpty(taskId))
                {
                    thisTask = stDal.FindNoDeleteById(long.Parse(taskId));
                }
                else if (!string.IsNullOrEmpty(project_id))
                {
                    thisProject = ppDal.FindNoDeleteById(long.Parse(project_id));
                    if (thisProject != null)
                    {
                        isProject   = true;
                        object_id   = thisProject.id;
                        thisAccount = accDal.FindNoDeleteById(thisProject.account_id);
                    }
                }
                else if (!string.IsNullOrEmpty(contract_id))
                {
                    thisContract = ccDal.FindNoDeleteById(long.Parse(contract_id));
                    if (thisContract != null)
                    {
                        object_id   = thisContract.id;
                        thisAccount = accDal.FindNoDeleteById(thisContract.account_id);
                        isContract  = true;
                    }
                }
                else if (!string.IsNullOrEmpty(ticket_id))
                {
                    thisTicket = stDal.FindNoDeleteById(long.Parse(ticket_id));
                }
                else if (!string.IsNullOrEmpty(call_id))
                {
                    thisCall = new sdk_service_call_dal().FindNoDeleteById(long.Parse(call_id));
                    if (thisCall != null)
                    {
                        isCall         = true;
                        thisAccount    = new CompanyBLL().GetCompany(thisCall.account_id);
                        callTicketList = stDal.GetTciketByCall(thisCall.id);
                        if (callTicketList != null && callTicketList.Count > 0)
                        {
                            thisTask = callTicketList[0];
                            if (callTicketList.Any(_ => _.id != thisTask.id && _.status_id != thisTask.status_id))
                            {
                                isMantStatus = true;
                            }
                            if (callTicketList.Any(_ => _.id != thisTask.id && _.account_id != thisTask.account_id))
                            {
                                isManyAccount = true;
                            }
                            if (callTicketList.Any(_ => _.id != thisTask.id && _.title != thisTask.title))
                            {
                                isManyTitle = true;
                            }
                        }
                        else
                        {
                            Response.Write("<script>alert('服务预定下暂无工单!');window.close();</script>");
                            return;
                        }
                    }
                }


                if (thisTask != null)
                {
                    thisAccount = accDal.FindNoDeleteById(thisTask.account_id);
                    object_id   = thisTask.id;
                    if (thisTask.type_id == (int)DicEnum.TASK_TYPE.PROJECT_PHASE)
                    {
                        isPhase = true;
                    }
                    task_creator = new sys_resource_dal().FindNoDeleteById(thisTask.create_user_id);
                    if (thisTask.project_id != null)
                    {
                        thisProject = ppDal.FindNoDeleteById((long)thisTask.project_id);
                        if (thisProject != null)
                        {
                            thisAccount = accDal.FindNoDeleteById(thisProject.account_id);
                        }
                    }
                }
                if (thisTicket != null)
                {
                    isTicket     = true;
                    object_id    = thisTicket.id;
                    task_creator = new sys_resource_dal().FindNoDeleteById(thisTicket.create_user_id);
                    thisAccount  = accDal.FindNoDeleteById(thisTicket.account_id);
                    if (thisTicket.contact_id != null)
                    {
                        thisContact = new crm_contact_dal().FindNoDeleteById((long)thisTicket.contact_id);
                    }
                }
                if (thisAccount == null)
                {
                    Response.End();
                }
                else
                {
                    if (thisAccount.resource_id != null)
                    {
                        thisAccManger = new sys_resource_dal().FindNoDeleteById((long)thisAccount.resource_id);
                    }
                }
                if (!IsPostBack)
                {
                    publish_type_id.DataTextField  = "name";
                    publish_type_id.DataValueField = "id";
                    var pushList = new d_general_dal().GetGeneralByTableId((int)GeneralTableEnum.NOTE_PUBLISH_TYPE);
                    if (pushList != null && pushList.Count > 0)
                    {
                        if (isProject)
                        {
                            pushList = pushList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.PROJECT_NOTE).ToString()).ToList();
                        }
                        else if (isContract)
                        {
                            pushList = pushList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.CONTRACT_NOTE).ToString()).ToList();
                        }
                        else if (isTicket)
                        {
                            pushList = pushList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.TASK_NOTE).ToString()).ToList();
                        }
                        else
                        {
                            pushList = pushList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.TASK_NOTE).ToString()).ToList();
                        }
                    }
                    publish_type_id.DataSource = pushList;
                    publish_type_id.DataBind();

                    status_id.DataTextField  = "show";
                    status_id.DataValueField = "val";
                    var statusList = dic.FirstOrDefault(_ => _.Key == "ticket_status").Value as List <DictionaryEntryDto>;
                    if (isMantStatus)
                    {
                        statusList.Add(new DictionaryEntryDto()
                        {
                            val = "0", show = "多个值,保持不变"
                        });
                    }
                    status_id.DataSource = statusList;
                    status_id.DataBind();
                    if (isMantStatus)
                    {
                        status_id.SelectedValue = "0";
                    }
                    else if (thisTask != null)
                    {
                        status_id.SelectedValue = thisTask.status_id.ToString();
                    }
                    else if (thisTicket != null)
                    {
                        status_id.SelectedValue = thisTicket.status_id.ToString();
                    }
                    action_type_id.DataTextField  = "name";
                    action_type_id.DataValueField = "id";
                    var actList = new d_general_dal().GetGeneralByTableId((int)GeneralTableEnum.ACTION_TYPE);
                    if (actList != null && actList.Count > 0)
                    {
                        if (isProject)
                        {
                            actList = actList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.PROJECT_NOTE).ToString()).ToList();
                        }
                        else if (isContract)
                        {
                            actList = actList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.CONTRACT_NOTE).ToString()).ToList();
                        }
                        else if (isTicket)
                        {
                            actList = actList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.TASK_NOTE).ToString()).ToList();
                        }
                        else
                        {
                            actList = actList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.TASK_NOTE).ToString()).ToList();
                        }
                    }
                    action_type_id.DataSource = actList;
                    action_type_id.DataBind();
                    if (thisNote != null)
                    {
                        if (!IsPostBack)
                        {
                            if (thisNote.publish_type_id != null)
                            {
                                publish_type_id.SelectedValue = thisNote.publish_type_id.ToString();
                            }
                            action_type_id.SelectedValue = thisNote.action_type_id.ToString();
                            isAnnounce.Checked           = thisNote.announce == 1;
                        }
                    }
                    else
                    {
                        if (isContract)
                        {
                            publish_type_id.SelectedValue = ((int)DicEnum.NOTE_PUBLISH_TYPE.CONTRACT_INTERNA_USER).ToString();
                        }
                    }

                    var tempList = new sys_notify_tmpl_dal().GetTempByEvent(DicEnum.NOTIFY_EVENT.NONE);
                    notify_id.DataTextField  = "name";
                    notify_id.DataValueField = "id";
                    notify_id.DataSource     = tempList;
                    notify_id.DataBind();
                }

                if (isProject)
                {
                    tmplList = new FormTemplateBLL().GetTmplByType((int)DicEnum.FORM_TMPL_TYPE.PROJECT_NOTE, LoginUserId);
                }
                else if (isTicket && thisTicket != null)
                {
                    tmplList = new FormTemplateBLL().GetTmplByType((int)DicEnum.FORM_TMPL_TYPE.TICKET_NOTE, LoginUserId);
                }
                else if (thisTask != null)
                {
                    tmplList = new FormTemplateBLL().GetTmplByType((int)DicEnum.FORM_TMPL_TYPE.TASK_NOTE, LoginUserId);
                }
            }
            catch (Exception msg)
            {
                Response.Write(msg);
                Response.End();
            }
        }