예제 #1
0
        /// <summary>
        /// Wraps the PCSC function 
        /// LONG SCardEstablishContext(
        ///		IN DWORD dwScope,
        ///		IN LPCVOID pvReserved1,
        ///		IN LPCVOID pvReserved2,
        ///		OUT LPSCARDCONTEXT phContext
        ///	);
        /// </summary>
        /// <param name="Scope"></param>
        public void EstablishContext(SCOPE Scope)
        {
            IntPtr hContext = Marshal.AllocHGlobal(Marshal.SizeOf(context));

            lastError = PCSC.SCardEstablishContext((uint)Scope, IntPtr.Zero, IntPtr.Zero, hContext);
            if (lastError != 0)
            {
                Marshal.FreeHGlobal(hContext);
                ThrowSmartcardException("SCardEstablishContext", lastError);
            }

            context = Marshal.ReadIntPtr(hContext);

            Marshal.FreeHGlobal(hContext);
        }
예제 #2
0
 public ToDoTask(string title, string description, DateTime startDate, DateTime endDate, int Registered_userId, STATUS status, SCOPE scope)
 {
     Title            = title;
     Description      = description;
     StartDate        = startDate;
     EndDate          = endDate;
     RegisteredUserId = Registered_userId;
     Status           = status;
     Scope            = scope;
 }
예제 #3
0
        /// <summary>
        /// Wraps the PCSC function 
        /// LONG SCardEstablishContext(
        ///		IN DWORD dwScope,
        ///		IN LPCVOID pvReserved1,
        ///		IN LPCVOID pvReserved2,
        ///		OUT LPSCARDCONTEXT phContext
        ///	);
        /// </summary>
        /// <param name="Scope"></param>
        public void EstablishContext(SCOPE Scope)
        {
            IntPtr	hContext = Marshal.AllocHGlobal(Marshal.SizeOf(m_hContext));

            m_nLastError = SCardEstablishContext((uint) Scope, IntPtr.Zero, IntPtr.Zero, hContext);
            if (m_nLastError != 0)
            {
                string msg = "SCardEstablishContext error: " + m_nLastError;

                Marshal.FreeHGlobal(hContext);
                throw new Exception(msg);
            }

            m_hContext = Marshal.ReadIntPtr(hContext);

            Marshal.FreeHGlobal(hContext);
        }
예제 #4
0
 public void SetScope(SCOPE setScope)
 {
     scope = setScope;
 }
예제 #5
0
 public void SetLocal()
 {
     scope  = SCOPE.LOCAL;
     status = POINTERSTATUS.EVALUATE;
 }
예제 #6
0
        public DataTable GetNotesNameAndIdByScopeAndParent(SCOPE aScope, int aParentID)
        {
            if (isDebugEnabled)
            {
                logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in");
            }

            DataTable table = new DataTable(TableNames.NOTES);

            try
            {
                string cmdText =
                    "SELECT _NOTEID, _NAME " +
                    "FROM NOTES " +
                    "WHERE _SCOPE = @nScope AND _PARENTID = @nParentID " +
                    "ORDER BY _DATE";

                if (compactDatabaseType)
                {
                    using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection())
                    {
                        SqlCeParameter[] spParams = new SqlCeParameter[2];
                        spParams[0] = new SqlCeParameter("@nScope", (int)aScope);
                        spParams[1] = new SqlCeParameter("@nParentID", aParentID);

                        using (SqlCeCommand command = new SqlCeCommand(cmdText, conn))
                        {
                            command.Parameters.AddRange(spParams);
                            new SqlCeDataAdapter(command).Fill(table);
                        }
                    }
                }
                else
                {
                    using (SqlConnection conn = DatabaseConnection.CreateOpenStandardConnection())
                    {
                        SqlParameter[] spParams = new SqlParameter[2];
                        spParams[0] = new SqlParameter("@nScope", (int)aScope);
                        spParams[1] = new SqlParameter("@nParentID", aParentID);

                        using (SqlCommand command = new SqlCommand(cmdText, conn))
                        {
                            command.Parameters.AddRange(spParams);
                            new SqlDataAdapter(command).Fill(table);
                        }
                    }
                }
            }
            catch (SqlException ex)
            {
                Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine +
                                            "Please see the log file for further details.");
                logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
            }
            catch (SqlCeException ex)
            {
                Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine +
                                            "Please see the log file for further details.");
                logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
            }
            catch (Exception ex)
            {
                Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine +
                                            "Please see the log file for further details.");

                logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
            }


            if (isDebugEnabled)
            {
                logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out");
            }
            return(table);
        }
예제 #7
0
 public FormNewNote(SCOPE scope, int parentID)
 {
     InitializeComponent();
     _scope    = scope;
     _parentId = parentID;
 }
