Example #1
0
        public sSiteModels GetWebsiteModels(sRowsData sRowsData, string cuurip, string userAgent)
        {
            database database = new database();
            datetime datetime = new datetime();
            string   stdate = datetime.sqldate("mssql", "flyformstring"), sttime = datetime.sqltime("mssql", "flyformstring"), original = "", encryption = new sha256().new256("mssql", "flyformstring"), extension = ".jpg";

            new WebClient().DownloadFile(sRowsData.value.TrimEnd(), $"{database.connectionString("formFiles")}{original}({encryption}){extension}");
            List <dbparam> dbparamlist = new List <dbparam>();
            string         date = datetime.sqldate("mssql", "flyformstring"), time = datetime.sqltime("mssql", "flyformstring"), cuname = Dns.GetHostEntry(cuurip).HostName.IndexOf('.') == -1 ? Dns.GetHostEntry(cuurip).HostName : Dns.GetHostEntry(cuurip).HostName.Split('.')[0];

            dbparamlist.Add(new dbparam("@formId", sRowsData.formId.TrimEnd()));
            dbparamlist.Add(new dbparam("@website", sRowsData.value.TrimEnd()));
            dbparamlist.Add(new dbparam("@externip", cuurip));
            dbparamlist.Add(new dbparam("@hostname", cuname));
            dbparamlist.Add(new dbparam("@browser", new information().browser(userAgent)));
            dbparamlist.Add(new dbparam("@stdate", stdate));
            dbparamlist.Add(new dbparam("@sttime", sttime));
            dbparamlist.Add(new dbparam("@eddate", date));
            dbparamlist.Add(new dbparam("@edtime", time));
            dbparamlist.Add(new dbparam("@indate", date));
            dbparamlist.Add(new dbparam("@intime", time));
            dbparamlist.Add(new dbparam("@inoper", sRowsData.newid.TrimEnd()));
            if (database.checkActiveSql("mssql", "flyformstring", "insert into web.websitelog (formId,website,externip,hostname,browser,stdate,sttime,eddate,edtime,indate,intime,inoper) values (@formId,@website,@externip,@hostname,@browser,@stdate,@sttime,@eddate,@edtime,@indate,@intime,@inoper);", dbparamlist) != "istrue")
            {
                return(new sSiteModels()
                {
                    status = "error"
                });
            }
            switch (File.Exists($"{database.connectionString("formFiles")}{original}({encryption}){extension}"))
            {
            case false:
                return(new sSiteModels()
                {
                    status = "nodata"
                });
            }
            return(new sSiteModels()
            {
                images = true, videos = false, audios = false, src = $"{original}({encryption}){extension}", imagePath = "http://221.222.222.16:4500/bugimage/", original = original, encryption = encryption, extension = extension, status = "istrue"
            });
        }
Example #2
0
        public loginModels GetLoginFormModels(userData userData, string cuurip, string userAgent)
        {
            switch (string.IsNullOrWhiteSpace(userData.userid))
            {
            case true:
                return(new loginModels()
                {
                    status = "errorFormLogin"
                });
            }
            database       database    = new database();
            DataTable      loginRows   = new DataTable();
            List <dbparam> dbparamlist = new List <dbparam>();

            dbparamlist.Add(new dbparam("@newid", userData.userid.TrimEnd()));
            dbparamlist.Add(new dbparam("@externip", cuurip));
            dbparamlist.Add(new dbparam("@status", "1"));
            loginRows = database.checkSelectSql("mssql", "epaperstring", "exec web.checkformlogin @newid,@externip,@status;", dbparamlist);
            switch (loginRows.Rows.Count)
            {
            case 0:
                return(new loginModels()
                {
                    status = "nodata"
                });
            }
            if (loginRows.Rows[0]["isused"].ToString().TrimEnd() == "1" && loginRows.Rows[0]["islogin"].ToString().TrimEnd() == "1")
            {
                datetime    datetime = new datetime();
                information information = new information();
                string      date = datetime.sqldate("mssql", "epaperstring"), time = datetime.sqltime("mssql", "epaperstring");
                dbparamlist.Add(new dbparam("@cpu", ""));
                dbparamlist.Add(new dbparam("@os", information.osystem(userAgent)));
                dbparamlist.Add(new dbparam("@internip", ""));
                dbparamlist.Add(new dbparam("@indate", date));
                dbparamlist.Add(new dbparam("@intime", time));
                switch (database.checkActiveSql("mssql", "epaperstring", "update web.sitelog set cpu = @cpu,os = @os,internip = @internip,indate = @indate,intime = @intime where newid = @newid and externip = @externip and islogin = @status;", dbparamlist))
                {
                case "istrue":
                    return(new loginModels()
                    {
                        newid = loginRows.Rows[0]["newid"].ToString().TrimEnd(), name = loginRows.Rows[0]["username"].ToString().TrimEnd().Substring(0, 1), allname = loginRows.Rows[0]["username"].ToString().TrimEnd(), status = "istrue"
                    });
                }
                return(new loginModels()
                {
                    status = "error"
                });
            }
            return(new loginModels()
            {
                status = "islock"
            });
        }
Example #3
0
        public statusModels GetInsertModels(iIconData iIconData, string cuurip)
        {
            database database = new database();
            datetime datetime = new datetime();
            string   date = datetime.sqldate("mssql", "flyformstring"), time = datetime.sqltime("mssql", "flyformstring");

            for (int i = 0; i < iIconData.items.Count; i++)
            {
                List <dbparam> dbparamlist = new List <dbparam>();
                dbparamlist.Add(new dbparam("@value", iIconData.items[i]["value"].ToString().TrimEnd()));
                switch (database.checkSelectSql("mssql", "flyformstring", "select value,icon from web.iconform where value = @value;", dbparamlist).Rows.Count)
                {
                case 0:
                    dbparamlist.Add(new dbparam("@icon", iIconData.items[i]["icon"].ToString().TrimEnd()));
                    dbparamlist.Add(new dbparam("@indate", date));
                    dbparamlist.Add(new dbparam("@intime", time));
                    dbparamlist.Add(new dbparam("@inoper", iIconData.newid.TrimEnd()));
                    if (database.checkActiveSql("mssql", "flyformstring", "insert into web.iconform (value,icon,indate,intime,inoper) values (@value,@icon,@indate,@intime,@inoper);", dbparamlist) != "istrue")
                    {
                        return(new statusModels()
                        {
                            status = "error"
                        });
                    }
                    break;
                }
            }
            for (int i = 0; i < iIconData.qaitems.Count; i++)
            {
                List <dbparam> dbparamlist = new List <dbparam>();
                dbparamlist.Add(new dbparam("@value", iIconData.qaitems[i]["value"].ToString().TrimEnd()));
                switch (database.checkSelectSql("mssql", "flyformstring", "select value,icon from web.itemform where value = @value;", dbparamlist).Rows.Count)
                {
                case 0:
                    dbparamlist.Add(new dbparam("@optionPadding", "0"));
                    dbparamlist.Add(new dbparam("@icon", iIconData.qaitems[i]["icon"].ToString().TrimEnd()));
                    dbparamlist.Add(new dbparam("@indate", date));
                    dbparamlist.Add(new dbparam("@intime", time));
                    dbparamlist.Add(new dbparam("@inoper", iIconData.newid.TrimEnd()));
                    if (database.checkActiveSql("mssql", "flyformstring", "insert into web.itemform (optionPadding,value,icon,indate,intime,inoper) values (@optionPadding,@value,@icon,@indate,@intime,@inoper);", dbparamlist) != "istrue")
                    {
                        return(new statusModels()
                        {
                            status = "error"
                        });
                    }
                    break;
                }
            }
            return(new statusModels()
            {
                status = "saveSuccess"
            });
        }
Example #4
0
        public statusModels GetDownloadModels(sRowsData sRowsData, string cuurip, string userAgent)
        {
            database database = new database();
            datetime datetime = new datetime();
            string   stdate = datetime.sqldate("mssql", "flyformstring"), sttime = datetime.sqltime("mssql", "flyformstring");

            switch (File.Exists(database.connectionString("formFiles") + sRowsData.value.TrimEnd()))
            {
            case false:
                return(new statusModels()
                {
                    status = "nodata"
                });
            }
            string         date = datetime.sqldate("mssql", "flyformstring"), time = datetime.sqltime("mssql", "flyformstring"), cuname = Dns.GetHostEntry(cuurip).HostName.IndexOf('.') == -1 ? Dns.GetHostEntry(cuurip).HostName : Dns.GetHostEntry(cuurip).HostName.Split('.')[0];
            List <dbparam> dbparamlist = new List <dbparam>();

            dbparamlist.Add(new dbparam("@formId", sRowsData.formId.TrimEnd()));
            dbparamlist.Add(new dbparam("@files", sRowsData.value.TrimEnd()));
            dbparamlist.Add(new dbparam("@externip", cuurip));
            dbparamlist.Add(new dbparam("@hostname", cuname));
            dbparamlist.Add(new dbparam("@browser", new information().browser(userAgent)));
            dbparamlist.Add(new dbparam("@stdate", stdate));
            dbparamlist.Add(new dbparam("@sttime", sttime));
            dbparamlist.Add(new dbparam("@eddate", date));
            dbparamlist.Add(new dbparam("@edtime", time));
            dbparamlist.Add(new dbparam("@indate", date));
            dbparamlist.Add(new dbparam("@intime", time));
            dbparamlist.Add(new dbparam("@inoper", sRowsData.newid.TrimEnd()));
            if (database.checkActiveSql("mssql", "flyformstring", "insert into web.downloadlog (formId,files,externip,hostname,browser,stdate,sttime,eddate,edtime,indate,intime,inoper) values (@formId,@files,@externip,@hostname,@browser,@stdate,@sttime,@eddate,@edtime,@indate,@intime,@inoper);", dbparamlist) != "istrue")
            {
                return(new statusModels()
                {
                    status = "error"
                });
            }
            return(new statusModels()
            {
                status = "istrue"
            });
        }
