protected void gvSubFolder_RowUpdate(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                int         index            = e.RowIndex;
                GridViewRow row              = gvFilters.Rows[index];
                Int64       Id               = Int64.Parse(gvFilters.DataKeys[index].Value.ToString());
                TextBox     txtSubFilterName = (TextBox)row.Cells[0].FindControl("txtSubFilterName");
                if (txtSubFilterName.Text.Trim() == "")
                {
                    Master.MessageCenter.DisplayWarningMessage(GlobalStrings.GetText(@"ErrorSubFilterName"));
                    return;
                }
                Query q = new Query(SubFilter.TableSchema).Where(SubFilter.Columns.SubFilterName, txtSubFilterName.Text.Trim())
                          .AddWhere(SubFilter.Columns.FilterId, WhereComparision.EqualsTo, FilterId)
                          .AddWhere(SubFilter.Columns.SubFilterId, WhereComparision.NotEqualsTo, Id);
                if (q.GetCount() > 0)
                {
                    Master.MessageCenter.DisplayErrorMessage(FiltersStrings.GetText(@"MessageSubFiltersAlreadyExists"));
                    return;
                }

                SubFilter subFilter = SubFilter.FetchByID(Id);
                subFilter.SubFilterName = txtSubFilterName.Text.Trim();
                subFilter.Save();
                gvFilters.EditIndex = -1;

                LoadItems();
            }
            catch (Exception) { }
        }
        private void FillDdlFilter(DropDownList ddlFilter)
        {
            FilterCollection filterList = FilterCollection.FetchAll();

            ddlFilter.Items.Add(new ListItem(GlobalStrings.GetText(@"NoneForDropDowns"), "0"));
            foreach (var item in filterList)
            {
                ddlFilter.Items.Add(new ListItem(item.FilterName, item.FilterId.ToString()));
            }
        }
        public override void Post(HttpRequest Request, HttpResponse Response, params string[] PathParams)
        {
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetMaxAge(TimeSpan.Zero);

            JObject inputData = null;

            try
            {
                using (StreamReader reader = new StreamReader(Request.InputStream))
                {
                    using (JsonTextReader jsonReader = new JsonTextReader(reader))
                    {
                        inputData = JObject.Load(jsonReader);
                    }
                }
            }
            catch
            {
                RespondBadRequest(Response);
            }
            string name    = inputData.Value <string>(@"name") ?? "";
            string email   = inputData.Value <string>(@"email") ?? "";
            string phone   = inputData.Value <string>(@"phone") ?? "";
            string content = inputData.Value <string>(@"content") ?? "";

            Response.ContentType = @"application/json";

            using (StreamWriter streamWriter = new StreamWriter(Response.OutputStream))
            {
                using (JsonTextWriter jsonWriter = new JsonTextWriter(streamWriter))
                {
                    try
                    {
                        string subject = GlobalStrings.GetText("ContactUsSubject", new CultureInfo("he-IL"));
                        string body    = GlobalStrings.GetText("Email", new CultureInfo("he-IL")) + " : " + email + "<br>" +
                                         GlobalStrings.GetText("Phone", new CultureInfo("he-IL")) + " : " + phone + "<br>" +
                                         GlobalStrings.GetText("Content", new CultureInfo("he-IL")) + " : " + content + "<br>";
                        string AdminEmail   = Settings.GetSetting(Settings.Keys.ADMIN_EMAIL);
                        string fromEmail    = Settings.GetSetting(Settings.Keys.DEFAULT_EMAIL_FROM);
                        string replyToEmail = Settings.GetSetting(Settings.Keys.DEFAULT_EMAIL_REPLYTO);
                        string fromName     = Settings.GetSetting(Settings.Keys.DEFAULT_EMAIL_FROM_NAME);
                        string replyToName  = Settings.GetSetting(Settings.Keys.DEFAULT_EMAIL_REPLYTO_NAME);
                        System.Net.Mail.MailMessage message = EmailTemplateController.BuildMailMessage(
                            fromEmail, fromName, replyToEmail, replyToName,
                            AdminEmail, null, null, subject, body, null, null);
                        EmailTemplateController.Send(message, EmailLogController.EmailLogType.OnError, true);
                    }
                    catch (Exception) { }

                    jsonWriter.WriteStartObject();
                    jsonWriter.WriteEndObject();
                }
            }
        }
