/// <summary>
        /// The initializer for this ShellComponent.
        /// </summary>
        /// <param name="lifetime">
        /// The lifetime for this object.
        /// </param>
        public void Init(JB::JetBrains.DataFlow.Lifetime lifetime)
        {
            RegistryUtils registryUtils = new RegistryUtils();

            object oneTimeInitializationRequiredRegistryKey = registryUtils.CUGetValue("LastInitializationDate");
            DateTime initializationDate = Convert.ToDateTime(oneTimeInitializationRequiredRegistryKey);

            string todayAsString = DateTime.Today.ToString("yyyy-MM-dd");

            string value = registryUtils.LMGetValue("InstallDate") as string;

            DateTime lastInstalledDate;

            try
            {
                lastInstalledDate = Convert.ToDateTime(value);

                // If the installer stored a date that has now been read back in and seems to be in the future
                // then use the LocalUserInstallDate value.
                if (lastInstalledDate > DateTime.Today)
                {
                    lastInstalledDate = GetInstallDateFromLocalUserRegistry(registryUtils, todayAsString);
                }
            }
            catch (FormatException ex)
            {
                // In some locales the installer saves the date in a format we can't parse back out.
                // Use today as the installed date and store it in the HKCU key.
                lastInstalledDate = GetInstallDateFromLocalUserRegistry(registryUtils, todayAsString);
            }

            if (oneTimeInitializationRequiredRegistryKey == null || initializationDate < lastInstalledDate)
            {
                SettingsStore settingsStore = Shell.Instance.GetComponent<SettingsStore>();

                IContextBoundSettingsStoreLive settings = settingsStore.BindToContextLive(lifetime, ContextRange.ApplicationWide);

                bool checkReSharperCodeStyleOptionsAtStartUp = settings.GetValue((StyleCopOptionsSettingsKey key) => key.CheckReSharperCodeStyleOptionsAtStartUp);

                if (checkReSharperCodeStyleOptionsAtStartUp)
                {
                    if (!StyleCopOptionsPage.CodeStyleOptionsValid(settings))
                    {
                        DialogResult result =
                            MessageBox.Show(
                                @"Your ReSharper code style settings are not completely compatible with StyleCop. Would you like to reset them now?", 
                                @"StyleCop", 
                                MessageBoxButtons.YesNo, 
                                MessageBoxIcon.Question, 
                                MessageBoxDefaultButton.Button2);
                        if (result == DialogResult.Yes)
                        {
                            StyleCopOptionsPage.CodeStyleOptionsReset(settings);
                        }
                    }
                }
            }

            registryUtils.CUSetValue("LastInitializationDate", todayAsString);
        }
