Exemplo n.º 1
0
 public static string GetFilters(string version, string data)
 {
     if (SiteMaster.VerifyRequest(HttpContext.Current.Session))
     {
         try
         {
             User user       = HttpContext.Current.Session[SKeys.User] as User;
             var  filterList = new
             {
                 AEList = LocationReportHandler.GetAccountExecutiveList(user),
                 BNList = LocationReportHandler.GetBrandNameList(user),
                 STList = LocationReportHandler.GetStoreList(user)
             };
             return(JsonConvert.SerializeObject(ApiResponse.Success(filterList), serializerSettings));
         }
         catch
         {
             return(JsonConvert.SerializeObject(ApiResponse.Error(ResponseType.ErrorLOCUnknown), serializerSettings));
         }
     }
     else
     {
         return(JsonConvert.SerializeObject(ApiResponse.Error(ResponseType.ErrorAuth), serializerSettings));
     }
 }
Exemplo n.º 2
0
 public static string ShowFilter(string version, string data)
 {
     if (SiteMaster.VerifyRequest(HttpContext.Current.Session))
     {
         var partner    = (HttpContext.Current.Session[SKeys.User] as User).ActivePartner;
         var locOptions = LocationReportHandler.GetOptions(partner);
         return(ApiResponse.JSONSuccess(new
         {
             Option = new
             {
                 Asn = locOptions.ShowAsn,
                 Location = locOptions.ShowLoc,
             },
             Query = new
             {
                 Bol = locOptions.ShowBol
             },
             Filter = new
             {
                 Store = locOptions.ShowStore,
                 Brand = locOptions.ShowBrand,
                 AE = locOptions.ShowAE
             }
         }));
     }
     else
     {
         return(ApiResponse.JSONError(ResponseType.ErrorAuth));
     }
 }
Exemplo n.º 3
0
        public static string GenerateReport(string version, string data)
        {
            if (SiteMaster.VerifyRequest(HttpContext.Current.Session))
            {
                var updateData = JsonConvert.DeserializeObject <ReportRequestData>(data);
                var user       = HttpContext.Current.Session[SKeys.User] as User;
                switch (updateData.RequestType)
                {
                case "ESS":
                default:
                {
                    return(JsonConvert.SerializeObject(ApiResponse.Success(SalesRequestManager.GenerateSalesReportList(user, updateData)), serializerSettings));
                }

                case "EST":
                {
                    return(JsonConvert.SerializeObject(ApiResponse.Success(SalesRequestManager.GenerateShipmentReportList(user, updateData)), serializerSettings));
                }
                }
            }
            else
            {
                return(JsonConvert.SerializeObject(ApiResponse.Error(ResponseType.ErrorAuth), serializerSettings));
            }
        }
Exemplo n.º 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     SiteMaster.SetAppID(AppID.ChangePO);
     _fetchList = (state) =>
     {
         CPODetails = JsonConvert.SerializeObject(ChangePOTracker.GetChangeList(Session[SKeys.User] as User));
     };
     Page.RegisterAsyncTask(new PageAsyncTask((sndr, args, callback, extraData) => { return(_fetchList.BeginInvoke(HttpContext.Current.Session, callback, extraData)); }, empty => { }, empty => { }, null));
 }
Exemplo n.º 5
0
        public static string GetDownloadReports(string version, string data)
        {
            if (!SiteMaster.VerifyRequest(HttpContext.Current.Session))
            {
                return(ApiResponse.JSONError(ResponseType.ErrorAuth));
            }
            var user    = HttpContext.Current.Session[SKeys.User] as User;
            var keyList = JsonConvert.DeserializeObject <List <string> >(data);

            return(ApiResponse.JSONSuccess(PdsManager.GetReportList(user, keyList)));
        }
Exemplo n.º 6
0
        public static string RemoveXref(string version, string data)
        {
            if (!SiteMaster.VerifyRequest(HttpContext.Current.Session))
            {
                return(ApiResponse.JSONError(ResponseType.ErrorAuth));
            }
            var           user       = HttpContext.Current.Session[SKeys.User] as User;
            List <string> recordKeys = JsonConvert.DeserializeObject <List <string> >(data);

            CatalogXrefManager.RemoveXref(user, recordKeys);
            return(ApiResponse.JSONSuccess());
        }