Exemple #4
0
 protected void Page_PreRender(object sender, EventArgs e)
 {
     if (RecoveryKey.Length == 0 || Email.Length == 0)
     {
         Page.Title = LoginPageStrings.GetText(@"ForgotPasswordPageTitle");
     }
     else
     {
         Page.Title = LoginPageStrings.GetText(@"ResetPasswordPageTitle");
     }
     Body.Attributes[@"class"] += @" " + GlobalStrings.GetText(@"direction");
 }
        protected void Page_PreRender(object sender, EventArgs e)
        {
            Page.Title = LoginPageStrings.GetText(@"PageTitle", new CultureInfo("he-IL"));
            Body.Attributes[@"class"] += @" " + GlobalStrings.GetText(@"direction", new CultureInfo("he-IL"));

            chkRememberMe.Text = string.Format(LoginPageStrings.GetText(@"RememberMe", new CultureInfo("he-IL")), AppConfig.GetInt32(@"Authentication.AuthCookieLifeInHours", 72) / 24).ToHtml();
            btnLogin.Text      = LoginPageStrings.GetHtml(@"Submit", new CultureInfo("he-IL"));

            rfvEml.ErrorMessage = LoginPageStrings.GetHtml(@"EmailRequired", new CultureInfo("he-IL"));
            revEml.ErrorMessage = LoginPageStrings.GetHtml(@"EmailRequired", new CultureInfo("he-IL"));
            rfvPwd.ErrorMessage = LoginPageStrings.GetHtml(@"PasswordRequired", new CultureInfo("he-IL"));
        }
 protected void lbDelete_Click(object sender, CommandEventArgs e)
 {
     if (e.CommandName.Equals("doDelete"))
     {
         if (Permissions.UserHasAnyPermissionIn(SessionHelper.UserId(), "sys_edit_emails"))
         {
             Int64 EmailLogId = Convert.ToInt64(e.CommandArgument);
             EmailLogController.DeleteLog(EmailLogId);
             Master.MessageCenter.DisplaySuccessMessage(EmailTemplatesStrings.GetText("MessageLogDeleted"));
         }
         else
         {
             Master.MessageCenter.DisplayWarningMessage(GlobalStrings.GetText(@"NoPermissionsForAction"));
         }
     }
 }
        protected void ExportToExcel(int limit, int offset)
        {
            EmailLogCollection coll = EmailLogController.GetLogItems(EmailLog.Columns.DeliveryDate, dg.Sql.SortDirection.DESC, limit, offset);

            System.Data.DataTable dt = new System.Data.DataTable();

            dt.Columns.Add(new System.Data.DataColumn(EmailTemplatesStrings.GetText("LogNumber"), typeof(Int64)));
            dt.Columns.Add(new System.Data.DataColumn(GlobalStrings.GetText("Date"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(GlobalStrings.GetText("Status"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(EmailTemplatesStrings.GetText("Subject"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(EmailTemplatesStrings.GetText("From"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(EmailTemplatesStrings.GetText("Recipient"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(EmailTemplatesStrings.GetText("CC"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(EmailTemplatesStrings.GetText("BCC"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(EmailTemplatesStrings.GetText("Priority"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(EmailTemplatesStrings.GetText("Content"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(EmailTemplatesStrings.GetText("Exception"), typeof(string)));

            foreach (EmailLog item in coll)
            {
                System.Data.DataRow row = dt.NewRow();
                row[0]  = item.EmailLogId;
                row[1]  = item.DeliveryDate.ToString(@"dd/MM/yyyy HH:mm:ss");
                row[2]  = GetStatus(item.Status);
                row[3]  = item.Subject;
                row[4]  = item.FromEmail + (string.IsNullOrEmpty(item.FromName) ? string.Empty : @" - " + item.FromName);
                row[5]  = item.ToList;
                row[6]  = item.CcList;
                row[7]  = item.BccList;
                row[8]  = GetMailPriority(item.MailPriority);
                row[9]  = item.Body.Replace(@"<br />", "\r\n").StripHtml();
                row[10] = item.Exception;
                dt.Rows.Add(row);
            }

            SpreadsheetWriter ex = SpreadsheetWriter.FromDataTable(dt, true, true);

            Response.Clear();
            Response.AddHeader(@"content-disposition", @"attachment;filename=EmailLogsExport_" + DateTime.UtcNow.ToString(@"yyyy_MM_dd_HH_mm_ss") + "." + ex.FileExtension);
            Response.Charset         = @"UTF-8";
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.ContentType = ex.FileContentType;
            Response.BinaryWrite(System.Text.Encoding.UTF8.GetPreamble());
            Response.Write(ex.ToString());
            Response.End();
        }
Exemple #8
0
        protected void lbDelete_Click(object sender, CommandEventArgs e)
        {
            if (e.CommandName.Equals("doDelete"))
            {
                if (Permissions.UserHasAnyPermissionIn(SessionHelper.UserId(), "sys_edit_emails"))
                {
                    Int64  EmailTemplateId = Convert.ToInt64(e.CommandArgument);
                    string Name            = EmailTemplateController.GetItemName(EmailTemplateId) ?? @"";
                    EmailTemplateController.Delete(EmailTemplateId);
                    Master.MessageCenter.DisplaySuccessMessage(string.Format(EmailTemplatesStrings.GetText("MessageTemplateDeleted"), Name.ToHtml()), true);

                    LoadItems();
                }
                else
                {
                    Master.MessageCenter.DisplayWarningMessage(GlobalStrings.GetText(@"NoPermissionsForAction"));
                }
            }
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            Pair[] items = HttpContext.Current.Items[HTTPCONTEXT_ITEMS_KEY] as Pair[];
            if (items == null)
            {
                Query qry = new Query(EmailTemplate.TableSchema)
                            .Select(EmailTemplate.Columns.EmailTemplateId)
                            .AddSelect(EmailTemplate.Columns.Name);
                using (DataReaderBase reader = qry.ExecuteReader())
                {
                    List <Pair> list = new List <Pair>();
                    while (reader.Read())
                    {
                        list.Add(new Pair(reader.GetInt32(0), reader.GetStringOrEmpty(1)));
                    }
                    HttpContext.Current.Items[HTTPCONTEXT_ITEMS_KEY] = items = list.ToArray();
                }
            }

            string[] AvailableLanguages = AppConfig.GetString(@"AvailableLanguages", @"").Split(','), langParts;
            foreach (string lang in AvailableLanguages)
            {
                langParts = lang.Split(':');
                HtmlTableRow  row   = new HtmlTableRow();
                HtmlTableCell cell1 = new HtmlTableCell();
                HtmlTableCell cell2 = new HtmlTableCell();
                DropDownList  ddl   = new DropDownList();
                cell1.InnerText = langParts[1] + @" (" + langParts[0] + @")";
                ddl.Items.Add(new ListItem(GlobalStrings.GetText(@"NoneForDropDowns"), "0"));
                foreach (Pair p in items)
                {
                    ddl.Items.Add(new ListItem(p.Second.ToString(), p.First.ToString()));
                }
                cell2.Controls.Add(ddl);
                row.Cells.Add(cell1);
                row.Cells.Add(cell2);
                tblOptions.Rows.Add(row);
                mapDdls[langParts[0]] = ddl;
            }
        }
        protected void btnImport_Click(object sender, EventArgs e)
        {
            if (CsvDataTable != null)
            {
                int count = 0;
                try
                {
                    foreach (DataRow row in CsvDataTable.Rows)
                    {
                        if (row["Comments"].ToString() == "")
                        {
                            Area area = Area.FetchByName(row["AreaName"].ToString());
                            if (area == null)
                            {
                                area          = new Area();
                                area.AreaName = row["AreaName"].ToString();
                                area.Save();
                            }
                            City city = new City();
                            city.CityName = row["CityName"].ToString();
                            city.AreaId   = area.AreaId;
                            city.Save();
                            count++;
                        }
                    }

                    lblImportResult.Text = GlobalStrings.GetText(@"MessageImportSuccess");
                }
                catch
                {
                    lblImportResult.Text = GlobalStrings.GetText(@"MessageImportFailedUnknown");
                }
                phImportResult.Visible = true;
                lblTotalImported.Text  = count.ToString();
                btnImport.Enabled      = false;
                phErrors.Visible       = false;
                phProductsList.Visible = false;
            }
        }
        protected void gvSubFolder_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                if (!e.CommandName.Equals("AddNew"))
                {
                    return;
                }

                GridViewRow row   = gvFilters.FooterRow;
                int         index = gvFilters.EditIndex;
                TextBox     txtSubFilterNameNew = (TextBox)row.Cells[0].FindControl("txtSubFilterNameNew");
                if (txtSubFilterNameNew.Text.Trim() == "")
                {
                    Master.MessageCenter.DisplayErrorMessage(GlobalStrings.GetText(@"ErrorSubFilterName"));
                    return;
                }
                Query q = new Query(SubFilter.TableSchema).Where(SubFilter.Columns.SubFilterName, txtSubFilterNameNew.Text.Trim())
                          .AddWhere(SubFilter.Columns.FilterId, WhereComparision.EqualsTo, FilterId);
                if (q.GetCount() > 0)
                {
                    Master.MessageCenter.DisplayErrorMessage(FiltersStrings.GetText(@"MessageSubFiltersAlreadyExists"));
                    return;
                }

                SubFilter subFilter = new SubFilter();
                subFilter.FilterId      = FilterId;
                subFilter.SubFilterName = txtSubFilterNameNew.Text.Trim();
                subFilter.Save();
                gvFilters.EditIndex = -1;

                // refresh the grid view data
                LoadItems();
            }
            catch (Exception) { }
        }
Exemple #12
0
        private void HandleAll(HttpRequest Request, HttpResponse Response, params string[] PathParams)
        {
            if (!Request.IsLocal)
            {
                Http.Respond404(true);
            }

            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetMaxAge(TimeSpan.Zero);

            if (PathParams[0] == @"rematch")
            {
                using (StreamWriter streamWriter = new StreamWriter(Response.OutputStream))
                {
                    using (JsonTextWriter jsonWriter = new JsonTextWriter(streamWriter))
                    {
                        jsonWriter.WriteStartObject();
                        try
                        {
                            jsonWriter.WritePropertyName(@"success");
                            jsonWriter.WriteValue(true);
                        }
                        catch (System.Exception ex)
                        {
                            jsonWriter.WritePropertyName(@"error");
                            jsonWriter.WriteValue(@"unknown");
                            jsonWriter.WritePropertyName(@"description");
                            jsonWriter.WriteValue(ex.ToString());
                        }
                        jsonWriter.WriteEndObject();
                    }
                }
            }
            else if (PathParams[0] == @"clean_tokens")
            {
                using (StreamWriter streamWriter = new StreamWriter(Response.OutputStream))
                {
                    using (JsonTextWriter jsonWriter = new JsonTextWriter(streamWriter))
                    {
                        jsonWriter.WriteStartObject();
                        try
                        {
                            AuthTokens.DeleteAllExpired();


                            jsonWriter.WritePropertyName(@"success");
                            jsonWriter.WriteValue(true);
                        }
                        catch (System.Exception ex)
                        {
                            jsonWriter.WritePropertyName(@"error");
                            jsonWriter.WriteValue(@"unknown");
                            jsonWriter.WritePropertyName(@"description");
                            jsonWriter.WriteValue(ex.ToString());
                        }
                        jsonWriter.WriteEndObject();
                    }
                }
            }
            else if (PathParams[0] == @"offer")
            {
                //using (StreamWriter streamWriter = new StreamWriter(Response.OutputStream))
                //{
                //    using (JsonTextWriter jsonWriter = new JsonTextWriter(streamWriter))
                //    {
                //        jsonWriter.WriteStartObject();
                //        try
                //        {
                //            Query qry = new Query(Bid.TableSchema);
                //            qry.Where(Bid.Columns.IsSendOffer, WhereComparision.EqualsTo, false);
                //            qry.AddWhere(Bid.Columns.EndDate, WhereComparision.LessThan, DateTime.UtcNow);

                //            BidCollection bidCollection = BidCollection.FetchByQuery(qry);


                //            Query.New<Bid>().Where(Bid.Columns.IsSendOffer, WhereComparision.EqualsTo, false)
                //                .AddWhere(Bid.Columns.EndDate, WhereComparision.LessThan, DateTime.UtcNow)
                //                .Update(Bid.Columns.IsSendOffer, true)
                //                .Execute();

                //            foreach (Bid item in bidCollection)
                //            {
                //                Query q = new Query(Offer.TableSchema);
                //                q.Where(Offer.Columns.BidId, WhereComparision.EqualsTo, item.BidId);

                //                OfferCollection offerCollection = OfferCollection.FetchByQuery(q);
                //                if (offerCollection != null && offerCollection.Count > 0)
                //                {
                //                    if (item.AppUserId != null && item.AppUserId != 0)
                //                    {
                //                        Notification.SendNotificationAppUserOffers(string.Format(Snoopi.web.Localization.PushStrings.GetText("PushOfferText"), offerCollection.Count), (Int64)item.AppUserId, item.BidId);
                //                    }
                //                    else if (item.TempAppUserId != null && item.TempAppUserId != 0)
                //                    {
                //                        Notification.SendNotificationTempUserOffers(string.Format(Snoopi.web.Localization.PushStrings.GetText("PushOfferText"), offerCollection.Count), (Int64)item.TempAppUserId, item.BidId);
                //                    }
                //                }
                //                else
                //                {
                //                    if (item.AppUserId != null && item.AppUserId != 0)
                //                    {
                //                        Notification.SendNotificationAppUserOffers(Snoopi.web.Localization.PushStrings.GetText("NoPushOfferText"), (Int64)item.AppUserId, item.BidId);
                //                        AppUserUI user = AppUserUI.GetAppUserUI((Int64)item.AppUserId);
                //                        List<BidProductUI> products = BidController.GetProductsByBid(item.BidId);
                //                        Bid b = Bid.FetchByID(item.BidId);
                //                        string subject = GlobalStrings.GetText("MailToAdmin", new CultureInfo("he-IL"));
                //                        string body = GlobalStrings.GetText("SubjectMailToAdminOffers",new CultureInfo("he-IL"));
                //                        EmailMessagingService.SendMailNoOffersToAdmin(user, b.StartDate, products, subject, body);
                //                    }
                //                    else if (item.TempAppUserId != null && item.TempAppUserId != 0)
                //                    {
                //                        Notification.SendNotificationTempUserOffers(Snoopi.web.Localization.PushStrings.GetText("NoPushOfferText"), (Int64)item.TempAppUserId, item.BidId);
                //                    }

                //                }
                //                item.IsSendOffer = true;
                //                item.Save();

                //            }
                //            jsonWriter.WritePropertyName(@"success");
                //            jsonWriter.WriteValue(true);
                //        }
                //        catch (System.Exception ex)
                //        {
                //            //RespondError(Response, HttpStatusCode.BadRequest, ex.ToString());
                //            jsonWriter.WritePropertyName(@"error");
                //            jsonWriter.WriteValue(@"unknown");
                //            jsonWriter.WritePropertyName(@"description");
                //            jsonWriter.WriteValue(ex.ToString());
                //        }
                //        jsonWriter.WriteEndObject();
                //    }
                //}
            }
            else if (PathParams[0] == @"service_offer")
            {
                using (StreamWriter streamWriter = new StreamWriter(Response.OutputStream))
                {
                    using (JsonTextWriter jsonWriter = new JsonTextWriter(streamWriter))
                    {
                        jsonWriter.WriteStartObject();
                        try
                        {
                            Query qry = new Query(BidService.TableSchema);
                            qry.Where(BidService.Columns.IsSendOffer, WhereComparision.EqualsTo, false);
                            qry.AddWhere(BidService.Columns.EndDate, WhereComparision.LessThan, DateTime.UtcNow);

                            BidServiceCollection bidCollection = BidServiceCollection.FetchByQuery(qry);
                            jsonWriter.WritePropertyName(@"qry");
                            jsonWriter.WriteValue(qry.ToString());

                            Query.New <BidService>().Where(BidService.Columns.IsSendOffer, WhereComparision.EqualsTo, false)
                            .AddWhere(BidService.Columns.EndDate, WhereComparision.LessThan, DateTime.UtcNow)
                            .Update(BidService.Columns.IsSendOffer, true)
                            .Execute();

                            foreach (BidService item in bidCollection)
                            {
                                Query q = new Query(OfferService.TableSchema);
                                q.Where(OfferService.Columns.BidId, WhereComparision.EqualsTo, item.BidId);

                                OfferServiceCollection offerCollection = OfferServiceCollection.FetchByQuery(q);
                                if (offerCollection != null && offerCollection.Count > 0)
                                {
                                    if (item.AppUserId != null && item.AppUserId != 0)
                                    {
                                        Notification.SendNotificationAppUserOffers(string.Format(Snoopi.web.Localization.PushStrings.GetText("PushOfferText"), offerCollection.Count), (Int64)item.AppUserId, item.BidId, true);
                                    }
                                    else if (item.TempAppUserId != null && item.TempAppUserId != 0)
                                    {
                                        Notification.SendNotificationTempUserOffers(string.Format(Snoopi.web.Localization.PushStrings.GetText("PushOfferText"), offerCollection.Count), (Int64)item.TempAppUserId, item.BidId, true);
                                    }
                                }
                                else
                                {
                                    if (item.AppUserId != null && item.AppUserId != 0)
                                    {
                                        Notification.SendNotificationAppUserOffers(Snoopi.web.Localization.PushStrings.GetText("NoPushOfferText"), (Int64)item.AppUserId, item.BidId, true);
                                        AppUserUI           user     = AppUserUI.GetAppUserUI((Int64)item.AppUserId);
                                        List <BidProductUI> products = BidController.GetProductsByBid(item.BidId);
                                        Bid    b       = Bid.FetchByID(item.BidId);
                                        string subject = GlobalStrings.GetText("MailToAdmin");
                                        string body    = GlobalStrings.GetText("SubjectMailToAdminOffers");
                                        EmailMessagingService.SendMailNoOffersToAdmin(user, b.StartDate, products, subject, body);
                                    }
                                    else if (item.TempAppUserId != null && item.TempAppUserId != 0)
                                    {
                                        Notification.SendNotificationTempUserOffers(Snoopi.web.Localization.PushStrings.GetText("NoPushOfferText"), (Int64)item.TempAppUserId, item.BidId, true);
                                    }
                                }
                                item.IsSendOffer = true;
                                item.Save();
                            }
                            jsonWriter.WritePropertyName(@"success");
                            jsonWriter.WriteValue(true);
                        }
                        catch (System.Exception ex)
                        {
                            //RespondError(Response, HttpStatusCode.BadRequest, ex.ToString());
                            jsonWriter.WritePropertyName(@"error");
                            jsonWriter.WriteValue(@"unknown");
                            jsonWriter.WritePropertyName(@"description");
                            jsonWriter.WriteValue(ex.ToString());
                        }
                        jsonWriter.WriteEndObject();
                    }
                }
            }
            else if (PathParams[0] == @"order_received")
            {
                using (StreamWriter streamWriter = new StreamWriter(Response.OutputStream))
                {
                    using (JsonTextWriter jsonWriter = new JsonTextWriter(streamWriter))
                    {
                        jsonWriter.WriteStartObject();
                        try
                        {
                            Query qry = new Query(Order.TableSchema);
                            qry.Where(Order.Columns.IsSendRecived, WhereComparision.EqualsTo, false);
                            qry.AddWhere(Order.Columns.ReceivedDate, WhereComparision.EqualsTo, null);
                            qry.AddWhere(Order.Columns.UserPaySupplierStatus, WhereComparision.EqualsTo, UserPaymentStatus.Payed);
                            qry.AddWhere(Order.Columns.SuppliedDate, WhereComparision.LessThanOrEqual, DateTime.UtcNow.AddHours(-24));

                            OrderCollection orderCollection = OrderCollection.FetchByQuery(qry);

                            //Query.New<Order>().Where(Order.Columns.IsSendRecived, WhereComparision.EqualsTo, false)
                            //     .AddWhere(Order.Columns.ReceivedDate, WhereComparision.EqualsTo, null)
                            //     .AddWhere(Order.Columns.CreateDate, WhereComparision.LessThanOrEqual, DateTime.UtcNow.AddHours(-24))
                            //     .Update(Order.Columns.IsSendRecived, true)
                            //     .Execute();

                            foreach (Order item in orderCollection)
                            {
                                Notification.SendNotificationAppUserReceviedOrder(Snoopi.web.Localization.PushStrings.GetText("ReceivedOrder"), (Int64)item.AppUserId, item.OrderId);
                                item.IsSendRecived = true;
                                item.Save();
                            }

                            jsonWriter.WritePropertyName(@"success");
                            jsonWriter.WriteValue(true);
                        }
                        catch (System.Exception ex)
                        {
                            //RespondError(Response, HttpStatusCode.BadRequest, ex.ToString());
                            jsonWriter.WritePropertyName(@"error");
                            jsonWriter.WriteValue(@"unknown");
                            jsonWriter.WritePropertyName(@"description");
                            jsonWriter.WriteValue(ex.ToString());
                        }
                        jsonWriter.WriteEndObject();
                    }
                }
            }
            else if (PathParams[0] == @"auto_push")
            {
                using (StreamWriter streamWriter = new StreamWriter(Response.OutputStream))
                {
                    using (JsonTextWriter jsonWriter = new JsonTextWriter(streamWriter))
                    {
                        jsonWriter.WriteStartObject();
                        try
                        {
                            var filters = NotificationGroups.GetAutoFilters();
                            foreach (var item in filters)
                            {
                                if (item.LastRun == null || item.LastRun.Value.AddDays(1) < DateTime.Now)
                                {
                                    var users = NotificationGroups.GetUsersOfAutoFilter(item);
                                    try
                                    {
                                        Task.Run(() => Snoopi.core.FcmService.SendTemplateToMany(item.Name, item.MessageTemplate, users)).Wait();
                                    }
                                    catch (Exception ex)
                                    {
                                        using (System.IO.StreamWriter sw = System.IO.File.AppendText(AppDomain.CurrentDomain.BaseDirectory + @"\Output\push-log.txt"))
                                        {
                                            sw.WriteLine(@" ------------" + DateTime.Now + "--------------------" + '\n' + "Exception  " + ex.Message + " CallStack : " + ex.StackTrace);
                                        }
                                    }
                                    item.LastRun = DateTime.Now;
                                    item.Save();
                                }
                            }

                            jsonWriter.WritePropertyName(@"success");
                            jsonWriter.WriteValue(true);
                        }
                        catch (System.Exception ex)
                        {
                            //RespondError(Response, HttpStatusCode.BadRequest, ex.ToString());
                            jsonWriter.WritePropertyName(@"error");
                            jsonWriter.WriteValue(@"unknown");
                            jsonWriter.WritePropertyName(@"description");
                            jsonWriter.WriteValue(ex.ToString());
                        }
                        jsonWriter.WriteEndObject();
                    }
                }
            }
            else if (PathParams[0] == @"rate_supplier")
            {
                using (StreamWriter streamWriter = new StreamWriter(Response.OutputStream))
                {
                    using (JsonTextWriter jsonWriter = new JsonTextWriter(streamWriter))
                    {
                        jsonWriter.WriteStartObject();
                        try
                        {
                            Query qry = new Query(Order.TableSchema);
                            qry.Where(Order.Columns.IsSendRateSupplier, WhereComparision.EqualsTo, false);
                            qry.AddWhere(Order.Columns.SuppliedDate, WhereComparision.LessThanOrEqual, DateTime.UtcNow.AddHours(-Settings.GetSettingInt32(Settings.Keys.RATE_SUPPLIER_AFTER_ORDER_HOUR, 24)));

                            OrderCollection orderCollection = OrderCollection.FetchByQuery(qry);

                            Query.New <Order>().Where(Order.Columns.IsSendRateSupplier, WhereComparision.EqualsTo, false)
                            .AddWhere(Order.Columns.SuppliedDate, WhereComparision.LessThanOrEqual, DateTime.UtcNow.AddHours(-Settings.GetSettingInt32(Settings.Keys.RATE_SUPPLIER_AFTER_ORDER_HOUR, 24)))
                            .Update(Order.Columns.IsSendRateSupplier, true)
                            .Execute();

                            foreach (Order item in orderCollection)
                            {
                                var         bid      = Bid.FetchByID(item.BidId);
                                AppSupplier supplier = AppSupplier.FetchByID(item.SupplierId);
                                Notification.SendNotificationAppUserRateSupplier(Snoopi.web.Localization.PushStrings.GetText("RateSupplier"), item.AppUserId, item.SupplierId.Value, supplier.BusinessName, item.BidId);
                                item.IsSendRateSupplier = true;
                                item.Save();
                            }

                            jsonWriter.WritePropertyName(@"success");
                            jsonWriter.WriteValue(true);
                        }
                        catch (System.Exception ex)
                        {
                            //RespondError(Response, HttpStatusCode.BadRequest, ex.ToString());
                            jsonWriter.WritePropertyName(@"error");
                            jsonWriter.WriteValue(@"unknown");
                            jsonWriter.WritePropertyName(@"description");
                            jsonWriter.WriteValue(ex.ToString());
                        }
                        jsonWriter.WriteEndObject();
                    }
                }
            }
            else if (PathParams[0] == @"test_rate_supplier")
            {
                Notification.SendNotificationAppUserRateSupplier(Snoopi.web.Localization.PushStrings.GetText("RateSupplier"), 18283, 387, "PetBool", 2345);
            }
            else
            {
                using (StreamWriter streamWriter = new StreamWriter(Response.OutputStream))
                {
                    using (JsonTextWriter jsonWriter = new JsonTextWriter(streamWriter))
                    {
                        jsonWriter.WriteStartObject();
                        jsonWriter.WritePropertyName(@"error");
                        jsonWriter.WriteValue(@"unknown");
                        jsonWriter.WriteEndObject();
                    }
                }
            }
        }
        private void ReadCSVFile(string filePath)
        {
            using (FileStream fs = new FileStream(filePath, FileMode.Open))
            {
                using (CsvReader csv = new CsvReader(fs))
                {
                    string[] _values = null;

                    CsvDataTable = new DataTable();
                    CsvDataTable.Columns.Add(new DataColumn("Line", typeof(int)));
                    CsvDataTable.Columns.Add(new DataColumn("AreaName", typeof(string)));
                    CsvDataTable.Columns.Add(new DataColumn("CityName", typeof(string)));
                    CsvDataTable.Columns.Add(new DataColumn("Comments", typeof(string)));

                    bool bErrors     = false;
                    int  line        = -1;
                    int  numToImport = 0;
                    _values = csv.ReadRow();
                    while (_values != null)
                    {
                        if (++line == 0)
                        {
                            _values = csv.ReadRow();
                            continue;
                        }

                        DataRow DR       = CsvDataTable.NewRow();
                        string  comments = "";

                        try
                        {
                            DR["Line"]     = line;
                            DR["AreaName"] = _values[2] == "" ? "" : _values[2].Trim();
                            DR["CityName"] = _values[1] == "" ? "" : _values[1].Trim();
                            if (DR["AreaName"] == null || DR["AreaName"].ToString() == "" || DR["CityName"] == null || DR["CityName"].ToString() == "")
                            {
                                if (comments != "")
                                {
                                    comments += "<br />";
                                }
                                comments += FiltersStrings.GetText(@"ReqCityAndAreaName");
                            }
                            else
                            {
                                Area f = Area.FetchByName(DR["AreaName"].ToString());
                                if (f != null)
                                {
                                    Query q = new Query(City.TableSchema);
                                    q.Where(City.Columns.CityName, DR["CityName"].ToString()).AddWhere(City.Columns.AreaId, f.AreaId);
                                    if (q.GetCount() > 0)
                                    {
                                        if (comments != "")
                                        {
                                            comments += "<br />";
                                        }
                                        comments += GlobalStrings.GetText(@"AlreadyExistsCity");
                                    }
                                }
                            }
                        }
                        catch (Exception e) { }

                        if (comments != "")
                        {
                            bErrors   = true;
                            comments += "<br />" + GlobalStrings.GetText(@"MessageWillNotImported");
                        }
                        else
                        {
                            numToImport++;
                        }

                        DR["Comments"] = comments;
                        CsvDataTable.Rows.Add(DR);

                        _values = csv.ReadRow();
                    }

                    if (bErrors)
                    {
                        lblErrors.Text = GlobalStrings.GetText(@"ImportErrorsLabel");
                    }
                    else
                    {
                        lblErrors.Text = GlobalStrings.GetText(@"ImportNoErrorsLabel");;
                    }

                    dgCity.DataSource = CsvDataTable;
                    dgCity.DataBind();
                    lblTotal.Text         = CsvDataTable.Rows.Count.ToString();
                    lblTotalToImport.Text = numToImport.ToString();
                    btnImport.Enabled     = numToImport == 0 ? false : true;
                }
            }
        }
 protected void Page_PreRender(object sender, EventArgs e)
 {
     Master.PageTitleHtml = GlobalStrings.GetText(@"ImportCityArea");
     Master.ActiveMenu    = "ImportCity";
 }
Exemple #15
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Master.PageTitle = GlobalStrings.GetText("Error404Line1");
     Master.MessageCenter.DisplayInformationMessage(GlobalStrings.GetText("Error404Line2"));
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     Master.PageTitle   = GlobalStrings.GetText(@"DefaultPageTitle");
     ltDescription.Text = GlobalStrings.GetText(@"DefaultPageBody");
 }