Exemple #1
0
        public static IEnumerable<AggregateView> GetRoadmapReleasesFromFile()
        {
            var import = new Import();
            if (File.Exists(HttpContext.Current.Server.MapPath(import.YouTrackJsonFile)) == false)
                import.SaveAllToFile();

            var allText = File.ReadAllText(HttpContext.Current.Server.MapPath(import.YouTrackJsonFile));

            var data = new JavaScriptSerializer().Deserialize<List<AggregateView>>(allText);
            var result = data.Where(x => x.released == false && x.isPatch == false);

            return result;
        }
Exemple #2
0
        /// <summary>Process
        /// <para>
        /// Process: Internal function to convert a RosetteFile into a dictionary to use for getResponse
        /// </para>
        /// </summary>
        /// <param name="file">RosetteFile: File being uploaded to use as a request to the Rosette server.</param>
        /// <returns>Dictionary&lt;string, object&gt;: Dictionary containing the results of the response from the server from the getResponse call.</returns>
        private Dictionary<string, Object> Process(RosetteFile file)
        {
            Dictionary<string, string> dict = new Dictionary<string, string>(){
                { "content", file.getFileDataString()},
                { "contentType", file.getDataType()},
                { "unit", "doc"},
            };

            if(file.getOptions() != null){
                Dictionary<string, string> opts = new JavaScriptSerializer().Deserialize<Dictionary<string, string>>(file.getOptions());
                dict = (Dictionary<string, string>)dict.Concat(opts.Where(x=> !dict.Keys.Contains(x.Key)));
            }


            return getResponse(SetupClient(), new JavaScriptSerializer().Serialize(dict));
        }
        private string GetReportOutputConfiguration(int reportId, int userId, IEnumerable<ReportColumn> columnsSwapHistory, IEnumerable<ReportColumn> columnsWidthHistory)
        {
            var userReport = GetUserReport(reportId, userId);

            var columnsConfig = new JavaScriptSerializer().Deserialize<List<ReportColumn>>(userReport.OutputConfiguration);

            columnsConfig.ForEach(reportConfig =>
            {
                var lastIndex = columnsSwapHistory.LastOrDefault(columnSwap => columnSwap.Name == reportConfig.Name);

                //There was an index change so an offset has to be performed
                if (!lastIndex.IsNull())
                {
                    //Right offset
                    if (lastIndex.Index > reportConfig.Index)
                    {
                        foreach (var column in columnsConfig.Where(colum => colum.Index <= lastIndex.Index && colum.Index > reportConfig.Index))
                            column.Index--;
                    }
                    else
                    {
                        //Left offset
                        foreach (var column in columnsConfig.Where(colum => colum.Index >= lastIndex.Index && colum.Index < reportConfig.Index))
                            column.Index++;
                    }

                    reportConfig.Index = lastIndex.Index;
                }

                var lastWidth = columnsWidthHistory.LastOrDefault(columnWidth => columnWidth.Name == reportConfig.Name);

                if (!lastWidth.IsNull())
                    reportConfig.Width = lastWidth.Width;
            });

            var jsonResult = new JsonSerializer().Serialize(columnsConfig);

            return jsonResult;
        }
        public ActionResult UpdateColumnOrder(int reportId, string columnName, int oldIndex, int newIndex)
        {
            try
            {
                var userReport = GetUserReport(reportId, GetLoggedUserId());

                var currentOutput = userReport.Output;

                var outputConfig = new JavaScriptSerializer().Deserialize<List<ReportColumn>>(userReport.OutputConfiguration);

                var column = outputConfig.FirstOrDefault(col => col.Name == columnName);

                if (!column.IsNull())
                {
                    //Right offset
                    if (newIndex > oldIndex)
                    {
                        foreach (var col in outputConfig.Where(colum => colum.Index <= newIndex && colum.Index > oldIndex))
                            col.Index--;
                    }
                    else
                    {
                        //Left offset
                        foreach (var col in outputConfig.Where(colum => colum.Index >= newIndex && colum.Index < oldIndex))
                            col.Index++;
                    }

                    column.Index = newIndex;

                    var updatedOutputConfig = new JavaScriptSerializer().Serialize(outputConfig);

                    UpdateUserReportOutPutConfig(reportId, GetLoggedUserId(), updatedOutputConfig);
                }

                return Json(true);
            }
            catch (Exception)
            {
                return null;
            }
        }
        public ActionResult GetOrderSummary(string mySelection)
        {
            try
            {
                var selectionDeserialized = new JavaScriptSerializer().Deserialize<IEnumerable<MarketingMaterialSelection>>(mySelection);

                var positiveSelection = selectionDeserialized.Where(selected => selected.Quantity > 0);

                var allMaterials = GetMarketingMaterials();

                var selection = allMaterials.Join(positiveSelection, marketing => marketing.Id, select => select.Id, (a, b) => new { a.Category, a.Id, b.Quantity });

                var selectionGrouped = selection.GroupBy(a => a.Category);

                var result = selectionGrouped.Select(group => new { Category = group.Key, Amount = group.Sum(a => a.Quantity) });

                //To be changed
                var shippingCost = 15;

                return Json(new { Summary = result, Cost = shippingCost });
            }
            catch (Exception exception)
            {
                return null;
            }
        }
        public ActionResult SendOrder(string things)
        {
            try
            {
                var userLogged = Session[Utils.UserKey] as UserModel;

                var thingsSelected = new JavaScriptSerializer().Deserialize<IEnumerable<MarketingMaterialSelection>>(things);

                var positiveSelection = thingsSelected.Where(selected => selected.Quantity > 0);

                var thingsInfo = GetMarketingMaterials();

                var thingsInOrder = positiveSelection.Join(thingsInfo, a => a.Id, b => b.Id, (a, b) => new MarketingProduct(b,b.Category,a.Quantity));

                var cartHeader = GetOrderReady(thingsInOrder);

                var request = Utils.GetRequestInfo(Method.POST, "/api/Orders/Add");

                var insertOrderResponse = _webClient.Execute<OrderResponse>(new JsonSerializer().Serialize(cartHeader), ApiUrls.API_KEY, ApiUrls.API_SECRET, request);

                var confirmation = new OrderConfirmation
                {
                    OrderConfirmationNumber = insertOrderResponse.OrderId,
                    Address = Utils.GetFormattedAddress(userLogged.Address1, userLogged.Address2, userLogged.City, userLogged.State, userLogged.ZipCode, "USA"),
                    Email = userLogged.Email,
                    Phone =  userLogged.Phone,
                    Name = userLogged.Name,
                };
                var result = insertOrderResponse.OrderId > 0? Utils.Success:"There were problems trying to process your order. Try it again later, please.";

                return Json(new{ShippingInfo = confirmation,  Result = result});
            }
            catch (Exception exception)
            {
                return Json(new { Result = "There were problems trying to process your order. Try it again later, please." });
            }
        }