public ActionResult AddNewChildAccount(string id) { string UserID = User.Identity.GetUserId(); var UserInfo = _unitOfWork.User.GetMyInfo(UserID); var CoInfo = _unitOfWork.Company.GetMyCompany(UserInfo.fCompanyId); var FatherAccount = _unitOfWork.CostCenter.GetCostCenterById(CoInfo.CompanyID, id); CostCenter Obj = new CostCenter(); Obj.CostChart = CoInfo.CostChart; Obj.CostZero = CoInfo.CostChartZero; Obj.CostLevel = FatherAccount.CostLevel + 1; Obj.CostFather = FatherAccount.CostNumber; Obj.CostFatherName = FatherAccount.ArabicName; Obj.CostNumber = "";// _unitOfWork.NativeSql.GetMaxCostNumberChild(CoInfo.CompanyID, Obj.CostFather).ToString(); Obj.LevelZero = FunctionUnit.GetLevelChart(CoInfo.CostChart, Obj.CostLevel); //Obj.LevelZero = Obj.LevelZero.Count().ToString(); if (String.IsNullOrEmpty(Obj.LevelZero)) { ViewBag.Error = Resources.Resource.LastAccountSub; return(PartialView("Error")); } else { return(PartialView("AddNewChildAccount", Obj)); } }
public JsonResult GetMaxFatherAccount(string id) { string UserID = User.Identity.GetUserId(); var UserInfo = _unitOfWork.User.GetMyInfo(UserID); var CoInfo = _unitOfWork.Company.GetMyCompany(UserInfo.fCompanyId); var FatherAccount = _unitOfWork.ChartOfAccount.GetChartOfAccountById(CoInfo.CompanyID, id); if (id != "") { ChartOfAccountMaxVM Obj = new ChartOfAccountMaxVM(); Obj.AccountLevel = FatherAccount.AccountLevel + 1; Obj.LevelZero = FunctionUnit.GetLevelChart(CoInfo.AccountChart, Obj.AccountLevel); int LevelZeroLength = Obj.LevelZero.Length; int AccountNumberLength = _unitOfWork.NativeSql.GetMaxChartNumberChild(CoInfo.CompanyID, id).ToString().Length; string NewAccountNumber = ""; if (LevelZeroLength == AccountNumberLength) { Obj.AccountNumber = _unitOfWork.NativeSql.GetMaxChartNumberChild(CoInfo.CompanyID, id).ToString(); } else { LevelZeroLength = LevelZeroLength - AccountNumberLength; for (int i = 1; i <= LevelZeroLength; i++) { NewAccountNumber = NewAccountNumber + "0"; } Obj.AccountNumber = NewAccountNumber + _unitOfWork.NativeSql.GetMaxChartNumberChild(CoInfo.CompanyID, id).ToString(); } return(Json(Obj, JsonRequestBehavior.AllowGet)); } return(Json(1, JsonRequestBehavior.AllowGet)); }
public JsonResult SaveChildAccount(CostCenter ObjToSave) { MsgUnit Msg = new MsgUnit(); string UserID = User.Identity.GetUserId(); var UserInfo = _unitOfWork.User.GetMyInfo(UserID); var CoInfo = _unitOfWork.Company.GetMyCompany(UserInfo.fCompanyId); ObjToSave.InsDateTime = DateTime.Now; ObjToSave.CompanyID = UserInfo.fCompanyId; var userId = User.Identity.GetUserId(); ObjToSave.CompanyYear = UserInfo.CurrYear; ObjToSave.CostNumber = FunctionUnit.RemoveAccountDash(ObjToSave.CostNumber); ObjToSave.IsFirstLevel = false; ObjToSave.CostNumber = ObjToSave.CostNumber.PadLeft(ObjToSave.LevelZero.Count(), '0'); ObjToSave.OrignalCost = ObjToSave.CostNumber; ObjToSave.CostNumber = ObjToSave.CostFather + ObjToSave.CostNumber; if (String.IsNullOrEmpty(ObjToSave.EnglishName)) { ObjToSave.EnglishName = ObjToSave.ArabicName; } if (!ModelState.IsValid) { string Err = " "; var errors = ModelState.Values.SelectMany(v => v.Errors); foreach (ModelError error in errors) { Err = Err + error.ErrorMessage + " * "; } Msg.Msg = Resources.Resource.SomthingWentWrong + " : " + Err; Msg.Code = 0; return(Json(Msg, JsonRequestBehavior.AllowGet)); } var CostInfo = _unitOfWork.CostCenter.GetCostByID(UserInfo.fCompanyId, ObjToSave.CostNumber); try { if (CostInfo != null) { Msg.Msg = Resources.Resource.TheCostCenterIsExist; Msg.Code = 0; return(Json(Msg, JsonRequestBehavior.AllowGet)); } _unitOfWork.CostCenter.Add(ObjToSave); _unitOfWork.Complete(); Msg.LastID = ""; Msg.Code = 1; Msg.Msg = Resources.Resource.AddedSuccessfully; return(Json(Msg, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { Msg.Msg = Resources.Resource.SomthingWentWrong + " : " + ex.Message.ToString(); Msg.Code = 0; return(Json(Msg, JsonRequestBehavior.AllowGet)); } }
public ActionResult Index() { string UserID = User.Identity.GetUserId(); var UserInfo = _unitOfWork.User.GetMyInfo(UserID); var CoInfo = _unitOfWork.Company.GetMyCompany(UserInfo.fCompanyId); var SupplierFatherAccountObj = _unitOfWork.NativeSql.GetClientFatherAccount(CoInfo.CompanyID); var FatherAccountNumber = _unitOfWork.NativeSql.GetClientFatherAccount(CoInfo.CompanyID).First(); var FatherAccount = _unitOfWork.ChartOfAccount.GetChartOfAccountById(CoInfo.CompanyID, FatherAccountNumber.AccountNumber); ChartOfAccountSupplierVM Obj = new ChartOfAccountSupplierVM(); Obj.SupplierFatherAccount = SupplierFatherAccountObj; Obj.AccountType = _unitOfWork.AccountType.GetAllAccountType(); Obj.AccountChart = CoInfo.AccountChart; Obj.AccountChartZero = CoInfo.AccountChartZero; Obj.AccountTypeID = FatherAccount.AccountTypeID; Obj.AccountKind = 2; Obj.AccountLevel = FatherAccount.AccountLevel + 1; Obj.AccountFather = FatherAccount.AccountNumber; Obj.AccountFatherName = FatherAccount.ArabicName; Obj.LevelZero = FunctionUnit.GetLevelChart(CoInfo.AccountChart, Obj.AccountLevel); int LevelZeroLength = Obj.LevelZero.Length; int AccountNumberLength = _unitOfWork.NativeSql.GetMaxChartNumberChild(CoInfo.CompanyID, Obj.AccountFather).ToString().Length; string NewAccountNumber = ""; if (LevelZeroLength == AccountNumberLength) { Obj.AccountNumber = _unitOfWork.NativeSql.GetMaxChartNumberChild(CoInfo.CompanyID, Obj.AccountFather).ToString(); } else { LevelZeroLength = LevelZeroLength - AccountNumberLength; for (int i = 1; i <= LevelZeroLength; i++) { NewAccountNumber = NewAccountNumber + "0"; } Obj.AccountNumber = NewAccountNumber + _unitOfWork.NativeSql.GetMaxChartNumberChild(CoInfo.CompanyID, Obj.AccountFather).ToString(); } Obj.Currency = _unitOfWork.Currency.GetAllCurrency(CoInfo.CompanyID); Obj.CurrencyID = FatherAccount.CurrencyID; Obj.SupplierCountry = _unitOfWork.SupplierCountry.GetAllSupplierCountry(CoInfo.CompanyID); Obj.SupplierCountryBank = _unitOfWork.SupplierCountryBank.GetAllSupplierCountryBank(CoInfo.CompanyID); Obj.SupplierBank = _unitOfWork.SupplierBank.GetAllSupplierBank(CoInfo.CompanyID); Obj.SupplierCity = _unitOfWork.SupplierCity.GetAllSupplierCityByCountryID(CoInfo.CompanyID, 0); Obj.SupplierCityBank = _unitOfWork.SupplierCityBank.GetAllSupplierCityBankByCountryBankID(CoInfo.CompanyID, 0); Obj.SupplierBranchBank = _unitOfWork.SupplierBranchBank.GetAllSupplierBranchBankByBankID(CoInfo.CompanyID, 0); Obj.SupplierType = _unitOfWork.NativeSql.GetAllSupplierType(); if (String.IsNullOrEmpty(Obj.LevelZero)) { ViewBag.Error = Resources.Resource.LastAccountSub; return(PartialView("Error")); } Obj.Sale = _unitOfWork.Sale.GetAllSale(UserInfo.fCompanyId); Obj.FSalesID = FatherAccount.SalesID; return(View(Obj)); }
public JsonResult Save(Company ObjToSave) { MsgUnit Msg = new MsgUnit(); string UserID = User.Identity.GetUserId(); var UserInfo = _unitOfWork.User.GetMyInfo(UserID); if (!ModelState.IsValid) { string Err = " "; var errors = ModelState.Values.SelectMany(v => v.Errors); foreach (ModelError error in errors) { Err = Err + error.ErrorMessage + " * "; } Msg.Msg = Resources.Resource.SomthingWentWrong + " : " + Err; Msg.Code = 0; return(Json(Msg, JsonRequestBehavior.AllowGet)); } try { ObjToSave.AccountChartZero = FunctionUnit.ConvertChartToZero(ObjToSave.AccountChart); if (ObjToSave.WorkWithCostCenter) { ObjToSave.CostChartZero = FunctionUnit.ConvertChartToZero(ObjToSave.CostChart); } else { ObjToSave.CostChartZero = ""; }; _unitOfWork.Company.Add(ObjToSave); _unitOfWork.Complete(); var CompanyID = ObjToSave.CompanyID; _unitOfWork.User.UpdateCompanyID(UserID, CompanyID); _unitOfWork.Complete(); Msg.Code = 1; Msg.Msg = Resources.Resource.AddedSuccessfully; return(Json(Msg, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { Msg.Msg = Resources.Resource.SomthingWentWrong + " : " + ex.Message.ToString(); Msg.Code = 0; return(Json(Msg, JsonRequestBehavior.AllowGet)); } }
public JsonResult Save(CostCenter ObjToSave) { MsgUnit Msg = new MsgUnit(); string UserID = User.Identity.GetUserId(); var UserInfo = _unitOfWork.User.GetMyInfo(UserID); ObjToSave.InsDateTime = DateTime.Now; // ObjToSave.i = UserID; ObjToSave.CompanyID = UserInfo.fCompanyId; var userId = User.Identity.GetUserId(); ObjToSave.CompanyYear = UserInfo.CurrYear; ObjToSave.CostFather = FunctionUnit.RemoveAccountDash(ObjToSave.CostFather); ObjToSave.CostNumber = FunctionUnit.RemoveAccountDash(ObjToSave.CostNumber); if (!ModelState.IsValid) { string Err = " "; var errors = ModelState.Values.SelectMany(v => v.Errors); foreach (ModelError error in errors) { Err = Err + error.ErrorMessage + " * "; } Msg.Msg = Resources.Resource.SomthingWentWrong + " : " + Err; Msg.Code = 0; return(Json(Msg, JsonRequestBehavior.AllowGet)); } try { _unitOfWork.CostCenter.Add(ObjToSave); _unitOfWork.Complete(); Msg.Code = 1; Msg.Msg = Resources.Resource.AddedSuccessfully; return(Json(Msg, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { Msg.Msg = Resources.Resource.SomthingWentWrong + " : " + ex.Message.ToString(); Msg.Code = 0; return(Json(Msg, JsonRequestBehavior.AllowGet)); } }
public ActionResult AddNewFatherAccount(int id) { string UserID = User.Identity.GetUserId(); var UserInfo = _unitOfWork.User.GetMyInfo(UserID); var CoInfo = _unitOfWork.Company.GetMyCompany(UserInfo.fCompanyId); CostCenter Obj = new CostCenter(); Obj.CostChart = CoInfo.CostChart; Obj.CostZero = CoInfo.CostChartZero; Obj.CostLevel = 1; Obj.LevelZero = FunctionUnit.GetLevelChart(CoInfo.CostChart, Obj.CostLevel); //Obj.LevelZero = Obj.LevelZero.Count().ToString(); return(PartialView("AddNewFatherAccount", Obj)); }
private void AnalyzeFunction( FunctionUnit functionUnit, WarningEmitter warningEmitter) { if (functionUnit.FunctionSymbol.IsCompilerGenerated()) { return; } var instructions = functionUnit.Instructions.ToList(); foreach (var instruction in instructions) { if (instruction.SourceOperand == null) { // 変数定義 continue; } if (instruction.DestinationOperand == null || instruction.DestinationOperand?.UseInstruction != null || !functionUnit.SymbolTable.AllSymbols.Contains(instruction.DestinationOperand.Symbol)) { continue; } var returnedOperands = functionUnit.IsNoReturn() ? null : instructions .Where(inst => inst.IsReturn) .Select(inst => inst.SourceOperand.DefinitionInstruction.DestinationOperand) .ToList(); var isUsedOnAnyCopiedOperand = EnumerableUtility.Seek( instruction, inst => inst.SourceOperand?.DefinitionInstruction, inst => inst.IsCopy) .Select(inst => inst.DestinationOperand) .Any(op => op.UseInstruction != null && returnedOperands.Contains(op)); if (!isUsedOnAnyCopiedOperand) { this.Violate(warningEmitter, instruction, instruction.DestinationOperand.Symbol); } } }
private void AnalyzeFunction( FunctionUnit functionUnit, WarningEmitter warningEmitter) { var comps = functionUnit.Instructions.OfType<CompareInstruction>().ToList(); foreach (var comp in comps) { if (comp.GetFileName().IsNull) { // ラムダ式などから生成されたメソッドで対応コードが無い部分の場合 continue; } var functionSymbol = comp.SourceOperand2.IsNullPtr() ? comp.SourceOperand1.DefinitionInstruction.SourceOperand?.AsFunctionOperand?.FunctionSymbol : comp.SourceOperand1.IsNullPtr() ? comp.SourceOperand2.DefinitionInstruction.SourceOperand?.AsFunctionOperand?.FunctionSymbol : null; if (functionSymbol == null) { continue; } var symbol = functionSymbol.UninstantiatedFunctionSymbol ?? functionSymbol; var fullNameWithoutGenericParameter = string.Format( "{0}.{1}", symbol.EnclosingAggregateType.DefinitionType.TypeSymbol.NameString, symbol.NameString); if (Settings.UnNullReturnMethod.Contains(fullNameWithoutGenericParameter)) { this.Violate(warningEmitter, comp, symbol); } } }
private void AnalyzeFunction( FunctionUnit functionUnit, WarningEmitter warningEmitter) { //this.Violate(warningEmitter, functionUnit.FirstInstruction); }
/// <summary> /// Private helper workhorse function for <see cref="Execute"/>. /// </summary> /// /// <param name="moduleUnit">The moduleUnit to process.</param> /// <returns>True if successful; false otherwise.</returns> private bool ExecuteHelper(Phx.ModuleUnit moduleUnit) { Console.Out.WriteLine(); Phx.Graphs.CallGraph callGraph = moduleUnit.CallGraph; if (callGraph == null) { Console.Out.WriteLine("PHOENIX: Call graph is null."); Console.Out.WriteLine("Exiting GameTime."); Environment.Exit(1); return(false); } /* Load GameTime configuration. */ string configFile = Console.ReadLine(); Console.Out.WriteLine("PHOENIX: Configuring this GameTime session with " + configFile + "..."); Utilities.Configuration config = Utilities.Configuration.ReadConfigFile(configFile); Console.Out.WriteLine("PHOENIX: Successfully configured this session."); /* Load the project configuration. */ string projectConfigFile = Console.ReadLine(); Console.Out.WriteLine("PHOENIX: Loading project configuration from " + projectConfigFile + "..."); ProjectConfiguration projectConfig = ProjectConfiguration.ReadProjectConfigFile(projectConfigFile, config); Console.Out.WriteLine("PHOENIX: Successfully loaded the project for this session."); /* Determine the current GameTime operation mode. */ string currentMode = Console.ReadLine(); mode = (currentMode.Equals(config.TEMP_PHX_CREATE_DAG)) ? MODES.CREATE_DAG : MODES.FIND_CONDITIONS; Console.Out.WriteLine("PHOENIX: GameTime operation mode is: " + ((mode == MODES.CREATE_DAG) ? "Create DAG." : "Find path conditions.")); /* Find the function to analyze. */ string funcToProcess = projectConfig.func; Console.Out.WriteLine("PHOENIX: Preprocessing " + funcToProcess + "..."); Console.Out.WriteLine(); Console.Out.WriteLine("PHOENIX: Finding the corresponding function unit..."); /* Find the function unit corresponding to the function to be analyzed. */ FunctionUnit functionUnitToProcess = null; /* Traverse the graph in post-order (top-down order). */ Phx.Graphs.NodeFlowOrder nodeOrder = Phx.Graphs.NodeFlowOrder.New(callGraph.Lifetime); nodeOrder.Build(callGraph, Phx.Graphs.Order.PostOrder); Phx.Targets.Runtimes.Runtime runtime = moduleUnit.Runtime; uint functionCount = 0; for (uint i = 1; i <= nodeOrder.NodeCount; ++i) { Phx.Graphs.CallNode node = nodeOrder.Node(i).AsCallNode; if ((node == callGraph.UnknownCallerNode) || (node == callGraph.UnknownCalleeNode)) { continue; } if (node.FunctionSymbol != null) { /* Is this LTCG mode? */ bool isLTCG = false; try { IDictionary env = Environment.GetEnvironmentVariables(); if (env.Contains("LINK_TIME_CODE_GENERATION")) { isLTCG = true; } } catch (ArgumentNullException) { } /* Only perform the check when the LTCG mode is off. */ if (isLTCG || moduleUnit.IsPEModuleUnit) { moduleUnit = node.FunctionSymbol.CompilationUnitParentSymbol.Unit.AsModuleUnit; } /* Create the corresponding function unit. */ Phx.Lifetime lifetime = Phx.Lifetime.New(Phx.LifetimeKind.Function, null); Phx.FunctionUnit functionUnit = Phx.FunctionUnit.New(lifetime, node.FunctionSymbol, Phx.CodeGenerationMode.Native, moduleUnit.TypeTable, runtime.Architecture, runtime, moduleUnit, functionCount++); /* Attach debugging info. */ Phx.Debug.Info.New(functionUnit.Lifetime, functionUnit); node.FunctionSymbol.FunctionUnit = functionUnit; this.PhaseConfiguration.PhaseList.DoPhaseList(functionUnit); functionUnit.Context.PopUnit(); string funcName = FunctionUnitHelper.GetFunctionName(functionUnit); if (funcName == funcToProcess) { functionUnitToProcess = functionUnit; break; } } } if (functionUnitToProcess == null) { Console.Out.WriteLine("PHOENIX: Cannot find function named " + funcToProcess + "."); Console.Out.WriteLine("PHOENIX: Exiting GameTime..."); Environment.Exit(1); return(false); } else { Console.Out.WriteLine("PHOENIX: Function unit found."); } Console.Out.WriteLine("PHOENIX: Preprocessing the function unit..."); FunctionUnitHelper.Preprocess(functionUnitToProcess); Console.Out.WriteLine("PHOENIX: Function unit preprocessing complete."); Console.Out.WriteLine(); Console.Out.WriteLine("PHOENIX: Building the flow graph..."); functionUnitToProcess.BuildFlowGraphWithoutEH(); Phx.Graphs.FlowGraph graph = functionUnitToProcess.FlowGraph; Console.Out.WriteLine("PHOENIX: Flow graph built."); Console.Out.WriteLine("PHOENIX: Snipping the relevant portion of the flow graph..."); uint sourceBlockId = 1; uint sinkBlockId = graph.NodeCount; if (projectConfig.startLabel != "") { Phx.Graphs.BasicBlock sourceBlock = FunctionUnitHelper.SplitAtUserLabel(functionUnitToProcess, projectConfig.startLabel); sourceBlockId = sourceBlock.Id; } if (projectConfig.endLabel != "") { Phx.Graphs.BasicBlock sinkBlock = FunctionUnitHelper.SplitAtUserLabel(functionUnitToProcess, projectConfig.endLabel); /* Correct the sink block: we want the block just before the block * we receive from SplitAtUserLabel. */ Phx.Graphs.FlowEdge edgeToSink = sinkBlock.PredecessorEdgeList; sinkBlock = edgeToSink.PredecessorNode; sinkBlockId = sinkBlock.Id; } Console.Out.WriteLine("PHOENIX: Relevant portion snipped."); Console.Out.WriteLine(); Console.Out.WriteLine("PHOENIX: Starting analysis..."); switch (mode) { case MODES.CREATE_DAG: FunctionUnitHelper.DumpCfgToFile(functionUnitToProcess, sourceBlockId, sinkBlockId, config, projectConfig); break; case MODES.FIND_CONDITIONS: FunctionUnitHelper.FindPathConditions(functionUnitToProcess, config, projectConfig); break; } Console.Out.WriteLine("PHOENIX: Analysis successful."); Console.Out.WriteLine(); Environment.Exit(0); return(true); }