예제 #1
0
        public IActionResult Details(int id)
        {
            using (var DataContext = new DocumentEntities())
            {
                DocumentActivity.RecordActivity(DocumentActivityOptions.Viewed, id, userid);

                var doc = DataContext.Documents.First(x => x.Id == id);
                var vm  = new ViewModels.SignFileViewModel
                {
                    DocumentID = doc.Id,
                    Filename   = doc.DocumentName,
                    Base64     = doc.SignedBased64 ?? doc.Base64
                };

                return(View(vm));
            }
        }
예제 #2
0
        public IActionResult SignImage(int id, int pageNumber, float x, float y)
        {
            using (var DataContext = new DocumentEntities())
            {
                DocumentActivity.RecordActivity(DocumentActivityOptions.Signed, id, userid);

                var db = new DocumentEntities();

                var file               = Convert.FromBase64String(db.Documents.Find(id).Base64).ToArray();
                var userSignature      = DataContext.UserSignatures.FirstOrDefault(sig => sig.UserName == username).SignatureBase64;
                var userSignatureBytes = Convert.FromBase64String(userSignature.Replace("image/png;base64,", ""));

                var signedFile = PDFTool.SignFile(file, id, pageNumber, userSignatureBytes, x, y);

                var doc = db.Documents.First(xx => xx.Id == id);
                doc.SignedBased64 = signedFile;
                db.SaveChanges();

                return(Content(signedFile));
            }
        }
예제 #3
0
        public IActionResult UploadFile(IFormFile file, double x = 1, double y = 1)
        {
            var stream = new MemoryStream();

            file.CopyTo(stream);


            //string base64 = PDFTool.ConvertFile(file);
            //string base64 = Libraries.GemBox.ConvertFile(file);

            var db     = new DocumentEntities();
            var newDoc = new Document()
            {
                DocumentName = file.FileName,
                Base64       = Convert.ToBase64String(stream.ToArray())
            };

            db.Documents.Add(newDoc);
            db.SaveChanges();


            DocumentActivity.RecordActivity(DocumentActivityOptions.Created, newDoc.Id, userid: 1);
            return(Json(newDoc.Id));
        }
예제 #4
0
        // Add your own data access methods here.  If you wish to
        // expose your public method to a WCF service, marked them with
        // the attribute [NCPublish], and another T4 template will generate your service contract

        /// <summary>
        /// This method inserts document activity details in db
        /// </summary>
        /// <param name="pkActivityID">pkActivityID</param>
        /// <param name="docID">docID</param>
        /// <param name="status">status</param>
        public void InsertDocumentActivityDetails(int pkActivityID, int docID, string status)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var docActRepo =
                        new DocumentActivityRepository(new EFRepository <DocumentActivity>(), unitOfWork);

                    DocumentActivity newDocAct = new DocumentActivity();
                    newDocAct.FK_UserActivityID = pkActivityID;
                    newDocAct.FK_DocumentID     = docID;
                    newDocAct.DocumentStatus    = status;

                    docActRepo.Add(newDocAct);
                    docActRepo.Save();
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
예제 #5
0
        /// <summary>
        /// Позволяет загрузить действие по идентификатору
        /// </summary>
        /// <param name="activityId">Идентификатор действия</param>
        /// <returns>Загруженное действие</returns>
        public WorkflowActivity LoadActivityById(Guid activityId)
        {
            ActivityCacheLock.AcquireReaderLock(LockTimeout);
            try
            {
                var cached = ActivityCache.Find(activityId);
                if (cached != null)
                {
                    return(cached.CachedObject);
                }

                var lc = ActivityCacheLock.UpgradeToWriterLock(LockTimeout);
                try
                {
                    cached = ActivityCache.Find(activityId);
                    if (cached != null)
                    {
                        return(cached.CachedObject);
                    }

                    var activity = DataContext.GetEntityDataContext().Entities.Object_Defs.OfType <Workflow_Activity>()
                                   .FirstOrDefault(p => p.Id == activityId);

                    WorkflowActivity returnActivity = null;

                    if (activity is Document_Activity)
                    {
                        returnActivity = new DocumentActivity(activity as Document_Activity);
                    }

                    else if (activity is Document_State_Activity)
                    {
                        returnActivity = new DocumentStateActivity(activity as Document_State_Activity);
                    }

                    else if (activity is Presentation_Activity)
                    {
                        returnActivity = new PresentationActivity(activity as Presentation_Activity);
                    }

                    else if (activity is Script_Activity)
                    {
                        returnActivity = new ScriptActivity(activity as Script_Activity);
                    }

                    else if (activity is Finish_Activity)
                    {
                        returnActivity = new FinishActivity(activity as Finish_Activity);
                    }

                    else if (activity is Process_Call_Activity)
                    {
                        returnActivity = new ProcessCallActivity(activity as Process_Call_Activity);
                    }

                    else if (activity is Start_Activity)
                    {
                        returnActivity = new StartActivity(activity as Start_Activity);
                    }

                    else if (activity is Gate_Call_Activity)
                    {
                        returnActivity = new GateCallActivity(activity as Gate_Call_Activity);
                    }

                    if (returnActivity != null)
                    {
                        ActivityCache.Add(returnActivity, activityId);
                    }

                    return(returnActivity);
                }
                finally
                {
                    ActivityCacheLock.DowngradeFromWriterLock(ref lc);
                }
            }
            finally
            {
                ActivityCacheLock.ReleaseReaderLock();
            }
        }
예제 #6
0
 public void RemoveActivity(DocumentActivity activity)
 {
     this.RemoveChild(activity.RelatedNode);
 }
예제 #7
0
 public DocumentActivity AppendActivity(DocumentActivity activity)
 {
     XmlNode node = this.AppendChild(activity.RelatedNode);
     return activity;
 }
예제 #8
0
 public void Delete(DocumentActivity entity)
 {
     Repository.Delete(entity);
 }
예제 #9
0
 public void Add(DocumentActivity entity)
 {
     Repository.Add(entity);
 }