Example #5
0
        public sSiteModels GetWebsiteModels(sRowsData sRowsData, string cuurip, string userAgent)
        {
            database       database    = new database();
            DataTable      mainRows    = new DataTable();
            List <dbparam> dbparamlist = new List <dbparam>();

            dbparamlist.Add(new dbparam("@newid", sRowsData.newid.TrimEnd()));
            mainRows = database.checkSelectSql("mssql", "sysstring", "exec web.searchformber @newid;", dbparamlist);
            switch (mainRows.Rows.Count)
            {
            case 0:
                return(new sSiteModels()
                {
                    status = "nodata"
                });
            }
            string filePath = $"{database.connectionString("sysFiles")}{mainRows.Rows[0]["formId"].ToString().TrimEnd()}\\";

            Directory.CreateDirectory(filePath);
            datetime datetime = new datetime();
            string   stdate = datetime.sqldate("mssql", "sysstring"), sttime = datetime.sqltime("mssql", "sysstring"), cuname = Dns.GetHostEntry(cuurip).HostName.IndexOf('.') == -1 ? Dns.GetHostEntry(cuurip).HostName : Dns.GetHostEntry(cuurip).HostName.Split('.')[0], original = "", encryption = new sha256().new256("mssql", "sysstring"), extension = ".jpg";

            new WebClient().DownloadFile(sRowsData.value.TrimEnd(), $"{filePath}{original}({encryption}){extension}");
            dbparamlist.Clear();
            dbparamlist.Add(new dbparam("@formId", mainRows.Rows[0]["formId"].ToString().TrimEnd()));
            dbparamlist.Add(new dbparam("@siteId", sRowsData.formId.TrimEnd()));
            dbparamlist.Add(new dbparam("@website", sRowsData.value.TrimEnd()));
            dbparamlist.Add(new dbparam("@externip", cuurip));
            dbparamlist.Add(new dbparam("@hostname", cuname));
            dbparamlist.Add(new dbparam("@browser", new information().browser(userAgent)));
            dbparamlist.Add(new dbparam("@stdate", stdate));
            dbparamlist.Add(new dbparam("@sttime", sttime));
            dbparamlist.Add(new dbparam("@inoper", sRowsData.newid.TrimEnd()));
            if (database.checkActiveSql("mssql", "sysstring", "exec web.insertwebsiteform @formId,@siteId,@website,@externip,@hostname,@browser,@stdate,@sttime,@inoper;", dbparamlist) != "istrue")
            {
                return(new sSiteModels()
                {
                    status = "error"
                });
            }
            switch (File.Exists($"{filePath}{original}({encryption}){extension}"))
            {
            case false:
                return(new sSiteModels()
                {
                    status = "nodata"
                });
            }
            return(new sSiteModels()
            {
                images = true, videos = false, audios = false, src = $"{original}({encryption}){extension}", imagePath = $"{database.connectionString("sysHttps")}{mainRows.Rows[0]["formId"].ToString().TrimEnd()}/", original = original, encryption = encryption, extension = extension, status = "istrue"
            });
        }
Example #6
0
        public statusModels GetDownloadModels(sRowsData sRowsData, string cuurip, string userAgent)
        {
            database       database    = new database();
            DataTable      mainRows    = new DataTable();
            List <dbparam> dbparamlist = new List <dbparam>();

            dbparamlist.Add(new dbparam("@newid", sRowsData.newid.TrimEnd()));
            mainRows = database.checkSelectSql("mssql", "sysstring", "exec web.searchformber @newid;", dbparamlist);
            switch (mainRows.Rows.Count)
            {
            case 0:
                return(new statusModels()
                {
                    status = "nodata"
                });
            }
            datetime datetime = new datetime();
            string   stdate = datetime.sqldate("mssql", "sysstring"), sttime = datetime.sqltime("mssql", "sysstring");

            switch (File.Exists($"{database.connectionString("sysFiles")}{mainRows.Rows[0]["formId"].ToString().TrimEnd()}\\{sRowsData.value.TrimEnd()}"))
            {
            case false:
                return(new statusModels()
                {
                    status = "nodata"
                });
            }
            string cuname = Dns.GetHostEntry(cuurip).HostName.IndexOf('.') == -1 ? Dns.GetHostEntry(cuurip).HostName : Dns.GetHostEntry(cuurip).HostName.Split('.')[0];

            dbparamlist.Clear();
            dbparamlist.Add(new dbparam("@formId", mainRows.Rows[0]["formId"].ToString().TrimEnd()));
            dbparamlist.Add(new dbparam("@fileId", sRowsData.formId.TrimEnd()));
            dbparamlist.Add(new dbparam("@files", sRowsData.value.TrimEnd()));
            dbparamlist.Add(new dbparam("@externip", cuurip));
            dbparamlist.Add(new dbparam("@hostname", cuname));
            dbparamlist.Add(new dbparam("@browser", new information().browser(userAgent)));
            dbparamlist.Add(new dbparam("@stdate", stdate));
            dbparamlist.Add(new dbparam("@sttime", sttime));
            dbparamlist.Add(new dbparam("@inoper", sRowsData.newid.TrimEnd()));
            if (database.checkActiveSql("mssql", "sysstring", "exec web.insertdownloadform @formId,@fileId,@files,@externip,@hostname,@browser,@stdate,@sttime,@inoper;", dbparamlist) != "istrue")
            {
                return(new statusModels()
                {
                    status = "error"
                });
            }
            return(new statusModels()
            {
                status = "istrue"
            });
        }
Example #7
0
        public statusModels GetAddCordModels(otherData otherData, string cuurip)
        {
            datetime       datetime = new datetime();
            string         stdate = datetime.sqldate("mssql", "sysstring"), sttime = datetime.sqltime("mssql", "sysstring");
            List <dbparam> dbparamlist = new List <dbparam>();

            dbparamlist.Add(new dbparam("@value", otherData.values.TrimEnd()));
            dbparamlist.Add(new dbparam("@inoper", otherData.userid.TrimEnd()));
            dbparamlist.Add(new dbparam("@stdate", stdate));
            dbparamlist.Add(new dbparam("@sttime", sttime));
            if (new database().checkActiveSql("mssql", "sysstring", "exec web.insertrecordform @value,@inoper,@stdate,@sttime;", dbparamlist) != "istrue")
            {
                return(new statusModels()
                {
                    status = "error"
                });
            }
            return(new statusModels()
            {
                status = "istrue"
            });
        }
Example #8
0
        public statusModels GetCodeUserModels(otherData otherData, string cuurip)
        {
            switch (string.IsNullOrWhiteSpace(otherData.userid))
            {
            case true:
                return(new statusModels()
                {
                    status = "nousers"
                });
            }
            switch (string.IsNullOrWhiteSpace(otherData.values))
            {
            case true:
                return(new statusModels()
                {
                    status = "errorCode"
                });
            }
            DataTable      userRows    = new DataTable();
            database       database    = new database();
            List <dbparam> dbparamlist = new List <dbparam>();

            dbparamlist.Add(new dbparam("@newid", otherData.userid.TrimEnd()));
            dbparamlist.Add(new dbparam("@vecode", otherData.values.TrimEnd()));
            dbparamlist.Add(new dbparam("@status", "1"));
            userRows = database.checkSelectSql("mssql", "sysstring", "exec web.codesiteber @newid,@vecode,@status;", dbparamlist);
            switch (userRows.Rows.Count)
            {
            case 0:
                return(new statusModels()
                {
                    status = "nodata"
                });
            }
            switch (userRows.Rows[0]["isused"].ToString().TrimEnd())
            {
            case "0":
                return(new statusModels()
                {
                    status = "islock"
                });
            }
            datetime datetime = new datetime();
            string   date = datetime.sqldate("mssql", "sysstring"), time = datetime.sqltime("mssql", "sysstring");
            DateTime startdate = DateTime.Parse(date + " " + time);
            DateTime enddate   = DateTime.Parse(userRows.Rows[0]["vedate"].ToString().TrimEnd() + " " + userRows.Rows[0]["vetime"].ToString().TrimEnd()).AddMinutes(10);

            if (enddate >= startdate)
            {
                dbparamlist.Clear();
                dbparamlist.Add(new dbparam("@vedate", ""));
                dbparamlist.Add(new dbparam("@vetime", ""));
                dbparamlist.Add(new dbparam("@vecode", ""));
                dbparamlist.Add(new dbparam("@modate", date));
                dbparamlist.Add(new dbparam("@motime", time));
                dbparamlist.Add(new dbparam("@newid", otherData.userid.TrimEnd()));
                if (database.checkActiveSql("mssql", "sysstring", "update web.siteber set vedate = @vedate,vetime = @vetime,vecode = @vecode,modate = @modate,motime = @motime where newid = @newid;", dbparamlist) != "istrue")
                {
                    return(new statusModels()
                    {
                        status = "error"
                    });
                }
                return(new statusModels()
                {
                    status = "istrue"
                });
            }
            Random random = new Random();
            string vecode = random.Next(100000, 999999).ToString().TrimEnd();

            dbparamlist.Clear();
            dbparamlist.Add(new dbparam("@vedate", date));
            dbparamlist.Add(new dbparam("@vetime", time));
            dbparamlist.Add(new dbparam("@vecode", vecode));
            dbparamlist.Add(new dbparam("@modate", date));
            dbparamlist.Add(new dbparam("@motime", time));
            dbparamlist.Add(new dbparam("@newid", otherData.userid.TrimEnd()));
            if (database.checkActiveSql("mssql", "sysstring", "update web.siteber set vedate = @vedate,vetime = @vetime,vecode = @vecode,modate = @modate,motime = @motime where newid = @newid;", dbparamlist) != "istrue")
            {
                return(new statusModels()
                {
                    status = "error"
                });
            }
            return(new statusModels()
            {
                status = "resend"
            });
        }