Exemplo n.º 7
0
        public static string SubmitPoList(string version, string data)
        {
            if (!SiteMaster.VerifyRequest(HttpContext.Current.Session))
            {
                return(ApiResponse.JSONError(ResponseType.ErrorAuth));
            }
            var user    = HttpContext.Current.Session[SKeys.User] as User;
            var poList  = JsonConvert.DeserializeObject <List <PoSummary> >(data);
            var keyList = PdsManager.CreateInvAsn(user, poList);

            return(ApiResponse.JSONSuccess(keyList));
        }
Exemplo n.º 8
0
        public static string VerifyPoList(string version, string data)
        {
            if (!SiteMaster.VerifyRequest(HttpContext.Current.Session))
            {
                return(ApiResponse.JSONError(ResponseType.ErrorAuth));
            }
            var user      = HttpContext.Current.Session[SKeys.User] as User;
            var poList    = JsonConvert.DeserializeObject <string>(data).Split(new[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.SQLEscape());
            var poDetails = PdsManager.VerifyPoList(user, poList);

            return(ApiResponse.JSONSuccess(poDetails));
        }
Exemplo n.º 9
0
        public static string GetSubmitStatusInv(string version, string data)
        {
            if (!SiteMaster.IsValid())
            {
                return(ApiResponse.JSONError(ResponseType.ErrorAuth));
            }

            var user    = HttpContext.Current.Session[SKeys.User] as User;
            var keyList = JsonConvert.DeserializeObject <List <string> >(data);
            var type    = IntegrationHandler.GetSubmitType(user, keyList);

            return(ApiResponse.JSONSuccess(type));
        }
Exemplo n.º 10
0
 public static string GetInvoiceCount(string version, string data)
 {
     if (SiteMaster.VerifyRequest(HttpContext.Current.Session))
     {
         var        user   = HttpContext.Current.Session[SKeys.User] as User;
         FilterInfo filter = JsonConvert.DeserializeObject <FilterInfo>(data);
         var        recCt  = IntegrationHandler.GetRecordCount(user, filter);
         return(ApiResponse.JSONSuccess(recCt));
     }
     else
     {
         return(ApiResponse.JSONError(ResponseType.ErrorAuth));
     }
 }
Exemplo n.º 11
0
 public static string EditInvoices(string version, string data)
 {
     if (SiteMaster.VerifyRequest(HttpContext.Current.Session))
     {
         var user = HttpContext.Current.Session[SKeys.User] as User;
         List <IntHeadRecord> updateRecords = JsonConvert.DeserializeObject <List <IntHeadRecord> >(data);
         IntegrationHandler.EditInvoices(user, updateRecords);
         return(ApiResponse.JSONSuccess());
     }
     else
     {
         return(ApiResponse.JSONError(ResponseType.ErrorAuth));
     }
 }
Exemplo n.º 12
0
 public static string GetSendList(string version, string data)
 {
     if (SiteMaster.VerifyRequest(HttpContext.Current.Session))
     {
         var user            = HttpContext.Current.Session[SKeys.User] as User;
         SubmitPreRequest sr = JsonConvert.DeserializeObject <SubmitPreRequest>(data);
         var pr = IntegrationHandler.GetSendRecord(user, sr);
         return(ApiResponse.JSONSuccess(pr));
     }
     else
     {
         return(ApiResponse.JSONError(ResponseType.ErrorAuth));
     }
 }
Exemplo n.º 13
0
        public static string CreateXref(string version, string data)
        {
            if (!SiteMaster.VerifyRequest(HttpContext.Current.Session))
            {
                return(ApiResponse.JSONError(ResponseType.ErrorAuth));
            }

            var user = HttpContext.Current.Session[SKeys.User] as User;

            var xref = JsonConvert.DeserializeObject <XrefRecord>(data);

            CatalogXrefManager.CreateXref(user, xref);

            return(ApiResponse.JSONSuccess());
        }
Exemplo n.º 14
0
        public static string GetXrefList(string version, string data)
        {
            if (!SiteMaster.VerifyRequest(HttpContext.Current.Session))
            {
                return(ApiResponse.JSONError(ResponseType.ErrorAuth));
            }

            var user   = HttpContext.Current.Session[SKeys.User] as User;
            var filter = JsonConvert.DeserializeObject <FilterInfo>(data);

            return(ApiResponse.JSONSuccess(new
            {
                TableState = CreateState(filter),
                TableData = CatalogXrefManager.GetXrefList(user, filter)
            }));
        }
Exemplo n.º 15
0
        public static string InitPoList(string version, string data)
        {
            if (!SiteMaster.VerifyRequest(HttpContext.Current.Session))
            {
                return(ApiResponse.JSONError(ResponseType.ErrorAuth));
            }

            var user   = HttpContext.Current.Session[SKeys.User] as User;
            var opt    = PdsManager.GetOptions(user);
            var filter = CreateFilter();

            return(ApiResponse.JSONSuccess(new
            {
                TableState = CreateState(filter, opt),
                TableData = PdsManager.GetCurrentPoList(user, filter)
            }));
        }
Exemplo n.º 16
0
        public string GetKey(string version, string data)
        {
            HttpSessionState session = HttpContext.Current.Session;

            if (SiteMaster.VerifyRequest(session))
            {
                string key = SiteMaster.AddKey(session);
                return(ApiResponse.JSONSuccess(key));
            }
            else
            {
                return(JsonConvert.SerializeObject(ApiResponse.Error(ResponseType.ErrorAuth), new JsonSerializerSettings()
                {
                    NullValueHandling = NullValueHandling.Ignore
                }));
            }
        }
Exemplo n.º 17
0
 public static string GetPendingList(string version, string data)
 {
     if (SiteMaster.VerifyRequest(HttpContext.Current.Session))
     {
         var        user   = HttpContext.Current.Session[SKeys.User] as User;
         FilterInfo filter = JsonConvert.DeserializeObject <FilterInfo>(data);
         var        list   = IntegrationHandler.GetCurrentInvoices(user, filter);
         return(ApiResponse.JSONSuccess(new
         {
             TableState = CreateState(filter, list.Any(x => x.TransferType == "C")),
             TableData = list
         }));
     }
     else
     {
         return(ApiResponse.JSONError(ResponseType.ErrorAuth));
     }
 }
Exemplo n.º 18
0
        public string ChangePartner(string version, string data)
        {
            HttpSessionState session = HttpContext.Current.Session;

            if (SiteMaster.VerifyRequest(session))
            {
                var user     = session[SKeys.User] as User;
                var attrList = JsonConvert.DeserializeObject <Dictionary <string, string> >(data);
                if (attrList.Count == 0 || !attrList.ContainsKey("PartnerIndex"))
                {
                    return(JsonConvert.SerializeObject(ApiResponse.Error(ResponseType.ErrorGeneralNoPartnerIndex), new JsonSerializerSettings()
                    {
                        NullValueHandling = NullValueHandling.Ignore
                    }));
                }
                int index = -1;
                if (!int.TryParse(attrList["PartnerIndex"], out index))
                {
                    return(JsonConvert.SerializeObject(ApiResponse.Error(ResponseType.ErrorGeneralInvalidPartnerIndex), new JsonSerializerSettings()
                    {
                        NullValueHandling = NullValueHandling.Ignore
                    }));
                }
                if (index < 0 || index >= user.PartnerList.Count)
                {
                    return(JsonConvert.SerializeObject(ApiResponse.Error(ResponseType.ErrorGeneralPartnerIndexOutOfRange), new JsonSerializerSettings()
                    {
                        NullValueHandling = NullValueHandling.Ignore
                    }));
                }
                user.PartnerIndex = index;
                return(JsonConvert.SerializeObject(ApiResponse.Success(), new JsonSerializerSettings()
                {
                    NullValueHandling = NullValueHandling.Ignore
                }));
            }
            else
            {
                return(JsonConvert.SerializeObject(ApiResponse.Error(ResponseType.ErrorAuth), new JsonSerializerSettings()
                {
                    NullValueHandling = NullValueHandling.Ignore
                }));
            }
        }
Exemplo n.º 19
0
 public static string GenerateReport(string version, string data)
 {
     if (SiteMaster.VerifyRequest(HttpContext.Current.Session))
     {
         try
         {
             User user = HttpContext.Current.Session[SKeys.User] as User;
             LocationReportDetails ldr = new LocationReportDetails();
             try
             {
                 ldr = JsonConvert.DeserializeObject <LocationReportDetails>(data);
             }
             catch
             {
                 return(JsonConvert.SerializeObject(ApiResponse.Error(ResponseType.ErrorLOCDateRangeInvalid), serializerSettings));
             }
             string fileToken = "";
             if (ldr.Type == "ASNSummary")
             {
                 fileToken = LocationReportHandler.GenerateASNSummaryReport(user, ldr);
             }
             else
             {
                 fileToken = LocationReportHandler.GenerateLocationReport(user, ldr);
             }
             if (fileToken != "")
             {
                 return(JsonConvert.SerializeObject(ApiResponse.Success(fileToken), serializerSettings));
             }
             else
             {
                 return(JsonConvert.SerializeObject(ApiResponse.Error(ResponseType.ErrorLOCReportGenFailed), serializerSettings));
             }
         }
         catch
         {
             return(JsonConvert.SerializeObject(ApiResponse.Error(ResponseType.ErrorLOCUnknown), serializerSettings));
         }
     }
     else
     {
         return(JsonConvert.SerializeObject(ApiResponse.Error(ResponseType.ErrorAuth), serializerSettings));
     }
 }
Exemplo n.º 20
0
        public static string InitPendingList(string version, string data)
        {
            if (SiteMaster.VerifyRequest(HttpContext.Current.Session))
            {
                var user            = HttpContext.Current.Session[SKeys.User] as User;
                var opt             = IntegrationHandler.GetOptions(user);
                var initialFilter   = CreateFilter();
                var tData           = IntegrationHandler.GetCurrentInvoices(user, initialFilter);
                var hasConsolidated = tData.Any(x => x.TransferType == "C");

                TableState tState = CreateState(initialFilter, hasConsolidated);

                var cOpt = IntegrationHandler.GetCarrierOptions(user);
                return(ApiResponse.JSONSuccess(new
                {
                    TableState = tState,
                    TableData = tData,
                    Options = new
                    {
                        Date = DateTime.Now.ToString("MMM dd yyyy"),
                        Invoice = new
                        {
                            Enabled = opt.IsInvoiceEnabled
                        },
                        Packing = new
                        {
                            Enabled = opt.IsPackingEnabled,
                            IsPP = opt.IsPPEnabled,
                            IsMX = opt.IsMXEnabled,
                            IsDS = opt.IsDSEnabled,
                            Default = opt.BoxOption
                        },
                        Shipping = new
                        {
                            Carriers = cOpt
                        }
                    }
                }));
            }
            else
            {
                return(ApiResponse.JSONError(ResponseType.ErrorAuth));
            }
        }
Exemplo n.º 21
0
 private void Upload_Click(object sender, EventArgs e)
 {
     if (SiteMaster.VerifyRequest(HttpContext.Current.Session))
     {
         try
         {
             User user = Session[SKeys.User] as User;
             if (fileUpload.HasFile)
             {
                 if (fileUpload.PostedFile.ContentLength >= MaxFileSize)
                 {
                     Session[SKeys.UploadResponse] = ApiResponse.JSONError(ResponseType.ErrorUploadFileTooLarge);
                     return;
                 }
                 if (!(SiteFileSystem.IsExtensionAllowed(fileUpload.FileName) && SiteFileSystem.IsContentTypeAllowed(fileUpload.PostedFile.ContentType)))
                 {
                     Session[SKeys.UploadResponse] = ApiResponse.JSONError(ResponseType.ErrorUploadFileFormatNotSupported);
                     return;
                 }
                 string token = Crypt.EncryptStreamToTempFile(user, fileUpload.FileContent);
                 if (string.IsNullOrWhiteSpace(token))
                 {
                     Session[SKeys.UploadResponse] = ApiResponse.JSONError(ResponseType.ErrorUploadUnknown);
                     return;
                 }
                 else
                 {
                     UploadDetail detail = new UploadDetail()
                     {
                         Extension = Path.GetExtension(fileUpload.FileName), Token = token
                     };
                     Session[SKeys.UploadResponse] = ApiResponse.JSONSuccess(detail);
                 }
             }
         }
         catch
         {
             Session[SKeys.UploadResponse] = ApiResponse.JSONError(ResponseType.ErrorUploadUnknown);
         }
     }
 }
Exemplo n.º 22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SiteMaster.SetAppID(AppID.SalesRequest);
            _fetchList = (state) =>
            {
                var user = Session[SKeys.User] as User;

                storeList      = JsonConvert.SerializeObject(SalesRequestManager.GetStoreList(user));
                retailWeekList = JsonConvert.SerializeObject(SalesRequestManager.GetRetailWeeks(user));
                partnerEmail   = user.Email;

                var pastReqs = SalesRequestManager.GetPastOrders(user);
                pastOrderGrid.DataSource = pastReqs;
                pastOrderGrid.DataBind();
                if (pastReqs.Count > 0)
                {
                    pastOrderGrid.HeaderRow.TableSection = System.Web.UI.WebControls.TableRowSection.TableHeader;
                }
            };
            Page.RegisterAsyncTask(new PageAsyncTask((sndr, args, callback, extraData) => { return(_fetchList.BeginInvoke(HttpContext.Current.Session, callback, extraData)); }, empty => { }, empty => { }, null));
        }
