/// <summary>
    /// Exports the blacklists.
    /// </summary>
    /// <param name="blacklistModel">The blacklists model.s</param>
    private void ExportBlacklists(BlacklistModel blacklistModel)
    {
        var importExport = new ImportExport();

        importExport.WriteDataToXmlFile(blacklistModel, Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Blacklist.xml"));
        MessageBox.Show(this.languageManager.GetWord("BlacklistSavedTest"), this.languageManager.GetWord("BlacklistSavedCaption"), MessageBoxButtons.OK, MessageBoxIcon.Information);
    }
Exemple #2
0
        private void buttonImportCSV()
        {
            ImportExport importexport = new ImportExport(ParentMainForm);
            string       str          = (string)comboBoxseletedTable.SelectedItem;
            string       str1         = "";
            string       str2         = "";

            switch (str)
            {
            case "Controller":
                importexport.AddControllers(filename);
                break;

            case "POU":
                str1 = (string)comboBoxSelect1.SelectedItem;
                importexport.AddPOU(filename, str1.ToLower());
                break;

            case "Board":
                break;

            case "Channel":

                break;

            case "Variable":
                str1 = (string)comboBoxSelect1.SelectedItem;
                str2 = (string)comboBoxSelect2.SelectedItem;
                importexport.AddVariable(filename, str1.ToLower(), str2.ToLower());
                break;

            case "BOOL":
                str1 = (string)comboBoxSelect1.SelectedItem;
                str2 = (string)comboBoxSelect2.SelectedItem;
                importexport.AddBOOL(filename, str1.ToLower(), str2.ToLower());
                break;

            case "REAL":
                str1 = (string)comboBoxSelect1.SelectedItem;
                str2 = (string)comboBoxSelect2.SelectedItem;
                importexport.AddREAL(filename, str1.ToLower(), str2.ToLower());
                break;

            case "HMI":

                break;

            case "Alarm":
                break;

            case "FormalParameter":
                importexport.AddFormalParameter(filename);
                break;
            }


            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            Close();
        }
Exemple #3
0
        private void btnAccount_Click(object sender, RoutedEventArgs e)
        {
            mainWindow.mAccount.mID = textboxId.Text;
            ImportExport importExport = new ImportExport();

            importExport.exportAccount(mainWindow.mAccount);
            MessageBox.Show("저장 완료!");
        }
        void btnConnect_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                bool tag = (bool)this.btnConnect.Tag;
                if (tag)
                {
                    //They want to cancel the connect.
                    try
                    {
                        this._client.CancelAsync(null);
                    }
                    catch
                    { }
                    this._client.Dispose();

                    //Set form.
                    this.barProg.IsIndeterminate = false;
                    this.btnConnect.Tag          = false;
                    this.btnConnect.Content      = "_Get Projects";
                    this.grdEntry.IsEnabled      = true;
                }
                else
                {
                    if (this.txbServer.Text.ToLowerInvariant().EndsWith(".asmx") || this.txbServer.Text.ToLowerInvariant().EndsWith(".aspx"))
                    {
                        MessageBox.Show("Your server url cannot contain a page in its address.", "Invalid Server URL", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    }
                    else
                    {
                        //Start the connections.
                        this.barProg.IsIndeterminate = true;
                        this.barProg.Foreground      = (Brush) new System.Windows.Media.BrushConverter().ConvertFrom(this._resources.GetString("barForeColor"));
                        this.grdEntry.IsEnabled      = false;
                        this.btnConnect.Content      = "_Cancel";
                        this.btnConnect.Tag          = true;
                        this.txtStatus.Text          = "Connecting to server...";
                        this.cmbProjectList.Items.Clear();
                        this.grdAvailProjs.IsEnabled = false;

                        //Create new client.
                        ImportExport client = new ImportExport();
                        client.Connection_Authenticate2Completed += new Connection_Authenticate2CompletedEventHandler(client_ActionCompleted);
                        client.User_RetrieveByUserNameCompleted  += new User_RetrieveByUserNameCompletedEventHandler(client_ActionCompleted);
                        client.Project_RetrieveCompleted         += new Project_RetrieveCompletedEventHandler(client_ActionCompleted);

                        this._client = client;
                        this._client.CookieContainer = new System.Net.CookieContainer();
                        this._client.Url             = new Uri(this.txbServer.Text + Connect.SpiraProject.URL_APIADD).AbsoluteUri;
                        this._client.Connection_Authenticate2Async(this.txbUserID.Text, this.txbUserPass.Password, this._resources.GetString("strAddinProgNamePretty"));
                    }
                }
            }
            catch (Exception ex)
            {
                Connect.logEventMessage("wpfNewSpiraProject::btnConnect_Click", ex, System.Diagnostics.EventLogEntryType.Error);
            }
        }
        /// <summary>Hit when the client is finishe getting a list of Requirements.</summary>
        /// <param name="sender">The client that caused the event.</param>
        /// <param name="evt">Event Args.</param>
        private void client_FinishRequirement(object sender, Requirement_RetrieveCompletedEventArgs evt)
        {
            try
            {
                ImportExport client = (ImportExport)sender;
                ObjectState  evtObj = (ObjectState)evt.UserState;

                //Make the current node and the existing parent node.
                TreeViewItem reqItemNode = new TreeViewItem();
                TreeViewItem reqNode     = (TreeViewItem)((TreeViewItem)this.trvProject.Items[evtObj.NodeNumber]).Items[NODE_REQUIREMENTNUM];
                reqItemNode = reqNode;

                if (evt.Error == null)
                {
                    //Add child nodes.
                    int numCounted = 0;
                    foreach (RemoteRequirement Req in evt.Result)
                    {
                        if (!Req.Summary)
                        {
                            numCounted++;
                            TreeViewItem reqDetNode = new TreeViewItem();
                            reqDetNode.Header            = createNodeHeader("imgRequirement", Req.Name);
                            reqDetNode.MouseDoubleClick += new MouseButtonEventHandler(tree_NodeDoubleClick);
                            reqDetNode.Tag = Connect.SpiraProject.GenerateToString(evtObj.Project) + Connect.SpiraProject.CHAR_RECORD + "RQ:" + Req.RequirementId.ToString();

                            reqItemNode.Items.Add(reqDetNode);
                        }
                    }

                    //Set the image & change text.
                    if (numCounted > 0)
                    {
                        reqItemNode = this.changeNodeText(reqItemNode, this._resources.GetString("strRequirements") + " (" + numCounted.ToString() + ")");
                    }

                    //Clean up.
                    removeClient(client);
                }
                else
                {
                    //Set error flag on node.
                    reqItemNode = changeNodeImage(reqItemNode, "imgError");
                    reqItemNode.Items.Clear();
                    reqItemNode.ToolTip = new TextBlock()
                    {
                        Text = evt.Error.Message
                    };

                    //Error, clean up.
                    removeClient(client);
                }
            }
            catch (Exception ex)
            {
                Connect.logEventMessage("wpfProjectTree::client_FinishRequirement", ex, System.Diagnostics.EventLogEntryType.Error);
            }
        }
