public List<JsonModels.Activity> GetUserActivity(int userId)
 {
     try
     {
         List<Activity> aList = activityAccessor.GetUserActivity(userId);
         List<JsonModels.Activity> jsonActivityList = new List<JsonModels.Activity>();
         foreach (Activity a in aList)
         {
             if (a != null)
             {
                 JsonModels.Activity jsonActivity = new JsonModels.Activity();
                 jsonActivity.action = a.action;
                 jsonActivity.id = a.id;
                 jsonActivity.referenceId = a.referenceId;
                 jsonActivity.timeStamp = a.timeStamp.ToString();
                 jsonActivity.type = a.type;
                 jsonActivity.userId = a.userId;
                 jsonActivityList.Add(jsonActivity);
             }
         }
         return jsonActivityList;
     }
     catch (Exception ex)
     {
         return null;
     }
 }
        public static List<string> getUserURLs()
        {
            List<string> urls = new List<string>();
            UserManager UM = new UserManager();

            foreach (User u in UM.GetAllUsers())
            {
                urls.Add(u.profileURL.ToLower());
            }
            return urls;
        }
        public static List<string> getUserEmails()
        {
            List<string> emails = new List<string>();
            UserManager UM = new UserManager();

            foreach (User u in UM.GetAllUsers())
            {
                emails.Add(u.email.ToLower());
            }
            return emails;
        }
 public ActionResult AutocompleteTags(int limit)
 {
     TagManager tm = new TagManager();
     List<sTag> stags = new List<sTag>();
     stags = tm.GetAllSTags();
     List<string> tags = new List<string>();
     foreach (sTag s in stags)
     {
         tags.Add(s.value);
     }
     return Json(tags, JsonRequestBehavior.AllowGet);
 }
        public ActionResult ErrorView()
        {
            List<Log> logs = new List<Log>();
            List<int> ids = new List<int>();
            List<DateTime> eventTimes = new List<DateTime>();
            List<string> locations = new List<string>();
            List<string> exceptions = new List<string>();

            //logs = logAccessor.GetLogs();

            List<ErrorModel> errorModelList = new List<ErrorModel>();

            int i = 0;
            foreach (Log log in logs)
            {
                ErrorModel er = new ErrorModel(log);
                errorModelList.Add(er);
            }

            return View(errorModelList);
        }
        public override void Run()
        {
            PrepareData();

            for (int i = 0; i < threads.Length; ++i)
            {
                threads[i].Start(threadData[i]);
            }

            AutoResetEvent.WaitAll(waitHandles);

            List<RealizationResult> results = new List<RealizationResult>();
            for (int i = 0; i < networks.Length; ++i)
            {
                if (networks[i].SuccessfullyCompleted)
                    results.Add(networks[i].NetworkResult);
            }

            if(results.Count != 0)
                Result = EnsembleResult.AverageResults(results);
        }
