Ejemplo n.º 1
0
        } // Adds a total of all sums per day
        
        public void writePosLogFile(List <saveData> lsd,string path) 
        {
            if(!Directory.Exists(path+@"\Logs"))
            {Directory.CreateDirectory(path+@"\Logs");}

            if (File.Exists(path + @"\Logs\log - " + this.name + ".csv"))
            { File.WriteAllText(path + @"\Logs\log - " + this.name + ".csv", string.Empty); }

            path += @"\Logs\log - " +this.name +".csv";
            StreamWriter w = File.AppendText(path);
            w.WriteLine("DateTimeStart,ask1Start,askVolumeStart,bid1Start,bidVolumeStart,dirAtStart,DateTimeEnd,ask1End,askVolumeEnd,bid1End,bidVolumeEnd,dirAtEnd,profit");
            string line;

            for (int i = 0; i < lsd.Count; i++)
            {
                line = lsd[i].printString();
                if (i > 0)
                {
                    if (lsd[i - 1].getEnd().datetime.Day != lsd[i].getFirst().datetime.Day)
                    {
                        w.WriteLine(lsd[i].clearRow());
                    }
                }
                w.WriteLine(line);

            }
            w.Flush();
            w.Close();

        } // writes position - configuration log into file
Ejemplo n.º 2
0
        // Use this for start
        override public void StartGame()
        {
            type = ManagerType.MAP;

            _root   = new GameObject("Map");
            _maps   = MapParser.Parse();
            _map    = _maps[Game.instance.mapIndex];

    #if DEBUG
            Debug.Log("Create a map with " + _map.tiles.Count + " tiles on " + _map.lines + " lines and " + _map.columns + " columns");
    #endif

            for (int i = 0; i < _map.tiles.Count; i++)
            {
                Tile        tile    = _map.tiles[i];
                GameObject  go      = tile.type < _gameObjects.Length ? _gameObjects[tile.type] : _gameObjects[0];
                GameObject  tileGO  = GameObject.Instantiate(go);
                tile.gameObject = tileGO;

                tileGO.name = "Tile " + i;
                tileGO.transform.position = _map.GetPositionFromIndex(i);
                tileGO.transform.SetParent(_root.transform);

                PopulateTile(tile);
            }
        }
Ejemplo n.º 3
0
        public static double MaxDrop(List<saveData> ListSaveData)
        {
            if (ListSaveData.Count() >= 3)
            {
                double prev = ListSaveData[0].getTotalSum();
                double now = ListSaveData[0].getTotalSum();
                double next = ListSaveData[0].getTotalSum();
                int count = 0;
                bool b = false;
                double Max = 0, MaxDrop = 0;
                foreach (saveData o in ListSaveData)
                {
                    if (count < 3)
                        count++;
                    else
                    {
                        if (!b)
                        {
                            if (now > prev && now < next)
                            {
                                Max = now;
                                b = true;
                            }
                            else
                            {
                                prev = now;
                                now = next;
                                next = o.getProfit();
                            }
                        }
                        else
                        {
                            if (now < prev && now > next)
                            {
                                if (MaxDrop < (Max - now))
                                    MaxDrop = Max - now;
                                b = false;
                            }
                            else
                            {
                                prev = now;
                                now = next;
                                next = o.getProfit();
                            }

                        }
                    }
                }
                return MaxDrop;
            }
            else
            {
                if (ListSaveData.Count() == 1 /*|| ListSaveData.Count() == 0*/)
                    return 0.0;
                else
                {
                    return Math.Abs(ListSaveData[0].getTotalSum() - ListSaveData[1].getTotalSum());
                }
            }//foreach End
         }
