Example #1
0
        public ActionResult SaveLocationOfExposure(FormCollection form)
        {
            long key       = long.Parse(Session["IdfCase"].ToString());
            var  humanCase = (HumanCase)ModelStorage.Get(Session.SessionID, key, null);

            Int64 originalIdfGeoLocation = humanCase.PointGeoLocation.idfGeoLocation;
            var   originalGeoLocation    = (GeoLocation)ModelStorage.Get(Session.SessionID, originalIdfGeoLocation, null);
            Int64 cloneIdfGeoLocation    = originalIdfGeoLocation + 1;
            var   cloneGeoLocation       = (GeoLocation)ModelStorage.Get(Session.SessionID, cloneIdfGeoLocation, null);

            var data = new CompareModel();

            ValidateGeoLocation(originalGeoLocation, cloneGeoLocation, form);

            if (m_Validation != null)
            {
                string errorMessage = Translator.GetErrorMessage(m_Validation);
                data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false);
            }
            else
            {
                using (GeoLocation tempGeoLocation = originalGeoLocation.CloneWithSetup())
                {
                    ModifyOriginalGeoLocation(originalGeoLocation, cloneGeoLocation, form);
                    ModelStorage.Remove(Session.SessionID, cloneIdfGeoLocation, null);
                    data = originalGeoLocation.Compare(tempGeoLocation);
                }
            }

            return(new JsonResult {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = data
            });
        }
Example #2
0
        internal CompareModel _compare(IObject o, CompareModel ret)
        {
            if (ret == null)
            {
                ret = new CompareModel();
            }
            if (o == null)
            {
                return(ret);
            }
            HACodeLookup obj = (HACodeLookup)o;

            using (DbManagerProxy manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance))
            {
                Accessor.Instance(null)._LoadLookups(manager, obj);
                foreach (var i in _field_infos)
                {
                    if (i != null && i._compare_func != null)
                    {
                        i._compare_func(this, obj, ret, manager);
                    }
                }
            }
            return(ret);
        }