Exemplo n.º 23
0
 public static string SendRecords(string version, string data)
 {
     if (SiteMaster.VerifyRequest(HttpContext.Current.Session))
     {
         var user         = HttpContext.Current.Session[SKeys.User] as User;
         var mergeRequest = JsonConvert.DeserializeObject <SubmitRequest>(data);
         try
         {
             var uniqueKeys = IntegrationHandler.SendInvoices(user, mergeRequest);
             return(ApiResponse.JSONSuccess(uniqueKeys));
         }
         catch
         {
             return(ApiResponse.JSONError(ResponseType.ErrorITMInvoiceSendUnknown));
         }
     }
     else
     {
         return(ApiResponse.JSONError(ResponseType.ErrorAuth));
     }
 }
Exemplo n.º 24
0
 public static string UpdateData(string version, string data)
 {
     if (SiteMaster.VerifyRequest(HttpContext.Current.Session))
     {
         var user       = HttpContext.Current.Session[SKeys.User] as User;
         var updateData = JsonConvert.DeserializeObject <UpdateData>(data);
         try
         {
             ItemTable.DoChanges(user, updateData);
         }
         catch
         {
             return(JsonConvert.SerializeObject(ApiResponse.Error(ResponseType.ErrorIDMUnknown), serializerSettings));
         }
         return(JsonConvert.SerializeObject(ApiResponse.Success(), serializerSettings));
     }
     else
     {
         return(JsonConvert.SerializeObject(ApiResponse.Error(ResponseType.ErrorAuth), serializerSettings));
     }
 }
