Example #1
0
        public override bool CheckLogin(string username, string password, VirtualFtpSession session)
        {
            if (username.ToLower().Equals(server.RootFolder.Name.ToLower()))
            {
                return(Common.Solution.CreateFromContext("").RootPassword.Equals(password));
            }

            String[] arr = username.Split('_');
            if (arr.Length == 2)
            {
                String solutionName = arr[0];

                if (arr[1].ToLower().Equals("admin"))
                {
                    foreach (String dir in System.IO.Directory.EnumerateDirectories(rootPath))
                    {
                        String name = new System.IO.DirectoryInfo(dir).Name;
                        if (solutionName.ToLower().Equals(name.ToLower()))
                        {
                            return(Common.Solution.CreateFromContext(solutionName).SolutionPassword.Equals(password));
                        }
                    }
                    return(false);
                }

                Guid userId;
                if (System.Guid.TryParse(arr[1], out userId))
                {
                    return(Common.Logon.UserExists(solutionName, userId, password));
                }
            }

            return(false);
        }
Example #2
0
 public void Awake()
 {
     Profiler.DMPReferenceTime.Start();
     GameObject.DontDestroyOnLoad(this);
     assemblyPath = new DirectoryInfo(Assembly.GetExecutingAssembly().Location).FullName;
     string kspPath = new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName;
     //I find my abuse of Path.Combine distrubing.
     assemblyShouldBeInstalledAt = Path.Combine(Path.Combine(Path.Combine(Path.Combine(kspPath, "GameData"), "DarkMultiPlayer"), "Plugins"), "DarkMultiPlayer.dll");
     UnityEngine.Debug.Log("KSP installed at " + kspPath);
     UnityEngine.Debug.Log("DMP installed at " + assemblyPath);
     incorrectlyInstalled = (assemblyPath.ToLower() != assemblyShouldBeInstalledAt.ToLower());
     if (incorrectlyInstalled)
     {
         UnityEngine.Debug.LogError("DMP is installed at '" + assemblyPath + "', It should be installed at '" + assemblyShouldBeInstalledAt + "'");
         return;
     }
     if (Settings.fetch.disclaimerAccepted != 1)
     {
         modDisabled = true;
         DisclaimerWindow.Enable();
     }
     SetupDirectoriesIfNeeded();
     //Register events needed to bootstrap the workers.
     lock (eventLock)
     {
         resetEvent.Add(LockSystem.Reset);
         resetEvent.Add(AdminSystem.Reset);
         resetEvent.Add(AsteroidWorker.Reset);
         resetEvent.Add(ChatWorker.Reset);
         resetEvent.Add(CraftLibraryWorker.Reset);
         resetEvent.Add(DebugWindow.Reset);
         resetEvent.Add(DynamicTickWorker.Reset);
         resetEvent.Add(FlagSyncer.Reset);
         resetEvent.Add(PlayerColorWorker.Reset);
         resetEvent.Add(PlayerStatusWindow.Reset);
         resetEvent.Add(PlayerStatusWorker.Reset);
         resetEvent.Add(QuickSaveLoader.Reset);
         resetEvent.Add(ScenarioWorker.Reset);
         resetEvent.Add(ScreenshotWorker.Reset);
         resetEvent.Add(TimeSyncer.Reset);
         resetEvent.Add(VesselWorker.Reset);
         resetEvent.Add(WarpWorker.Reset);
         GameEvents.onHideUI.Add(() =>
         {
             showGUI = false;
         });
         GameEvents.onShowUI.Add(() =>
         {
             showGUI = true;
         });
     }
     FireResetEvent();
     HandleCommandLineArgs();
     DarkLog.Debug("DarkMultiPlayer " + Common.PROGRAM_VERSION + ", protocol " + Common.PROTOCOL_VERSION + " Initialized!");
 }
        private bool ConsistencyCheckCategoryLocalToSlide()
        {
            var categoriesOnDisk = Directory.EnumerateDirectories(Path).ToList();
            var categoryLost = false;

            foreach (var categoryPath in categoriesOnDisk)
            {
                var categoryName = new DirectoryInfo(categoryPath).Name;

                if (Slides.All(category => category.Name.ToLower() != categoryName.ToLower()))
                {
                    categoryLost = true;
                    break;
                }
            }

            return categoryLost;
        }