Ejemplo n.º 4
0
 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;
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SoundScreen"/> class.
        /// </summary>
        /// <param name="graphicsManager">The graphics manager.</param>
        /// <param name="screenManager">The screen manager.</param>
        public SoundScreen(IBallerburgGraphicsManager graphicsManager, IScreenManager screenManager)
            : base(graphicsManager, screenManager, "Ballerburg3D")
        {
            // Zurück button
              zurueckMenuEntry = new MenuEntry(this, ResourceLoader.GetString("BackText"), 0) { Position = new Vector2(500, 450) };
              zurueckMenuEntry.Selected += ZurueckMenuEntrySelected;

              musicVolumeSlider = new HSlider(this, new Rectangle(250, 100, 300, 20), screenManager.ApplicationSettings.MusicVolume);
              musicVolumeSlider.ValueChanged += OnMusicVolumeChanged;
              soundFxVolumeSlider = new HSlider(this, new Rectangle(250, 200, 300, 20), screenManager.ApplicationSettings.FxVolume);
              menuEffectsVolumeSlider = new HSlider(this, new Rectangle(250, 300, 300, 20), screenManager.ApplicationSettings.MenuEffectsVolume);

              var musicList = new List<string> { "DarkStar", "High Tension", "Tentacle", "Death Row", "Boomerang", "Aus" };

              musicSelectButton = new ComboToggleButton(this, "Musik", new Collection<string>(musicList), 0, 0) { Position = new Vector2(20, 100) };
              musicSelectButton.Selected += OnMusicButtonSelected;

              toggleMenuEffectsActionButton = new OnOffToggleButton(this, "Menueeffekte", true, 0) { Position = new Vector2(20, 200) };

              toggleSoundEffectsActionButton = new OnOffToggleButton(this, "Soundeffekte", true, 0) { Position = new Vector2(20, 300) };

              ControlsContainer.Add(zurueckMenuEntry);
              ControlsContainer.Add(musicVolumeSlider);
              ControlsContainer.Add(soundFxVolumeSlider);
              ControlsContainer.Add(menuEffectsVolumeSlider);
              ControlsContainer.Add(musicSelectButton);
              ControlsContainer.Add(toggleMenuEffectsActionButton);
              ControlsContainer.Add(toggleSoundEffectsActionButton);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="AnimatedBillboard"/> class.
 /// </summary>
 /// <param name="loop">if set to <c>true</c> [loop].</param>
 /// <param name="contentManager">The content manager.</param>
 public AnimatedBillboard(bool loop, IContentManager contentManager)
 {
     Camera = null;
       framecount = 0;
       doLoop = loop;
       frames = new List<AnimationFrame>();
       Position = new Vector3(0.0f, 0.0f, 0.0f);
       this.contentManager = contentManager;
 }
Ejemplo n.º 7
0
        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;
        }
Ejemplo n.º 8
0
        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;
        }
Ejemplo n.º 9
0
        private List<double> eachDaySum; // List of each day sum + before for scoring

        public Strategy()
        {
            this.sum = 0;
            //this.maxSum = 0;
            this.pvol = 0;
            this.logInfo = new List<saveData>();
            this.paramArr = new double[arrLength];
            this.eachDaySum = new List<double>();
            setArr();
            
        } //Constructor
Ejemplo n.º 10
0
 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);
 }
Ejemplo n.º 11
0
        } // checks all files in folder path and run manager

        public static void Manager(String path, List<Strategy> ls)
        {           
            clearQueue();
            bool prevRowIn = false;
            bool firstWasIn = false;
            RowData rToChange;
            Console.WriteLine("Start file: " + path);
            Stream s = File.Open(path, FileMode.Open);
            BinaryFormatter bin = new BinaryFormatter();
            ProgramMain.lr = (List<RowData>)bin.Deserialize(s);
            s.Close();
            Console.WriteLine("End file: " + path);
            bin = null;
            foreach (RowData r in ProgramMain.lr)
            {
                setQueue(r);

                foreach (var strat in ls)
                {
                    if (prevRowIn)
                    {
                        
                        strat.getInfo(r);
                        
                    }
                    Strategy.prevRowData = new RowData(r);
                    if (!prevRowIn)
                    {
                        prevRowIn = true;
                    }
                }
                rToChange = r;
                rToChange = default(RowData);
            }
          
            foreach (var strat in ls)
            {
                if (strat.getList().Count() > 0 && !strat.getList()[strat.getList().Count() - 1].getPosEnd())
                {
                    strat.mustClosePos(Strategy.prevRowData);
                }

                strat.setDayToList(firstWasIn);
                strat.reset();
            }
           
            //GC.Collect();
            ProgramMain.lr.Clear();
            s.Close();
            firstWasIn = true;
        } // sends each row data to strategy
