/// <summary>
        /// Calls the InvalidateSetting method to get the values.
        /// </summary>
        public static void InitializeValues()
        {
            manager = new GFS();
            string settingsDirectory = Application.StartupPath + @"\Settings\";

            if (!Directory.Exists(settingsDirectory))
            {
                Directory.CreateDirectory(settingsDirectory);
            }

            string SettingFile = settingsDirectory + "applicationSettings.set";

            manager.SettingsDirectory = SettingFile;

            UniversalUsername = InvalidateSetting(_Username, "");
            UniversalPassword = InvalidateSetting(_Password, "");
            BrowserEngine     = BrowserEngineFromString(InvalidateSetting(_BrowserEngine, _cefSharp));
            SearchEngine      = SearchEngineFromString(InvalidateSetting(_SearchEngine, _google));
            HistorySettings   = HistoryEngineFromString(InvalidateSetting(_HistoryEngine, _SyncAll));
            UserAgent         = UserAgentFromString(InvalidateSetting(_UserAgent, _default));
            BuildVersion      = BuildVersionFromString(InvalidateSetting(_BuildVersion, _Public));
            SyncHistory       = bool.Parse(InvalidateSetting(_SyncHistory, true.ToString()));
            SyncBookmarks     = bool.Parse(InvalidateSetting(_SyncBookmarks, true.ToString()));
            SyncInterval      = int.Parse(InvalidateSetting(_SyncInterval, 10000.ToString()));
        }