Exemple #7
0
        static void Main(string[] args)
        {
            //binaryconverter.binconv(); //only for new files
            List<Strategy> ls = new List<Strategy>(); //list of strategies
            List<finalAllStratLog> ell = new List<finalAllStratLog>(); //list of config final log

            //creates list
            createStrategyToList(ls);

            RunMain(path, ls); // runs methods

            finalAllStratLog editLog = new finalAllStratLog(ls[0].getLength());

            foreach (var strat in ls) // prints log for pos
            {
                if (strat.getList().Count != 0)
                {
                    strat.writePosLogFile(strat.getList(), path);
                }
                else
                {
                    creatErrorInfoLogTxt("No Transactions and Positions for: " + strat.getName() + " Paramaters: " + strat.getParamatersInfo());
                }
                finalAllStratLog logInfo;
                logInfo = strat.editFinalLogData(path, editLog);
                if (logInfo != null)
                    ell.Add(new finalAllStratLog(logInfo));
            }


            foreach (finalAllStratLog e in ell) // prints sum log for all strategy
            {
                printFinalConfigLog(path, ell);
            }

            //add func to create graph img to top 10 (paramater)

            
        } // Main
        public string GetProfile(int id = -1, string profileURL = null, IEnumerable<string> request = null, bool ignoreViewCount = false, string token = null)
        {
            if (Request.RequestType.Equals("OPTIONS", StringComparison.InvariantCultureIgnoreCase))  //This is a preflight request
            {
                return null;
            }
            else
            {

                //authenticate via token
                string returnVal;
                int authenticateId = -1;
                int add = 0;
                try
                {
                    if (token != null)
                    {
                        authenticateId = authenticationEngine.authenticate(token);
                        if (authenticateId < 0)
                        {
                            //Only return PUBLIC projects
                            //retreive user
                            //two lists of networks
                            //networks, admin networks <- list of network where i am an admin
                        }
                    }
                    bool requestAll = false;

                    JsonModels.ProfileInformation ui = new JsonModels.ProfileInformation();
                    User u;
                    Boolean sameUser = false;
                    Boolean adminOrMemberCheck = false;
                    if (id < 0)//???? && profileURL != "" ===>>> this endpoint supports getting by id OR profileURL. if the id is < 0, we must try to retrieve the profileURL
                    {
                        if (profileURL != null)
                        {
                            u = userManager.GetUserByProfileURL(profileURL);
                            if (u == null)
                            {
                                return AddErrorHeader("A user with the specified profileURL was not found", 1);
                            }
                            id = u.id;
                            if (id != authenticateId)//check to see if the authenticated user is an admin of the requested user's networks
                            {
                                User authenticatedUser = userManager.GetUser(authenticateId);
                                if (authenticatedUser == null)
                                {
                                    //This means somebody is attempting to hit the profile PUBLICLY, without a token
                                    if (u.isPublic == 0)
                                    {
                                        return AddErrorHeader("Not Authorized", 3);
                                    }
                                    //TODO
                                    //whatever setting needs to happen so that only public projects are returned
                                }
                                else
                                {
                                    List<int> authenticatedUserAdminandNetworkIds = new List<int>();
                                    List<int> requestedUserNetworkIds = new List<int>();
                                    foreach (Network n in u.networks)
                                    {
                                        requestedUserNetworkIds.Add(n.id);
                                    }
                                    foreach (Network n in authenticatedUser.adminNetworks)
                                    {
                                        authenticatedUserAdminandNetworkIds.Add(n.id);
                                    }
                                    foreach (Network n in authenticatedUser.networks)
                                    {
                                        authenticatedUserAdminandNetworkIds.Add(n.id);
                                    }
                                    foreach (int i in authenticatedUserAdminandNetworkIds)
                                    {
                                        foreach (int n in requestedUserNetworkIds)
                                        {
                                            if (i == n)
                                            {
                                                adminOrMemberCheck = true;
                                                break;
                                            }
                                        }
                                    }
                                    if (u.isPublic == 0 && !adminOrMemberCheck)
                                    {
                                        return AddErrorHeader("Not Authorized", 3);
                                    }
                                }
                            }
                            else
                            {
                                sameUser = true;
                            }

                            if (id == authenticateId)
                            {
                                if (request == null)
                                {
                                    requestAll = true;
                                }
                                else
                                {
                                    //requestAll is false still
                                }
                            }
                            else
                            {
                                if (request == null)
                                {
                                    requestAll = true;
                                    if (!ignoreViewCount)
                                    {
                                        u.profileViews++;
                                        userManager.UpdateUser(u);
                                    }
                                }
                            }
                        }
                        else
                        {
                            return AddErrorHeader("An id or profileURL must be specified", 1);
                        }
                    }
                    else
                    {
                        u = userManager.GetUser(id);
                        if (u == null)
                        {
                            return AddErrorHeader("A user with the specified id was not found", 1);
                        }
                        if (id != authenticateId)//check to see if the authenticated user is an admin of the requested user's networks
                        {
                            User authenticatedUser = userManager.GetUser(authenticateId);
                            if (authenticatedUser == null)
                            {
                                if (u.isPublic == 0)
                                {
                                    return AddErrorHeader("Not Authorized", 3);
                                }
                                //whatever setting needs to happen so that only public projects are returned
                            }
                            else
                            {
                                List<int> authenticatedUserAdminandNetworkIds = new List<int>();
                                List<int> requestedUserNetworkIds = new List<int>();
                                foreach (Network n in u.networks)
                                {
                                    requestedUserNetworkIds.Add(n.id);
                                }
                                foreach (Network n in authenticatedUser.adminNetworks)
                                {
                                    authenticatedUserAdminandNetworkIds.Add(n.id);
                                }
                                foreach (Network n in authenticatedUser.networks)
                                {
                                    authenticatedUserAdminandNetworkIds.Add(n.id);
                                }
                                foreach (int i in authenticatedUserAdminandNetworkIds)
                                {
                                    foreach (int n in requestedUserNetworkIds)
                                    {
                                        if (i == n)
                                        {
                                            adminOrMemberCheck = true;
                                            break;
                                        }
                                    }
                                }
                                if (u.isPublic == 0 && !adminOrMemberCheck)
                                {
                                    return AddErrorHeader("Not Authorized", 3);
                                }
                            }
                        }
                        else
                        {
                            sameUser = true;
                        }
                        if (id == authenticateId)
                        {
                            if (request == null)
                            {
                                requestAll = true;
                            }
                            else
                            {
                                //requestAll is still false
                            }
                        }
                        else
                        {
                            if (request == null)
                            {
                                requestAll = true;
                                if (!ignoreViewCount)
                                {
                                    u.profileViews++;
                                    userManager.UpdateUser(u);
                                }
                            }
                        }
                    }

                    //END OF DETECTING SETTINGS
                    List<string> projectPrivacyPrivledge = new List<string>();
                    projectPrivacyPrivledge.Add("public");
                    if (sameUser)
                    {
                        projectPrivacyPrivledge.Add("network");
                        projectPrivacyPrivledge.Add("private");
                    }
                    else if (adminOrMemberCheck)
                    {
                        projectPrivacyPrivledge.Add("network");
                    }

                    if (u != null)
                    {
                        add = 0;
                        if (requestAll || request.Contains("firstName"))
                        {
                            if (u.firstName != null)
                            {
                                ui.firstName = u.firstName;
                                add = 1;
                            }
                            else
                            {
                                ui.firstName = null;
                            }
                        }
                        if (requestAll || request.Contains("lastName"))
                        {
                            if (u.lastName != null)
                            {
                                ui.lastName = u.lastName;
                                add = 1;
                            }
                            else
                            {
                                ui.lastName = null;
                            }
                        }
                        if (requestAll || request.Contains("phoneNumber"))
                        {
                            if (u.phoneNumber != null)
                            {
                                ui.phoneNumber = u.phoneNumber;
                                add = 1;
                            }
                        }
                        if (requestAll || request.Contains("tagLine"))
                        {
                            if (u.tagLine != null)
                            {
                                ui.tagLine = u.tagLine;
                                add = 1;
                            }
                            else
                            {
                                ui.tagLine = null;
                            }
                        }
                        if (requestAll || request.Contains("email"))
                        {
                            if (u.email != null)
                            {
                                ui.email = u.email;
                                add = 1;
                            }
                            else
                            {
                                ui.email = null;
                            }
                        }
                        if (requestAll || request.Contains("location"))
                        {
                            if (u.location != null)
                            {
                                ui.location = u.location;
                                add = 1;
                            }
                            else
                            {
                                ui.location = null;
                            }
                        }
                        if (requestAll || request.Contains("title"))
                        {
                            if (u.title != null)
                            {
                                ui.title = u.title;
                                add = 1;
                            }
                            else
                            {
                                ui.title = null;
                            }
                        }
                        if (requestAll || request.Contains("organization"))
                        {
                            if (u.organization != null)
                            {
                                ui.organization = u.organization;
                                add = 1;
                            }
                            else
                            {
                                ui.organization = null;
                            }
                        }
                        if (requestAll || request.Contains("major"))
                        {
                            if (u.major != null)
                            {
                                ui.major = u.major;
                                add = 1;
                            }
                            else
                            {
                                ui.major = null;
                            }
                        }
                        if (requestAll || request.Contains("description"))
                        {
                            if (u.description != null)
                            {
                                ui.description = u.description;
                                add = 1;
                            }
                            else
                            {
                                ui.description = null;
                            }
                        }
                        if (requestAll || request.Contains("resume"))
                        {
                            if (u.resume != null)
                            {
                                ui.resume = u.resume;
                                add = 1;
                            }
                            else
                            {
                                ui.resume = null;
                            }
                        }
                        if (requestAll || request.Contains("projectOrder"))
                        {
                            if (u.projectOrder != null)
                            {
                                ui.projectOrder = u.projectOrder;
                                add = 1;
                            }
                            else
                            {
                                ui.projectOrder = null;
                            }
                        }
                        if (requestAll || request.Contains("profilePicture"))
                        {
                            if (u.profilePicture != null)
                            {
                                ui.profilePicture = u.profilePicture;
                                add = 1;
                            }
                            else
                            {
                                ui.profilePicture = null;
                            }
                        }
                        if (requestAll || request.Contains("profilePictureThumbnail"))
                        {
                            if (u.profilePictureThumbnail != null)
                            {
                                ui.profilePictureThumbnail = u.profilePictureThumbnail;
                                add = 1;
                            }
                            else
                            {
                                ui.profilePictureThumbnail = null;
                            }
                        }
                        //TODO actually calculate the stats
                        if (requestAll || request.Contains("stats"))
                        {
                            JsonModels.UserStats stats = userManager.getUserStats(id);
                            if (stats != null)
                            {
                                ui.stats = stats;
                                add = 1;
                            }
                            else
                            {
                                ui.stats = null;
                            }
                        }
                        if (requestAll || request.Contains("links"))
                        {
                            ui.facebookLink = u.facebookLink;
                            ui.twitterLink = u.twitterLink;
                            ui.linkedinLink = u.linkedinLink;
                        }
                        if (requestAll || request.Contains("experiences"))
                        {
                            List<JsonModels.Experience> experiences = userManager.GetUserExperiences(id);
                            if (experiences != null && experiences.Count != 0)
                            {
                                ui.experiences = experiences;
                                add = 1;
                            }
                            else
                            {
                                ui.experiences = null;
                            }
                        }
                        if (requestAll || request.Contains("references"))
                        {
                            List<JsonModels.Reference> references = userManager.GetUserReferences(id);
                            if (references != null && references.Count != 0)
                            {
                                ui.references = references;
                                add = 1;
                            }
                            else
                            {
                                ui.references = null;
                            }
                        }
                        if (requestAll || request.Contains("tags"))
                        {
                            List<JsonModels.UserTag> tags = userManager.GetUserTags(id);
                            if (tags != null && tags.Count != 0)
                            {
                                ui.tags = tags;
                                add = 1;
                            }
                            else
                            {
                                ui.tags = null;
                            }
                        }
                        if (requestAll || request.Contains("projects"))
                        {
                            int[] projectIds = new int[u.projects.Count];
                            int count = 0;
                            foreach (Project p in u.projects)
                            {
                                projectIds[count] = p.id;
                                count++;
                            }
                            List<JsonModels.CompleteProject> projects = projectManager.GetCompleteProjects(projectIds, projectPrivacyPrivledge);
                            if (projects != null && projects.Count != 0)
                            {
                                ui.projects = projects;
                                add = 1;
                            }
                            else
                            {
                                ui.projects = null;
                            }
                        }
                        if (requestAll || request.Contains("profileViews"))
                        {
                            ui.profileViews = u.profileViews;
                        }
                        if (requestAll || request.Contains("activity"))
                        {
                            List<JsonModels.Activity> activity = activityManager.GetUserActivity(id);
                            ui.activity = activity;
                        }
                        //if (requestAll || request.Contains("profileScore"))
                        //{
                        //    ui.profileScore = userManager.GetProfileScore(u);
                        //}
                        ui.id = u.id.ToString();
                    }
                    try
                    {
                        returnVal = Serialize(ui);
                    }
                    catch (Exception ex)
                    {
                        logAccessor.CreateLog(DateTime.Now, this.GetType().ToString() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString(), ex.ToString());
                        return AddErrorHeader(ex.Message, 1);
                    }
                }
                catch (Exception ex)
                {
                    logAccessor.CreateLog(DateTime.Now, this.GetType().ToString() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString(), ex.ToString());
                    return AddErrorHeader("Bad Request", 1);
                }
                return AddSuccessHeader(returnVal);
            }
        }
 public string UpdateProjectOrder(string order, string token)
 {
     Response.AddHeader("Access-Control-Allow-Origin", "*");
     if (Request.RequestType.Equals("OPTIONS", StringComparison.InvariantCultureIgnoreCase))  //This is a preflight request
     {
         Response.AddHeader("Access-Control-Allow-Methods", "POST, PUT");
         Response.AddHeader("Access-Control-Allow-Headers", "X-Requested-With");
         Response.AddHeader("Access-Control-Allow-Headers", "X-Request");
         Response.AddHeader("Access-Control-Allow-Headers", "X-File-Name");
         Response.AddHeader("Access-Control-Allow-Headers", "Content-Type");
         Response.AddHeader("Access-Control-Max-Age", "86400"); //caching this policy for 1 day
         return null;
     }
     else
     {
         try
         {
             int userId = authenticationEngine.authenticate(token);
             if (userId < 0)
             {
                 return AddErrorHeader("You are not authenticated, please log in!", 2);
             }
             User u = userManager.GetUser(userId);
             ReorderEngine re = new ReorderEngine();
             List<int> ListOrder = re.stringOrderToList(order);
             List<int> currentProjectIds = new List<int>();
             bool add = true;
             foreach (Project p in u.projects)
             {
                 currentProjectIds.Add(p.id);
             }
             foreach (int i in ListOrder)
             {
                 if (!currentProjectIds.Contains(i))
                 {
                     add = false;
                 }
             }
             if (add == false)
             {
                 //????????you cant do that
                 return AddErrorHeader("Update Failed.", 1);
             }
             else
             {
                 u.projectOrder = order;
                 u = userManager.UpdateUser(u);
             }
             return AddSuccessHeader("Order updated", true);
         }
         catch (Exception ex)
         {
             logAccessor.CreateLog(DateTime.Now, this.GetType().ToString() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString(), ex.ToString());
             return AddErrorHeader("Something went wrong while updating the Project Order", 1);
         }
     }
 }
        public string GetUserModel(int userId, string token)
        {
            if (Request.RequestType.Equals("OPTIONS", StringComparison.InvariantCultureIgnoreCase))
            {
                return null;
            }
            try
            {
                int authUserId = -1;
                if (token != null)
                {
                    authUserId = authenticationEngine.authenticate(token);
                }
                else
                {
                    return AddErrorHeader("A token must be passed in", 2);
                }
                if (authUserId < 0)
                {
                    return AddErrorHeader("The authenticaiton token is not valid", 2);
                }

                if (authUserId != userId)
                {
                    return AddErrorHeader("User must be profile owner to retrieve the User Model", 1);
                }
                User user = userManager.GetUserWithNetworks(userId);
                if (user != null)
                {
                    NetworkManager networkManager = new NetworkManager();
                    JsonModels.UserInformationModel userInfoJson = new JsonModels.UserInformationModel();
                    JsonModels.UserSettings userSettingsJson = new JsonModels.UserSettings();
                    List<JsonModels.UserNetworkShell> userNetworksJson = new List<JsonModels.UserNetworkShell>();

                    List<Network> topLevelNetworks = new List<Network>();
                    List<Network> subNetworks = new List<Network>();
                    List<Network> groupNetworks = new List<Network>();

                    foreach (Network n in user.networks)
                    {
                        if (n != null)
                        {
                            if (n.GetType().Name.Contains("Network_TopNetwork"))
                            {
                                if (!topLevelNetworks.Contains(n))
                                {
                                    topLevelNetworks.Add(n);
                                }
                            }
                            else if (n.GetType().Name.Contains("Network_SubNetwork"))
                            {
                                if (!subNetworks.Contains(n))
                                {
                                    subNetworks.Add(n);
                                }
                            }
                            else if (n.GetType().Name.Contains("Network_Group"))
                            {
                                if (!groupNetworks.Contains(n))
                                {
                                    groupNetworks.Add(n);
                                }
                            }
                        }
                    }
                    foreach (Network n in user.adminNetworks)
                    {
                        if (n != null)
                        {
                            if (n.GetType().Name.Contains("Network_TopNetwork"))
                            {
                                if (!topLevelNetworks.Contains(n))
                                {
                                    topLevelNetworks.Add(n);
                                }
                            }
                            else if (n.GetType().Name.Contains("Network_SubNetwork"))
                            {
                                if (!subNetworks.Contains(n))
                                {
                                    subNetworks.Add(n);
                                }
                            }
                            else if (n.GetType().Name.Contains("Network_Group"))
                            {
                                if (!groupNetworks.Contains(n))
                                {
                                    groupNetworks.Add(n);
                                }
                            }
                        }
                    }

                    for (int i = 0; i < topLevelNetworks.Count; i++)
                    {
                        Network topNet = topLevelNetworks.ElementAt(i);
                        JsonModels.UserNetworkShell topNetShell = new JsonModels.UserNetworkShell();
                        topNetShell.name = topNet.name;
                        topNetShell.networkId = topNet.id;
                        topNetShell.networkURL = topNet.profileURL;
                        if (user.adminNetworks.Contains(topNet))
                        {
                            topNetShell.userAuthorization = "admin";
                        }
                        else
                        {
                            topNetShell.userAuthorization = "member";
                        }

                        for (int j = 0; j < subNetworks.Count; j++)
                        {
                            Network_SubNetwork subNet = (Network_SubNetwork)subNetworks.ElementAt(j);
                            JsonModels.UserNetworkShell subNetShell = new JsonModels.UserNetworkShell();
                            if (subNet.Network_TopNetwork.id == topNet.id)
                            {
                                subNetShell.name = subNet.name;
                                subNetShell.networkId = subNet.id;
                                subNetShell.networkURL = subNet.profileURL;
                                if (user.adminNetworks.Contains(subNet))
                                {
                                    subNetShell.userAuthorization = "admin";
                                }
                                else
                                {
                                    subNetShell.userAuthorization = "member";
                                }

                                for (int k = 0; k < groupNetworks.Count; k++)
                                {
                                    Network_Group groupNet = (Network_Group)groupNetworks.ElementAt(k);
                                    if (groupNet.Network_SubNetwork.id == subNet.id)
                                    {
                                        JsonModels.UserNetworkShell groupNetShell = new JsonModels.UserNetworkShell();
                                        groupNetShell.name = groupNet.name;
                                        groupNetShell.networkId = groupNet.id;
                                        groupNetShell.networkURL = groupNet.profileURL;
                                        if (user.adminNetworks.Contains(groupNet))
                                        {
                                            groupNetShell.userAuthorization = "admin";
                                        }
                                        else
                                        {
                                            groupNetShell.userAuthorization = "member";
                                        }
                                        if (subNetShell.subnetworks == null)
                                        {
                                            subNetShell.subnetworks = new List<JsonModels.UserNetworkShell>();
                                        }
                                        subNetShell.subnetworks.Add(groupNetShell);
                                    }
                                }
                                if (topNetShell.subnetworks == null)
                                {
                                    topNetShell.subnetworks = new List<JsonModels.UserNetworkShell>();
                                }
                                topNetShell.subnetworks.Add(subNetShell);

                            }
                        }

                        userNetworksJson.Add(topNetShell);

                    }
                    userSettingsJson.email = user.email;
                    userSettingsJson.profileURL = user.profileURL;
                    userSettingsJson.firstName = user.firstName;
                    userSettingsJson.lastName = user.lastName;
                    if(user.isPublic == 1)
                    {
                        userSettingsJson.visibility = "visible";
                    }
                    else
                    {
                        userSettingsJson.visibility = "hidden";
                    }

                    userInfoJson.networks = userNetworksJson;
                    userInfoJson.settings = userSettingsJson;

                    return AddSuccessHeader(Serialize(userInfoJson));
                }
                else
                {
                    return AddErrorHeader("User not found", 1);
                }
            }
            catch (Exception ex)
            {
                logAccessor.CreateLog(DateTime.Now, "UserController - GetUserModel", ex.StackTrace);
                return AddErrorHeader("something went wrong while retrieving this user's info", 1);
            }
        }
 public string GetUserInformation(int id = -1, string profileURL = null, string[] request = null, string token = null)
 {
     Response.AddHeader("Access-Control-Allow-Origin", "*");
     if (Request.RequestType.Equals("OPTIONS", StringComparison.InvariantCultureIgnoreCase))  //This is a preflight request
     {
         Response.AddHeader("Access-Control-Allow-Methods", "POST, PUT");
         Response.AddHeader("Access-Control-Allow-Headers", "X-Requested-With");
         Response.AddHeader("Access-Control-Allow-Headers", "X-Request");
         Response.AddHeader("Access-Control-Allow-Headers", "X-File-Name");
         Response.AddHeader("Access-Control-Allow-Headers", "Content-Type");
         Response.AddHeader("Access-Control-Max-Age", "86400"); //caching this policy for 1 day
         return null;
     }
     else
     {
         //authenticate via token
         string returnVal;
         try
         {
             if (token != null)
             {
                 int authenticate = authenticationEngine.authenticate(token);
                 if (authenticate < 0)
                 {
                     //Response.StatusCode = 500;
                     //return AddErrorHeader("Not Authenticated");
                 }
             }
             bool requestAll = false;
             if (request == null)
             {
                 requestAll = true;
             }
             List<JsonModels.UserInformation> userInformationList = new List<JsonModels.UserInformation>();
             int add = 0;
             User u;
             if (id < 0)
             {
                 if (profileURL != null)
                 {
                     u = userManager.GetUserByProfileURL(profileURL);
                     if (u == null)
                     {
                         return AddErrorHeader("A user with the specified profileURL was not found", 1);
                     }
                     else
                     {
                         id = u.id;
                     }
                 }
                 else
                 {
                     return AddErrorHeader("An id or profileURL must be specified", 1);
                 }
             }
             else
             {
                 u = userManager.GetUser(id);
                 if (u == null)
                 {
                     return AddErrorHeader("A user with the specified id was not found", 1);
                 }
             }
             if (u != null)
             {
                 add = 0;
                 //TODO add company
                 JsonModels.UserInformation ui = new JsonModels.UserInformation();
                 if (requestAll || request.Contains("firstName"))
                 {
                     if (u.firstName != null)
                     {
                         ui.firstName = u.firstName;
                         add = 1;
                     }
                 }
                 if (requestAll || request.Contains("lastName"))
                 {
                     if (u.lastName != null)
                     {
                         ui.lastName = u.lastName;
                         add = 1;
                     }
                 }
                 if (requestAll || request.Contains("connections"))
                 {
                     if (u.connections != null)
                     {
                         ui.connections = u.connections;
                         add = 1;
                     }
                 }
                 if (requestAll || request.Contains("tagLine"))
                 {
                     if (u.tagLine != null)
                     {
                         ui.tagLine = u.tagLine;
                         add = 1;
                     }
                 }
                 if (requestAll || request.Contains("title"))
                 {
                     if (u.title != null)
                     {
                         ui.title = u.title;
                         add = 1;
                     }
                 }
                 if (requestAll || request.Contains("school"))
                 {
                     if (u.organization != null)
                     {
                         ui.school = u.organization;
                         add = 1;
                     }
                 }
                 if (requestAll || request.Contains("description"))
                 {
                     if (u.description != null)
                     {
                         ui.description = u.description;
                         add = 1;
                     }
                 }
                 if (requestAll || request.Contains("resume"))
                 {
                     if (u.resume != null)
                     {
                         ui.resume = u.resume;
                         add = 1;
                     }
                 }
                 if (requestAll || request.Contains("profilePicture"))
                 {
                     if (u.profilePicture != null)
                     {
                         ui.profilePicture = u.profilePicture;
                         add = 1;
                     }
                 }
                 if (requestAll || request.Contains("aboutPicture"))
                 {
                     if (u.aboutPicture != null)
                     {
                         ui.aboutPicture = u.aboutPicture;
                         add = 1;
                     }
                 }
                 if (requestAll || request.Contains("profilePictureThumbnail"))
                 {
                     if (u.profilePictureThumbnail != null)
                     {
                         ui.profilePictureThumbnail = u.profilePictureThumbnail;
                         add = 1;
                     }
                 }
                 if (requestAll || request.Contains("aboutPictureThumbnail"))
                 {
                     if (u.aboutPictureThumbnail != null)
                     {
                         ui.aboutPictureThumbnail = u.aboutPictureThumbnail;
                         add = 1;
                     }
                 }
                 if (requestAll || request.Contains("stats"))
                 {
                     JsonModels.UserStats stats = userManager.getUserStats(id);
                     if (stats != null)
                     {
                         ui.stats = stats;
                         add = 1;
                     }
                 }
                 if (requestAll || request.Contains("links"))
                 {
                     JsonModels.Links links = userManager.getUserLinks(id);
                     if (links != null)
                     {
                         ui.links = links;
                         add = 1;
                     }
                 }
                 if (requestAll || request.Contains("experiences"))
                 {
                     List<JsonModels.Experience> experiences = userManager.GetUserExperiences(id);
                     if (experiences != null && experiences.Count != 0)
                     {
                         ui.experiences = experiences;
                         add = 1;
                     }
                 }
                 if (requestAll || request.Contains("references"))
                 {
                     List<JsonModels.Reference> references = userManager.GetUserReferences(id);
                     if (references != null && references.Count != 0)
                     {
                         ui.references = references;
                         add = 1;
                     }
                 }
                 if (requestAll || request.Contains("tags"))
                 {
                     List<JsonModels.UserTag> tags = userManager.GetUserTags(id);
                     if (tags != null && tags.Count != 0)
                     {
                         ui.tags = tags;
                         add = 1;
                     }
                 }
                 if (requestAll || request.Contains("projects"))
                 {
                     List<JsonModels.ProjectShell> projects = projectManager.GetProjectShells(id);
                     if (projects != null && projects.Count != 0)
                     {
                         ui.projects = projects;
                         add = 1;
                     }
                 }
                 if (requestAll || request.Contains("todo"))
                 {
                     List<JsonModels.Todo> todoList = userManager.GetTodo(id);
                     if (todoList != null && todoList.Count != 0)
                     {
                         ui.todo = todoList;
                         add = 1;
                     }
                 }
                 if (requestAll || request.Contains("recentActivity"))
                 {
                     List<JsonModels.RecentActivity> recentActivity = userManager.GetRecentActivity(id);
                     if (recentActivity != null && recentActivity.Count != 0)
                     {
                         ui.recentActivity = recentActivity;
                         add = 1;
                     }
                 }
                 if (add == 1)
                 {
                     userInformationList.Add(ui);
                 }
             }
             try
             {
                 returnVal = Serialize(userInformationList);
             }
             catch (Exception ex)
             {
                 logAccessor.CreateLog(DateTime.Now, this.GetType().ToString() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString(), ex.ToString());
                 return AddErrorHeader(ex.Message, 1);
             }
         }
         catch (Exception ex)
         {
             logAccessor.CreateLog(DateTime.Now, this.GetType().ToString() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString(), ex.ToString());
             return AddErrorHeader("Bad Request", 1);
         }
         return AddSuccessHeader(returnVal);
     }
 }