Exemplo n.º 2
0
        public JB ReduceStock(int id, int number)
        {
            JB jb = _context.JBs.Find(id);

            if (jb.Num >= number)
            {
                jb.Num -= number;
                _context.JBs.Update(jb);
                _context.SaveChanges();
                System.Console.WriteLine("扣除数量成功,当前库存剩余:" + jb.Num);
                return(jb);
            }
            System.Console.WriteLine("库存不足!当前库存剩余:" + jb.Num);
            return(null);
        }
        /// <summary>
        /// Performs the QuickFix, ensures the file is both writable and creates a transaction.
        /// </summary>
        /// <param name="solution">
        /// Current Solution.
        /// </param>
        /// <param name="progress">
        /// Progress Indicator for the fix.
        /// </param>
        /// <returns>
        /// The execute transaction.
        /// </returns>
        protected override Action<ITextControl> ExecutePsiTransaction(ISolution solution, JB::JetBrains.Application.Progress.IProgressIndicator progress)
        {
            return delegate(ITextControl textControl)
                {
                    solution.GetComponent<DocumentManagerOperations>().SaveAllDocuments();

                    using (
                        JB::JetBrains.Util.ITransactionCookie documentTransaction =
                            solution.GetComponent<DocumentTransactionManager>().CreateTransactionCookie(JB::JetBrains.Util.DefaultAction.Commit, "action name"))
                    {
                        PsiManager.GetInstance(solution).DoTransaction(() => this.ExecuteWriteLockableTransaction(solution, textControl), "Code cleanup");
                    }
                };
        }
        /// <summary>
        /// Performs the QuickFix, ensures the file is both writable and creates a transaction.
        /// </summary>
        /// <param name="solution">
        /// Current Solution.
        /// </param>
        /// <param name="progress">
        /// Progress Indicator for the fix.
        /// </param>
        /// <returns>
        /// The execute transaction.
        /// </returns>
        protected override Action<ITextControl> ExecuteTransaction(ISolution solution, JB::JetBrains.Application.Progress.IProgressIndicator progress)
        {
            return delegate(ITextControl textControl)
                {
                    DocumentManager.GetInstance(solution).SaveAllDocuments();

                    using (DocumentManager.GetInstance(solution).EnsureWritable())
                    {
                        PsiManager.GetInstance(solution).DoTransaction(() => this.ExecuteWriteLockableTransaction(solution, textControl));
                    }
                };
        }
        /// <summary>
        /// Determines whether the current QuickFix is available for the violation.
        /// </summary>
        /// <remarks>
        /// Essentially to display the bulb item in the IDE the current ViolationID
        /// must match the name of the QuickFix Class.
        /// </remarks>
        /// <param name="cache">
        /// Current Data Cache.
        /// </param>
        /// <returns>
        /// Whether the current QuickFix is available for the violation.
        /// </returns>
        public bool IsAvailable(JB::JetBrains.Util.IUserDataHolder cache)
        {
            // use a more resiliant matching method - this caught me out
            // quite a bit while I was refactoring and debugging and wondering
            // why no bulb items were appearing
            if (this.Violation.CheckId.StartsWith("SA") || this.Violation.CheckId.StartsWith("BB"))
            {
                return this.GetType().Name.Substring(2).StartsWith(this.Violation.CheckId.Substring(2));
            }

            return this.GetType().Name.StartsWith(this.Violation.CheckId);
        }
 /// <summary>
 /// Initializes a new instance of the StyleCopCodeStyleChecker class.
 /// </summary>
 /// <param name="lifetime">
 /// The lifetime for this instance.
 /// </param>
 public StyleCopCodeStyleChecker(JB::JetBrains.DataFlow.Lifetime lifetime)
 {
     StyleCopReferenceHelper.EnsureStyleCopIsLoaded();
     this.Init(lifetime);
 }
 /// <summary>
 /// True if this QuickFix is available.
 /// </summary>
 /// <param name="cache">
 /// The cache object to use.
 /// </param>
 /// <returns>
 /// The is available.
 /// </returns>
 public bool IsAvailable(JB::JetBrains.Util.IUserDataHolder cache)
 {
     return true;
 }
        /// <summary>
        /// Executes the standard C Sharp reformatter on the lines passed in.
        /// </summary>
        /// <param name="solution">
        /// The solution.
        /// </param>
        /// <param name="document">
        /// The document.
        /// </param>
        /// <param name="startLine">
        /// The line to start the format of. Zero based.
        /// </param>
        /// <param name="endLine">
        /// The line to end the formatting.
        /// </param>
        public static void FormatLines(
            ISolution solution, 
            IDocument document, 
            JB::JetBrains.Util.dataStructures.TypedIntrinsics.Int32<DocLine> startLine, 
            JB::JetBrains.Util.dataStructures.TypedIntrinsics.Int32<DocLine> endLine)
        {
            JB::JetBrains.Util.dataStructures.TypedIntrinsics.Int32<DocLine> lineCount = document.GetLineCount();

            if (startLine < (JB::JetBrains.Util.dataStructures.TypedIntrinsics.Int32<DocLine>)0)
            {
                startLine = (JB::JetBrains.Util.dataStructures.TypedIntrinsics.Int32<DocLine>)0;
            }

            if (endLine > lineCount.Minus1())
            {
                endLine = lineCount.Minus1();
            }

            int startOffset = document.GetLineStartOffset(startLine);
            int endOffset = document.GetLineEndOffsetNoLineBreak(endLine);

            CSharpFormatterHelper.FormatterInstance.Format(
                solution, 
                new DocumentRange(document, new JB::JetBrains.Util.TextRange(startOffset, endOffset)), 
                SolutionCodeStyleSettings.GetInstance(solution).CodeStyleSettings, 
                CodeFormatProfile.DEFAULT, 
                true, 
                true, 
                NullProgressIndicator.Instance);
        }
        /// <summary>
        /// Gets a HashSet of tokens for the entire line specified.
        /// </summary>
        /// <param name="solution">
        /// The solution.
        /// </param>
        /// <param name="lineNumber">
        /// The line number.
        /// </param>
        /// <param name="document">
        /// The document.
        /// </param>
        /// <returns>
        /// A HashSet of tokens for this line.
        /// </returns>
        public static IList<ITokenNode> GetTokensForLine(
            ISolution solution, JB::JetBrains.Util.dataStructures.TypedIntrinsics.Int32<DocLine> lineNumber, IDocument document)
        {
            List<ITokenNode> tokens = new List<ITokenNode>();

            ICSharpFile file = Utils.GetCSharpFile(solution, document);

            using (ReadLockCookie.Create())
            {
                // must call GetLineCount first - it forces the line index to be built
                document.GetLineCount();
                int start = document.GetLineStartOffset(lineNumber);
                int end = document.GetLineEndOffsetNoLineBreak(lineNumber);

                for (int i = start; i < end; i++)
                {
                    ITokenNode t = (ITokenNode)file.FindTokenAt(new TreeOffset(i));
                    tokens.Add(t);
                }
            }

            return tokens;
        }
 /// <summary>
 /// Gets a TextRange covering the entire line specified.
 /// </summary>
 /// <param name="document">
 /// The document the line is in.
 /// </param>
 /// <param name="lineNumber">
 /// The line number to use. 0 based.
 /// </param>
 /// <returns>
 /// A TextRange for the line.
 /// </returns>
 public static JB::JetBrains.Util.TextRange GetTextRangeForLineNumber(
     IDocument document, JB::JetBrains.Util.dataStructures.TypedIntrinsics.Int32<DocLine> lineNumber)
 {
     using (ReadLockCookie.Create())
     {
         // must call GetLineCount first - it forces the line index to be built
         document.GetLineCount();
         int start = document.GetLineStartOffset(lineNumber);
         int end = document.GetLineEndOffsetNoLineBreak(lineNumber);
         return new JB::JetBrains.Util.TextRange(start, end);
     }
 }
        /// <summary>
        /// Gets a TextRange for the ReSharper line number provided.
        /// </summary>
        /// <param name="projectFile">
        /// The project file to use.
        /// </param>
        /// <param name="resharperLineNumber">
        /// These are zero based.
        /// </param>
        /// <returns>
        /// A TextRange covering the line number specified.
        /// </returns>
        public static JB::JetBrains.Util.TextRange GetTextRange(
            IProjectFile projectFile, JB::JetBrains.Util.dataStructures.TypedIntrinsics.Int32<DocLine> resharperLineNumber)
        {
            using (ReadLockCookie.Create())
            {
                ISolution solution = projectFile.GetSolution();
                if (solution == null)
                {
                    return new JB::JetBrains.Util.TextRange();
                }

                IDocument document = DocumentManager.GetInstance(solution).GetOrCreateDocument(projectFile);

                return GetTextRangeForLineNumber(document, resharperLineNumber);
            }
        }
 /// <summary>
 /// True if this QuickFix is available.
 /// </summary>
 /// <param name="cache">
 /// The cache object to use.
 /// </param>
 /// <returns>
 /// The is available.
 /// </returns>
 public bool IsAvailable(JB::JetBrains.Util.IUserDataHolder cache)
 {
     // TODO Not all StyleCop issues can be suppressed. We should check here and return false for those that cannot be handled.
     return true;
 }
        /// <summary>
        /// Process clean-up on file.
        /// </summary>
        /// <param name="projectFile">
        /// The project file to process.
        /// </param>
        /// <param name="rangeMarker">
        /// The range marker to process.
        /// </param>
        /// <param name="profile">
        /// The code cleanup settings to use.
        /// </param>
        /// <param name="progressIndicator">
        /// The progress indicator.
        /// </param>
        public void Process(
            IPsiSourceFile projectFile, IRangeMarker rangeMarker, CodeCleanupProfile profile, JB::JetBrains.Application.Progress.IProgressIndicator progressIndicator)
        {
            if (projectFile == null)
            {
                return;
            }

            if (!this.IsAvailable(projectFile))
            {
                return;
            }

            ISolution solution = projectFile.GetSolution();

            ICSharpFile file = projectFile.GetPsiFile<CSharpLanguage>() as ICSharpFile;

            if (file == null)
            {
                return;
            }

            PsiManager.GetInstance(solution).DoTransaction(() => this.InternalProcess(profile, file), "Code cleanup");

            StyleCopTrace.Out();
        }
        /// <summary>
        /// Process clean-up on file.
        /// </summary>
        /// <param name="projectFile">
        /// The project file to process.
        /// </param>
        /// <param name="range">
        /// The range marker to process.
        /// </param>
        /// <param name="profile">
        /// The code cleanup settings to use.
        /// </param>
        /// <param name="canIncrementalUpdate">
        /// Determines whether we can incrementally update.
        /// </param>
        /// <param name="progressIndicator">
        /// The progress indicator.
        /// </param>
        public void Process(
            IProjectFile projectFile, 
            IPsiRangeMarker range, 
            CodeCleanupProfile profile, 
            out bool canIncrementalUpdate, 
            JB::JetBrains.Application.Progress.IProgressIndicator progressIndicator)
        {
            StyleCopTrace.In(projectFile, range, profile, progressIndicator);
            canIncrementalUpdate = true;

            if (projectFile == null)
            {
                return;
            }

            if (!this.IsAvailable(projectFile))
            {
                return;
            }

            ISolution solution = projectFile.GetSolution();

            PsiManagerImpl psiManager = PsiManagerImpl.GetInstance(solution);

            ICSharpFile file = psiManager.GetPsiFile(projectFile, PsiLanguageType.GetByProjectFile(projectFile)) as ICSharpFile;

            if (file == null)
            {
                return;
            }

            DocumentationOptions documentationOptions = profile.GetSetting(DocumentationDescriptor);
            LayoutOptions layoutOptions = profile.GetSetting(LayoutDescriptor);
            MaintainabilityOptions maintainabilityOptions = profile.GetSetting(MaintainabilityDescriptor);
            OrderingOptions orderingOptions = profile.GetSetting(OrderingDescriptor);
            ReadabilityOptions readabilityOptions = profile.GetSetting(ReadabilityDescriptor);
            SpacingOptions spacingOptions = profile.GetSetting(SpacingDescriptor);

            // Process the file for all the different Code Cleanups we have here
            // we do them in a very specific order. Do not change it.
            new ReadabilityRules().Execute(readabilityOptions, file);
            new MaintainabilityRules().Execute(maintainabilityOptions, file);
            new DocumentationRules().Execute(documentationOptions, file);
            new LayoutRules().Execute(layoutOptions, file);
            new SpacingRules().Execute(spacingOptions, file);
            new OrderingRules().Execute(orderingOptions, file);

            StyleCopTrace.Out();
        }