Esempio n. 2
0
 /// <summary>
 ///     Open File
 /// </summary>
 private void OpenFileStripButton_Click(object sender, EventArgs e)
 {
     if (lstData.SelectedItems.Count == 1)
     {
         String strFileName = lstData.SelectedItems[0].Text;
         GFS.OpenFile(strFileName);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Calling of the IDownlaod (Initialization)
        /// </summary>
        public IDownload(string _Url, string _fileName, int _percent)
        {
            //Setting local var's
            URL      = _Url;
            FileName = _fileName;
            Percent  = _percent;

            //Initializing AUS and getting the Download Directory setting.
            GFS    gFS = new GFS();
            string DownloadDirectory = gFS.ReadSetting("downloadD");

            //Setting client event's
            client.DownloadProgressChanged += client_DownloadProgressChanged;
            client.DownloadDataCompleted   += client_DownloadDataCompleted;

            //Create the Download Directory if it does not exist
            if (!Directory.Exists(DownloadDirectory))
            {
                Directory.CreateDirectory(DownloadDirectory);
            }

            //Setting the FileDirectory to locate where to save the file
            string fileDirectory = DownloadDirectory + @"\" + FileName;

            //Split the FileName into the name[0] and type [1]
            string[] FileArgs = FileName.Split('.');

            #region Reinvalidating the FileName

            for (int i = 0; ; i++)
            {
                //Initialize a tmpI
                int tmpI = i - 1;

                //Set the file name to 'FileName('i+1').exce
                if (i != 0)
                {
                    fileDirectory = DownloadDirectory + "\\" + FileArgs[0] + " (" + (tmpI + 1) + ")." + FileArgs[1];
                }

                //Check if file exist, if false then break the for loop.
                if (!File.Exists(fileDirectory))
                {
                    break;
                }
            }

            //Download's the file to the FileDirectory from URL
            client.DownloadFileAsync(new Uri(_Url), fileDirectory);

            #endregion
        }
Esempio n. 4
0
        /// <summary>
        ///     DownLoad File
        /// </summary>
        public void DownloadFileStripButton_Click(object sender, EventArgs e)
        {
            var    downfile    = new SaveFileDialog();
            String strFileName = lstData.SelectedItems[0].Text;

            //For Winodws,Linux user DirectorySeparatorChar Replace with @"\"
            downfile.FileName =
                strFileName.Split(Path.DirectorySeparatorChar)[strFileName.Split(Path.DirectorySeparatorChar).Length - 1
                ];
            if (downfile.ShowDialog() == DialogResult.OK)
            {
                GFS.DownloadFile(downfile.FileName, strFileName);
            }
            RefreshGUI();
        }
Esempio n. 5
0
        /// <summary>
        ///     Upload File
        /// </summary>
        private void UploadFileStripButton_Click(object sender, EventArgs e)
        {
            var upfile = new OpenFileDialog();
            var opt    = new GFS.UpLoadFileOption();

            if (upfile.ShowDialog() == DialogResult.OK)
            {
                var frm = new frmGFSOption();
                SystemManager.OpenForm(frm, false, true);
                opt.FileNameOpt            = frm.filename;
                opt.AlreadyOpt             = frm.option;
                opt.DirectorySeparatorChar = frm.DirectorySeparatorChar;
                frm.Dispose();
                GFS.UpLoadFile(upfile.FileName, opt);
                RefreshGUI();
            }
        }
Esempio n. 6
0
        /// <summary>
        ///     Delete File
        /// </summary>
        public void DeleteFileStripButton_Click(object sender, EventArgs e)
        {
            String strTitle   = "Delete Files";
            String strMessage = "Are you sure to delete selected File(s)?";

            if (!SystemManager.IsUseDefaultLanguage)
            {
                strTitle   = SystemManager.MStringResource.GetText(StringResource.TextType.Drop_Data);
                strMessage = SystemManager.MStringResource.GetText(StringResource.TextType.Drop_Data_Confirm);
            }
            if (MyMessageBox.ShowConfirm(strTitle, strMessage))
            {
                foreach (ListViewItem item in lstData.SelectedItems)
                {
                    GFS.DelFile(item.Text);
                }
                RefreshGUI();
            }
        }
Esempio n. 7
0
        /// <summary>
        /// </summary>
        /// <param name="uploadDir"></param>
        /// <param name="fileCount"></param>
        /// <param name="opt"></param>
        /// <returns>是否继续执行后续的所有操作</returns>
        private Boolean UploadFolder(DirectoryInfo uploadDir, ref int fileCount, GFS.UpLoadFileOption opt)
        {
            foreach (FileInfo file in uploadDir.GetFiles())
            {
                GFS.UploadResult rtn = GFS.UpLoadFile(file.FullName, opt);
                switch (rtn)
                {
                case GFS.UploadResult.Complete:
                    fileCount++;
                    break;

                case GFS.UploadResult.Skip:
                    if (opt.AlreadyOpt == GFS.enumGFSAlready.Stop)
                    {
                        ///这个操作返回为False,停止包括父亲过程在内的所有操作
                        return(false);
                    }
                    break;

                case GFS.UploadResult.Exception:
                    return(MyMessageBox.ShowConfirm("Upload Exception", "Is Continue?"));

                default:
                    break;
                }
            }
            if (!opt.IgnoreSubFolder)
            {
                foreach (DirectoryInfo dir in uploadDir.GetDirectories())
                {
                    ///递归文件夹操作,如果下层有任何停止的意愿,则立刻停止,并且使上层也立刻停止
                    Boolean IsContinue = UploadFolder(dir, ref fileCount, opt);
                    if (!IsContinue)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
        public CommandLine()
        {
            settingsFramework = new GFS(Environment.CurrentDirectory + @"\" + "UniversalSettings.dll");
            ILogger.SetLoggingEvents();

            //CheckForSystemUpdate();

            string oldSettingValue = settingsFramework.ReadSetting(_servers);

            if (oldSettingValue != null)
            {
                List <string> _Servers = oldSettingValue.Split(new string[] { seperator }, StringSplitOptions.RemoveEmptyEntries).ToList();

                foreach (string s in _Servers)
                {
                    UniversalServerObject USO = new UniversalServerObject(s, Environment.CurrentDirectory);
                    servers.Add(USO);
                }
            }

            new Thread(new ThreadStart(() => { commandLine(); })).Start();
        }
        public UniversalServerObject(string Name, string ServerDirectory)
        {
            ServerDirectory        = ServerDirectory + @"\" + Name;
            PluginDirectory        = ServerDirectory + @"\Plugins";
            ServerStorageDirectory = ServerDirectory + @"\UserStorage";
            PluginEditDirectory    = ServerDirectory + @"\Plugin Settings";
            if (!Directory.Exists(ServerDirectory))
            {
                Directory.CreateDirectory(ServerDirectory);
            }
            ServerDirectory = ServerDirectory + @"\" + "settings.dll";

            if (!Directory.Exists(PluginDirectory))
            {
                Directory.CreateDirectory(PluginDirectory);
            }
            if (!Directory.Exists(PluginEditDirectory))
            {
                Directory.CreateDirectory(PluginEditDirectory);
            }
            if (!Directory.Exists(ServerStorageDirectory))
            {
                Directory.CreateDirectory(ServerStorageDirectory);
            }

            ServerName        = Name;
            settingsFramework = new GFS(ServerDirectory);
            string port = null; if (settingsFramework.CheckSetting("port"))

            {
                port = settingsFramework.ReadSetting("port");
            }

            else
            {
                settingsFramework.EditSetting("port", "7777"); port = "7777";
            }
        }
        public void SaveDownloadItems()
        {
            //Seperator for the download
            string[] Seperator         = new string[] { "%20%|downloadSep|%20%" };
            string   DownloadDirectory = Application.StartupPath + @"\Download";
            string   DownloadFile      = DownloadDirectory + @"\downloadfiles.dat";

            //Creates the directory and file if it does not exist
            if (!Directory.Exists(DownloadDirectory))
            {
                Directory.CreateDirectory(DownloadDirectory);
            }

            //Sets a new instance of GFS
            GFS gfs = new GFS();

            gfs.SettingsDirectory = DownloadFile;

            List <string> DownloadinString  = new List <string>();
            string        RawDownloadString = null;

            //Formating for each DownloadInString list and RawDownloadString
            foreach (DownloadObject download in DownloadList)
            {
                string[] fileSeperator = new string[] { "%20%|downloadFileSep|%20%" };
                DownloadinString.Add(download.FileName + fileSeperator[0] + download.FileURL);
            }
            foreach (string str in DownloadinString)
            {
                RawDownloadString += str + Seperator[0];
            }

            //Editing the setting
            try
            {
                gfs.EditSetting(DownloadSettingHeader, RawDownloadString);
            } catch { ILogger.AddToLog("Download", "Failed to write download histroy."); }
        }
        /// <summary>
        /// Creates download objects out of the download list
        /// </summary>
        public void InitializeDownloadItems()
        {
            //Seperator for the download
            string[] Seperator         = new string[] { "%20%|downloadSep|%20%" };
            string   DownloadDirectory = Application.StartupPath + @"\Download";
            string   DownloadFile      = DownloadDirectory + @"\downloadfiles.dat";

            //Creates the directory and file if it does not exist
            if (!Directory.Exists(DownloadDirectory))
            {
                Directory.CreateDirectory(DownloadDirectory);
            }

            //Sets a new instance of GFS
            GFS gfs = new GFS();

            gfs.SettingsDirectory = DownloadFile;

            //Check if the setting exist
            if (!gfs.CheckSetting(DownloadSettingHeader))
            {
                gfs.EditSetting(DownloadSettingHeader, Seperator[0]);
            }

            //Gets the string and split it into an array
            string rawDownloadString = gfs.ReadSetting(DownloadSettingHeader);

            string[] formatDownloadString = rawDownloadString.Split(Seperator, StringSplitOptions.RemoveEmptyEntries);

            //Adds the download object
            foreach (string str in formatDownloadString)
            {
                string[] fileSeperator = new string[] { "%20%|downloadFileSep|%20%" };
                string[] fileInfo      = str.Split(fileSeperator, StringSplitOptions.None);
                DownloadList.Add(new DownloadObject(fileInfo[0], fileInfo[1], false));
            }
        }
Esempio n. 12
0
        public static void GfsNowCastInsert()
        {
            _log.Info($"Start Insert");
            List <GFS_DB_INSERT_CHECK> gfsDbIndertCheck = new List <GFS_DB_INSERT_CHECK>();

            DateTime UTC;

            double[] LAT;
            double[] LON;
            double[] temp_surfaceValue;
            double[] temp_above_groundValue;
            double[] press_surfaceValue;
            double[] press_mslValue;

            GribEnvironment.Init();
            List <GribMessage> gfs = new List <GribMessage>();

            _log.Info($"Start Insert : {_decodeList[6]}");
            using (GribFile file = new GribFile(_decodeList[6]))
            {
                file.Context.EnableMultipleFieldMessages = true;

                var temp_surface = file.Where(d => d.ParameterName == "Temperature" && d.TypeOfLevel == "surface" && d.Level == 0).Single();

                if (_oceanModel.GFS_DB_INSERT_CHECK.Where(s => s.DATE_OF_FILE == temp_surface.Time).Count() > 0)
                {
                    _log.Info("TRIGGER/*/" + "Gfs DB에 " + temp_surface.Time.ToString() + "데이터가 이미 있습니다.");
                    return;
                }
                var temp_above_ground = file.Where(d => d.ParameterName == "Temperature" && d.TypeOfLevel == "heightAboveGround" && d.Level == 2).Single();
                var press_surface     = file.Where(d => d.ParameterName == "Pressure" && d.TypeOfLevel == "surface" && d.Level == 0).Single();
                var press_msl         = file.Where(d => d.ParameterName == "Pressure reduced to MSL" && d.TypeOfLevel == "meanSea" && d.Level == 0).Single();

                ////////////////////////////////////////////////////////////////////////
                //////////////////DB INSERT
                ////////////////////////////////////////////////////////////////////////

                UTC = temp_surface.Time;
                LAT = temp_surface.GridCoordinateValues.Select(d => d.Latitude).ToArray();
                LON = temp_surface.GridCoordinateValues.Select(d => d.Longitude).ToArray();

                temp_surface.Values(out temp_surfaceValue);
                temp_above_ground.Values(out temp_above_groundValue);
                press_surface.Values(out press_surfaceValue);
                press_msl.Values(out press_mslValue);
            }

            List <GFS> gfsList = new List <GFS>();

            for (int j = 0; j < LAT.Length; j++)
            {
                ////////////////////////////////////////////////////////////////////////
                //////////////////예보 데이터
                ////////////////////////////////////////////////////////////////////////

                gfsList.Add(new GFS
                {
                    UTC               = UTC,
                    LAT               = Convert.ToDecimal(LAT[j]),
                    LON               = Convert.ToDecimal(LON[j]),
                    TEMP_SURFACE      = Convert.ToSingle(temp_surfaceValue[j] - 273.15f),
                    TEMP_ABOVE_GROUND = Convert.ToSingle(temp_above_groundValue[j] - 273.15f),
                    PRESSURE_SURFACE  = Convert.ToSingle(press_surfaceValue[j]),
                    PRESSURE_MSL      = Convert.ToSingle(press_mslValue[j]),
                });
            }
            ////////////////////////////////////////////////////////////////////////
            //////////////////DB INSERT
            ////////////////////////////////////////////////////////////////////////

            int resumeCount     = 0;
            int insertDataCount = 259920;
            var checkDate       = UTC;

            _oceanModel.Database.CommandTimeout = 99999;
            GFS checkDB = _oceanModel.GFS.FirstOrDefault(s => s.UTC == checkDate);

            if (checkDB != null)
            {
                var resumeCount1 = _oceanModel.GFS.Count(s => s.UTC == checkDate);
                resumeCount = resumeCount1;
                if (resumeCount == insertDataCount)
                {
                    gfsDbIndertCheck.Add(new GFS_DB_INSERT_CHECK
                    {
                        FILE_NAME     = _decodeList[4].ToLower(),
                        DATE_OF_FILE  = UTC,
                        DATE_INSERTED = DateTime.UtcNow
                    });
                    gfsDbIndertCheck.ForEach(s => _oceanModel.GFS_DB_INSERT_CHECK.Add(s));
                    _oceanModel.SaveChanges();
                    return;
                }

                _log.Info("TRIGGER/*/" + "Gfs 데이터를 " + resumeCount.ToString() + "개부터 이어 받습니다.");
            }

            var gfsSplit = Split(gfsList, 10000);

            int index = 0;

            foreach (var item in gfsSplit)
            {
                if (index * 10000 >= resumeCount)
                {
                    EFBatchOperation.For(_oceanModel, _oceanModel.GFS).InsertAll(item);
                    Thread.Sleep(500);
                }
                var progress = Math.Round((double)index / 0.26, 2);
                _log.Info($"Gfs Nowcast Db insert :{_decodeList[0]}-{_decodeList[1]}-{_decodeList[2]} {_decodeList[3]}:00 / {progress} %");
                index++;
            }
            gfsSplit = null;
            gfsList  = null;

            gfsDbIndertCheck.Add(new GFS_DB_INSERT_CHECK
            {
                FILE_NAME     = _decodeList[4].ToLower(),
                DATE_OF_FILE  = UTC,
                DATE_INSERTED = DateTime.UtcNow
            });

            gfsDbIndertCheck.ForEach(s => _oceanModel.GFS_DB_INSERT_CHECK.Add(s));
            _oceanModel.SaveChanges();

            _log.Info($"Gfs Db insert Finish");
        }
Esempio n. 13
0
 /// <summary>
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OpenDocInEditorDocStripButton_Click(object sender, EventArgs e)
 {
     GFS.SaveAndOpenStringAsFile(txtData.Text);
 }
Esempio n. 14
0
 /// <summary>
 ///     Open
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void EditDocStripButton_Click(object sender, EventArgs e)
 {
     GFS.SaveAndOpenStringAsFile(txtJavaScript.Text);
 }
Esempio n. 15
0
 /// <summary>
 ///     Init GFS
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void InitGFSToolStripMenuItem_Click(object sender, EventArgs e)
 {
     GFS.InitGFS();
     DisableAllOpr();
     UIHelper.FillConnectionToTreeView(trvsrvlst);
 }