Exemplo n.º 1
0
        public AccountView CreateAccount(AccountView accountView)
        {
            if (CheckAccount(accountView) == true)
            {
                var lastempCode = GetLastEmpCode();
                var accNew      = new Account
                {
                    Code                               = lastempCode != null?GenerateCode.GenerateEmpCodeNTU(lastempCode, "EMP") : "EMP00000001",
                                              Email    = accountView.Email,
                                              FullName = accountView.FullName,
                                              Password = accountView.Password,
                                              Image    = accountView.Image,
                                              Role     = 2,
                                              Active   = true,
                                              Status   = true
                };
                var account = CreateNTU(accNew).Result;
                accountView.Id   = account.Id;
                accountView.Code = account.Code;


                return(accountView);
            }
            return(null);
        }
Exemplo n.º 2
0
        public void DictionaryShouldContainPair_WhenPropertiesOfDifferentVariables_ShouldNotTrigger()
        {
            const string assertion = "actual.Should().ContainValue(pair.Value).And.ContainKey(otherPair.Key);";
            var          source    = GenerateCode.DictionaryAssertion(assertion);

            DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source);
        }
Exemplo n.º 3
0
 private void btnGenareCode_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(txtPathSln.Text))
     {
         MessageBox.Show("Digite o caminho da Solution SLN.");
     }
     else
     {
         try
         {
             Cursor.Current      = Cursors.WaitCursor;
             _ProjectsToGenarate = new List <Project>();
             foreach (var project in _ProjectsToTreeView)
             {
                 TreeNode projectNode = treeViewProjects.Nodes.Find(project.NameSpace, true).FirstOrDefault();
                 if (projectNode != null && projectNode.Checked)
                 {
                     GenerateCode generateCode = new GenerateCode();
                     generateCode.PathSolution = txtPathSln.Text + "\\";
                     generateCode.Entity       = project.ProjectClasses[0].Name;
                     GenerateCodeService codeService = new GenerateCodeService(project, generateCode);
                     codeService.executeDDD();
                 }
             }
             Cursor.Current = Cursors.Default;
         }
         catch (Exception ex)
         {
             MessageBox.Show("Erro ao criar Solution.");
         }
     }
 }
Exemplo n.º 4
0
        private string GetFormCode()
        {
            GenerateCode gserver = new GenerateCode(0, 0);
            string       code    = "YA" + gserver.nextId().ToString();

            return(code);
        }
Exemplo n.º 5
0
        public string createCode([FromBody] GenerateCode config)
        {
            String code = "Teste\n 2";

            // GenerateCode ge = JsonSerializer.Deserialize<GenerateCode>(config);
            return(code);
        }
Exemplo n.º 6
0
        public void CountWithPredicate()
        {
            const string assertion = "actual.Count(d => d.Message.Contains(\"a\")).Should().Be(2);";
            var          source    = GenerateCode.EnumerableCodeBlockAssertion(assertion);

            DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source);
        }
Exemplo n.º 7
0
        public ActionResult GenerateDataAccess()
        {
            var model = new Mo.SysDatabase();

            UpdateModel(model);

            var actionResult = default(AgileJsonResult);

            try
            {
                dynamic wherePart = new ExpandoObject();

                wherePart.DBName = model.DbName;

                wherePart.ID = model.TableID;

                var columns = Da.Sys.GetColumns(Config.ConnectionString_Read, wherePart);

                actionResult = new AgileJsonResult()
                {
                    Content = AgileJson.ToJson(new
                    {
                        result = HttpUtility.UrlDecode(GenerateCode.GetDataAccess(columns, model.TableName))
                    })
                };
            }
            catch { }

            return(actionResult);
        }
        public Guid CreateChildOrder(Guid parentOrderId, Guid customerId, bool createNew)
        {
            string code = string.Empty;

            if (createNew)
            {
                code = GenerateCode.GetChildOrderCode(parentOrderId);
            }
            else
            {
                code = UnitOfWork.OrderRepository.GetById(parentOrderId).Code;
                Order parent = UnitOfWork.OrderRepository.GetById(parentOrderId);
                parent.IsLatest = false;
            }
            Order order = new Order()
            {
                ParentId   = parentOrderId,
                Code       = code,
                CustomerId = customerId,
                IsActive   = true,
                IsDeleted  = false,
                IsLatest   = true
            };

            UnitOfWork.OrderRepository.Insert(order);

            return(order.Id);
        }