Example #9
0
        public statusModels GetInsertModels(iFormsData iFormsData, string cuurip)
        {
            database database = new database();
            datetime datetime = new datetime();
            string   formId = new sha256().new256("mssql", "flyformstring"), date = datetime.sqldate("mssql", "flyformstring"), time = datetime.sqltime("mssql", "flyformstring");

            foreach (var item in iFormsData.items)
            {
                List <dbparam> dbparamlist = new List <dbparam>();
                dbparamlist.Add(new dbparam("@formId", formId));
                dbparamlist.Add(new dbparam("@iid", item["iid"].ToString().TrimEnd()));
                dbparamlist.Add(new dbparam("@inoper", iFormsData.newid.TrimEnd()));
                dbparamlist.Add(new dbparam("@tile", item["title"].ToString().TrimEnd()));
                dbparamlist.Add(new dbparam("@outValue", item["outValue"].ToString().TrimEnd()));
                dbparamlist.Add(new dbparam("@verified", bool.Parse(item["showVeri"].ToString().TrimEnd()) ? "1" : "0"));
                dbparamlist.Add(new dbparam("@type", item["type_"].ToString().TrimEnd()));
                dbparamlist.Add(new dbparam("@operation", item["operation"].ToString().TrimEnd()));
                dbparamlist.Add(new dbparam("@area", item["area"].ToString().TrimEnd()));
                dbparamlist.Add(new dbparam("@eror", item["eror"].ToString().TrimEnd()));
                dbparamlist.Add(new dbparam("@checked", bool.Parse(item["showCheck"].ToString().TrimEnd()) ? "1" : "0"));
                dbparamlist.Add(new dbparam("@indate", date));
                dbparamlist.Add(new dbparam("@intime", time));
                if (database.checkActiveSql("mssql", "flyformstring", "insert into web.subform (formId,iid,inoper,tile,outValue,verified,type,operation,area,eror,checked,indate,intime) values (@formId,@iid,@inoper,@tile,@outValue,@verified,@type,@operation,@area,@eror,@checked,@indate,@intime);", dbparamlist) != "istrue")
                {
                    return(new statusModels()
                    {
                        status = "error"
                    });
                }
                switch (item["outValue"].ToString().TrimEnd())
                {
                case "radio":
                case "checkbox":
                case "droplist":
                    foreach (var answeritem in JsonSerializer.Deserialize <List <Dictionary <string, object> > >(item["answeritems"].ToString().TrimEnd()))
                    {
                        switch (bool.Parse(answeritem["ansrDelete"].ToString().TrimEnd()))
                        {
                        case false:
                            dbparamlist.Clear();
                            dbparamlist.Add(new dbparam("@formId", formId));
                            dbparamlist.Add(new dbparam("@iid", item["iid"].ToString().TrimEnd()));
                            dbparamlist.Add(new dbparam("@id", answeritem["id"].ToString().TrimEnd()));
                            dbparamlist.Add(new dbparam("@inoper", iFormsData.newid.TrimEnd()));
                            dbparamlist.Add(new dbparam("@value", answeritem["value"].ToString().TrimEnd()));
                            dbparamlist.Add(new dbparam("@answer", bool.Parse(answeritem["showAnswer"].ToString().TrimEnd()) ? "1" : "0"));
                            dbparamlist.Add(new dbparam("@indate", date));
                            dbparamlist.Add(new dbparam("@intime", time));
                            if (database.checkActiveSql("mssql", "flyformstring", "insert into web.optionform (formId,iid,id,inoper,value,answer,indate,intime) values (@formId,@iid,@id,@inoper,@value,@answer,@indate,@intime);", dbparamlist) != "istrue")
                            {
                                return(new statusModels()
                                {
                                    status = "error"
                                });
                            }
                            break;
                        }
                    }
                    break;
                }
            }
            foreach (var settitem in iFormsData.settitems)
            {
                string number = settitem["number"].ToString().TrimEnd() == "" || settitem["number"].ToString().TrimEnd() == "0" ? iFormsData.items.Count.ToString().TrimEnd() : settitem["number"].ToString().TrimEnd();
                if (!bool.Parse(settitem["showExam"].ToString().TrimEnd()))
                {
                    number = iFormsData.items.Count.ToString().TrimEnd();
                }
                List <dbparam> dbparamlist = new List <dbparam>();
                dbparamlist.Add(new dbparam("@formId", formId));
                dbparamlist.Add(new dbparam("@inoper", iFormsData.newid.TrimEnd()));
                dbparamlist.Add(new dbparam("@tile", iFormsData.tile.TrimEnd()));
                dbparamlist.Add(new dbparam("@desc", iFormsData.desc.TrimEnd()));
                dbparamlist.Add(new dbparam("@stdate", settitem["stdate"].ToString().TrimEnd().Replace("-", "/")));
                dbparamlist.Add(new dbparam("@sttime", settitem["sttime"].ToString().TrimEnd().Replace("-", "/")));
                dbparamlist.Add(new dbparam("@endate", settitem["endate"].ToString().TrimEnd().Replace("-", "/")));
                dbparamlist.Add(new dbparam("@entime", settitem["entime"].ToString().TrimEnd().Replace("-", "/")));
                dbparamlist.Add(new dbparam("@examed", bool.Parse(settitem["showExam"].ToString().TrimEnd()) ? "1" : "0"));
                dbparamlist.Add(new dbparam("@restarted", bool.Parse(settitem["showRestart"].ToString().TrimEnd()) ? "1" : "0"));
                dbparamlist.Add(new dbparam("@limited", bool.Parse(settitem["showLimit"].ToString().TrimEnd()) ? "1" : "0"));
                dbparamlist.Add(new dbparam("@randopt", bool.Parse(settitem["randOption"].ToString().TrimEnd()) ? "1" : "0"));
                dbparamlist.Add(new dbparam("@randsub", bool.Parse(settitem["randSubtile"].ToString().TrimEnd()) ? "1" : "0"));
                dbparamlist.Add(new dbparam("@number", number));
                dbparamlist.Add(new dbparam("@indate", date));
                dbparamlist.Add(new dbparam("@intime", time));
                if (database.checkActiveSql("mssql", "flyformstring", "insert into web.mainform (formId,inoper,tile,[desc],stdate,sttime,endate,entime,examed,restarted,limited,randopt,randsub,number,indate,intime) values (@formId,@inoper,@tile,@desc,@stdate,@sttime,@endate,@entime,@examed,@restarted,@limited,@randopt,@randsub,@number,@indate,@intime);", dbparamlist) != "istrue")
                {
                    return(new statusModels()
                    {
                        status = "error"
                    });
                }
            }
            foreach (var dertitem in iFormsData.dertitems)
            {
                foreach (var operitem in JsonSerializer.Deserialize <List <Dictionary <string, object> > >(dertitem["operitems"].ToString().TrimEnd()))
                {
                    switch (bool.Parse(operitem["showOper"].ToString().TrimEnd()))
                    {
                    case true:
                        List <dbparam> dbparamlist = new List <dbparam>();
                        dbparamlist.Add(new dbparam("@formId", formId));
                        dbparamlist.Add(new dbparam("@inoper", iFormsData.newid.TrimEnd()));
                        dbparamlist.Add(new dbparam("@newid", operitem["newid"].ToString().TrimEnd()));
                        dbparamlist.Add(new dbparam("@indate", date));
                        dbparamlist.Add(new dbparam("@intime", time));
                        if (database.checkActiveSql("mssql", "flyformstring", "insert into web.operform (formId,inoper,newid,indate,intime) values (@formId,@inoper,@newid,@indate,@intime);", dbparamlist) != "istrue")
                        {
                            return(new statusModels()
                            {
                                status = "error"
                            });
                        }
                        break;
                    }
                }
            }
            return(new statusModels()
            {
                status = "istrue"
            });
        }