Example #3
0
        /// <summary>
        /// Gets the compare results.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns>Dictionary&lt;System.String, System.Int32&gt;.</returns>
        public static Dictionary <string, string> GetCompareResults(CompareModel model)
        {
            Dictionary <string, string> keys = new Dictionary <string, string>();

            var results = model.ColumnCompare.SelectMany(s => s.CompareResults).ToList();

            foreach (var item in results)
            {
                string key1 = item.Row + item.LeftKey;  // "left_" + item.LeftSide;
                string key2 = item.Row + item.RightKey; // "right_" + item.RightSide;

                if (keys.ContainsKey(key1))
                {
                    model.ErrorMessages.Add(new
                                            ErrorMessageModel("Get Compare Results", string.Format("The left key {0} already exists", key1), "Please report this error"));
                }

                if (keys.ContainsKey(key2))
                {
                    model.ErrorMessages.Add(new
                                            ErrorMessageModel("Get Compare Results", string.Format("The right key {0} already exists", key2), "Please report this error"));
                }

                if (keys.ContainsKey(key1) == false)
                {
                    keys.Add(key1, "Red");
                }
                if (keys.ContainsKey(key2) == false)
                {
                    keys.Add(key2, "LightGreen");
                }
            }
            return(keys);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CompareExecuter"/> class.
        /// </summary>
        /// <param name="table">The table.</param>
        /// <param name="model">The model.</param>
        /// <param name="cancelToken">The cancel token.</param>
        public CompareExecuter(DataTable table, CompareModel model, CancellationTokenSource cancelToken)
        {
            this.Table = table;

            this.CancelToken = cancelToken;
            this.Model       = model;
        }
        public ActionResult Message()
        {
            ViewBag.Message = "Bạn phải chọn ít nhất 2 sản phẩm để so sánh";
            CompareModel model = new CompareModel();

            return(View(model));
        }
        public async Task <ActionResult> Compare(CompareModel model)
        {
            model.Group1Projects = await GetProjectsSelectListItems(model.Project1Guid.GetValueOrDefault());

            model.Group2Projects = await GetProjectsSelectListItems(model.Project2Guid.GetValueOrDefault());

            if (model.Project1Guid.HasValue)
            {
                model.Project1Groups = await GetVariableGroupsSelectListItems(model.Project1Guid.Value, model.Group1Id.GetValueOrDefault());
            }

            if (model.Project2Guid.HasValue)
            {
                model.Project2Groups = await GetVariableGroupsSelectListItems(model.Project2Guid.GetValueOrDefault(), model.Group2Id.GetValueOrDefault());
            }

            if (model.Group1Id.HasValue && model.Group2Id.HasValue)
            {
                model.Group1 = await VariableGroupService.GetVariableGroupAsync(model.Project1Guid.GetValueOrDefault(), model.Group1Id.GetValueOrDefault());

                model.Group2 = await VariableGroupService.GetVariableGroupAsync(model.Project2Guid.GetValueOrDefault(), model.Group2Id.GetValueOrDefault());

                model.Results = Comparer.Compare(model.Group1, model.Group2);
            }

            return(View(model));
        }
Example #7
0
        public CompareModel GetNextCombination()
        {
            if (combinations.Count() > 0)
            {
                CompareModel compareModel = new CompareModel();

                Random random             = new Random();
                int    indexComaringItems = random.Next(0, combinations.Count() - 1);

                compareModel.Name1     = combinations[indexComaringItems].Name1;
                compareModel.Name2     = combinations[indexComaringItems].Name2;
                compareModel.Position1 = combinations[indexComaringItems].Position1;
                compareModel.Position2 = combinations[indexComaringItems].Position2;
                compareModel.Score1    = combinations[indexComaringItems].Score1;
                compareModel.Score2    = combinations[indexComaringItems].Score2;

                return(compareModel);
            }

            return(new CompareModel
            {
                Name1 = "No name",
                Name2 = "No name",
                Position1 = 0,
                Position2 = 0,
                Score1 = 0,
                Score2 = 0
            });
        }
        public void Test_Comparison_UseCases()
        {
            CompareModel model = new CompareModel();

            string file = @".\Comparisons\v2_xls_docment_compare_use_cases.xml";

            if (File.Exists(file) == false)
            {
                throw new FileNotFoundException(file);
            }

            model = CompareModel.Load(file);
            CompareModelRepository repo = new CompareModelRepository(model);

            CancellationTokenSource token = new CancellationTokenSource();
            Task task = repo.ExecuteWait(token);

            repo.CompareComplete += (o, e) =>
            {
                var errors = model.ColumnCompare.Where(w => w.Errors != "0" && !string.IsNullOrEmpty(w.Errors)).Count();
                Assert.AreEqual(errors, 3);
                Assert.AreEqual(model.ColumnCompare.Count, 7);
            };

            task.Wait(token.Token);
        }
Example #9
0
        public static CompareModel CompareUpsert(CompareModel CompareToUpsert)
        {
            if (CompareToUpsert != null)
            {
                LogManager.Models.LogModel oLog = Company.Controller.Company.GetGenericLogModel();
                try
                {
                    CompareToUpsert.CompareId =
                        DAL.Controller.CompareDataController.Instance.CompareUpsert
                            (CompareToUpsert.CompareId > 0 ? (int?)CompareToUpsert.CompareId : null,
                            CompareToUpsert.CompareName,
                            CompareToUpsert.User,
                            CompareToUpsert.Enable);

                    CompareToUpsert = CompareCompanyUpsert(CompareToUpsert);

                    oLog.IsSuccess = true;
                }
                catch (Exception err)
                {
                    oLog.IsSuccess = false;
                    oLog.Message   = err.Message + " - " + err.StackTrace;

                    throw err;
                }
                finally
                {
                    oLog.LogObject = CompareToUpsert;
                    LogManager.ClientLog.AddLog(oLog);
                }
            }

            return(CompareToUpsert);
        }
Example #10
0
        public ActionResult SetSelectedFarm(string root, string selectedId)
        {
            long key     = long.Parse(root);
            long rootKey = (long)((IObject)ModelStorage.GetRoot(Session.SessionID, key, null)).Key;
            var  vetCase = ModelStorage.Get(Session.SessionID, rootKey, null) as VetCase;

            using (DbManagerProxy manager = DbManagerFactory.Factory.Create(EidssUserContext.Instance))
            {
                var  cloneVetCase = (VetCase)vetCase.CloneWithSetup(manager, true);
                long idfFarm      = string.IsNullOrEmpty(selectedId) ? 0 : long.Parse(selectedId);
                if (idfFarm == 0)
                {
                    var accessor = FarmPanel.Accessor.Instance(null);
                    vetCase.Farm = accessor.CreateByCase(manager, vetCase, vetCase);
                }
                else
                {
                    vetCase.Farm.idfRootFarm = idfFarm;
                }
                CompareModel data = vetCase.Compare(cloneVetCase);
                return(new JsonResult {
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = data
                });
            }
        }
Example #11
0
        public CompareModel CompareItems(CompareModel comparedItems)
        {
            if (comparedItems != null)
            {
                if (comparedItems.Value1.GetType() == typeof(int) &&
                    comparedItems.Value2.GetType() == typeof(int))
                {
                    int  indexOfCombination = 0;
                    bool founded            = false;
                    for (int i = 0; i < combinations.Count(); i++)
                    {
                        if (String.Equals(combinations[i].Name1, comparedItems.Name1) &&
                            String.Equals(combinations[i].Name2, comparedItems.Name2))
                        {
                            indexOfCombination = i;
                            founded            = true;
                            Item item = new Item();

                            if (comparedItems.Value1 > comparedItems.Value2)
                            {
                                //item.Score = comparedItems.Score1;
                                item.Name = comparedItems.Name1;
                                //item.Position = comparedItems.Position1;
                                var indexOfItem = items.FindIndex(x => x.Name == item.Name);
                                //item.Score++;
                                items[indexOfItem].Score++;
                            }
                            else if (comparedItems.Value1 < comparedItems.Value2)
                            {
                                //item.Score = comparedItems.Score2;
                                item.Name = comparedItems.Name2;
                                //item.Position = comparedItems.Position2;
                                var indexOfItem = items.FindIndex(x => x.Name == item.Name);
                                //item.Score++;
                                items[indexOfItem].Score++;
                            }

                            items = items.OrderByDescending(x => x.Score).ToList();

                            int position = 0;

                            foreach (var itm in items)
                            {
                                itm.Position = ++position;
                            }

                            break;
                        }
                    }
                    if (founded)
                    {
                        combinations.RemoveAt(indexOfCombination);
                    }
                }
                return(GetNextCombination());
            }

            return(null);
        }
Example #12
0
        public JsonResult getcomparison(string strfromval, string strtoval, string strFCurr, string strTcurr, string strlist)
        {
            JavaScriptSerializer serializer  = new JavaScriptSerializer();
            List <SortList>      ListAnswers = serializer.Deserialize <List <SortList> >(strlist);

            MoneyScannerEntities mse = new MoneyScannerEntities();

            var getfrocurry            = mse.TransferBases.Where(m => m.FromCurrency == strFCurr && m.ToCurrency == strTcurr);
            List <CompareModel> lstcrl = new List <CompareModel>();

            foreach (var g in getfrocurry)
            {
                CompareModel cm = new CompareModel();
                cm.ImageName        = g.Provider.ProviderLogo;
                cm.rating           = Convert.ToString(g.Provider.ProviderRating);
                cm.todaysrate       = Convert.ToString(g.ToValue);
                cm.transferfee      = Convert.ToString(g.TransferFee);
                cm.transfercurrency = g.TransferCurrency;
                if (g.TransferDuration < 24)
                {
                    cm.transfertime = string.Format("{0} Hour(s)", Convert.ToString(g.TransferDuration));
                }
                else
                {
                    cm.transfertime = string.Format("{0} Day(s)", Convert.ToString(g.TransferDuration / 24));
                }
                cm.send           = g.Websitelink;
                cm.amountreceived = Convert.ToString(Convert.ToDecimal(strfromval) * g.ToValue);

                lstcrl.Add(cm);
            }
            IEnumerable <CompareModel>        querysorted = null;
            IOrderedEnumerable <CompareModel> lstsorted   = null;

            if (ListAnswers.Count > 0)
            {
                foreach (SortList sl in ListAnswers)
                {
                    var propertyInfo = typeof(CompareModel).GetProperty(sl.strKey);

                    if (sl.strSort.ToUpper() == "ASC")
                    {
                        lstsorted = lstcrl.OrderBy(x => propertyInfo.GetValue(x, null));
                    }
                    else
                    {
                        lstsorted = lstcrl.OrderByDescending(x => propertyInfo.GetValue(x, null));
                    }
                }
            }
            else
            {
                lstsorted = lstcrl.OrderByDescending(x => x.amountreceived);
            }

            querysorted = lstsorted;

            return(Json(querysorted, JsonRequestBehavior.AllowGet));
        }
Example #13
0
        public IActionResult Index([FromForm] CompareModel comparedItems)
        {
            _itemRepository.CompareItems(comparedItems);
            ViewData["CombinationCount"] = _itemRepository.GetAllCombinations().Count();
            var items = _itemRepository.GetAllItems();

            return(View(items));
        }
Example #14
0
        public ActionResult Details(FormCollection form)
        {
            string errorMessage;

            form.AllKeys.ToList().ForEach(k => form[k] = EidssWebHelper.UnescapeHtml(form[k]));
            bool isDatesValid = DateTimeHelper.TryParseCustomDates(form, out errorMessage) && DateTimeHelper.TryParseMobileSafariDates(form, out errorMessage);
            var  data         = new CompareModel();

            if (!isDatesValid)
            {
                data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false);
                return(new JsonResult {
                    Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }

            long key       = long.Parse(Session["IdfCase"].ToString());
            var  humanCase = (HumanCase)ModelStorage.Get(Session.SessionID, key, null);

            var cloneHumanCase = (HumanCase)humanCase.Clone();

            m_Validation          = null;
            humanCase.Validation += hc_ValidationDetails;
            humanCase.ParseFormCollection(form);
            if (m_Validation != null)
            {
                humanCase.Validation -= hc_ValidationDetails;
                errorMessage          = Translator.GetErrorMessage(m_Validation);
                data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false);
                return(new JsonResult {
                    Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }

            using (DbManagerProxy manager = DbManagerFactory.Factory.Create(EidssUserContext.Instance))
            {
                HumanCase.Accessor acc = HumanCase.Accessor.Instance(null);
                acc.Validate(manager, humanCase, true, true, true);
                if (m_Validation == null)
                {
                    acc.Post(manager, humanCase);
                }
            }
            humanCase.Validation -= hc_ValidationDetails;
            if (m_Validation != null)
            {
                errorMessage = Translator.GetErrorMessage(m_Validation);
                data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false);
            }
            else
            {
                data = humanCase.Compare(cloneHumanCase);
            }
            return(new JsonResult {
                Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
        public ActionResult Compare()
        {
            CompareModel model = GetCompare();

            if (model.Item1 != null && model.Item2 != null)
            {
                return(View("Index", model));
            }
            TempData["UserMess"] = "Для сравнения не хватает предметов";
            return(RedirectToAction("List", "Goods"));
        }
Example #16
0
        public PageCompare()
        {
            InitializeComponent();

            if (!this.IsDesignMode())
            {
                DataContext = new CompareModel();
                var size = (double)Application.Current.Resources["SyllableFontSize"] / 2;
                list.FontSize = size;
                list.Width    = size;
            }
        }
        public ActionResult Index(int?id)
        {
            // Arrange
            CompareModel model    = GetCompare();
            var          category = _repository.GetCategories().ToList();
            var          goods    = _repository.GetGoods().First(g => g.Id == id);
            var          url      = string.Empty;

            if (Request.UrlReferrer != null)
            {
                url = HttpContext.Request.UrlReferrer.AbsolutePath;
            }
            else
            {
                url = "~/Goods/List";
            }

            // Set url for return
            model.ReturnUrl = url;

            // Adding item to qq
            if (model.Item1 == null)   // first item is empty
            {
                model.Item1        = goods;
                Session["Compare"] = model;
            }
            else
            {
                if (model.Item2 == null) // second item is empty
                {
                    model.Item2        = _repository.GetGoods().FirstOrDefault(g => g.CategoryId == goods.CategoryId);
                    Session["Compare"] = model;
                }
                else  // qq is full, so we need cant add more items
                {
                    TempData["UserMess"] = "В очереди для сравнения уже есть 2 товара, для начала удалите один из них";
                    return(RedirectToAction("Index", "Item", new { id = id, UserMess = "В очереди для " }));
                }
            }

            // if we have 2 objects to compare - we compare them
            if (model.Item1 != null && model.Item2 != null)
            {
                return(View(model));
            }
            else // all other ways
            {
                TempData["UserMess"] = "Товар успешно добавлен в очередь для сравнения, добавьте еще один товар для сравнения";
                return(RedirectToAction("Index", "Item", new { id = id }));
            }
        }
        public JsonResult GetCompareFacilities(string code, Boolean ifac, CompareModel model, FacilityService service)
        {
            code           = code.Trim().Split(null)[0];
            model.Facility = service.GetFacility(code);
            if (ifac)
            {
                model.Facilities = service.GetFacilitiesAutocomplete("WHERE fc_idnt<>" + model.Facility.Id + " AND fc_level=" + model.Facility.Category.Level.Id);
            }

            List <Norms> HumanResources = service.GetNorms(model.Facility, 1);
            List <Norms> Infrastructure = service.GetNorms(model.Facility, 2);
            List <Norms> FacilityChecks = service.GetNorms(model.Facility, 3);

            double norms = 0;
            double value = 0;

            foreach (var norm in HumanResources)
            {
                norms += norm.Norm;
                value += norm.Value;
            }

            model.ScoreHumanResources = (value / norms) * 100;
            norms = 0;
            value = 0;

            foreach (var norm in Infrastructure)
            {
                norms += norm.Norm;
                value += norm.Value;
            }

            model.ScoreInfrastructure = (value / norms) * 100;
            norms = 0;
            value = 0;

            foreach (var norm in FacilityChecks)
            {
                norms += norm.Norm;
                value += norm.Value;
            }

            model.ScoreChecklist = (value / norms) * 100;
            norms = 0;
            value = 0;

            model.ScoreOverall = (model.ScoreChecklist + model.ScoreInfrastructure + model.ScoreHumanResources) / 3;

            return(Json(model));
        }
        /// <summary>
        /// Setting and getting Compare obj from session
        /// </summary>
        /// <returns>Compare obj</returns>
        private CompareModel GetCompare()
        {
            CompareModel sess = (CompareModel)Session["Compare"];

            if (sess == null)
            {
                CompareModel compare = new CompareModel();
                Session["Compare"] = compare;
                return(compare);
            }
            else
            {
                return(sess);
            }
        }
Example #20
0
        public static CompareModel CompareCompanyUpsert(CompareModel CompareToUpsert)
        {
            if (CompareToUpsert != null &&
                CompareToUpsert.CompareId > 0 &&
                CompareToUpsert.RelatedProvider != null &&
                CompareToUpsert.RelatedProvider.Count > 0)
            {
                CompareToUpsert.RelatedProvider.
                Where(cmpc => cmpc.RelatedCompany != null &&
                      !string.IsNullOrEmpty(cmpc.RelatedCompany.CompanyPublicId)).
                All(cmpc =>
                {
                    LogManager.Models.LogModel oLog = Company.Controller.Company.GetGenericLogModel();

                    try
                    {
                        cmpc.CompareCompanyId = DAL.Controller.CompareDataController.Instance.CompareCompanyUpsert
                                                    (CompareToUpsert.CompareId,
                                                    cmpc.RelatedCompany.CompanyPublicId,
                                                    cmpc.Enable);

                        oLog.IsSuccess = true;
                    }
                    catch (Exception err)
                    {
                        oLog.IsSuccess = false;
                        oLog.Message   = err.Message + " - " + err.StackTrace;

                        throw err;
                    }
                    finally
                    {
                        oLog.LogObject = cmpc;

                        oLog.RelatedLogInfo.Add(new LogManager.Models.LogInfoModel()
                        {
                            LogInfoType = "CompareId",
                            Value       = CompareToUpsert.CompareId.ToString(),
                        });

                        LogManager.ClientLog.AddLog(oLog);
                    }
                    return(true);
                });
            }

            return(CompareToUpsert);
        }
        public RedirectToRouteResult DeleteItem(int position)
        {
            CompareModel model = GetCompare();

            switch (position)
            {
            case 1:
                model.Item1 = null;
                break;

            case 2:
                model.Item2 = null;
                break;
            }

            return(RedirectToAction("List", "Goods"));
        }
        public ActionResult Compare(CompareModel compareFiles)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    string clientFileName = null, bankFileName = null, sessionId;
                    if (compareFiles.ClientMarkOffFile.ContentLength > 0 && compareFiles.BankMarkOfffile.ContentLength > 0)
                    {
                        clientFileName = Path.GetFileName(compareFiles.ClientMarkOffFile.FileName);
                        sessionId      = SessionIdGenerator.CreateNewId();


                        ParserResult result = _csvFileReader.Validate(compareFiles.ClientMarkOffFile.InputStream);
                        if (!result.IsValid)
                        {
                            ModelState.AddModelError("ClientMarkOffFile", result.Errors[1]);
                            return(View());
                        }
                        else
                        {
                            _markOffFileProvider.SaveMarkOffFile(compareFiles.ClientMarkOffFile.InputStream, sessionId, clientFileName);
                        }

                        result = _csvFileReader.Validate(compareFiles.BankMarkOfffile.InputStream);
                        if (!result.IsValid)
                        {
                            ModelState.AddModelError("BankMarkOfffile", result.Errors[1]);
                            return(View());
                        }
                        else
                        {
                            bankFileName = Path.GetFileName(compareFiles.BankMarkOfffile.FileName);
                            _markOffFileProvider.SaveMarkOffFile(compareFiles.BankMarkOfffile.InputStream, sessionId, bankFileName);
                        }
                        return(RedirectToAction("compareresult", new { sid = sessionId, cfn = clientFileName, tfn = bankFileName }));
                    }
                }

                return(View());
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #23
0
        public ActionResult StoreCase(FormCollection form)
        {
            var key = Int64.Parse(Session["IdfCase"].ToString());

            form.AllKeys.ToList().ForEach(k => form[k] = EidssWebHelper.UnescapeHtml(form[k]));
            var    vetCase = (VetCase)ModelStorage.Get(Session.SessionID, key, null);
            string errorMessage;
            bool   isDatesValid = DateTimeHelper.TryParseCustomDates(form, out errorMessage);
            var    data         = new CompareModel();

            if (!isDatesValid)
            {
                data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false);
                return(new JsonResult {
                    Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }

            bool isNumericValid = NumericHelper.TryParseInteger(form, out errorMessage);

            if (!isNumericValid)
            {
                data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false);
                return(new JsonResult {
                    Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }

            m_validation        = null;
            vetCase.Validation += vc_ValidationDetails;
            vetCase.ParseFormCollection(form);
            if (m_validation != null)
            {
                vetCase.Validation -= vc_ValidationDetails;
                errorMessage        = Translator.GetErrorMessage(m_validation);
                data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false);
                return(new JsonResult {
                    Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }

            return(new JsonResult {
                Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Example #24
0
        public CompareModel GetCompare(string start, string end)
        {
            string name1, name2;
            var    commit1 = GetCommitByPath(ref start, out name1);
            var    commit2 = GetCommitByPath(ref end, out name2);

            if (commit1 == null)
            {
                commit1 = _repository.Head.Tip;
                name1   = _repository.Head.FriendlyName;
            }
            if (commit2 == null)
            {
                commit2 = _repository.Head.Tip;
                name2   = _repository.Head.FriendlyName;
            }

            var walks = _repository.Commits
                        .QueryBy(new CommitFilter
            {
                IncludeReachableFrom = commit2,
                ExcludeReachableFrom = commit1,
                SortBy = CommitSortStrategies.Time
            })
                        .Select(s => new CommitModel
            {
                Sha                = s.Sha,
                Committer          = s.Committer,
                CommitMessageShort = s.MessageShort.RepetitionIfEmpty(UnknowString),
            })
                        .ToArray();

            var fromBranchSelector = GetBranchSelectorModel(name1, commit1.Sha, null);
            var toBranchSelector   = GetBranchSelectorModel(name2, commit2.Sha, null);
            var model = new CompareModel
            {
                BaseBranchSelector    = fromBranchSelector,
                CompareBranchSelector = toBranchSelector,
                CompareResult         = ToCommitModel(commit1, name1, true, "", commit2.Tree),
                Walks = walks,
            };

            return(model);
        }
Example #25
0
        public async Task <IActionResult> SkillCompare(string login)
        {
            if (login == null)
            {
                return(NotFound());
            }

            var employee = await _context.Employee
                           .Include(e => e.EmployeeRole)
                           .Include(e => e.Rank)
                           .Include(e => e.EmployeeAccount)
                           .Include(e => e.EmployeeMentorsIntern).ThenInclude(m => m.Mentor).ThenInclude(m => m.EmployeeAccount)
                           .Include(e => e.EmployeeMentorsMentor).ThenInclude(m => m.Intern).ThenInclude(m => m.EmployeeAccount)
                           .Include(e => e.EmployeeSkillValue).ThenInclude(s => s.Skill).ThenInclude(s => s.SkillValue)
                           .FirstOrDefaultAsync(e => e.EmployeeAccount.Login == login);

            if (employee == null)
            {
                return(NotFound());
            }
            var          employeeRankSeq = _context.EmployeeRank.Where(u => u.EmployeeRankId == employee.RankId + 1).Include(u => u.SkillValueRank).ThenInclude(u => u.Skill).ThenInclude(u => u.SkillValue);
            EmployeeRank employeeRank;

            if (employeeRankSeq.Count() <= 0)
            {
                employeeRank = _context.EmployeeRank.Where(u => u.EmployeeRankId == employee.RankId).Include(u => u.SkillValueRank).ThenInclude(u => u.Skill).ThenInclude(u => u.SkillValue).First();
            }
            else
            {
                employeeRank = _context.EmployeeRank.Where(u => u.EmployeeRankId == employee.RankId + 1).Include(u => u.SkillValueRank).ThenInclude(u => u.Skill).ThenInclude(u => u.SkillValue).First();
            }
            if (employeeRank == null)
            {
                return(NotFound());
            }
            var ComparerModel = new CompareModel
            {
                employeeProfile = employee,
                compRank        = employeeRank
            };

            return(View(ComparerModel));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="frmValidator"/> class.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="data">The data.</param>
        public frmValidator(CompareModel model, DataSourceModel data) : this()
        {
            this.model              = model;
            this.dataSource         = data;
            gridControl1.DataSource = data.SelectedSchema().Fields;
            gridView1.BestFitWidth(false, true);
            RefreshSummary();
            this.Text = data.DataSource.GetConnectionStringBuilder()["Data Source"]?.ToString();
            gridControl3.DataSource = eventItems.ToList();

            QueryBuilder query = model.Source.DataSource.GetQueryBuilder();

            if (string.IsNullOrEmpty(data.SelectedSchema().Query))
            {
                data.SelectedSchema().Query = query.BuildSql(model.Source,
                                                             data.SelectedSchema().Fields.Select(s => s.Name).ToArray(), null, null);
            }
            memoEdit1.Text     = data.SelectedSchema().Query.Replace("\r\n", "\n").Replace("\n", "\r\n");
            memoEdit1.ReadOnly = true;
        }
Example #27
0
        public ActionResult StoreContactDetails(FormCollection form)
        {
            var    key = Int64.Parse(form["idfContactedCasePerson"]);
            var    contactedCasePerson = (ContactedCasePerson)ModelStorage.Get(Session.SessionID, key, null);
            string errorMessage;
            bool   isDatesValid = DateTimeHelper.TryParseCustomDates(form, out errorMessage);
            var    data         = new CompareModel();

            if (!isDatesValid)
            {
                data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false);
            }
            else
            {
                contactedCasePerson.ParseFormCollection(form);
            }
            return(new JsonResult {
                Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Example #28
0
 public ActionResult Index(CompareModel model)
 {
     if (ModelState.IsValid)
     {
         CapitalCalculator calc = new CapitalCalculator
         {
             Money   = model.Money,
             Percent = model.Percent
         };
         string[] dates = model.Range.Split('-');
         calc.StartDate = DateTime.ParseExact(dates[0], "MM/dd/yyyy ", CultureInfo.InvariantCulture);
         calc.StopDate  = DateTime.ParseExact(dates[1], " MM/dd/yyyy", CultureInfo.InvariantCulture);
         var result = calc.GetIncome(FundList);
         ViewBag.depositIncome = result.Item2;
         ViewBag.fundIncome    = result.Item1;
         ViewBag.chart         = calc.Chart;
         return(View(model));
     }
     return(View(model));
 }
        public ActionResult AddProduct(int id)
        {
            Product product = db.Products.Find(id);  // tim sp theo sanPhamID
            var     com     = Session[CompareSession];

            if (com != null)
            {
                var list = (List <CompareModel>)com;
                if (!list.Exists(x => x.Product.ProductId == id))
                {
                    //tạo mới so sánh nếu chưa có
                    var item = new CompareModel();
                    item.Product = product;
                    //if (count >= 2)
                    //{
                    //    list.RemoveAt(0);
                    //    list.Add(item);
                    //    count++;
                    //}
                    if (count < 2)
                    {
                        list.Add(item);
                        count++;
                    }
                }
                //gán vào session
                Session[CompareSession] = list;
            }
            else
            {
                //tạo mới so sánh nếu chưa có
                var item = new CompareModel();
                item.Product = product;
                var list = new List <CompareModel>();
                list.Add(item);
                count++;
                //gán vào session
                Session[CompareSession] = list;
            }
            return(RedirectToAction("Index"));
        }
        public void Test_SetupComparison()
        {
            ExcelDbConnectionStringBuilder builder1 = new ExcelDbConnectionStringBuilder(@".\dm_document1.xlsx");
            ExcelDataSource dql1   = new ExcelDataSource(builder1.ConnectionString);
            var             source = dql1.GetSchemaModel("Sheet1$");

            ExcelDbConnectionStringBuilder builder2 = new ExcelDbConnectionStringBuilder(@".\dm_document3.xlsx");
            ExcelDataSource dql2   = new ExcelDataSource(builder2.ConnectionString);
            var             target = dql2.GetSchemaModel("Sheet1$");

            var model = new CompareModel();
            //model.Source.DataSource = dql1;
            //model.Source.TableSchemas = source;
            //model.Source.SelectedTable = "Sheet1$";
            //model.Target = dsl2;
            //model.Target.TableSchemas = target;
            //model.Target.SelectedTable = "Sheet1$";


            var pairs = source.Fields.
                        Join(target.Fields,
                             s => new { s.Name },
                             t => new { t.Name },
                             (s, t) => new CompareMappingModel(s.Name, t.Name)
                             ).ToList();

            //  model.ColumnCompare = pairs;


            //QueryBuilder query = new QueryBuilder();
            //var select1 = query.BuildSql("r_object_id", pairs.Select(s=> s.LeftSide.Field).ToArray(), "Sheet1$", "left");
            //var select2 = query.BuildSql("r_object_id", pairs.Select(s => s.RightSide.Field).ToArray(), "Sheet1$", "right");

            //var t1 = dql1.ExecuteQuery(select1).Tables[0];
            //var t2 = dql2.ExecuteQuery(select2).Tables[0];
            //t1.SetPrimaryKey(Alias.Primary_Key, t2);
            //t1.Merge(t2);
            //TODO: order columns
            //TODO Now we should do the compare.
            //Next Dump to Excel? or do we do the compare within excel
        }