Exemplo n.º 9
0
        public void PropertyOfIndexerShouldBe_ShouldNotThrowException()
        {
            const string assertion = "actual[0].Message.Should().Be(\"test\");";
            var          source    = GenerateCode.EnumerableCodeBlockAssertion(assertion);

            DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source);
        }
        public ActionResult ShowTransferData(string orderId, string productId)
        {
            Guid orderIdGuid   = new Guid(orderId);
            Guid productIdGuid = new Guid(productId);

            Order order = UnitOfWork.OrderRepository.GetById(orderIdGuid);

            Product            product      = UnitOfWork.ProductRepository.GetById(productIdGuid);
            string             orderCode    = string.Empty;
            List <InputDetail> inputDetails = UnitOfWork.InputDetailsRepository
                                              .Get(c => c.OrderId == order.Id).ToList();

            if (inputDetails.Count() == 1)
            {
                orderCode = order.Code;
            }
            else
            {
                orderCode = GenerateCode.GetChildOrderCode(order.Id);
            }

            TransferDetailViewModel transfer = new TransferDetailViewModel()
            {
                RemainQuantity   = GetRemainProduct(productIdGuid, orderIdGuid, order.CustomerId).RemainQuantity,
                RemainWight      = GetRemainProduct(productIdGuid, orderIdGuid, order.CustomerId).RemainWeight,
                OrderCode        = orderCode,
                ProductTitle     = product.Title,
                CustomerFullName = order.Customer.FullName,
                ParentOrderId    = orderId,
                ProductId        = productId
            };

            return(Json(transfer, JsonRequestBehavior.AllowGet));
        }
        public Guid SetOrder(Guid orderId, Guid customerId, Guid productId)
        {
            Guid newOrderId = new Guid(System.Web.Configuration.WebConfigurationManager.AppSettings["newOrderId"]);

            if (orderId == newOrderId)
            {
                Order order = new Order()
                {
                    Id             = Guid.NewGuid(),
                    CustomerId     = customerId,
                    IsMultyProduct = false,
                    CreationDate   = DateTime.Now,
                    Code           = GenerateCode.GetOrderCode(),
                    ProductId      = productId,
                    IsActive       = true,
                    IsDeleted      = false,
                    ParentId       = null,
                };

                UnitOfWork.OrderRepository.Insert(order);

                return(order.Id);
            }

            return(orderId);
        }
Exemplo n.º 12
0
        public void PropertyOfElementAtShouldBe_ShouldNotTriggerDiagnostic()
        {
            const string assertion = "actual.ElementAt(0).Message.Should().Be(\"test\");";
            var          source    = GenerateCode.EnumerableCodeBlockAssertion(assertion);

            DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source);
        }