Exemple #6
0
        public virtual void ShareBatch(ApiCall call)
        {
            SiteDb siteDb = call.WebSite != null?call.WebSite.SiteDb() : null;

            var formreader = Kooboo.Lib.NETMultiplePart.FormReader.ReadForm(call.Context.Request.PostData);

            if (siteDb == null)
            {
                Guid siteId;
                if (!Guid.TryParse(formreader.FormData["SiteId"], out siteId))
                {
                    return;
                }
                var website = Kooboo.Data.GlobalDb.WebSites.Get(siteId);
                siteDb = website.SiteDb();
            }

            if (siteDb == null)
            {
                return;
            }

            var tempFolder = Kooboo.Data.AppSettings.TempDataPath;

            var exportfile = ImportExport.ExportInter(siteDb);

            if (!File.Exists(exportfile))
            {
                return;
            }


            var postdata = InitData(formreader, call);

            var zipbytes = IOHelper.ReadAllBytes(exportfile);

            postdata.Bytes = zipbytes;

            if (zipbytes.Length > AppSettings.MaxTemplateSize)
            {
                throw new Exception(Data.Language.Hardcoded.GetValue("Exceed max template size", call.Context));
            }

            postdata.ByteHash = Kooboo.Lib.Security.Hash.ComputeGuid(zipbytes);

            Kooboo.IndexedDB.Serializer.Simple.SimpleConverter <TemplateDataModel> converter = new IndexedDB.Serializer.Simple.SimpleConverter <TemplateDataModel>();

            var postbytes = converter.ToBytes(postdata);

            string url = UrlHelper.Combine(AppSettings.ThemeUrl, "/_api/receiver/template");

            var response = HttpHelper.PostData(url, new Dictionary <string, string>(), postbytes);

            if (!response)
            {
                throw new Exception(Data.Language.Hardcoded.GetValue("Share template failed", call.Context));
            }
        }
        public void ImportExportAccessTest()
        {
            sample = new GameObject();
            sample.AddComponent <ImportExport>();
            test = sample.GetComponent <ImportExport>();
            Assert.AreNotEqual(test, null);

            // Debug.Log(test.Dialogues.Length);
        }
Exemple #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ImportExportTests"/> class.
 /// </summary>
 public ImportExportTests()
 {
     this.MockRepository     = MockRepositoryFactory.Get();
     this.SerializerSettings = JsonSerializerSettingsFactory.Get();
     this.Mapper             = MapperFactory.Get();
     this.MockImport         = MockImportFactory.Get();
     this.MockExport         = MockExportFactory.Get();
     this.ImportExport       = new ImportExport(MockRepository.Object, this.SerializerSettings, Mapper, MockImport.Object, MockExport.Object);
 }
