Ejemplo n.º 1
0
 public void RaiseCallbackEvent(string eventArgument)
 {
     result = "";
     Security.Token tok = (Security.Token)Page.Session["Token"];
     if (tok != null && tok.Authenticated && tok.GetCurrentUser().Registered)
     {
         Security.User usr = tok.GetCurrentUser();
         List <Security.FilledWorkflowReference> listForm = usr.GetCompiledForms();
         if (listForm.Count == 0)
         {
             result = "You didn't create any form.";
         }
         else
         {
             foreach (Security.FilledWorkflowReference w in listForm)
             {
                 result += w.getFilledWorkflowName() + "\\|)//" + w.getPublicationDescription() + "\\|//";
             }
         }
     }
     else
     {
         result = "You haven't authenticated yet.";
     }
 }
Ejemplo n.º 2
0
        public void RaiseCallbackEvent(string eventArgument)
        {
            Security.Token tok = (Security.Token)Page.Session["Token"];


            if (tok != null && tok.Authenticated && tok.GetCurrentUser().Registered)
            {
                Security.User user = tok.GetCurrentUser();

                if (user.Registered)
                {
                    if (user != null)
                    {
                        if (eventArgument != null && eventArgument.Equals(""))
                        {
                            result = "true";
                            foreach (Security.Service serv in user.GetSubscribedServices())
                            {
                                result += "β" + serv.ServiceName + "γ" + Convert.ToString(user.LoginNeeded(serv.ServiceId));
                            }
                        }
                    }
                }
                else
                {
                    result = "unrβ";
                }
            }
        }
Ejemplo n.º 3
0
        public void RaiseCallbackEvent(string eventArgument)
        {
            Security.Token tok = (Security.Token)Page.Session["Token"];
            if (tok != null && tok.Authenticated && tok.GetCurrentUser().Registered)
            {
                Security.User user = tok.GetCurrentUser();
                string[]      args = eventArgument.Split('|');

                List <Security.Contact> contacts = user.GetContactsByGroup(args[1]);

                if (contacts.Count == 0)
                {
                    result = "There is not any contact";
                }
                else
                {
                    result = args[0] + "\\|/";

                    foreach (Security.Contact c in contacts)
                    {
                        result += c.Name + "\\|/";
                    }
                }
            }
            else
            {
                result = "You haven't authenticated yet.";
            }
        }
Ejemplo n.º 4
0
        public void RaiseCallbackEvent(string eventArgument)
        {
            result = "";
            Security.Token tok = (Security.Token)Page.Session["Token"];
            if (tok != null && tok.Authenticated && tok.GetCurrentUser().Registered)
            {
                Security.User user = tok.GetCurrentUser();
                List <Security.ComputableWorkflowReference> computableWf = user.GetComputableWorkflows();
                List <Security.WorkflowReference>           editableWf   = user.GetEditableWorkflows();

                if (computableWf.Count == 0 && editableWf.Count == 0)
                {
                    result = "You didn't create or publish any form.";
                }
                else
                {
                    if (computableWf.Count == 0)
                    {
                        result += "You didn't publish any form";
                    }
                    else
                    {
                        int i = 0;
                        foreach (Security.ComputableWorkflowReference w in computableWf)
                        {
                            result += w.GetWorkflowName() + "\\|)//" + w.GetWorkflowDescription() + "\\|)//" + i + "\\|)//" + w.GetWorkflowExpirationDate().ToString("d") + "\\|//";
                            i++;
                        }
                    }

                    result += "\\||//";

                    if (editableWf.Count == 0)
                    {
                        result += "You didn't create any models";
                    }
                    else
                    {
                        int i = 0;
                        foreach (Security.WorkflowReference w in editableWf)
                        {
                            result += w.GetWorkflowName() + "\\|)//" + w.GetWorkflowDescription() + "\\|)//" + i + "\\|//";
                            i++;
                        }
                    }
                    Page.Session["ComputableWorkflowReferenceList"] = computableWf;
                    Page.Session["WorkflowReferenceList"]           = editableWf;
                }
            }
            else
            {
                result = "You haven't authenticated yet.";
            }
        }