Example #4
0
        //example 1: simple
        //>arnis /ws:"c:\github\arnis"
        //>arnis /ws:"c:\github\arnis" /sf:"c:\skip.txt"

        //example 1: publish into web sink
        //>arnis /web /r /u:[email protected]
        //>arnis /web /apk:"XXXX-XXXX" /ws:"c:\github\arnis" /wsn="arnis"

        static void Main(string[] args)
        {
            try
            {
                var settings = args.Select(a =>
                {
                    var parameter = a.Split('=');
                    return new
                    {
                        Key = parameter[0].Replace("/", ""),
                        Value = parameter.Length == 2 ? parameter[1] : null
                    };
                }).ToDictionary(m => m.Key, m => m.Value);

                PrintSettings(settings);

                //capture /sf
                var skipList = GetSkipList(settings);

                //capture /web
                var slashWebExist = settings.ContainsKey("web");
                if (slashWebExist)
                {
                    //capture /web /r
                    var slashRExist = settings.ContainsKey("r");
                    if (slashRExist)
                    {
                        //capture /web /r /u
                        var slashUExist = settings.ContainsKey("u");
                        if (slashUExist)
                        {
                            var userName = settings.SingleOrDefault(s => s.Key == "u").Value;

                            var sinkRegistrar = new WebSinkRegistrar();
                            var registration = sinkRegistrar.Register(userName);

                            if (null != registration)
                            {
                                string response =
                                      $"{Environment.NewLine}   Api Key: {registration.ApiKey}"
                                    + $"{Environment.NewLine}   Workspace: {registration.Workspace}"
                                    + $"{Environment.NewLine}   Workspace Uri: {registration.WorkspaceUri}"
                                    + $"{Environment.NewLine}   Account Uri: {registration.AccountUri}";

                                ConsoleEx.Ok($"Done! Please keep your API key secret.{response}");
                            }
                        }
                    }

                    //capture /web /apk /ws /wsn
                    var slashApkExist = settings.ContainsKey("apk");
                    if (slashApkExist)
                    {
                        var apiKey = settings.SingleOrDefault(s => s.Key == "apk").Value;

                        //validate working folder /ws is required parameter
                        string slashWs = settings.SingleOrDefault(s => s.Key == "ws").Value;
                        if (null == slashWs)
                        {
                            throw new ArgumentException("Missing parameter", "ws");
                        }

                        //validate working folder /wsn is required parameter
                        string slashWsn = settings.SingleOrDefault(s => s.Key == "wsn").Value;
                        if (null == slashWsn)
                        {
                            throw new ArgumentException("Missing parameter", "wsn");
                        }

                        //run all trackers, at this point we have all the dependencies
                        var trackerResult = TrackDependencies(slashWs, skipList);

                        //create the workspace details
                        var workspace = new Workspace
                        {
                            Name = slashWsn,
                            Solutions = trackerResult.Solutions,
                            Logs = trackerResult.Logs,
                            ApiKey = apiKey
                        };

                        var webSink = new WebSink();
                        webSink.Flush(workspace);
                    }
                }
                else
                {
                    //capture /ws
                    string slashWs = settings.SingleOrDefault(s => s.Key == "ws").Value;
                    if (null == slashWs)
                    {
                        throw new ArgumentException("Missing parameter", "ws");
                    }

                    //fall back to default csv as default sink 
                    //run all trackers, at this point we have all the dependencies
                    var trackerResult = TrackDependencies(slashWs, skipList);

                    //create the workspace details
                    string worspaceName = new DirectoryInfo(slashWs.TrimEnd(Path.DirectorySeparatorChar)).Name;
                    var workspace = new Workspace
                    {
                        Name = worspaceName.ToLower(),
                        Solutions = trackerResult.Solutions,
                        Logs = trackerResult.Logs
                    };

                    //run default sink
                    SinkDependencies("csv", workspace);
                }

            }
            catch (Exception ex)
            {
                ConsoleEx.Error("Arnis.NET breaks ;(. \n" + ex.Message);
            }
        }
