Esempio n. 1
0
    public string SyncEventMethods(string codecontent, string epid, string propertyname, string devid, string sk)
    {
        string[,] p = new string[2, 4];
        p[0, 0]     = "codecontent";
        p[1, 0]     = codecontent;
        p[0, 1]     = "epid";
        p[1, 1]     = epid;
        p[0, 2]     = "propertyname";
        p[1, 2]     = propertyname;
        p[0, 3]     = "devid";
        p[1, 3]     = devid;

        devid = SEC.SECURITY_ContentDecrypt(devid);
        if (!SEC.SECURITY_RequestDecrypt(p, sk, devid))
        {
            return(SEC.SECURITY_ContentEncrypt("-4"));
        }

        codecontent  = SEC.SECURITY_ContentDecrypt(codecontent);
        propertyname = SEC.SECURITY_ContentDecrypt(propertyname);
        epid         = SEC.SECURITY_ContentDecrypt(epid);

        ArrayList     x = new ArrayList();
        EventCompiler c = null;

        if (codecontent != "")
        {
            try
            {
                c = new EventCompiler(devid, epid, propertyname);
                x = c.GetProcess(codecontent);
            }
            catch
            {
                x = null;
            }
        }
        else
        {
            string query2 = "DELETE FROM EP_EVENTS_CODE WHERE EVENT_CODE_ID IN (SELECT CODEID FROM  EP_EVENTS_FACT WHERE EP_ID = '" + epid + "' AND PROPERTYNAME = '" + propertyname + "');"
                            + "DELETE FROM EP_EVENTS_FACT WHERE EP_ID = '" + epid + "' AND PROPERTYNAME = '" + propertyname + "'";
            int ret2 = DataHelper_COSWEBIDE.Query_ExecuteNonQuery(DataHelper_COSWEBIDE.DataBaseFact.PROPERTY, query2, null);

            if (ret2 == 1)
            {
                return("0");
            }
            else
            {
                return("-2");
            }
        }

        try
        {
            if (x == null)
            {
                return("-1");
            }
        }
        catch { }

        string query = "DELETE FROM EP_EVENTS_CODE WHERE EVENT_CODE_ID IN (SELECT CODEID FROM  EP_EVENTS_FACT WHERE EP_ID = '" + epid + "' AND PROPERTYNAME = '" + propertyname + "');"
                       + "DELETE FROM EP_EVENTS_FACT WHERE EP_ID = '" + epid + "' AND PROPERTYNAME = '" + propertyname + "'";
        int ret = DataHelper_COSWEBIDE.Query_ExecuteNonQuery(DataHelper_COSWEBIDE.DataBaseFact.PROPERTY, query, null);



        if (ret == 1)
        {
            string ret2 = "0";
            string q2   = "INSERT INTO EP_EVENTS_CODE (RAW_CODE) VALUES (N'" + codecontent.Replace("'", "''") + "'); SELECT SCOPE_IDENTITY();";
            ret2 = DataHelper_COSWEBIDE.Query_ExecuteScalar(DataHelper_COSWEBIDE.DataBaseFact.PROPERTY, q2, null);

            for (int s = 0; s < x.Count; s++)
            {
                string q3 = "INSERT INTO EP_EVENTS_FACT (EP_ID,PROPERTYNAME,TRIGGERCONTENT,STATUS,CODEID) VALUES ('" + epid + "','" + propertyname + "',N'" + x[s].ToString().Replace("'", "''") + "','1','" + ret2 + "')";
                DataHelper_COSWEBIDE.Query_ExecuteNonQuery(DataHelper_COSWEBIDE.DataBaseFact.PROPERTY, q3, null);
            }

            return("1");
        }
        else
        {
            return("-2");
        }
    }