Exemple #12
0
 public bool IsUserOwnerOfProject(int projectId, User user)
 {
     List<int> projectIds = new List<int>();
     foreach (Project p in user.projects)
     {
         projectIds.Add(p.id);
     }
     if (projectIds.Contains(projectId))
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Exemple #13
0
        //returns artifacts for documents, pictures, videos, and audio
        public List<JsonModels.Artifact> GetArtifacts(int[] id)
        {
            List<JsonModels.Artifact> artifacts = new List<JsonModels.Artifact>();
            ProjectAccessor pa = new ProjectAccessor();
            int add = 0;
            foreach (int i in id)
            {
                add = 0;
                JsonModels.Artifact a = new JsonModels.Artifact();
                ProjectElement pe = pa.GetProjectElement(i);
                if (pe != null)
                {
                    a.id = pe.id;
                    if (pe.GetType() == typeof(ProjectElement_Document))
                    {
                        a.type = "document";
                        ProjectElement_Document ped = (ProjectElement_Document)pe;
                        if (ped.documentThumbnailLocation != null)
                        {
                            a.artifactLocation = ped.documentThumbnailLocation;

                        }
                        if (ped.documentThumbnailLocation == null && ped.documentLocation != null)
                        {
                            a.artifactLocation = ped.documentLocation;

                        }
                        if (ped.documentLocation != null)
                        {
                            a.fileLocation = ped.documentLocation;
                        }
                        a.creationDate = "?/?/????";
                        if (ped.description != null)
                        {
                            a.description = ped.description;
                        }
                        else
                        {
                            a.description = null;
                        }
                        if (ped.title != null)
                        {
                            a.title = ped.title;
                        }
                        else
                        {
                            a.title = null;
                        }
                        add = 1;
                    }
                    else if (pe.GetType() == typeof(ProjectElement_Picture))
                    {
                        a.type = "picture";
                        ProjectElement_Picture pep = (ProjectElement_Picture)pe;
                        if (pep.pictureThumbnailLocation != null)
                        {
                            a.artifactLocation = pep.pictureThumbnailLocation;
                        }
                        if (pep.pictureLocation != null)
                        {
                            a.fileLocation = pep.pictureLocation;
                        }
                        a.creationDate = "?/?/????";
                        if (pep.description != null)
                        {
                            a.description = pep.description;
                        }
                        else
                        {
                            a.description = "";
                        }
                        if (pep.title != null)
                        {
                            a.title = pep.title;
                        }
                        else
                        {
                            a.title = null;
                        }
                        add = 1;
                    }
                    else if (pe.GetType() == typeof(ProjectElement_Video))
                    {
                        a.type = "video";
                        ProjectElement_Video pev = (ProjectElement_Video)pe;
                        if (pev.videoId != null)
                        {
                            a.artifactLocation = pev.videoId;
                        }
                        if (pev.description != null)
                        {
                            a.description = pev.description;
                        }
                        else
                        {
                            a.description = null;
                        }
                        a.creationDate = "?/?/????";
                        if (pev.title != null)
                        {
                            a.title = pev.title;
                        }
                        else
                        {
                            a.title = null;
                        }
                        if (pev.videoType != null)
                        {
                            a.fileLocation = pev.videoType;
                        }
                        else
                        {
                            a.fileLocation = null;
                        }
                        add = 1;
                    }
                    else if (pe.GetType() == typeof(ProjectElement_Audio))
                    {
                        a.type = "audio";
                        ProjectElement_Audio pea = (ProjectElement_Audio)pe;
                        if (pea.audioLocation != null)
                        {
                            a.artifactLocation = pea.audioLocation;
                        }
                        if (pea.description != null)
                        {
                            a.description = pea.description;
                        }
                        else
                        {
                            a.description = null;
                        }
                        a.creationDate = "?/?/????";
                        if (pea.title != null)
                        {
                            a.title = pea.title;
                        }
                        else
                        {
                            a.title = null;
                        }
                        add = 1;
                    }
                    else if (pe.GetType() == typeof(ProjectElement_Code))
                    {
                        a.type = "code";
                        ProjectElement_Code pec = (ProjectElement_Code)pe;
                        if (pec.code != null)
                        {
                            a.artifactLocation = pec.code;
                        }
                        if (pec.description != null)
                        {
                            a.description = pec.description;
                        }
                        else
                        {
                            a.description = null;
                        }
                        a.creationDate = "?/?/????";
                        if (pec.title != null)
                        {
                            a.title = pec.title;
                        }
                        else
                        {
                            a.title = null;
                        }
                        if (pec.fileLocation != null)
                        {
                            a.fileLocation = pec.fileLocation;
                        }
                        else
                        {
                            a.fileLocation = null;
                        }
                        add = 1;
                    }
                }
                if (add == 1)
                {
                    artifacts.Add(a);
                }
            }
            if (artifacts.Count != 0)
            {
                return artifacts;
            }
            else
            {
                return null;
            }
        }
Exemple #14
0
 public List<string> getAllProjectTags(int projectId)
 {
     List<Tag> projectTags = tagAccessor.GetProjectTags(projectId);
     List<string> projectTagStrings = new List<string>();
     foreach (Tag t in projectTags)
     {
         projectTagStrings.Add(t.value);
     }
     return projectTagStrings;
 }
Exemple #15
0
 public List<JsonModels.Prop> GetProjectProps(int projectId)
 {
     try
     {
         List<Prop> projectProps = propAccessor.GetProjectProps(projectId);
         List<JsonModels.Prop> projectPropJson = new List<JsonModels.Prop>();
         if (projectProps.Count > 0)
         {
             foreach (Prop p in projectProps)
             {
                 if (p != null)
                 {
                     JsonModels.Prop propJson = new JsonModels.Prop();
                     propJson.id = p.id;
                     propJson.message = p.message;
                     propJson.projectId = p.projectId;
                     propJson.timeStamp = p.timeStamp.ToString();
                     propJson.userId = p.userId;
                     propJson.firstName = p.firstName;
                     propJson.lastName = p.lastName;
                     projectPropJson.Add(propJson);
                 }
             }
             return projectPropJson;
         }
         else
         {
             return null;
         }
     }
     catch (Exception ex)
     {
         logAccessor.CreateLog(DateTime.Now, "ProjectManager - GetProjectProps", ex.StackTrace);
         return null;
     }
 }
Exemple #16
0
        } // creats final config log

        public static void createStrategyToList(List<Strategy> ls)
        {
            /*
            for (int sec = 30; sec <= 420; sec += 30)
            {
                for (int cell = 5; cell <= 7; cell++)
                {
                    for (double diff = 0.99; diff < 1.0; diff += 0.002)
                    {
                        for (double exit = 0.4; exit < 1; exit += 0.2)
                        {
                            for (double lost = 0.4; lost < 1; lost += 0.2)
                            {
                                for (double percentToExit = 0.2; percentToExit < 1; percentToExit += 0.1)
                                {
                                    ls.Add(new Dan(sec, cell, diff, cell / 4, exit, lost, percentToExit));
                                }
                            }
                        }
                    }
                }
            }
           */

            ls.Add(new Dan(60,7,0.99,3,0.6,1,0.4));
            //ls.Add(new NotFail(7, 2, 1));

            //ls.Add(new NotFail(7, 2, 1));
            
        } // creates strategy config list
