/// <summary> /// WorkflowReference constructor, usable only inside Security package /// NDR: Takes a great number of parameters to not make a DB access /// </summary> /// <param name="userId">The owner's userId</param> /// <param name="publicationId">The Storage Publication id</param> /// <param name="wfName">The workflow name</param> /// <param name="wfName">The workflow description</param> /// <param name="themeId">the theme id</param> /// <param name="creqid">The Storage Compilation Request id</param> /// <param name="isPrivate"><value>true</value>if is a private form, <value>false</value>otherwise</param> /// <param name="filling"><value>true</value>if the form is currently fillable, <value>false</value> otherwise</param> internal ComputableWorkflowReference(int userId, int publicationId, string wfName, string wfDescription, int themeId, int creqid, bool isPrivate, bool filling, DateTime expiry) { this.sto = new StorageManager(); this.userId = userId; this.publicationId = publicationId; this.wfName = wfName; this.wfDescription = wfDescription; this.themeId = themeId; this.isPrivate = isPrivate; this.filling = filling; this.compilationReqId = creqid; complete = true; this.expirationDate = expiry; if (themeId == defaultthemeid) { isDefTheme = true; } else { isDefTheme = false; } cwf_cache = null; }
internal ComputableWorkflowReference(int userId, int publicationId, string wfName, string wfDescription, bool filling, DateTime expiry) { this.sto = new StorageManager(); this.userId = userId; this.publicationId = publicationId; this.wfName = wfName; this.wfDescription = wfDescription; this.filling = filling; complete = false; this.themeId = -1; this.isPrivate = false; this.compilationReqId = -1; cwf_cache = null; this.expirationDate = expiry; }
//is it possible to delete computable workflows??? if not delete this method.. public bool Remove() { if (sto.removeEntity <Storage.Publication>(publicationId)) { isPrivate = false; filling = false; userId = -1; publicationId = -1; themeId = -1; compilationReqId = -1; isDefTheme = false; cwf_cache = null; return(true); } else { return(false); } }
//Metodo barbaro per calcolare i nodi coinvolti nel percorso anche in caso di biforcazioni private List <string> BackTrace(IComputableWorkflow WF, string checkPointNode) { List <string> backNodes = new List <string>(); while (!WF.IsInitialState())//backtrace dal nodo corrente { backNodes.Add(WF.GetState().Name); WF.ComputeNewStatus(WFeventType.ROLLBACK, null, null); //nodePlaceHolder.ResetStates(); presenPanel2.Controls.Clear(); presenPanel2.Visible = false; //renderNode(workflow.GetState()); //nodePlaceHolder.ResetStates(); //nodePlaceHolder.Controls.Clear(); presenPanel.Controls.Clear(); renderNode(workflow.GetState()); } backNodes.Add(WF.GetState().Name); WFnode curr = WF.GetState(); while (curr.Name != checkPointNode)//riporta il workflow allo stato corrente { WFnode actual = workflow.GetState(); XmlDocument doc = new XmlDocument(); doc.LoadXml(actual.GetValue(nodePlaceHolder.Controls[0], actual.GetRenderingDocument().DocumentElement.FirstChild)); ActionResult ar = workflow.ComputeNewStatus(WFeventType.TRYGOON, doc, ValidationEventHandler); curr = WF.GetState(); //nodePlaceHolder.ResetStates(); //nodePlaceHolder.Controls.Clear(); presenPanel.Controls.Clear(); renderNode(workflow.GetState()); } return(backNodes); }
private void loadWf(string wfId, string crId, string user, string serv, string tokMail) { Trace.Warn("Begin load workflow"); Security.ComputableWorkflowReference cref = Security.Token.GetWorkflow(wfId, crId, user, serv, tokMail); if (cref == null) { contentAll.Style.Add("background", "#A7A7A7 url('../lib/image/lock2.png') no-repeat center"); contentAll.Style.Add("-moz-opacity", "0.35"); contentAll.Visible = true; Page.Controls.Add(new LiteralControl("<script>setType(-2);</script>")); Session["wf"] = null; } else { Session["wfr"] = cref; workflow = cref.GetWorkflow(); Session["wf"] = workflow; //si fa la prima visualizzazione renderNode(workflow.GetState()); #region caricamento del tema 2° versione pro Security.Theme theme = ((Security.ComputableWorkflowReference)Session["wfr"]).GetTheme(); Page.Header.Controls.Add(new LiteralControl(@"<style type='text/css'>" + theme.CSS + "</style" + ">")); if (theme.Title == "") { formTitle.InnerText = "Testo di prova"; } else { formTitle.InnerText = theme.Title; formTitle.Style.Add("font-family", "Verdana"); formTitle.Style.Add("font-size", "30px"); } #endregion } Trace.Warn("End load workflow"); }
/// <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); } }
protected void Page_Load(object sender, EventArgs e) { // Init the Session element that bring the logo to null if (Page != null) { Page.Session["TE_currentLogo"] = null; } // Taking the CurrentWorkflow from the session elemnt. ComputableWorkflowReference wfr = null; IComputableWorkflow wf = null; try { wfr = (ComputableWorkflowReference)Page.Session["WFE_CurrentWorkflow"]; wf = wfr.GetWorkflow(); } catch (Exception) { Response.Write("No workflow in session!"); Response.End(); return; } bool useStaticLabel = false; try { useStaticLabel = (bool)Page.Session["UsingStaticFields"]; } catch (Exception) { Response.Write("No UsingStaticFields in session!"); Response.End(); return; } if (useStaticLabel) { editStaticLabel.InnerHtml = "<label for=\"color_staticLabel\">Static Label Color:</label><input rel=\"staticLabel\" class=\"gccolor\" onblur=\"toolbox.applyChanges('staticLabel','color', this.value, 'color' );\" title=\"Color of the Static Label. Example: #ff00ff\" id=\"color_staticLabel\" type=\"text\"/><div style=\"display:none;\"><input id=\"staticLabelApplyToID\" type=\"checkbox\" /></div>"; } else { editStaticLabel.InnerHtml = ""; } // bla bla bla int tabCounter = 1; List <Panel> divPanel = new List <Panel>(); presenPanel.Controls.Add(new LiteralControl("<ul class=\"tabs\">")); // Iterating each workflow node to render the form elemnt list foreach (WFnode nd in wf.getNodeList()) { Panel p = new Panel(); //p.Enabled = false; XmlDocument renderDoc = nd.GetRenderingDocument(); string nodeName = XmlConvert.DecodeName(renderDoc.DocumentElement.Attributes["name"].InnerText); presenPanel.Controls.Add(new LiteralControl("<li><a href=\"#tabs" + tabCounter + "\" >" + nodeName + "</a></li>")); //p.Controls.Add(new LiteralControl("<div id=\"tabs" + tabCounter + "\" style=\"position: relative; height: 500px;\" >")); // Hangling the webcontrol XmlNode cmplexRenering = renderDoc.DocumentElement.FirstChild; Control wc = nd.GetWebControl(Page.Server, cmplexRenering); //Disabling all BaseValidator to remove useless text <.< DisableControl(wc); p.Controls.Add(new LiteralControl("<div>")); p.Controls.Add(wc); p.Controls.Add(new LiteralControl("</div>")); divPanel.Add(p); tabCounter++; } presenPanel.Controls.Add(new LiteralControl("</ul>")); presenPanel.Controls.Add(new LiteralControl("<div class=\"panes\"> ")); // Add each panel to presenPanel foreach (var p in divPanel) { presenPanel.Controls.Add(p); } presenPanel.Controls.Add(new LiteralControl("</div>")); // Retriving the current Theme informations IWorkflowThemeReference iwfr = (IWorkflowThemeReference)Page.Session["WFE_CurrentWorkflow"]; if (Page.Session["CurrentTheme"] == null) { Page.Session["CurrentTheme"] = (Theme)iwfr.GetTheme(); } Theme theme = (Theme)Page.Session["CurrentTheme"]; //Theme theme = (Theme)iwfr.GetTheme(); string propertyListJson = "<script language='javascript'> initTE('" + theme.Title + "');"; propertyListJson += " var PropertyList=function(){"; IBaseType field; foreach (Type t in FieldsManager.FieldTypes) { field = (IBaseType)FieldsManager.GetInstance(t); if (!String.IsNullOrEmpty(field.JSON_StyleProperties)) { propertyListJson += "var " + field.GetType().Name + "PropertyList = " + field.JSON_StyleProperties + ";"; } } propertyListJson += @" return{ getList:function( type ){ if( eval( ""typeof "" + type + ""PropertyList == 'undefined'"" ) ) { type = ""StringBox""; } return eval( type + ""PropertyList""); }, validate:function( type, value ){ if( type == ""color"" ) return (value.match( /#[a-fA-F0-9]{6}/ ) || value.match(/rgb\([ ]*[0-9]{1,3}[ ]*,[ ]*[0-9]{1,3}[ ]*,[ ]*[0-9]{1,3}[ ]*\)/i)); if( type == ""size"" ) return ( value.match( /\d+px/ ) || value.match( /\d+\%/ ) || value.match( /\d+em/ )); if( type == ""none"" ) return true; if( type == ""font"" ) return true; return false; } }; }(); "; CssParser cssParser = new CssParser(); cssParser.AddStyleSheet(theme.CSS); foreach (var styles in cssParser.Styles) { foreach (KeyValuePair <string, string> pv in styles.Value.Attributes) { propertyListJson += string.Format(CssAddJS, styles.Key.Substring(0, 1), styles.Key.Substring(1), pv.Key, pv.Value); } } if (theme.Image != null) { Page.Session["TE_currentLogo"] = theme.Image; propertyListJson += "stopUpload('drawLogo.aspx', true);"; } propertyListJson += "</script>"; Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", propertyListJson); //Adding the CSS to the Page Header. Page.Header.Controls.Add( new LiteralControl( @"<style type='text/css'>" + theme.CSS + "</style" + ">" ) ); //for manage contacts back button (GUI modify) Session["contactReturn"] = "/ThemeEditor/ThemeEditor.aspx"; }
protected void Page_Init(object sender, EventArgs e) { //presenPanel.Controls.Add(nodePlaceHolder); //presenPanel.Controls.Add(); if (!Page.IsPostBack) { Trace.Warn("Begin retrieving env variabiles from db"); Page.Controls.Add(new LiteralControl("<script>headerDivRed('none');</script>")); String crId = Request.Params.Get("CompilationRequestID"); String wfId = Request.Params.Get("WorkflowID"); String user = Request.Params.Get("Username"); String serv = Request.Params.Get("Service"); String tokMail = Request.Params.Get("Token"); Trace.Warn("End retrieving env variabiles from db"); if (crId != null) { if (!crId.Equals("-1")) {//Abbiamo tutto loadWf(wfId, crId, user, serv, tokMail); } else { //Manca qualcosa crID ==-1 if (Session["LoginContactUserID"] == null) { //E' la prima volta che viene richieta la pagina con crId == -1 int serviceid = -1; try { serviceid = int.Parse(serv); } catch (Exception e2) { serviceid = -1; } if (serviceid == -1) {//Va fatto scegliere il servizio contentAll.Style.Add("background", "#A7A7A7 url('../lib/image/lock2.png') no-repeat center"); contentAll.Style.Add("-moz-opacity", "0.35"); contentAll.Visible = true; List <Security.Service> listaServizi = Security.ExternalService.List(); string temp = ""; foreach (Security.Service s in listaServizi) { temp = temp + s.ServiceName + "|"; } Page.Controls.Add(new LiteralControl("<script>setType(-1, '" + temp + "');</script>")); } //Si presume che serv sia valido o scelto dall'utente Session["LoginContact"] = true; Session["LoginContactServiceID"] = serviceid; Session["LoginContactReturnURL"] = "http://" + Security.EnvironmentManagement.getEnvValue("webServerAddress") + Request.Url.AbsolutePath + Request.Url.Query; if (serviceid != -1) { Response.Redirect("http://" + Security.EnvironmentManagement.getEnvValue("webServerAddress") + "/Auth/login.aspx"); } } else {//Vuol dire che Session["LoginContactUserID"] != null, e' la seconda volta e ho tutte le info // Si ma le hai nella sessione! serv = "" + (int)Session["LoginContactServiceID"]; user = (string)Session["LoginContactUserID"]; // Pulisco la sessione, nn mi servono piu' Session["LoginContactServiceID"] = null; Session["LoginContactUserID"] = null; loadWf(wfId, crId, user, serv, tokMail); } } } else { workflow = (IComputableWorkflow)Session["wf"]; WFnode currentNode = workflow.GetState(); renderNode(currentNode); UpdateHistory(currentNode, new ActionResult(true)); } } else { Page.Controls.Add(new LiteralControl("<script>headerDivRed('filling');</script>")); workflow = ((IComputableWorkflow)Session["wf"]); if (workflow != null) { if (!workflow.IsEndComputationState) { renderNode(workflow.GetState()); } Security.Theme theme = ((Security.ComputableWorkflowReference)Session["wfr"]).GetTheme(); Page.Header.Controls.Add(new LiteralControl(@"<style type='text/css'>" + theme.CSS + "</style" + ">")); if (theme.Title == "") { formTitle.InnerText = "NO TITLE"; formTitle.Style.Add("font-family", "Verdana"); formTitle.Style.Add("font-size", "30px"); } else { formTitle.InnerText = theme.Title; } } } }
protected void Page_Load(object sender, EventArgs e) { List <Control> listControl = new List <Control>(); string cbReference = this.ClientScript.GetCallbackEventReference(this, "arg", "ReceiveServerData", ""); string callBackScript = @"function CallServer(arg, context){" + cbReference + ";}"; this.ClientScript.RegisterClientScriptBlock(this.GetType(), "CallServer", callBackScript, true); listControl.Add(new ServiceFakeLog()); List <Control> .Enumerator it = listControl.GetEnumerator(); while (it.MoveNext()) { callFill.Controls.Add(it.Current); IControlFormFiller t = (IControlFormFiller)it.Current; cbReference = Page.ClientScript.GetCallbackEventReference(it.Current, "arg", t.getNameFunctionServerResponse(), "context"); callBackScript = @"function " + t.getNameFunctionServerCall() + "(arg, context)" + "{ " + cbReference + ";}"; Page.ClientScript.RegisterClientScriptBlock(it.Current.GetType(), t.getNameFunctionServerCall(), callBackScript, true); } if (((IComputableWorkflow)Session["wf"]) != null) { workflow = (IComputableWorkflow)Session["wf"]; //RIGA DI FIX PER NULL??!!! presenPanel.Attributes.Add("style", "position:relative;left:800px;width:0px;display:none;"); /////////////////////////////////HISTORY////////////////////////////////////////////////////////////////// IEnumerable <WFnode> nl = workflow.getNodeList(); List <string> nodeNames = new List <string>(); foreach (WFnode n in nl) { nodeNames.Add(n.Name); } List <string> ns = new List <string>(); ns = workflow.GetThroughPath(); if (ns.Count > 0) { string initNode = ""; int initNodeIndex = 0; for (int i = 0; i < nodeNames.Count; i++) { if (nodeNames[i] == ns[ns.Count - 1]) { initNode = nodeNames[i]; initNodeIndex = i; } } string tmp = nodeNames[0]; nodeNames.RemoveAt(0); nodeNames.Insert(0, initNode); nodeNames.RemoveAt(initNodeIndex); nodeNames.Insert(initNodeIndex, tmp); int h = 1; for (int i = ns.Count - 2; i >= 0; i--) { nodeNames.RemoveAt(h); nodeNames.Insert(h, ns[i]); h++; } //if (ns.Count < nodeNames.Count) //{ // nodeNames.RemoveAt(ns.Count); // nodeNames.Insert(ns.Count, workflow.GetState().Name); //} } else { string initNode = ""; int initNodeIndex = 0; for (int i = 0; i < nodeNames.Count; i++) { if (nodeNames[i] == workflow.GetState().Name) { initNode = nodeNames[i]; initNodeIndex = i; } } string tmp = nodeNames[0]; nodeNames.RemoveAt(0); nodeNames.Insert(0, initNode); nodeNames.RemoveAt(initNodeIndex); nodeNames.Insert(initNodeIndex, tmp); } int W = ((nodeNames.Count() - 1) * 16) + 32 + ((nodeNames.Count()) * 5); int L = 480 - W / 2; presenPanel3.Attributes.Add("style", "position:relative;width:" + W + "px;margin:4px 0px 10px 0px;left:" + L + "px;");//"style", "position:relative;width:100%;margin:4px 0px 10px 0px;left:0px;" WFnode actual = workflow.GetState(); int j = 0; presenPanel3.Controls.Clear(); foreach (string n in nodeNames) { ImageButton l = new ImageButton(); l.ImageUrl = "../lib/image/backNode.PNG"; l.CssClass = "HistoryLabel"; //if (j == 0) // l.ToolTip = nodeNames[0]; l.ToolTip = nodeNames[j]; if (!IsPostBack) { if (j == 0) { l.ImageUrl = "../lib/image/currentNode.PNG"; l.Attributes.Add("style", "margin-left:5px;"); } else { l.Enabled = false; l.ImageUrl = "../lib/image/forwardNode.PNG"; l.Attributes.Add("style", "margin-left:5px;margin-bottom:8px;"); } } l.ID = j.ToString(); //l.OnClientClick = "slideRightToLeft();"; l.Click += new ImageClickEventHandler(l_Click); l.CausesValidation = false; presenPanel3.Controls.Add(l); j++; } /////////////////////////////////HISTORY////////////////////////////////////////////////////////////////// } }