示例#1
0
        public ActionResult CompareProduct(long proId, long proId1, int subcatid)
        {
            var temperatory = new CompareService();

            var table = from t1 in temperatory.Summary() where t1.ProductId == proId select t1;

            var table1    = from t1 in temperatory.Summary() where t1.ProductId == proId1 select t1;
            var templist  = table.ToList().ToList();
            var templist1 = table1.ToList().ToList();

            List <CompareProducts> objproductinfo = new List <CompareProducts>();
            CompareProducts        tempproduct1   = new CompareProducts();
            CompareProducts        tempproduct2   = new CompareProducts();

            tempproduct1 = templist[0];
            tempproduct2 = templist1[0];
            objproductinfo.Add(tempproduct1);
            objproductinfo.Add(tempproduct2);
            var temp = objproductinfo.ToList();

            if (subcatid == 21)
            {
                return(View("FanCompare", objproductinfo.ToList()));
            }
            else if (subcatid == 22)
            {
                return(View("VaccumCompare", objproductinfo.ToList()));
            }
            else
            {
                return(View("ToasterCompare", objproductinfo.ToList()));
            }
        }
        protected void Session_End()
        {
            /* Close Compare Server Connection */
            CompareService cs = new CompareService(new HttpSessionStateWrapper(this.Session));

            cs.Close();
        }
//        [HttpPost]
        public ActionResult Results(ComparerModel model)
        {
            /* Set Original document Path */
//            JavaScriptSerializer serializer = new JavaScriptSerializer();
            ComparerResultModel result = new ComparerResultModel();

            if (ModelState.IsValid)
            {
                CompareService cs  = new CompareService(Session);
                ComparerResult res = new ComparerResult();
                try
                {
                    res = cs.DoComparison(HttpContext.User, model.GetComparerArguments(UploadPath));
                }
                catch (Exception ex)
                {
                    Log.Write(TraceEventType.Stop, "Upload Controller, Results | Exception {0}", ex);
                    res.Errors.Add(ex.Message);
                }
                result = new ComparerResultModel(res);
                //return Json(new { success = true, results = serializer.Serialize(new ComparerResultModel(res))}, "application/json");
            }
            else
            {
                result.Errors.Add("Input values is not filled or is not valid");
                //return Json(new { success = false, message = serializer.Serialize(result) }, "application/json");
            }
            return(View(result));
        }
        public string GroupLessonCompare(string groupFirst, string groupSecond)
        {
            throw new NotImplementedException();
            var repository = new ServerStorageRepository();

            var compare = new CompareService(repository.GetLessonList(groupFirst),
                                             repository.GetLessonList(groupSecond));
        }
示例#5
0
    public override void load(object sender, EventArgs e)
    {
        string sku1 = Request.Params["sku0"];
        string sku2 = Request.Params["sku1"];
        string sku3 = Request.Params["sku2"];
        string sku4 = Request.Params["sku3"];

        compDT = CompareService.getDTBySKUs(sku1, sku2, sku3, sku4);
    }
示例#6
0
 public PriceCompareForm()
 {
     InitializeComponent();
     _compareService = new CompareService(
         new ParserFactory(new ParseInputRowService()),
         new ComparePriceTableService(),
         new CreateResultFileService()
         );
 }
示例#7
0
        /// <summary>
        /// 计算时间
        /// </summary>
        private static void TestTime()
        {
            TempTestService ts = new TempTestService();

            ts.DateDiff(); //时间差
            ts.TestJson(); //位运算
            CompareService cs = new CompareService();

            cs.DoService();
        }
示例#8
0
    public string getSizes(string sku)
    {
        DataTable dt    = CompareService.getSizeDTBySKUs(sku);
        String    sizes = "";

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            sizes += "," + dt.Rows[i]["Size"];
        }
        return(sizes.Length > 1 ? sizes.Substring(1, sizes.Length - 1) : "N/A");
    }
示例#9
0
    public string getColor(string sku)
    {
        DataTable dt     = CompareService.getColorsDTBySKUs(sku);
        String    colors = "";

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            colors += "," + dt.Rows[i]["Color"];
        }
        return(colors.Length > 1 ? colors.Substring(1, colors.Length - 1) : "N/A");
    }
示例#10
0
        private void InitService(AccessService accessService, String projectId)
        {
            this.compareService    = new CompareService(accessService, projectId);
            this.detectService     = new DetectService(accessService, projectId);
            this.faceService       = new FaceService(accessService, projectId);
            this.faceSetService    = new FaceSetService(accessService, projectId);
            this.liveDetectService = new LiveDetectService(accessService, projectId);
            this.qualityService    = new QualityService(accessService, projectId);
            this.searchService     = new SearchService(accessService, projectId);

            this.apiCollectionV2 = new ApiCollectionV2(accessService, projectId);
        }
