Beispiel #1
0
        public DataTable Retreive(string Connection, string OfficeSpaceId, string DatabaseName, string TableName, NColumns NCS, NWheres NWS)
        {
            WorkSpace.Service WS = new WorkSpace.Service();
            WS.Url = getWebUrl();

            string ssss = NCS.ExportString();
            string xxxx = NWS.ExportString();

            string NCS_Encrypt = new EncryptDecrypt.CryptorEngine().Encrypt(NCS.ExportString(), true);
            string NWS_Encrypt = new EncryptDecrypt.CryptorEngine().Encrypt(NWS.ExportString(), true);


            DataTable dt = WS.SelectByColumnAndWhere(Connection, OfficeSpaceId, DatabaseName, TableName, NCS_Encrypt, NWS_Encrypt, UserName);

            ErrorLog = WS.getError();
            return(dt);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            System.Collections.Generic.IEnumerable <String> lines = File.ReadLines("file.txt");

            foreach (var item in lines)
            {
                string Connection    = "NextwaverDatabase";
                string OfficeSpaceId = "OF.0001";
                string DatabaseName  = "GunBook";

                string RootPath = "//Document/Data/Section[@ID='1']/Items[@Name='GunBook']";

                string RootPathPage = "//Document/Data/Section[@ID='1']/Items[@Name='Page']";

                System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.RealTime;

                string bookno         = getParam(item, "bookno");
                string bookyear       = getParam(item, "bookyear");
                string gunregidstart  = getParam(item, "gunregidstart");
                string gunregidend    = getParam(item, "gunregidend");
                string pagetotal      = getParam(item, "pagetotal");
                string gunregidprefix = getParam(item, "gunregidprefix");
                string dual           = getParam(item, "dual");
                int    n;
                if (bookno.Trim() != "" && pagetotal.Trim() != "" && int.TryParse(bookno, out n) && int.TryParse(bookyear, out n) && int.TryParse(pagetotal, out n))
                {
                    System.Console.WriteLine("Create Book " + bookno);
                    Boolean isSuccess = false;
                    for (int iindex = 0; iindex < 10; iindex++)
                    {
                        if (iindex > 1)
                        {
                            System.Console.WriteLine("Rerun Book :: " + bookno);
                        }
                        try
                        {
                            string NCS_Encrypt;
                            string NWS_Encrypt;
                            NextwaverDB.NColumns NCS_S;
                            DataTable            dt;

                            WorkSpace.Service WS = new WorkSpace.Service();

                            NextwaverDB.NWheres NWS = new NextwaverDB.NWheres();
                            NWS.Add(new NextwaverDB.NWhere("BOOKNO", bookno));

                            NCS_S = new NextwaverDB.NColumns();
                            NCS_S.Add(new NextwaverDB.NColumn("BOOKNO"));

                            NCS_Encrypt = new EncryptDecrypt.CryptorEngine().Encrypt(NCS_S.ExportString(), true);
                            NWS_Encrypt = new EncryptDecrypt.CryptorEngine().Encrypt(NWS.ExportString(), true);

                            dt = WS.SelectByColumnAndWhere(Connection, OfficeSpaceId, DatabaseName, "Book", NCS_Encrypt, NWS_Encrypt, "System");
                            if (dt.Rows.Count == 0)
                            {
                                XmlDocument xDoc = new XmlDocument();
                                xDoc.Load(@"tempdoc\Book.xml");

                                NextwaverDB.NColumns NCS = new NextwaverDB.NColumns();
                                NCS.Add(new NextwaverDB.NColumn("BOOKNO", bookno));
                                NCS.Add(new NextwaverDB.NColumn("BOOKYEAR", bookyear));
                                NCS.Add(new NextwaverDB.NColumn("GUNREGIDSTART", gunregidstart));
                                NCS.Add(new NextwaverDB.NColumn("GUNREGIDEND", gunregidend));
                                NCS.Add(new NextwaverDB.NColumn("PAGETOTAL", pagetotal));
                                NCS.Add(new NextwaverDB.NColumn("GUNREGIDPREFIX", gunregidprefix));
                                NCS.Add(new NextwaverDB.NColumn("BOOKSTATUS", "Create"));
                                NCS.Add(new NextwaverDB.NColumn("CREATEDATE", convertDatetime(DateTime.Now)));
                                NCS.Add(new NextwaverDB.NColumn("CREATEBY", "System"));
                                NCS.Add(new NextwaverDB.NColumn("UPDATEDATE", convertDatetime(DateTime.Now)));
                                NCS.Add(new NextwaverDB.NColumn("UPDATEBY", "System"));

                                AddDataXmlNode(xDoc, RootPath + "/Item[@Name='BookNo']", bookno);
                                AddDataXmlNode(xDoc, RootPath + "/Item[@Name='BookYear']", bookyear);
                                AddDataXmlNode(xDoc, RootPath + "/Item[@Name='GunRegIDStart']", gunregidstart);
                                AddDataXmlNode(xDoc, RootPath + "/Item[@Name='GunRegIDEnd']", gunregidend);
                                AddDataXmlNode(xDoc, RootPath + "/Item[@Name='PageTotal']", pagetotal);
                                AddDataXmlNode(xDoc, RootPath + "/Item[@Name='GunRegIDPrefix']", gunregidprefix);
                                AddDataXmlNode(xDoc, RootPath + "/Item[@Name='BookStatus']", "Create");
                                AddDataXmlNode(xDoc, RootPath + "/Item[@Name='CreateDate']", convertDatetime(DateTime.Now));
                                AddDataXmlNode(xDoc, RootPath + "/Item[@Name='CreateBy']", "System");
                                AddDataXmlNode(xDoc, RootPath + "/Item[@Name='UpdateDate']", convertDatetime(DateTime.Now));
                                AddDataXmlNode(xDoc, RootPath + "/Item[@Name='UpdateBy']", "System");

                                string   strDoc = xDoc.OuterXml;
                                string[] OP     = WS.InsertData(Connection, OfficeSpaceId, DatabaseName, "Book", NCS.ExportString(), strDoc, "System");

                                if (OP[0].ToUpper() == "OK")
                                {
                                }
                                else
                                {
                                    File.AppendAllText("log.txt", Environment.NewLine + Environment.NewLine
                                                       + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + " :: " + OP[1]);
                                    System.Console.WriteLine(OP[1]);
                                    //isSuccess = false;
                                    break;
                                }
                            }

                            NWS = new NextwaverDB.NWheres();
                            NWS.Add(new NextwaverDB.NWhere("BOOKNO", bookno));
                            NWS.Add(new NextwaverDB.NWhere("PAGEVERSION", "1"));

                            NCS_S = new NextwaverDB.NColumns();
                            NCS_S.Add(new NextwaverDB.NColumn("BOOKNO"));
                            NCS_S.Add(new NextwaverDB.NColumn("PAGENO"));

                            NCS_Encrypt = new EncryptDecrypt.CryptorEngine().Encrypt(NCS_S.ExportString(), true);
                            NWS_Encrypt = new EncryptDecrypt.CryptorEngine().Encrypt(NWS.ExportString(), true);

                            XmlDocument xDocPage = new XmlDocument();
                            xDocPage.Load(@"tempdoc\Page.xml");
                            AddDataXmlNode(xDocPage, RootPathPage + "/Item[@Name='BookNo']", bookno);
                            AddDataXmlNode(xDocPage, RootPathPage + "/Item[@Name='PageVersion']", "1");
                            AddDataXmlNode(xDocPage, RootPathPage + "/Item[@Name='PageStatus']", "Create");
                            AddDataXmlNode(xDocPage, RootPathPage + "/Item[@Name='CreateDate']", convertDatetime(DateTime.Now));
                            AddDataXmlNode(xDocPage, RootPathPage + "/Item[@Name='CreateBy']", "System");
                            AddDataXmlNode(xDocPage, RootPathPage + "/Item[@Name='UpdateDate']", convertDatetime(DateTime.Now));
                            AddDataXmlNode(xDocPage, RootPathPage + "/Item[@Name='UpdateBy']", "System");

                            DataTable dtp;
                            dtp = WS.SelectByColumnAndWhere(Connection, OfficeSpaceId, DatabaseName, "Page", NCS_Encrypt, NWS_Encrypt, "System");
                            int MaxPageTotal = dtp.Rows.Count;

                            bool isuccess = true;
                            if (MaxPageTotal < int.Parse(pagetotal))
                            {
                                for (int i = (MaxPageTotal + 1); i <= int.Parse(pagetotal); i++)
                                {
                                    NextwaverDB.NColumns NCSPage = new NextwaverDB.NColumns();
                                    NCSPage.Add(new NextwaverDB.NColumn("BOOKNO", bookno));
                                    NCSPage.Add(new NextwaverDB.NColumn("PAGEVERSION", "1"));
                                    NCSPage.Add(new NextwaverDB.NColumn("PAGESTATUS", "Create"));
                                    NCSPage.Add(new NextwaverDB.NColumn("CREATEDATE", convertDatetime(DateTime.Now)));
                                    NCSPage.Add(new NextwaverDB.NColumn("CREATEBY", "System"));
                                    NCSPage.Add(new NextwaverDB.NColumn("UPDATEDATE", convertDatetime(DateTime.Now)));
                                    NCSPage.Add(new NextwaverDB.NColumn("UPDATEBY", "System"));
                                    NCSPage.Add(new NextwaverDB.NColumn("PAGENO", i.ToString()));

                                    AddDataXmlNode(xDocPage, RootPathPage + "/Item[@Name='PageNo']", i.ToString());

                                    string   strDocPage = xDocPage.OuterXml;
                                    string[] OPPage     = WS.InsertData(Connection, OfficeSpaceId, DatabaseName, "Page", NCSPage.ExportString(), strDocPage, "System");

                                    if (OPPage[0].ToUpper() == "OK")
                                    {
                                        System.Console.WriteLine("Create Book " + bookno + " Page " + i.ToString());
                                    }
                                    else
                                    {
                                        File.AppendAllText("log.txt", Environment.NewLine + Environment.NewLine
                                                           + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + " :: " + OPPage[1]);

                                        System.Console.WriteLine(OPPage[1]);
                                        isuccess = false;
                                        break;
                                    }
                                }
                            }

                            System.Console.WriteLine("Create Book " + bookno + " Success");
                            isSuccess = isuccess;
                        }
                        catch (Exception ex)
                        {
                            File.AppendAllText("log.txt", Environment.NewLine + Environment.NewLine
                                               + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + " :: Book:" + bookno + " --> " + ex.Message);
                            break;
                        }

                        if (isSuccess)
                        {
                            break;
                        }
                        else
                        {
                            System.Threading.Thread.Sleep(500);
                        }
                    }
                }
                //
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            string Connection    = "NextwaverDatabase";
            string OfficeSpaceId = "OF.0001";
            string DatabaseName  = "GunBook";

            System.Collections.Generic.IEnumerable <String> lines = File.ReadLines("file.txt");
            int sIndex = 0;

            foreach (var item in lines)
            {
                try
                {
                    if (item.Trim() != "")
                    {
                        sIndex++;

                        WorkSpace.Service WS = new WorkSpace.Service();

                        NextwaverDB.NWheres NWS = new NextwaverDB.NWheres();
                        NWS.Add(new NextwaverDB.NWhere("NAME", item));

                        NextwaverDB.NColumns NCS_S = new NextwaverDB.NColumns();
                        NCS_S.Add(new NextwaverDB.NColumn("NAME"));

                        string NCS_Encrypt = new EncryptDecrypt.CryptorEngine().Encrypt(NCS_S.ExportString(), true);
                        string NWS_Encrypt = new EncryptDecrypt.CryptorEngine().Encrypt(NWS.ExportString(), true);

                        DataTable dt = WS.SelectByColumnAndWhere(Connection, OfficeSpaceId, DatabaseName, "GunOwner", NCS_Encrypt, NWS_Encrypt, "System");

                        if (dt.Rows.Count == 0)
                        {
                            try
                            {
                                NextwaverDB.NColumns NCS = new NextwaverDB.NColumns();
                                NCS.Add(new NextwaverDB.NColumn("NAME", item));
                                NCS.Add(new NextwaverDB.NColumn("DESCRIPTION", ""));
                                NCS.Add(new NextwaverDB.NColumn("UPDATEDATE", convertDatetime(DateTime.Now)));
                                NCS.Add(new NextwaverDB.NColumn("DELETE", "0"));
                                string[] OP = WS.InsertData(Connection, OfficeSpaceId, DatabaseName, "GunOwner", NCS.ExportString(), "", "System");

                                if (OP[0].ToUpper() == "OK")
                                {
                                    System.Console.WriteLine(sIndex + " :: Add :: " + item);
                                }
                                else
                                {
                                    System.Console.WriteLine("Add :: " + item + " fail");
                                }
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                        else
                        {
                            System.Console.WriteLine("Have :: " + item);
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            string Connection    = "NextwaverDatabase";
            string OfficeSpaceId = "OF.0001";
            string DatabaseName  = "GunBook";
            string UserName      = "******";

            string strHostName = System.Net.Dns.GetHostName();
            string pathImgGun  = System.Configuration.ConfigurationSettings.AppSettings["pathImgGun"];
            bool   isSuccess   = false;

            String[] EditImageTemplate = System.IO.File.ReadAllLines("BookEdit.txt");

            //NextwaverDB.NWheres NWSTest = new NextwaverDB.NWheres();
            //NWSTest.Add(new NextwaverDB.NWhere("PAGESTATUS", "Create"));

            //DataTable dttest = WS.SelectAllColumnByWhere(Connection, OfficeSpaceId, DatabaseName, "Page", NWSTest.ExportString(), UserName);

            for (int index = 0; index < 20; index++)
            {
                try
                {
                    WorkSpace.Service WS           = new WorkSpace.Service();
                    string            RootPathPage = "//Document/Data/Section[@ID='1']/Items[@Name='Page']";

                    foreach (string item in EditImageTemplate)
                    {
                        string Bookno           = getParam(item, "BOOKNO");
                        NextwaverDB.NWheres NWS = new NextwaverDB.NWheres();
                        NWS.Add(new NextwaverDB.NWhere("BOOKNO", Bookno));

                        NextwaverDB.NColumns NCS_S = new NextwaverDB.NColumns();
                        NCS_S.Add(new NextwaverDB.NColumn("ID"));
                        NCS_S.Add(new NextwaverDB.NColumn("BOOKNO"));
                        NCS_S.Add(new NextwaverDB.NColumn("PAGENO"));
                        NCS_S.Add(new NextwaverDB.NColumn("IMGURL"));

                        string NCS_Encrypt = new EncryptDecrypt.CryptorEngine().Encrypt(NCS_S.ExportString(), true);
                        string NWS_Encrypt = new EncryptDecrypt.CryptorEngine().Encrypt(NWS.ExportString(), true);

                        DataTable dt = WS.SelectByColumnAndWhere(Connection, OfficeSpaceId, DatabaseName, "Page", NCS_Encrypt, NWS_Encrypt, UserName);

                        int intPageNo    = 0;
                        int intRowInPage = 20;
                        int intBegin     = 0;

                        int.TryParse(getParam(item, "BEGINID"), out intBegin);

                        int.TryParse(getParam(item, "ROWINPAGE"), out intRowInPage);

                        if (intRowInPage == 0)
                        {
                            intRowInPage = 20;
                        }

                        foreach (DataRow itemData in dt.Rows)
                        {
                            intPageNo = Convert.ToInt16(itemData["PAGENO"]);
                            if (itemData["IMGURL"].ToString().Trim() != "")
                            {
                                XmlDocument xDocPage = new XmlDocument();
                                String      strDoc   = WS.SelectLastDocument(Connection, OfficeSpaceId, DatabaseName, "Page", int.Parse(itemData["ID"].ToString()), UserName);
                                xDocPage.LoadXml(strDoc);

                                string      XPathDataRecord = "//Document/Data/Section[@ID='2']/Items[@Name='RecordInfo']";
                                XmlNode     nodeDataGrid    = xDocPage.SelectSingleNode(XPathDataRecord);
                                XmlNodeList listItem        = nodeDataGrid.SelectNodes("./Item");
                                if (listItem.Count == 0)
                                {
                                    NextwaverDB.NColumns NColumns = new NextwaverDB.NColumns();

                                    NColumns.Add(new NextwaverDB.NColumn("UPDATEDATE", convertDatetime(DateTime.Now)));
                                    NColumns.Add(new NextwaverDB.NColumn("UPDATEBY", UserName));

                                    AddDataXmlNode(xDocPage, RootPathPage + "/Item[@Name='UpdateDate']", convertDatetime(DateTime.Now));
                                    AddDataXmlNode(xDocPage, RootPathPage + "/Item[@Name='UpdateBy']", UserName);

                                    XmlAttribute att;
                                    XmlNode      nodeItem;
                                    for (int i = intBegin + ((intPageNo - 1) * intRowInPage); i < (intPageNo * intRowInPage) + intBegin; i++)
                                    {
                                        nodeItem = xDocPage.CreateElement("Item");

                                        att       = xDocPage.CreateAttribute("C00");
                                        att.Value = i.ToString();
                                        nodeItem.Attributes.Append(att);

                                        att       = xDocPage.CreateAttribute("C01");
                                        att.Value = "";
                                        nodeItem.Attributes.Append(att);

                                        att       = xDocPage.CreateAttribute("C02");
                                        att.Value = "";
                                        nodeItem.Attributes.Append(att);

                                        att       = xDocPage.CreateAttribute("C03");
                                        att.Value = "";
                                        nodeItem.Attributes.Append(att);

                                        att       = xDocPage.CreateAttribute("C04");
                                        att.Value = "";
                                        nodeItem.Attributes.Append(att);

                                        att       = xDocPage.CreateAttribute("C05");
                                        att.Value = "";
                                        nodeItem.Attributes.Append(att);

                                        att       = xDocPage.CreateAttribute("C06");
                                        att.Value = "";
                                        nodeItem.Attributes.Append(att);

                                        att       = xDocPage.CreateAttribute("C07");
                                        att.Value = "";
                                        nodeItem.Attributes.Append(att);

                                        att       = xDocPage.CreateAttribute("C08");
                                        att.Value = "";
                                        nodeItem.Attributes.Append(att);

                                        att       = xDocPage.CreateAttribute("C09");
                                        att.Value = "";
                                        nodeItem.Attributes.Append(att);

                                        att       = xDocPage.CreateAttribute("C10");
                                        att.Value = "";
                                        nodeItem.Attributes.Append(att);

                                        att       = xDocPage.CreateAttribute("C11");
                                        att.Value = "";
                                        nodeItem.Attributes.Append(att);

                                        att       = xDocPage.CreateAttribute("C12");
                                        att.Value = "";
                                        nodeItem.Attributes.Append(att);

                                        att       = xDocPage.CreateAttribute("C13");
                                        att.Value = "";
                                        nodeItem.Attributes.Append(att);

                                        att       = xDocPage.CreateAttribute("C14");
                                        att.Value = "";
                                        nodeItem.Attributes.Append(att);

                                        att       = xDocPage.CreateAttribute("C15");
                                        att.Value = "";
                                        nodeItem.Attributes.Append(att);

                                        att       = xDocPage.CreateAttribute("C16");
                                        att.Value = "";
                                        nodeItem.Attributes.Append(att);

                                        att       = xDocPage.CreateAttribute("C17");
                                        att.Value = "";
                                        nodeItem.Attributes.Append(att);

                                        nodeDataGrid.AppendChild(nodeItem);
                                    }

                                    string strDocPage = xDocPage.OuterXml;

                                    NextwaverDB.NWheres NWheres = new NextwaverDB.NWheres();
                                    NWheres.Add(new NextwaverDB.NWhere("ID", itemData["ID"].ToString()));

                                    string[] msgOutput = WS.UpdateData(Connection, OfficeSpaceId, DatabaseName, "Page", NColumns.ExportString(), NWheres.ExportString(), strDocPage, UserName);
                                    if (msgOutput[0].ToUpper() == "OK")
                                    {
                                        System.Console.WriteLine("Update ID -->> BookNo " + itemData["BOOKNO"] + " PageNo " + itemData["PAGENO"]);
                                    }
                                    else
                                    {
                                        File.AppendAllText("Log.txt", Environment.NewLine + Environment.NewLine
                                                           + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + " :: Book:" + itemData["BOOKNO"] + " :: Page:" + itemData["PAGENO"] + " --> " + msgOutput[1]);
                                    }
                                }
                            }
                        }
                    }
                    isSuccess = true;
                }
                catch (Exception ex)
                {
                    File.AppendAllText("Log.txt", Environment.NewLine + Environment.NewLine
                                       + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + " --> " + ex.Message);
                }
                if (isSuccess)
                {
                    break;
                }
                else
                {
                    System.Threading.Thread.Sleep(500);
                }
            }
        }