Exemplo n.º 25
0
 public static string SendRequest(string version, string data)
 {
     if (SiteMaster.VerifyRequest(HttpContext.Current.Session))
     {
         var updateData = JsonConvert.DeserializeObject <ReportRequestData>(data);
         var user       = HttpContext.Current.Session[SKeys.User] as User;
         try
         {
             SalesRequestManager.SendRequest(user, updateData);
         }
         catch
         {
             return(JsonConvert.SerializeObject(ApiResponse.Error(ResponseType.ErrorSalesReqUnknown), serializerSettings));
         }
         return(JsonConvert.SerializeObject(ApiResponse.Success(SalesRequestManager.GetPastOrders(user)), serializerSettings));
     }
     else
     {
         return(JsonConvert.SerializeObject(ApiResponse.Error(ResponseType.ErrorAuth), serializerSettings));
     }
 }
Exemplo n.º 26
0
 public static string GetPastRequests(string version, string data)
 {
     if (SiteMaster.VerifyRequest(HttpContext.Current.Session))
     {
         var user    = HttpContext.Current.Session[SKeys.User] as User;
         var trxDict = HttpContext.Current.Session[SKeys.TrxDict] as Dictionary <string, string>;
         var recs    = ProcessQueue.GetPreviousRecords(user);
         foreach (var item in recs)
         {
             if (trxDict.ContainsKey(item.Type))
             {
                 item.Type = trxDict[item.Type];
             }
         }
         return(ApiResponse.JSONSuccess(recs));
     }
     else
     {
         return(ApiResponse.JSONError(ResponseType.ErrorAuth));
     }
 }
