Esempio n. 1
0
        public static ClassBase CreateEntityClass(DDLTable table, CSharpBeanConfig beanConfig, bool createVo)
        {
            CSharpClass cSharpClass = new CSharpClass(beanConfig.NamespaceName, table, beanConfig);



            table.Columns.ForEach(c =>
            {
                if (false == c.Validate())
                {
                    return;
                }
                FieldBase filedBase;
                cSharpClass.Fields.Add(filedBase = FieldBase.Create(c));
                filedBase.FiledTypeStr           = GetFildTypeStr(filedBase);
            });

            cSharpClass.Desc = table.Desc;

            cSharpClass.ClassName = table.ClassName.Length == 0 ? CodeUtil.GetClassName(beanConfig, table.TableName) : table.ClassName;

            if (createVo)
            {
                //javaClass.JavaVoClass = JavaClass.CreateVo(javaBeanConfig.VOPackageName, javaClass);
                throw new NotImplementedException();
            }
            return(cSharpClass);
        }
Esempio n. 2
0
 public FieldInformation(string fieldName, string fieldType, string fieldId)
 {
     FieldName  = fieldName;
     FieldId    = fieldId;
     MethodName = CodeUtil.CleanStringOfIllegalCharacters(fieldName);
     FieldType  = fieldType;
 }
Esempio n. 3
0
    private void Connect()
    {
        try {
            Debug.Log("connecting");
            client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            IPAddress iPAddress = IPAddress.Parse(ip);
            EndPoint  endPoint  = new IPEndPoint(iPAddress, port);
            client.Connect(endPoint);
            int retryCount = 5;
            while (retryCount-- > 0)
            {
                if (client.Connected)
                {
                    Debug.Log("connected!");
                    // TransferMessag
                    checkVersion();
                    //  connectSuccess();
                    break;
                }
                Thread.Sleep(5 * 1000);
                client.Connect(endPoint);
            }
        } catch (Exception e) {
            //TODO
            Debug.Log(e);
            Debug.Log("connecte to server fail");
            disconnect();
            return;
        }

        try {
            //Thread.Sleep(5 * 1000);
            while (true)
            {
                int length;
                //List<byte> list = new List<byte>();
                byte[] data = new byte[ONE_TIME_READ_MAX_DATA_LENGTH];
                //do {
                length = client.Receive(data);
                //byte[] temp = new byte[length];
                //    Array.Copy(data, 0, temp, 0, length);
                //    list.AddRange(temp);
                //} while (length >= ONE_TIME_READ_MAX_DATA_LENGTH);

                if (length != 0)
                {
                    List <MessageBean> messages = CodeUtil.decode(data, length);
                    Debug.Log("message size:" + messages.Count);
                    MessageQueue.put(messages);
                }

                Thread.Sleep(50);
            }
        } catch {
            //TODO
            Debug.Log("receive message error");
            disconnect();
            //   GameObject.Find("UIController").SendMessage("","");
        }
    }
Esempio n. 4
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtNameSpace.Text))
            {
                MessageBox.Show("请填写类命名空间");
                return;
            }
            if (string.IsNullOrEmpty(txtLocation.Text))
            {
                MessageBox.Show("请填写类文件存放路径");
                return;
            }
            if (clbTables.SelectedItems.Count == 0)
            {
                MessageBox.Show("请选择要生成代码的表");
                return;
            }
            Regex reg = new Regex("{\\}|{/}$");

            for (int i = 0; i < clbTables.Items.Count; i++)
            {
                if (clbTables.GetItemChecked(i))
                {
                    string    tableName = clbTables.Items[i].ToString();
                    TableInfo tableInfo = dataBase.GetTableInfo(tableName);
                    string    filePath  = reg.Replace(txtLocation.Text, "").Replace("/", "\\");

                    if (tableInfo != null)
                    {
                        CodeUtil.CreateCodeFile(tableInfo, string.Format("{0}.cs", filePath + "\\" + tableName), tableName, txtNameSpace.Text);
                    }
                }
            }
            MessageBox.Show("执行完毕");
        }
