public bool EditTicketTmpl(sys_form_tmpl tmpl, sys_form_tmpl_ticket tmplTicket, List <UserDefinedFieldValue> udfValue, List <CheckListDto> checkList, long userId) { var user = UserInfoBLL.GetUserInfo(userId); sys_form_tmpl_ticket_dal sfttDal = new sys_form_tmpl_ticket_dal(); var oldtmplTicket = sfttDal.FindNoDeleteById(tmplTicket.id); if (oldtmplTicket == null || user == null) { return(false); } if (!EditFormTmpl(tmpl, userId)) { return(false); } tmplTicket.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); tmplTicket.update_user_id = userId; sfttDal.Update(tmplTicket); OperLogBLL.OperLogUpdate <sys_form_tmpl_ticket>(tmplTicket, oldtmplTicket, tmplTicket.id, userId, OPER_LOG_OBJ_CATE.SYS_FORM_TMPL_TICKET, ""); var udf_ticket_list = new UserDefinedFieldsBLL().GetUdf(DicEnum.UDF_CATE.TICKETS); if (udf_ticket_list != null && udf_ticket_list.Count > 0) { new UserDefinedFieldsBLL().UpdateUdfValue(DicEnum.UDF_CATE.FORM_TICKET, udf_ticket_list, tmplTicket.id, udfValue, user, DicEnum.OPER_LOG_OBJ_CATE.SYS_FORM_TMPL_TICKET_EXT); } CheckManage(checkList, tmplTicket.id, userId); return(true); }
public ContactAddAndUpdateDto GetContactDto(long id) { ContactAddAndUpdateDto dto = new ContactAddAndUpdateDto(); dto.contact = GetContact(id); if (dto.contact == null) { return(null); } var bll = new UserDefinedFieldsBLL(); dto.udf = bll.GetUdfValue(UDF_CATE.CONTACT, id, bll.GetUdf(UDF_CATE.CONTACT)); if (dto.contact.location_id != null) { dto.location = new LocationBLL().GetLocation((long)dto.contact.location_id); } if (dto.contact.location_id2 != null) { dto.location2 = new LocationBLL().GetLocation((long)dto.contact.location_id2); } var company = new CompanyBLL().GetCompany(dto.contact.account_id); dto.company_name = company.name; return(dto); }
/// <summary> /// 修改销售订单 /// </summary> /// <param name="sale_order"></param> /// <param name="udfValue"></param> /// <param name="user_id"></param> /// <returns></returns> public ERROR_CODE EditSaleOrder(crm_sales_order sale_order, List <UserDefinedFieldValue> udfValue, long user_id) { if (sale_order.status_id == 0 || sale_order.contact_id == 0 || sale_order.owner_resource_id == 0) { return(ERROR_CODE.PARAMS_ERROR); } if (sale_order.begin_date.ToString("yyyy-MM-dd") == "0001-01-01" || sale_order.end_date == null || ((DateTime)sale_order.end_date).ToString("yyyy-MM-dd") == "0001-01-01") { return(ERROR_CODE.PARAMS_ERROR); } var user = UserInfoBLL.GetUserInfo(user_id); if (user == null) { return(ERROR_CODE.USER_NOT_FIND); } var old_sale_order = new crm_sales_order_dal().GetSingleSalesOrderByWhere($" and id= {sale_order.id}"); sale_order.oid = old_sale_order.oid; sale_order.opportunity_id = old_sale_order.opportunity_id; sale_order.create_user_id = old_sale_order.create_user_id; sale_order.create_time = old_sale_order.create_time; sale_order.update_user_id = user.id; sale_order.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); _dal.Update(sale_order); new sys_oper_log_dal().Insert(new sys_oper_log() { user_cate = "用户", user_id = user_id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.SALE_ORDER, oper_object_id = sale_order.id,// 操作对象id oper_type_id = (int)OPER_LOG_TYPE.UPDATE, oper_description = _dal.CompareValue(old_sale_order, sale_order), remark = "修改销售订单" }); // 销售订单自定义 var udf_sales_list = new UserDefinedFieldsBLL().GetUdf(DicEnum.UDF_CATE.SALES); new UserDefinedFieldsBLL().UpdateUdfValue(DicEnum.UDF_CATE.SALES, udf_sales_list, sale_order.id, udfValue, user, OPER_LOG_OBJ_CATE.SALE_ORDER); return(ERROR_CODE.SUCCESS); }
/// <summary> /// 快速新增 /// </summary> public bool AddQuickCall(ServiceCallDto param, long userId) { // 新增工单 var tBll = new TicketBLL(); param.thisTicket.type_id = (int)DicEnum.TASK_TYPE.SERVICE_DESK_TICKET; param.thisTicket.status_id = (int)DicEnum.TICKET_STATUS.NEW; tBll.InsertTicket(param.thisTicket, userId); // 新增自定义 var udf_list = new UserDefinedFieldsBLL().GetUdf(DicEnum.UDF_CATE.TICKETS); new UserDefinedFieldsBLL().SaveUdfValue(DicEnum.UDF_CATE.TICKETS, userId, param.thisTicket.id, udf_list, param.udfList, DicEnum.OPER_LOG_OBJ_CATE.PROJECT_TASK_INFORMATION); // 新增其他负责人 if (!string.IsNullOrEmpty(param.resIds)) { tBll.TicketResManage(param.thisTicket.id, param.resIds, userId); } // 新增服务预定 var timeNow = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); tBll.AddCallOnly(param.call, userId); var ssctDal = new sdk_service_call_task_dal(); var taskRes = new sdk_service_call_task() { id = ssctDal.GetNextIdCom(), create_time = timeNow, create_user_id = userId, service_call_id = param.call.id, task_id = param.thisTicket.id, update_time = timeNow, update_user_id = userId, }; ssctDal.Insert(taskRes); OperLogBLL.OperLogAdd <sdk_service_call_task>(taskRes, taskRes.id, userId, DicEnum.OPER_LOG_OBJ_CATE.SERVICE_CALL_TICKET, "新增服务预定关联工单"); if (!string.IsNullOrEmpty(param.resIds)) { tBll.CallTicketResManage(param.call.id, param.resIds, userId); } return(true); }
public bool AddRecTicketTmpl(sys_form_tmpl tmpl, sys_form_tmpl_recurring_ticket tmplRecTicket, List <UserDefinedFieldValue> udfValue, long userId) { if (!AddFormTmpl(tmpl, userId)) { return(false); } tmplRecTicket.id = _dal.GetNextIdCom(); tmplRecTicket.form_tmpl_id = tmpl.id; tmplRecTicket.create_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); tmplRecTicket.create_user_id = userId; tmplRecTicket.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); tmplRecTicket.update_user_id = userId; new sys_form_tmpl_recurring_ticket_dal().Insert(tmplRecTicket); OperLogBLL.OperLogAdd <sys_form_tmpl_recurring_ticket>(tmplRecTicket, tmplRecTicket.id, userId, OPER_LOG_OBJ_CATE.SYS_FORM_TMPL_RECURRING_TICKET, ""); var udf_ticket_list = new UserDefinedFieldsBLL().GetUdf(DicEnum.UDF_CATE.TICKETS); // 获取到所有的自定义的字段信息 new UserDefinedFieldsBLL().SaveUdfValue(DicEnum.UDF_CATE.FORM_RECTICKET, userId, tmplRecTicket.id, udf_ticket_list, udfValue, OPER_LOG_OBJ_CATE.SYS_FORM_TMPL_RECURRING_TICKET_EXT); // 保存自定义字段,保存成功,插入日志 return(true); }
/// <summary> /// 新增联系人 /// </summary> /// <returns></returns> public ERROR_CODE Insert(ContactAddAndUpdateDto contactAddDto, long user_id) { var user = UserInfoBLL.GetUserInfo(user_id); if (user == null) { return(ERROR_CODE.USER_NOT_FIND); } #region 对联系人必填项的校验 // 必填项校验 if (string.IsNullOrEmpty(contactAddDto.contact.name) || string.IsNullOrEmpty(contactAddDto.contact.phone) || string.IsNullOrEmpty(contactAddDto.contact.first_name)) { return(ERROR_CODE.PARAMS_ERROR); // string类型的非空校验 } if (contactAddDto.contact.allow_notify_email_task_ticket == 1) { if (string.IsNullOrEmpty(contactAddDto.contact.email)) { return(ERROR_CODE.PARAMS_ERROR); // 如果任务和工单中允许发邮件,那么联系人的邮箱为必填项 } } #endregion #region 对联系人中的唯一性信息进行校验(联系人和移动电话) if (!string.IsNullOrEmpty(contactAddDto.contact.mobile_phone)) // 如果用户填写了移动电话,那么对电话进行唯一检验(全表内未删除的联系人进行检索,不局限于本客户联系人) { var same_phone_contact = _dal.GetContactByPhone(contactAddDto.contact.mobile_phone); if (same_phone_contact != null && same_phone_contact.Count > 0) // 查询到此手机号已经有联系人在使用,不可重复使用,返回错误 { return(ERROR_CODE.ERROR); } } // 联系人名称校验 var compare_contact = _dal.GetContactByName(contactAddDto.contact.account_id, contactAddDto.contact.name); if (compare_contact != null && compare_contact.Count > 0) // 该客户如果存在名称一样的未删除的用户,返回错误,提醒用户 { return(ERROR_CODE.ERROR); } #endregion if (contactAddDto.location != null) { var _location = contactAddDto.location; new LocationBLL().Insert(_location, user_id); } #region 如果是主要联系人,首先将原主要联系人设置为普通联系人 if (contactAddDto.contact.is_primary_contact == 1) // 客户将当前联系人设置为主要联系人,此时将原有的主要联系人更改为普通联系人 { var old_primary_contact = _dal.GetPrimaryContactByAccountId(contactAddDto.contact.account_id); // 获取到客户的主要联系人 if (old_primary_contact != null && old_primary_contact.id != contactAddDto.contact.id) { old_primary_contact.is_primary_contact = 0; if (_dal.Update(old_primary_contact)) // 更改主要联系人,插入操作日志 { new sys_oper_log_dal().Insert(new sys_oper_log() { user_cate = "用户", user_id = user.id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.CONTACTS, oper_object_id = old_primary_contact.id, oper_type_id = (int)OPER_LOG_TYPE.UPDATE, oper_description = @"{""is_primary_contact"":""1→0""}", // 1 主要联系人 0 普通联系人 remark = "修改主要联系人为普通联系人", }); // 插入更改日志 } } } #endregion #region 保存联系人信息 //contactAddDto.contact.suffix_id = contactAddDto.contact.suffix_id == 0 ? null : contactAddDto.contact.suffix_id; contactAddDto.contact.id = contactAddDto.contact.id == 0 ? _dal.GetNextIdCom() : contactAddDto.contact.id; contactAddDto.contact.create_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); contactAddDto.contact.create_user_id = user.id; contactAddDto.contact.update_time = contactAddDto.contact.create_time; contactAddDto.contact.update_user_id = user.id; _dal.Insert(contactAddDto.contact); new sys_oper_log_dal().Insert(new sys_oper_log() { user_cate = "用户", user_id = (int)user.id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.CONTACTS, oper_object_id = contactAddDto.contact.id,// 操作对象id oper_type_id = (int)OPER_LOG_TYPE.ADD, oper_description = _dal.AddValue(contactAddDto.contact), remark = "新增联系人" }); // 插入日志 #endregion #region 保存联系人扩展信息 var udf_contact_list = new UserDefinedFieldsBLL().GetUdf(DicEnum.UDF_CATE.CONTACT); // 联系人的自定义字段 var udf_con_list = contactAddDto.udf; // 传过来的联系人的自定义参数 new UserDefinedFieldsBLL().SaveUdfValue(DicEnum.UDF_CATE.CONTACT, user.id, contactAddDto.contact.id, udf_contact_list, udf_con_list, OPER_LOG_OBJ_CATE.CONTACTS_EXTENSION_INFORMATION); // 保存成功即插入日志 #endregion #region 更新客户最后活动时间 crm_account thisAccount = new CompanyBLL().GetCompany(contactAddDto.contact.account_id); if (thisAccount != null) { thisAccount.last_activity_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); new CompanyBLL().EditAccount(thisAccount, user_id); } #endregion return(ERROR_CODE.SUCCESS); }
/// <summary> /// 新增产品和相关供应商信息 /// </summary> /// <param name="product">产品</param> /// <param name="vendordata">供应商集合</param> /// <param name="udf">自定义字段值</param> /// <param name="user_id">操作用户</param> /// <returns></returns> public ERROR_CODE InsertProductAndVendor(ivt_product product, VendorData vendordata, List <UserDefinedFieldValue> udf, long user_id) { //产品 var user = UserInfoBLL.GetUserInfo(user_id); if (user == null) { // 查询不到用户,用户丢失 return(ERROR_CODE.USER_NOT_FIND); } product.id = (int)(_dal.GetNextIdCom()); product.create_time = product.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); product.create_user_id = product.update_user_id = user_id; //唯一性校验 var propro = _dal.FindSignleBySql <ivt_product>($"select * from ivt_product where name='{ product.name}' and delete_time=0 "); if (propro != null) { return(ERROR_CODE.EXIST); } _dal.Insert(product); //更新日志 var add_log = new sys_oper_log() { user_cate = "用户", user_id = (int)user.id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.PRODUCT, oper_object_id = product.id,// 操作对象id oper_type_id = (int)OPER_LOG_TYPE.ADD, oper_description = _dal.AddValue(product), remark = "新增产品信息" }; // 创建日志 new sys_oper_log_dal().Insert(add_log); // 插入日志 //供应商 foreach (var ve in vendordata.VENDOR) { ivt_product_vendor veve = new ivt_product_vendor(); if (ve.operate == 3) { veve.id = (int)(_dal.GetNextIdCom()); veve.update_time = veve.create_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); veve.create_user_id = user_id; veve.product_id = product.id; veve.is_active = ve.is_active; veve.is_default = ve.is_default; veve.vendor_account_id = ve.vendor_account_id; veve.vendor_cost = ve.vendor_cost; veve.vendor_product_no = ve.vendor_product_no; _dal1.Insert(veve); var add_vendor_log = new sys_oper_log() { user_cate = "用户", user_id = (int)user.id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.PRODUCT_VENDOR, oper_object_id = veve.id,// 操作对象id oper_type_id = (int)OPER_LOG_TYPE.ADD, oper_description = _dal1.AddValue(veve), remark = "新增供应商信息" }; // 创建日志 new sys_oper_log_dal().Insert(add_vendor_log); // 插入日志 } } #region 保存产品扩展信息 var udf_contact_list = new UserDefinedFieldsBLL().GetUdf(DicEnum.UDF_CATE.PRODUCTS); // 产品的自定义字段 var udf_con_list = udf; // 传过来的产品 new UserDefinedFieldsBLL().SaveUdfValue(DicEnum.UDF_CATE.PRODUCTS, user_id, product.id, udf_contact_list, udf_con_list, OPER_LOG_OBJ_CATE.PRODUCT); // 保存成功即插入日志 #endregion return(ERROR_CODE.SUCCESS); }
/// <summary> /// 修改更新产品和相关供应商信息 /// </summary> /// <param name="product">产品</param> /// <param name="vendordata">供应商集合</param> /// <param name="udf">自定义字段值</param> /// <param name="user_id">操作用户</param> /// <returns></returns> public ERROR_CODE UpdateProductAndVendor(ivt_product product, VendorData vendordata, List <UserDefinedFieldValue> udf, long user_id) { var user = UserInfoBLL.GetUserInfo(user_id); if (user == null) { // 查询不到用户,用户丢失 return(ERROR_CODE.USER_NOT_FIND); } //产品更新 product.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); product.update_user_id = user_id; //唯一性校验 var propro = _dal.FindSignleBySql <ivt_product>($"select * from ivt_product where name='{product.name}' and delete_time=0 "); ivt_product oldpropro = _dal.FindSignleBySql <ivt_product>($"select * from ivt_product where id='{product.id}' and delete_time=0 "); if (propro != null && product.id != propro.id) { return(ERROR_CODE.EXIST); } //更新日志 var add_log = new sys_oper_log() { user_cate = "用户", user_id = (int)user.id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.PRODUCT, oper_object_id = product.id,// 操作对象id oper_type_id = (int)OPER_LOG_TYPE.UPDATE, oper_description = _dal.CompareValue(oldpropro, product), remark = "修改产品信息" }; // 创建日志 new sys_oper_log_dal().Insert(add_log); // 插入日志 if (!_dal.Update(product)) { return(ERROR_CODE.ERROR); } //供应商更新 foreach (var ve in vendordata.VENDOR) { ivt_product_vendor veve = new ivt_product_vendor(); //删除 if (ve.operate == 1) { var de = _dal1.FindById(ve.id); if (de != null) { de.delete_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); de.delete_user_id = user_id; _dal1.Update(de); var add_vendor_log = new sys_oper_log() { user_cate = "用户", user_id = (int)user.id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.PRODUCT_VENDOR, oper_object_id = veve.id,// 操作对象id oper_type_id = (int)OPER_LOG_TYPE.DELETE, oper_description = _dal1.AddValue(veve), remark = "删除供应商信息" }; // 创建日志 new sys_oper_log_dal().Insert(add_vendor_log); // 插入日志 } } //更新 if (ve.operate == 2) { veve = _dal1.FindById(ve.id); if (veve != null) { veve.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); veve.update_user_id = user_id; veve.product_id = product.id; veve.is_active = ve.is_active; veve.is_default = ve.is_default; veve.vendor_account_id = ve.vendor_account_id; veve.vendor_cost = ve.vendor_cost; veve.vendor_product_no = ve.vendor_product_no; var oldve = GetSingelVendor(veve.id); _dal1.Update(veve); var add_vendor_log = new sys_oper_log() { user_cate = "用户", user_id = (int)user.id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.PRODUCT_VENDOR, oper_object_id = veve.id,// 操作对象id oper_type_id = (int)OPER_LOG_TYPE.UPDATE, oper_description = _dal1.CompareValue(oldve, veve), remark = "修改供应商信息" }; // 创建日志 new sys_oper_log_dal().Insert(add_vendor_log); // 插入日志 } } //新增 if (ve.operate == 3) { veve.id = (int)(_dal.GetNextIdCom()); veve.update_time = veve.create_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); veve.create_user_id = user_id; veve.product_id = product.id; veve.is_active = ve.is_active; veve.is_default = ve.is_default; veve.vendor_account_id = ve.vendor_account_id; veve.vendor_cost = ve.vendor_cost; veve.vendor_product_no = ve.vendor_product_no; _dal1.Insert(veve); var add_vendor_log = new sys_oper_log() { user_cate = "用户", user_id = (int)user.id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.PRODUCT_VENDOR, oper_object_id = veve.id,// 操作对象id oper_type_id = (int)OPER_LOG_TYPE.ADD, oper_description = _dal1.AddValue(veve), remark = "新增供应商信息" }; // 创建日志 new sys_oper_log_dal().Insert(add_vendor_log); // 插入日志 } } var udfBll = new UserDefinedFieldsBLL(); var udf_contact_list = udfBll.GetUdf(DicEnum.UDF_CATE.PRODUCTS); // 产品的自定义字段 udfBll.UpdateUdfValue(UDF_CATE.PRODUCTS, udf_contact_list, product.id, udf, new UserInfoDto { id = user.id, name = user.name }, OPER_LOG_OBJ_CATE.PRODUCT); return(ERROR_CODE.SUCCESS); }