Пример #1
0
        public void UplaodCrashAcra()
        {
            if (Request.HttpMethod == "POST")
            {
                string       file_path       = ConfigurationManager.AppSettings["APP_LOG"];
                string       file_name       = "_Crash_" + DateTime.Today.ToString("yyyy_MM_dd") + ".txt";
                string       full_error_path = string.Empty;
                FileStream   fs = null;
                StreamWriter sw = null;
                try
                {
                    full_error_path = System.Web.HttpContext.Current.Server.MapPath(file_path + file_name);

                    if (!System.IO.File.Exists(full_error_path))
                    {
                        fs = System.IO.File.Create(full_error_path);
                        fs.Close();
                    }
                    sw = System.IO.File.AppendText(full_error_path);
                    sw.WriteLine("\n***************************************\n");
                    foreach (string key in Request.Form)
                    {
                        sw.WriteLine(key + ":" + Request.Form[key]);
                    }
                }
                catch (Exception errEx)
                {
                    MobileLogger.logDefault("crash called " + errEx.Message, "crasttest");
                }
                finally
                {
                    sw.Close();
                }
            }
        }
Пример #2
0
        public string UploadPrefs()
        {
            string file_path = ConfigurationManager.AppSettings["DB_UPLOAD_URL"];

            try
            {
                if (!System.IO.Directory.Exists(file_path))
                {
                    System.IO.Directory.CreateDirectory(file_path);
                }
                HttpPostedFileBase file = Request.Files["file"];

                /*foreach (HttpPostedFile file in Request.Files)
                 * {*/
                //MobileLogger.logDefault("File length "+file.ContentLength+" name "+file.FileName, "dbuploaded");
                var fileName = Path.GetFileName(file.FileName);

                //var path = Path.Combine(file_path, fileName);
                file.SaveAs(file_path + fileName);
                //}
                return("was here");
            }
            catch (Exception errEx)
            {
                MobileLogger.logDefault("dbuploaded err " + errEx.Message, "dbuploaded");
            }

            return("false");
        }
Пример #3
0
        public string UploadCrashReports2()
        {
            // MobileLogger.logDefault("crash called", "crasttest");
            if (Request.ContentLength > 0)
            {
                string res = "";
                //var str = docbinaryarray.;
                int    strLen = Convert.ToInt32(Request.ContentLength);
                Stream stream = Request.InputStream;
                //byte[] strArr =stream.;

                //str.Read(strArr, 0, strLen);
                //for (int i = 0; i < strLen; i++)
                byte[] buf;                    // byte array

                buf = new byte[stream.Length]; //declare arraysize
                stream.Read(buf, 0, buf.Length);

                /*for (int i = 0; i < Request.ContentLength;i++ )
                 *  res += buf[i].ToString();*/
                buf = buf.Where(x => x != 0x00).ToArray(); // not sure this is OK with your requirements
                res = System.Text.Encoding.ASCII.GetString(buf).Trim();
                //res = filename;
                //MobileLogger.logDefault("crash called","crasttest");

                string       file_path       = ConfigurationManager.AppSettings["APP_LOG"];
                string       file_name       = "_Crash_" + DateTime.Today.ToString("yyyy_MM_dd") + ".txt";
                string       full_error_path = string.Empty;
                FileStream   fs = null;
                StreamWriter sw = null;
                try
                {
                    full_error_path = System.Web.HttpContext.Current.Server.MapPath(file_path + file_name);

                    if (!System.IO.File.Exists(full_error_path))
                    {
                        fs = System.IO.File.Create(full_error_path);
                        fs.Close();
                    }

                    sw = System.IO.File.AppendText(full_error_path);
                    sw.WriteLine("\n***************************************\n" + res + "\n\n");
                }
                catch (Exception errEx)
                {
                    MobileLogger.logDefault("crash called", "crasttest");
                }
                finally
                {
                    sw.Close();
                }
                return("was here");
            }
            return("false");
        }
