//将指定人员查看存入关系表中
        public void InserAppointManSee(B_OA_Notice baseInfor_Notice, IDbTransaction tran)
        {
            string rangeCheckManId = baseInfor_Notice.rangeCheckManId;
            string[] manIdArray = rangeCheckManId.Split(';');
            //删除原数据
            B_OA_Notice_AppointManSee manSee_Delete = new B_OA_Notice_AppointManSee();
            manSee_Delete.Condition.Add("noticeid =" + baseInfor_Notice.NewsId);
            Utility.Database.Delete(manSee_Delete, tran);

            for (var range = 0; range < manIdArray.Length - 1; range++)
            {
                B_OA_Notice_AppointManSee manSee = new B_OA_Notice_AppointManSee();
                manSee.noticeid = baseInfor_Notice.NewsId;
                manSee.userid = manIdArray[range];
                Utility.Database.Insert(manSee, tran);
            }
        }
Exemplo n.º 2
0
        public string SaveAricle(string JsonData, string userid)
        {
            var tran = Utility.Database.BeginDbTransaction();
            StringBuilder strSql = new StringBuilder();

            try
            {
                B_OA_Notice notice = JsonConvert.DeserializeObject<B_OA_Notice>(JsonData);

                //会议通知
                if (notice.isConferenceInform == false)
                {
                    notice.conferenceEndDate = null;
                }
                else
                {
                    if (notice.conferenceEndDate == "" || notice.conferenceEndDate == null)
                    {
                        strSql.Append("\n请输入会议时间");
                    }
                }
                //邮件送达
                if (notice.isSendEmail == false)
                {
                    notice.sendEmailToManId = "";
                    notice.sendEmailToManName = "";
                }
                else
                {
                    if (notice.sendEmailToManId == "" || notice.sendEmailToManId == null)
                    {
                        strSql.Append("\n请选择发件人");
                    }
                }
                //指定发布范围
                if (notice.publicRange == 0)
                {
                    notice.rangeCheckManId = "";
                    notice.rangeCheckManName = "";
                }
                else
                {
                    if (notice.rangeCheckManId == "" || notice.rangeCheckManId == null)
                    {
                        strSql.Append("\n请选择指定人员");
                    }
                }

                if (strSql.ToString().Length != 0)
                {
                    return Utility.JsonMsg(false, strSql.ToString()); //将对象转为json字符串并返回到客户端
                }

                if (notice.NewsId == null || notice.NewsId == "")
                {
                    notice.NewsId = ComClass.GetGuid();
                    notice.CreateTime = DateTime.Now.ToString();
                    notice.isSeeInDoor = false; //设置为已发布进入审核流程
                    Utility.Database.Insert(notice, tran);
                }
                else
                {
                    notice.Condition.Add("NewsId =" + notice.NewsId);
                    Utility.Database.Update(notice, tran);
                }

                var userInfor = ComClass.GetUserInfo(userid);

                //删除文章与目录关系表
                B_OA_Notice_FileType_R del_nf_R = new B_OA_Notice_FileType_R();
                del_nf_R.Condition.Add("noticeId = " + notice.NewsId);
                Utility.Database.Delete(del_nf_R, tran);
                //保存关系表
                string[] documenTypeArray = notice.documentTypeId.Split('/');
                for (int k = 0; k < documenTypeArray.Length; k++)
                {
                    B_OA_Notice_FileType_R nf_R = new B_OA_Notice_FileType_R();
                    nf_R.noticeId = notice.NewsId;
                    nf_R.fileTypeId = documenTypeArray[k];

                    Utility.Database.Insert(nf_R, tran);
                }

                //邮件送达
                if (notice.isSendEmail == true)
                {
                    string Mail_Id = ComClass.GetGuid();
                    //保存已发送
                    B_Email email = new B_Email();
                    email.Mail_ID = Mail_Id;
                    email.Mail_CreateData = DateTime.Now.ToString(); //发送时间
                    email.ID = Mail_Id; // +"_" + DateTime.Now.ToLocalTime().ToString();/ID主键
                    email.Mail_SendPersonId = userid; //发件人ID
                    email.Mail_SendPersonName = userInfor.CnName; //发件人姓名
                    email.Mail_Deleted = "0"; //是否已删除
                    email.Mail_deletedPerson = ""; //删除人
                    email.Mail_Type = "1"; //类型,0 未发送,草稿,1已发送
                    email.MailDocumentType = "fajian"; //的文件夹分类 默认是0收件箱
                    email.Mail_IsSee = "0"; //是否已被查看
                    email.markId = ""; //标签id
                    email.markName = ""; //标签名称
                    email.markColor = ""; //标签颜色
                    email.whosEmailId = userid; //邮件拥有者
                    email.Mail_SendDate = DateTime.Now.ToString(); //发送时间
                    email.emailRecieveDate = DateTime.Now.ToString(); //接收事件
                    email.isSaveSendBox = true; //保存发件
                    email.Mail_ReceivePersonId = notice.sendEmailToManId; //接收人ID
                    email.Mail_ReceivePersonName = notice.sendEmailToManName; //接收人名称
                    email.isImportant = true; //重要邮件
                    email.Mail_Title = "(来自文档中心)" + notice.NewsTitle; //标题
                    email.Mail_SendAttachment = notice.ShareAttachment; //附件
                    email.Mail_SendText = notice.NewsText; //内容
                    Utility.Database.Insert<B_Email>(email, tran);
                    //保存给发送方
                    string[] sendIdArray = email.Mail_ReceivePersonId.Split(';');
                    for (int i = 0; i < sendIdArray.Length - 1; i++)
                    {
                        B_Email sendEmail = new B_Email();
                        sendEmail.ID = email.ID + sendIdArray[i]; //主键
                        sendEmail.Mail_ID = email.Mail_ID; //关联ID
                        sendEmail.Mail_Title = email.Mail_Title; //主题
                        sendEmail.Mail_SendText = email.Mail_SendText; //发送内容
                        sendEmail.Mail_SendPersonId = email.Mail_SendPersonId; //发件人ID
                        var sendUserInfor = ComClass.GetUserInfo(sendEmail.Mail_SendPersonId);
                        sendEmail.Mail_SendPersonName = sendUserInfor.CnName; //发件人姓名
                        sendEmail.Mail_SendDate = email.Mail_SendDate; //发送时间
                        sendEmail.Mail_ReceivePersonId = sendIdArray[i]; //接收人ID
                        sendEmail.Mail_ReceivePersonName = email.Mail_ReceivePersonName;
                        sendEmail.Mail_SendAttachment = email.Mail_SendAttachment; //附件
                        sendEmail.Mail_Deleted = "0"; //是否删除0为未删除
                        sendEmail.Mail_Type = "1"; //邮件类别(1已发送0草稿)
                        sendEmail.Mail_CreateData = DateTime.Now.ToString(); //创建时间
                        sendEmail.Mail_IsSee = "0"; //是否已读0未读1已读
                        sendEmail.MailDocumentType = "shoujian"; //电子邮件文件夹类型
                        // sendEmail.isSaveSendBox = email.isSaveSendBox;//是否保存到发件箱
                        sendEmail.isImportant = email.isImportant; //是否是重要的邮件
                        sendEmail.isReadReceipt = email.isReadReceipt; //是否发送查看回执1发送回执0不回执
                        sendEmail.haveAttachment = email.haveAttachment; //是否有附件
                        sendEmail.CCId = email.CCId; //抄送人
                        sendEmail.CCName = email.CCName; //抄送人姓名
                        sendEmail.emailRecieveDate = DateTime.Now.ToString(); //收件时间
                        sendEmail.markId = ""; //标记ID
                        sendEmail.markName = ""; //标记名称
                        sendEmail.markColor = ""; //标记颜色
                        sendEmail.whosEmailId = sendIdArray[i]; //邮件拥有者
                        Utility.Database.Insert<B_Email>(sendEmail, tran);
                    }
                }

                //将指定人员查看存入关系表中
                if (notice.publicRange == 1)
                {
                    string rangeCheckManId = notice.rangeCheckManId;
                    string[] manIdArray = rangeCheckManId.Split(';');
                    //删除原数据
                    B_OA_Notice_AppointManSee manSee_Delete = new B_OA_Notice_AppointManSee();
                    manSee_Delete.Condition.Add("noticeid =" + notice.NewsId);
                    Utility.Database.Delete(manSee_Delete, tran);

                    for (var range = 0; range < manIdArray.Length - 1; range++)
                    {
                        B_OA_Notice_AppointManSee manSee = new B_OA_Notice_AppointManSee();
                        manSee.noticeid = notice.NewsId;
                        manSee.userid = manIdArray[range];
                        Utility.Database.Insert(manSee, tran);
                    }
                }

                Utility.Database.Commit(tran);
                return Utility.JsonMsg(true, "保存成功!"); //将对象转为json字符串并返回到客户端
            }
            catch (Exception ex)
            {
                Utility.Database.Rollback(tran);
                ComBase.Logger(ex); //写异常日志到本地文件夹
                return Utility.JsonMsg(false, ex.Message); //将对象转为json字符串并返回到客户端
            }
        }