Exemple #1
0
        public ServicesResult CreateDraftDoc(VmDocDraftSave vmDraftDoc)
        {
            try
            {
                var ownerUserId = vmDraftDoc.OwnerUserId;

                Guid senderDepartmentId  = _chartService.GetDepartment(vmDraftDoc.DraftFolderId).ChartId;
                Guid receverDepartmentId = senderDepartmentId;



                //درج خود سند
                var document = new DomainLayer.DB_Model.Documents.Document
                {
                    OwnerUserId = ownerUserId,
                    Subject     = vmDraftDoc.Subject,
                    Content     = vmDraftDoc.Content,
                };

                _document.Add(document);

                //درج گردش سند برای نمایش سند در ‍پوشه پیشنویس
                var send = new DomainLayer.DB_Model.Send.Send()
                {
                    DocId       = document.DocId,
                    OwnerUserId = ownerUserId,
                    //محل سند
                    FolderId            = vmDraftDoc.DraftFolderId,
                    ReceverEmployeeId   = ownerUserId,
                    SenderEmployeeId    = ownerUserId,
                    ReceverDepartmentId = receverDepartmentId,
                    SenderDepartmentId  = senderDepartmentId,
                    SendDescription     = "تایپ سند جدید"
                };

                _send.Add(send);


                _uow.SaveChanges();

                return(new ServicesResult()
                {
                    Success = true,
                    Data = new { docNo = document.DocNo, docId = document.DocId },
                });
            }
            catch (Exception ex)
            {
                return(new ServicesResult()
                {
                    Success = false,
                    Message = ex.Message,
                    InnerExeption = ex.InnerException.Message,
                });
            }
        }
Exemple #2
0
        public ServicesResult SendDocuments(VmDocSendPost docSendmodel)
        {
            try
            {
                foreach (var doc in docSendmodel.DocIds)
                {
                    foreach (var recivers in docSendmodel.Recivers)
                    {
                        var newsSendRecord = new DomainLayer.DB_Model.Send.Send()
                        {
                            DocId               = Guid.Parse(doc),
                            OwnerUserId         = Guid.Parse(docSendmodel.OwnerUserId),
                            SendDescription     = docSendmodel.Description,
                            ReceverEmployeeId   = Guid.Parse(recivers.ReceiverPrsId),
                            ReceverDepartmentId = Guid.Parse(recivers.ReceiverFolIds),
                            SenderEmployeeId    = Guid.Parse(docSendmodel.OwnerUserId),
                        };

                        newsSendRecord.FolderId =
                            _chartService.GetFolders(Guid.Parse(recivers.ReceiverFolIds),
                                                     ChartEnumerable.FolderType.Inbox).ChartId;

                        newsSendRecord.SenderDepartmentId =
                            _chartService.GetDepartment(Guid.Parse(docSendmodel.Folid)).ChartId;


                        _sendService.CreateNewSend(newsSendRecord);
                    }
                }


                return(new ServicesResult()
                {
                    Success = true,
                    Message = "اسناد با موفقیت ارسال شد",
                });
            }
            catch (Exception ex)
            {
                return(new ServicesResult()
                {
                    Success = false,
                    Message = ex.Message,
                    InnerExeption = ex.InnerException.Message,
                });
            }
        }
Exemple #3
0
        public ServicesResult CreateNewSend(DomainLayer.DB_Model.Send.Send send)
        {
            try
            {
                _send.Add(send);

                _uow.SaveChanges();
                return(new ServicesResult()
                {
                    Success = true
                });
            }
            catch (Exception ex)
            {
                return(new ServicesResult()
                {
                    Success = false,
                    Message = ex.Message,
                    InnerExeption = ex.InnerException.Message,
                });
            }
        }
Exemple #4
0
        public ServicesResult SendDocWithTitles(Guid docId, Guid OwnerUserId, Guid OwnerFolId)
        {
            try
            {
                var docModel = _documentService.GetDocument(docId);
                if (docModel == null)
                {
                    return new ServicesResult()
                           {
                               Success = false, Message = "Document Not found"
                           }
                }
                ;

                var Titles = docModel.Titles.Where(w => w.IsActive && !w.IsSended);
                if (!Titles.Any())
                {
                    return new ServicesResult()
                           {
                               Success = false, Message = "Ready Titles Not Exist"
                           }
                }
                ;

                foreach (var title in Titles.OrderBy(o => o.Order))
                {
                    var newsSendRecord = new DomainLayer.DB_Model.Send.Send()
                    {
                        DocId               = docId,
                        OwnerUserId         = OwnerUserId,
                        SendDescription     = $"{title.Type.Subject} - {title.SenDescription}",
                        ReceverEmployeeId   = title.ReceiverEmployeeId,
                        ReceverDepartmentId = title.ReceiverDepartmentId,
                        SenderEmployeeId    = OwnerUserId,
                    };

                    newsSendRecord.FolderId =
                        _chartService.GetFolders(title.ReceiverDepartmentId,
                                                 ChartEnumerable.FolderType.Inbox).ChartId;

                    newsSendRecord.SenderDepartmentId =
                        _chartService.GetDepartment(OwnerFolId).ChartId;


                    _sendService.CreateNewSend(newsSendRecord);

                    _titleService.SetAsSendedDoc(title.Id);

                    //اگر تایید و امضا یا ثبت بود تا قبل از انجام عملیات برای عناوین بعدی ارسال نگردد
                    if (title.Type.TypeId == (int)TitleEnumerable.TitleType.confirme || title.TypeId == (int)TitleEnumerable.TitleType.signe || title.TypeId == (int)TitleEnumerable.TitleType.Register)
                    {
                        break;
                    }
                }

                return(new ServicesResult()
                {
                    Success = true,
                    Message = "سند با موفقیت ارسال شد",
                });
            }
            catch (Exception ex)
            {
                return(new ServicesResult()
                {
                    Success = false,
                    Message = ex.Message,
                    InnerExeption = ex.InnerException.Message,
                });
            }
        }