public void Close(UserStoryAttachment diagramObject, string userId)
        {
            TransactionOptions _transcOptions = new TransactionOptions();
            _transcOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            using (TransactionScope sc = new TransactionScope(TransactionScopeOption.Required, _transcOptions, EnterpriseServicesInteropOption.Full))
            {
                try
                {
                    #region lock
                    var diagrams = new List<UserStoryAttachment>();
                    diagrams.Add(diagramObject);
                    LockDiagrams(diagrams,userId);
                    #endregion

                    diagramObject.state = AppConstants.DIAGRAM_STATUS_CLOSED;
                    rep.UpdateStatus(diagramObject);

                    sc.Complete();

                }
                catch (Exception ex)
                {
                    throw new Exception(AppConstants.EXCEPTION_GLOBAL);
                }
                finally
                {
                    sc.Dispose();
                }
            }
        }
 public void Share(Attachment diagramObject,int userStoryId, string userId)
 {
     TransactionOptions _transcOptions = new TransactionOptions();
     _transcOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
     using (TransactionScope sc = new TransactionScope(TransactionScopeOption.Required, _transcOptions, EnterpriseServicesInteropOption.Full))
     {
         try
         {
             UserStoryAttachment attachment = rep.Get(new UserStoryAttachment() { attachId = diagramObject.Id, userStoryId = userStoryId });
             diagramObject.UserStoryAttachments.ToList().ForEach(attach =>
             {
                 attach.activties = attachment.activties;
                 attach.state = AppConstants.DIAGRAM_STATUS_OPEN;
                 attach.SVG = attachment.SVG;
                 attach.update_by = userId;
                 attach.update_date = DateTime.Now;
                 attach.version = attachment.version;
             });
             rep.Add(diagramObject.UserStoryAttachments.ToList());
             sc.Complete();
         }
         catch (Exception ex)
         { }
         finally
         {
             sc.Dispose();
         }
     }
 }
Beispiel #3
0
 public List <AttachmentHistory> FindHistory(UserStoryAttachment diagramObject)
 {
     try
     {
         return(repository.FindDiagramHistory(diagramObject));
     }
     catch (Exception ex)
     {
         throw new BadRequestException(AppConstants.EXCEPTION_RETREIVE_DIAGRAM_HISTORY);
     }
 }
        public int Update(UserStoryAttachment diagramObject, string graph, string userId, string svg)
        {
            int id = 0;
            TransactionOptions _transcOptions = new TransactionOptions();
            _transcOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            List<UserStoryAttachment> openDiagrams = new List<UserStoryAttachment>();
            using (TransactionScope sc = new TransactionScope(TransactionScopeOption.Required, _transcOptions, EnterpriseServicesInteropOption.Full))
            {
                
                try
                {
                    diagramObject.activties = graph;
                    diagramObject.SVG = svg;
                    diagramObject.state = AppConstants.DIAGRAM_STATUS_OPEN;

                    openDiagrams = repository.Update(diagramObject, userId);
                    sc.Complete();
                }
                catch (Exception ex)
                {
                    throw new BadRequestException(AppConstants.EXCEPTION_DIAGRAM_SAVING_ERROR);
                }
                finally
                {
                    sc.Dispose();
                }

            }
            #region send email notification / save to history in case diagram updated
                openDiagrams.ForEach(diagram =>
                {
                    repository.SaveToHistory(diagram, userId);
                    try
                    {
                        SendEmail(diagram, userId, "EditDiagram");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Cannot send email" + ex.Message);
                    }
                });
           
            
            #endregion
            return id;

        }
        public void Delete(UserStoryAttachment diagram,string userId)
        {
            diagram.state = AppConstants.DIAGRAM_STATUS_FINISIHED;
            rep.UpdateStatus(diagram);

            #region send email notification / save to history in case diagram updated
            try
            {
                diagram = rep.Get(diagram);
                SendEmail(diagram, userId, "DeleteDiagram");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Cannot send email" + ex.Message);
            }
            #endregion
        }
Beispiel #6
0
        private void SendEmail(UserStoryAttachment diagramObject, string userId, string template)
        {
            MailService mailService         = MailService.Instance;
            string      _mailConfigFilePath = AppDomain.CurrentDomain.GetData("DataDirectory") + "\\Mail.xml";

            mailService.LoadFile(_mailConfigFilePath);
            DTOMessage     message      = mailService.GetMessage(template);
            string         sendFrom     = (ConfigurationSettings.AppSettings["MailFromAddress"] != null) ? ConfigurationSettings.AppSettings["MailFromAddress"].ToString() : "";
            UserRepository uRepositorty = new UserRepository();
            var            actionUser   = uRepositorty.FindById(userId);

            diagramObject.UserStory.AspNetUsers.ToList().ForEach(f =>
            {
                string messageSubject = MailService.formatMsg(message.Subject, new string[] { diagramObject.Attachment.name.ToString() });
                string bodyStr        = MailService.formatMsg(message.Body, new string[] { diagramObject.Attachment.name.ToString(), f.UserName, actionUser.UserName, diagramObject.UserStory.name });
                MailService.SendMessageWithAttachment(sendFrom, f.Email, null, messageSubject, bodyStr, null);
            });
        }
Beispiel #7
0
        public static void Update(IDictionary <string, object> diagram)
        {
            var diagramObject = new UserStoryAttachment();

            if (diagram.ContainsKey("Id") && !string.IsNullOrEmpty(diagram["Id"].ToString()))
            {
                diagramObject.attachId = int.Parse(diagram["Id"].ToString());
            }

            if (diagram.ContainsKey("userStoryId") && !string.IsNullOrEmpty(diagram["userStoryId"].ToString()))
            {
                diagramObject.userStoryId = int.Parse(diagram["userStoryId"].ToString());
            }

            string graph = diagram.ContainsKey("graph") ? diagram["graph"].ToString() : null;
            string svg   = diagram.ContainsKey("svg") ? diagram["svg"].ToString() : null;

            service.Update(diagramObject, graph, new New().GetUserId(), svg).ToString();
        }