Пример #4
0
        public string UploadCrashReports(HttpPostedFileBase filestream)
        {
            // MobileLogger.logDefault("crash called", "crasttest");
            if (filestream.ContentLength > 0)
            {
                string res = "";
                //var str = docbinaryarray.;
                int strLen = Convert.ToInt32(Request.ContentLength);
                //InputStrea
                byte[] strArr = null;
                using (var binaryReader = new BinaryReader(Request.Files[0].InputStream))
                {
                    strArr = binaryReader.ReadBytes(Request.Files[0].ContentLength);
                }

                //str.Read(strArr, 0, strLen);
                for (int i = 0; i < strLen; i++)
                {
                    res += strArr[i].ToString();
                }
                //res = filename;
                //MobileLogger.logDefault("crash called","crasttest");

                string       file_path       = ConfigurationManager.AppSettings["APP_LOG"];
                string       file_name       = "_Crash_" + DateTime.Today.ToString("yyyy_MM_dd") + ".txt";
                string       full_error_path = string.Empty;
                FileStream   fs = null;
                StreamWriter sw = null;
                try
                {
                    full_error_path = System.Web.HttpContext.Current.Server.MapPath(file_path + file_name);

                    if (!System.IO.File.Exists(full_error_path))
                    {
                        fs = System.IO.File.Create(full_error_path);
                        fs.Close();
                    }

                    sw = System.IO.File.AppendText(full_error_path);
                    sw.WriteLine("\n***************************************\n" + res + "\n\n");
                }
                catch (Exception errEx)
                {
                    MobileLogger.logDefault("crash called", "crasttest");
                }
                finally
                {
                    sw.Close();
                }
                return("was here");
            }
            return("false");
        }