Exemplo n.º 27
0
        private const int MaxFileSize = 2 * 1024 * 1024; // 2 MB

        protected void Page_Load(object sender, EventArgs e)
        {
            if (SiteMaster.VerifyRequest(Session))
            {
                if (!IsPostBack)
                {
                    if (!Page.RouteData.Values.ContainsKey("key"))
                    {
                        Response.Redirect(SiteMaster.Path404);
                    }
                    if (!SiteMaster.IsKeyGood(Session, Page.RouteData.Values["key"] as string))
                    {
                        Response.Redirect(SiteMaster.Path404);
                    }
                }
                submitButton.ServerClick += new EventHandler(Upload_Click);
            }
            else
            {
                Response.Redirect(SiteMaster.Path404);
            }
        }
Exemplo n.º 28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SiteMaster.SetAppID(AppID.None);
            if (SiteMaster.VerifyRequest(HttpContext.Current.Session))
            {
                User user = Session[SKeys.User] as User;
                switch (Page.RouteData.Values[qsType] as string)
                {
                case typeDownload:
                    DownloadFile(user, Page.RouteData.Values[qsFile] as string);
                    break;

                case typeTemporary:
                    DownloadTemp(user, Page.RouteData.Values[qsFile] as string, Page.RouteData.Values[qsToken] as string);
                    break;

                case typeGeneral:
                    DownloadDoc(user, Page.RouteData.Values[qsFile] as string);
                    break;

                case typeTemplate:
                    DownloadTemplate(user, Page.RouteData.Values[qsFile] as string);
                    break;

                case typeSpec:
                    DownloadSpec(user, Page.RouteData.Values[qsFile] as string);
                    break;

                default:
                    Response.Redirect(SiteMaster.Path404);
                    break;
                }
            }
            else
            {
                Response.Redirect(SiteMaster.Path404);
            }
        }
