Esempio n. 1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="entityKey"></param>
 public static void Delete(int entityKey)
 {
     using (var context = new EntitiesContext())
     {
         DAL.PortalAlia r = context.PortalAlias.Single(p => p.PortalAliasID == entityKey);
         context.DeleteObject(r);
         context.SaveChanges();
     }
 }
Esempio n. 2
0
        public static void InsertLog(int _ClientHeight, int _ClientWidth, string _FileName, bool _Ajax)
        {
            try
            {

                string _Host = HttpContext.Current.Request.Url.Host;

                int _UserID = 0;
                HttpBrowserCapabilities r = HttpContext.Current.Request.Browser;
                if (HttpContext.Current.Session["UserID"] != null)
                {
                    _UserID = (int)HttpContext.Current.Session["UserID"];
                }
                using (EntitiesContext context = new EntitiesContext())
                {
                    DAL.SiteLog L = new DAL.SiteLog
                    {
                        PortalID = SiteLog.PortalID,
                        CreateDate = DateTime.Now,
                        UserID = _UserID,
                        Ajax = _Ajax,
                        Host = _Host,
                        FileName = _FileName.Replace("ACTION=", "/"),
                        RequestRequestType = HttpContext.Current.Request.RequestType,
                        RequestUserHostAddress = HttpContext.Current.Request.UserHostAddress,
                        RequestUserHostName = HttpContext.Current.Request.UserHostName,
                        RequestHttpMethod = HttpContext.Current.Request.HttpMethod,
                        ClientHeight = _ClientHeight,
                        ClientWidth = _ClientWidth,
                        Browser = r.Browser,
                        BrowserType = r.Type,
                        BrowserVersion = decimal.Parse(r.Version),
                        BrowserMajorVersion = r.MajorVersion,
                        BrowserPlatform = r.Platform,
                        BrowserCrawler = r.Crawler,
                        BrowserFrames = r.Frames,
                        BrowserTables = r.Tables,
                        BrowserCookies = r.Cookies,
                        BrowserVBScript = r.VBScript,
                        BrowserEcmaScriptVersion = decimal.Parse(r.EcmaScriptVersion.ToString()),
                        BrowserJavaApplets = r.JavaApplets,
                        BrowserActiveXControls = r.ActiveXControls,
                        BrowserJavaScriptVersion = decimal.Parse(r["JavaScriptVersion"])
                    };
                    context.SiteLogs.AddObject(L);
                    context.SaveChanges();
                }

            }
            catch (Exception ex)
            {
                ElmahExtension.LogToElmah(ex);
            }
        }
Esempio n. 3
0
        public void UpdateItemPath(string path, string newName, int newParentId)
        {
            int fileID = GetItemId(path);
            if (fileID < 0)
            {
                return;
            }

            using (EntitiesContext context = new EntitiesContext())
            {
                //var I = context.ContentFiles.FirstOrDefault(i => i.FileID == fileID & i.PortalID == Portals.PortalID);
                var I = context.ContentFiles.FirstOrDefault(i => i.FileID == fileID);
                I.Name = newName;
                I.ParentID = newParentId;
                context.SaveChanges();
            }

            _data = null;
        }
Esempio n. 4
0
        public void ReplaceItemContent(string path, byte[] content)
        {
            int fileID = GetItemId(path);
            if (fileID < 0)
            {
                return;
            }

            using (EntitiesContext context = new EntitiesContext())
            {
                //var I = context.ContentFiles.FirstOrDefault(i => i.FileID == fileID & i.PortalID == Portals.PortalID);
                var I = context.ContentFiles.FirstOrDefault(i => i.FileID == fileID);
                I.FileContent = content;
                context.SaveChanges();
            }
        }
Esempio n. 5
0
        public void DeleteItem(string path)
        {
            //TODO: cascade delete when removing a non-empty folder
            int itemId = GetItemId(path);
            if (itemId <= 0)
            {
                return;
            }

            using (EntitiesContext context = new EntitiesContext())
            {
                //dynamic I = context.ContentFiles.FirstOrDefault(i => i.FileID == itemId & i.PortalID == Portals.PortalID);
                dynamic I = context.ContentFiles.FirstOrDefault(i => i.FileID == itemId);
                context.ContentFiles.DeleteObject(I);
                context.SaveChanges();
            }

            _data = null;
        }
Esempio n. 6
0
        public void CreateItem(string name, string path, string mimeType, bool isDirectory, long size, byte[] content)
        {
            int parentId = GetItemId(path);
            if (parentId < 0)
            {
                return;
            }

            using (EntitiesContext context = new EntitiesContext())
            {
                ContentFile I = new ContentFile
                {
                    Name = name,
                    ParentID = parentId,
                    MimeType = mimeType,
                    IsDirectory = isDirectory,
                    Size = int.Parse(size.ToString()),
                    FileContent = content,
                    PortalID = this.PortalID
                };
                context.ContentFiles.AddObject(I);
                context.SaveChanges();
            }

            _data = null;
        }