Example #10
0
        public loginModels GetLoginModels(loginData loginData, string cuurip, string userAgent)
        {
            switch (string.IsNullOrWhiteSpace(loginData.userid))
            {
            case true:
                return(new loginModels()
                {
                    status = "errorUserid"
                });
            }
            switch (string.IsNullOrWhiteSpace(loginData.password))
            {
            case true:
                return(new loginModels()
                {
                    status = "errorPassword"
                });
            }
            DataTable      userRows    = new DataTable();
            database       database    = new database();
            List <dbparam> dbparamlist = new List <dbparam>();

            dbparamlist.Add(new dbparam("@userid", loginData.userid.TrimEnd()));
            dbparamlist.Add(new dbparam("@password", new sha256().encry256(loginData.password.TrimEnd())));
            dbparamlist.Add(new dbparam("@status", "1"));
            userRows = database.checkSelectSql("mssql", "epaperstring", "exec web.loginsiteber @userid,@password,@status;", dbparamlist);
            switch (userRows.Rows.Count)
            {
            case 0:
                return(new loginModels()
                {
                    status = "nodata"
                });
            }
            datetime datetime = new datetime();
            string   newid = userRows.Rows[0]["newid"].ToString().TrimEnd(), name = userRows.Rows[0]["username"].ToString().TrimEnd(), longitude = string.IsNullOrWhiteSpace(loginData.longitude) ? "0.0" : loginData.longitude, latitude = string.IsNullOrWhiteSpace(loginData.latitude) ? "0.0" : loginData.latitude, cuname = Dns.GetHostEntry(cuurip).HostName.IndexOf('.') == -1 ? Dns.GetHostEntry(cuurip).HostName : Dns.GetHostEntry(cuurip).HostName.Split('.')[0], date = datetime.sqldate("mssql", "epaperstring"), time = datetime.sqltime("mssql", "epaperstring");

            switch (userRows.Rows[0]["isused"].ToString().TrimEnd())
            {
            case "1":
                information information = new information();
                userRows.Clear();
                dbparamlist.Add(new dbparam("@externip", cuurip));
                userRows = database.checkSelectSql("mssql", "epaperstring", "exec web.checksitelog @userid,@password,@externip,@status;", dbparamlist);
                switch (userRows.Rows.Count)
                {
                case 0:
                    dbparamlist.Clear();
                    dbparamlist.Add(new dbparam("@newid", newid));
                    dbparamlist.Add(new dbparam("@externip", cuurip));
                    dbparamlist.Add(new dbparam("@longitude", longitude));
                    dbparamlist.Add(new dbparam("@latitude", latitude));
                    dbparamlist.Add(new dbparam("@hostname", cuname));
                    dbparamlist.Add(new dbparam("@browser", information.browser(userAgent)));
                    dbparamlist.Add(new dbparam("@os", information.osystem(userAgent)));
                    dbparamlist.Add(new dbparam("@indate", date));
                    dbparamlist.Add(new dbparam("@intime", time));
                    dbparamlist.Add(new dbparam("@islogin", "1"));
                    if (database.checkActiveSql("mssql", "epaperstring", "insert into web.sitelog (newid,externip,longitude,latitude,hostname,browser,os,indate,intime,islogin) values (@newid,@externip,@longitude,@latitude,@hostname,@browser,@os,@indate,@intime,@islogin);", dbparamlist) != "istrue")
                    {
                        return(new loginModels()
                        {
                            status = "error"
                        });
                    }
                    return(new loginModels()
                    {
                        newid = newid, name = name.Substring(0, 1), allname = name, status = "istrue"
                    });
                }
                if (userRows.Rows[0]["isused"].ToString().TrimEnd() == "1" && userRows.Rows[0]["islogin"].ToString().TrimEnd() == "1")
                {
                    dbparamlist.Clear();
                    dbparamlist.Add(new dbparam("@longitude", longitude));
                    dbparamlist.Add(new dbparam("@latitude", latitude));
                    dbparamlist.Add(new dbparam("@browser", information.browser(userAgent)));
                    dbparamlist.Add(new dbparam("@os", information.osystem(userAgent)));
                    dbparamlist.Add(new dbparam("@indate", date));
                    dbparamlist.Add(new dbparam("@intime", time));
                    dbparamlist.Add(new dbparam("@newid", newid));
                    dbparamlist.Add(new dbparam("@externip", cuurip));
                    dbparamlist.Add(new dbparam("@islogin", "1"));
                    if (database.checkActiveSql("mssql", "epaperstring", "update web.sitelog set longitude = @longitude,latitude = @latitude,browser = @browser,os = @os,indate = @indate,intime = @intime where newid = @newid and externip = @externip and islogin = @islogin;", dbparamlist) != "istrue")
                    {
                        return(new loginModels()
                        {
                            status = "error"
                        });
                    }
                    return(new loginModels()
                    {
                        newid = newid, name = name.Substring(0, 1), allname = name, status = "istrue"
                    });
                }
                break;
            }
            return(new loginModels()
            {
                status = "islock"
            });
        }
Example #11
0
        public statusModels GetResendUserModels(otherData otherData, string cuurip)
        {
            switch (string.IsNullOrWhiteSpace(otherData.userid))
            {
            case true:
                return(new statusModels()
                {
                    status = "nousers"
                });
            }
            switch (string.IsNullOrWhiteSpace(otherData.values))
            {
            case true:
                return(new statusModels()
                {
                    status = "errorResend"
                });
            }
            DataTable      userRows    = new DataTable();
            database       database    = new database();
            List <dbparam> dbparamlist = new List <dbparam>();

            dbparamlist.Add(new dbparam("@newid", otherData.userid.TrimEnd()));
            dbparamlist.Add(new dbparam("@status", "1"));
            userRows = database.checkSelectSql("mssql", "sysstring", "exec web.resendsiteber @newid,@status;", dbparamlist);
            switch (userRows.Rows.Count)
            {
            case 0:
                return(new statusModels()
                {
                    status = "nodata"
                });
            }
            switch (userRows.Rows[0]["isused"].ToString().TrimEnd())
            {
            case "0":
                return(new statusModels()
                {
                    status = "islock"
                });
            }
            datetime datetime = new datetime();
            string   date = datetime.sqldate("mssql", "sysstring"), time = datetime.sqltime("mssql", "sysstring");

            dbparamlist.Clear();
            dbparamlist.Add(new dbparam("@password", new sha256().encry256(otherData.values.TrimEnd())));
            dbparamlist.Add(new dbparam("@modate", date));
            dbparamlist.Add(new dbparam("@motime", time));
            dbparamlist.Add(new dbparam("@newid", otherData.userid.TrimEnd()));
            if (database.checkActiveSql("mssql", "sysstring", "update web.siteber set password = @password,modate = @modate,motime = @motime where newid = @newid;", dbparamlist) != "istrue")
            {
                return(new statusModels()
                {
                    status = "error"
                });
            }
            return(new statusModels()
            {
                status = "istrue"
            });
        }