Exemple #9
0
        private void buttonImportBATCH()
        {
            if (!File.Exists(filename))
            {
                ParentMainForm.WriteToOutputWindows("File " + filename + " does not exist");
                return;
            }
            string str;
            int    count = 0;

            using (StreamReader reader = new StreamReader(filename))
            {
                while ((str = reader.ReadLine()) != null)
                {
                    str = str.ToLower();
                    string[] _strs = str.Split(new Char[] { ',', '(', ')' });
                    count = _strs.Count();
                    if ((count >= 2) && (_strs[0] == "addcontrollers"))
                    {
                        ImportExport importexport = new ImportExport(ParentMainForm);
                        importexport.AddControllers(_strs[1]);
                        continue;
                    }
                    if ((count >= 3) && (_strs[0] == "addpou"))
                    {
                        ImportExport importexport = new ImportExport(ParentMainForm);
                        importexport.AddPOU(_strs[1], _strs[2]);
                        continue;
                    }
                    if ((count >= 4) && (_strs[0] == "addvariable"))
                    {
                        ImportExport importexport = new ImportExport(ParentMainForm);
                        importexport.AddVariable(_strs[1], _strs[2], _strs[3]);
                        continue;
                    }
                    if ((count >= 4) && (_strs[0] == "addbool"))
                    {
                        ImportExport importexport = new ImportExport(ParentMainForm);
                        importexport.AddBOOL(_strs[1], _strs[2], _strs[3]);
                        continue;
                    }
                    if ((count >= 4) && (_strs[0] == "addreal"))
                    {
                        ImportExport importexport = new ImportExport(ParentMainForm);
                        importexport.AddREAL(_strs[1], _strs[2], _strs[3]);
                        continue;
                    }
                    if ((count >= 2) && (_strs[0] == "addformalparameter"))
                    {
                        ImportExport importexport = new ImportExport(ParentMainForm);
                        importexport.AddFormalParameter(_strs[1]);
                        continue;
                    }
                }
                reader.Close();
            }
        }
        public static void StartImport()
        {
            Console.Clear();
            SetFileName("CSV\\csv.csv");
            ImportExport import = new ImportExport(fileName);

            Console.WriteLine("Naciśnij dowolny klawisz aby wrócić do Menu...");
            Console.ReadKey();
        }
Exemple #11
0
        private void targetExportButton_Click(object sender, EventArgs e)
        {
            if (targetlistBox.SelectedItem == null || string.IsNullOrEmpty(targetlistBox.SelectedItem.ToString()))
            {
                return;
            }

            ImportExport.ExportTargetFilter(targetlistBox.SelectedItem.ToString());
        }
Exemple #12
0
 public CurveFileImportExportDialog(ImportExport importExport)
 {
     FilePath = "";
     InitializeComponent();
     _importExport = importExport;
     openFileDialog.InitialDirectory = Paths.ImportExportPath;
     openFileDialog.DefaultExt       = ".xml";
     openFileDialog.Filter           = "Curve file|*.xml";
 }
 public CurveFileImportExportDialog(ImportExport importExport)
 {
     FilePath = "";
     InitializeComponent();
     _importExport = importExport;
     openFileDialog.InitialDirectory = Paths.ImportExportPath;
     openFileDialog.DefaultExt = ".xml";
     openFileDialog.Filter = "Curve file|*.xml";
 }
Exemple #14
0
 private void exportToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (ImportExport == null)
     {
         ImportExport = new ImportExport(Client);
     }
     ImportExport.ImportExport_Load(null, null);
     enableControl(ImportExport);
 }
    void OnGUI()
    {
        ScriptableObject   target          = this;
        SerializedObject   so              = new SerializedObject(target);
        SerializedProperty stringsProperty = so.FindProperty("tiles");

        string[] brushNames = System.Enum.GetNames(typeof(Brushes));

        brushSelected = GUILayout.SelectionGrid(brushSelected, brushNames, brushNames.Length, EditorStyles.miniButtonMid, GUILayout.Height(50f));

        EditorGUILayout.Space();

        if (GUILayout.Button("Generate Level"))
        {
            GenerateLevelWindow.Init();
        }

        GUILayout.BeginHorizontal();

        if (GUILayout.Button("Save Level"))
        {
            ImportExport.Export(MainWindow.lvl.Tex);
        }
        if (GUILayout.Button("Load Level"))
        {
            MainWindow.lvl.Tex = ImportExport.Import();
        }
        if (GUILayout.Button("New Level"))
        {
            CreateNewLevelWindow.Init();
        }

        GUILayout.EndHorizontal();


        if (tiles != null)
        {
            string[] tileNames = new string[tiles.Length];

            for (int i = 0; i < tiles.Length; i++)
            {
                if (tiles[i].name == "")
                {
                    tiles[i].name = "Tile " + i;
                }

                tileNames[i] = tiles[i].name;
            }

            tileSelected = GUILayout.SelectionGrid(tileSelected, tileNames, 1, EditorStyles.radioButton);
        }


        EditorGUILayout.PropertyField(stringsProperty, true); // True means show children
        so.ApplyModifiedProperties();                         // Remember to apply modified properties
    }