Esempio n. 7
0
        public static void InsertResponse(string ResponseIN)
        {
            if (ConfigurationManager.AppSettings.Get("PayPalSubmitUrl") != null)
            {

                try
                {
                    string Environment = null;

                    if (ConfigurationManager.AppSettings.Get("PayPalSubmitUrl") == "https://www.sandbox.paypal.com/cgi-bin/webscr")
                    {
                        Environment = "PayPalSandBox";
                    }

                    if (ConfigurationManager.AppSettings.Get("PayPalSubmitUrl") == "https://www.paypal.com/cgi-bin/webscr")
                    {
                        Environment = "PayPalProduction";
                    }

                    using (EntitiesContext context = new EntitiesContext())
                    {
                        DAL.IPN I = new DAL.IPN
                        {
                            CreateDate = DateTime.Now,
                            Environment = Environment,
                            ResponseIN = ResponseIN
                        };
                        context.IPNs.AddObject(I);
                        context.SaveChanges();
                        ParseResponse(ResponseIN, I.IPNID);
                    }
                }
                catch (Exception ex)
                {
                    ElmahExtension.LogToElmah(ex);
                }
            }
            else
            {
                ElmahExtension.LogToElmah(new ApplicationException("Unable to read the value PayPalSubmitUrl in web.config file"));
            }
        }
Esempio n. 8
0
        public static void ParseResponse(string ResponseIN, int IPNID)
        {
            NameValueCollection PayPal_Args = HttpUtility.ParseQueryString(ResponseIN);

            using (EntitiesContext context = new EntitiesContext())
            {
                var i = context.IPNs.FirstOrDefault(s => s.IPNID == IPNID);

                if (i != null)
                {

                    if (PayPal_Args["txn_id"] != null)
                    {
                        i.txn_id = PayPal_Args["txn_id"];
                    }

                    if (PayPal_Args["mc_gross"] != null)
                    {
                        i.mc_gross = decimal.Parse(PayPal_Args["mc_gross"]);
                    }

                    if (PayPal_Args["tax"] != null)
                    {
                        i.tax = decimal.Parse(PayPal_Args["tax"]);
                    }

                    if (PayPal_Args["protection_eligibility"] != null)
                    {
                        i.protection_eligibility = PayPal_Args["protection_eligibility"];
                    }

                    if (PayPal_Args["address_status"] != null)
                    {
                        i.address_status = PayPal_Args["address_status"];
                    }

                    if (PayPal_Args["payer_id"] != null)
                    {
                        i.payer_id = PayPal_Args["payer_id"];
                    }

                    if (PayPal_Args["first_name"] != null)
                    {
                        i.first_name = PayPal_Args["first_name"];
                    }

                    if (PayPal_Args["last_name"] != null)
                    {
                        i.last_name = PayPal_Args["last_name"];
                    }

                    if (PayPal_Args["address_street"] != null)
                    {
                        i.address_street = PayPal_Args["address_street"];
                    }

                    if (PayPal_Args["payment_date"] != null)
                    {
                        i.payment_date = PayPal_Args["payment_date"];
                    }

                    if (PayPal_Args["payment_status"] != null)
                    {
                        i.payment_status = PayPal_Args["payment_status"];
                    }

                    if (PayPal_Args["charset"] != null)
                    {
                        i.charset = PayPal_Args["charset"];
                    }

                    if (PayPal_Args["address_zip"] != null)
                    {
                        i.address_zip = int.Parse(PayPal_Args["address_zip"]);
                    }

                    if (PayPal_Args["mc_fee"] != null)
                    {
                        i.mc_fee = decimal.Parse(PayPal_Args["mc_fee"]);
                    }

                    if (PayPal_Args["address_country_code"] != null)
                    {
                        i.address_country_code = PayPal_Args["address_country_code"];
                    }

                    if (PayPal_Args["address_name"] != null)
                    {
                        i.address_name = PayPal_Args["address_name"];
                    }

                    if (PayPal_Args["notify_version"] != null)
                    {
                        i.notify_version = decimal.Parse(PayPal_Args["notify_version"]);
                    }

                    if (PayPal_Args["custom"] != null)
                    {
                        i.custom = PayPal_Args["custom"];
                    }

                    if (PayPal_Args["payer_status"] != null)
                    {
                        i.payer_status = PayPal_Args["payer_status"];
                    }

                    if (PayPal_Args["business"] != null)
                    {
                        i.business = PayPal_Args["business"];
                    }

                    if (PayPal_Args["address_country"] != null)
                    {
                        i.address_country = PayPal_Args["address_country"];
                    }

                    if (PayPal_Args["address_city"] != null)
                    {
                        i.address_city = PayPal_Args["address_city"];
                    }

                    if (PayPal_Args["quantity"] != null)
                    {
                        i.quantity = int.Parse(PayPal_Args["quantity"]);
                    }

                    if (PayPal_Args["verify_sign"] != null)
                    {
                        i.verify_sign = PayPal_Args["verify_sign"];
                    }

                    if (PayPal_Args["payer_email"] != null)
                    {
                        i.payer_email = PayPal_Args["payer_email"];
                    }

                    if (PayPal_Args["payment_type"] != null)
                    {
                        i.payment_type = PayPal_Args["payment_type"];
                    }

                    if (PayPal_Args["address_state"] != null)
                    {
                        i.address_state = PayPal_Args["address_state"];
                    }

                    if (PayPal_Args["receiver_email"] != null)
                    {
                        i.receiver_email = PayPal_Args["receiver_email"];
                    }

                    if (PayPal_Args["payment_fee"] != null)
                    {
                        i.payment_fee = decimal.Parse(PayPal_Args["payment_fee"]);
                    }

                    if (PayPal_Args["receiver_id"] != null)
                    {
                        i.receiver_id = PayPal_Args["receiver_id"];
                    }

                    if (PayPal_Args["txn_type"] != null)
                    {
                        i.txn_type = PayPal_Args["txn_type"];
                    }

                    if (PayPal_Args["item_name"] != null)
                    {
                        i.item_name = PayPal_Args["item_name"];
                    }

                    if (PayPal_Args["mc_currency"] != null)
                    {
                        i.mc_currency = PayPal_Args["mc_currency"];
                    }

                    if (PayPal_Args["item_number"] != null)
                    {
                        i.item_number = PayPal_Args["item_number"];
                    }

                    if (PayPal_Args["residence_country"] != null)
                    {
                        i.residence_country = PayPal_Args["residence_country"];
                    }

                    if (PayPal_Args["test_ipn"] != null)
                    {
                        i.test_ipn = PayPal_Args["test_ipn"];
                    }

                    if (PayPal_Args["handling_amount"] != null)
                    {
                        i.handling_amount = decimal.Parse(PayPal_Args["handling_amount"]);
                    }

                    if (PayPal_Args["transaction_subject"] != null)
                    {
                        i.transaction_subject = PayPal_Args["transaction_subject"];
                    }

                    if (PayPal_Args["payment_gross"] != null)
                    {
                        i.payment_gross = decimal.Parse(PayPal_Args["payment_gross"]);
                    }

                    if (PayPal_Args["shipping"] != null)
                    {
                        i.shipping = decimal.Parse(PayPal_Args["shipping"]);
                    }

                    if (PayPal_Args["ipn_track_id"] != null)
                    {
                        i.ipn_track_id = PayPal_Args["ipn_track_id"];
                    }

                    try
                    {
                        i.LastUpdated = DateTime.Now;
                        i.ResponseParsed = true;
                        context.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        i.ResponseParsed = false;
                        context.SaveChanges();
                        ElmahExtension.LogToElmah(ex);
                    }

                }

            }
        }