Пример #5
0
        public JsonResult Login(SEC_USERS sec_users)
        {
            //MobileLogger.logDefault( "called", "test");
            //return Request.CreateResponse(HttpStatusCode.OK, sec_users);

            bool     is_success     = false;
            string   msg            = @"";
            decimal  login_msg_type = (decimal)LOGIN_MSG_TYPE.NOTHING;
            string   down_link      = string.Empty;
            string   version_number = string.Empty;
            decimal? USER_NO        = null;
            decimal? ENTRY_USER_NO  = null;
            decimal? ZM_USER_NO     = null;
            decimal? AGENT_USER_NO  = null;
            string   SESSION_ID     = string.Empty;
            DateTime?SERVER_TIME    = null;
            decimal? LAST_PK_VAL    = null;


            string APP_VERSION = string.Empty;

            try
            {
                var gen_app_version = db.GEN_APP_VERSION.Where(a => a.IS_CURR_VER == 1).FirstOrDefault();
                if (gen_app_version != null)
                {
                    APP_VERSION = gen_app_version.APP_VERSION;
                }

                if (string.IsNullOrEmpty(sec_users.APP_VERSION) || string.IsNullOrWhiteSpace(sec_users.APP_VERSION))
                {
                    msg            = "APP VERSION is required";
                    login_msg_type = (decimal)LOGIN_MSG_TYPE.INVALID_APP_VERSION;
                    //var result = new { @SESSION_ID = "", @SERVER_TIME = "", @msg = msg };
                    //return Json(result, JsonRequestBehavior.AllowGet);
                }
                else
                {
                    if (APP_VERSION.Trim().ToUpper() != sec_users.APP_VERSION.Trim().ToUpper())
                    {
                        msg            = @"Application Version Mismatch, Please download the updated version from https://dl.dropboxusercontent.com/u/67899212/Omicon.apk";
                        login_msg_type = (decimal)LOGIN_MSG_TYPE.INVALID_APP_VERSION;
                        down_link      = gen_app_version.DOWN_LINK;
                        version_number = gen_app_version.APP_VERSION;
                        //var result = new { @SESSION_ID = "", @SERVER_TIME = "", @msg = msg };
                        //return Json(result, JsonRequestBehavior.AllowGet);
                    }
                    else
                    {
                        var res_obj = db.SEC_USERS_LOGIN(sec_users.USER_NAME, sec_users.USER_PWD, null).FirstOrDefault();

                        if (res_obj != null)
                        {
                            if (res_obj.USER_NO > 0)
                            {
                                //
                                Session["sess_sec_users"] = res_obj;
                                Session["sess_USER_NO"]   = res_obj.USER_NO;

                                USER_NO     = res_obj.USER_NO;
                                SERVER_TIME = res_obj.SERVER_TIME;

                                if (res_obj.USER_TYPE_NO == (decimal)UserType.Agents)
                                {
                                    Session["sess_entry_user_no"] = res_obj.USER_NO;
                                    Session["sess_zm_user_no"]    = res_obj.USER_PARENT_NO;
                                    Session["sess_agent_user_no"] = res_obj.USER_NO;

                                    ENTRY_USER_NO = res_obj.USER_NO;
                                    ZM_USER_NO    = res_obj.USER_PARENT_NO;
                                    AGENT_USER_NO = res_obj.USER_NO;
                                }
                                else
                                {
                                    Session["sess_entry_user_no"] = res_obj.USER_NO;
                                    Session["sess_zm_user_no"]    = res_obj.USER_NO;
                                    Session["sess_agent_user_no"] = null;

                                    ENTRY_USER_NO = res_obj.USER_NO;
                                    ZM_USER_NO    = res_obj.USER_PARENT_NO;
                                    AGENT_USER_NO = res_obj.USER_NO;
                                }

                                string sess_id      = Session.SessionID;
                                string ip_addr      = CustomValidator.GetRequestIpAddress();
                                string device_id    = CustomValidator.GetDeviceId();
                                string login_mobile = sec_users.USER_MOBILE;
                                string ws_id        = CustomValidator.GetWebServerId();
                                string app_version  = sec_users.APP_VERSION;

                                SESSION_ID = sess_id;

                                decimal LOGON_NO = db.SEC_USER_LOGONS_INSERT(res_obj.USER_NO, ip_addr, device_id, null, null, null, (decimal)ApproveType.Approved, null, null, sess_id, login_mobile, ws_id, app_version, login_mobile).First().Value;

                                Session["sess_LOGON_NO"] = LOGON_NO;

                                LAST_PK_VAL = db.TRN_OFFLINE_LAST_PK_GET(res_obj.USER_NO).FirstOrDefault();

                                is_success = true;
                                if (sec_users.USER_NAME == "testuser")
                                {
                                    MobileLogger.logDefault("found him testuser " + USER_NO + " msg " + is_success.ToString(), "test");
                                }
                                //var result = new { @SESSION_ID = sess_id, @SERVER_TIME = res_obj.SERVER_TIME, @msg = "" };
                                //return Json(result, JsonRequestBehavior.AllowGet);
                            }
                            else
                            {
                                msg            = "Invalid Username or password";
                                login_msg_type = (decimal)LOGIN_MSG_TYPE.INVALID_LOGIN;
                                //var result = new { @SESSION_ID = "", @SERVER_TIME = "", @msg = msg };
                                //return Json(result, JsonRequestBehavior.AllowGet);
                            }
                            //MobileLogger.logDefault((res_obj.USER_NO == null) ? "NULL user no in Login LN:143 WS_SEC_USERS Controller" : res_obj.USER_NO.ToString(),"username");
                        }
                        else
                        {
                            msg            = "Invalid Username or password";
                            login_msg_type = (decimal)LOGIN_MSG_TYPE.INVALID_LOGIN;
                            //var result = new { @SESSION_ID = "", @SERVER_TIME = "", @msg = msg };
                            //return Json(result, JsonRequestBehavior.AllowGet);
                        }
                    }
                }
                if (sec_users.USER_NAME == "testuser" && !is_success)
                {
                    MobileLogger.logDefault(msg, "test");
                }
                var result_object = new
                {
                    @SESSION_ID     = SESSION_ID,
                    @SERVER_TIME    = SERVER_TIME,
                    @msg            = msg,
                    @is_success     = is_success,
                    @USER_NO        = USER_NO,
                    @ENTRY_USER_NO  = ENTRY_USER_NO,
                    @ZM_USER_NO     = ZM_USER_NO,
                    @AGENT_USER_NO  = AGENT_USER_NO,
                    @login_msg_type = login_msg_type,
                    @down_link      = down_link,
                    @version_number = version_number,
                    @LAST_PK_VAL    = LAST_PK_VAL,
                };

                return(Json(result_object, JsonRequestBehavior.AllowGet));

                //return null;
            }
            catch (Exception ex)
            {
                DbErrorTracker db_error = new DbErrorTracker();
                db_error.WriteErrorLog(db_error.GetErrorMessage(ex, true), ex, sess_entry_user_name);
                return(null);
            }
        }