Esempio n. 5
0
 public void TransferMessage(MessageBean message)
 {
     if (client != null)
     {
         client.Send(CodeUtil.encode(message));
     }
 }
        protected void OnItemSaved(object sender, EventArgs args)
        {
            CustomItemSettings settings = new CustomItemSettings(HttpContext.Current);

            // Only continue if we have valid args, auto update is set to true, and the file exists already
            if (args != null && settings.AutoUpdate)
            {
                // Get the template destination
                Item _temp = masterDb.GetItem(GetCurrentContentGuid());
                if (_temp != null)
                {
                    string file_path = FileUtil.GetClassFilePath(CodeUtil.GetClassNameForTemplate(_temp), settings.BaseFileOutputPath);

                    // Make sure the template already exists
                    if (File.Exists(file_path))
                    {
                        // Set these up since we don't have the editor open
                        CustomItemNamespace = new Edit();
                        CustomItemFilePath  = new Edit();

                        // Call the current code beside
                        OnLoad(args);
                        OnOK(sender, args);
                    }
                }
            }

            return;
        }
Esempio n. 7
0
        private string GenerateCode()
        {
            var code = CodeUtil.PadCode(_generator.Compute(), _digits);

            Interlocked.Exchange(ref _secondsRemaining, _period - (int)DateTimeOffset.Now.ToUnixTimeSeconds() % _period);
            return(code);
        }
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position, IList <Object> payloads)
        {
            if (payloads == null || payloads.Count == 0)
            {
                OnBindViewHolder(viewHolder, position);
                return;
            }

            var auth   = _authSource.Get(position);
            var holder = (AuthenticatorListHolder)viewHolder;

            holder.Code.Text = CodeUtil.PadCode(auth.GetCode(), auth.Digits);

            switch (auth.Type.GetGenerationMethod())
            {
            case GenerationMethod.Time:
                AnimateProgressBar(holder.ProgressBar, auth.Period);
                break;

            case GenerationMethod.Counter:
                holder.RefreshButton.Visibility = ViewStates.Visible;
                _counterCooldownSeconds[auth.Secret.GetHashCode()] = Hotp.CooldownSeconds;
                break;
            }
        }
Esempio n. 9
0
    public void SettingsEvent()
    {
        SettingsWindow.SetActive(true);
        Color32 BGCOLOR = BGrender.color;

        SettingsWindow.GetComponent <SettingsWindow>().EnterAspect(CodeUtil.FloatToByte(BGCOLOR.g));
    }
Esempio n. 10
0
        /// <summary>
        /// 返回验证码图片
        /// </summary>
        /// <returns></returns>
        public ActionResult GetValidateCode()
        {
            Dictionary <String, Object> dic = CodeUtil.GenerateCodeAndPic(4);

            Session["ValidateCode"] = dic["code"];
            //返回
            return(File((byte[])dic["pic"], "image/jpeg"));
        }