Example #5
0
        private void cmdCreate_Click(object sender, EventArgs e)
        {
            // ensure source path format
            txtRoot.Text = System.IO.Path.GetFullPath(txtRoot.Text);
            if (txtRoot.Text.EndsWith(@"\"))
            {
                txtRoot.Text = txtRoot.Text.Substring(0, txtRoot.Text.Length - 1);
            }
            if (IsWildcardMatch("?:", txtRoot.Text, false))
            {
                txtRoot.Text += @"\";                                                   // add backslash to path if only letter and colon eg "c:"
            }
            // add slash or backslash to end of link (in cases where it is clearthat we we can)
            if (!txtLinkRoot.Text.EndsWith(@"/") && txtLinkRoot.Text.ToLower().StartsWith(@"http"))                     // web site
            {
                txtLinkRoot.Text += @"/";
            }
            if (!txtLinkRoot.Text.EndsWith(@"\") && IsWildcardMatch("?:*", txtLinkRoot.Text, false))                    // local disk
            {
                txtLinkRoot.Text += @"\";
            }

            // get output file
            if (outFile == "")
            {
                string fileName = new System.IO.DirectoryInfo(txtRoot.Text + @"\").Name;
                char[] invalid  = System.IO.Path.GetInvalidFileNameChars();
                for (int i = 0; i < invalid.Length; i++)
                {
                    fileName = fileName.Replace(invalid[i].ToString(), "");
                }

                saveFileDialog1.DefaultExt = "html";
                if (!fileName.ToLower().EndsWith(".html"))
                {
                    fileName += ".html";
                }
                saveFileDialog1.FileName         = fileName;
                saveFileDialog1.InitialDirectory = System.IO.Path.GetDirectoryName(txtRoot.Text);
                if (saveFileDialog1.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }
            else // command line
            {
                saveFileDialog1.FileName = outFile;
            }

            if (!saveFileDialog1.FileName.ToLower().EndsWith(".html"))
            {
                saveFileDialog1.FileName += ".html";
            }

            // make sure output path exists
            if (!System.IO.Directory.Exists(System.IO.Path.GetDirectoryName(saveFileDialog1.FileName)))
            {
                MessageBox.Show("The output folder does not exists...\n\n" + System.IO.Path.GetDirectoryName(saveFileDialog1.FileName), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // begin generating html
            Cursor.Current      = Cursors.WaitCursor;
            this.Text           = "Snap2HTML (Working... Press Escape to Cancel)";
            tabControl1.Enabled = false;
            backgroundWorker.RunWorkerAsync();
        }
Example #6
0
        public void CreateReconciliationFile(string sourcePath)
        {
            try
            {
                using (var container = new TransactionModelContainer())
                {
                    var fileName = GetFileName(sourcePath);
                    var fileinfo = new FileInfo(fileName);
                    var contents = ReadFile(sourcePath);

                    if (!IsValidFile(fileinfo))
                    {
                        var newFileName = MoveFileToFolder(container, errPath, sourcePath, fileinfo);
                        container.ReconciliationFiles.AddObject(new ReconciliationFile
                        {
                            FileName = fileinfo.Name,
                            Contents = contents,
                            CreateDate = DateTime.Now,
                            CreateBy = "System",
                            BackupPath = errPath + newFileName,
                            IsValid = false,
                            Source = null,
                            IsRead = false,
                            FileType = FileType.E.ToString(),
                        });
                    }
                    else
                    {
                        var parentFolder = new DirectoryInfo(successPath).Parent.Name;
                        var newFileName = MoveFileToFolder(container, successPath, sourcePath, fileinfo);
                        container.ReconciliationFiles.AddObject(new ReconciliationFile
                        {
                            FileName = fileinfo.Name,
                            Contents = contents,
                            CreateDate = DateTime.Now,
                            CreateBy = "System",
                            BackupPath = newFileName, //successPath + newFileName,
                            IsValid = true,
                            Source = null,
                            IsRead = false,
                            FileType = (parentFolder.ToLower().Contains("credit"))
                                            ? FileType.C.ToString()
                                            : FileType.P.ToString(),
                        });
                    }
                    container.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                ErrorLog.Log("System", ex, SystemError.ServiceReader);
            }
        }
Example #7
0
        public override bool CheckLogin(string username, string password, VirtualFtpSession session)
        {
            if (username.ToLower().Equals(server.RootFolder.Name.ToLower()))
            {
                return Common.Solution.CreateFromContext("").RootPassword.Equals(password);
            }

            String[] arr = username.Split('_');
            if (arr.Length == 2)
            {
                String solutionName = arr[0];

                if (arr[1].ToLower().Equals("admin"))
                {

                    foreach (String dir in System.IO.Directory.EnumerateDirectories(rootPath))
                    {
                        String name = new System.IO.DirectoryInfo(dir).Name;
                        if (solutionName.ToLower().Equals(name.ToLower()))
                        {
                            return Common.Solution.CreateFromContext(solutionName).SolutionPassword.Equals(password);
                        }
                    }
                    return false;
                }

                Guid userId;
                if (System.Guid.TryParse(arr[1], out userId))
                {
                    return Common.Logon.UserExists(solutionName, userId, password);
                }
            }

            return false;
        }