Exemple #17
0
        public List<JsonModels.CompleteProject> GetCompleteProjects(int[] id, List<string> projectPrivacyPrivledge)
        {
            List<JsonModels.CompleteProject> projects = new List<JsonModels.CompleteProject>();
            ProjectAccessor pa = new ProjectAccessor();
            if (projectPrivacyPrivledge == null)
            {
                projectPrivacyPrivledge = new List<string>();
                projectPrivacyPrivledge.Add("public");
                projectPrivacyPrivledge.Add("network");
                projectPrivacyPrivledge.Add("private");
            }
            foreach (int i in id)
            {
                JsonModels.CompleteProject cp = new JsonModels.CompleteProject();
                ReorderEngine re = new ReorderEngine();
                Project p = pa.GetProject(i);
                if (p != null)
                {
                    if (p.isActive == true && (projectPrivacyPrivledge.Contains(p.privacy) || p.privacy == null))
                    {
                        cp.id = p.id;
                        if (p.name != null)
                        {
                            cp.title = p.name;
                        }
                        else
                        {
                            cp.title = null;
                        }
                        if (p.description != null)
                        {
                            cp.description = p.description;
                        }
                        else
                        {
                            cp.description = null;
                        }
                        cp.projectTags = GetProjectTags(p.id);

                        //we have to reset everyone's project order or when you add a new element this breaks - removes all old elements
                        List<int> peIds = new List<int>();
                        //just reset order if its null - duh!
                        if (p.projectElementOrder == null | p.projectElementOrder == "")
                        {
                            p = resetProjectElementOrder(p);
                            if (p.projectElementOrder != null)
                            {
                                List<int> IDS = re.stringOrderToList(p.projectElementOrder);
                                int[] ids = IDS.ToArray();
                                cp.artifactOrder = p.projectElementOrder;
                                cp.artifacts = GetArtifacts(ids);
                            }
                            else
                            {
                                cp.artifactOrder = null;
                                cp.artifacts = null;
                            }
                        }
                        else //projectElementOrder isn't null
                        {
                            List<int> IDS = re.stringOrderToList(p.projectElementOrder);
                            int[] ids = IDS.ToArray();
                            cp.artifacts = GetArtifacts(ids);
                            cp.artifactOrder = p.projectElementOrder;
                        }
                        if (p.coverPicture != null)
                        {
                            cp.coverPicture = p.coverPicture;
                        }
                        if (p.coverPictureThumbnail != null)
                        {
                            cp.coverPictureThumbnail = p.coverPictureThumbnail;
                        }
                        if (p.dateModified != null)
                        {
                            cp.dateModified = p.dateModified.ToString();
                        }
                        if (p.privacy != null)
                        {
                            cp.privacy = p.privacy;
                        }
                        cp.props = GetProjectProps(p.id);
                        projects.Add(cp);
                    }
                }
            }
            if (projects.Count != 0)
            {
                return projects;
            }
            else
            {
                return null;
            }
        }
