Example #1
0
 /// <summary>
 /// 读写器的类型项
 /// </summary>
 /// <param name="typeID"></param>
 /// <param name="itemType"></param>
 /// <param name="readHandle"></param>
 /// <param name="writerHandle"></param>
 internal MemTypeItem(int typeID, Type itemType, ReadInfo readHandle, WriteInfo writerHandle)
 {
     _typeID       = typeID;
     _itemType     = itemType;
     _readHandle   = readHandle;
     _writerHandle = writerHandle;
 }
Example #2
0
        /// <summary>
        /// 添加项
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="typeID">分配的ID</param>
        /// <param name="readInfo">读取器</param>
        private static void AddItem <T>(int typeID, ReadInfo readInfo, WriteInfo writeInfo)
        {
            MemTypeItem item = new MemTypeItem(typeID, typeof(T), readInfo, writeInfo);

            _dicMemTypeItem[typeID] = item;
            _dicMemTypeItemByFullName[item.ItemType.FullName] = item;
        }
Example #3
0
        private void _writeSpooler_ItemSpooled(WriteInfo item)
        {
            var previousForeColor       = Console.ForegroundColor;
            var previousBackgroundColor = Console.BackgroundColor;

            switch (item.WriteMode)
            {
            case WriteModes.Information:
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(item.MessageToWrite);
                break;

            case WriteModes.Emphasis:
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine(item.MessageToWrite);
                break;

            case WriteModes.Important:
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine(item.MessageToWrite);
                break;

            case WriteModes.Warning:
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(item.MessageToWrite);
                break;
            }


            Console.Write("\b \b");

            Console.ForegroundColor = previousForeColor;
            Console.BackgroundColor = previousBackgroundColor;
        }
Example #4
0
        /// <summary>
        /// Entry Of MongoCola@Browser
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lnkWebFormEntry_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            this.Height = 500;
            HTTP.HTTPServer.ServerPath = Application.StartupPath + "\\HTML";
            HTTP.HTTPServer svr = new HTTP.HTTPServer();
            svr.LogInfo += new EventHandler <HTTP.HTTPServer.LogOutEvent>(
                (x, y) =>
            {
                if (txtInfo.InvokeRequired)
                {
                    WriteInfo t = new WriteInfo(Write);
                    object[] o  = new object[2] {
                        y.Info, y.Level
                    };
                    ((Control)this).Invoke(t, o);
                    return;
                }
                else
                {
                    Write(y.Info, y.Level);
                }
            });
            Thread q = new Thread(new ThreadStart(svr.Start));

            q.Start();
            System.Diagnostics.Process.Start("http://localhost:13000/");
        }
Example #5
0
        public void GenerateCode(IConceptInfo conceptInfo, ICodeBuilder codeBuilder)
        {
            WriteInfo info = (WriteInfo)conceptInfo;

            codeBuilder.InsertCode(
                String.Format(ImplementationCodeSnippet, info.DataStructure.Module.Name, info.DataStructure.Name),
                DataStructureCodeGenerator.AdditionalOperationsTag.Evaluate(info.DataStructure));
        }
Example #6
0
 public ItemPrototype(ushort sId, ushort cId, bool useable)
 {
     ServerID      = sId;
     ClientID      = cId;
     CanUse        = useable;
     ItemComponent = new NoneComponent();
     DecayInfo     = new DecayInfo();
     WriteInfo     = new WriteInfo();
 }