Exemple #16
0
        public ActionResult AddQuest(HttpPostedFileBase file, int id_subject, int id_thematic)
        {
            try
            {
                var dao     = new QuestionDao();
                var session = (AdminLogin)Session[CommonConstants.USER_SESSION];
                if (session.id_permission == 2)
                {
                    return(View("Error"));
                }
                ViewBag.AdminName = session.name;

                var ad = new ImportExport();
                HttpPostedFileBase upload = Request.Files["file"];
                string             path   = Path.Combine(Server.MapPath("~/App_Data/uploads"), "cauhoi.xlsx");
                if (file.ContentLength > 0)
                {
                    var fileName = Path.GetFileName(file.FileName);
                    path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName);
                    file.SaveAs(path);
                }
                var data = ad.ReadFromExcelfile(path, "");

                int id = dao.InsertList(data, id_thematic);
                if (id > 0)
                {
                    SetViewBag(id_subject);
                    //để thông báo thêm thành công
                    SetNotice("Hệ thống đã thêm thành công " + id.ToString() + " câu hỏi", "success");
                    return(RedirectToAction("QDetail", new { id = id_subject }));
                }
                else
                {
                    var dao2 = new SubjectDao().ViewDetail(id_subject);
                    TempData["subject_name"] = dao2.subject_name;
                    TempData["id_subject"]   = id_subject;
                    SetViewBag(id_subject);
                    ModelState.AddModelError("", "Thêm câu hỏi không thành công.");
                }
            }
            catch
            {
                var dao2 = new SubjectDao().ViewDetail(id_subject);
                TempData["subject_name"] = dao2.subject_name;
                TempData["id_subject"]   = id_subject;
                SetViewBag(id_subject);
                ModelState.AddModelError("", "Thêm câu hỏi không thành công. Vui lòng kiểm tra file!");
            }

            var dao3 = new SubjectDao().ViewDetail(id_subject);

            TempData["subject_name"] = dao3.subject_name;
            TempData["id_subject"]   = id_subject;
            SetViewBag(id_subject);
            return(View());
        }
Exemple #17
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            string fileName = Factory.GUIController.ShowSaveFileDialog("Export background as...", Constants.IMAGE_FILE_FILTER);

            if (fileName != null)
            {
                Bitmap bmp = Factory.NativeProxy.GetBitmapForBackground(_room, cmbBackgrounds.SelectedIndex);
                ImportExport.ExportBitmapToFile(fileName, bmp);
                bmp.Dispose();
            }
        }
Exemple #18
0
 private void restockExportListB_Click(object sender, EventArgs e)
 {
     if (restockListSelect.Text != String.Empty)
     {
         ImportExport.ExportRestock(restockListSelect.Text);
     }
     else
     {
         Restock.AddLog("Item list not selected!");
     }
 }
Exemple #19
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (mAccount.mID == null)
            {
                mAccount.mID             = "default";
                mAccount.mNowPlayingList = new NowPlayingList();
            }
            ImportExport importExport = new ImportExport();

            importExport.exportAccount(mAccount);
        }
Exemple #20
0
        private static void CreateWithParameters(RSAParameters parameters)
        {
            RSAParameters exportedPrivate;

            using (RSA rsa = RSA.Create(parameters))
            {
                exportedPrivate = rsa.ExportParameters(true);
            }

            ImportExport.AssertKeyEquals(parameters, exportedPrivate);
        }
Exemple #21
0
        private object ImportOldGameThread(object parameter)
        {
            ImportGameResult result     = new ImportGameResult();
            string           gameToLoad = (string)parameter;

            result.LoadedGame = Factory.NativeProxy.ImportOldGame(gameToLoad);
            Dictionary <int, Sprite> spriteList = Factory.NativeProxy.LoadSpriteDimensions();

            result.Errors = ImportExport.ImportOldEditorDatFile(gameToLoad, result.LoadedGame, spriteList);
            ImportExport.CreateInteractionScripts(result.LoadedGame, result.Errors);
            return(result);
        }
        public ActionResult Download(string clientid, string historyid)
        {
            string       filePath = @"D:/temp"; //Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["FileManagementPath"]);
            ImportExport im       = new ImportExport(clientid);
            ExportEvent  ev       = im.getExportEvent(historyid);

            string actualFilePath = filePath + "" + ev.FolderPath;
            string filename       = Path.GetFileName(actualFilePath);

            byte[] fileBytes = System.IO.File.ReadAllBytes(actualFilePath);
            return(File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, filename));
        }