示例#11
0
 public DeveloperController(
     CourseService courseService, LanguageService languageService,
     ProblemDescriptionService problemDescriptionService,
     CompareService compareService, IHttpContextAccessor httpContextAccessor,
     ILogger <DeveloperController> logger, UserService userService, AppOptions appOptions)
 {
     _courseService             = courseService;
     _languageService           = languageService;
     _problemDescriptionService = problemDescriptionService;
     _compareService            = compareService;
     _logger      = logger;
     _userService = userService;
     _appOptions  = appOptions;
 }
示例#12
0
 public CoursesController(
     CourseService courseService, LanguageService languageService,
     ProblemDescriptionService problemDescriptionService, AppOptions appOptions,
     CompareService compareService, IHttpContextAccessor httpContextAccessor, UserService userService,
     UtilService utilService, Courses courses)
 {
     _courseService             = courseService;
     _languageService           = languageService;
     _problemDescriptionService = problemDescriptionService;
     _appOptions     = appOptions;
     _compareService = compareService;
     _userService    = userService;
     _utilService    = utilService;
     _courses        = courses;
 }
示例#13
0
 public AdminController(
     CourseService courseService, LanguageService languageService,
     ProblemDescriptionService problemDescriptionService,
     CompareService compareService, IHttpContextAccessor httpContextAccessor,
     ILogger <AdminController> logger, UserService userService, AppOptions appOptions, ServerStatus serverStatus)
 {
     _courseService             = courseService;
     _languageService           = languageService;
     _problemDescriptionService = problemDescriptionService;
     _compareService            = compareService;
     _logger       = logger;
     _userService  = userService;
     _appOptions   = appOptions;
     _serverStatus = serverStatus;
 }
示例#14
0
        public ActionResult Ping()
        {
            CompareService service = new CompareService(this.Session);

            try
            {
                service.Ping();
                return(Json(new { success = true, ping = "ping success" }, "application/json"));
            }
            catch (Exception ex)
            {
                Log.Write(TraceEventType.Stop, "Home Controller, Ping | Exception {0}", ex);
                return(Json(new { success = false, ping = "ping failed", message = ex.Message }, "text/json"));
            }
        }
示例#15
0
 public StatsController(
     CourseService courseService, LanguageService languageService, IDbService dbService,
     ProblemDescriptionService problemDescriptionService, AppOptions appOptions,
     CompareService compareService, IHttpContextAccessor httpContextAccessor, UserService userService,
     UtilService utilService, ILogger <StatsController> logger)
 {
     _courseService             = courseService;
     _languageService           = languageService;
     _dbService                 = dbService;
     _problemDescriptionService = problemDescriptionService;
     _appOptions                = appOptions;
     _compareService            = compareService;
     _userService               = userService;
     _utilService               = utilService;
     _logger = logger;
 }
示例#16
0
        public void TestInit()
        {
            _moqer = new AutoMoqer();

            _moqer.GetMock <IRepository>()
            .Setup(m => m.UpdateLeft(It.IsAny <int>(), It.IsAny <string>()))
            .Returns(Task.FromResult(0));
            _moqer.GetMock <IRepository>()
            .Setup(m => m.UpdateRight(It.IsAny <int>(), It.IsAny <string>()))
            .Returns(Task.FromResult(0));
            _moqer.GetMock <IUnitOfWork>()
            .Setup(m => m.B64ComparerRepository)
            .Returns(_moqer.GetMock <IRepository>().Object);

            _service = _moqer.Create <CompareService>();
        }
示例#17
0
        private static void Init(string[] args)
        {
            _config = new AppConfigModelProvider();
            _pages  = _config.GetPages().ToList();
            _config.GetCustomPageProviders()
            .ToList()
            .ForEach(x => _pages.AddRange(x.GetPages()));

            var sources = _config.GetSource();

            _compareService = new CompareService(
                _config.GetComparers(),
                _config.GetCheckers(),
                sources.First(x => x.CompareRole == CompareRole.Origin),
                sources.First(x => x.CompareRole == CompareRole.Target)
                );
        }