Exemple #18
0
 public List<JsonModels.Artifact> GetArtifacts(List<ProjectElement> elements)
 {
     List<JsonModels.Artifact> artifacts = new List<JsonModels.Artifact>();
     ProjectAccessor pa = new ProjectAccessor();
     int add = 0;
     foreach (ProjectElement pe in elements)
     {
         add = 0;
         JsonModels.Artifact a = new JsonModels.Artifact();
         if (pe != null)
         {
             a.id = pe.id;
             if (pe.GetType() == typeof(ProjectElement_Document))
             {
                 a.type = "document";
                 ProjectElement_Document ped = (ProjectElement_Document)pe;
                 if (ped.documentThumbnailLocation != null)
                 {
                     a.artifactLocation = ped.documentThumbnailLocation;
                 }
                 a.creationDate = "?/?/????";
                 if (ped.description != null)
                 {
                     a.description = ped.description;
                 }
                 if (ped.title != null)
                 {
                     a.title = ped.title;
                 }
                 add = 1;
             }
             else if (pe.GetType() == typeof(ProjectElement_Picture))
             {
                 a.type = "picture";
                 ProjectElement_Picture pep = (ProjectElement_Picture)pe;
                 if (pep.pictureLocation != null)
                 {
                     a.artifactLocation = pep.pictureLocation;
                 }
                 //if (pep.pictureGalleriaThumbnailLocation != null)
                 //{
                 //    a.thumbnailLocation = pep.pictureGalleriaThumbnailLocation;
                 //}
                 a.creationDate = "?/?/????";
                 if (pep.description != null)
                 {
                     a.description = pep.description;
                 }
                 if (pep.title != null)
                 {
                     a.title = pep.title;
                 }
                 add = 1;
             }
             else if (pe.GetType() == typeof(ProjectElement_Video))
             {
                 a.type = "video";
                 ProjectElement_Video pev = (ProjectElement_Video)pe;
                 if (pev.videoId != null)
                 {
                     a.artifactLocation = pev.videoId;
                 }
                 if (pev.description != null)
                 {
                     a.description = pev.description;
                 }
                 a.creationDate = "?/?/????";
                 if (pev.title != null)
                 {
                     a.title = pev.title;
                 }
                 add = 1;
             }
             else if (pe.GetType() == typeof(ProjectElement_Audio))
             {
                 a.type = "audio";
                 ProjectElement_Audio pea = (ProjectElement_Audio)pe;
                 if (pea.audioLocation != null)
                 {
                     a.artifactLocation = pea.audioLocation;
                 }
                 if (pea.description != null)
                 {
                     a.description = pea.description;
                 }
                 a.creationDate = "?/?/????";
                 if (pea.title != null)
                 {
                     a.title = pea.title;
                 }
                 add = 1;
             }
         }
         if (add == 1)
         {
             artifacts.Add(a);
         }
     }
     if (artifacts.Count != 0)
     {
         return artifacts;
     }
     else
     {
         return null;
     }
 }