Exemplo n.º 13
0
        public void AssertionCallMultipleMethodWithTheSameNameAndArguments()
        {
            const string assertion = "actual.Should().Contain(d => d.Message.Contains(\"a\")).And.Contain(d => d.Message.Contains(\"c\"));";
            var          source    = GenerateCode.EnumerableCodeBlockAssertion(assertion);

            DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source);
        }
        public ActionResult Create(Order order)
        {
            if (ModelState.IsValid)
            {
                if (!order.IsMultyProduct && order.ProductId == null)
                {
                    ModelState.AddModelError("productRequired", "محصول را انتخاب کنید.");

                    ViewBag.CustomerId = new SelectList(UnitOfWork.CustomerRepository.Get(), "Id", "FullName", order.CustomerId);
                    ViewBag.ProductId  = new SelectList(UnitOfWork.ProductRepository.Get(), "Id", "Title", order.ProductId);

                    return(View(order));
                }


                order.IsActive = true;
                order.Code     = GenerateCode.GetOrderCode();
                order.ParentId = null;
                order.IsLatest = true;

                UnitOfWork.OrderRepository.Insert(order);
                UnitOfWork.Save();
                return(RedirectToAction("Index"));
            }

            ViewBag.CustomerId = new SelectList(UnitOfWork.CustomerRepository.Get(), "Id", "FullName", order.CustomerId);
            ViewBag.ProductId  = new SelectList(UnitOfWork.ProductRepository.Get(), "Id", "Title", order.ProductId);

            return(View(order));
        }
Exemplo n.º 15
0
        //生成LocalizationData
        //private void CreateDataClass()
        //{
        //    string path = Application.dataPath + PathDefinition.Auto_Generate_Path;
        //    GenerateCode.Generate("LocalizationData", path, TypeAttributes.Public, CodeType.IsClass, GetFields(), null,
        //                            new CodeAttributeDeclaration(new CodeTypeReference(typeof(SerializableAttribute))), "EasyLocalization", GetImports());
        //}

        //生成LanguageType
        private void CreateEnum()
        {
            string path = Application.dataPath + PathDefinition.Auto_Generate_Path;

            GenerateCode.Generate("LanguageType", path, TypeAttributes.Public, CodeType.IsEnum, GetEnumFields(), null, null, "EasyLocalization", null);
            //刷新资源(LanguageType会很久才会更新成新设置的)
            AssetDatabase.Refresh();
        }
Exemplo n.º 16
0
        public void NestedAssertions_ShouldNotTrigger()
        {
            const string declaration = "var nestedList = new List<List<int>>();";
            const string assertion   = "nestedList.Should().NotBeNull().And.ContainSingle().Which.Should().NotBeEmpty();";
            var          source      = GenerateCode.EnumerableCodeBlockAssertion(declaration + assertion);

            DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source);
        }
Exemplo n.º 17
0
        private void VerifyCSharpFix <TCodeFixProvider, TDiagnosticAnalyzer>(string oldSourceAssertion, string newSourceAssertion)
            where TCodeFixProvider : Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider, new()
            where TDiagnosticAnalyzer : Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer, new()
        {
            var oldSource = GenerateCode.NumericAssertion(oldSourceAssertion);
            var newSource = GenerateCode.NumericAssertion(newSourceAssertion);

            DiagnosticVerifier.VerifyCSharpFix <TCodeFixProvider, TDiagnosticAnalyzer>(oldSource, newSource);
        }
Exemplo n.º 18
0
 public GenerateCodeService(Project prProject, GenerateCode prGenerateCode)
 {
     _Project         = prProject;
     _GenerateCode    = prGenerateCode;
     _GuidToFolder    = "2150E333-8FDC-42A3-9474-1A3956D46DE8";
     _GuidToProject   = "FAE04EC0-301F-11D3-BF4B-00C04F79EFBC";
     _TextSL          = File.ReadAllText(_GenerateCode.PathSolution + _Project.NameSpace + ".sln");
     _IndexEndProject = _TextSL.LastIndexOf("EndProject");
 }
Exemplo n.º 19
0
 // Use this for initialization
 void Start()
 {
     if (generateCode == null)
     {
         generateCode = Transform.FindObjectOfType <GenerateCode>();
     }
     InitButton.onClick.AddListener(InitButtonClick);
     GenerateButton.onClick.AddListener(GenerateButtonClick);
     ResetButton.onClick.AddListener(ResetButtonClick);
 }