Ejemplo n.º 5
0
        public void RaiseCallbackEvent(string eventArgument)
        {
            Security.Contact        tempcontact;
            string                  newgroupname = "";
            List <Security.Contact> contacts     = new List <Security.Contact>();

            Security.Token tok = (Security.Token)Page.Session["Token"];
            Dictionary <string, string> services = (Dictionary <string, string>)Page.Session["services"];

            if (tok != null && tok.Authenticated && tok.GetCurrentUser().Registered)
            {
                Security.User user = tok.GetCurrentUser();

                if (user.Registered)
                {
                    string contactsadded = "";
                    if (eventArgument != null && !eventArgument.Equals(""))
                    {
                        string[] args = eventArgument.Split('β');
                        string[] argcontact;

                        newgroupname = args[0];

                        if (args.Length > 1)
                        {
                            for (int i = 1; i < args.Length; i++)
                            {
                                argcontact     = args[i].Split('γ');
                                contactsadded += "β" + args[i];
                                string servicename = services[argcontact[2]];
                                tempcontact = new Security.Contact(argcontact[0], argcontact[1], new Security.Service(servicename, Convert.ToInt32(argcontact[2])));
                                contacts.Add(tempcontact);
                            }

                            if (user.CreateGroup(newgroupname, contacts))
                            {
                                result = "trueβ" + newgroupname + contactsadded;
                            }
                        }
                        else
                        if (user.CreateGroup(newgroupname))
                        {
                            result = "trueβ" + newgroupname;
                        }
                    }
                }
                else
                {
                    result = "unrβ";
                }
            }
        }
Ejemplo n.º 6
0
        public void RaiseCallbackEvent(string eventArgument)
        {
            Security.Token tok = (Security.Token)Page.Session["Token"];
            if (tok != null && tok.Authenticated && tok.GetCurrentUser().Registered)
            {
                List <Security.ComputableWorkflowReference> computableWf = Page.Session["ComputableWorkflowReferenceList"] as List <Security.ComputableWorkflowReference>;

                Security.ComputableWorkflowReference reference = computableWf[Int32.Parse(eventArgument)];
                if (reference != null)
                {
                    XmlDocument xmlDoc = reference.GetWorkflow().GetXMLDocument();
                    if (xmlDoc.GetElementsByTagName("TEXT").Count > 0 || xmlDoc.GetElementsByTagName("IMAGE").Count > 0 || xmlDoc.GetElementsByTagName("HTMLCODE").Count > 0)
                    {
                        Page.Session["UsingStaticFields"] = true;
                    }
                    else
                    {
                        Page.Session["UsingStaticFields"] = false;
                    }

                    Page.Session["WFE_CurrentWorkflow"] = reference;
                    Page.Session["themeReturn"]         = "http://" + Security.EnvironmentManagement.getEnvValue("webServerAddress") + "/FormFillier/index.aspx";
                    result = "OK";
                }
                else
                {
                    result = "Not found";
                }
            }
            else
            {
                result = "User not logged in";
            }
        }
Ejemplo n.º 7
0
        protected override void OnInit(EventArgs e)
        {
            Security.Token tok = (Security.Token)Session["Token"];

            base.OnInit(e);

            if (!Page.IsPostBack)
            {
                if (tok != null && tok.Authenticated)
                {
                    user            = (Security.User)tok.GetCurrentUser();
                    Session["user"] = user;

                    if (user.Registered)
                    {
                        services = new Dictionary <string, string>();
                        foreach (Security.Service service in user.GetSubscribedServices())
                        {
                            services.Add(Convert.ToString(service.ServiceId), service.ServiceName);
                        }
                        Session["services"] = services;
                    }
                }
            }
            else
            {
                user     = Session["user"] as Security.User;
                services = Session["services"] as Dictionary <string, string>;
            }
        }
Ejemplo n.º 8
0
        public void RaiseCallbackEvent(string eventArgument)
        {
            Security.Token tok = (Security.Token)Page.Session["Token"];
            if (tok != null && tok.Authenticated && tok.GetCurrentUser().Registered)
            {
                List <Security.ComputableWorkflowReference> computableWf = Page.Session["ComputableWorkflowReferenceList"] as List <Security.ComputableWorkflowReference>;

                Security.ComputableWorkflowReference reference = computableWf[Int32.Parse(eventArgument)];
                if (reference != null)
                {
                    if (reference.Remove())
                    {
                        result = "OK";
                    }
                    else
                    {
                        result = "Error";
                    }
                }
                else
                {
                    result = "Not found";
                }
            }
            else
            {
                result = "User not logged in";
            }
        }