Exemple #19
0
 public List<JsonModels.ProjectShell> GetProjectShells(int ID)
 {
     try
     {
         UserAccessor userAccessor = new UserAccessor();
         List<Project> projects = reorderEngine.ReOrderProjects(userAccessor.GetUser(ID)).projects;
         List<JsonModels.ProjectShell> shells = new List<JsonModels.ProjectShell>();
         foreach (Project p in projects)
         {
             if (p.isActive == true && p.name != "About")
             {
                 JsonModels.ProjectShell ps = new JsonModels.ProjectShell();
                 ps.id = p.id;
                 if (p.name != null)
                 {
                     ps.name = p.name;
                 }
                 if (p.description != null)
                 {
                     ps.description = p.description;
                 }
                 if (p.tagIds != "" && p.tagIds != null)
                 {
                     ps.projectTags = GetProjectTags(p.id);
                 }
                 if (p.coverPicture != null)
                 {
                     ps.coverPicture = p.coverPicture;
                 }
                 if (p.coverPictureThumbnail != null)
                 {
                     ps.coverPictureThumbnail = p.coverPictureThumbnail;
                 }
                 List<JsonModels.ArtifactShell> artifactShells = new List<JsonModels.ArtifactShell>();
                 foreach (ProjectElement pe in p.projectElements)
                 {
                     if (pe == null)
                     {
                         continue;
                     }
                     JsonModels.ArtifactShell aShell = new JsonModels.ArtifactShell();
                     aShell.id = pe.id;
                     if (pe.title != null)
                     {
                         aShell.title = pe.title;
                     }
                     artifactShells.Add(aShell);
                 }
                 ps.artifacts = artifactShells;
                 shells.Add(ps);
             }
         }
         return shells;
     }
     catch (Exception ex)
     {
         return null;
     }
 }
        public TravelItineraryAddInfoRS AddTraveler(string securityToken)
        {
            TravelItineraryAddInfoRQ tirq = new TravelItineraryAddInfoRQ();

            tirq.CustomerInfo = new TravelItineraryAddInfoRQCustomerInfo();

            List<TravelItineraryAddInfoRQCustomerInfoPersonName> travelerInfos =
                new List<TravelItineraryAddInfoRQCustomerInfoPersonName>();

            TravelItineraryAddInfoRQCustomerInfoPersonName travelerInfo
                = new TravelItineraryAddInfoRQCustomerInfoPersonName();

            travelerInfo.NameNumber = "1.1";
            travelerInfo.GivenName = "RICHARD";
            travelerInfo.Surname = "FEYNMAN";
            travelerInfo.NameReference = "REF1";

            travelerInfos.Add(travelerInfo);

            tirq.CustomerInfo.PersonName = travelerInfos.ToArray();

            List<TravelItineraryAddInfoRQCustomerInfoEmail> emails =
                new List<TravelItineraryAddInfoRQCustomerInfoEmail>();
            emails.Add(new TravelItineraryAddInfoRQCustomerInfoEmail {
                Address = "*****@*****.**",
                NameNumber = "1.1"
            });
            tirq.CustomerInfo.Email = emails.ToArray();

            tirq.CustomerInfo.CustomerIdentifier = "1234567890";

            List<TravelItineraryAddInfoRQCustomerInfoContactNumber> contacts
                = new List<TravelItineraryAddInfoRQCustomerInfoContactNumber>();
            contacts.Add(new TravelItineraryAddInfoRQCustomerInfoContactNumber {
                Phone = "8175551212",
                NameNumber = "1.1",
                LocationCode = "YYZ",
                 PhoneUseType = "H"
            });
            tirq.CustomerInfo.ContactNumbers = contacts.ToArray();

            tirq.AgencyInfo = new TravelItineraryAddInfoRQAgencyInfo();
            tirq.AgencyInfo.Address = new TravelItineraryAddInfoRQAgencyInfoAddress();
            tirq.AgencyInfo.Address.AddressLine = "SABRE TRAVEL";
            tirq.AgencyInfo.Address.StreetNmbr = "3150 SABRE DRIVE";
            tirq.AgencyInfo.Address.CityName = "SOUTHLAKE";
            tirq.AgencyInfo.Address.PostalCode = "76092";
            tirq.AgencyInfo.Address.StateCountyProv = new TravelItineraryAddInfoRQAgencyInfoAddressStateCountyProv();
            tirq.AgencyInfo.Address.StateCountyProv.StateCode = "TX";
            tirq.AgencyInfo.Address.CountryCode = "US";

            tirq.AgencyInfo.Ticketing = new TravelItineraryAddInfoRQAgencyInfoTicketing();
            tirq.AgencyInfo.Ticketing.TicketType = "7T-";

            TravelItineraryAddInfoService
                ti = new TravelItineraryAddInfoService();
            ti.Security = this.CreateSecurityDto(securityToken);
            ti.MessageHeaderValue = this.CreateMessageHeader();

            return ti.TravelItineraryAddInfoRQ(tirq);
        }