Exemple #23
0
        /// <summary>
        /// Uploads the configuration.
        /// </summary>
        private bool UploadConfig(DeploymentProfile profile)
        {
            string configFileName = GetTempFileName();

            try
            {
                Cursor = Cursors.WaitCursor;
                DateTime t0 = DateTime.UtcNow;

                // prepare an archive
                ImportExport importExport = new ImportExport();
                importExport.ExportToArchive(configFileName, project, instance, profile.UploadSettings);
                FileInfo configFileInfo = new FileInfo(configFileName);
                long     configFileSize = configFileInfo.Length;

                // upload the configuration
                ConnectionSettings connSettings = profile.ConnectionSettings.Clone();
                connSettings.ScadaInstance = instance.Name;
                IAgentClient agentClient = new AgentWcfClient(connSettings);
                agentClient.UploadConfig(configFileName, profile.UploadSettings.ToConfigOpions());

                // restart the services
                if (profile.UploadSettings.RestartServer &&
                    (profile.UploadSettings.IncludeBase || profile.UploadSettings.IncludeServer))
                {
                    agentClient.ControlService(ServiceApp.Server, ServiceCommand.Restart);
                }

                if (profile.UploadSettings.RestartComm &&
                    (profile.UploadSettings.IncludeBase || profile.UploadSettings.IncludeComm))
                {
                    agentClient.ControlService(ServiceApp.Comm, ServiceCommand.Restart);
                }

                // show result
                Cursor = Cursors.Default;
                ScadaUiUtils.ShowInfo(string.Format(AppPhrases.UploadConfigComplete,
                                                    Math.Round((DateTime.UtcNow - t0).TotalSeconds), configFileSize));
                return(true);
            }
            catch (Exception ex)
            {
                Cursor = Cursors.Default;
                appData.ProcError(ex, AppPhrases.UploadConfigError);
                return(false);
            }
            finally
            {
                // delete temporary file
                try { File.Delete(configFileName); }
                catch { }
            }
        }
Exemple #24
0
        private void ContextMenuEventHandler(object sender, EventArgs e)
        {
            ToolStripMenuItem item = (ToolStripMenuItem)sender;

            if (item.Name == MENU_ITEM_EXPORT_TO_FILE)
            {
                string fileName = Factory.GUIController.ShowSaveFileDialog("Export palette...", PALETTE_FILE_FILTER);
                if (fileName != null)
                {
                    try
                    {
                        ImportExport.ExportPaletteToFile(fileName);
                        Factory.GUIController.ShowMessage("Palette exported successfully.", MessageBoxIcon.Information);
                    }
                    catch (Exception ex)
                    {
                        Factory.GUIController.ShowMessage("There was an error exporting the palette. The error message was '" + ex.Message + "'. Please retry.", MessageBoxIcon.Warning);
                    }
                }
            }
            else if (item.Name == MENU_ITEM_REPLACE_FROM_FILE)
            {
                if (Factory.GUIController.ShowQuestion("This will replace your entire palette with one from the file you select. Are you sure you want to do this?") == DialogResult.Yes)
                {
                    PaletteEntry[] newPalette = ImportPalette();
                    if (newPalette != null)
                    {
                        for (int i = 0; i < newPalette.Length; i++)
                        {
                            newPalette[i].ColourType = Factory.AGSEditor.CurrentGame.Palette[i].ColourType;
                            Factory.AGSEditor.CurrentGame.Palette[i] = newPalette[i];
                        }
                        palettePanel.Invalidate();
                        Factory.NativeProxy.PaletteColoursChanged(Factory.AGSEditor.CurrentGame);
                    }
                }
            }
            else if (item.Name == MENU_ITEM_IMPORT_FROM_FILE)
            {
                PaletteEntry[] newPalette = ImportPalette();
                if (newPalette != null)
                {
                    for (int i = 0; i < _selectedIndexes.Count; i++)
                    {
                        int palIndex = _selectedIndexes[i];
                        newPalette[palIndex].ColourType = Factory.AGSEditor.CurrentGame.Palette[palIndex].ColourType;
                        Factory.AGSEditor.CurrentGame.Palette[palIndex] = newPalette[palIndex];
                    }
                    palettePanel.Invalidate();
                }
            }
        }
Exemple #25
0
 private void FormMain_Load(object sender, EventArgs e)
 {
     Organization org = new Organization();
     Type type = new Type();
     Tovar tovar = new Tovar();
     ImportExport impexp = new ImportExport();
     TovarInOrganization tovinorg = new TovarInOrganization();
     org.Load();
     type.Load();
     tovar.Load();
     impexp.Load();
     tovinorg.Load();
 }