Esempio n. 11
0
        /// <summary>
        /// Kompiliert den Code und startet die Executable als neuen Prozess
        /// </summary>
        /// <param name="assemblys">The assemblies that are needed for the compilation of the program</param>
        /// <param name="code">The C#-SourceCode</param>
        /// <param name="version">The compiler-version to use.</param>
        /// <param name="name">The name of the process</param>
        /// <returns>The index of the process</returns>
        public int StartThread(string[] assemblys, string code, string version, string name)
        {
            string temp = FileUtil.TempFile;

            CodeUtil.Compile(assemblys, temp, code, version);
            processes.Add(Process.Start(temp));
            names.Add(name, processes.Count - 1);
            return(processes.Count - 1);
        }
        public override async void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            var auth = _authSource.Get(position);

            if (auth == null)
            {
                return;
            }

            var holder = (AuthenticatorListHolder)viewHolder;

            holder.Issuer.Text   = auth.Issuer;
            holder.Username.Text = auth.Username;

            holder.Username.Visibility = String.IsNullOrEmpty(auth.Username)
                ? ViewStates.Gone
                : ViewStates.Visible;

            holder.Code.Text = CodeUtil.PadCode(auth.GetCode(), auth.Digits);

            if (auth.Icon != null && auth.Icon.StartsWith(CustomIcon.Prefix))
            {
                var id         = auth.Icon.Substring(1);
                var customIcon = _customIconSource.Get(id);

                if (customIcon != null)
                {
                    holder.Icon.SetImageBitmap(await customIcon.GetBitmap());
                }
                else
                {
                    holder.Icon.SetImageResource(Icon.GetService(Icon.Default, _isDark));
                }
            }
            else
            {
                holder.Icon.SetImageResource(Icon.GetService(auth.Icon, _isDark));
            }

            switch (auth.Type.GetGenerationMethod())
            {
            case GenerationMethod.Time:
                holder.RefreshButton.Visibility = ViewStates.Gone;
                holder.ProgressBar.Visibility   = ViewStates.Visible;
                AnimateProgressBar(holder.ProgressBar, auth.Period);
                break;

            case GenerationMethod.Counter:
                holder.RefreshButton.Visibility = auth.TimeRenew < DateTime.UtcNow
                        ? ViewStates.Visible
                        : ViewStates.Gone;

                holder.ProgressBar.Visibility = ViewStates.Invisible;
                break;
            }
        }
Esempio n. 13
0
        public async Task <IActionResult> Index()
        {
            var model = new UsuarioModel();

            model.Status = CodeUtil.PopulaComboComEnum(model.Filtro.Status);
            model.Perfis = CodeUtil.PopulaComboComEnum(model.Filtro.PerfilUsuario);
            model.Itens  = await usuarioFacade.ToListAsync(null).ToPagedListAsync(PAGE_SIZE, 1);

            return(View(model));
        }
Esempio n. 14
0
        public async Task <IActionResult> Index()
        {
            var model = new IncidenteModel
            {
                Itens = await incidenteFacade.ToListAsync(null).ToPagedListAsync(PAGE_SIZE, 1)
            };

            model.Estado           = CodeUtil.PopulaComboComEnum(model.Detalhe.EstadoIncidente);
            model.NaoConformidades = naoConformidades.AddAllToList(nameof(NaoConformidade.Descricao));
            return(View(model));
        }
Esempio n. 15
0
        public async Task <IActionResult> Index()
        {
            var model = new NaoConformidadeModel
            {
                Itens = await naoConformidadeFacade.ToListAsync(null).ToPagedListAsync(PAGE_SIZE, 1)
            };

            model.OrigemNc = CodeUtil.PopulaComboComEnum(model.Filtro.OrigemNc);
            model.Status   = CodeUtil.PopulaComboComEnum(model.Filtro.Status);
            return(View(model));
        }
Esempio n. 16
0
        public string GetFolderPath(TemplateItem template, string baseFilePath)
        {
            string relativeTemplatePath = TemplateUtil.GetRelativeTemplatePath(template).Replace("/", "\\");

            relativeTemplatePath = CodeUtil.CleanStringOfIllegalCharacters(relativeTemplatePath);

            if (!baseFilePath.EndsWith("\\"))
            {
                baseFilePath += "\\";
            }

            return(baseFilePath + relativeTemplatePath);
        }
Esempio n. 17
0
        public override SourceCode GenerateHandler(CodeContext context)
        {
            var code         = new SourceCode();
            var listAccessor = GetVarAccessor(context);
            var iteratorName = context.StartIterator();

            code.Append(CodeUtil.ForEachCode(TypeName, listAccessor, iteratorName, true));
            code.IndentRight();
            code.Append("{0}::handle(session, *{1});", CanonicalTarget, iteratorName);
            code.BracketEnd();
            context.EndIterator();
            return(code);
        }