Example #7
0
        protected static string MemberFunctionsSnippet(WriteInfo info)
        {
            return(string.Format(
                       @"public void Save(IEnumerable<{0}.{1}> insertedNew, IEnumerable<{0}.{1}> updatedNew, IEnumerable<{0}.{1}> deletedIds, bool checkUserPermissions = false)
        {{
            Rhetos.Utilities.CsUtility.Materialize(ref insertedNew);
            Rhetos.Utilities.CsUtility.Materialize(ref updatedNew);
            Rhetos.Utilities.CsUtility.Materialize(ref deletedIds);

            if (insertedNew == null) insertedNew = Enumerable.Empty<{0}.{1}>();
            if (updatedNew == null) updatedNew = Enumerable.Empty<{0}.{1}>();
            if (deletedIds == null) deletedIds = Enumerable.Empty<{0}.{1}>();

            if (insertedNew.Count() == 0 && updatedNew.Count() == 0 && deletedIds.Count() == 0)
                return;

            foreach (var item in insertedNew)
                if (item.ID == Guid.Empty)
                    item.ID = Guid.NewGuid();

            " + WritableOrmDataStructureCodeGenerator.ClearContextTag.Evaluate(info.DataStructure) + @"

            " + WritableOrmDataStructureCodeGenerator.ArgumentValidationTag.Evaluate(info.DataStructure) + @"

            " + WritableOrmDataStructureCodeGenerator.InitializationTag.Evaluate(info.DataStructure) + @"

            {2}

            bool allEffectsCompleted = false;
            try
            {{
                " + WritableOrmDataStructureCodeGenerator.OnSaveTag1.Evaluate(info.DataStructure) + @"

                " + WritableOrmDataStructureCodeGenerator.OnSaveTag2.Evaluate(info.DataStructure) + @"

                Rhetos.Dom.DefaultConcepts.InvalidDataMessage.ValidateOnSave(insertedNew, updatedNew, this, ""{0}.{1}"");
                allEffectsCompleted = true;
            }}
            finally
            {{
                if (!allEffectsCompleted)
                    _executionContext.PersistenceTransaction.DiscardChanges();
            }}
        }}

        public IEnumerable<Rhetos.Dom.DefaultConcepts.InvalidDataMessage> Validate(IList<Guid> ids, bool onSave)
        {{
            " + WritableOrmDataStructureCodeGenerator.OnSaveValidateTag.Evaluate(info.DataStructure) + @"
            yield break;
        }}

        ",
                       info.DataStructure.Module.Name,
                       info.DataStructure.Name,
                       info.SaveImplementation));
        }
 public WorldItemPrototype(IBaseItemPrototype item)
 {
     ServerID      = item.ServerID;
     ClientID      = item.ClientID;
     Name          = item.Name;
     Article       = item.Article;
     Plural        = item.Plural;
     CanUse        = item.CanUse;
     ItemComponent = item.ItemComponent;
     DecayInfo     = item.DecayInfo;
     WriteInfo     = item.WriteInfo;
 }
 public WorldItemPrototype(ushort sId, ushort cId, bool useable, bool moveable = false,
                           bool blocksolid      = false, bool blockvision = false, bool blockpathfind = false,
                           bool blockprojectile = false)
 {
     ServerID      = sId;
     ClientID      = cId;
     CanUse        = useable;
     ItemComponent = new NoneComponent();
     DecayInfo     = new DecayInfo();
     WriteInfo     = new WriteInfo();
     BlockInfo     = new BlockInfo(blocksolid, blockvision, blockpathfind, blockprojectile);
 }
        protected static string MemberFunctionsSnippet(WriteInfo info)
        {
            return(string.Format(
                       @"public virtual void Save(IEnumerable<{0}.{1}> insertedNew, IEnumerable<{0}.{1}> updatedNew, IEnumerable<{0}.{1}> deletedIds, bool checkUserPermissions = false)
        {{
            if (!DomHelper.InitializeSaveMethodItems(ref insertedNew, ref updatedNew, ref deletedIds))
                return;

            " + WritableOrmDataStructureCodeGenerator.ClearContextTag.Evaluate(info.DataStructure) + @"

            " + WritableOrmDataStructureCodeGenerator.ArgumentValidationTag.Evaluate(info.DataStructure) + @"

            " + WritableOrmDataStructureCodeGenerator.InitializationTag.Evaluate(info.DataStructure) + @"

            {2}

            bool allEffectsCompleted = false;
            try
            {{
                " + WritableOrmDataStructureCodeGenerator.OnSaveTag1.Evaluate(info.DataStructure) + @"

                " + WritableOrmDataStructureCodeGenerator.OnSaveTag2.Evaluate(info.DataStructure) + @"

                Rhetos.Dom.DefaultConcepts.InvalidDataMessage.ValidateOnSave(insertedNew, updatedNew, this, ""{0}.{1}"");
                allEffectsCompleted = true;
            }}
            finally
            {{
                if (!allEffectsCompleted)
                    _executionContext.PersistenceTransaction.DiscardOnDispose();
            }}
        }}

        public IEnumerable<Rhetos.Dom.DefaultConcepts.InvalidDataMessage> Validate(IList<Guid> ids, bool onSave)
        {{
            " + WritableOrmDataStructureCodeGenerator.OnSaveValidateTag.Evaluate(info.DataStructure) + @"
            yield break;
        }}

        ",
                       info.DataStructure.Module.Name,
                       info.DataStructure.Name,
                       info.SaveImplementation));
        }