Exemple #26
0
 private void FormMain_FormClosed(object sender, FormClosedEventArgs e)
 {
     Organization org = new Organization();
     Type type = new Type();
     Tovar tovar = new Tovar();
     ImportExport impexp = new ImportExport();
     TovarInOrganization tovinorg = new TovarInOrganization();
     org.Save();
     type.Save();
     tovar.Save();
     impexp.Save();
     tovinorg.Save();
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="ImportSearchesCommand" /> class.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="options">The options.</param>
        public ImportSearchesCommand(string path, CommandLineOptions options)
        {
            _path    = path;
            _options = options;

            this.Repository         = Program.Repository;
            this.Import             = new Import();
            this.Export             = new Export();
            this.Mapper             = MapperFactory.Get();
            this.SerializerSettings = JsonSerializerSettingsFactory.Get();

            this.ImportExport = new ImportExport(Repository, SerializerSettings, Mapper, Import, Export);
        }
        public void TestLoadURDFRobotFromCSV(string modelName, int expNumLinks)
        {
            string csvFilename = GetCSVPath(modelName);

            using (StreamReader reader = new StreamReader(csvFilename))
            {
                List <Link> links = ImportExport.LoadURDFRobotFromCSV(reader.BaseStream);
                Assert.Equal(expNumLinks, links.Count);
                foreach (Link link in links)
                {
                    Assert.NotNull(link);
                }
            }
        }
Exemple #29
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ExportPeopleCommand" /> class.
        /// </summary>
        /// <param name="options">The options.</param>
        public ExportPeopleCommand(CommandLineOptions options)
        {
            _options = options;

            this.Repository         = Program.Repository;
            this.Import             = new Import();
            this.Export             = new Export();
            this.Mapper             = MapperFactory.Get();
            this.SerializerSettings = JsonSerializerSettingsFactory.Get();

            _fullPath = Path.Combine(Program.ExportDirectory, $"PeopleExport-{DateTime.Now}.csv");

            this.ImportExport = new ImportExport(Repository, SerializerSettings, Mapper, Import, Export);
        }
Exemple #30
0
        public Guid Use(ApiCall call)
        {
            string SiteName = call.GetValue("SiteName");

            if (!Data.GlobalDb.WebSites.CheckNameAvailable(SiteName, call.Context.User.CurrentOrgId))
            {
                throw new Exception(Data.Language.Hardcoded.GetValue("SiteName is taken", call.Context));
            }

            string RootDomain = call.GetValue("RootDomain");
            string SubDomain  = call.GetValue("SubDomain");

            string FullDomain = RootDomain;

            if (!string.IsNullOrEmpty(SubDomain))
            {
                if (FullDomain.StartsWith("."))
                {
                    FullDomain = SubDomain + FullDomain;
                }
                else
                {
                    FullDomain = SubDomain + "." + FullDomain;
                }
            }

            string downloadcode = call.GetValue("DownloadCode");

            string url = UrlHelper.Combine(AppSettings.ThemeUrl, "/_api/download/package/" + downloadcode);

            if (call.Context.User != null)
            {
                url += "?userid=" + call.Context.User.Id.ToString();
            }

            var download = DownloadHelper.DownloadFile(url, "zip");

            if (download == null)
            {
                throw new Exception(Data.Language.Hardcoded.GetValue("template package not found", call.Context));
            }

            MemoryStream memory  = new MemoryStream(download);
            var          newsite = ImportExport.ImportZip(memory, call.Context.User.CurrentOrgId, SiteName, FullDomain, call.Context.User.Id);

            return(newsite.Id);
        }
        /// <summary>
        /// Downloads the configuration.
        /// </summary>
        private bool DownloadConfig(DeploymentProfile profile)
        {
            string configFileName = GetTempFileName();

            try
            {
                Cursor = Cursors.WaitCursor;
                DateTime t0 = DateTime.UtcNow;

                // download the configuration
                ConnectionSettings connSettings = profile.ConnectionSettings.Clone();
                connSettings.ScadaInstance = instance.Name;
                IAgentClient agentClient = new AgentWcfClient(connSettings);
                agentClient.DownloadConfig(configFileName, profile.DownloadSettings.ToConfigOpions());

                // import the configuration
                ImportExport importExport = new ImportExport();
                importExport.ImportArchive(configFileName, project, instance, out ConfigParts foundConfigParts);
                FileInfo configFileInfo = new FileInfo(configFileName);
                long     configFileSize = configFileInfo.Length;

                // set the modification flags
                BaseModified      = foundConfigParts.HasFlag(ConfigParts.Base);
                InterfaceModified = foundConfigParts.HasFlag(ConfigParts.Interface);
                InstanceModified  = foundConfigParts.HasFlag(ConfigParts.Server) ||
                                    foundConfigParts.HasFlag(ConfigParts.Comm) || foundConfigParts.HasFlag(ConfigParts.Web);

                // show result
                Cursor = Cursors.Default;
                ScadaUiUtils.ShowInfo(string.Format(AppPhrases.DownloadConfigComplete,
                                                    Math.Round((DateTime.UtcNow - t0).TotalSeconds), configFileSize));
                return(true);
            }
            catch (Exception ex)
            {
                Cursor = Cursors.Default;
                appData.ProcError(ex, AppPhrases.DownloadConfigError);
                return(false);
            }
            finally
            {
                // delete temporary file
                try { File.Delete(configFileName); }
                catch { }
            }
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="columnName">The name of the column that this filter applies to; appears on the left side of the condition</param>
        /// <param name="conditionOperator">The operator that will be used to separate the column name from the value (e.g. "equals to")</param>
        /// <param name="paramName">The name of the query parameter</param>
        /// <param name="value">The raw value that will appear on the right side of the condition</param>
        public RowFilterConditionBase(ImportExport.Filters.ConditionOperators conditionOperator, string columnName, string paramName, object value)
        {
            Contract.Requires(!String.IsNullOrEmpty(columnName));
            Contract.Requires(!String.IsNullOrEmpty(paramName));
            Contract.Requires(paramName.StartsWith("@"));
            Contract.Requires(value != null);

            _legacyMode = false;

            this.ColumnName = columnName;
            this.ParameterName = paramName;
            this.Value = value;
            this.ConditionOperator = conditionOperator;
            ValidateCondition();
            Construct();
            BuildSql();
        }
    /// <summary>
    /// Handles the blacklist dialog load event.
    /// </summary>
    /// <param name="sender">The sender.</param>
    /// <param name="e">The event args.</param>
    private void BlacklistDialogLoad(object sender, EventArgs e)
    {
        try
        {
            if (!File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Blacklist.xml")))
            {
                return;
            }

            var importExport   = new ImportExport();
            var blacklistModel = importExport.LoadConfigFromXmlFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Blacklist.xml")) ?? new();
            this.LoadDataToTable(blacklistModel);
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.StackTrace, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
    }
 private void ExportCharacter(Character character, string fileName)
 {
     try
     {
         if (fileName.ToLower().EndsWith(NEW_CHARACTER_FILE_EXTENSION))
         {
             ImportExport.ExportCharacterNewFormat(character, fileName, _agsEditor.CurrentGame);
         }
         else
         {
             ImportExport.ExportCharacter272(character, fileName, _agsEditor.CurrentGame);
         }
     }
     catch (ApplicationException ex)
     {
         _guiController.ShowMessage("An error occurred exporting the character file. The error was: " + ex.Message, MessageBoxIcon.Warning);
     }
 }
 private void btnMove_Click(object sender, EventArgs e)
 {
     try
     {
         if (cbSourceOrg.Text == "" || cbDestOrg.Text == ""|| label7.Text == "") throw new Exception();
         if (lbSourceOrgTotars.DataSource == null) throw new Exception();
         TovarInOrganization new_tovar = new TovarInOrganization((Organization)cbDestOrg.SelectedItem, (Tovar)lbSourceOrgTotars.SelectedItem);
         TovarInOrganization tovInOrg = new TovarInOrganization();
         foreach (TovarInOrganization obj in TovarInOrganization.TovarInOrganizations)
         {
             if ((Tovar)lbSourceOrgTotars.SelectedItem == obj.Tovar && (Organization)cbSourceOrg.SelectedItem == obj.Organization)
                 tovInOrg = obj;
         }
         TovarInOrganization.TovarInOrganizations.Remove(tovInOrg);
         ImportExport tmp = new ImportExport(cbSourceOrg.Text, cbDestOrg.Text, (string)label7.Text,(Organization)cbSourceOrg.SelectedItem);
         lbSourceOrgTotars.DataSource = ((Organization)cbSourceOrg.SelectedItem).Tovars;
         lbDestOrgTovars.DataSource = ((Organization)cbDestOrg.SelectedItem).Tovars;
     }
     catch (Exception)
     {
         MessageBox.Show("Коректно заповніть поля або створіть організацію!Пустий список!");
     }
 }
Exemple #36
0
        //private void btnChange_Click(object sender, EventArgs e)
        //{
        //    if (btnChange.Text == "Change")
        //    {
        //        txtDecCrit.ReadOnly = false;
        //        txtRegStd.ReadOnly = false;
        //        btnChange.Text = "Save";
        //    }
        //    else if (btnChange.Text == "Save")
        //    {
        //        txtDecCrit.ReadOnly = true;
        //        txtRegStd.ReadOnly = true;
        //        btnChange.Text = "Change";
        //    }
        //}
        private void btnImportIVs_Click(object sender, EventArgs e)
        {
            VBTools.ImportExport import = new ImportExport();
            DataTable dt = import.Input;
            if (dt == null)
                return;

            string[] headerCaptions = { "Model Variables", "Imported Variables" };

            Dictionary<string, string> fields = new Dictionary<string, string>(_mainEffects);
            //if (_mainEffects.ContainsKey("ID") == false)
            //    fields.Add("ID", "ID");

            //frmColumnMapper colMapper =  new frmColumnMapper(_mainEffects, dt, headerCaptions, true);
            frmColumnMapper colMapper = new frmColumnMapper(_referencedVariables, dt, headerCaptions, true);

            DialogResult dr = colMapper.ShowDialog();

            if (dr == DialogResult.OK)
            {
                dt = colMapper.MappedTable;

                int errndx = 0;
                if (!recordIndexUnique(dt, out errndx))
                {
                    MessageBox.Show("Unable to import datasets with non-unique record identifiers.\n" +
                                    "Fix your datatable by assuring unique record identifier values\n" +
                                    "in the ID column and try importing again.\n\n" +
                                    "Record Identifier values cannot be blank or duplicated;\nencountered " +
                                    "error near row " + errndx.ToString(), "Import Data Error - Cannot Import This Dataset", MessageBoxButtons.OK);
                    return;
                }

                dgvVariables.DataSource = dt;
            }
            else
                return;

            //DataColumn dc = new DataColumn("IVRowIdx", typeof(int));
            //dt.Columns.Add(dc);
            //dc.SetOrdinal(0);
            foreach (DataGridViewColumn dvgCol in dgvVariables.Columns)
            {
                dvgCol.SortMode = DataGridViewColumnSortMode.NotSortable;
            }

            //for (int i = 0; i < dt.Rows.Count; i++)
            //{
            //    dt.Rows[i]["IVRowIdx"] = i;
            //}
            //dgvVariables.Columns[0].Visible = false;

            setViewOnGrid(dgvVariables);
            btnMakePredictions.Enabled = false;
        }
Exemple #37
0
        private void btnImportIVs_Click(object sender, EventArgs e)
        {
            VBTools.ImportExport import = new ImportExport();
            DataTable dt = import.Input;
            if (dt == null)
                return;

            string[] headerCaptions = { "Model Variables", "Imported Variables" };
            frmColumnMapper colMapper = new frmColumnMapper(_mainEffects, dt, headerCaptions, false);
            DialogResult dr = colMapper.ShowDialog();

            if (dr == DialogResult.OK)
            {
                dt = colMapper.MappedTable;
                dgvVariables.DataSource = dt;
            }

            foreach (DataGridViewColumn dvgCol in dgvVariables.Columns)
                dvgCol.SortMode = DataGridViewColumnSortMode.NotSortable;
        }
Exemple #38
0
        private void btnImportObs_Click(object sender, EventArgs e)
        {
            VBTools.ImportExport import = new ImportExport();
            DataTable dt = import.Input;
            if (dt == null)
                return;

            string[] headerCaptions = { "Obs IDs", "Obs" };
            Dictionary<string, string> obsColumns = new Dictionary<string, string>();
            //obsColumns.Add("id", "id");
            obsColumns.Add(pls_model.target, pls_model.target);

            frmColumnMapper colMapper = new frmColumnMapper(obsColumns, dt, headerCaptions, false);
            DialogResult dr = colMapper.ShowDialog();

            if (dr == DialogResult.OK)
            {
                dt = colMapper.MappedTable;
                dgvObs.DataSource = dt;
            }

            string target = pls_model.target;
            for(int indx=0; indx<dgvObs.RowCount; indx++)
                if (Convert.ToDouble(dgvObs.Rows[indx].Cells[target].Value) > pls_model.regulatory_threshold )
                    dgvObs.Rows[indx].Cells[target].Style.ForeColor = Color.Red;

            foreach (DataGridViewColumn dvgCol in dgvObs.Columns)
                dvgCol.SortMode = DataGridViewColumnSortMode.NotSortable;
        }
        private void ShowExportDialog()
        {
            ImportExport dialog = new ImportExport();
            dialog.Options = _options;
            dialog.EnterExportMode(ImportExport.ExporPanelTab.Schedule);

            dialog.ShowDialog();
        }
        private void ShowImportDialog()
        {
            ImportExport dialog = new ImportExport();
            dialog.Options = _options;
            dialog.EnterImportMode();

            dialog.ShowDialog();
            LoadTasks();
        }
Exemple #41
0
        private void btnImportObs_Click(object sender, EventArgs e)
        {
            VBTools.ImportExport import = new ImportExport();
            DataTable dt = import.Input;
            if (dt == null)
                return;

            string[] headerCaptions = { "Obs IDs", "Obs" };
            //Dictionary<string, string> obsColumns = new Dictionary<string, string>();
               // obsColumns.Add("ID", "ID");
            //obsColumns.Add("Observation", "Observation");

            string[] obsColumns = { "ID", "Observation" };

            frmColumnMapper colMapper = new frmColumnMapper(obsColumns, dt, headerCaptions, true);
            DialogResult dr = colMapper.ShowDialog();

            if (dr == DialogResult.OK)
            {
                dt = colMapper.MappedTable;
                dgvObs.DataSource = dt;
            }
            else
                return;

            foreach (DataGridViewColumn dvgCol in dgvObs.Columns)
                dvgCol.SortMode = DataGridViewColumnSortMode.NotSortable;

            setViewOnGrid(dgvObs);
        }