Esempio n. 18
0
        public BaseTemplateInformation(TemplateItem template, ICustomItemNamespaceProvider namespaceProvider)
        {
            ClassName = CodeUtil.GetClassNameForTemplate(template);

            PropertyName = ClassName.Remove(ClassName.Length - 4);
            if (PropertyName.StartsWith("_"))
            {
                PropertyName = PropertyName.Substring(1);
            }

            CustomItemSettings settings = new CustomItemSettings(HttpContext.Current);

            UsingNameSpace = namespaceProvider.GetNamespace(template, settings.BaseNamespace);
        }
        public string GetNamespace(TemplateItem template, string baseNamespace)
        {
            string relativePath = TemplateUtil.GetRelativeTemplatePath(template);

            if (string.IsNullOrEmpty(relativePath))
            {
                return(baseNamespace);
            }

            relativePath = relativePath.Replace("/", ".");
            relativePath = CodeUtil.CleanStringOfIllegalCharacters(relativePath);

            return(baseNamespace + "." + relativePath);
        }
Esempio n. 20
0
        public override SourceCode GenerateWriter(CodeContext context)
        {
            var code         = new SourceCode();
            var listAccessor = GetVarAccessor(context);
            var iteratorName = context.StartIterator();

            code.Append("(*this) << static_cast<uint32_t>({0}size());", listAccessor);
            code.Append(CodeUtil.ForEachCode(CanonicalType, listAccessor, iteratorName, true));
            code.IndentRight();
            code.Append("(*this) << (*{0});", iteratorName);
            code.BracketEnd();
            context.EndIterator();
            return(code);
        }
Esempio n. 21
0
        private void Refresh(object sender = null, ElapsedEventArgs args = null)
        {
            var now = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
            var generationOffset = now - (now % _period);

            var code      = _generator.Compute(generationOffset);
            var renewTime = generationOffset + _period;

            var secondsRemaining = Math.Max(renewTime - now, 0);

            RunOnUiThread(delegate
            {
                _codeTextView.Text = CodeUtil.PadCode(code, _digits, _codeGroupSize);
                _authProgressLayout.StartTimer((_period - secondsRemaining) * 1000);
            });
        }
Esempio n. 22
0
 [Test] public void TestCodeUtil()
 {
     Assert.False(CodeUtil.IsWithinString(@"0'23\'67\\'12", 0));
     Assert.False(CodeUtil.IsWithinString(@"0'23\'67\\'12", 1));
     Assert.True(CodeUtil.IsWithinString(@"0'23\'67\\'12", 2));
     Assert.True(CodeUtil.IsWithinString(@"0'23\'67\\'12", 3));
     Assert.True(CodeUtil.IsWithinString(@"0'23\'67\\'12", 4));
     Assert.True(CodeUtil.IsWithinString(@"0'23\'67\\'12", 5));
     Assert.True(CodeUtil.IsWithinString(@"0'23\'67\\'12", 6));
     Assert.True(CodeUtil.IsWithinString(@"0'23\'67\\'12", 7));
     Assert.True(CodeUtil.IsWithinString(@"0'23\'67\\'12", 8));
     Assert.True(CodeUtil.IsWithinString(@"0'23\'67\\'12", 9));
     Assert.True(CodeUtil.IsWithinString(@"0'23\'67\\'12", 10));
     Assert.False(CodeUtil.IsWithinString(@"0'23\'67\\'12", 11));
     Assert.False(CodeUtil.IsWithinString(@"0'23\'67\\'12", 12));
 }