Example #12
0
        public sFormModels GetInsertModels(iFormData iFormData, string cuurip)
        {
            database       database    = new database();
            List <dbparam> dbparamlist = new List <dbparam>();

            dbparamlist.Add(new dbparam("@formId", iFormData.formId.TrimEnd()));
            dbparamlist.Add(new dbparam("@inoper", iFormData.newid.TrimEnd()));
            switch (database.checkSelectSql("mssql", "flyformstring", "exec web.searchmaindeta @formId,@inoper;", dbparamlist).Rows.Count)
            {
            case 0:
                return(new sFormModels()
                {
                    status = "nodata"
                });
            }
            foreach (var item in iFormData.items)
            {
                switch (bool.Parse(item["showCheck"].ToString().TrimEnd()))
                {
                case true:
                    switch (item["outValue"].ToString().TrimEnd())
                    {
                    case "radio":
                    case "checkbox":
                        bool showAnswer = false;
                        foreach (var answeritem in JsonSerializer.Deserialize <List <Dictionary <string, object> > >(item["answeritems"].ToString().TrimEnd()))
                        {
                            if (bool.Parse(answeritem["showAnswer"].ToString().TrimEnd()))
                            {
                                showAnswer = true;
                            }
                        }
                        switch (showAnswer)
                        {
                        case false:
                            return(new sFormModels()
                            {
                                status = $"{item["title"].ToString().TrimEnd()} is not choose"
                            });
                        }
                        break;

                    case "image":
                        switch (item["value"].ToString().TrimEnd())
                        {
                        case "":
                            return(new sFormModels()
                            {
                                status = $"{item["title"].ToString().TrimEnd()} is not upload"
                            });
                        }
                        break;

                    default:
                        switch (item["value"].ToString().TrimEnd())
                        {
                        case "":
                            return(new sFormModels()
                            {
                                status = $"{item["title"].ToString().TrimEnd()} is not write"
                            });
                        }
                        break;
                    }
                    break;
                }
            }
            if (database.checkActiveSql("mssql", "flyformstring", "exec web.deletesuboption @formId,@inoper;", dbparamlist) != "istrue")
            {
                return(new sFormModels()
                {
                    status = "error"
                });
            }
            datetime datetime = new datetime();
            double   total = 0, right = 0;
            string   date = datetime.sqldate("mssql", "flyformstring"), time = datetime.sqltime("mssql", "flyformstring");

            foreach (var item in iFormData.items)
            {
                dbparamlist.Clear();
                dbparamlist.Add(new dbparam("@formId", iFormData.formId.TrimEnd()));
                dbparamlist.Add(new dbparam("@iid", int.Parse(item["iid"].ToString().TrimEnd())));
                dbparamlist.Add(new dbparam("@inoper", iFormData.newid.TrimEnd()));
                dbparamlist.Add(new dbparam("@value", item["value"].ToString().TrimEnd()));
                dbparamlist.Add(new dbparam("@indate", date));
                dbparamlist.Add(new dbparam("@intime", time));
                if (database.checkActiveSql("mssql", "flyformstring", "insert into web.sillform (formId,iid,inoper,value,indate,intime) values (@formId,@iid,@inoper,@value,@indate,@intime);", dbparamlist) != "istrue")
                {
                    return(new sFormModels()
                    {
                        status = "error"
                    });
                }
                switch (item["outValue"].ToString().TrimEnd())
                {
                case "radio":
                case "checkbox":
                    bool showRight = true;
                    foreach (var answeritem in JsonSerializer.Deserialize <List <Dictionary <string, object> > >(item["answeritems"].ToString().TrimEnd()))
                    {
                        dbparamlist.Clear();
                        dbparamlist.Add(new dbparam("@formId", iFormData.formId.TrimEnd()));
                        dbparamlist.Add(new dbparam("@iid", int.Parse(item["iid"].ToString().TrimEnd())));
                        dbparamlist.Add(new dbparam("@id", int.Parse(answeritem["id"].ToString().TrimEnd())));
                        bool answer = database.checkSelectSql("mssql", "flyformstring", "exec web.searchoptioninfo @formId,@iid,@id;", dbparamlist).Rows[0]["answer"].ToString().TrimEnd() == "1";
                        dbparamlist.Add(new dbparam("@inoper", iFormData.newid.TrimEnd()));
                        dbparamlist.Add(new dbparam("@answer", bool.Parse(answeritem["showAnswer"].ToString().TrimEnd()) ? "1" : "0"));
                        dbparamlist.Add(new dbparam("@right", bool.Parse(answeritem["showAnswer"].ToString().TrimEnd()) == answer ? "1" : "0"));
                        dbparamlist.Add(new dbparam("@indate", date));
                        dbparamlist.Add(new dbparam("@intime", time));
                        if (database.checkActiveSql("mssql", "flyformstring", "insert into web.oillform (formId,iid,id,inoper,answer,[right],indate,intime) values (@formId,@iid,@id,@inoper,@answer,@right,@indate,@intime);", dbparamlist) != "istrue")
                        {
                            return(new sFormModels()
                            {
                                status = "error"
                            });
                        }
                        if (bool.Parse(answeritem["showAnswer"].ToString().TrimEnd()) != answer)
                        {
                            showRight = false;
                        }
                    }
                    if (showRight)
                    {
                        right++;
                    }
                    total++;
                    break;
                }
            }
            dbparamlist.Clear();
            dbparamlist.Add(new dbparam("@formId", iFormData.formId.TrimEnd()));
            dbparamlist.Add(new dbparam("@score", total == 0 ? 100 : Math.Round((right / total) * 100, 1)));
            dbparamlist.Add(new dbparam("@inoper", iFormData.newid.TrimEnd()));
            if (database.checkActiveSql("mssql", "flyformstring", "exec web.searchmaininfo @formId,@score,@inoper;", dbparamlist) != "istrue")
            {
                return(new sFormModels()
                {
                    status = "error"
                });
            }
            dbparamlist.Clear();
            DataTable mainRows = new DataTable();

            dbparamlist.Add(new dbparam("@formId", iFormData.formId.TrimEnd()));
            dbparamlist.Add(new dbparam("@inoper", iFormData.newid.TrimEnd()));
            mainRows = database.checkSelectSql("mssql", "flyformstring", "exec web.searchmaindeta @formId,@inoper;", dbparamlist);
            switch (mainRows.Rows.Count)
            {
            case 0:
                return(new sFormModels()
                {
                    status = "nodata"
                });
            }
            int i = 1;

            dbparamlist.Add(new dbparam("@random", mainRows.Rows[0]["randsub"].ToString().TrimEnd()));
            dbparamlist.Add(new dbparam("@number", mainRows.Rows[0]["number"].ToString().TrimEnd()));
            dbparamlist.Add(new dbparam("@finish", mainRows.Rows[0]["finish"].ToString().TrimEnd()));
            List <Dictionary <string, object> > items = new List <Dictionary <string, object> >();

            foreach (DataRow dr in database.checkSelectSql("mssql", "flyformstring", "exec web.searchsubdeta @formId,@inoper,@random,@number,@finish;", dbparamlist).Rows)
            {
                bool answer = true;
                dbparamlist.Clear();
                dbparamlist.Add(new dbparam("@formId", iFormData.formId.TrimEnd()));
                dbparamlist.Add(new dbparam("@iid", int.Parse(dr["iid"].ToString().TrimEnd())));
                dbparamlist.Add(new dbparam("@inoper", iFormData.newid.TrimEnd()));
                dbparamlist.Add(new dbparam("@random", mainRows.Rows[0]["randopt"].ToString().TrimEnd()));
                List <Dictionary <string, object> > answeritems = new List <Dictionary <string, object> >();
                foreach (DataRow drs in database.checkSelectSql("mssql", "flyformstring", "exec web.searchoptiondeta @formId,@iid,@inoper,@random;", dbparamlist).Rows)
                {
                    if (drs["answer"].ToString().TrimEnd() != drs["right"].ToString().TrimEnd())
                    {
                        answer = false;
                    }
                    answeritems.Add(new Dictionary <string, object>()
                    {
                        { "id", drs["id"].ToString().TrimEnd() }, { "values", drs["value"].ToString().TrimEnd() }, { "showAnswer", drs["answer"].ToString().TrimEnd() == "1" }, { "showRight", drs["right"].ToString().TrimEnd() == "1" }
                    });
                }
                items.Add(new Dictionary <string, object>()
                {
                    { "iid", dr["iid"].ToString().TrimEnd() }, { "title", $"{i}.{dr["tile"].ToString().TrimEnd()}" }, { "showVeri", dr["verified"].ToString().TrimEnd() == "1" }, { "showDrop", false }, { "showFile", false }, { "outValue", dr["outValue"].ToString().TrimEnd() }, { "value", dr["value"].ToString().TrimEnd() }, { "showMenu", false }, { "type_", dr["type"].ToString().TrimEnd() }, { "operation", dr["operation"].ToString().TrimEnd() }, { "area", dr["area"].ToString().TrimEnd() }, { "eror", dr["eror"].ToString().TrimEnd() }, { "answer", answer }, { "showCheck", dr["checked"].ToString().TrimEnd() == "1" }, { "answeritems", answeritems.ToArray() }
                });
                i++;
            }
            return(new sFormModels()
            {
                formId = mainRows.Rows[0]["formId"].ToString().TrimEnd(), tile = mainRows.Rows[0]["tile"].ToString().TrimEnd(), desc = mainRows.Rows[0]["desc"].ToString().TrimEnd(), exam = mainRows.Rows[0]["examed"].ToString().TrimEnd() == "1", restart = mainRows.Rows[0]["restarted"].ToString().TrimEnd() == "1", finish = mainRows.Rows[0]["finish"].ToString().TrimEnd() == "1", score = $"{mainRows.Rows[0]["score"].ToString().TrimEnd()}分", items = items, status = "istrue"
            });
        }