예제 #8
0
 public static void SET_ADD_BUTTON_COLOR(SCOPE scope = SCOPE.BCKG)
 {
     setColor(ADD_BUTTON_COLOR, scope);
 }
예제 #9
0
 public static void SET_REMOVE_BUTTON_COLOR(SCOPE scope = SCOPE.BCKG)
 {
     setColor(REMOVE_BUTTON_COLOR, scope);
 }
예제 #10
0
 public static void SET_SUBTITLE2_COLOR(SCOPE scope = SCOPE.BCKG)
 {
     setColor(SUBTITLE2_COLOR, scope);
 }
예제 #11
0
 public static void SET_MAINTITLE_COLOR(SCOPE scope = SCOPE.BCKG)
 {
     setColor(MAINTITLE_COLOR, scope);
 }
예제 #12
0
        public static DSReplay DecodePython(Object stateInfo, bool toJson = true, bool GetDetails = false)
        {
            Interlocked.Increment(ref THREADS);
            DSReplay dsreplay = null;
            string   rep      = (string)stateInfo;
            //Console.WriteLine("Working on rep ..");
            string id = Path.GetFileNameWithoutExtension(rep);

            AddLog("Working on rep .. " + id);
            AddLog("Loading s2protocol ..");
            dynamic MPQArchive = SCOPE.GetVariable("MPQArchive");
            dynamic archive    = null;
            //dynamic files = null;
            dynamic contents = null;
            dynamic versions = null;

            try
            {
                archive = MPQArchive(rep);
                //files = archive.extract();
                contents = archive.header["user_data_header"]["content"];

                //versions = SCOPE.GetVariable("versions");
                versions = SCOPE.GetVariable("versions");
            }
            catch
            {
                AddLog("No MPQArchive for " + id);
                FailCleanup(rep, GetDetails);
                return(null);
            }
            dynamic header = null;

            try
            {
                lock (_locker)
                {
                    header = versions.latest().decode_replay_header(contents);
                }
            }
            catch (Exception e)
            {
                AddLog("No header for " + id + ": " + e.Message + " " + versions.latest().ToString());
                FailCleanup(rep, GetDetails);
                return(null);
            }

            if (header != null)
            {
                AddLog("Loading s2protocol header finished");
                var     baseBuild = header["m_version"]["m_baseBuild"];
                dynamic protocol  = null;
                try
                {
                    protocol = versions.build(baseBuild);
                }
                catch
                {
                    AddLog("No protocol found for " + id + " " + baseBuild.ToString());
                    FailCleanup(rep, GetDetails);
                    return(null);
                }
                AddLog("Loading s2protocol protocol finished");


                // init

                /**
                 * var init_enc = archive.read_file("replay.initData");
                 * dynamic init_dec = null;
                 * try
                 * {
                 *  init_dec = protocol.decode_replay_initdata(init_enc);
                 * }
                 * catch
                 * {
                 *  AddLog("No Init version for " + id);
                 *  FailCleanup(rep, GetDetails);
                 *  return null;
                 * }
                 * AddLog("Loading s2protocol init finished");
                 *
                 * s2parse.GetInit(rep, init_dec);
                 **/

                // details
                var details_enc = archive.read_file("replay.details");

                dynamic details_dec = null;
                try
                {
                    details_dec = protocol.decode_replay_details(details_enc);
                }
                catch
                {
                    AddLog("No Version for " + id);
                    FailCleanup(rep, GetDetails);
                    return(null);
                }
                AddLog("Loading s2protocol details finished");

                //replay = DSparseNG.GetDetails(rep, details_dec);
                dsreplay = Details.Get(rep, details_dec);

                // trackerevents
                var trackerevents_enc = archive.read_file("replay.tracker.events");

                dynamic trackerevents_dec = null;
                try
                {
                    trackerevents_dec = protocol.decode_replay_tracker_events(trackerevents_enc);
                    AddLog("Loading trackerevents success");
                }
                catch
                {
                    AddLog("No tracker version for " + id);
                    FailCleanup(rep, GetDetails);
                    return(null);
                }
                AddLog("Loading s2protocol trackerevents finished");

                try
                {
                    //replay = DSparseNG.GetTrackerevents(trackerevents_dec, replay, GetDetails);
                    dsreplay = Trackerevents.Get(trackerevents_dec, dsreplay);
                }
                catch
                {
                    AddLog("Trackerevents failed for " + id);
                    FailCleanup(rep, GetDetails);
                    return(null);
                }

                AddLog("trackerevents analyzed.");

                Initialize.Replay(dsreplay, GetDetails);

                if (toJson == true)
                {
                    DSReplays.Add(dsreplay);
                }
            }
            Interlocked.Increment(ref DONE);
            Interlocked.Decrement(ref THREADS);

            return(null);
        }