Ejemplo n.º 9
0
        public void RaiseCallbackEvent(string eventArgument)
        {
            Security.Token tok = (Security.Token)Page.Session["Token"];
            if (tok != null && tok.Authenticated)
            {
                Security.User user = tok.GetCurrentUser();

                if (user.Registered)
                {
                    string[] args = eventArgument.Split('β');

                    if (args != null)
                    {
                        if (user.RemoveGroup(args[0], Convert.ToBoolean(args[1])))
                        {
                            result = "trueβ" + args[1] + "β" + args[0];
                        }
                    }
                }
                else
                {
                    result = "unrβ";
                }
            }
        }
Ejemplo n.º 10
0
        public void RaiseCallbackEvent(string eventArgument)
        {
            Security.Token tok = (Security.Token)Page.Session["Token"];
            if (tok != null && tok.Authenticated && tok.GetCurrentUser().Registered)
            {
                List <Security.WorkflowReference> editableWf = Page.Session["WorkflowReferenceList"] as List <Security.WorkflowReference>;
                Security.WorkflowReference        model      = editableWf[Int32.Parse(eventArgument)];
                if (model != null)
                {
                    //TOCHANGE: now can edit only ONE workflow >>>>>alla volta<<<<< LOL
                    string wfID = "workflow_1"; //model.GetWorkflowName();
                    result = "OK&" + wfID;
                    Workflow wf = model.GetWorkflow();
                    Page.Session[wfID] = wf;

                    //To can publish
                    Page.Session["WFE_CurrentWorkflowReference"] = model;

                    //Recovering wf's nodes
                    foreach (WFnode n in wf.GetNodes())
                    {
                        Page.Session[n.Name] = n;
                    }
                }
                else
                {
                    result = "Model" + model.GetWorkflowName() + " not found&";
                }
            }
            else
            {
                result = "User not logged in&";
            }
        }
Ejemplo n.º 11
0
        public void RaiseCallbackEvent(string eventArgument)
        {
            Security.Token          tok       = (Security.Token)Page.Session["Token"];
            List <string>           listgroup = new List <string>();
            List <Security.Contact> contacts  = new List <Security.Contact>();

            if (tok != null && tok.Authenticated && tok.GetCurrentUser().Registered)
            {
                Security.User user = tok.GetCurrentUser();

                if (user.Registered)
                {
                    listgroup = user.GetGroups();
                    if (listgroup != null || listgroup.Count > 0)
                    {
                        result = "true";
                        foreach (string s in listgroup)
                        {
                            result  += "α" + s;
                            contacts = user.GetContactsByGroup(s);
                            foreach (Security.Contact con in contacts)
                            {
                                result += "β" + con.Name + "γ" + con.Email + "γ" + con.Service.ServiceId;
                            }
                        }
                        if (result.Equals("trueαOtherContacts"))
                        {
                            result = "falseα";
                        }
                    }
                    else
                    {
                        result = "falseα";
                    }
                }
                else
                {
                    result = "unrα";
                }
            }
        }
Ejemplo n.º 12
0
        public void RaiseCallbackEvent(string eventArgument)
        {
            string ingroupname  = "";
            string outgroupname = "";
            List <Security.Contact> contacts = new List <Security.Contact>();

            Security.Contact            tempcontact;
            Security.Token              tok      = (Security.Token)Page.Session["Token"];
            Dictionary <string, string> services = (Dictionary <string, string>)Page.Session["services"];
            string groupandcontacts = "";

            if (tok != null && tok.Authenticated)
            {
                Security.User user = tok.GetCurrentUser();

                if (user.Registered)
                {
                    if (eventArgument != null && !eventArgument.Equals(""))
                    {
                        string[] args = eventArgument.Split('β');
                        string[] argcontact;

                        if (args.Length > 2)
                        {
                            ingroupname  = args[0];
                            outgroupname = args[1];

                            groupandcontacts = "β" + ingroupname + "β" + outgroupname;

                            for (int i = 2; i < args.Length; i++)
                            {
                                argcontact = args[i].Split('γ');
                                string servicename = services[argcontact[2]];
                                tempcontact = new Security.Contact(argcontact[0], argcontact[1], new Security.Service(servicename, Convert.ToInt32(argcontact[2])));
                                contacts.Add(tempcontact);
                                groupandcontacts += "β" + args[i];
                            }

                            if (user.MoveContacts(outgroupname, ingroupname, contacts))
                            {
                                result = "true" + groupandcontacts;
                            }
                        }
                    }
                }
                else
                {
                    result = "unrβ";
                }
            }
        }
