示例#1
0
        public void DownloadJson(clsJSONOffline JSONOffline)
        {
            try
            {
                var          json          = new JavaScriptSerializer().Serialize(JSONOffline);
                StringWriter oStringWriter = new StringWriter();
                Response.ContentType = "text/plain";

                Response.AddHeader("content-disposition", "attachment;filename=data.json");
                Response.Clear();

                using (StreamWriter writer = new StreamWriter(Response.OutputStream, Encoding.UTF8))
                {
                    writer.Write(json);
                }
                Response.End();
            }
            catch (Exception ex)
            {
                cls_ErrorLog ob = new cls_ErrorLog();
                cls_ErrorLog.LogError(ex, Common.LoggedInUserID());
            }
        }
示例#2
0
        public void generateJson(Int16 getMonth)
        {
            try
            {
                var            gstin       = Common.GetCurrentGSTIN();
                var            userid      = Common.LoggedInUserID();
                var            data        = unitOfWork.OfflineinvoiceRepository.Filter(x => x.UserID == userid && x.GST_TRN_OFFLINE.Month == getMonth);
                clsJSONOffline JSONOffline = new clsJSONOffline();
                JSONOffline.gstin   = gstin;
                JSONOffline.hash    = "hash";
                JSONOffline.gt      = 0;
                JSONOffline.cur_gt  = 0;
                JSONOffline.fp      = DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString();
                JSONOffline.version = "GST2.0";
                JSONOffline.b2b     = new List <B2b>();
                JSONOffline.b2cl    = new List <B2cl>();
                JSONOffline.b2cs    = new List <B2cs>();
                JSONOffline.cdnr    = new List <Cdnr>();
                JSONOffline.cdnur   = new List <Cdnur>();
                JSONOffline.exp     = new List <Exp>();
                JSONOffline.at      = new List <At>();

                JSONOffline.txpd = new List <Txpd>();
                var B2Bs = data.Where(x => x.SectionType == (byte)EnumConstants.OfflineSection.B2B);
                foreach (var B2B in B2Bs)
                {
                    JSONOffline.b2b.Add(GetB2b(B2B));
                }

                var b2cldatas = data.Where(x => x.SectionType == (byte)EnumConstants.OfflineSection.B2CL);
                foreach (var b2cldata in b2cldatas)
                {
                    JSONOffline.b2cl.Add(GetB2cl(b2cldata));
                }

                var b2csdatas = data.Where(x => x.SectionType == (byte)EnumConstants.OfflineSection.B2CS);
                foreach (var b2csdata in b2csdatas)
                {
                    JSONOffline.b2cs.Add(GetB2cs(b2csdata));
                }

                var expdatas = data.Where(x => x.SectionType == (byte)EnumConstants.OfflineSection.EXP);
                foreach (var expdata in expdatas)
                {
                    JSONOffline.exp.Add(GetExpData(expdata));
                }


                var ats = data.Where(x => x.SectionType == (byte)EnumConstants.OfflineSection.AT);
                foreach (var at in ats)
                {
                    JSONOffline.at.Add(Getatsdata(at));
                }

                var cdnrdatas = data.Where(x => x.SectionType == (byte)EnumConstants.OfflineSection.CDNR);
                foreach (var cdnrdata in cdnrdatas)
                {
                    JSONOffline.cdnr.Add(Getcdnrdata(cdnrdata));
                }

                var cdnurdatas = data.Where(x => x.SectionType == (byte)EnumConstants.OfflineSection.CDNUR);
                foreach (var cdnur in cdnurdatas)
                {
                    JSONOffline.cdnur.Add(Getcdnurdata(cdnur));
                }
                var hsndatas = data.Where(x => x.SectionType == (byte)EnumConstants.OfflineSection.HSN).ToList();
                JSONOffline.hsn = Gethsndata(hsndatas);

                var txpddatas = data.Where(x => x.SectionType == (byte)EnumConstants.OfflineSection.MASTER);
                foreach (var txpddata in txpddatas)
                {
                    JSONOffline.txpd.Add(Gettxpdata(txpddata));
                }


                DownloadJson(JSONOffline);
            }
            catch (Exception ex)
            {
                cls_ErrorLog ob = new cls_ErrorLog();
                cls_ErrorLog.LogError(ex, Common.LoggedInUserID());
            }
        }