Esempio n. 9
0
 public static void InsertResult(int _QuestionID, int _AnswerID, int _UserID, string _AnswerText, int _ResultID)
 {
     using (EntitiesContext context = new EntitiesContext())
     {
         SurveyResultItem r = new SurveyResultItem
         {
             ResultID = _ResultID,
             QuestionID = _QuestionID,
             AnswerID = _AnswerID,
             UserID = _UserID,
             AnswerText = _AnswerText,
             PortalID = ResultItems.PortalID
         };
         context.SurveyResultItems.AddObject(r);
         context.SaveChanges();
     }
 }
Esempio n. 10
0
 /// <summary>
 /// Updates a PortalAlias entity by its entiy key using a hashtable of values.
 /// </summary>
 /// <param name="entityKey">The entity key of the PortalAlias entity</param>
 /// <param name="values">A hashtable of values</param>
 public static void Update(int entityKey, Hashtable values)
 {
     using (var context = new EntitiesContext())
     {
         DAL.PortalAlia r = context.PortalAlias.Single(p => p.PortalAliasID == entityKey);
         r.PortalID = int.Parse(values["PortalID"].ToString());
         r.HTTPAlias = values["HTTPAlias"].ToString();
         r.LastUpdated = DateTime.Now;
         r.LastModifiedByUserID = (int)HttpContext.Current.Session["UserID"];
         context.SaveChanges();
     }
 }
Esempio n. 11
0
 /// <summary>
 /// Uses a hashtable of values to create and insert a new PortalAlias entity into the database
 /// </summary>
 /// <param name="values">The hashtable</param>
 public static void Insert(Hashtable values)
 {
     using (var context = new EntitiesContext())
     {
         DAL.PortalAlia r = new DAL.PortalAlia
         {
             CreateDate = DateTime.Now,
             PortalID = int.Parse(values["PortalID"].ToString()),
             HTTPAlias = values["HTTPAlias"].ToString(),
             LastModifiedByUserID = (Int32)HttpContext.Current.Session["UserID"]
         };
         context.AddToPortalAlias(r);
         context.SaveChanges();
     }
 }