Ejemplo n.º 13
0
        public void RaiseCallbackEvent(string eventArgument)
        {
            result = "";
            Security.Token tok = (Security.Token)Page.Session["Token"];
            if (tok != null && tok.Authenticated && tok.GetCurrentUser().Registered)
            {
                List <Security.WorkflowReference> editableWf = Page.Session["WorkflowReferenceList"] as List <Security.WorkflowReference>;
                Security.WorkflowReference        model      = editableWf[Int32.Parse(eventArgument)];
                if (model != null)
                {
                    //TOCHANGE: now can edit only ONE workflow alla volta
                    string wfID = "workflow_1"; //model.GetWorkflowName();
                    result = wfID;

                    Workflow wf = model.GetWorkflow();
                    Page.Session[wfID] = wf;

                    //To can publish
                    Page.Session["WFE_CurrentWorkflowReference"] = model;

                    //Recovering wf's nodes
                    int i = 1;
                    foreach (WFnode n in wf.GetNodes())
                    {
                        Page.Session[wfID + "_node_" + i++] = n;
                    }
                }
                else
                {
                    result = "Model" + model.GetWorkflowName() + " not found";
                }
            }
            else
            {
                result = "User not logged in";
            }
            result = result + "\\//";
            List <Security.Service> service_list = Security.ExternalService.List();
            int count = 0;

            foreach (Security.Service s in service_list)
            {
                result += s.ServiceName + "\\|//" + s.ServiceId;
                count++;
                if (count < service_list.Count)
                {
                    result += "\\||//";
                }
            }
        }
Ejemplo n.º 14
0
        protected void okButt_Click(object sender, EventArgs e)
        {
            if (chkTandCs.Checked)
            {
                Security.Token tok = (Security.Token)Session["Token"];
                if (tok != null)
                {
                    Security.User user = tok.GetCurrentUser();
                    string        errorReg;
                    Security.User.RegisterMeResult registration = user.RegisterMe(TextBoxNick.Text, TextBoxMail.Text, out errorReg);

                    if (registration == Security.User.RegisterMeResult.OK)
                    {
                        Session["LoginPhase"]   = null;
                        Session["LoginService"] = null;
                        string url = "";
                        if (string.IsNullOrEmpty((string)Session["OriginalURL"]))
                        {
                            url = (string)Session["ReturnURL"];
                        }
                        else
                        {
                            url = (string)Session["OriginalURL"];
                        }
                        Session["OriginalURL"] = null;
                        if (string.IsNullOrEmpty(url))
                        {
                            url = "http://" + Security.EnvironmentManagement.getEnvValue("webServerAddress") + "/FormFillier/index.aspx";
                        }
                        Response.Redirect(url);
                    }
                    else
                    {
                        //Gestisci no reg
                        Page.Controls.Add(new LiteralControl("<script>alert('" + errorReg + "');</script>"));
                    }
                }
                else
                {
                    //Gestione errore token
                }
            }
            else
            {
                //check non marcata
                Page.Controls.Add(new LiteralControl("<script>alert('Accept term & condition before submitting');</script>"));
            }
        }