Example #13
0
        public ActionResult exampleData(string newid)
        {
            string         filename = "", clientip = Request.HttpContext.Connection.RemoteIpAddress.ToString().TrimEnd() == "::1" ? "127.0.0.1" : Request.HttpContext.Connection.RemoteIpAddress.ToString().TrimEnd();
            XSSFWorkbook   workbook    = new XSSFWorkbook();
            XSSFSheet      sheet       = (XSSFSheet)workbook.CreateSheet("Information");
            XSSFRow        row         = (XSSFRow)sheet.CreateRow(0);
            database       database    = new database();
            DataTable      mainRows    = new DataTable();
            List <dbparam> dbparamlist = new List <dbparam>();

            dbparamlist.Add(new dbparam("@newid", newid));
            mainRows = database.checkSelectSql("mssql", "epaperstring", "exec web.checksitename @newid;", dbparamlist);
            switch (mainRows.Rows.Count)
            {
            case 0:
                row.CreateCell(0).SetCellValue("NOT YOUR INFORMATION ABOUT THIS FORM DATABASE");
                filename = "沒資料呈現";
                break;

            default:
                datetime      datetime = new datetime();
                string        stdate = datetime.sqldate("mssql", "epaperstring"), sttime = datetime.sqltime("mssql", "epaperstring");
                XSSFCellStyle xs = (XSSFCellStyle)workbook.CreateCellStyle();
                xs.Alignment = HorizontalAlignment.Center;
                row.CreateCell(0).SetCellValue("表單上傳範例");
                sheet.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(0, 0, 0, 19));
                row.GetCell(0).CellStyle = xs;
                row = (XSSFRow)sheet.CreateRow(1);
                row.CreateCell(0).SetCellValue("表單代碼");
                row.CreateCell(1).SetCellValue("57ae8a28-5b48-4e61-97af-e50431a9c65b");
                row.CreateCell(2).SetCellValue("表單題目");
                row.CreateCell(3).SetCellValue("測試表單");
                row.CreateCell(4).SetCellValue("表單備註");
                row.CreateCell(5).SetCellValue("測試備註");
                row = (XSSFRow)sheet.CreateRow(2);
                row.CreateCell(0).SetCellValue("開始日期");
                row.CreateCell(1).SetCellValue("2020/09/08");
                row.CreateCell(2).SetCellValue("開始時間");
                row.CreateCell(3).SetCellValue("11:17");
                row.CreateCell(4).SetCellValue("截止日期");
                row.CreateCell(5).SetCellValue("2020/09/08");
                row.CreateCell(6).SetCellValue("截止時間");
                row.CreateCell(7).SetCellValue("12:00");
                row.CreateCell(8).SetCellValue("是否考試?(0:否 ,1:是)");
                row.CreateCell(9).SetCellValue("1");
                row.CreateCell(10).SetCellValue("重新開始?(0:否 ,1:是)");
                row.CreateCell(11).SetCellValue("1");
                row.CreateCell(12).SetCellValue("限制人員?(0:否 ,1:是)");
                row.CreateCell(13).SetCellValue("1");
                row.CreateCell(14).SetCellValue("選項隨機?(0:否 ,1:是)");
                row.CreateCell(15).SetCellValue("1");
                row.CreateCell(16).SetCellValue("題目隨機?(0:否 ,1:是)");
                row.CreateCell(17).SetCellValue("1");
                row.CreateCell(18).SetCellValue("顯示題數(若要全數,請輸入0或空白)");
                row.CreateCell(19).SetCellValue("0");
                row = (XSSFRow)sheet.CreateRow(4);
                row.CreateCell(0).SetCellValue("題目編號");
                row.CreateCell(1).SetCellValue("選項編號");
                row.CreateCell(2).SetCellValue("題目 / 選項內容");
                row.CreateCell(3).SetCellValue("類型(radio:單選 / checkbox:複選 / text:短句 / textarea:長句 / image:圖片)");
                row.CreateCell(4).SetCellValue("是否需要檢查(0:不需要 / 1:需要)");
                row.CreateCell(5).SetCellValue("是否為答案(0:否 / 1:是)");
                row = (XSSFRow)sheet.CreateRow(5);
                row.CreateCell(0).SetCellValue("1");
                row.CreateCell(2).SetCellValue("測試第一題");
                row.CreateCell(3).SetCellValue("radio");
                row.CreateCell(4).SetCellValue("1");
                row = (XSSFRow)sheet.CreateRow(6);
                row.CreateCell(1).SetCellValue("1");
                row.CreateCell(2).SetCellValue("是");
                row.CreateCell(5).SetCellValue("1");
                dbparamlist.Clear();
                string date = datetime.sqldate("mssql", "epaperstring"), time = datetime.sqltime("mssql", "epaperstring"), cuname = Dns.GetHostEntry(clientip).HostName.IndexOf('.') == -1 ? Dns.GetHostEntry(clientip).HostName : Dns.GetHostEntry(clientip).HostName.Split('.')[0];
                dbparamlist.Add(new dbparam("@externip", clientip));
                dbparamlist.Add(new dbparam("@hostname", cuname));
                dbparamlist.Add(new dbparam("@stdate", stdate));
                dbparamlist.Add(new dbparam("@sttime", sttime));
                dbparamlist.Add(new dbparam("@endate", date));
                dbparamlist.Add(new dbparam("@entime", time));
                dbparamlist.Add(new dbparam("@indate", date));
                dbparamlist.Add(new dbparam("@intime", time));
                dbparamlist.Add(new dbparam("@inoper", newid));
                database.checkActiveSql("mssql", "flyformstring", "insert into web.examplelog (externip,hostname,stdate,sttime,endate,entime,indate,intime,inoper) values (@externip,@hostname,@stdate,@sttime,@endate,@entime,@indate,@intime,@inoper);", dbparamlist);
                filename = $"{mainRows.Rows[0]["username"].ToString().TrimEnd()}匯入表單範本";
                break;
            }
            MemoryStream ms = new MemoryStream();

            workbook.Write(ms);
            byte[] bytes = ms.ToArray();
            return(File(bytes, "application/vnd.ms-excel", $"FLYTECH{filename}.xlsx"));
        }
Example #14
0
        public async Task <JsonResult> uploadData()
        {
            if (Request.Form.Files.Count > 0)
            {
                ISheet   sheet;
                database database = new database();
                string   original = Request.Form.Files[0].FileName.Substring(0, Request.Form.Files[0].FileName.LastIndexOf('.')), extension = Path.GetExtension(Request.Form.Files[0].FileName).ToLower();
                using (var fileStream = new FileStream(database.connectionString("formFiles") + original + extension, FileMode.Create))
                {
                    await Request.Form.Files[0].CopyToAsync(fileStream);
                    fileStream.Position = 0;
                    switch (extension)
                    {
                    case ".xls":
                        HSSFWorkbook hSSFWorkbook = new HSSFWorkbook(fileStream);
                        sheet = (XSSFSheet)hSSFWorkbook.GetSheetAt(0);
                        break;

                    case ".xlsx":
                        XSSFWorkbook xSSFWorkbook = new XSSFWorkbook(fileStream);
                        sheet = (XSSFSheet)xSSFWorkbook.GetSheetAt(0);
                        break;

                    default:
                        return(Json(new sExcelModels()
                        {
                            status = "nodata"
                        }));
                    }
                    IRow           row         = sheet.GetRow(1);
                    datetime       datetime    = new datetime();
                    List <dbparam> dbparamlist = new List <dbparam>();
                    dbparamlist.Add(new dbparam("@formId", checkNullObject(row.GetCell(1))));
                    bool   showSafe = database.checkSelectSql("mssql", "flyformstring", "exec web.checkmainformId @formId;", dbparamlist).Rows.Count > 0;
                    string formId = showSafe ? checkNullObject(row.GetCell(1)) : new sha256().new256("mssql", "flyformstring"), tile = checkNullObject(row.GetCell(3)) == "" ? "noTitle" : checkNullObject(row.GetCell(3)), desc = checkNullObject(row.GetCell(5)), date = datetime.sqldate("mssql", "flyformstring"), time = datetime.sqltime("mssql", "flyformstring");
                    switch (showSafe)
                    {
                    case true:
                        if (database.checkActiveSql("mssql", "flyformstring", "exec web.deleteformdeta @formId;", dbparamlist) != "istrue")
                        {
                            return(Json(new sExcelModels()
                            {
                                status = "error"
                            }));
                        }
                        break;
                    }
                    string iid = "";
                    int    i = 5, number = 0;
                    while (i <= sheet.LastRowNum)
                    {
                        row = sheet.GetRow(i);
                        switch (checkNullObject(row.GetCell(0)))
                        {
                        case "":
                            switch (iid)
                            {
                            case "":
                                return(Json(new sExcelModels()
                                {
                                    status = "error"
                                }));
                            }
                            if (checkNullObject(row.GetCell(1)) != "")
                            {
                                dbparamlist.Clear();
                                dbparamlist.Add(new dbparam("@formId", formId));
                                dbparamlist.Add(new dbparam("@iid", iid));
                                dbparamlist.Add(new dbparam("@id", checkNullObject(row.GetCell(1))));
                                dbparamlist.Add(new dbparam("@value", checkNullObject(row.GetCell(2))));
                                dbparamlist.Add(new dbparam("@answer", checkBoolObject(row.GetCell(5))));
                                dbparamlist.Add(new dbparam("@indate", date));
                                dbparamlist.Add(new dbparam("@intime", time));
                                if (database.checkActiveSql("mssql", "flyformstring", "insert into web.optionform (formId,iid,id,value,answer,indate,intime) values (@formId,@iid,@id,@value,@answer,@indate,@intime);", dbparamlist) != "istrue")
                                {
                                    return(Json(new sExcelModels()
                                    {
                                        status = "error"
                                    }));
                                }
                            }
                            break;

                        default:
                            iid = checkNullObject(row.GetCell(0));
                            dbparamlist.Clear();
                            dbparamlist.Add(new dbparam("@formId", formId));
                            dbparamlist.Add(new dbparam("@iid", iid));
                            dbparamlist.Add(new dbparam("@tile", checkNullObject(row.GetCell(2))));
                            dbparamlist.Add(new dbparam("@outValue", checkNullObject(row.GetCell(3))));
                            dbparamlist.Add(new dbparam("@checked", checkBoolObject(row.GetCell(4))));
                            dbparamlist.Add(new dbparam("@indate", date));
                            dbparamlist.Add(new dbparam("@intime", time));
                            if (database.checkActiveSql("mssql", "flyformstring", "insert into web.subform (formId,iid,tile,outValue,checked,indate,intime) values (@formId,@iid,@tile,@outValue,@checked,@indate,@intime);", dbparamlist) != "istrue")
                            {
                                return(Json(new sExcelModels()
                                {
                                    status = "error"
                                }));
                            }
                            number++;
                            break;
                        }
                        i++;
                    }
                    row = sheet.GetRow(2);
                    dbparamlist.Clear();
                    dbparamlist.Add(new dbparam("@formId", formId));
                    dbparamlist.Add(new dbparam("@tile", tile));
                    dbparamlist.Add(new dbparam("@desc", desc));
                    dbparamlist.Add(new dbparam("@stdate", checkNullObject(row.GetCell(1))));
                    dbparamlist.Add(new dbparam("@sttime", checkNullObject(row.GetCell(3))));
                    dbparamlist.Add(new dbparam("@endate", checkNullObject(row.GetCell(5))));
                    dbparamlist.Add(new dbparam("@entime", checkNullObject(row.GetCell(7))));
                    dbparamlist.Add(new dbparam("@examed", checkBoolObject(row.GetCell(9))));
                    dbparamlist.Add(new dbparam("@restarted", checkBoolObject(row.GetCell(11))));
                    dbparamlist.Add(new dbparam("@limited", checkBoolObject(row.GetCell(13))));
                    dbparamlist.Add(new dbparam("@randopt", checkBoolObject(row.GetCell(15))));
                    dbparamlist.Add(new dbparam("@randsub", checkBoolObject(row.GetCell(17))));
                    dbparamlist.Add(new dbparam("@number", checkNullObject(row.GetCell(19)) == "" || checkNullObject(row.GetCell(19)) == "0" ? number.ToString().TrimEnd() : checkNullObject(row.GetCell(19))));
                    dbparamlist.Add(new dbparam("@indate", date));
                    dbparamlist.Add(new dbparam("@intime", time));
                    if (database.checkActiveSql("mssql", "flyformstring", "insert into web.mainform (formId,tile,[desc],stdate,sttime,endate,entime,examed,restarted,limited,randopt,randsub,number,indate,intime) values (@formId,@tile,@desc,@stdate,@sttime,@endate,@entime,@examed,@restarted,@limited,@randopt,@randsub,@number,@indate,@intime);", dbparamlist) != "istrue")
                    {
                        return(Json(new sExcelModels()
                        {
                            status = "error"
                        }));
                    }
                    return(Json(new sExcelModels()
                    {
                        formId = formId, status = "istrue"
                    }));
                }
            }
            return(Json(new sExcelModels()
            {
                status = "nodata"
            }));
        }