Esempio n. 23
0
        public void GenerateDao(JavaDaoConfig javaDaoConfig, JavaMapperConfig javaMapperConfig)
        {
            initDefault();


            string rootDir;
            string result = String.Empty;

            Action action = () =>
            {
                result = daoTemplate.Run(instance =>
                {
                    instance.Model = javaDaoConfig;
                });
                Console.WriteLine(result);
                rootDir = CodeUtil.PrepareJavaRoot(javaDaoConfig);

                string filePath = rootDir + Path.DirectorySeparatorChar + javaDaoConfig.DaoName + ".java";

                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                }
                File.WriteAllText(filePath, result, new UTF8Encoding(false));

                javaMapperConfig.JavaClass = javaDaoConfig.JavaClass;
                GenerateMapper(javaMapperConfig);
            };


            if (javaDaoConfig.SplitReadWrite)
            {
                javaDaoConfig.ForRead  = true;
                javaDaoConfig.ForWrite = false;

                action();


                javaDaoConfig.ForWrite = true;
                javaDaoConfig.ForRead  = false;
                action();
            }
            else
            {
                action();
            }
        }
Esempio n. 24
0
        public void GenerateBean(JavaBeanConfig javaBeanConfig)
        {
            initDefault();

            //IRazorEngineCompiledTemplate template = razorEngine.Compile(templateContent);// "Hello @Model.Name");

            javaBeanConfig.DDLConfig.Prepare();



            string beanRootDir = CodeUtil.PrepareCodeRoot(javaBeanConfig.JavaDiretory, javaBeanConfig.PackageName);
            string voRootDir   = CodeUtil.PrepareCodeRoot(javaBeanConfig.JavaDiretory, javaBeanConfig.VOPackageName);


            string result = String.Empty;

            javaBeanConfig.DDLConfig.Tables.ForEach(t =>
            {
                result = beanTemplate.Run(instance =>
                {
                    javaBeanConfig.Table = t;
                    t.CreatedClass       = JavaClass.CreateBoClass(t, javaBeanConfig, true);
                    instance.Model       = t.CreatedClass as JavaClass;
                });
                Console.WriteLine(result);
                string filePath = beanRootDir + Path.DirectorySeparatorChar + t.CreatedClass.ClassName + ".java";

                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                }
                File.WriteAllText(filePath, result, new UTF8Encoding(false));


                result = beanTemplate.Run(instance =>
                {
                    instance.Model = (t.CreatedClass as JavaClass).JavaVoClass;
                });
                Console.WriteLine(result);
                filePath = voRootDir + Path.DirectorySeparatorChar + (t.CreatedClass as JavaClass).JavaVoClass.ClassName + ".java";
                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                }
                File.WriteAllText(filePath, result, new UTF8Encoding(false));
            });
        }
Esempio n. 25
0
        private void UpdateCode()
        {
            var code = CodeUtil.PadCode(_generator.Compute(), _digits);

            _codeTextView.Text = code;

            _secondsRemaining = _period - (int)DateTimeOffset.Now.ToUnixTimeSeconds() % _period;
            var progress = (int)Math.Floor((double)_progressBar.Max * _secondsRemaining / _period);

            _progressBar.Progress = progress;

            var animator = ObjectAnimator.OfInt(_progressBar, "progress", 0);

            animator.SetDuration(_secondsRemaining * 1000);
            animator.SetInterpolator(new LinearInterpolator());
            animator.Start();
        }
Esempio n. 26
0
        public async Task <IActionResult> Detalhes(int?id)
        {
            var model = new NaoConformidadeModel();

            model.OrigemNc = CodeUtil.PopulaComboComEnum(model.Filtro.OrigemNc);
            model.Status   = CodeUtil.PopulaComboComEnum(model.Detalhe.Status, enumStatus.Todos);
            if (id.HasValue)
            {
                model.Detalhe = await naoConformidadeFacade.Get(id.Value);

                if (model.Detalhe == null)
                {
                    return(NotFound());
                }
            }
            return(View(model));
        }