Ejemplo n.º 15
0
        public void RaiseCallbackEvent(string eventArgument)
        {
            string[]       array = eventArgument.Split('|');
            Security.Token tok   = (Security.Token)Page.Session["Token"];
            Security.User  usr   = tok.GetCurrentUser();
            Security.ComputableWorkflowReference wf = null;
            if (array[0].Equals("-200"))
            {
                wf = (Security.ComputableWorkflowReference)Page.Session["WFE_CurrentWorkflow"];
            }
            else
            {
                wf = ((List <Security.ComputableWorkflowReference>)Page.Session["ComputableWorkflowReferenceList"])[Int32.Parse(array[0])];
            }
            string gruppo = "";
            List <Security.Contact> contUsr = new List <Security.Contact>();
            bool flag = false;
            List <Security.Contact> contSend = new List <Security.Contact>();

            string[] array2 = merge(array).ToArray();
            for (int i = 1; i < array2.Length - 1; i++)
            {
                string[] grp = array2[i].Split('/');

                if (grp[1] != gruppo)
                {
                    if (i > 1)
                    {
                        flag = flag || wf.PermitContacts(contSend);
                    }
                    gruppo   = grp[1];
                    contUsr  = usr.GetContactsByGroup(gruppo);
                    contSend = new List <Security.Contact>();
                }

                contSend.Add(contUsr[Int32.Parse(grp[0])]);
            }
            flag = flag || wf.PermitContacts(contSend);
            if (flag)
            {
                result = "OK";
            }
            else
            {
                result = "ERROR";
            }
        }
Ejemplo n.º 16
0
        public void RaiseCallbackEvent(string eventArgument)
        {
            Security.Token tok    = (Security.Token)Page.Session["Token"];
            Security.User  usr    = tok.GetCurrentUser();
            List <string>  gruppi = usr.GetGroups();

            if (gruppi.Count == 0)
            {
                result = "You did not create any group of contacts";
            }
            else
            {
                result = eventArgument;
                foreach (string gruppo in gruppi)
                {
                    result += "\\|/" + gruppo;
                }
            }
        }
Ejemplo n.º 17
0
        public void RaiseCallbackEvent(string eventArgument)
        {
            List <Security.Contact> contacts = new List <Security.Contact>();

            Security.Token tok = (Security.Token)Page.Session["Token"];
            if (tok != null && tok.Authenticated)
            {
                Security.User user = tok.GetCurrentUser();

                if (user.Registered)
                {
                    if (eventArgument != null && !eventArgument.Equals(""))
                    {
                        foreach (Security.Service serv in user.GetSubscribedServices())
                        {
                            if (eventArgument.Equals(serv.ServiceName))
                            {
                                contacts = user.ImportContacts(serv.ServiceId);
                                result   = "true";
                                break;
                            }
                        }
                    }

                    if (contacts != null && contacts.Count > 0)
                    {
                        foreach (Security.Contact contact in contacts)
                        {
                            result += "β" + contact.Name + "γ" + contact.Email + "γ" + contact.Service.ServiceId;
                        }
                    }
                    else
                    {
                        result = "false";
                    }
                }
                else
                {
                    result = "unr";
                }
            }
        }
Ejemplo n.º 18
0
        public void RaiseCallbackEvent(string eventArgument)
        {
            Security.Token tok = (Security.Token)Page.Session["Token"];
            if (tok != null && tok.Authenticated)
            {
                Security.User user = tok.GetCurrentUser();

                if (user.Registered)
                {
                    string[] args = eventArgument.Split('β');

                    if (args != null)
                    {
                        if (user.ModifyGroupName(args[0], args[1]))
                        {
                            result = "trueβ" + args[0] + "β" + args[1];
                        }
                    }
                }
            }
        }