Exemplo n.º 15
0
        public string GetBranchesByUserId(string token)
        {
            token = TokenManager.readToken(HttpContext.Current.Request);
            var strP = TokenManager.GetPrincipal(token);

            if (strP != "0") //invalid authorization
            {
                return(TokenManager.GenerateToken(strP));
            }
            else
            {
                int userId = 0;
                IEnumerable <Claim> claims = TokenManager.getTokenClaims(token);
                foreach (Claim c in claims)
                {
                    if (c.Type == "itemId")
                    {
                        userId = int.Parse(c.Value);
                    }
                }
                using (incposdbEntities entity = new incposdbEntities())
                {
                    var List = (from S in entity.branchesUsers
                                join B in entity.branches on S.branchId equals B.branchId into JB
                                join U in entity.users on S.userId equals U.userId into JU
                                from JBB in JB.DefaultIfEmpty()
                                from JUU in JU.DefaultIfEmpty()
                                where S.userId == userId
                                select new BranchesUsersModel()
                    {
                        branchsUsersId = S.branchsUsersId,

                        branchId = S.branchId,
                        userId = S.userId,
                        createDate = S.createDate,
                        updateDate = S.updateDate,
                        createUserId = S.createUserId,
                        updateUserId = S.updateUserId,
                        // branch
                        bbranchId = JBB.branchId,
                        bcode = JBB.code,
                        bname = JBB.name,
                        baddress = JBB.address,
                        bemail = JBB.email,
                        bphone = JBB.phone,
                        bmobile = JBB.mobile,
                        bcreateDate = JBB.createDate,
                        bupdateDate = JBB.updateDate,
                        bcreateUserId = JBB.createUserId,
                        bupdateUserId = JBB.updateUserId,
                        bnotes = JBB.notes,
                        bparentId = JBB.parentId,
                        bisActive = JBB.isActive,
                        btype = JBB.type,
                        // user
                        uuserId = JUU.userId,
                        uusername = JUU.username,
                        upassword = JUU.password,
                        uname = JUU.name,
                        ulastname = JUU.lastname,
                        ujob = JUU.job,
                        uworkHours = JUU.workHours,
                        ucreateDate = JUU.createDate,
                        uupdateDate = JUU.updateDate,
                        ucreateUserId = JUU.createUserId,
                        uupdateUserId = JUU.updateUserId,
                        uphone = JUU.phone,
                        umobile = JUU.mobile,
                        uemail = JUU.email,
                        unotes = JUU.notes,
                        uaddress = JUU.address,
                        uisActive = JUU.isActive,
                        uisOnline = JUU.isOnline,

                        uimage = JUU.image,
                    }).ToList();
                    return(TokenManager.GenerateToken(List));
                }
            }
        }