Example #1
0
 private Storage.Theme duptheme(int themeId)
 {
     Storage.Theme theme = sto.getEntityByID <Storage.Theme>(themeId);
     if (theme == null)
     {
         return(null);
     }
     Storage.Theme       result = sto.addTheme(userId, theme.themeTitle, theme.CSS, Image.FromStream(new MemoryStream(theme.logo.ToArray())));
     Storage.Publication pub    = sto.getEntityByID <Storage.Publication>(publicationId);
     if (result != null && pub != null)
     {
         this.themeId = result.themeID;
         pub.themeID  = result.themeID;
         if (sto.commit())
         {
             return(result);
         }
         else
         {
             return(null);
         }
     }
     else
     {
         return(null);
     }
 }
Example #2
0
        /// <summary>
        /// Build an email conteining the link to the private form.
        /// </summary>
        /// <param name="receiverMail">the recipient mail address</param>
        /// <param name="publication">the publication</param>
        /// <param name="compilationRequest">the compilation request</param>
        public MailForPublicForm(MailAddress receiverMail, Storage.Publication publication, Storage.CompilationRequest compilationRequest)
        {
            From = senderAdd;
            To.Add(receiverMail);

            //Subject = "Floading - Form pubblica creata!";
            Subject = _Subject;

            Object[] parameters = new Object[4];
            parameters[0] = publication.namePublication;
            parameters[1] = Token.ToLink(publication, compilationRequest);
            if (compilationRequest == null)
            {
                parameters[2] = "CompilationRequestID: " + "-1";
                parameters[3] = "CompilationRequestID: " + "-1";
            }
            else
            {
                parameters[2] = "CompilationRequestID: " + compilationRequest.compilReqID;
                parameters[3] = "CompilationRequestID: " + compilationRequest.compilReqID;
            }
            //Metto caratteri speciali giusti. Il db li codifica diversamenti, qui li rimetto a posto.
            string message = String.Format(_bodyPlainTextFormat, parameters);
            int    index;
            string sub;

            index = message.IndexOf("\\n");
            if (index != -1 && index < message.Length - 2)
            {
                sub     = message.Substring(index, 2);
                message = message.Replace(sub, "\n");
            }
            index = message.IndexOf("\\r");
            if (index != -1 && index < message.Length - 2)
            {
                sub     = message.Substring(index, 2);
                message = message.Replace(sub, "\n");
            }
            index = message.IndexOf("\\t");
            if (index != -1 && index < message.Length - 2)
            {
                sub     = message.Substring(index, 2);
                message = message.Replace(sub, "\t");
            }
            AlternateView alternatePLAIN = AlternateView.CreateAlternateViewFromString(message, new System.Net.Mime.ContentType("text/plain"));

            alternatePLAIN.TransferEncoding = System.Net.Mime.TransferEncoding.SevenBit;
            //if (alternatePLAIN==null || alternateHTML==null) return;
            if (alternatePLAIN == null)
            {
                return;
            }
            //AlternateViews.Add(alternateHTML);
            AlternateViews.Add(alternatePLAIN);
        }
Example #3
0
        private bool fillReference()
        {
            StorageManager sto = new StorageManager();

            Storage.Publication pub = sto.getEntityByID <Publication>(publicationId);
            if (pub == null)
            {
                return(false);
            }
            this.themeId = pub.themeID;

            this.isPrivate = !pub.isPublic;
            if (themeId == defaultthemeid)
            {
                isDefTheme = true;
            }
            else
            {
                isDefTheme = false;
            }
            if (filling)
            {
                // Find the compilationRequest
                Storage.CompilationRequest creq = sto.getCompilationRequestByPulicationAndContact(userId, publicationId);
                if (creq == null)
                {
                    return(false);
                }
                else
                {
                    compilationReqId = creq.compilReqID;
                }
            }
            this.complete = true;
            return(true);
        }
Example #4
0
        public FormType GetFormType()
        {
            Storage.Publication pub = sto.getEntityByID <Storage.Publication>(publicationId);

            bool isPublic           = pub.isPublic;
            bool isAnonymous        = pub.anonymResult;
            bool isResultReplicated = pub.isResultReplicated;

            if (isPublic)
            {
                if (isResultReplicated)
                {
                    return(FormType.PUBLIC_WITH_REPLICATION);
                }
                else
                if (pub.Service.serviceID != 1)
                {
                    return(FormType.PUBLIC_BY_SERVICE);
                }
                else
                {
                    return(FormType.PUBLIC_WITHOUT_REPLICATION);
                }
            }
            else
            {
                if (isAnonymous)
                {
                    return(FormType.PRIVATE_ANONYM);
                }
                else
                {
                    return(FormType.PRIVATE_NOT_ANONYM);
                }
            }
        }
Example #5
0
        /// <summary>
        /// Private method, used to retrieve wf from db and put into the object cache
        /// </summary>
        /// <returns><value>true</value>on success,<value>false</value> otherwise</returns>
        private bool _RetrieveWf()
        {
            if (cwf_cache == null)
            {
                // Must retrieve it from db

                Storage.Publication pub = sto.getEntityByID <Publication>(publicationId);
                if (pub == null)
                {
                    return(false);
                }
                cwf_cache = (IComputableWorkflow)sto.byteArray2Object(pub.xml.ToArray());
                if (cwf_cache == null)
                {
                    return(false);
                }
                cwf_cache.setWFname(pub.namePublication);
                return(true);
            }
            else
            {
                return(false);
            }
        }