Example #15
0
        public statusModels GetInsertModels(uFormsData uFormsData, string cuurip)
        {
            database       database    = new database();
            DataTable      mainRows    = new DataTable();
            List <dbparam> dbparamlist = new List <dbparam>();

            dbparamlist.Add(new dbparam("@formId", uFormsData.formId.TrimEnd()));
            dbparamlist.Add(new dbparam("@inoper", uFormsData.newid.TrimEnd()));
            mainRows = database.checkSelectSql("mssql", "flyformstring", "exec web.searchclimainform @formId,@inoper;", dbparamlist);
            switch (mainRows.Rows.Count)
            {
            case 0:
                return(new statusModels()
                {
                    status = "nodata"
                });
            }
            datetime datetime = new datetime();
            string   date = datetime.sqldate("mssql", "flyformstring"), time = datetime.sqltime("mssql", "flyformstring");

            foreach (var item in uFormsData.items)
            {
                switch (bool.Parse(item["formCreate"].ToString().TrimEnd()))
                {
                case true:
                    dbparamlist.Clear();
                    dbparamlist.Add(new dbparam("@formId", uFormsData.formId.TrimEnd()));
                    dbparamlist.Add(new dbparam("@iid", int.Parse(item["iid"].ToString().TrimEnd())));
                    dbparamlist.Add(new dbparam("@inoper", uFormsData.newid.TrimEnd()));
                    dbparamlist.Add(new dbparam("@tile", item["title"].ToString().TrimEnd()));
                    dbparamlist.Add(new dbparam("@outValue", item["outValue"].ToString().TrimEnd()));
                    dbparamlist.Add(new dbparam("@verified", bool.Parse(item["showVeri"].ToString().TrimEnd()) ? "1" : "0"));
                    dbparamlist.Add(new dbparam("@type", item["type_"].ToString().TrimEnd()));
                    dbparamlist.Add(new dbparam("@operation", item["operation"].ToString().TrimEnd()));
                    dbparamlist.Add(new dbparam("@area", item["area"].ToString().TrimEnd()));
                    dbparamlist.Add(new dbparam("@eror", item["eror"].ToString().TrimEnd()));
                    dbparamlist.Add(new dbparam("@checked", bool.Parse(item["showCheck"].ToString().TrimEnd()) ? "1" : "0"));
                    dbparamlist.Add(new dbparam("@indate", date));
                    dbparamlist.Add(new dbparam("@intime", time));
                    if (database.checkActiveSql("mssql", "flyformstring", "insert into web.subform (formId,iid,inoper,tile,outValue,verified,type,operation,area,eror,checked,indate,intime) values (@formId,@iid,@inoper,@tile,@outValue,@verified,@type,@operation,@area,@eror,@checked,@indate,@intime);", dbparamlist) != "istrue")
                    {
                        return(new statusModels()
                        {
                            status = "error"
                        });
                    }
                    break;

                default:
                    switch (bool.Parse(item["formDelete"].ToString().TrimEnd()))
                    {
                    case true:
                        dbparamlist.Clear();
                        dbparamlist.Add(new dbparam("@formId", uFormsData.formId.TrimEnd()));
                        dbparamlist.Add(new dbparam("@iid", int.Parse(item["iid"].ToString().TrimEnd())));
                        dbparamlist.Add(new dbparam("@inoper", uFormsData.newid.TrimEnd()));
                        if (database.checkActiveSql("mssql", "flyformstring", "exec web.deletesubdata @formId,@iid,@inoper;", dbparamlist) != "istrue")
                        {
                            return(new statusModels()
                            {
                                status = "error"
                            });
                        }
                        break;

                    default:
                        switch (bool.Parse(item["formModify"].ToString().TrimEnd()))
                        {
                        case true:
                            dbparamlist.Clear();
                            dbparamlist.Add(new dbparam("@tile", item["title"].ToString().TrimEnd()));
                            dbparamlist.Add(new dbparam("@outValue", item["outValue"].ToString().TrimEnd()));
                            dbparamlist.Add(new dbparam("@verified", bool.Parse(item["showVeri"].ToString().TrimEnd()) ? "1" : "0"));
                            dbparamlist.Add(new dbparam("@type", item["type_"].ToString().TrimEnd()));
                            dbparamlist.Add(new dbparam("@operation", item["operation"].ToString().TrimEnd()));
                            dbparamlist.Add(new dbparam("@area", item["area"].ToString().TrimEnd()));
                            dbparamlist.Add(new dbparam("@eror", item["eror"].ToString().TrimEnd()));
                            dbparamlist.Add(new dbparam("@checked", bool.Parse(item["showCheck"].ToString().TrimEnd()) ? "1" : "0"));
                            dbparamlist.Add(new dbparam("@modate", date));
                            dbparamlist.Add(new dbparam("@motime", time));
                            dbparamlist.Add(new dbparam("@mooper", uFormsData.newid.TrimEnd()));
                            dbparamlist.Add(new dbparam("@formId", uFormsData.formId.TrimEnd()));
                            dbparamlist.Add(new dbparam("@iid", int.Parse(item["iid"].ToString().TrimEnd())));
                            dbparamlist.Add(new dbparam("@inoper", uFormsData.newid.TrimEnd()));
                            if (database.checkActiveSql("mssql", "flyformstring", "update web.subform set tile = @tile,outValue = @outValue,verified = @verified,type = @type,operation = @operation,area = @area,eror = @eror,checked = @checked,modate = @modate,motime = @motime,mooper = @mooper where formId = @formId and iid = @iid and inoper = @inoper;", dbparamlist) != "istrue")
                            {
                                return(new statusModels()
                                {
                                    status = "error"
                                });
                            }
                            break;
                        }
                        break;
                    }
                    break;
                }
                switch (bool.Parse(item["formDelete"].ToString().TrimEnd()))
                {
                case false:
                    switch (item["outValue"].ToString().TrimEnd())
                    {
                    case "radio":
                    case "checkbox":
                    case "droplist":
                        foreach (var answeritem in JsonSerializer.Deserialize <List <Dictionary <string, object> > >(item["answeritems"].ToString().TrimEnd()))
                        {
                            switch (bool.Parse(answeritem["ansrDelete"].ToString().TrimEnd()))
                            {
                            case true:
                                dbparamlist.Clear();
                                dbparamlist.Add(new dbparam("@formId", uFormsData.formId.TrimEnd()));
                                dbparamlist.Add(new dbparam("@iid", item["iid"].ToString().TrimEnd()));
                                dbparamlist.Add(new dbparam("@id", answeritem["id"].ToString().TrimEnd()));
                                dbparamlist.Add(new dbparam("@inoper", uFormsData.newid.TrimEnd()));
                                if (database.checkActiveSql("mssql", "flyformstring", "delete from web.optionform where formId = @formId and iid = @iid and id = @id and inoper = @inoper;", dbparamlist) != "istrue")
                                {
                                    return(new statusModels()
                                    {
                                        status = "error"
                                    });
                                }
                                break;

                            default:
                                switch (bool.Parse(answeritem["ansrCreate"].ToString().TrimEnd()))
                                {
                                case true:
                                    dbparamlist.Clear();
                                    dbparamlist.Add(new dbparam("@formId", uFormsData.formId.TrimEnd()));
                                    dbparamlist.Add(new dbparam("@iid", item["iid"].ToString().TrimEnd()));
                                    dbparamlist.Add(new dbparam("@id", answeritem["id"].ToString().TrimEnd()));
                                    dbparamlist.Add(new dbparam("@inoper", uFormsData.newid.TrimEnd()));
                                    dbparamlist.Add(new dbparam("@value", answeritem["value"].ToString().TrimEnd()));
                                    dbparamlist.Add(new dbparam("@answer", bool.Parse(answeritem["showAnswer"].ToString().TrimEnd()) ? "1" : "0"));
                                    dbparamlist.Add(new dbparam("@indate", date));
                                    dbparamlist.Add(new dbparam("@intime", time));
                                    if (database.checkActiveSql("mssql", "flyformstring", "insert into web.optionform (formId,iid,id,inoper,value,answer,indate,intime) values (@formId,@iid,@id,@inoper,@value,@answer,@indate,@intime);", dbparamlist) != "istrue")
                                    {
                                        return(new statusModels()
                                        {
                                            status = "error"
                                        });
                                    }
                                    break;

                                default:
                                    switch (bool.Parse(answeritem["ansrModify"].ToString().TrimEnd()))
                                    {
                                    case true:
                                        dbparamlist.Clear();
                                        dbparamlist.Add(new dbparam("@value", answeritem["value"].ToString().TrimEnd()));
                                        dbparamlist.Add(new dbparam("@answer", bool.Parse(answeritem["showAnswer"].ToString().TrimEnd()) ? "1" : "0"));
                                        dbparamlist.Add(new dbparam("@modate", date));
                                        dbparamlist.Add(new dbparam("@motime", time));
                                        dbparamlist.Add(new dbparam("@mooper", uFormsData.newid.TrimEnd()));
                                        dbparamlist.Add(new dbparam("@formId", uFormsData.formId.TrimEnd()));
                                        dbparamlist.Add(new dbparam("@iid", item["iid"].ToString().TrimEnd()));
                                        dbparamlist.Add(new dbparam("@id", answeritem["id"].ToString().TrimEnd()));
                                        dbparamlist.Add(new dbparam("@inoper", uFormsData.newid.TrimEnd()));
                                        if (database.checkActiveSql("mssql", "flyformstring", "update web.optionform set value = @value,answer = @answer,modate = @modate,motime = @motime,mooper = @mooper where formId = @formId and iid = @iid and id = @id and inoper = @inoper;", dbparamlist) != "istrue")
                                        {
                                            return(new statusModels()
                                            {
                                                status = "error"
                                            });
                                        }
                                        break;
                                    }
                                    break;
                                }
                                break;
                            }
                        }
                        break;

                    default:
                        dbparamlist.Clear();
                        dbparamlist.Add(new dbparam("@formId", uFormsData.formId.TrimEnd()));
                        dbparamlist.Add(new dbparam("@iid", item["iid"].ToString().TrimEnd()));
                        dbparamlist.Add(new dbparam("@inoper", uFormsData.newid.TrimEnd()));
                        if (database.checkActiveSql("mssql", "flyformstring", "delete from web.optionform where formId = @formId and iid = @iid and inoper = @inoper;", dbparamlist) != "istrue")
                        {
                            return(new statusModels()
                            {
                                status = "error"
                            });
                        }
                        break;
                    }
                    break;
                }
            }
            foreach (var settitem in uFormsData.settitems)
            {
                string number = settitem["number"].ToString().TrimEnd();
                switch (bool.Parse(settitem["showExam"].ToString().TrimEnd()))
                {
                case false:
                    dbparamlist.Clear();
                    dbparamlist.Add(new dbparam("@formId", uFormsData.formId.TrimEnd()));
                    dbparamlist.Add(new dbparam("@inoper", uFormsData.newid.TrimEnd()));
                    number = database.checkSelectSql("mssql", "flyformstring", "exec web.countclisubform @formId,@inoper;", dbparamlist).Rows[0]["itemCount"].ToString().TrimEnd();
                    break;
                }
                dbparamlist.Clear();
                dbparamlist.Add(new dbparam("@tile", uFormsData.tile.TrimEnd()));
                dbparamlist.Add(new dbparam("@desc", uFormsData.desc.TrimEnd()));
                dbparamlist.Add(new dbparam("@stdate", settitem["stdate"].ToString().TrimEnd().Replace("-", "/")));
                dbparamlist.Add(new dbparam("@sttime", settitem["sttime"].ToString().TrimEnd().Replace("-", "/")));
                dbparamlist.Add(new dbparam("@endate", settitem["endate"].ToString().TrimEnd().Replace("-", "/")));
                dbparamlist.Add(new dbparam("@entime", settitem["entime"].ToString().TrimEnd().Replace("-", "/")));
                dbparamlist.Add(new dbparam("@examed", bool.Parse(settitem["showExam"].ToString().TrimEnd()) ? "1" : "0"));
                dbparamlist.Add(new dbparam("@restarted", bool.Parse(settitem["showRestart"].ToString().TrimEnd()) ? "1" : "0"));
                dbparamlist.Add(new dbparam("@limited", bool.Parse(settitem["showLimit"].ToString().TrimEnd()) ? "1" : "0"));
                dbparamlist.Add(new dbparam("@randopt", bool.Parse(settitem["randOption"].ToString().TrimEnd()) ? "1" : "0"));
                dbparamlist.Add(new dbparam("@randsub", bool.Parse(settitem["randSubtile"].ToString().TrimEnd()) ? "1" : "0"));
                dbparamlist.Add(new dbparam("@number", number));
                dbparamlist.Add(new dbparam("@modate", date));
                dbparamlist.Add(new dbparam("@motime", time));
                dbparamlist.Add(new dbparam("@mooper", uFormsData.newid.TrimEnd()));
                dbparamlist.Add(new dbparam("@formId", uFormsData.formId.TrimEnd()));
                dbparamlist.Add(new dbparam("@inoper", uFormsData.newid.TrimEnd()));
                if (database.checkActiveSql("mssql", "flyformstring", "update web.mainform set tile = @tile,[desc] = @desc,stdate = @stdate,sttime = @sttime,endate = @endate,entime = @entime,examed = @examed,restarted = @restarted,limited = @limited,randopt = @randopt,randsub = @randsub,number = @number,modate = @modate,motime = @motime,mooper = @mooper where formId = @formId and inoper = @inoper;", dbparamlist) != "istrue")
                {
                    return(new statusModels()
                    {
                        status = "error"
                    });
                }
            }
            foreach (var dertitem in uFormsData.dertitems)
            {
                foreach (var operitem in JsonSerializer.Deserialize <List <Dictionary <string, object> > >(dertitem["operitems"].ToString().TrimEnd()))
                {
                    switch (bool.Parse(operitem["showOper"].ToString().TrimEnd()))
                    {
                    case true:
                        dbparamlist.Clear();
                        dbparamlist.Add(new dbparam("@formId", uFormsData.formId.TrimEnd()));
                        dbparamlist.Add(new dbparam("@inoper", uFormsData.newid.TrimEnd()));
                        dbparamlist.Add(new dbparam("@newid", operitem["newid"].ToString().TrimEnd()));
                        switch (database.checkSelectSql("mssql", "flyformstring", "exec web.searchoperform @formId,@inoper,@newid;", dbparamlist).Rows.Count)
                        {
                        case 0:
                            dbparamlist.Add(new dbparam("@indate", date));
                            dbparamlist.Add(new dbparam("@intime", time));
                            if (database.checkActiveSql("mssql", "flyformstring", "insert into web.operform (formId,inoper,newid,indate,intime) values (@formId,@inoper,@newid,@indate,@intime);", dbparamlist) != "istrue")
                            {
                                return(new statusModels()
                                {
                                    status = "error"
                                });
                            }
                            break;
                        }
                        break;

                    default:
                        dbparamlist.Clear();
                        dbparamlist.Add(new dbparam("@formId", uFormsData.formId.TrimEnd()));
                        dbparamlist.Add(new dbparam("@inoper", uFormsData.newid.TrimEnd()));
                        dbparamlist.Add(new dbparam("@newid", operitem["newid"].ToString().TrimEnd()));
                        if (database.checkActiveSql("mssql", "flyformstring", "delete from web.operform where formId = @formId and inoper = @inoper and newid = @newid;", dbparamlist) != "istrue")
                        {
                            return(new statusModels()
                            {
                                status = "error"
                            });
                        }
                        break;
                    }
                }
            }
            return(new statusModels()
            {
                status = "istrue"
            });
        }