Exemple #21
0
 public List<string> getAllUserTags(int userId)
 {
     List<Tag> userTags = tagAccessor.GetUserTags(userId);
     List<string> userTagStrings = new List<string>();
     foreach (Tag t in userTags)
     {
         userTagStrings.Add(t.value);
     }
     return userTagStrings;
 }
Exemple #22
0
        public List<ProjectElement> SearchProjects(User u, string query)
        {
            List<ProjectElement> matchElements = new List<ProjectElement>();
            string documentText = "";
            bool add = false;
            foreach (Project p in u.projects)
            {
                if (p.isActive == true)
                {
                    foreach (ProjectElement pe in p.projectElements)
                    {
                        add = false;
                        if (pe.GetType() == typeof(ProjectElement_Document))
                        {
                            ProjectElement_Document ped = (ProjectElement_Document)pe;
                            if (ped.description != null)
                            {
                                if (ped.description.ToLower().Contains(query))
                                {
                                    add = true;
                                }
                            }
                            if (ped.documentText != null)
                            {
                                if (ped.documentText.ToLower().Contains(query))
                                {
                                    add = true;
                                }
                            }
                            if (ped.title != null)
                            {
                                if (ped.title.ToLower().Contains(query))
                                {
                                    add = true;
                                }
                            }
                            if (add == true)
                            {
                                matchElements.Add(ped);
                            }
                        }
                        else
                        {
                            if (pe.description != null)
                            {
                                if (pe.description.ToLower().Contains(query))
                                {
                                    add = true;
                                }
                            }
                            if (pe.title != null)
                            {
                                if (pe.title.ToLower().Contains(query))
                                {
                                    add = true;
                                }
                            }
                            if (add == true)
                            {
                                matchElements.Add(pe);
                            }

                        }
                    }
                }
            }
            return matchElements;
        }