示例#18
0
        public ActionResult TestConnection()
        {
            CompareService service = new CompareService(this.Session);
            string         serviceVersion;
            string         comparisonVersion;

            try
            {
                service.GetVersions(out serviceVersion, out comparisonVersion);
                return(Json(new { success = true, service = serviceVersion, comparison = comparisonVersion }, "application/json"));
            }
            catch (Exception ex)
            {
                Log.Write(TraceEventType.Stop, "Home Controller, TestConnection | Exception {0}", ex);
                return(Json(new { success = false, service = "", comparison = "", message = ex.Message }, "text/json"));
            }
        }
示例#19
0
        private ICompareService CreateComparer(TransportProtocolEnum transport)
        {
            switch (transport)
            {
            case TransportProtocolEnum.Http:
                return(CompareService.CreateHttpService("localhost", 8080));

            case TransportProtocolEnum.NamedPipe:
                return(CompareService.CreateNamedPipeService());

            case TransportProtocolEnum.Tcp:
                return(CompareService.CreateTcpService("localhost", 8090));

            default:
                return(null);
            }
        }
示例#20
0
        /// <summary>
        /// Create appropriate service based on protocol specified by the user. Its safe to assume that this
        /// page will always be running on the same machine as the service.
        /// </summary>
        /// <param name="protocol"></param>
        /// <returns></returns>
        private ICompareService CreateAppropriateService(TransportProtocolEnum protocol)
        {
            switch (protocol)
            {
            case TransportProtocolEnum.Tcp:
                _divideFactor = 1;
                return(CompareService.CreateTcpService("localhost", Int32.Parse(System.Configuration.ConfigurationSettings.AppSettings["tcp_port"])));

            case TransportProtocolEnum.NamedPipe:
                _divideFactor = 10;
                return(CompareService.CreateNamedPipeService());

            case TransportProtocolEnum.Http:
            default:
                _divideFactor = 1;
                return(CompareService.CreateHttpService("localhost", Int32.Parse(System.Configuration.ConfigurationSettings.AppSettings["http_port"])));
            }
        }
    public async Task GetDuplicates()
    {
        // Given
        const string file1          = "file1";
        const string file2          = "file2";
        const string file3          = "file3";
        const string file4          = "file4";
        const string file5          = "file5";
        const string file6          = "file6";
        var          compareService = new CompareService(_fileSystemService, _fileDetailService);

        _fileDetailService.GetContentHash(file1, true).Returns("SHA");
        _fileDetailService.GetContentHash(file2, true).Returns("OTHER SHA");
        _fileDetailService.GetContentHash(file3, true).Returns("SHA");
        _fileDetailService.GetContentHash(file4, true).Returns("SHA");
        _fileDetailService.GetContentHash(file5).Returns("SHA2");
        _fileDetailService.GetContentHash(file6).Returns("SHA2");

        _fileSystemService.GetFileLength(file1).Returns(42);
        _fileSystemService.GetFileLength(file2).Returns(42);
        _fileSystemService.GetFileLength(file3).Returns(42);
        _fileSystemService.GetFileLength(file4).Returns(4);
        _fileSystemService.GetFileLength(file5).Returns(33);
        _fileSystemService.GetFileLength(file6).Returns(33);

        // When
        compareService.AddFile(file1);
        compareService.AddFile(file2);
        compareService.AddFile(file3);
        compareService.AddFile(file3);
        compareService.AddFile(file4);
        compareService.AddFile(file5);
        compareService.AddFile(file6);

        var actual = await compareService.GetGroupedDuplicates();

        // Then
        Assert.True(actual[0].Count == 2);
        Assert.True(actual[1].Count == 2);
        Assert.True(actual[0][0].FileName == "file1");
        Assert.True(actual[0][1].FileName == "file3");
        Assert.True(actual[1][0].FileName == "file5");
        Assert.True(actual[1][1].FileName == "file6");
    }
        /// <summary>
        /// Create and returns appropriate service object based upon protocol selected in config file
        /// </summary>
        /// <returns></returns>
        private ICompareService CreateAppropriateService()
        {
            var serviceUrl = ConfigurationManager.AppSettings["url.address"];
            var binding    = ConfigurationManager.AppSettings["transport.binding"];
            var security   = ConfigurationManager.AppSettings["transport.security"];
            var transport  = ConfigurationManager.AppSettings["transport.clientsecurity"];
            var message    = ConfigurationManager.AppSettings["message.clientsecurity"];

            switch (_protocol)
            {
            default:
            case TransportProtocolEnum.Http:
                return(CompareService.CreateHttpService(_host, _port, serviceUrl, binding, security, transport, message));

            case TransportProtocolEnum.NamedPipe:
                return(CompareService.CreateNamedPipeService());

            case TransportProtocolEnum.Tcp:
                return(CompareService.CreateTcpService(_host, _port));
            }
        }
        public ActionResult File(string fileName)
        {
            string ClientName = string.Empty;
            string ServerName = string.Empty;

            try
            {
                Stream stream = null;
                if (Request.ContentType.Contains(@"multipart/form-data"))
                {   // IE
                    HttpPostedFileBase postedFile = Request.Files[0];
                    stream     = postedFile.InputStream;
                    ClientName = Request.Files[0].FileName;
                }
                else if (Request.ContentType.Contains("application/octet-stream"))
                {   // Webkit, Mozilla
                    stream     = Request.InputStream;
                    ClientName = Request.QueryString["qqfile"];
                }
                else
                {
                    throw new Exception("Unsupported ContentType");
                }
                var buffer = new byte[stream.Length];
                stream.Read(buffer, 0, buffer.Length);
                ServerFile sf = new CompareService(Session).storeFileOnServer(buffer, ClientName);
                ServerName = sf.ServerName;
            }
            catch (System.IO.IOException ex)
            {
                Log.Write(TraceEventType.Stop, "Upload Controller, File | Exception {0}", ex);
                return(Json(new { success = false, message = ex.Message }, "text/html"));
            }
            catch (Exception ex)
            {
                Log.Write(TraceEventType.Stop, "Upload Controller, File | Exception {0}", ex);
                return(Json(new { success = false, message = ex.Message }, "text/html"));
            }
            return(Json(new { success = true, file = ServerName }, "text/html"));
        }