Esempio n. 27
0
        public void GenerateBean(CSharpBeanConfig beanConfig)
        {
            initDefault();

            //IRazorEngineCompiledTemplate template = razorEngine.Compile(templateContent);// "Hello @Model.Name");

            beanConfig.DDLConfig.Prepare();



            string beanRootDir = CodeUtil.PrepareCodeRoot(beanConfig.CodeDiretory, beanConfig.NamespacePath);

            string result = String.Empty;

            beanConfig.DDLConfig.Tables.ForEach(t =>
            {
                result = beanTemplate.Run(instance =>
                {
                    beanConfig.Table = t;
                    t.CreatedClass   = CSharpClass.CreateEntityClass(t, beanConfig, true);
                    instance.Model   = t.CreatedClass as CSharpClass;
                });
                Console.WriteLine(result);
                string filePath = beanRootDir + Path.DirectorySeparatorChar + t.CreatedClass.ClassName + ".java";

                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                }
                File.WriteAllText(filePath, result, new UTF8Encoding(false));


                //result = beanTemplate.Run(instance =>
                //{
                //    instance.Model = t.CreatedClass.JavaVoClass;
                //});
                //Console.WriteLine(result);
                //filePath = voRootDir + Path.DirectorySeparatorChar + t.CreatedClass.JavaVoClass.ClassName + ".java";
                //if (File.Exists(filePath))
                //{
                //    File.Delete(filePath);
                //}
                //File.WriteAllText(filePath, result, new UTF8Encoding(false));
            });
        }
Esempio n. 28
0
        private void Btn2_Click(object sender, EventArgs e)
        {
            string json = inputBox.Text;
            UserConfig <BaseConfig> config = ConfigUtil.ReadConfig(json);
            HookType type    = (HookType)Enum.Parse(typeof(HookType), config.Type.ToUpper());
            int      counter = 0;
            string   res     = "";

            foreach (BaseConfig cr in config.ConfigList)
            {
                switch (type)
                {
                case HookType.JAVA:
                {
                    JavaConfig result = (JavaConfig)cr;
                    foreach (Dictionary <string, JavaParaItem> chk in result.ParamConfig)
                    {
                        List <Object> checkedItems = chk.Values.ToList <Object>();
                        string        script       = CodeUtil.GenJavaCode(result.ClassName, result.FunctionName, result.Param, checkedItems, result.ParamCount, counter++);
                        res += "\r\n" + script;
                    }
                }
                break;

                case HookType.NATIVE:
                {
                    NativeConfig result = (NativeConfig)cr;
                    foreach (Dictionary <string, NativeParaItem> chk in result.ParamConfig)
                    {
                        List <Object> checkedItems = chk.Values.ToList <Object>();
                        string        script       = CodeUtil.GenNativeCode(result.ModelName, result.Address, checkedItems, counter++);
                        res += "\r\n" + script;
                    }
                    //outputBox.Text = res;
                    //outputBox.Refresh();
                }
                break;

                default:
                    break;
                }
            }
            outputBox.Text = res;
            outputBox.Refresh();
        }
Esempio n. 29
0
        public async Task <IActionResult> Detalhes(int?id)
        {
            ViewBag.propertydisable = id > 0 ? false : true;
            var model = new IncidenteModel();

            model.Estado           = CodeUtil.PopulaComboComEnum(model.Detalhe.EstadoIncidente, enumEstadoIncidente.Todos);
            model.NaoConformidades = naoConformidades.AddAllToList(nameof(NaoConformidade.Descricao));
            if (id.HasValue)
            {
                model.Detalhe = await incidenteFacade.Get(id.Value);

                if (model.Detalhe == null)
                {
                    return(NotFound());
                }
            }
            return(View(model));
        }
Esempio n. 30
0
        public async Task <IActionResult> Detalhes(int?id)
        {
            var model = new UsuarioModel();

            model.Status = CodeUtil.PopulaComboComEnum(model.Detalhe.Status, enumStatus.Todos);
            model.Perfis = CodeUtil.PopulaComboComEnum(model.Filtro.PerfilUsuario, enumPerfilUsuario.Todos);

            if (id.HasValue)
            {
                model.Detalhe = await usuarioFacade.Get(id.Value);

                if (model.Detalhe == null)
                {
                    return(NotFound());
                }
            }
            return(View(model));
        }