Ejemplo n.º 12
0
        } // Main

        public static void RunMain(String path, List<Strategy> ls)
        {

            String[] names = Directory.GetFiles(path);

            foreach (var i in names)
            {
                if (-1 != i.IndexOf(".bin"))
                {
                    Manager(i.ToString(), ls);

                }
            }
        } // checks all files in folder path and run manager
Ejemplo n.º 13
0
        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);
        }
Ejemplo n.º 15
0
        public static double MaxSum(List<saveData> ListSaveData, List<RowData> ListRowData)
        //ListRowData => info of all the day
        //ListSaveData => info of all my pos's
        {
            double first = 0;
            double second = 0;
            double Max = 0;
            back.Clear();
            Stack<RowData> StackRowData = new Stack<RowData>();
            foreach (saveData s in ListSaveData)
            {
                foreach (RowData r in ListRowData)
                {
                    if (r.Equals(s.getFirst()))
                        first = helpMaxsum(StackRowData, s.getFirst());
                    else
                    {
                        if (r.Equals(s.getEnd()))
                            second = helpMaxsum(StackRowData, s.getEnd());

                        else
                            StackRowData.Push(r);
                    }
                   
                    if (first != 0 && second != 0)
                    {
                        if (Math.Abs(first - second) > Max)
                        {
                            Max = Math.Abs(first - second);
                            first = 0;
                            second = 0;
                        }
                    }

                }

            }
            
            return Max;
        }