Example #11
0
 static Log()
 {
     #region ---日志地址---
     string dirpath = System.Configuration.ConfigurationManager.AppSettings.Get("LogPath");
     //string dirpath = ConfigurationManager.Get("LogPath");
     if (string.IsNullOrEmpty(dirpath))
     {
         dirpath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData);
     }
     softName = System.Configuration.ConfigurationManager.AppSettings.Get("SoftName");
     if (string.IsNullOrEmpty(softName))
     {
         softName = System.Diagnostics.Process.GetCurrentProcess().MainModule.ModuleName;
     }
     logDir = System.IO.Path.Combine(dirpath, softName);
     try
     {
         if (!System.IO.Directory.Exists(logDir))
         {
             System.IO.Directory.CreateDirectory(logDir);
         }
     }
     catch (System.Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.ToString());
     }
     #endregion
     d = (string message) =>
     {
         writeLine(LogType.debug, message);
     };
     i = (string message) =>
     {
         writeLine(LogType.info, message);
     };
     e = (string message, System.Exception ex) =>
     {
         writeLine(LogType.error, message, ex);
     };
     System.AppDomain.CurrentDomain.ProcessExit += (object sender, System.EventArgs args) => { Dispose(); };
 }
Example #12
0
        protected static string MemberFunctionsSnippet(WriteInfo info)
        {
            return(string.Format(
                       @"        public void Save(IEnumerable<{0}.{1}> insertedNew, IEnumerable<{0}.{1}> updatedNew, IEnumerable<{0}.{1}> deletedIds, bool checkUserPermissions = false)
        {{
            Rhetos.Utilities.CsUtility.Materialize(ref insertedNew);
            Rhetos.Utilities.CsUtility.Materialize(ref updatedNew);
            Rhetos.Utilities.CsUtility.Materialize(ref deletedIds);

            if (insertedNew == null) insertedNew = Enumerable.Empty<{0}.{1}>();
            if (updatedNew == null) updatedNew = Enumerable.Empty<{0}.{1}>();
            if (deletedIds == null) deletedIds = Enumerable.Empty<{0}.{1}>();

            if (insertedNew.Count() == 0 && updatedNew.Count() == 0 && deletedIds.Count() == 0)
                return;

            foreach (var item in insertedNew)
                if (item.ID == Guid.Empty)
                    item.ID = Guid.NewGuid();

            " + WritableOrmDataStructureCodeGenerator.ClearContextTag.Evaluate(info.DataStructure) + @"

            " + WritableOrmDataStructureCodeGenerator.ArgumentValidationTag.Evaluate(info.DataStructure) + @"

            " + WritableOrmDataStructureCodeGenerator.InitializationTag.Evaluate(info.DataStructure) + @"

            {2}

            " + WritableOrmDataStructureCodeGenerator.OnSaveTag1.Evaluate(info.DataStructure) + @"

            " + WritableOrmDataStructureCodeGenerator.OnSaveTag2.Evaluate(info.DataStructure) + @"
        }}

",
                       info.DataStructure.Module.Name,
                       info.DataStructure.Name,
                       info.SaveImplementation));
        }
Example #13
0
        /// <summary>
        ///     Entry Of MongoCola@Browser
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lnkWebFormEntry_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Height = 500;
            MongoCola.HTTPServer.ServerPath = Application.StartupPath + "\\HTML";
            var svr = new MongoCola.HTTPServer();

            svr.LogInfo += (x, y) =>
            {
                if (txtInfo.InvokeRequired)
                {
                    WriteInfo t = Write;
                    var       o = new object[2] {
                        y.Info, y.Level
                    };
                    Invoke(t, o);
                }
                Write(y.Info, y.Level);
            };
            var q = new Thread(svr.Start);

            q.Start();
            Process.Start("http://localhost:13000/");
        }