示例#24
0
        private string GetJsonString(string tableName, string queryString)
        {
            SaveCompareServiceRequest request = new SaveCompareServiceRequest();

            request.model               = new CompareServiceModelType();
            request.model.keys          = new CompareServiceKeysType();
            request.model.instance      = new CompareServiceInstanceType();
            request.model.instance.Name = new StringType {
                Value = tableName
            };
            request.model.instance.QueryString = new StringType {
                Value = queryString
            };
            CompareService    compareService  = new CompareService();
            CredentialCache   credentialCache = new CredentialCache();
            NetworkCredential credentials     = new NetworkCredential("ASIAPACIFIC_DAIZHEN", "", "");

            credentialCache.Add(new Uri(compareService.Url), "Basic", credentials);
            compareService.Credentials = credentialCache;

            XmlSerializer ser       = new XmlSerializer(request.GetType());
            MemoryStream  memstream = new MemoryStream();

            ser.Serialize(memstream, request);
            memstream.Seek(0, SeekOrigin.Begin);
            var buffer = new byte[memstream.Length];

            memstream.Read(buffer, 0, (int)memstream.Length);

            string requestXML = Encoding.UTF8.GetString(buffer);

            memstream.Close();


            var response = compareService.SaveCompareService(request);

            return(response.model.instance.Content.Value);
        }
 public void Equals_NumberIsEqualAmountNotEqual_ReturnFalse()
 {
     //arrange
     var compare = new CompareService();
     var caiWu = new CaiWuItem
     {
         CreditAmount = 4800.7d,
         VoucherNumber = "Z01380",
         VoucherDate = "2015-10-26",
         Remark = "付福州迈新生物技术开发有限公司科研材料款"
     };
     var guoKu = new GuoKuItem
     {
         Amount = 4800.6d,
         CreateDate = "2015-10-29",
         PaymentNumber = "1516671935",
         RemarkReason = "材料款1380#"
     };
     //act
     var actual = compare.Equals(caiWu, guoKu);
     //assert
     Assert.AreEqual(false, actual);
 }
示例#26
0
 public PlagiarismController(IDbService dbService, CompareService compareService)
 {
     _dbService      = dbService;
     _compareService = compareService;
 }
 public ActionResult StopServcie()
 {
     return(Json(new { success = true, status = CompareService.StopService() }));
 }
 public ActionResult GetServiceStatus()
 {
     return(Json(new { success = true, status = CompareService.GetServiceStatus() }));
 }
示例#29
0
 public void TestInit()
 {
     Service = new CompareService(uow.Object, CPUs.Object, GPUs.Object, Mapper);
 }
        protected void Session_Start()
        {
            CompareService cs = new CompareService(new HttpSessionStateWrapper(this.Session));

            cs.StoreClientInSession = true;
        }
示例#31
0
 public DeltaModel(ILogger <DeltaModel> logger, CompareService compareService)
 {
     _logger         = logger;
     _compareService = compareService;
 }