Ejemplo n.º 19
0
        public void RaiseCallbackEvent(string eventArgument)
        {
            result = "";
            try
            {
                Security.Token tok = (Security.Token)Page.Session["Token"];
                Security.User  usr = tok.GetCurrentUser();
                List <Security.FilledWorkflowReference> list = usr.GetCompiledForms();

                Security.FilledWorkflowReference work = list[Int32.Parse(eventArgument)];
                XmlSchemaSet bh = work.GetWorkflow().GetCollectedDocumentSchemas();

                XmlSchema schemaTemp = new XmlSchema();

                foreach (XmlSchemaObject tp in bh.GlobalAttributes.Values)
                {
                    schemaTemp.Items.Add(tp);
                }
                foreach (XmlSchemaObject s in bh.GlobalElements.Values)
                {
                    schemaTemp.Items.Add(s);
                }
                foreach (XmlSchemaObject tp in bh.GlobalTypes.Values)
                {
                    schemaTemp.Items.Add(tp);
                }

                string schemaContent = Utils.WriteSchema(schemaTemp);
                List <Storage.StorageManager.Pair <Security.Contact, XmlDocument> > doc2 = work.getFilledDocument();

                XmlDocument    finaldoc  = new XmlDocument();
                XmlDeclaration dec       = finaldoc.CreateXmlDeclaration("1.0", "utf-8", null);
                XmlNode        firstNode = finaldoc.CreateElement("ExportResults");
                finaldoc.InsertBefore(dec, finaldoc.DocumentElement);
                finaldoc.AppendChild(firstNode);
                XmlNode schema = finaldoc.CreateElement("Schema");

                XmlDocument fi = new XmlDocument();
                fi.LoadXml(schemaContent);
                fi.RemoveChild(fi.FirstChild);

                schema.InnerXml = fi.FirstChild.InnerXml;

                firstNode.AppendChild(schema);
                XmlNode data = finaldoc.CreateElement("Data");
                firstNode.AppendChild(data);
                int i = 0;

                string url = HttpContext.Current.Request.PhysicalApplicationPath + "FormFillier\\result.xml";
                foreach (Storage.StorageManager.Pair <Security.Contact, XmlDocument> coppia in doc2)
                {
                    i++;
                    Security.Contact c = coppia.First;
                    if (c != null)
                    {
                        XmlNode compiler = finaldoc.CreateElement("Compiler");
                        XmlNode mail     = finaldoc.CreateElement("Mail");
                        XmlNode name     = finaldoc.CreateElement("Name");
                        mail.InnerText = c.Email;
                        name.InnerText = c.Name;
                        compiler.AppendChild(name);
                        compiler.AppendChild(mail);
                        data.AppendChild(compiler);
                    }

                    XmlDocument doc      = coppia.Second;
                    XmlNode     nodeData = doc.DocumentElement;
                    data.AppendChild(finaldoc.ImportNode(nodeData, true));
                }

                Page.Session["resultXml"] = finaldoc;
            }
            catch (Exception e)
            {
                result = "no";
            }
        }