Example #14
0
        /// <summary>
        ///     Entry Of MongoCola@Browser
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lnkWebFormEntry_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            //加载Config
            ConfigHelper.LoadFromConfigFile(ConfigFile.SelectedPathOrFileName);
            HTTPServer.ServerPath = ServerPathPicker.SelectedPathOrFileName;
            var svr = new HTTPServer();

            svr.LogInfo += (x, y) =>
            {
                if (txtInfo.InvokeRequired)
                {
                    WriteInfo t = Write;
                    var       o = new object[2] {
                        y.Info, y.Level
                    };
                    Invoke(t, o);
                }
                Write(y.Info, y.Level);
            };
            var q = new Thread(svr.Start);

            q.Start();
            Process.Start("http://localhost:13000/");
        }
Example #15
0
        protected void WriteDateElement(string localname, string fluxochamada, DateTime value, string format, WriteInfo info)
        {
            FluxoObrigatorio(localname, fluxochamada, value, info.CodigoCampo, info.IsObrigatorio);

            string stringFormatada = value.ToString(format);

            _xml.WriteStartElement(localname);
            _xml.WriteString(stringFormatada);
            _xml.WriteEndElement();
        }
Example #16
0
        protected void WriteNumberElement(string localname, string fluxochamada, decimal value, NumberFormatInfo format, WriteInfo info)
        {
            FluxoObrigatorio(localname, fluxochamada, value, info.CodigoCampo, info.IsObrigatorio);

            string stringFormatada = value.ToString(format);

            _xml.WriteStartElement(localname);
            _xml.WriteString(stringFormatada.PadLeft(info.Padleft, info.Chpadleft));
            _xml.WriteEndElement();
        }
Example #17
0
        protected void WriteNumberElement(string localname, string fluxochamada, long value, WriteInfo info, int padleft = 0, char chpadleft = default(char))
        {
            FluxoObrigatorio(localname, fluxochamada, value, info.CodigoCampo, info.IsObrigatorio);

            string stringFormatada = value.ToString();

            if (info.Maximo > 0 && stringFormatada.Length > info.Maximo)
            {
                throw GerarEx("Máximo", localname, fluxochamada, info.CodigoCampo, String.Empty, value);
            }
            _xml.WriteStartElement(localname);
            _xml.WriteString(stringFormatada.PadLeft(padleft, chpadleft));
            _xml.WriteEndElement();
        }
Example #18
0
        protected void WriteEnumElement(string localname, string fluxochamada, Enum value, WriteInfo info, bool obrigatorio = false)
        {
            int valorEnum = Convert.ToInt32(value);

            if (obrigatorio && valorEnum > 0)
            {
                throw GerarEx("Obrigatório", localname, fluxochamada, info.CodigoCampo, String.Empty, value);
            }
            if (!obrigatorio && valorEnum == 0)
            {
                return;                                 // Não é obrigatório e não tem valor - não precisa escrever a tag
            }
            string stringFormatada = valorEnum.ToString();

            _xml.WriteStartElement(localname);
            _xml.WriteString(stringFormatada);
            _xml.WriteEndElement();
        }
Example #19
0
 /// <summary>
 /// Entry Of MongoCola@Browser
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void lnkTryBrowse_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
 {
     this.Height = 500;
     HTTP.HTTPServer.ServerPath = Application.StartupPath + "\\HTML";
     HTTP.HTTPServer svr = new HTTP.HTTPServer();
     svr.LogInfo += new EventHandler<HTTP.HTTPServer.LogOutEvent>(
          (x, y) =>
          {
              if (txtInfo.InvokeRequired)
              {
                  WriteInfo t = new WriteInfo(Write);
                  object[] o = new object[2] { y.Info,y.Level };
                  ((Control)this).Invoke(t, o);
                  return;
              }
              else
              {
                  Write(y.Info,y.Level);
              }
          });
     Thread q = new Thread(new ThreadStart(svr.Start));
     q.Start();
     System.Diagnostics.Process.Start("http://localhost:13000/");
 }