Exemplo n.º 20
0
 public IActionResult CodeGenerator(string name)
 {
     try
     {
         string code = GenerateCode.SystemCode(name);
         return(Ok(code));
     }
     catch (Exception ex)
     {
         return(NoContent());
     }
 }
        private string GenerateEmailCode()
        {
            var code = GenerateCode.EmailCode();

            var user = _userRepository.FindUserByVerifyCode(code);

            if (user == null)
            {
                return(code);
            }

            return(GenerateEmailCode());
        }
Exemplo n.º 22
0
        public string GetSecuential(SecuentialDto data, string token)
        {
            Response <int> obj = null;

            var hCliente = _global.rspClient("Secuential/", data, token);

            if (hCliente.IsSuccessStatusCode)
            {
                obj = new JavaScriptSerializer().Deserialize <Response <int> >(hCliente.Content.ReadAsStringAsync().Result);
            }

            return(GenerateCode.Code(data.Process, data.SystemUserId.ToString(), obj.Data));
        }
        public Guid CreateParentOrder(Guid customerId)
        {
            Order order = new Order()
            {
                Code       = GenerateCode.GetOrderCode(),
                ParentId   = null,
                CustomerId = customerId,
                IsActive   = true,
                IsLatest   = true
            };

            UnitOfWork.OrderRepository.Insert(order);
            return(order.Id);
        }
Exemplo n.º 24
0
 private void Generate()
 {
     GCode = new GenerateCode(TargetGenerate, Options.Type, Options.WithCoockie, Options.WithHeaders);
     if (GCode.DirectoryNotFoundException())
     {
         WindowsManager.Message("Project path error", "Directory path of project not found");
         return;
     }
     GCode.Generate();
     if (Options.OpenFolder)
     {
         Process.Start(TargetGenerate.ProjectPath);
     }
 }
Exemplo n.º 25
0
        /// <summary>
        /// starts actual generation for an ecr those info has been previously saved in globalvar from setoptions function.
        /// It Finally rollbacks transaction
        /// </summary>
        /// <returns></returns>
        public bool GenerateECRDeliverables(ECRLevelOptions ecrOptions, Logger logger)
        {
            DBManager      dbManager       = null;
            DataPrepartion dataPreparation = null;

            try
            {
                dbManager       = new DBManager(this._connectionString);
                dataPreparation = new DataPrepartion(this._guid, dbManager, ref ecrOptions);

                if (this._userInputs.DataMode.Equals(DataMode.Model))
                {
                    _progress.Report("Populating Hashtables for " + ecrOptions.Ecrno + "...");
                    dataPreparation.PrepareHashTables();
                }

                List <Task> consolidatedTasks = new List <Task>();
                Task        task1             = Task.Run(() =>
                {
                    GenerateCode generateCode = new GenerateCode(dataPreparation, ref ecrOptions, this._progress);
                    generateCode.Generate(_userInputs);
                });
                consolidatedTasks.Add(task1);

                Task task2 = Task.Run(() =>
                {
                    this.GenerateHtmXmlAndScripts(dataPreparation, this._userInputs, ref ecrOptions, logger);
                });
                consolidatedTasks.Add(task2);
                Task.WaitAll(consolidatedTasks.ToArray());


                return(ecrOptions.ErrorCollection != null ? ecrOptions.ErrorCollection.Count == 0 : true);
            }
            catch (Exception ex)
            {
                Logger.WriteLogToTraceListener("Codegenwrapper->Generate->", string.Format("{0}", ex.InnerException != null ? ex.InnerException.Message : ex.Message));
                return(false);
            }
            finally
            {
                Logger.WriteLogToTraceListener("CodegenWrapper->Generate", string.Format("Rollback Transaction..."));
                if (dbManager != null && dbManager.Connection != null)
                {
                    dbManager.RollbackTransaction();
                    dbManager.Close();
                }
            }
        }
Exemplo n.º 26
0
        public int CreateCustomer(AccountView accountView)
        {
            var account = new Account
            {
                Email       = accountView.Email,
                Phone       = accountView.Phone,
                Name        = accountView.Name,
                Gender      = accountView.Gender,
                Description = accountView.Description,
                Code        = GenerateCode.GenerateNumber(000, 999).ToString()
            };

            var rs = Create(account, CheckIsExists(account)).Result;

            return(rs.Id);
        }