Example #16
0
        public statusModels GetForgetUserModels(otherData otherData, string cuurip)
        {
            switch (string.IsNullOrWhiteSpace(otherData.userid))
            {
            case true:
                return(new statusModels()
                {
                    status = "nousers"
                });
            }
            switch (string.IsNullOrWhiteSpace(otherData.values))
            {
            case true:
                return(new statusModels()
                {
                    status = "errorForget"
                });
            }
            DataTable      userRows    = new DataTable();
            database       database    = new database();
            List <dbparam> dbparamlist = new List <dbparam>();

            dbparamlist.Add(new dbparam("@newid", otherData.userid.TrimEnd()));
            dbparamlist.Add(new dbparam("@birthday", otherData.values.TrimEnd()));
            dbparamlist.Add(new dbparam("@status", "1"));
            userRows = database.checkSelectSql("mssql", "epaperstring", "exec web.forgetsiteber @newid,@birthday,@status;", dbparamlist);
            switch (userRows.Rows.Count)
            {
            case 0:
                return(new statusModels()
                {
                    status = "nodata"
                });
            }
            switch (userRows.Rows[0]["isused"].ToString().TrimEnd())
            {
            case "0":
                return(new statusModels()
                {
                    status = "islock"
                });
            }
            Random   random = new Random();
            datetime datetime = new datetime();
            string   vecode = random.Next(100000, 999999).ToString().TrimEnd(), date = datetime.sqldate("mssql", "epaperstring"), time = datetime.sqltime("mssql", "epaperstring");

            dbparamlist.Clear();
            dbparamlist.Add(new dbparam("@vedate", date));
            dbparamlist.Add(new dbparam("@vetime", time));
            dbparamlist.Add(new dbparam("@vecode", vecode));
            dbparamlist.Add(new dbparam("@modate", date));
            dbparamlist.Add(new dbparam("@motime", time));
            dbparamlist.Add(new dbparam("@newid", otherData.userid.TrimEnd()));
            if (database.checkActiveSql("mssql", "epaperstring", "update web.siteber set vedate = @vedate,vetime = @vetime,vecode = @vecode,modate = @modate,motime = @motime where newid = @newid;", dbparamlist) != "istrue")
            {
                return(new statusModels()
                {
                    status = "error"
                });
            }
            return(new statusModels()
            {
                status = "istrue"
            });
        }