Exemple #23
0
        public JsonModels.Network GetNetworkJson(Network network)
        {
            try
            {
                if (network != null)
                {
                    JsonModels.Network networkJson = new JsonModels.Network();
                    networkJson.id = network.id;
                    networkJson.coverPicture = network.coverPicture;
                    networkJson.description = network.description;
                    networkJson.name = network.name;
                    networkJson.privacy = network.privacy;
                    networkJson.profileURL = network.profileURL;
                    if (network.GetType().Name.Contains("Network_TopNetwork"))
                    {
                        Network_TopNetwork topNetwork = networkAccessor.GetTopNetwork(network.id);
                        if (topNetwork.subNetworks.Count > 0)
                        {
                            List<JsonModels.NetworkShell> subNetShells = new List<JsonModels.NetworkShell>();
                            foreach (Network_SubNetwork subNetwork in topNetwork.subNetworks)
                            {
                                if (subNetwork != null)
                                {
                                    JsonModels.NetworkShell netShell = new JsonModels.NetworkShell();
                                    netShell.id = subNetwork.id;
                                    netShell.name = subNetwork.name;
                                    netShell.profileURL = subNetwork.profileURL;
                                    netShell.coverPicture = subNetwork.coverPicture;
                                    netShell.privacy = subNetwork.privacy;
                                    subNetShells.Add(netShell);
                                }
                            }
                            networkJson.subNetworks = subNetShells;
                            networkJson.parentNetwork = null;
                        }
                        else
                        {
                            networkJson.subNetworks = null;
                        }
                    }
                    else if (network.GetType().Name.Contains("Network_SubNetwork"))
                    {
                        Network_SubNetwork subNetwork = (Network_SubNetwork)network;
                        if (subNetwork.groups.Count > 0)
                        {
                            List<JsonModels.NetworkShell> groupShells = new List<JsonModels.NetworkShell>();
                            foreach (Network_Group group in subNetwork.groups)
                            {
                                if (group != null)
                                {
                                    JsonModels.NetworkShell gShell = new JsonModels.NetworkShell();
                                    gShell.id = group.id;
                                    gShell.name = group.name;
                                    gShell.profileURL = group.profileURL;
                                    gShell.coverPicture = group.coverPicture;
                                    gShell.privacy = group.privacy;
                                    groupShells.Add(gShell);
                                }
                            }
                            networkJson.subNetworks = groupShells;

                            JsonModels.NetworkShell parentNetworkShell = new JsonModels.NetworkShell();
                            Network_TopNetwork topNet = subNetwork.Network_TopNetwork;

                            parentNetworkShell.id = topNet.id;
                            parentNetworkShell.name = topNet.name;
                            parentNetworkShell.profileURL = topNet.profileURL;
                            parentNetworkShell.coverPicture = topNet.coverPicture;
                            parentNetworkShell.privacy = topNet.privacy;
                            networkJson.parentNetwork = parentNetworkShell;
                        }
                        else
                        {
                            networkJson.subNetworks = null;

                            JsonModels.NetworkShell parentNetworkShell = new JsonModels.NetworkShell();
                            Network_TopNetwork topNet = subNetwork.Network_TopNetwork;

                            parentNetworkShell.id = topNet.id;
                            parentNetworkShell.name = topNet.name;
                            parentNetworkShell.profileURL = topNet.profileURL;
                            parentNetworkShell.coverPicture = topNet.coverPicture;
                            parentNetworkShell.privacy = topNet.privacy;
                            networkJson.parentNetwork = parentNetworkShell;
                        }

                    }
                    else if (network.GetType().Name.Contains("Network_Group"))
                    {
                        Network_Group networkGroup = (Network_Group)network;
                        JsonModels.NetworkShell parentNetworkShell = new JsonModels.NetworkShell();
                        Network_SubNetwork subNet = networkGroup.Network_SubNetwork;
                        parentNetworkShell.id = subNet.id;
                        parentNetworkShell.name = subNet.name;
                        parentNetworkShell.profileURL = subNet.profileURL;
                        parentNetworkShell.coverPicture = subNet.coverPicture;
                        parentNetworkShell.privacy = subNet.privacy;
                        networkJson.parentNetwork = parentNetworkShell;
                    }

                    if (network.admins.Count > 0)
                    {
                        List<JsonModels.NetworkUserShell> adminShells = new List<JsonModels.NetworkUserShell>();
                        foreach (User admin in network.admins)
                        {
                            if (admin != null)
                            {
                                JsonModels.NetworkUserShell adminJson = new JsonModels.NetworkUserShell();
                                adminJson.userId = admin.id;
                                adminJson.firstName = admin.firstName;
                                adminJson.lastName = admin.lastName;
                                adminJson.profileURL = admin.profileURL;
                                adminJson.pictureLocation = admin.networkPictureThumbnail;
                                if (admin.isPublic == 1)
                                {
                                    adminJson.visibility = "visible";
                                }
                                else
                                {
                                    adminJson.visibility = "hidden";
                                }
                                adminShells.Add(adminJson);
                            }
                        }
                        networkJson.admins = adminShells;
                    }
                    return networkJson;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception ex)
            {
                logAccessor.CreateLog(DateTime.Now, "Network Manager - GetNetworkJson", ex.StackTrace);
                return null;
            }
        }
Exemple #24
0
 //doesnt yet return only unique tags
 private List<JsonModels.ProjectTag> GetProjectTags(int p)
 {
     TagAccessor ta = new TagAccessor();
     List<JsonModels.ProjectTag> projectTags = new List<JsonModels.ProjectTag>();
     List<Tag> tags = ta.GetProjectTags(p);
     foreach (Tag t in tags)
     {
         JsonModels.ProjectTag pt = new JsonModels.ProjectTag();
         if (t.value != null)
         {
             pt.projectTagValue = t.value;
             pt.projectTagId = t.id;
         }
         projectTags.Add(pt);
     }
     return projectTags;
 }