Exemplo n.º 27
0
        static void Main(string[] args)
        {
            //args = new string[1];
            //args[0] = "C:/Users/DAYRENE/source/repos/CoolMIPS_Compiler_DW/Test/hello_world.cl";

            Utils.Welcome();
            Utils.OpenFile(args);

            var         ast         = Parsing.Parsing.AST(args[0]);
            var         scope       = new Scope();
            ProgramNode programNode = ast as ProgramNode;

            Semantic.Semantic.Check(programNode, scope);
            GenerateCode.Generate(programNode, Utils.GetOutputPath(args[0]), scope);

            Environment.Exit(0);
        }
Exemplo n.º 28
0
        static void Main(string[] args)
        {
            string code;

            System.IO.FileStream stream = System.IO.File.Open("c:\\DBModel.cs", System.IO.FileMode.Open);
            GenerateCode         gc     = new GenerateCode();

            System.IO.Stream st = gc.Builder(stream);
            st.Seek(0, System.IO.SeekOrigin.Begin);
            using (System.IO.StreamReader r = new System.IO.StreamReader(st))
            {
                code = r.ReadToEnd();
                Console.Write(code);
            }


            Console.Read();
        }
Exemplo n.º 29
0
        static void Main(string[] args)
        {
            
            string code;
            System.IO.FileStream stream = System.IO.File.Open("c:\\DBModel.cs", System.IO.FileMode.Open);
            GenerateCode gc = new GenerateCode();
            System.IO.Stream st = gc.Builder(stream);
            st.Seek(0, System.IO.SeekOrigin.Begin);
            using (System.IO.StreamReader r = new System.IO.StreamReader(st))
            {
                code = r.ReadToEnd();
                Console.Write(code);

            }


            Console.Read();
        }
Exemplo n.º 30
0
        private void VerifyCSharpDiagnostic <TDiagnosticAnalyzer>(string sourceAssertion) where TDiagnosticAnalyzer : Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer, new()
        {
            var source = GenerateCode.NumericAssertion(sourceAssertion);

            var type         = typeof(TDiagnosticAnalyzer);
            var diagnosticId = (string)type.GetField("DiagnosticId").GetValue(null);
            var message      = (string)type.GetField("Message").GetValue(null);

            DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source, new DiagnosticResult
            {
                Id        = diagnosticId,
                Message   = message,
                Locations = new DiagnosticResultLocation[]
                {
                    new DiagnosticResultLocation("Test0.cs", 10, 13)
                },
                Severity = DiagnosticSeverity.Info
            });
        }
Exemplo n.º 31
0
 public void GenerateRegId()
 {
     Assert.AreEqual(
         40,
         GenerateCode.GenRegId(10, RegType.u32),
         "RegIdの生成に失敗してます");
     Assert.AreEqual(
         1,
         GenerateCode.GenRegId(0, RegType.u16),
         "RegIdの生成に失敗してます");
     Assert.AreEqual(
         50,
         GenerateCode.GenRegId(12, RegType.u8h),
         "RegIdの生成に失敗してます");
     Assert.AreEqual(
         115,
         GenerateCode.GenRegId(28, RegType.u8l),
         "RegIdの生成に失敗してます");
 }
Exemplo n.º 32
0
 private static void OutputCodeObject(GenerateCode generate)
 {
     using (CodeDomProvider provider = CodeDomProvider.CreateProvider("C#"))
     using (StringWriter sw = new StringWriter())
     {
         CodeGeneratorOptions options = new CodeGeneratorOptions();
         options.BlankLinesBetweenMembers = false;
         options.BracingStyle = "C";
         //options.ElseOnClosing = true;
         generate(provider, sw, options);
         Output(sw.ToString());
     }
 }