public void InitBatch(UserConfigModel config, string outputPath)
        {
            _batchItems = new List <BatchItemModel>();

            config.ImageModels.Sort(ImageComparison.ImageModelComparison);

            for (int i = 0; i < config.ImageModels.Count; i++)
            {
                var imageModel = config.ImageModels[i];
                imageModel.SortOrder = i;

                var inputFile  = _mapper.Map <ImageProcessModel>(imageModel);
                var outputFile = _mapper.Map <ImageProcessModel>(imageModel);
                outputFile.DirectoryPath = outputPath;
                outputFile.FileSize      = 0;
                outputFile.SortOrder     = i;
                outputFile.Extension     = config.OutputFileExtension;
                outputFile.FileName      = inputFile.FileName;

                outputFile.FileName = outputFile.FileName.Replace(inputFile.Extension, outputFile.Extension);
                outputFile.FilePath = Path.Combine(outputFile.DirectoryPath, outputFile.FileName);

                var batchItem = new BatchItemModel(inputFile, outputFile);
                _batchItems.Add(batchItem);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UserConfigService"/> class.
 /// </summary>
 /// <param name="mapper">The mapper.</param>
 /// <param name="userConfigRepository">The user configuration repository.</param>
 public UserConfigService(IMapper mapper, UserConfigRepository userConfigRepository)
 {
     _mapper = mapper;
     _userConfigRepository = userConfigRepository;
     _userConfig           = CreateDefaultConfig();
     CreateOutputDir(_userConfig.OutputDirectory);
 }
 private void Userconfig_Load(object sender, EventArgs e)
 {
     UserConfigPath = @"./Files/UserConfig.json";
     if (File.Exists(UserConfigPath))
     {
         userconfig            = JsonConvert.DeserializeObject <UserConfigModel>(File.ReadAllText(UserConfigPath));
         txtToMailAddress.Text = userconfig.ToMailAddress = EncodeMD5.DecryptString(userconfig.ToMailAddress, "ITFramasBDVN");
         txtCCMailAddress.Text = userconfig.CCMailAddress = EncodeMD5.DecryptString(userconfig.CCMailAddress, "ITFramasBDVN");
         txtMaterial.Text      = EncodeMD5.DecryptString(userconfig.Mixing_Material_BoxWeight.ToString(), "ITFramasBDVN");
         userconfig.Mixing_Material_BoxWeight = txtMaterial.Text;
         txtRecycle.Text = EncodeMD5.DecryptString(userconfig.Mixing_Recycle_BoxWeight.ToString(), "ITFramasBDVN");
         userconfig.Mixing_Recycle_BoxWeight = txtRecycle.Text;
         txtIncoming.Text = EncodeMD5.DecryptString(userconfig.Incoming_BoxWeight.ToString(), "ITFramasBDVN");
         userconfig.Incoming_BoxWeight = txtIncoming.Text;
         txtCrushing.Text = EncodeMD5.DecryptString(userconfig.Crushing_BoxWeight.ToString(), "ITFramasBDVN");
         userconfig.Crushing_BoxWeight = txtCrushing.Text;
     }
     else
     {
         userconfig            = new UserConfigModel();
         txtToMailAddress.Text = userconfig.ToMailAddress = "*****@*****.**";
         txtCCMailAddress.Text = userconfig.CCMailAddress = "*****@*****.**";
         txtMaterial.Text      = userconfig.Mixing_Material_BoxWeight = "0.16";
         txtRecycle.Text       = userconfig.Mixing_Recycle_BoxWeight = "1.14";
         txtIncoming.Text      = userconfig.Incoming_BoxWeight = "2.1966";
         txtCrushing.Text      = userconfig.Crushing_BoxWeight = "1.14";
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// 保存用户配置信息
        /// </summary>
        /// <param name="model"></param>
        public void SaveConfig(UserConfigModel model)
        {
            var dir    = GetConfigFileDir(AppFolderName);
            var folder = Path.Combine(dir, model.UserId.ToString(CultureInfo.InvariantCulture));

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            var filePath = Path.Combine(folder, UserConfigFileName);

            XmlSerializerUtil.SaveToXml(filePath, model, typeof(UserConfigModel));
        }
Exemplo n.º 5
0
 public FrmUserConfig(UserConfigModel userConfig) : this()
 {
     this.Model = CopyUtil.DeepCopy(userConfig);
     if (!this.mvvmContext1.IsDesignMode)
     {
         if (this.Model == null)
         {
             this.Model = new UserConfigModel();
         }
         this.mvvmContext1.SetViewModel(typeof(UserConfigModel), this.Model);
         InitializeBindings();
         InitializeBindings();
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// 加载所有用户配置
        /// </summary>
        /// <returns></returns>
        private void InitUserConfig()
        {
            UserConfigHelper.AppFolderName = AssemblyInfoHelper.Product + "\\";
            var configHepler = UserConfigHelper.GetInstence();

            _config = configHepler.LoadLastUserConfig();

            if (_config != null)
            {
                UserName      = _config.UserName;
                IsRememberPwd = Convert.ToBoolean(_config.RememberPwd);
                if (IsRememberPwd)
                {
                    //生成密钥
                    _key = AecDesCrypto.GenerateKey();
                    //解密
                    UserPwd = AecDesCrypto.Decrypt(_config.UserPwd, _key);
                }
                IsAutoLogin = Convert.ToBoolean(_config.AutoLogin);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 获取最后登录的用户配置
        /// </summary>
        /// <returns></returns>
        public UserConfigModel LoadLastUserConfig()
        {
            var config = new UserConfigModel();

            var configs   = LoadAllConfigs(UserConfigFileName, typeof(UserConfigModel));
            var lastTimes = new List <DateTime>();

            foreach (var model in configs)
            {
                if (model.LastLoginTime != null)
                {
                    lastTimes.Add(Convert.ToDateTime(model.LastLoginTime));
                }
            }

            if (lastTimes.Count > 0)
            {
                lastTimes.Sort();
                var strTime = lastTimes[lastTimes.Count - 1].ToString(CultureInfo.InvariantCulture);
                config = configs.FirstOrDefault(p => p.LastLoginTime == strTime);
            }

            return(config);
        }
        /// <summary>
        /// Constructor for the Application object.
        /// </summary>
        public App()
        {
            // Global handler for uncaught exceptions.
            UnhandledException += Application_UnhandledException;

            // Standard Silverlight initialization
            InitializeComponent();

            // Phone-specific initialization
            InitializePhoneApplication();

            // Show graphics profiling information while debugging.
            if (System.Diagnostics.Debugger.IsAttached)
            {
                // Display the current frame rate counters.
                Application.Current.Host.Settings.EnableFrameRateCounter = true;

                // Show the areas of the app that are being redrawn in each frame.
                //Application.Current.Host.Settings.EnableRedrawRegions = true;

                // Enable non-production analysis visualization mode,
                // which shows areas of a page that are being GPU accelerated with a colored overlay.
                //Application.Current.Host.Settings.EnableCacheVisualization = true;

                // Disable the application idle detection by setting the UserIdleDetectionMode property of the
                // application's PhoneApplicationService object to Disabled.
                // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
                // and consume battery power when the user is not using the phone.
                PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            }

            //Retrieves locale of the mobile device
            CurrentCulture = Thread.CurrentThread.CurrentCulture.ToString();
            CurrentUICulture = Thread.CurrentThread.CurrentUICulture.ToString();

            var uris = new[]
            {
                GetThemeSettingsUri()
            };

            LoadResources(uris);

            //Creates an instance of the Diagnostics component.
            diagnostics = new RadDiagnostics();

            //Defines the default email where the diagnostics info will be send.
            diagnostics.EmailTo = "*****@*****.**";

            //Initializes this instance.
            diagnostics.Init();

              //Creates a new instance of the RadRateApplicationReminder component.
            rateReminder = new RadRateApplicationReminder();

            //Sets how often the rate reminder is displayed.
            rateReminder.RecurrencePerUsageCount = 2;

            IsTrackImageLoad = false;
            AppVersion = "";

            DataTracker = new Tracker();
            DataTracker.RegisterNewDeviceIfNotAlready();

            DownloadCloudAppConfig();
            //LoadDefaultCloudAppConfig();

            _analytics = Analytics.GetInstance();
            //_timeLaunch = DateTime.Now;

            //Initialize user config
            var u = MiscHelpers.GetItemFromIsolatedStorage<UserConfigModel>("fbd-userconfig.xml");
            if (u == null)
            {
                u = new UserConfigModel
                    {
                        FetchLanguage = FetchLanguages.en,
                        FontSize = FontSizes.medium,
                        //FacebookLogin = FacebookLoginStatus.Logout,
                        FacebppkAccessToken = String.Empty,
                        IsTutorialRead = new int[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
                    };
                MiscHelpers.SaveDataToIsolatedStorage("fbd-userconfig.xml", u, typeof (UserConfigModel));

                //Set default hometiles and fetch the corrsponding context
                HomePagePinTiles.GetInstance().InitTiles();
            }
            DataFetcher dataFetcher2 = DataFetcher.GetInstance();
            dataFetcher2.FetchCategories(null);

            UserConfig.FetchLanguage = u.FetchLanguage;
            UserConfig.FontSize = u.FontSize;
            //UserConfig.FacebookLogin = u.FacebookLogin;
            //UserConfig.FacebppkAccessToken = u.FacebppkAccessToken;
            App.AccessToken = u.FacebppkAccessToken;
            UserConfig.IsTutorialRead = u.IsTutorialRead;
            if (UserConfig.IsTutorialRead == null)
            {
                u.IsTutorialRead = new int[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
                MiscHelpers.SaveDataToIsolatedStorage("fbd-userconfig.xml", u, typeof(UserConfigModel));
            }

            //Initialize categories config
            DataFetcher fetcher = DataFetcher.GetInstance();
            CategoryConfigA.Config = fetcher.GetCategoryConfig(
                new Uri("CategoryConfig_" + CultureSelector.GetCultureLocale(CurrentUICulture) + ".json", UriKind.Relative)
            );
            CategoryConfigB.Config = fetcher.GetCategoryConfig(
                new Uri("CategoryConfig_" + UserConfig.FetchLanguage + ".json", UriKind.Relative)
            );

            BackgroundWorker bw = new BackgroundWorker();
            bw.WorkerSupportsCancellation = true;
            bw.WorkerReportsProgress = true;
            bw.DoWork += delegate
            {
                //Initial file management
                //FileHelper.RemoveAllFeedBoardFiles();
                //Removed all feedboard cache files
                FileHelper.RemoveFeedBoardCaches();
                FileHelper.RemoveRedundantFeedBoardFiles();
                //FileHelper.ViewFiles();

                //Prefetcher
                DataFetcher dataFetcher = DataFetcher.GetInstance();
                dataFetcher.PreFetch();
            };
            bw.RunWorkerAsync();

            //Background agent
            BackgroundAgent b = new BackgroundAgent();
            //b.StartPeriodicAgent();
            b.StartResourceIntensiveAgent();
        }
Exemplo n.º 9
0
        private void frmConfigFirstInstall_Load(object sender, EventArgs e)
        {
            //try
            {
                // GetComPort();
                #region đọc textFile để lấy thông số cấu hình
                pathApp = $"{ Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)}\\Files\\DbServerParametter.txt";//get path
                // Debug.WriteLine(pathApp);

                dataArr = ReadFile(pathApp).Split('|');

                //giải mã MD5 các thồng số với pass giải mã là "ITFramasBDVN"
                serverName = txtServerName.Text = EncodeMD5.DecryptString(dataArr[0].Split(':')[1], "ITFramasBDVN");
                dbName     = txtDbName.Text = EncodeMD5.DecryptString(dataArr[1].Split(':')[1], "ITFramasBDVN");
                userName   = txtUserName.Text = EncodeMD5.DecryptString(dataArr[2].Split(':')[1], "ITFramasBDVN");
                password   = txtPassword.Text = EncodeMD5.DecryptString(dataArr[3].Split(':')[1], "ITFramasBDVN");

                configFirstInstall = dataArr[4].Split(':')[1];//kiểm tra biến này nếu =False là cài đặt đầu tiên, =True là đã cài đặt rồi cho vào thẳng form Login
                #endregion

                //gắn connection
                DataProvider.Instance.connectionStr = $"Data Source={serverName}" +
                                                      $";Database={dbName};UID={userName}" +
                                                      $";Password={password}; Min Pool Size=0;Max Pool Size=1000;Pooling=true; Connect Timeout=100;";

                txtDbName.Enabled     = false;
                txtServerName.Enabled = false;
                txtUserName.Enabled   = false;
                txtPassword.Enabled   = false;
                btnSend.Enabled       = false;
                //Cấu hình Mail server
                pathMailserverConfig = @"./Files/MailserverConfig.json";
                if (File.Exists(pathMailserverConfig))
                {
                    mailConfig = JsonConvert.DeserializeObject <MailConfig>(File.ReadAllText(pathMailserverConfig));
                    txtFromMailAddress.Text = mailConfig.FromMailAddress = EncodeMD5.DecryptString(mailConfig.FromMailAddress, "ITFramasBDVN");
                    txtMailPassword.Text    = mailConfig.Password = EncodeMD5.DecryptString(mailConfig.Password, "ITFramasBDVN");
                    txtHost.Text            = mailConfig.Host = EncodeMD5.DecryptString(mailConfig.Host, "ITFramasBDVN");
                    txtPort.Text            = mailConfig.Port = EncodeMD5.DecryptString(mailConfig.Port, "ITFramasBDVN");
                }
                else
                {
                    mailConfig = new MailConfig();
                    mailConfig.FromMailAddress = txtFromMailAddress.Text = "*****@*****.**";
                    mailConfig.Password        = txtMailPassword.Text = "san48Ngu#";
                    mailConfig.Host            = txtHost.Text = "smtp.office365.com";
                    mailConfig.Port            = txtPort.Text = "587";
                }

                //Cấu hình Scale IP
                pathScaleConfig = @"./Files/ScaleConfig.json";
                if (File.Exists(pathScaleConfig))
                {
                    scaleConfig       = JsonConvert.DeserializeObject <ScaleConfig>(File.ReadAllText(pathScaleConfig));
                    txtScaleIP.Text   = scaleConfig.ScaleIP = EncodeMD5.DecryptString(scaleConfig.ScaleIP, "ITFramasBDVN");
                    txtScalePort.Text = scaleConfig.ScalePort = EncodeMD5.DecryptString(scaleConfig.ScalePort, "ITFramasBDVN");
                }
                else
                {
                    scaleConfig           = new ScaleConfig();
                    scaleConfig.ScaleIP   = txtScaleIP.Text = "192.168.1.236";
                    scaleConfig.ScalePort = txtScalePort.Text = "23";
                }
                //Đọc cấu hình của User
                pathUserConfig = @"./Files/UserConfig.json";
                if (File.Exists(pathUserConfig))
                {
                    userConfig = JsonConvert.DeserializeObject <UserConfigModel>(File.ReadAllText(pathUserConfig));
                }
                //khi cài chương trình chạy dầu tiên thì vào cấu hình DB server
                if (configFirstInstall == "True")
                {
                    txtDbName.Enabled     = true;
                    txtServerName.Enabled = true;
                    txtUserName.Enabled   = true;
                    txtPassword.Enabled   = true;
                    btnSend.Enabled       = true;
                }
                else//
                {
                    //Đẩy dữ liệu vào biến toàn cục

                    GlobalVariable.fromEmailAddress = txtFromMailAddress.Text;
                    GlobalVariable.fromEmailPass    = txtPassword.Text;
                    GlobalVariable.emailHost        = txtHost.Text;
                    GlobalVariable.emailPort        = txtPort.Text;

                    if (userConfig != null)
                    {
                        GlobalVariable.toEmailAddress          = EncodeMD5.DecryptString(userConfig.ToMailAddress, "ITFramasBDVN");
                        GlobalVariable.ccEmailAddress          = EncodeMD5.DecryptString(userConfig.CCMailAddress, "ITFramasBDVN");
                        GlobalVariable.boxWeightMixingMaterial = Convert.ToDouble(EncodeMD5.DecryptString(userConfig.Mixing_Material_BoxWeight, "ITFramasBDVN"));
                        GlobalVariable.boxWeightMixingRecycle  = Convert.ToDouble(EncodeMD5.DecryptString(userConfig.Mixing_Recycle_BoxWeight, "ITFramasBDVN"));
                        GlobalVariable.boxWeightIncoming       = Convert.ToDouble(EncodeMD5.DecryptString(userConfig.Incoming_BoxWeight, "ITFramasBDVN"));
                        GlobalVariable.boxWeightCrushing       = Convert.ToDouble(EncodeMD5.DecryptString(userConfig.Crushing_BoxWeight, "ITFramasBDVN"));
                    }

                    GlobalVariable.ipScale   = txtScaleIP.Text;
                    GlobalVariable.portScale = txtScalePort.Text;

                    SplashScreenManager.ShowForm(this, typeof(frmProcessing), true, true, false);
                    SplashScreenManager.Default.SetWaitFormCaption("Check database server...");
                    var checkConnectDB = DataProvider.Instance.ExecuteScalar("select count(*) from tblAccount"); //kiểm tra kết nối đến DB server
                    Thread.Sleep(1000);                                                                          //thời gian chờ cho tiến trình chạy
                    if (checkConnectDB != null && (int)checkConnectDB > 0)                                       //kết nối thành công
                    {
                        SplashScreenManager.Default.SetWaitFormCaption("Connect databases successful...");
                        Thread.Sleep(1000);
                        SplashScreenManager.CloseForm();

                        //vao form Login
                        frmLogin newForm = new frmLogin();
                        this.Hide();
                        newForm.ShowDialog();
                        this.Close();
                    }
                    else//kết nối thất bại
                    {
                        SplashScreenManager.Default.SetWaitFormCaption("Connect databases fail...");
                        Thread.Sleep(1000);
                        SplashScreenManager.CloseForm();
                    }
                }
            }
            //catch { }
        }
Exemplo n.º 10
0
 public void SaveConfiguration(UserConfigModel userConfig)
 {
 }