예제 #13
0
 public UserDataCategory(SCOPE scope)
     : this()
 {
     _scope = scope;
 }
예제 #14
0
파일: s2decode.cs 프로젝트: Mnuzz/dsmm_web
        public dsreplay DecodePython(Object stateInfo, int ID)
        {
            Interlocked.Increment(ref THREADS);
            //Console.WriteLine("Threads running: " + THREADS);
            dsreplay replay = null;
            string   rep    = (string)stateInfo;
            string   id     = Path.GetFileNameWithoutExtension(rep);

            Program.Log("Working on rep ..");
            Program.Log("Loading s2protocol ..");
            dynamic MPQArchive = SCOPE.GetVariable("MPQArchive");
            dynamic archive    = null;
            dynamic files      = null;
            dynamic contents   = null;
            dynamic versions   = null;

            try
            {
                archive  = MPQArchive(rep);
                files    = archive.extract();
                contents = archive.header["user_data_header"]["content"];

                //versions = SCOPE.GetVariable("versions");
                versions = SCOPE.GetVariable("versions");
            }
            catch
            {
                Program.Log("No MPQArchive for " + id);
                FailCleanup(rep);
                return(null);
            }
            dynamic header = null;

            try
            {
                lock (_locker)
                {
                    header = versions.latest().decode_replay_header(contents);
                }
            }
            catch (Exception e)
            {
                Program.Log("No header for " + id + ": " + e.Message);
                FailCleanup(rep);
                return(null);
            }

            if (header != null)
            {
                Program.Log("Loading s2protocol header finished");
                var     baseBuild = header["m_version"]["m_baseBuild"];
                dynamic protocol  = null;
                try
                {
                    protocol = versions.build(baseBuild);
                }
                catch
                {
                    Program.Log("No protocol found for " + id);
                    FailCleanup(rep);
                    return(null);
                }
                Program.Log("Loading s2protocol protocol finished");


                // init
                var     init_enc = archive.read_file("replay.initData");
                dynamic init_dec = null;
                try
                {
                    init_dec = protocol.decode_replay_initdata(init_enc);
                }
                catch
                {
                    Program.Log("No Init version for " + id);
                    FailCleanup(rep);
                    return(null);
                }
                Program.Log("Loading s2protocol init finished");

                s2parse.GetInit(rep, init_dec);


                // details
                var     details_enc = archive.read_file("replay.details");
                dynamic details_dec = null;
                try
                {
                    details_dec = protocol.decode_replay_details(details_enc);
                }
                catch
                {
                    Program.Log("No Version for " + id);
                    FailCleanup(rep);
                    return(null);
                }
                Program.Log("Loading s2protocol details finished");

                //s2replay replay = s2parse.GetDetails(rep, details_dec);
                replay = DSparseNG.GetDetails(rep, details_dec);

                // trackerevents
                var     trackerevents_enc = archive.read_file("replay.tracker.events");
                dynamic trackerevents_dec = null;
                try
                {
                    trackerevents_dec = protocol.decode_replay_tracker_events(trackerevents_enc);
                    Program.Log("Loading trackerevents success");
                }
                catch
                {
                    Program.Log("No tracker version for " + id);
                    FailCleanup(rep);
                    return(null);
                }
                Program.Log("Loading s2protocol trackerevents finished");

                replay = DSparseNG.GetTrackerevents(rep, trackerevents_dec, replay);
                //s2parse.GetTrackerevents(rep, protocol.decode_replay_tracker_events(trackerevents_enc));
                Interlocked.Increment(ref REPID);
                //replay.ID = REPID;
                replay.ID = ID;
                replay.Init();
                //if (!replaysng.ContainsKey(repid)) replaysng.TryAdd(repid, replay);
                //Save(Program.myJson_file, replay);
                SaveDS(Program.myJson_file, replay);
            }

            Interlocked.Increment(ref TOTAL_DONE);
            double wr = 0;

            if (TOTAL > 0)
            {
                wr = TOTAL_DONE * 100 / TOTAL;
            }
            wr = Math.Round(wr, 2);

            if (TOTAL_DONE >= TOTAL)
            {
                DateTime end      = DateTime.UtcNow;
                TimeSpan timeDiff = end - START;
                Console.WriteLine(timeDiff.TotalSeconds);
                END = end;
                if (REDO.Count > 0)
                {
                    Console.WriteLine("REDO: " + REDO.Count);
                    //RedoScan();
                }
                else
                {
                    //Stop_decode();
                }
            }

            Interlocked.Decrement(ref THREADS);
            return(replay);
        }