Esempio n. 2
0
        private void Compile()
        {
            Console.WriteLine("Compiling resources...");
            using (var sprites_texture = new TextureCompiler(Path.Combine(OutputDirectory, "SpritesTexture")))
                using (var tiles_texture = new TextureCompiler(Path.Combine(OutputDirectory, "TilesTexture")))
                    using (var interfaces_texture = new TextureCompiler(Path.Combine(OutputDirectory, "InterfacesTexture")))
                    {
                        foreach (var cat in Table.Categories)
                        {
                            var      type     = Enum.Parse <ResourceType>(cat.Key);
                            string   output   = "";
                            Compiler compiler = null;
                            switch (type)
                            {
                            case ResourceType.Entity:
                                compiler         = new EntityCompiler();
                                compiler.Texture = sprites_texture;
                                output           = Path.Combine(OutputDirectory, "Entities");
                                break;

                            case ResourceType.Event:
                                compiler         = new EventCompiler();
                                compiler.Texture = sprites_texture;
                                output           = Path.Combine(OutputDirectory, "Events");
                                break;

                            case ResourceType.Interface:
                                compiler         = new InterfaceCompiler();
                                compiler.Texture = interfaces_texture;
                                output           = Path.Combine(OutputDirectory, "Interfaces");
                                break;

                            //case ResourceType.Item:
                            //    compiler = new ItemCompiler();
                            //    break;
                            case ResourceType.Tile:
                                compiler         = new TileCompiler();
                                compiler.Texture = tiles_texture;
                                output           = Path.Combine(OutputDirectory, "Tiles");
                                break;
                            }

                            if (compiler != null)
                            {
                                using (compiler.Writer = new BinaryWriter(File.OpenWrite(output)))
                                {
                                    compiler.RootDirectory = InputDirectory;
                                    compiler.Table         = Table;

                                    compiler.Writer.Write(Table.GetLastID(cat.Key) + 1);

                                    int id = 0;
                                    foreach (var item in cat.Value)
                                    {
                                        while (id < item.ID)
                                        {
                                            compiler.Placeholder();
                                            id++;
                                        }
                                        compiler.Compile(item.Path);
                                        id++;
                                    }
                                }
                            }
                            else
                            {
                                Console.WriteLine($"Warning: Unsupported resource type [{type}].");
                            }
                            //foreach (var v in cat.Value)
                            //    Console.WriteLine(v.Path);
                        }
                    }
            Console.WriteLine("Compilation done.");
            Console.WriteLine();
        }
    public string SyncEventMethods(string codecontent, string epid, string propertyname, string devid, string sk)
    {
        string[,] p = new string[2, 4];
        p[0, 0] = "codecontent";
        p[1, 0] = codecontent;
        p[0, 1] = "epid";
        p[1, 1] = epid;
        p[0, 2] = "propertyname";
        p[1, 2] = propertyname;
        p[0, 3] = "devid";
        p[1, 3] = devid;

        devid = SEC.SECURITY_ContentDecrypt(devid);
        if (!SEC.SECURITY_RequestDecrypt(p, sk, devid)) return SEC.SECURITY_ContentEncrypt("-4");

        codecontent = SEC.SECURITY_ContentDecrypt(codecontent);
        propertyname = SEC.SECURITY_ContentDecrypt(propertyname);
        epid = SEC.SECURITY_ContentDecrypt(epid);

        ArrayList x = new ArrayList();
        EventCompiler c = null;

        if (codecontent != "")
        {
            try
            {
                c = new EventCompiler(devid, epid, propertyname);
                x = c.GetProcess(codecontent);
            }
            catch
            {
                x = null;
            }

        }
        else
        {
            string query2 = "DELETE FROM EP_EVENTS_CODE WHERE EVENT_CODE_ID IN (SELECT CODEID FROM  EP_EVENTS_FACT WHERE EP_ID = '" + epid + "' AND PROPERTYNAME = '" + propertyname + "');"
                          + "DELETE FROM EP_EVENTS_FACT WHERE EP_ID = '" + epid + "' AND PROPERTYNAME = '" + propertyname + "'";
            int ret2 = DataHelper_COSWEBIDE.Query_ExecuteNonQuery(DataHelper_COSWEBIDE.DataBaseFact.PROPERTY, query2, null);

            if (ret2 == 1)
            {
                return "0";
            }
            else
            {
                return "-2";
            }

        }

        try
        {
            if (x == null)
            {
                return "-1";
            }
        }
        catch { }

        string query = "DELETE FROM EP_EVENTS_CODE WHERE EVENT_CODE_ID IN (SELECT CODEID FROM  EP_EVENTS_FACT WHERE EP_ID = '" + epid + "' AND PROPERTYNAME = '" + propertyname + "');"
                     + "DELETE FROM EP_EVENTS_FACT WHERE EP_ID = '" + epid + "' AND PROPERTYNAME = '" + propertyname + "'";
        int ret = DataHelper_COSWEBIDE.Query_ExecuteNonQuery(DataHelper_COSWEBIDE.DataBaseFact.PROPERTY, query, null);



        if (ret == 1)
        {
            string ret2 = "0";
            string q2 = "INSERT INTO EP_EVENTS_CODE (RAW_CODE) VALUES (N'" + codecontent.Replace("'", "''") + "'); SELECT SCOPE_IDENTITY();";
            ret2 = DataHelper_COSWEBIDE.Query_ExecuteScalar(DataHelper_COSWEBIDE.DataBaseFact.PROPERTY, q2, null);

            for (int s = 0; s < x.Count; s++)
            {
                string q3 = "INSERT INTO EP_EVENTS_FACT (EP_ID,PROPERTYNAME,TRIGGERCONTENT,STATUS,CODEID) VALUES ('" + epid + "','" + propertyname + "',N'" + x[s].ToString().Replace("'", "''") + "','1','" + ret2 + "')";
                DataHelper_COSWEBIDE.Query_ExecuteNonQuery(DataHelper_COSWEBIDE.DataBaseFact.PROPERTY, q3, null);
            }

            return "1";
        }
        else
        {

            return "-2";

        }


    }