Exemplo n.º 29
0
 public static string GetTemplateLink(string version, string data)
 {
     if (SiteMaster.VerifyRequest(HttpContext.Current.Session))
     {
         var    user       = HttpContext.Current.Session[SKeys.User] as User;
         var    isTest     = (bool?)HttpContext.Current.Session[SKeys.IsTest] == true;
         string tplPath    = SiteFileSystem.GetTemplateDocFilePath(user, isTest, "855.xlsx");
         string linkReturn = "";
         if (tplPath != "")
         {
             linkReturn = "doc/template/855.xlsx";
         }
         else
         {
             linkReturn = "";
         }
         return(ApiResponse.JSONSuccess(linkReturn));
     }
     else
     {
         return(ApiResponse.JSONError(ResponseType.ErrorAuth));
     }
 }
Exemplo n.º 30
0
 public static string EditFilteredInvoices(string version, string data)
 {
     if (SiteMaster.VerifyRequest(HttpContext.Current.Session))
     {
         var user = HttpContext.Current.Session[SKeys.User] as User;
         var pack = JObject.Parse(data);
         if (pack["filter"] != null && pack["data"] != null)
         {
             FilterInfo    filter = JsonConvert.DeserializeObject <FilterInfo>(pack["filter"].ToString());
             IntHeadRecord ihr    = JsonConvert.DeserializeObject <IntHeadRecord>(pack["data"].ToString());
             IntegrationHandler.EditFilteredInvoices(user, filter, ihr);
             return(ApiResponse.JSONSuccess());
         }
         else
         {
             return(ApiResponse.JSONError(ResponseType.ErrorITMInvoiceSendUnknown));
         }
     }
     else
     {
         return(ApiResponse.JSONError(ResponseType.ErrorAuth));
     }
 }