Ejemplo n.º 20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            #region Callback function registration

            listControl = new List <Control>();
            listControl.Add(new WorkflowRetrieve());
            listControl.Add(new ContactsRetrieve());
            listControl.Add(new UserWorkflowSend());
            listControl.Add(new WorkflowSelection());
            listControl.Add(new PublicWFRetrieve());
            listControl.Add(new GroupSelectionToSend());
            listControl.Add(new ResultRetrieve());
            listControl.Add(new ExportResult());
            listControl.Add(new EditModel());
            listControl.Add(new EditTheme());
            listControl.Add(new CommInformation());
            listControl.Add(new ServiceFieldRetrieve());
            listControl.Add(new IdMOdelAuthServiceRetrieve());
            listControl.Add(new PublishWf());
            listControl.Add(new CommInformationPW());
            listControl.Add(new ServiceFieldPWRetrieve());
            listControl.Add(new CreateUriPW());
            listControl.Add(new CreateUri());
            listControl.Add(new RemovePublication());
            listControl.Add(new RemoveModel());
            listControl.Add(new Logout());

            String cbReference;
            String callbackScript;

            List <Control> .Enumerator it = listControl.GetEnumerator();
            while (it.MoveNext())
            {
                call.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);
            }

            #endregion

            string         reg = Request.Params.Get("reg");
            Security.Token tok = (Security.Token)Session["Token"];

            if (reg != null)
            {
                if (tok != null)
                {
                    if (!tok.GetCurrentUser().Registered)
                    {
                        string url = "http://" + Security.EnvironmentManagement.getEnvValue("webServerAddress") + Request.Url.PathAndQuery;//.AbsolutePath;

                        Session["ReturnURL"] = url;
                        Response.Redirect("http://" + Security.EnvironmentManagement.getEnvValue("webServerAddress") + "/FormFillier/Registration.aspx");
                    }
                }
                else
                {
                    Response.Redirect("http://" + Security.EnvironmentManagement.getEnvValue("webServerAddress") + "/FormFillier/index.aspx");
                }
            }


            if (!IsPostBack)
            {
                List <Security.Service> listTemp = new List <Security.Service>();
                if (tok != null && tok.Authenticated)
                {
                    Security.User user = tok.GetCurrentUser();
                    listTemp = user.LoggedServices;
                }
                List <Security.Service> listaServizi = Security.ExternalService.List();

                foreach (Security.Service s in listaServizi)
                {
                    ServiceList.Items.Add(s.ServiceName);
                }
                foreach (Security.Service s in listTemp)
                {
                    ServiceList.Items.Remove(s.ServiceName);
                }
            }

            if (tok != null && tok.Authenticated)
            {
                Security.User user = tok.GetCurrentUser();

                // if (user.Registered)
                //{
                labelUser.Text = "Welcome, " + user.GetNickname();
                if (ServiceList.Items.Count != 0)
                {
                    LoginService.ImageUrl = "~/lib/image/AddLogin.png";
                    LoginService.ToolTip  = "Add Login";
                    LoginService.Style.Add("margin-top", "-2px");
                }
                else if (ServiceList.Items.Count == 0)
                {
                    LoginService.Visible = false;
                }
                Logout.Visible         = true;
                ManageContacts.Visible = true;
                //ManageFiles.Visible = true;
                //}
                //else
                //{
                // labelUser.Text = "Welcome, " + user.ToString();
                //}
            }
            else
            {
                Logout.Visible         = false;
                ManageContacts.Visible = false;
                labelUser.Visible      = false;
            }

            //Login error management
            if (Session["LoginError"] != null)
            {
                string message   = (string)Session["LoginError"];
                string returnUrl = (string)Session["ReturnUrl"];
                String script    = "ShowLoginError(\" " + message + " \", \" " + returnUrl + " \");";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "LoginErrorScript", script, true);
                Session["LoginError"] = null;
            }
        }
Ejemplo n.º 21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Security.Token tok = (Security.Token)Session["Token"];

            //if (!IsPostBack)
            //{

            if (tok != null)
            {
                Security.User user = tok.GetCurrentUser();
                if (user.Registered)
                {
                    TextBoxNick.Text    = user.GetNickname();
                    TextBoxMail.Text    = user.GetEmail();
                    TextBoxNick.Enabled = false;
                    TextBoxMail.Enabled = false;
                }
                List <Security.Service> listaServizi = Security.ExternalService.List();

                List <Security.Service> listaServiziUsati = user.LoggedServices;

                if (listaServiziUsati.Count > 0)
                {
                    chkTandCs.Enabled = true;
                    //valTandCs.Enabled = true;
                    foreach (Security.Service s in listaServizi)
                    {
                        DropDownList1.Items.Add(s.ServiceName);
                        foreach (Security.Service su in listaServiziUsati)
                        {
                            if (su.ServiceName == s.ServiceName)
                            {
                                Session["ServiceID"] = s.ServiceId;

                                Label lab = new Label();
                                lab.Text = s.ServiceName;
                                Panel p = new Panel();

                                p.Controls.Add(lab);
                                PanelServReg.Controls.Add(p);
                                PanelServReg.Style.Add("margin-left", "40px");
                                DropDownList1.Items.Remove(s.ServiceName);
                            }
                        }
                    }
                }
                //else
                if (listaServiziUsati.Count == listaServizi.Count)
                {
                    DropDownList1.Visible = false;
                    register.Visible      = false;
                }
                //else
                //{
                //    foreach (Security.Service s in listaServizi)
                //    {
                //        DropDownList1.Items.Add(s.ServiceName);
                //    }
                //}
            }
            else
            {
                List <Security.Service> listaServizi = Security.ExternalService.List();
                foreach (Security.Service s in listaServizi)
                {
                    DropDownList1.Items.Add(s.ServiceName);
                }
            }
            if (!IsPostBack)
            {
                TextBoxNick.Text = ((string)Session["Nick"] != null) ? (string)Session["Nick"] : "";
                TextBoxMail.Text = ((string)Session["Mail"] != null) ? (string)Session["Mail"] : "";
            }
            //}else{}
        }