Ejemplo n.º 16
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
        /// <summary>
        /// Initializes a new instance of the <see cref="SpielerDialogScreen"/> class.
        /// </summary>
        /// <param name="graphicsManager">The GraphicsManager</param>
        /// <param name="screenManager">The screen manager.</param>
        /// <param name="spielerNr">The spieler nr.</param>
        /// <param name="playerSettings">The player settings.</param>
        public SpielerDialogScreen(IBallerburgGraphicsManager graphicsManager, IScreenManager screenManager, int spielerNr, PlayerSettings playerSettings)
            : base(graphicsManager, screenManager, "Spieler" + spielerNr.ToString() + " Dialog")
        {
            this.playerSettings = playerSettings;

              // Zurück button
              zurueckMenuEntry = new MenuEntry(this, ResourceLoader.GetString("BackText"), 0) { Position = new Vector2(500, 450) };
              zurueckMenuEntry.Selected += ZurueckMenuEntrySelected;

              castleType = screenManager.PlayerSettings[spielerNr - 1].Castle.CastleType;

              var selectedEntry = 0;

              if (screenManager.PlayerSettings[spielerNr - 1].PlayerType == PlayerType.Computer)
              {
            selectedEntry = 1;
              }

              var entries = new List<string> { "Aus", "An" };

              computerMenuEntry = new ComboToggleButton(this, "Computer", new Collection<string>(entries), selectedEntry, 0)
                              {
                                Position = new Vector2(10, 100)
                              };
              computerMenuEntry.Selected += ComputerMenuEntrySelected;

              txtCastleName = new TextBox(this, false) { Position = new Vector2(260, 270), ShowCursor = false };

              nameLabel = new MenuEntry(this, "Name", 0) { Position = new Vector2(10, 200) };
              nameLabel.Selected += NameMenuEntrySelected;

              ControlsContainer.Add(zurueckMenuEntry);
              ControlsContainer.Add(computerMenuEntry);
              ControlsContainer.Add(nameLabel);
              ControlsContainer.Add(txtCastleName);

              var pp = GraphicsManager.GraphicsDevice.PresentationParameters;
              renderTarget = new RenderTarget2D(GraphicsManager.GraphicsDevice, pp.BackBufferWidth, pp.BackBufferHeight, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8);
        }
        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 ActionResult Profile(string profileURL)
        {
            if (profileURL == "")
            {
                User currentUser = userManager.GetUser(User.Identity.Name);
                return RedirectToAction("Profile", "User", new { profileURL = currentUser.profileURL });
            }

            //throw (new ArgumentNullException());
            TempData["MessageBar"] = TempData["MessageBar"];
            TempData["Popup"] = TempData["Popup"];

            try
            {
                ViewBag.DisplayPicture = false;
                ViewBag.DisplayInfo = false;

                TagManager tagManager = new TagManager();

                User user = userManager.GetUserByProfileURL(profileURL);
                if (user == null)
                {
                    try
                    {
                        string userNameLoggedIn = User.Identity.Name;
                        if (userNameLoggedIn == null || userNameLoggedIn == "")
                        {
                            return RedirectToAction("Index", "Home");
                        }
                        else
                        {
                            user = userManager.GetUser(userNameLoggedIn);
                        }
                    }
                    catch (Exception e)
                    {

                    }
                }
                else if ((User.Identity.Name != user.userName) && (user.isPublic != 1))
                {
                    //if not the owner and trying to access a user that is not public
                    return RedirectToAction("Index", "Home");
                }
                //else...
                //projectManager.moveProjectRight(user, 2);
                //userManager.UpdateUser(user);
                if (user.projectOrder == null)
                {
                    userManager.ResetProjectOrder(user);
                    userManager.UpdateUser(user);
                    foreach (Project p in user.projects)
                    {
                        projectManager.resetProjectElementOrder(p);
                        projectManager.UpdateProject(p);
                    }
                }

                ProfileModel model = new ProfileModel(user);
                List<string> tagValues = new List<string>();
                //Put user's tags on the ProfileModel
                /*
                if (user.tagIds != null && user.tagIds != "")
                {
                    List<Tag> tagList = tagManager.GetTags(user.tagIds);
                    foreach (Tag tag in tagList)
                    {
                        tagValues.Add(tag.value);
                    }
                    model.tagValues = tagValues;
                }*/

                //ViewBag.WillingToRelocate = new List<string>(Enum.GetNames(typeof(WillingToRelocateType)));

                if (user.userName == User.Identity.Name && User.Identity.IsAuthenticated)
                {
                    AnalyticsAccessor aa = new AnalyticsAccessor();
                    aa.CreateAnalytic("Profile Page Hit: Logged in", DateTime.Now, user.userName);

                    //User is going to their own profile
                    ViewBag.IsOwner = true;
                    model.connections = new List<User>();
                    if (user.connections != null)
                    {
                        foreach (string userId in user.connections.Split(','))
                        {
                            if (userId.Trim() != "")
                            {
                                int userIdInt = Convert.ToInt32(userId);
                                User connection = userManager.GetUser(userIdInt);
                                model.connections.Add(connection);
                            }
                        }
                    }

                    /*//depreciated. can't use .CompleteProfilePrompt any more. will have to deal with tags some other way
                     * if (userManager.IsProfilePartiallyComplete(user))
                    {
                        //User has already entered some extra information on their profile
                        ViewBag.CompleteProfilePrompt = false;
                    }
                    else
                    {
                        //User has not updated any further info on their profile
                        //Get list of tags for picking out which ones we initially want on our profile
                        List<string> listOfLowestLevelTags = userManager.GetAllLowestLevelTagValues();
                        ViewBag.LowestLevelTags = listOfLowestLevelTags;
                        ViewBag.CompleteProfilePrompt = true;
                    }*/
                }
                else
                {
                    AnalyticsAccessor aa = new AnalyticsAccessor();
                    aa.CreateAnalytic("Profile Page Hit: Not Logged in", DateTime.Now, user.userName);

                    //User is visiting someone else's profile
                    ViewBag.IsOwner = false;
                }

                //------------------------------------------------------------
                return View(model);
            }
            catch (Exception ex)
            {
                logAccessor.CreateLog(DateTime.Now, this.GetType().ToString() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString(), ex.ToString());
                return View("Error");
            }
        }
        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);
     }
 }
Ejemplo n.º 23
0
 public void Initialize()
 {
     list_urinal = new List<Urinal>();
     Spawn_Urinals();
 }
Ejemplo n.º 24
0
 public void Initialize()
 {
     is_ready = true;
     list_meones = new List<Meon.Info>();
 }
Ejemplo n.º 25
0
        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);
        }
Ejemplo n.º 26
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;
 }
Ejemplo n.º 27
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;
 }
Ejemplo n.º 28
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
Ejemplo n.º 29
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;
            }
        }
Ejemplo n.º 30
0
 public static string ValidateFileIsNotInStreamList(Stream newFileStream, List<Stream> existingFileStreams)
 {
     foreach (Stream stream in existingFileStreams)
     {
         if (ValidateFileHasChanged(newFileStream, stream) != Success)
         {
             return "The new file was identical to another file of the same type in this project";
         }
     }
     return Success;
 }